|
41 | 41 | OFFSET_MAX_LANES = 2
|
42 | 42 | OFFSET_INITIATE_EYE_MEASUREMENT = 784
|
43 | 43 | OFFSET_LANE_1_EYE_RESULT = 785
|
44 |
| -OFFSET_PN_NUMBER = 168 |
| 44 | +OFFSET_PART_NUMBER = 168 |
45 | 45 | OFFSET_VENDOR_NAME = 148
|
46 | 46 | OFFSET_MANUAL_SWITCH_COUNT = 653
|
47 | 47 | OFFSET_AUTO_SWITCH_COUNT = 657
|
|
92 | 92 |
|
93 | 93 | MAX_NUM_LANES = 4
|
94 | 94 |
|
| 95 | +# Valid return codes for upgrade_firmware() routine |
| 96 | +FIRMWARE_UPGRADE_SUCCESS = 0 |
| 97 | +FIRMWARE_UPGRADE_FAILURE = 1 |
| 98 | + |
95 | 99 | SYSLOG_IDENTIFIER = "sonic_y_cable"
|
96 | 100 |
|
97 | 101 | # Global logger instance for helper functions and classes to log
|
@@ -977,33 +981,56 @@ def get_eye_info(physical_port, target):
|
977 | 981 | return eye_result
|
978 | 982 |
|
979 | 983 |
|
980 |
| -def get_pn_number_and_vendor_name(physical_port): |
| 984 | +def get_part_number(physical_port): |
981 | 985 | """
|
982 |
| - This API specifically returns the pn number and vendor name for a specfic port. |
| 986 | + This API specifically returns the part number of the Y cable for a specfic port. |
983 | 987 |
|
984 | 988 | Args:
|
985 | 989 | physical_port:
|
986 | 990 | an Integer, the actual physical port connected to a Y cable
|
987 | 991 | Returns:
|
988 |
| - a tuple, with pn_number and vendor name |
| 992 | + a string, with part number |
989 | 993 | """
|
990 | 994 |
|
991 |
| - curr_offset = OFFSET_PN_NUMBER |
| 995 | + curr_offset = OFFSET_PART_NUMBER |
992 | 996 |
|
993 | 997 | if platform_chassis is not None:
|
994 |
| - pn_result = platform_chassis.get_sfp(physical_port).read_eeprom(curr_offset, 15) |
995 |
| - if y_cable_validate_read_data(pn_result, 15, physical_port, "PN number") == EEPROM_READ_DATA_INVALID: |
996 |
| - return EEPROM_ERROR |
997 |
| - curr_offset = OFFSET_VENDOR_NAME |
998 |
| - vendor_name = platform_chassis.get_sfp(physical_port).read_eeprom(curr_offset, 15) |
999 |
| - if y_cable_validate_read_data(vendor_name, 15, physical_port, "vendor name") == EEPROM_READ_DATA_INVALID: |
| 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: |
1000 | 1000 | return EEPROM_ERROR
|
| 1001 | + else: |
| 1002 | + helper_logger.log_error("platform_chassis is not loaded, failed to get part number") |
| 1003 | + return -1 |
| 1004 | + |
| 1005 | + part_number = str(part_result.decode()) |
| 1006 | + |
| 1007 | + return part_number |
| 1008 | + |
| 1009 | + |
| 1010 | +def get_vendor(physical_port): |
| 1011 | + """ |
| 1012 | + This API specifically returns the vendor name of the Y cable for a specfic port. |
| 1013 | +
|
| 1014 | + Args: |
| 1015 | + physical_port: |
| 1016 | + an Integer, the actual physical port connected to a Y cable |
| 1017 | + Returns: |
| 1018 | + a string, with vendor name |
| 1019 | + """ |
1001 | 1020 |
|
| 1021 | + curr_offset = OFFSET_VENDOR_NAME |
| 1022 | + |
| 1023 | + 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: |
| 1026 | + return EEPROM_ERROR |
1002 | 1027 | else:
|
1003 |
| - helper_logger.log_error("platform_chassis is not loaded, failed to get pin results") |
| 1028 | + helper_logger.log_error("platform_chassis is not loaded, failed to get Vendor name") |
1004 | 1029 | return -1
|
1005 | 1030 |
|
1006 |
| - return pn_result, vendor_name |
| 1031 | + vendor_name = str(result.decode()) |
| 1032 | + |
| 1033 | + return vendor_name |
1007 | 1034 |
|
1008 | 1035 |
|
1009 | 1036 | def get_switch_count(physical_port, count_type):
|
@@ -1237,3 +1264,94 @@ def get_nic_voltage_temp(physical_port):
|
1237 | 1264 | return -1
|
1238 | 1265 |
|
1239 | 1266 | return temp, voltage
|
| 1267 | + |
| 1268 | + |
| 1269 | +def get_local_temperature(physical_port): |
| 1270 | + |
| 1271 | + curr_offset = OFFSET_INTERNAL_TEMPERATURE |
| 1272 | + if platform_chassis is not None: |
| 1273 | + result = platform_chassis.get_sfp(physical_port).read_eeprom(curr_offset, 1) |
| 1274 | + if y_cable_validate_read_data(result, 1, physical_port, "local temperature") == EEPROM_READ_DATA_INVALID: |
| 1275 | + return EEPROM_ERROR |
| 1276 | + temp = result[0] |
| 1277 | + else: |
| 1278 | + helper_logger.log_error("platform_chassis is not loaded, failed to get local temp") |
| 1279 | + return -1 |
| 1280 | + |
| 1281 | + return temp |
| 1282 | + |
| 1283 | + |
| 1284 | +def get_local_voltage(physical_port): |
| 1285 | + |
| 1286 | + if platform_chassis is not None: |
| 1287 | + curr_offset = OFFSET_INTERNAL_VOLTAGE |
| 1288 | + msb_result = platform_chassis.get_sfp(physical_port).read_eeprom(curr_offset, 1) |
| 1289 | + if y_cable_validate_read_data(msb_result, 1, physical_port, "local voltage MSB") == EEPROM_READ_DATA_INVALID: |
| 1290 | + return EEPROM_ERROR |
| 1291 | + lsb_result = platform_chassis.get_sfp(physical_port).read_eeprom(curr_offset+1, 1) |
| 1292 | + if y_cable_validate_read_data(lsb_result, 1, physical_port, "local voltage LSB") == EEPROM_READ_DATA_INVALID: |
| 1293 | + return EEPROM_ERROR |
| 1294 | + |
| 1295 | + voltage = (((msb_result[0] << 8) | lsb_result[0]) * 0.0001) |
| 1296 | + else: |
| 1297 | + helper_logger.log_error("platform_chassis is not loaded, failed to get local voltage") |
| 1298 | + return -1 |
| 1299 | + |
| 1300 | + return voltage |
| 1301 | + |
| 1302 | + |
| 1303 | +def get_nic_temperature(physical_port): |
| 1304 | + |
| 1305 | + curr_offset = OFFSET_NIC_TEMPERATURE |
| 1306 | + if platform_chassis is not None: |
| 1307 | + result = platform_chassis.get_sfp(physical_port).read_eeprom(curr_offset, 1) |
| 1308 | + if y_cable_validate_read_data(result, 1, physical_port, "NIC temperature") == EEPROM_READ_DATA_INVALID: |
| 1309 | + return EEPROM_ERROR |
| 1310 | + temp = result[0] |
| 1311 | + else: |
| 1312 | + helper_logger.log_error("platform_chassis is not loaded, failed to get NIC temp") |
| 1313 | + return -1 |
| 1314 | + |
| 1315 | + return temp |
| 1316 | + |
| 1317 | + |
| 1318 | +def get_nic_voltage(physical_port): |
| 1319 | + |
| 1320 | + curr_offset = OFFSET_NIC_VOLTAGE |
| 1321 | + if platform_chassis is not None: |
| 1322 | + msb_result = platform_chassis.get_sfp(physical_port).read_eeprom(curr_offset, 1) |
| 1323 | + if y_cable_validate_read_data(msb_result, 1, physical_port, "NIC voltage MSB") == EEPROM_READ_DATA_INVALID: |
| 1324 | + return EEPROM_ERROR |
| 1325 | + lsb_result = platform_chassis.get_sfp(physical_port).read_eeprom(curr_offset+1, 1) |
| 1326 | + if y_cable_validate_read_data(lsb_result, 1, physical_port, "NIC voltage LSB") == EEPROM_READ_DATA_INVALID: |
| 1327 | + return EEPROM_ERROR |
| 1328 | + |
| 1329 | + voltage = (((msb_result[0] << 8) | lsb_result[0]) * 0.0001) |
| 1330 | + else: |
| 1331 | + helper_logger.log_error("platform_chassis is not loaded, failed to get NIC voltage") |
| 1332 | + return -1 |
| 1333 | + |
| 1334 | + return voltage |
| 1335 | + |
| 1336 | + |
| 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. |
| 1345 | +
|
| 1346 | + Args: |
| 1347 | + physical_port: |
| 1348 | + an Integer, the actual physical port connected to a Y cable |
| 1349 | + fwfile: |
| 1350 | + a string, a path to the binary file which contains the firmware image |
| 1351 | + Returns: |
| 1352 | + 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 |
| 1355 | + """ |
| 1356 | + |
| 1357 | + return FIRMWARE_UPGRADE_SUCCESS |
0 commit comments