Skip to content

Commit

Permalink
Update WRR test to support qos remapping (#6737)
Browse files Browse the repository at this point in the history
* Update WRR test to support qos remapping
  • Loading branch information
bingwang-ms authored and wangxin committed Nov 11, 2022
1 parent b08568e commit bb0a9e1
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 21 deletions.
8 changes: 8 additions & 0 deletions tests/qos/files/qos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1470,6 +1470,7 @@ qos_params:
q4_num_of_pkts: 150
q5_num_of_pkts: 140
q6_num_of_pkts: 140
q7_num_of_pkts: 140
limit: 80
wrr_chg:
ecn: 1
Expand All @@ -1480,6 +1481,7 @@ qos_params:
q4_num_of_pkts: 300
q5_num_of_pkts: 80
q6_num_of_pkts: 80
q7_num_of_pkts: 80
limit: 80
lossy_weight: 8
lossless_weight: 30
Expand Down Expand Up @@ -1668,6 +1670,7 @@ qos_params:
q4_num_of_pkts: 150
q5_num_of_pkts: 140
q6_num_of_pkts: 140
q7_num_of_pkts: 140
limit: 80
wrr_chg:
ecn: 1
Expand All @@ -1678,6 +1681,7 @@ qos_params:
q4_num_of_pkts: 300
q5_num_of_pkts: 80
q6_num_of_pkts: 80
q7_num_of_pkts: 80
limit: 80
lossy_weight: 8
lossless_weight: 30
Expand Down Expand Up @@ -1860,6 +1864,7 @@ qos_params:
q4_num_of_pkts: 150
q5_num_of_pkts: 140
q6_num_of_pkts: 140
q7_num_of_pkts: 140
limit: 80
wrr_chg:
ecn: 1
Expand All @@ -1870,6 +1875,7 @@ qos_params:
q4_num_of_pkts: 300
q5_num_of_pkts: 80
q6_num_of_pkts: 80
q7_num_of_pkts: 80
limit: 80
lossy_weight: 8
lossless_weight: 30
Expand Down Expand Up @@ -2017,6 +2023,7 @@ qos_params:
q4_num_of_pkts: 150
q5_num_of_pkts: 140
q6_num_of_pkts: 140
q7_num_of_pkts: 140
limit: 80
wrr_chg:
ecn: 1
Expand All @@ -2027,6 +2034,7 @@ qos_params:
q4_num_of_pkts: 300
q5_num_of_pkts: 80
q6_num_of_pkts: 80
q7_num_of_pkts: 80
limit: 80
lossy_weight: 8
lossless_weight: 30
Expand Down
2 changes: 2 additions & 0 deletions tests/qos/qos_sai_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ def runPtfTest(self, ptfhost, testCase='', testParams={}):
"remote",
"-t",
";".join(["{}={}".format(k, repr(v)) for k, v in testParams.items()]),
"--qlen",
"10000",
"--disable-ipv6",
"--disable-vxlan",
"--disable-geneve",
Expand Down
11 changes: 7 additions & 4 deletions tests/qos/test_qos_sai.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from tests.common.fixtures.ptfhost_utils import copy_saitests_directory # lgtm[py/unused-import]
from tests.common.fixtures.ptfhost_utils import change_mac_addresses # lgtm[py/unused-import]
from tests.common.fixtures.ptfhost_utils import ptf_portmap_file # lgtm[py/unused-import]
from tests.common.dualtor.dual_tor_utils import dualtor_ports # lgtm[py/unused-import]
from tests.common.dualtor.dual_tor_utils import dualtor_ports, is_tunnel_qos_remap_enabled # lgtm[py/unused-import]
from tests.common.helpers.pfc_storm import PFCStorm
from tests.pfcwd.files.pfcwd_helper import set_pfc_timers, start_wd_on_ports
from qos_sai_base import QosSaiBase
Expand Down Expand Up @@ -902,13 +902,14 @@ def testQosSaiDot1pPgMapping(
)

def testQosSaiDwrr(
self, ptfhost, dutTestParams, dutConfig, dutQosConfig,
self, ptfhost, duthost, dutTestParams, dutConfig, dutQosConfig,
):
"""
Test QoS SAI DWRR
Args:
ptfhost (AnsibleHost): Packet Test Framework (PTF)
duthost (AnsibleHost): The DUT for testing
dutTestParams (Fixture, dict): DUT host test params
dutConfig (Fixture, dict): Map of DUT config containing dut interfaces, test port IDs, test port IPs,
and test ports
Expand All @@ -922,7 +923,7 @@ def testQosSaiDwrr(
"""
portSpeedCableLength = dutQosConfig["portSpeedCableLength"]
qosConfig = dutQosConfig["param"]

qos_remap_enable = is_tunnel_qos_remap_enabled(duthost)
testParams = dict()
testParams.update(dutTestParams["basicParams"])
testParams.update({
Expand All @@ -938,10 +939,12 @@ def testQosSaiDwrr(
"q4_num_of_pkts": qosConfig["wrr"]["q4_num_of_pkts"],
"q5_num_of_pkts": qosConfig["wrr"]["q5_num_of_pkts"],
"q6_num_of_pkts": qosConfig["wrr"]["q6_num_of_pkts"],
"q7_num_of_pkts": qosConfig["wrr"].get("q7_num_of_pkts", 0),
"limit": qosConfig["wrr"]["limit"],
"pkts_num_leak_out": qosConfig[portSpeedCableLength]["pkts_num_leak_out"],
"hwsku":dutTestParams['hwsku'],
"topo": dutTestParams["topo"]
"topo": dutTestParams["topo"],
"qos_remap_enable": qos_remap_enable
})

if "lossy_queue_1" in dutQosConfig["param"][portSpeedCableLength].keys():
Expand Down
55 changes: 38 additions & 17 deletions tests/saitests/py3/sai_qos_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2144,31 +2144,54 @@ def runTest(self):
src_port_ip = self.test_params['src_port_ip']
src_port_vlan = self.test_params['src_port_vlan']
src_port_mac = self.dataplane.get_mac(0, src_port_id)
print("dst_port_id: %d, src_port_id: %d" %
(dst_port_id, src_port_id), file=sys.stderr)
qos_remap_enable = bool(self.test_params.get('qos_remap_enable', False))
print("dst_port_id: %d, src_port_id: %d qos_remap_enable: %d" %
(dst_port_id, src_port_id, qos_remap_enable), file=sys.stderr)
print("dst_port_mac: %s, src_port_mac: %s, src_port_ip: %s, dst_port_ip: %s" % (
dst_port_mac, src_port_mac, src_port_ip, dst_port_ip), file=sys.stderr)
asic_type = self.test_params['sonic_asic_type']
default_packet_length = 1500
exp_ip_id = 110
queue_0_num_of_pkts = int(self.test_params['q0_num_of_pkts'])
queue_1_num_of_pkts = int(self.test_params['q1_num_of_pkts'])
queue_2_num_of_pkts = int(self.test_params['q2_num_of_pkts'])
queue_3_num_of_pkts = int(self.test_params['q3_num_of_pkts'])
queue_4_num_of_pkts = int(self.test_params['q4_num_of_pkts'])
queue_5_num_of_pkts = int(self.test_params['q5_num_of_pkts'])
queue_6_num_of_pkts = int(self.test_params['q6_num_of_pkts'])
queue_0_num_of_pkts = int(self.test_params.get('q0_num_of_pkts', 0))
queue_1_num_of_pkts = int(self.test_params.get('q1_num_of_pkts', 0))
queue_2_num_of_pkts = int(self.test_params.get('q2_num_of_pkts', 0))
queue_3_num_of_pkts = int(self.test_params.get('q3_num_of_pkts', 0))
queue_4_num_of_pkts = int(self.test_params.get('q4_num_of_pkts', 0))
queue_5_num_of_pkts = int(self.test_params.get('q5_num_of_pkts', 0))
queue_6_num_of_pkts = int(self.test_params.get('q6_num_of_pkts', 0))
queue_7_num_of_pkts = int(self.test_params.get('q7_num_of_pkts', 0))
limit = int(self.test_params['limit'])
pkts_num_leak_out = int(self.test_params['pkts_num_leak_out'])
topo = self.test_params['topo']

if 'backend' not in topo:
prio_list = [3, 4, 8, 0, 5, 46, 48]
if not qos_remap_enable:
# When qos_remap is disabled, the map is as below
# DSCP TC QUEUE
# 3 3 3
# 4 4 4
# 8 0 0
# 0 1 1
# 5 2 2
# 46 5 5
# 48 6 6
prio_list = [3, 4, 8, 0, 5, 46, 48]
q_pkt_cnt = [queue_3_num_of_pkts, queue_4_num_of_pkts, queue_0_num_of_pkts, queue_1_num_of_pkts, queue_2_num_of_pkts, queue_5_num_of_pkts, queue_6_num_of_pkts]
else:
# When qos_remap is enabled, the map is as below
# DSCP TC QUEUE
# 3 3 3
# 4 4 4
# 8 0 0
# 0 1 1
# 46 5 5
# 48 7 7
prio_list = [3, 4, 8, 0, 46, 48]
q_pkt_cnt = [queue_3_num_of_pkts, queue_4_num_of_pkts, queue_0_num_of_pkts, queue_1_num_of_pkts, queue_5_num_of_pkts, queue_7_num_of_pkts]
else:
prio_list = [3, 4, 1, 0, 2, 5, 6]
q_pkt_cnt = [queue_3_num_of_pkts, queue_4_num_of_pkts, queue_1_num_of_pkts,
queue_0_num_of_pkts, queue_2_num_of_pkts, queue_5_num_of_pkts, queue_6_num_of_pkts]

q_pkt_cnt = [queue_3_num_of_pkts, queue_4_num_of_pkts, queue_1_num_of_pkts, queue_0_num_of_pkts, queue_2_num_of_pkts, queue_5_num_of_pkts, queue_6_num_of_pkts]
q_cnt_sum = sum(q_pkt_cnt)
# Send packets to leak out
pkt_dst_mac = router_mac if router_mac != '' else dst_port_mac
pkt = construct_ip_pkt(64,
Expand Down Expand Up @@ -2260,8 +2283,7 @@ def runTest(self):

queue_pkt_counters[dscp_of_pkt] += 1
if queue_pkt_counters[dscp_of_pkt] == queue_num_of_pkts[dscp_of_pkt]:
diff_list.append((dscp_of_pkt, (queue_0_num_of_pkts + queue_1_num_of_pkts + queue_2_num_of_pkts +
queue_3_num_of_pkts + queue_4_num_of_pkts + queue_5_num_of_pkts + queue_6_num_of_pkts) - total_pkts))
diff_list.append((dscp_of_pkt, q_cnt_sum - total_pkts))

print(queue_pkt_counters, file=sys.stderr)

Expand All @@ -2280,8 +2302,7 @@ def runTest(self):
queue_counters_base)), file=sys.stderr)

# All packets sent should be received intact
assert(queue_0_num_of_pkts + queue_1_num_of_pkts + queue_2_num_of_pkts + queue_3_num_of_pkts +
queue_4_num_of_pkts + queue_5_num_of_pkts + queue_6_num_of_pkts == total_pkts)
assert(q_cnt_sum == total_pkts)


class LossyQueueTest(sai_base_test.ThriftInterfaceDataPlane):
Expand Down

0 comments on commit bb0a9e1

Please sign in to comment.