Skip to content

Commit 1673d25

Browse files
authored
[y_cable] refactor upgrade firmware API's; Fix vendor and part number API's read size for read_eeprom (sonic-net#174)
This PR adds stub functions definition with details as to how firmware upgrade should be implemented by a Y cable vendor. It also fixes the read_eeprom read size for vendor part number and vendor name retreival API's Description Added a stub functions definition with a doc string describing how it should be implemented Added these API's stub functions for vendors to implement def download_firmware(physical_port, fwfile) def activate_firmware(physical_port) def rollback_firmware(physical_port) Motivation and Context Firmware upgrade is a functionality that vendors need to implement, this PR adds the definition's and a description of how the implementation of this firmware upgrade procedure API's should be implemented by breaking down the firmware upgrade into above specified sub routines. Signed-off-by: vaibhav-dahiya <[email protected]>
1 parent ed93a15 commit 1673d25

File tree

1 file changed

+66
-20
lines changed

1 file changed

+66
-20
lines changed

sonic_y_cable/y_cable.py

+66-20
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
OFFSET_SWITCH_MUX_DIRECTION = 642
3232
OFFSET_MUX_DIRECTION = 644
3333
OFFSET_ACTIVE_TOR_INDICATOR = 645
34-
OFFSET_MANUAL_SWITCH_COUNT = 669
3534
OFFSET_CONFIGURE_PRBS_TYPE = 768
3635
OFFSET_ENABLE_PRBS = 769
3736
OFFSET_INITIATE_BER_MEASUREMENT = 770
@@ -92,9 +91,13 @@
9291

9392
MAX_NUM_LANES = 4
9493

95-
# Valid return codes for upgrade_firmware() routine
96-
FIRMWARE_UPGRADE_SUCCESS = 0
97-
FIRMWARE_UPGRADE_FAILURE = 1
94+
# Valid return codes for upgrade firmware routine steps
95+
FIRMWARE_DOWNLOAD_SUCCESS = 0
96+
FIRMWARE_DOWNLOAD_FAILURE = 1
97+
FIRMWARE_ACTIVATE_SUCCESS = 0
98+
FIRMWARE_ACTIVATE_FAILURE = 1
99+
FIRMWARE_ROLLBACK_SUCCESS = 0
100+
FIRMWARE_ROLLBACK_FAILURE = 1
98101

99102
SYSLOG_IDENTIFIER = "sonic_y_cable"
100103

@@ -995,8 +998,8 @@ def get_part_number(physical_port):
995998
curr_offset = OFFSET_PART_NUMBER
996999

9971000
if platform_chassis is not None:
998-
part_result = platform_chassis.get_sfp(physical_port).read_eeprom(curr_offset, 15)
999-
if y_cable_validate_read_data(part_result, 15, physical_port, "Part number") == EEPROM_READ_DATA_INVALID:
1001+
part_result = platform_chassis.get_sfp(physical_port).read_eeprom(curr_offset, 16)
1002+
if y_cable_validate_read_data(part_result, 16, physical_port, "Part number") == EEPROM_READ_DATA_INVALID:
10001003
return EEPROM_ERROR
10011004
else:
10021005
helper_logger.log_error("platform_chassis is not loaded, failed to get part number")
@@ -1021,8 +1024,8 @@ def get_vendor(physical_port):
10211024
curr_offset = OFFSET_VENDOR_NAME
10221025

10231026
if platform_chassis is not None:
1024-
result = platform_chassis.get_sfp(physical_port).read_eeprom(curr_offset, 15)
1025-
if y_cable_validate_read_data(result, 15, physical_port, "Vendor name") == EEPROM_READ_DATA_INVALID:
1027+
result = platform_chassis.get_sfp(physical_port).read_eeprom(curr_offset, 16)
1028+
if y_cable_validate_read_data(result, 16, physical_port, "Vendor name") == EEPROM_READ_DATA_INVALID:
10261029
return EEPROM_ERROR
10271030
else:
10281031
helper_logger.log_error("platform_chassis is not loaded, failed to get Vendor name")
@@ -1334,24 +1337,67 @@ def get_nic_voltage(physical_port):
13341337
return voltage
13351338

13361339

1337-
def upgrade_firmware(physical_port, fwfile):
1338-
""" This routine should facilitate complete firmware
1339-
upgrade of the Y cable on all the three ends of the
1340-
Y cable of the port specified.
1341-
All the components of the Y cable should be upgraded and committed
1342-
in their entirety by this single call subroutine.
1343-
This should return success code if firmware upgrade is successful
1344-
and an error code otherwise.
1340+
def download_firmware(physical_port, fwfile):
1341+
""" This routine should download and store the firmware on all the
1342+
components of the Y cable of the port specified.
1343+
This should include any internal transfers, checksum validation etc.
1344+
from TOR to TOR or TOR to NIC side of the firmware specified by the fwfile.
1345+
This basically means that the firmware which is being downloaded should be
1346+
available to be activated (start being utilized by the cable) once this API is
1347+
successfully executed.
1348+
Note that this API should ideally not require any rollback even if it fails
1349+
as this should not interfere with the existing cable functionality because
1350+
this has not been activated yet.
13451351
13461352
Args:
13471353
physical_port:
13481354
an Integer, the actual physical port connected to a Y cable
13491355
fwfile:
1350-
a string, a path to the binary file which contains the firmware image
1356+
a string, a path to the file which contains the firmware image.
1357+
Note that the firmware file can be in the format of the vendor's
1358+
choosing (binary, archive, etc.). But note that it should be one file
1359+
which contains firmware for all components of the Y-cable
13511360
Returns:
13521361
an Integer:
1353-
a predefined code stating whether the firmware upgrade was successful
1354-
or an error code as to what was the cause of firmware upgrade failure
1362+
a predefined code stating whether the firmware download was successful
1363+
or an error code as to what was the cause of firmware download failure
13551364
"""
13561365

1357-
return FIRMWARE_UPGRADE_SUCCESS
1366+
return FIRMWARE_DOWNLOAD_SUCCESS
1367+
1368+
def activate_firmware(physical_port):
1369+
""" This routine should activate the downloaded firmware on all the
1370+
components of the Y cable of the port specified.
1371+
This API is meant to be used in conjunction with download_firmware API, and
1372+
should be called once download_firmware API is succesful.
1373+
This means that the firmware which has been downloaded should be
1374+
activated (start being utilized by the cable) once this API is
1375+
successfully executed.
1376+
1377+
Args:
1378+
physical_port:
1379+
an Integer, the actual physical port connected to a Y cable
1380+
Returns:
1381+
an Integer:
1382+
a predefined code stating whether the firmware activate was successful
1383+
or an error code as to what was the cause of firmware activate failure
1384+
"""
1385+
1386+
return FIRMWARE_ACTIVATE_SUCCESS
1387+
1388+
def rollback_firmware(physical_port):
1389+
""" This routine should rollback the firmware to the previous version
1390+
which was being used by the cable. This API is intended to be called when the
1391+
user either witnesses an activate_firmware API failure or sees issues with
1392+
newer firmware in regards to stable cable functioning.
1393+
1394+
Args:
1395+
physical_port:
1396+
an Integer, the actual physical port connected to a Y cable
1397+
Returns:
1398+
an Integer:
1399+
a predefined code stating whether the firmware rollback was successful
1400+
or an error code as to what was the cause of firmware rollback failure
1401+
"""
1402+
1403+
return FIRMWARE_ROLLBACK_SUCCESS

0 commit comments

Comments
 (0)