Skip to content

Commit 439d615

Browse files
ccroy-aristasreejithsreekumaran
authored andcommitted
Fix asic identification (sonic-net#15297)
* sonic-mgmt: improve asic identification Device ASIC identification is achieved by whole line matches from the output of lspci, which is excessive and subject to fail due to unforeseeable changes in such output. This change reduces the string matching to specific unique differentiators in the output from lspci, while also future-proofing against similar changes in the lspci that could foreseeably occur. * sonic-mgmt: add th4/th5 asic identification Add token matches for identifying the TH4 and TH5 ASICs from the output of lspci. * sonic-mgmt: fix pre-commit issue Fix pre-commit error introduced within the prior two commits.
1 parent b4601ad commit 439d615

1 file changed

Lines changed: 22 additions & 15 deletions

File tree

tests/common/devices/sonic.py

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"orchagent": "swss",
3333
"syncd": "syncd"
3434
}
35+
UNKNOWN_ASIC = "unknown"
3536

3637

3738
class SonicHost(AnsibleHostBase):
@@ -1759,28 +1760,34 @@ def run_redis_cli_cmd(self, redis_cmd):
17591760
cmd = "/usr/bin/redis-cli {}".format(redis_cmd)
17601761
return self.command(cmd, verbose=False)
17611762

1763+
def _try_get_brcm_asic_name(self, output):
1764+
search_sets = {
1765+
"td2": {"b85", "BCM5685"},
1766+
"td3": {"b87", "BCM5687"},
1767+
"th": {"b96", "BCM5696"},
1768+
"th2": {"b97", "BCM5697"},
1769+
"th3": {"b98", "BCM5698"},
1770+
"th4": {"b99", "BCM5699"},
1771+
"th5": {"f90", "BCM7890"},
1772+
}
1773+
for asic in search_sets.keys():
1774+
for search_term in search_sets[asic]:
1775+
if search_term in output:
1776+
return asic
1777+
return UNKNOWN_ASIC
1778+
17621779
def get_asic_name(self):
1763-
asic = "unknown"
1780+
asic = UNKNOWN_ASIC
17641781
output = self.shell("lspci", module_ignore_errors=True)["stdout"]
1765-
if ("Broadcom Limited Device b960" in output or
1766-
"Broadcom Limited Broadcom BCM56960" in output):
1767-
asic = "th"
1768-
elif "Device b971" in output:
1769-
asic = "th2"
1770-
elif ("Broadcom Limited Device b850" in output or
1771-
"Broadcom Limited Broadcom BCM56850" in output or
1772-
"Broadcom Inc. and subsidiaries Broadcom BCM56850" in output):
1773-
asic = "td2"
1774-
elif ("Broadcom Limited Device b870" in output or
1775-
"Broadcom Inc. and subsidiaries Device b870" in output):
1776-
asic = "td3"
1777-
elif "Broadcom Limited Device b980" in output:
1778-
asic = "th3"
1782+
if "Broadcom" in output:
1783+
asic = self._try_get_brcm_asic_name(output)
17791784
elif "Cisco Systems Inc Device a001" in output:
17801785
asic = "gb"
17811786
elif "Mellanox Technologies" in output:
17821787
asic = "spc"
17831788

1789+
logger.info("asic: {}".format(asic))
1790+
17841791
return asic
17851792

17861793
def is_nvidia_platform(self):

0 commit comments

Comments
 (0)