5858#define MBIT_OFFSET 0x0d
5959#define RATE_SELECT 0x02
6060
61+ /* Macro for Multirate Bit*/
62+ #define SET_RATE_SELECT_BIT (x ,RS_BIT_pos ) (x | (1<<RS_BIT_pos))
63+ #define RESET_RATE_SELECT_BIT (x ,RS_BIT_pos ) (x & ~(1<<RS_BIT_pos))
6164
6265#define NUM_OF_SFP_PORT 28
6366static const int port_bus_index [NUM_OF_SFP_PORT ] = {
285288onlp_sfpi_control_set (int port , onlp_sfp_control_t control , int value )
286289{
287290 int present = 0 ;
288- int mbit_identifier = 0 ;
291+ int mbit_identifier ;
292+ int mbit_value ;
289293 switch (control ) {
290294 case ONLP_SFP_CONTROL_TX_DISABLE : {
291295 VALIDATE_SFP (port );
@@ -324,12 +328,28 @@ onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value)
324328 present = onlp_sfpi_is_present (port );
325329 if (present == 1 ) {
326330 mbit_identifier = onlp_sfpi_dev_readb (port , MBIT_IDENTIFIER_ADDR , MBIT_OFFSET );
327- if (mbit_identifier == RATE_SELECT ) {
328- onlp_sfpi_dev_writeb (port , PORT_EEPROM_DEVADDR , MULTIRATE_OFFSET , value );
329- return ONLP_STATUS_OK ;
331+ if (mbit_identifier == RATE_SELECT ) {
332+ mbit_value = onlp_sfpi_dev_readb (port , PORT_EEPROM_DEVADDR , MULTIRATE_OFFSET );
333+ if (value == 0x0 ) {
334+ mbit_value = RESET_RATE_SELECT_BIT (mbit_value ,3 );
335+ if (onlp_sfpi_dev_writeb (port , PORT_EEPROM_DEVADDR , MULTIRATE_OFFSET , mbit_value ) < 0 ){
336+ AIM_LOG_ERROR ("Unable to write multirate status to port(%d)\r\n" , port );
337+ return ONLP_STATUS_E_INTERNAL ;
338+ }
339+ return ONLP_STATUS_OK ;
340+ }
341+ else if (value == 0x1 ) {
342+ mbit_value = SET_RATE_SELECT_BIT (mbit_value ,3 );
343+ if (onlp_sfpi_dev_writeb (port , PORT_EEPROM_DEVADDR , MULTIRATE_OFFSET , mbit_value ) < 0 ){
344+ AIM_LOG_ERROR ("Unable to write multirate status to port(%d)\r\n" , port );
345+ return ONLP_STATUS_E_INTERNAL ;
346+ }
347+ return ONLP_STATUS_OK ;
348+ }
349+ return ONLP_STATUS_E_INTERNAL ;
330350 }
331351 else {
332- AIM_LOG_ERROR ("Unable to write multirate status to port(%d)\r\n" , port );
352+ AIM_LOG_ERROR ("Unable to support multirate for the port(%d)\r\n" , port );
333353 return ONLP_STATUS_E_UNSUPPORTED ;
334354 }
335355 }
@@ -350,7 +370,7 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value)
350370{
351371 int present = 0 ;
352372 int multirate = 0 ;
353- int mbit_identifier = 0 ;
373+ int mbit_identifier ;
354374 switch (control ) {
355375 case ONLP_SFP_CONTROL_RX_LOS : {
356376 VALIDATE_SFP (port );
@@ -412,16 +432,20 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value)
412432 mbit_identifier = onlp_sfpi_dev_readb (port , MBIT_IDENTIFIER_ADDR , MBIT_OFFSET );
413433 if (mbit_identifier == RATE_SELECT ) {
414434 multirate = onlp_sfpi_dev_readb (port , PORT_EEPROM_DEVADDR , MULTIRATE_OFFSET );
415- * value = multirate ;
416- return ONLP_STATUS_OK ;
435+ if (multirate < 0 ) {
436+ return ONLP_STATUS_E_INTERNAL ;
437+ }
438+ else {
439+ * value = multirate ;
440+ return ONLP_STATUS_OK ;
441+ }
417442 }
418443 else {
419444 AIM_LOG_ERROR ("Unable to read multirate status from port(%d)\r\n" , port );
420445 return ONLP_STATUS_E_UNSUPPORTED ;
421446 }
422447 }
423448 else {
424- AIM_LOG_ERROR ("Unable to read multirate status from port(%d)\r\n" , port );
425449 return ONLP_STATUS_E_INTERNAL ;
426450 }
427451 }
0 commit comments