From 4533f829781f9d3706406f33d82a58adef74d294 Mon Sep 17 00:00:00 2001 From: ngoc-do <72221689+ngoc-do@users.noreply.github.com> Date: Mon, 21 Jun 2021 11:47:38 -0700 Subject: [PATCH] Add a template function that returns list of asics on module (#185) Add a generic function that returns a list of asics on module. Vendors will implement their own for their platform. The function could be used for collecting fabric asic info in each module and populating into CHASSIS_STATE_DB (Azure/sonic-platform-daemons#175). To simplify the change, all fabric cards in system should be identical in terms of number of asics in a card. --- sonic_platform_base/module_base.py | 36 +++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/sonic_platform_base/module_base.py b/sonic_platform_base/module_base.py index 5b36a649695e..3e96f8b24012 100644 --- a/sonic_platform_base/module_base.py +++ b/sonic_platform_base/module_base.py @@ -71,6 +71,10 @@ def __init__(self): # available on the module self._sfp_list = [] + # List of ASIC-derived objects representing all ASICs + # visibile in PCI domain on the module + self._asic_list = [] + def get_base_mac(self): """ Retrieves the base MAC address for the module @@ -461,4 +465,34 @@ def is_midplane_reachable(self): Returns: A bool value, should return True if module is reachable via midplane """ - raise NotImplementedError + return NotImplementedError + + ############################################## + # ASIC methods + ############################################## + def get_all_asics(self): + """ + Retrieves the list of all ASICs on the module that are visible in PCI domain. + When called from the Supervisor of modular system, the module could be + fabric card, and the function returns all fabric ASICs on this module that + appear in PCI domain of the Supervisor. + + Returns: + A list of ASICs. Index of an ASIC in the list is the index of the ASIC + on the module. Index is 0 based. + + An item in the list is a tuple that includes: + - ASIC instance number (indexed globally across all modules of + the chassis). This number is used to find settings for the ASIC + from /usr/share/sonic/device/platform/hwsku/asic_instance_number/. + - ASIC PCI address: It is used by syncd to attach the correct ASIC. + + For example: [('4', '0000:05:00.0'), ('5', '0000:07:00.0')] + In this example, from the output, we know the module has 2 ASICs. + Item ('4', '0000:05:00.0') describes information about the first ASIC + in the module. + '4' means it is asic4 in the chassis. Settings for this ASIC is at + /usr/share/sonic/device/platform/hwsku/4/. + And '0000:05:00.0' is its PCI address. + """ + return self._asic_list