Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Double commit #8546 add overflow_egress for PGDropTest multi-asic #9464

Merged
merged 1 commit into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions tests/qos/test_qos_sai.py
Original file line number Diff line number Diff line change
Expand Up @@ -1535,21 +1535,13 @@ def testQosSaiPGDrop(

testParams = dict()
testParams.update(dutTestParams["basicParams"])
pgDropKey = "pg_drop"
testParams.update(qosConfig['pg_drop'])
testParams.update({
"dscp": qosConfig[pgDropKey]["dscp"],
"ecn": qosConfig[pgDropKey]["ecn"],
"pg": qosConfig[pgDropKey]["pg"],
"queue": qosConfig[pgDropKey]["queue"],
"dst_port_id": dutConfig["testPorts"]["dst_port_id"],
"dst_port_ip": dutConfig["testPorts"]["dst_port_ip"],
"src_port_id": dutConfig["testPorts"]["src_port_id"],
"src_port_ip": dutConfig["testPorts"]["src_port_ip"],
"src_port_vlan": dutConfig["testPorts"]["src_port_vlan"],
"pkts_num_trig_pfc": qosConfig[pgDropKey]["pkts_num_trig_pfc"],
"pkts_num_trig_ingr_drp": qosConfig[pgDropKey]["pkts_num_trig_ingr_drp"],
"pkts_num_margin": qosConfig[pgDropKey]["pkts_num_margin"],
"iterations": qosConfig[pgDropKey]["iterations"],
"hwsku": dutTestParams['hwsku']
})

Expand Down
47 changes: 44 additions & 3 deletions tests/saitests/py3/sai_qos_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
sai_thrift_read_pg_shared_watermark,
sai_thrift_read_buffer_pool_watermark,
sai_thrift_read_headroom_pool_watermark,
sai_thrift_read_queue_occupancy)
sai_thrift_read_queue_occupancy,
sai_thrift_read_pg_occupancy)
from switch_sai_thrift.ttypes import (sai_thrift_attribute_value_t,
sai_thrift_attribute_t)
from switch_sai_thrift.sai_headers import (SAI_PORT_ATTR_QOS_SCHEDULER_PROFILE_ID)
Expand Down Expand Up @@ -241,6 +242,37 @@ def fill_leakout_plus_one(test_case, src_port_id, dst_port_id, pkt, queue, asic_
return False


def overflow_egress(test_case, src_port_id, pkt, queue, asic_type):
# Attempts to queue 1 packet while compensating for a varying packet
# leakout and egress queues. Returns pkts_num_egr_mem: number of packets
# short of filling egress memory and leakout.
# Returns extra_bytes_occupied:
# extra number of bytes occupied in source port
pkts_num_egr_mem = 0
extra_bytes_occupied = 0
if asic_type not in ['cisco-8000']:
return pkts_num_egr_mem, extra_bytes_occupied

pg_cntrs_base = sai_thrift_read_pg_occupancy(
test_case.src_client, port_list['src'][src_port_id])
max_cycles = 1000
for cycle_i in range(max_cycles):
send_packet(test_case, src_port_id, pkt, 1000)
pg_cntrs = sai_thrift_read_pg_occupancy(
test_case.src_client, port_list['src'][src_port_id])
if pg_cntrs[queue] > pg_cntrs_base[queue]:
print("get_pkts_num_egr_mem: Success, sent %d packets, "
"SQ occupancy bytes rose from %d to %d" % (
(cycle_i + 1) * 1000, pg_cntrs_base[queue],
pg_cntrs[queue]), file=sys.stderr)
pkts_num_egr_mem = cycle_i * 1000
extra_bytes_occupied = pg_cntrs[queue] - pg_cntrs_base[queue]
print("overflow_egress:pkts_num_egr_mem:{}, extra_bytes_occupied:{}".format(
pkts_num_egr_mem, extra_bytes_occupied))
return pkts_num_egr_mem, extra_bytes_occupied
raise RuntimeError("Couldn't overflow the egress memory after 1000 iterations.")


def get_peer_addresses(data):
def get_peer_addr(data, addr):
if isinstance(data, dict) and 'peer_addr' in data:
Expand Down Expand Up @@ -3865,6 +3897,8 @@ def runTest(self):
self.test_params['pkts_num_trig_ingr_drp'])
iterations = int(self.test_params['iterations'])
margin = int(self.test_params['pkts_num_margin'])
cell_size = int(self.test_params.get('cell_size', 0))
is_multi_asic = (self.src_client != self.dst_client)

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

pg_dropped_cntrs_base = sai_thrift_read_pg_drop_counters(
self.src_client, port_list['src'][src_port_id])
pkt_num = pkts_num_trig_pfc

# Fill egress memory and leakout
if 'cisco-8000' in asic_type and is_multi_asic:
pkts_num_egr_mem, extra_bytes_occupied = overflow_egress(
self, src_port_id, pkt, pg, asic_type)
pkt_num -= extra_bytes_occupied // cell_size

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

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