From: Ido Schimmel <idosch(a)mellanox.com>
The PCP to PG recipe deals with ingress mapping, but at egress packets
should be mapped to a TC according to their PCP value and user priority
to TC mapping.
Add a recipe to check that in much the same way as the PCP to PG recipe.
Signed-off-by: Ido Schimmel <idosch(a)mellanox.com>
---
recipes/switchdev/qos-002-tc.py | 71 ++++++++++++++++++++++++++++++++++++++++
recipes/switchdev/qos-002-tc.xml | 22 +++++++++++++
2 files changed, 93 insertions(+)
create mode 100644 recipes/switchdev/qos-002-tc.py
create mode 100644 recipes/switchdev/qos-002-tc.xml
diff --git a/recipes/switchdev/qos-002-tc.py b/recipes/switchdev/qos-002-tc.py
new file mode 100644
index 0000000..8cc6c29
--- /dev/null
+++ b/recipes/switchdev/qos-002-tc.py
@@ -0,0 +1,71 @@
+"""
+Copyright 2016 Mellanox Technologies. All rights reserved.
+Licensed under the GNU General Public License, version 2 as
+published by the Free Software Foundation; see COPYING for details.
+"""
+
+__author__ = """
+idosch(a)mellanox.com (Ido Schimmel)
+"""
+
+from lnst.Controller.Task import ctl
+from TestLib import TestLib
+from time import sleep
+
+def check_etc_max_occ(tl, iface, etc):
+ err_msg = ""
+
+ for etc_iter in range(1, 8):
+ max_occ = tl.devlink_tc_max_occ_get(iface, False, etc_iter)
+ if max_occ != 0 and etc != etc_iter:
+ err_msg = "etc {0} occ isn't zero when should
be".format(etc_iter)
+ break
+ elif max_occ == 0 and etc == etc_iter:
+ err_msg = "etc {0} occ is zero when shouldn't be".format(etc)
+ break
+
+ tl.custom(iface.get_host(), "etc occ test", err_msg)
+
+def do_task(ctl, hosts, ifaces, aliases):
+ m1, m2, sw = hosts
+ m1_if1, m2_if1, sw_if1, sw_if2 = ifaces
+
+ m1_if1.reset(ip=["192.168.101.10/24", "2002::1/64"])
+ m2_if1.reset(ip=["192.168.101.11/24", "2002::2/64"])
+
+ sleep(30)
+
+ sw.create_bridge(slaves=[sw_if1, sw_if2], options={"vlan_filtering": 1})
+ sw_if1.add_br_vlan(10)
+ sw_if2.add_br_vlan(10)
+
+ tl = TestLib(ctl, aliases)
+
+ sw.enable_service("lldpad")
+ sw_if1.enable_lldp()
+ tl.lldp_ets_default_set(sw_if1, willing=False)
+
+ m1.enable_service("lldpad")
+ m1_if1.enable_lldp()
+ tl.lldp_ets_default_set(m1_if1)
+
+ tl.ping_simple(m1_if1, m2_if1)
+
+ for prio in range(1, 8):
+ tl.lldp_ets_up2tc_set(sw_if1, [(prio, prio)])
+ tl.devlink_clearmax(sw, sw_if1.get_devlink_name())
+
+ sleep(5) # lldpad's event loop runs every second.
+ tl.pktgen(m2_if1, m1_if1, m2_if1.get_mtu(), vlan_id=10, vlan_p=prio)
+ check_etc_max_occ(tl, sw_if1, prio)
+
+ tl.lldp_ets_up2tc_set(sw_if1, [(prio, 0)])
+
+do_task(ctl, [ctl.get_host("machine1"),
+ ctl.get_host("machine2"),
+ ctl.get_host("switch")],
+ [ctl.get_host("machine1").get_interface("if1"),
+ ctl.get_host("machine2").get_interface("if1"),
+ ctl.get_host("switch").get_interface("if1"),
+ ctl.get_host("switch").get_interface("if2")],
+ ctl.get_aliases())
diff --git a/recipes/switchdev/qos-002-tc.xml b/recipes/switchdev/qos-002-tc.xml
new file mode 100644
index 0000000..fcd3ccf
--- /dev/null
+++ b/recipes/switchdev/qos-002-tc.xml
@@ -0,0 +1,22 @@
+<lnstrecipe
xmlns:xi="http://www.w3.org/2003/XInclude">
+ <xi:include href="default_aliases.xml" />
+ <network>
+ <host id="machine1">
+ <interfaces>
+ <eth id="if1" label="A" />
+ </interfaces>
+ </host>
+ <host id="machine2">
+ <interfaces>
+ <eth id="if1" label="B" />
+ </interfaces>
+ </host>
+ <host id="switch">
+ <interfaces>
+ <eth id="if1" label="A" />
+ <eth id="if2" label="B" />
+ </interfaces>
+ </host>
+ </network>
+ <task python="qos-002-tc.py" />
+</lnstrecipe>
--
2.7.4