Skip to content

Commit d0fcd47

Browse files
authored
Merge pull request #986 from muthukumars-arrcus/soft_select
Enhanced sfpi.c for AS7535-28XB-O-AC-F to support ONLP_SFP_CONTROL for 'Soft Rate_Select Select'
2 parents ad40508 + f664022 commit d0fcd47

1 file changed

Lines changed: 78 additions & 0 deletions

File tree

  • packages/platforms/accton/x86-64/as7535-28xb/onlp/builds/x86_64_accton_as7535_28xb/module/src

packages/platforms/accton/x86-64/as7535-28xb/onlp/builds/x86_64_accton_as7535_28xb/module/src/sfpi.c

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@
5151
#define MODULE_PRESENT_ALL_ATTR "/sys/bus/i2c/devices/12-0061/module_present_all"
5252
#define MODULE_RXLOS_ALL_ATTR "/sys/bus/i2c/devices/12-0061/module_rx_los_all"
5353

54+
/* Definitions for Soft_Rate_Select*/
55+
#define PORT_EEPROM_DEVADDR 0X51
56+
#define MULTIRATE_OFFSET 0x6E
57+
#define MBIT_IDENTIFIER_ADDR 0x50
58+
#define MBIT_OFFSET 0x0d
59+
#define RATE_SELECT 0x02
60+
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))
64+
5465
#define NUM_OF_SFP_PORT 28
5566
static const int port_bus_index[NUM_OF_SFP_PORT] = {
5667
23, 21, 24, 22, 25, 26, 27, 28, 29, 30,
@@ -276,6 +287,9 @@ onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value)
276287
int
277288
onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value)
278289
{
290+
int present = 0;
291+
int mbit_identifier;
292+
int mbit_value;
279293
switch(control) {
280294
case ONLP_SFP_CONTROL_TX_DISABLE: {
281295
VALIDATE_SFP(port);
@@ -308,6 +322,42 @@ onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value)
308322
return ONLP_STATUS_OK;
309323
}
310324
}
325+
case ONLP_SFP_CONTROL_SOFT_RATE_SELECT: {
326+
VALIDATE_SFP(port);
327+
328+
present = onlp_sfpi_is_present(port);
329+
if (present == 1) {
330+
mbit_identifier = onlp_sfpi_dev_readb(port, MBIT_IDENTIFIER_ADDR, MBIT_OFFSET);
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;
350+
}
351+
else {
352+
AIM_LOG_ERROR("Unable to support multirate for the port(%d)\r\n", port);
353+
return ONLP_STATUS_E_UNSUPPORTED;
354+
}
355+
}
356+
else {
357+
AIM_LOG_ERROR("Unable to write multirate status to port(%d)\r\n", port);
358+
return ONLP_STATUS_E_INTERNAL;
359+
}
360+
}
311361
default:
312362
break;
313363
}
@@ -318,6 +368,9 @@ onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value)
318368
int
319369
onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value)
320370
{
371+
int present = 0;
372+
int multirate = 0;
373+
int mbit_identifier;
321374
switch(control) {
322375
case ONLP_SFP_CONTROL_RX_LOS: {
323376
VALIDATE_SFP(port);
@@ -371,6 +424,31 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value)
371424

372425
return ONLP_STATUS_OK;
373426
}
427+
case ONLP_SFP_CONTROL_SOFT_RATE_SELECT: {
428+
VALIDATE_SFP(port);
429+
430+
present = onlp_sfpi_is_present(port);
431+
if(present == 1) {
432+
mbit_identifier = onlp_sfpi_dev_readb(port, MBIT_IDENTIFIER_ADDR, MBIT_OFFSET);
433+
if(mbit_identifier == RATE_SELECT) {
434+
multirate = onlp_sfpi_dev_readb(port, PORT_EEPROM_DEVADDR, MULTIRATE_OFFSET);
435+
if (multirate < 0) {
436+
return ONLP_STATUS_E_INTERNAL;
437+
}
438+
else{
439+
*value = multirate;
440+
return ONLP_STATUS_OK;
441+
}
442+
}
443+
else {
444+
AIM_LOG_ERROR("Unable to read multirate status from port(%d)\r\n", port);
445+
return ONLP_STATUS_E_UNSUPPORTED;
446+
}
447+
}
448+
else {
449+
return ONLP_STATUS_E_INTERNAL;
450+
}
451+
}
374452
default:
375453
break;
376454
}

0 commit comments

Comments
 (0)