Skip to content

Commit

Permalink
[PG] add checking for increasing ingress PG drop packet counters (#4176)
Browse files Browse the repository at this point in the history
Add ability to check PG dropped packet counters

- How did you do it?
Use existing QoS infrastructure to check dropped packets per PG per Interface

- How did you verify/test it?
run test:
py.test qos/test_qos_sai.py::TestQosSai::testQosSaiPfcXoffLimit --inventory "../ansible/inventory, ../ansible/veos" --host-pattern (dut)-ptf32 --module-path ../ansible/library/ --testbed (dut)-ptf32 --testbed_file ../ansible/testbed.csv
  • Loading branch information
ayurkiv-nvda authored Sep 12, 2021
1 parent 104c6e2 commit eefc0e5
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/saitests/sai_qos_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
port_list,
sai_thrift_read_port_watermarks,
sai_thrift_read_pg_counters,
sai_thrift_read_pg_drop_counters,
sai_thrift_read_pg_shared_watermark,
sai_thrift_read_buffer_pool_watermark,
sai_thrift_read_headroom_pool_watermark,
Expand Down Expand Up @@ -674,6 +675,13 @@ def runTest(self):
# get counter names to query
ingress_counters, egress_counters = get_counter_names(sonic_version)

# get a snapshot of PG drop packets counter
if '201811' not in sonic_version:
# According to SONiC configuration lossless dscps are classified as follows:
# dscp 3 -> pg 3
# dscp 4 -> pg 4
pg_dropped_cntrs_old = sai_thrift_read_pg_drop_counters(self.client, port_list[src_port_id])

# Prepare IP packet data
ttl = 64
default_packet_length = 64
Expand Down Expand Up @@ -795,6 +803,12 @@ def runTest(self):
for cntr in egress_counters:
assert(xmit_counters[cntr] == xmit_counters_base[cntr])

if '201811' not in sonic_version:
pg_dropped_cntrs = sai_thrift_read_pg_drop_counters(self.client, port_list[src_port_id])
logging.info("Dropped packet counters on port #{} :{} packets, current dscp: {}".format(src_port_id, pg_dropped_cntrs[dscp], dscp))
# Check that counters per lossless PG increased
assert pg_dropped_cntrs[dscp] > pg_dropped_cntrs_old[dscp]

finally:
sai_thrift_port_tx_enable(self.client, asic_type, [dst_port_id])

Expand Down
22 changes: 22 additions & 0 deletions tests/saitests/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,28 @@ def sai_thrift_read_pg_counters(client, port_id):

return pg_cntrs

def sai_thrift_read_pg_drop_counters(client, port_id):
pg_cntr_ids = [
SAI_INGRESS_PRIORITY_GROUP_STAT_DROPPED_PACKETS
]

# fetch pg ids under port id
pg_ids = []
port_attrs = client.sai_thrift_get_port_attribute(port_id)
attrs = port_attrs.attr_list
for attr in attrs:
if attr.id == SAI_PORT_ATTR_INGRESS_PRIORITY_GROUP_LIST:
for pg_id in attr.value.objlist.object_id_list:
pg_ids.append(pg_id)

# get counter values of counter ids of interest under each pg
pg_cntrs = []
for pg_id in pg_ids:
cntr_vals = client.sai_thrift_get_pg_stats(pg_id, pg_cntr_ids, len(pg_cntr_ids))
pg_cntrs.append(cntr_vals[0])

return pg_cntrs

def sai_thrift_read_pg_shared_watermark(client, port_id):
pg_cntr_ids=[
SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES
Expand Down

0 comments on commit eefc0e5

Please sign in to comment.