From 451b7fa26c1a42096d3a13a87cd8922d3945ede7 Mon Sep 17 00:00:00 2001 From: Jie Feng Date: Mon, 21 Nov 2022 08:28:25 -0800 Subject: [PATCH] Adding comments about the getting asic name for display. Signed-off-by: Jie Feng --- scripts/fabricstat | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/scripts/fabricstat b/scripts/fabricstat index 1847ac15e7..fea92e6402 100755 --- a/scripts/fabricstat +++ b/scripts/fabricstat @@ -122,20 +122,21 @@ class FabricPortStat(FabricStat): table = [] header = None - if not self.namespace: - asic = '0' - else: - asic = multi_asic.get_asic_id_from_name(self.namespace) + # Default ASIC name is 0 for single-ASIC systems. For multi-ASIC systems, + # derive name from namespace. + asic_name = '0' + if self.namespace: + asic_name = multi_asic.get_asic_id_from_name(self.namespace) for key, data in cnstat_dict.items(): port_id = key[len(PORT_NAME_PREFIX):] if errors_only: header = portstat_header_errors_only - table.append((asic, port_id, self.get_port_state(key), + table.append((asic_name, port_id, self.get_port_state(key), data.crc, data.fec_correctable, data.fec_uncorrectable, data.symbol_err)) else: header = portstat_header_all - table.append((asic, port_id, self.get_port_state(key), + table.append((asic_name, port_id, self.get_port_state(key), data.in_cell, data.in_octet, data.out_cell, data.out_octet, data.crc, data.fec_correctable, data.fec_uncorrectable, data.symbol_err)) @@ -171,14 +172,15 @@ class FabricQueueStat(FabricStat): return table = [] - if not self.namespace: - asic = '0' - else: - asic = multi_asic.get_asic_id_from_name(self.namespace) + # Default ASIC name is 0 for single-ASIC systems. For multi-ASIC systems, + # derive name from namespace. + asic_name = '0' + if self.namespace: + asic_name = multi_asic.get_asic_id_from_name(self.namespace) for key, data in cnstat_dict.items(): port_name, queue_id = key.split(':') port_id = port_name[len(PORT_NAME_PREFIX):] - table.append((asic, port_id, self.get_port_state(port_name), queue_id, + table.append((asic_name, port_id, self.get_port_state(port_name), queue_id, data.curbyte, data.curlevel, data.watermarklevel)) print(tabulate(table, queuestat_header, tablefmt='simple', stralign='right'))