Skip to content

Commit 9dd33d7

Browse files
authored
add overflow_egress for PGDropTest multi-asic (sonic-net#9464)
Signed-off-by: Zhixin Zhu <[email protected]>
1 parent eafa1b2 commit 9dd33d7

2 files changed

Lines changed: 45 additions & 12 deletions

File tree

tests/qos/test_qos_sai.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,21 +1535,13 @@ def testQosSaiPGDrop(
15351535

15361536
testParams = dict()
15371537
testParams.update(dutTestParams["basicParams"])
1538-
pgDropKey = "pg_drop"
1538+
testParams.update(qosConfig['pg_drop'])
15391539
testParams.update({
1540-
"dscp": qosConfig[pgDropKey]["dscp"],
1541-
"ecn": qosConfig[pgDropKey]["ecn"],
1542-
"pg": qosConfig[pgDropKey]["pg"],
1543-
"queue": qosConfig[pgDropKey]["queue"],
15441540
"dst_port_id": dutConfig["testPorts"]["dst_port_id"],
15451541
"dst_port_ip": dutConfig["testPorts"]["dst_port_ip"],
15461542
"src_port_id": dutConfig["testPorts"]["src_port_id"],
15471543
"src_port_ip": dutConfig["testPorts"]["src_port_ip"],
15481544
"src_port_vlan": dutConfig["testPorts"]["src_port_vlan"],
1549-
"pkts_num_trig_pfc": qosConfig[pgDropKey]["pkts_num_trig_pfc"],
1550-
"pkts_num_trig_ingr_drp": qosConfig[pgDropKey]["pkts_num_trig_ingr_drp"],
1551-
"pkts_num_margin": qosConfig[pgDropKey]["pkts_num_margin"],
1552-
"iterations": qosConfig[pgDropKey]["iterations"],
15531545
"hwsku": dutTestParams['hwsku']
15541546
})
15551547

tests/saitests/py3/sai_qos_tests.py

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
sai_thrift_read_pg_shared_watermark,
3333
sai_thrift_read_buffer_pool_watermark,
3434
sai_thrift_read_headroom_pool_watermark,
35-
sai_thrift_read_queue_occupancy)
35+
sai_thrift_read_queue_occupancy,
36+
sai_thrift_read_pg_occupancy)
3637
from switch_sai_thrift.ttypes import (sai_thrift_attribute_value_t,
3738
sai_thrift_attribute_t)
3839
from switch_sai_thrift.sai_headers import (SAI_PORT_ATTR_QOS_SCHEDULER_PROFILE_ID)
@@ -241,6 +242,37 @@ def fill_leakout_plus_one(test_case, src_port_id, dst_port_id, pkt, queue, asic_
241242
return False
242243

243244

245+
def overflow_egress(test_case, src_port_id, pkt, queue, asic_type):
246+
# Attempts to queue 1 packet while compensating for a varying packet
247+
# leakout and egress queues. Returns pkts_num_egr_mem: number of packets
248+
# short of filling egress memory and leakout.
249+
# Returns extra_bytes_occupied:
250+
# extra number of bytes occupied in source port
251+
pkts_num_egr_mem = 0
252+
extra_bytes_occupied = 0
253+
if asic_type not in ['cisco-8000']:
254+
return pkts_num_egr_mem, extra_bytes_occupied
255+
256+
pg_cntrs_base = sai_thrift_read_pg_occupancy(
257+
test_case.src_client, port_list['src'][src_port_id])
258+
max_cycles = 1000
259+
for cycle_i in range(max_cycles):
260+
send_packet(test_case, src_port_id, pkt, 1000)
261+
pg_cntrs = sai_thrift_read_pg_occupancy(
262+
test_case.src_client, port_list['src'][src_port_id])
263+
if pg_cntrs[queue] > pg_cntrs_base[queue]:
264+
print("get_pkts_num_egr_mem: Success, sent %d packets, "
265+
"SQ occupancy bytes rose from %d to %d" % (
266+
(cycle_i + 1) * 1000, pg_cntrs_base[queue],
267+
pg_cntrs[queue]), file=sys.stderr)
268+
pkts_num_egr_mem = cycle_i * 1000
269+
extra_bytes_occupied = pg_cntrs[queue] - pg_cntrs_base[queue]
270+
print("overflow_egress:pkts_num_egr_mem:{}, extra_bytes_occupied:{}".format(
271+
pkts_num_egr_mem, extra_bytes_occupied))
272+
return pkts_num_egr_mem, extra_bytes_occupied
273+
raise RuntimeError("Couldn't overflow the egress memory after 1000 iterations.")
274+
275+
244276
def get_peer_addresses(data):
245277
def get_peer_addr(data, addr):
246278
if isinstance(data, dict) and 'peer_addr' in data:
@@ -3865,6 +3897,8 @@ def runTest(self):
38653897
self.test_params['pkts_num_trig_ingr_drp'])
38663898
iterations = int(self.test_params['iterations'])
38673899
margin = int(self.test_params['pkts_num_margin'])
3900+
cell_size = int(self.test_params.get('cell_size', 0))
3901+
is_multi_asic = (self.src_client != self.dst_client)
38683902

38693903
pkt_dst_mac = router_mac if router_mac != '' else dst_port_mac
38703904
dst_port_id = get_rx_port(
@@ -3896,14 +3930,21 @@ def runTest(self):
38963930

38973931
pg_dropped_cntrs_base = sai_thrift_read_pg_drop_counters(
38983932
self.src_client, port_list['src'][src_port_id])
3933+
pkt_num = pkts_num_trig_pfc
3934+
3935+
# Fill egress memory and leakout
3936+
if 'cisco-8000' in asic_type and is_multi_asic:
3937+
pkts_num_egr_mem, extra_bytes_occupied = overflow_egress(
3938+
self, src_port_id, pkt, pg, asic_type)
3939+
pkt_num -= extra_bytes_occupied // cell_size
38993940

39003941
# Send packets to trigger PFC
39013942
print("Iteration {}/{}, sending {} packets to trigger PFC".format(
39023943
test_i + 1, iterations, pkts_num_trig_pfc), file=sys.stderr)
3903-
send_packet(self, src_port_id, pkt, pkts_num_trig_pfc)
3944+
send_packet(self, src_port_id, pkt, pkt_num)
39043945

39053946
# Account for leakout
3906-
if 'cisco-8000' in asic_type:
3947+
if 'cisco-8000' in asic_type and not is_multi_asic:
39073948
queue_counters = sai_thrift_read_queue_occupancy(
39083949
self.dst_client, "dst", dst_port_id)
39093950
occ_pkts = queue_counters[queue] // (packet_length + 24)

0 commit comments

Comments
 (0)