Skip to content

Commit 5ca3163

Browse files
committed
[Edgecore][AS4630-54TE] Add controlling function of QSFP Tx disable
1. Add controlling function of QSFP Tx disable 2. To get and set qsfp tx disable by accessing qsfp eeprom Signed-off-by: willy_liu <willy_liu@edge-core.com>
1 parent 784b985 commit 5ca3163

File tree

1 file changed

+70
-11
lines changed
  • packages/platforms/accton/x86-64/as4630-54te/onlp/builds/x86_64_accton_as4630_54pe/module/src

1 file changed

+70
-11
lines changed

packages/platforms/accton/x86-64/as4630-54te/onlp/builds/x86_64_accton_as4630_54pe/module/src/sfpi.c

Lines changed: 70 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
#define MODULE_LPMODE_FORMAT "/sys/bus/i2c/devices/3-0060/module_lpmode_%d"
3939
#define MODULE_PRESENT_ALL_ATTR "/sys/bus/i2c/devices/3-0060/module_present_all"
4040
#define MODULE_RXLOS_ALL_ATTR "/sys/bus/i2c/devices/3-0060/module_rx_los_all"
41+
/* QSFP device address of eeprom */
42+
#define PORT_EEPROM_DEVADDR 0x50
43+
/* QSFP tx disable offset */
44+
#define QSFP_EEPROM_OFFSET_TXDIS 0x56
4145

4246
int port_bus_index[] = { 18, 19, 20, 21, 22, 23 };
4347
#define PORT_BUS_INDEX(port) (port_bus_index[port-48])
@@ -281,16 +285,43 @@ onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value)
281285
int
282286
onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value)
283287
{
288+
int present = 0;
289+
284290
switch(control) {
285291
case ONLP_SFP_CONTROL_TX_DISABLE: {
286-
VALIDATE_SFP(port);
287-
288-
if (onlp_file_write_int(value, MODULE_TXDISABLE_FORMAT, (port+1)) < 0) {
289-
AIM_LOG_ERROR("Unable to set tx_disable status to port(%d)\r\n", port);
292+
VALIDATE(port);
293+
if (port >= 48 && port < 52)
294+
{
295+
if (onlp_file_write_int(value, MODULE_TXDISABLE_FORMAT, (port+1)) < 0) {
296+
AIM_LOG_ERROR("Unable to set tx_disable status to port(%d)\r\n", port);
297+
return ONLP_STATUS_E_INTERNAL;
298+
}
299+
300+
return ONLP_STATUS_OK;
301+
}
302+
else if(port >= 52 && port <= 53)
303+
{
304+
present = onlp_sfpi_is_present(port);
305+
if(present == 1)
306+
{
307+
/* txdis valid bit(bit0-bit3), xxxx 1111 */
308+
value = value&0xf;
309+
310+
onlp_sfpi_dev_writeb(port, PORT_EEPROM_DEVADDR, QSFP_EEPROM_OFFSET_TXDIS, value);
311+
312+
return ONLP_STATUS_OK;
313+
}
314+
else
315+
{
316+
return ONLP_STATUS_E_INTERNAL;
317+
}
318+
}
319+
else
320+
{
290321
return ONLP_STATUS_E_INTERNAL;
291322
}
292323

293-
return ONLP_STATUS_OK;
324+
return ONLP_STATUS_E_INTERNAL;
294325
}
295326
case ONLP_SFP_CONTROL_RESET: {
296327
VALIDATE_QSFP(port);
@@ -322,6 +353,9 @@ onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value)
322353
int
323354
onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value)
324355
{
356+
int present = 0;
357+
int tx_dis = 0;
358+
325359
switch(control) {
326360
case ONLP_SFP_CONTROL_RX_LOS: {
327361
VALIDATE_SFP(port);
@@ -336,7 +370,6 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value)
336370

337371
case ONLP_SFP_CONTROL_TX_FAULT: {
338372
VALIDATE_SFP(port);
339-
340373
if (onlp_file_read_int(value, MODULE_TXFAULT_FORMAT, (port+1)) < 0) {
341374
AIM_LOG_ERROR("Unable to read tx_fault status from port(%d)\r\n", port);
342375
return ONLP_STATUS_E_INTERNAL;
@@ -346,14 +379,40 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value)
346379
}
347380

348381
case ONLP_SFP_CONTROL_TX_DISABLE: {
349-
VALIDATE_SFP(port);
350-
351-
if (onlp_file_read_int(value, MODULE_TXDISABLE_FORMAT, (port+1)) < 0) {
352-
AIM_LOG_ERROR("Unable to read tx_disabled status from port(%d)\r\n", port);
382+
VALIDATE(port);
383+
if (port >= 48 && port < 52)
384+
{
385+
if (onlp_file_read_int(value, MODULE_TXDISABLE_FORMAT, (port+1)) < 0) {
386+
AIM_LOG_ERROR("Unable to read tx_disabled status from port(%d)\r\n", port);
387+
return ONLP_STATUS_E_INTERNAL;
388+
}
389+
390+
return ONLP_STATUS_OK;
391+
}
392+
else if(port >= 52 && port <= 53)
393+
{
394+
present = onlp_sfpi_is_present(port);
395+
if(present == 1)
396+
{
397+
tx_dis = onlp_sfpi_dev_readb(port, PORT_EEPROM_DEVADDR, QSFP_EEPROM_OFFSET_TXDIS);
398+
399+
*value = tx_dis;
400+
401+
return ONLP_STATUS_OK;
402+
403+
}
404+
else
405+
{
406+
return ONLP_STATUS_E_INTERNAL;
407+
}
408+
}
409+
else
410+
{
353411
return ONLP_STATUS_E_INTERNAL;
354412
}
355413

356-
return ONLP_STATUS_OK;
414+
415+
return ONLP_STATUS_E_INTERNAL;
357416
}
358417
case ONLP_SFP_CONTROL_RESET: {
359418
VALIDATE_QSFP(port);

0 commit comments

Comments
 (0)