Skip to content

Commit

Permalink
Fix asic identification (sonic-net#15297)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
ccroy-arista authored and mssonicbld committed Nov 13, 2024
1 parent 2dde9ec commit db777b5
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions tests/common/devices/sonic.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"orchagent": "swss",
"syncd": "syncd"
}
UNKNOWN_ASIC = "unknown"


class SonicHost(AnsibleHostBase):
Expand Down Expand Up @@ -1735,28 +1736,34 @@ def run_redis_cli_cmd(self, redis_cmd):
cmd = "/usr/bin/redis-cli {}".format(redis_cmd)
return self.command(cmd, verbose=False)

def _try_get_brcm_asic_name(self, output):
search_sets = {
"td2": {"b85", "BCM5685"},
"td3": {"b87", "BCM5687"},
"th": {"b96", "BCM5696"},
"th2": {"b97", "BCM5697"},
"th3": {"b98", "BCM5698"},
"th4": {"b99", "BCM5699"},
"th5": {"f90", "BCM7890"},
}
for asic in search_sets.keys():
for search_term in search_sets[asic]:
if search_term in output:
return asic
return UNKNOWN_ASIC

def get_asic_name(self):
asic = "unknown"
asic = UNKNOWN_ASIC
output = self.shell("lspci", module_ignore_errors=True)["stdout"]
if ("Broadcom Limited Device b960" in output or
"Broadcom Limited Broadcom BCM56960" in output):
asic = "th"
elif "Device b971" in output:
asic = "th2"
elif ("Broadcom Limited Device b850" in output or
"Broadcom Limited Broadcom BCM56850" in output or
"Broadcom Inc. and subsidiaries Broadcom BCM56850" in output):
asic = "td2"
elif ("Broadcom Limited Device b870" in output or
"Broadcom Inc. and subsidiaries Device b870" in output):
asic = "td3"
elif "Broadcom Limited Device b980" in output:
asic = "th3"
if "Broadcom" in output:
asic = self._try_get_brcm_asic_name(output)
elif "Cisco Systems Inc Device a001" in output:
asic = "gb"
elif "Mellanox Technologies" in output:
asic = "spc"

logger.info("asic: {}".format(asic))

return asic

def is_nvidia_platform(self):
Expand Down

0 comments on commit db777b5

Please sign in to comment.