52
52
OFFSET_INTERNAL_VOLTAGE = 26
53
53
OFFSET_NIC_TEMPERATURE = 727
54
54
OFFSET_NIC_VOLTAGE = 729
55
+ OFFSET_ENABLE_AUTO_SWITCH = 651
55
56
56
57
# definitions of targets for getting the cursor
57
58
# equalization parameters from the register spec
91
92
92
93
MAX_NUM_LANES = 4
93
94
95
+ # switching modes inside muxcable
96
+ SWITCHING_MODE_MANUAL = 0
97
+ SWITCHING_MODE_AUTO = 1
98
+
94
99
# Valid return codes for upgrade firmware routine steps
95
100
FIRMWARE_DOWNLOAD_SUCCESS = 0
96
101
FIRMWARE_DOWNLOAD_FAILURE = 1
@@ -1365,6 +1370,7 @@ def download_firmware(physical_port, fwfile):
1365
1370
1366
1371
return FIRMWARE_DOWNLOAD_SUCCESS
1367
1372
1373
+
1368
1374
def activate_firmware (physical_port ):
1369
1375
""" This routine should activate the downloaded firmware on all the
1370
1376
components of the Y cable of the port specified.
@@ -1385,6 +1391,7 @@ def activate_firmware(physical_port):
1385
1391
1386
1392
return FIRMWARE_ACTIVATE_SUCCESS
1387
1393
1394
+
1388
1395
def rollback_firmware (physical_port ):
1389
1396
""" This routine should rollback the firmware to the previous version
1390
1397
which was being used by the cable. This API is intended to be called when the
@@ -1401,3 +1408,87 @@ def rollback_firmware(physical_port):
1401
1408
"""
1402
1409
1403
1410
return FIRMWARE_ROLLBACK_SUCCESS
1411
+
1412
+
1413
+ def set_switching_mode (physical_port , mode ):
1414
+ """
1415
+ This API specifically enables the auto switching or manual switching feature on the muxcable,
1416
+ depending upon the mode entered by the user.
1417
+ Autoswitch feature if enabled actually does an automatic toggle of the mux in case the active
1418
+ side link goes down and basically points the mux to the other side.
1419
+
1420
+ Register Specification at offset 139 is documented below
1421
+
1422
+ Byte offset bits Name Description
1423
+ 139 0 Switch Target "0x01 - enable auto switchover; if both TOR#1 and TOR#2 are linked and the active link fails,
1424
+ the cable will automatically switchover to the inactive link.
1425
+ 0x00 - disable auto switchover. Default is disabled."
1426
+
1427
+
1428
+ Args:
1429
+ physical_port:
1430
+ an Integer, the actual physical port connected to Y end of a Y cable which can toggle the MUX
1431
+ mode:
1432
+ an Integer, specifies which type of switching mode we set the muxcable to
1433
+ either SWITCHING_MODE_AUTO or SWITCHING_MODE_MANUAL
1434
+
1435
+ Returns:
1436
+ a Boolean, true if the switch succeeded and false if it did not succeed.
1437
+ """
1438
+
1439
+ if mode == SWITCHING_MODE_AUTO :
1440
+ buffer = bytearray ([1 ])
1441
+ elif mode == SWITCHING_MODE_MANUAL :
1442
+ buffer = bytearray ([0 ])
1443
+ else :
1444
+ helper_logger .log_error (
1445
+ "ERR: invalid mode provided for autoswitch feature, failed to do a switch" )
1446
+ return False
1447
+
1448
+ curr_offset = OFFSET_ENABLE_AUTO_SWITCH
1449
+
1450
+ if platform_chassis is not None :
1451
+ result = platform_chassis .get_sfp (
1452
+ physical_port ).write_eeprom (curr_offset , 1 , buffer )
1453
+ else :
1454
+ helper_logger .log_error ("platform_chassis is not loaded, failed to do a switch target" )
1455
+ return False
1456
+
1457
+ return result
1458
+
1459
+ def get_switching_mode (physical_port ):
1460
+ """
1461
+ This API specifically returns which type of switching mode the cable is set to auto/manual
1462
+
1463
+ Register Specification at offset 139 is documented below
1464
+
1465
+ Byte offset bits Name Description
1466
+ 139 0 Switch Target "0x01 - enable auto switchover; if both TOR#1 and TOR#2 are linked and the active link fails,
1467
+ the cable will automatically switchover to the inactive link.
1468
+ 0x00 - disable auto switchover. Default is disabled."
1469
+
1470
+
1471
+ Args:
1472
+ physical_port:
1473
+ an Integer, the actual physical port connected to Y end of a Y cable which can toggle the MUX
1474
+
1475
+ Returns:
1476
+ an Integer, SWITCHING_MODE_AUTO if auto switch is enabled.
1477
+ SWITCHING_MODE_MANUAL if manual switch is enabled.
1478
+ """
1479
+
1480
+ curr_offset = OFFSET_ENABLE_AUTO_SWITCH
1481
+
1482
+ if platform_chassis is not None :
1483
+ result = platform_chassis .get_sfp (
1484
+ physical_port ).read_eeprom (curr_offset , 1 )
1485
+ if y_cable_validate_read_data (result , 1 , physical_port , "check if autoswitch is enabled" ) == EEPROM_READ_DATA_INVALID :
1486
+ return EEPROM_ERROR
1487
+ else :
1488
+ helper_logger .log_error ("platform_chassis is not loaded, failed to get the switch mode" )
1489
+ return - 1
1490
+
1491
+ if result [0 ] == 1 :
1492
+ return SWITCHING_MODE_AUTO
1493
+ else :
1494
+ return SWITCHING_MODE_MANUAL
0 commit comments