Skip to content

Commit

Permalink
[Mellanox] fix the issue that failing to test whether dom supported p…
Browse files Browse the repository at this point in the history
…rior to reading dom data (#3120)

* fix the issue Bug SW #1816356 which is due to failing to test whether dom supported prior to reading dom data

* use pre-defined variable to avoid magic number.
no need to read 16 bytes, 1 byte is enough since calibration and dom capability are all in bytes at offset 92
  • Loading branch information
stephenxs authored and lguohan committed Jul 6, 2019
1 parent ae2e555 commit f41e381
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfputil.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
except ImportError as e:
raise ImportError("%s - required module not found" % str(e))

# sfp supports dom
XCVR_DOM_CAPABILITY_DOM_SUPPORT_BIT = 0x40
# I2C page size for sfp
SFP_I2C_PAGE_SIZE = 256

# parameters for DB connection
REDIS_HOSTNAME = "localhost"
REDIS_PORT = 6379
Expand Down Expand Up @@ -514,14 +519,19 @@ def get_transceiver_dom_info_dict(self, port_num):
transceiver_dom_info_dict['tx4bias'] = dom_channel_monitor_data['data']['TX4Bias']['value']

else:
offset = 256
offset = SFP_I2C_PAGE_SIZE

eeprom_raw = ['0'] * 256
eeprom_raw[92:92+16] = self._read_eeprom_specific_bytes_via_ethtool(port_num, 92, 16)
eeprom_raw = ['0'] * SFP_I2C_PAGE_SIZE
eeprom_raw[XCVR_DOM_CAPABILITY_OFFSET : XCVR_DOM_CAPABILITY_OFFSET + XCVR_DOM_CAPABILITY_WIDTH] = \
self._read_eeprom_specific_bytes_via_ethtool(port_num, XCVR_DOM_CAPABILITY_OFFSET, XCVR_DOM_CAPABILITY_WIDTH)
sfp_obj = sff8472InterfaceId()
calibration_type = sfp_obj._get_calibration_type(eeprom_raw)

eeprom_domraw = self._read_eeprom_specific_bytes_via_ethtool(port_num, offset, 256)
dom_supported = (int(eeprom_raw[XCVR_DOM_CAPABILITY_OFFSET], 16) & XCVR_DOM_CAPABILITY_DOM_SUPPORT_BIT != 0)
if not dom_supported:
return transceiver_dom_info_dict

eeprom_domraw = self._read_eeprom_specific_bytes_via_ethtool(port_num, offset, SFP_I2C_PAGE_SIZE)
if eeprom_domraw is None:
return transceiver_dom_info_dict

Expand Down

0 comments on commit f41e381

Please sign in to comment.