Skip to content

Commit

Permalink
[chassis][voq] broadcom-dnx does not support SAI_PORT_STAT_IN_DROPPED…
Browse files Browse the repository at this point in the history
…_PKTS starting from SAI 11.x. (sonic-net#14743)

SAI thrift call sai_thrift_read_port_counters() reads a collection of counters together, including SAI_PORT_STAT_IN_DROPPED_PKTS. Starting from BRCM SAI 11.x, SAI_PORT_STAT_IN_DROPPED_PKTS is not supported and retrieving the count may fail SAI call sonic-net/sonic-buildimage#19998. In order to retrieve other counters correctly, read SAI_PORT_STAT_IN_DROPPED_PKTS in a separate SAI call.
  • Loading branch information
ysmanman authored Oct 7, 2024
1 parent c1d47b3 commit b781bad
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion tests/saitests/py3/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,14 @@ def sai_thrift_read_port_counters(client, asic_type, port):
port_cnt_ids.append(SAI_PORT_STAT_PFC_7_TX_PKTS)
port_cnt_ids.append(SAI_PORT_STAT_IF_OUT_OCTETS)
port_cnt_ids.append(SAI_PORT_STAT_IF_OUT_UCAST_PKTS)
port_cnt_ids.append(SAI_PORT_STAT_IN_DROPPED_PKTS)

# broadcom-dnx does not support SAI_PORT_STAT_IN_DROPPED_PKTS. Reading this counter may fail
# to retrieve other counters (https://github.com/sonic-net/sonic-buildimage/issues/19998).
# Since we cannot tell if the ASIC is DNX or or not from provided asic_type, read the counter
# separately in another SAI call for all broadcom ASIC.
if asic_type != 'broadcom':
port_cnt_ids.append(SAI_PORT_STAT_IN_DROPPED_PKTS)

port_cnt_ids.append(SAI_PORT_STAT_OUT_DROPPED_PKTS)
port_cnt_ids.append(SAI_PORT_STAT_IF_IN_UCAST_PKTS)
port_cnt_ids.append(SAI_PORT_STAT_IF_IN_NON_UCAST_PKTS)
Expand All @@ -819,6 +826,14 @@ def sai_thrift_read_port_counters(client, asic_type, port):
if asic_type == 'mellanox':
counters_results.append(0)

# Read SAI_PORT_STAT_IN_DROPPED_PKTS now and insert the cnt at the correct
# index in the counter results.
if asic_type == 'broadcom':
in_drop_pkts_cnt_id = [SAI_PORT_STAT_IN_DROPPED_PKTS]
in_drop_pkts_cnt_result = client.sai_thrift_get_port_stats(
port, in_drop_pkts_cnt_id, 1)
counters_results.insert(12, in_drop_pkts_cnt_result[0])

queue_list = []
port_attr_list = client.sai_thrift_get_port_attribute(port)
attr_list = port_attr_list.attr_list
Expand Down

0 comments on commit b781bad

Please sign in to comment.