From: Ido Schimmel <idosch(a)mellanox.com>
When testing QoS functionality we'll need to transmit flows with
different priority code point (PCP) simultaneously.
This is something normally done using pktgen with different properties
set for each pktgen thread. However, the PktgenTx module forces the
same properties for all the threads.
Add the 'thread_option' optional parameter to PktgenTx, which is a list
whose length corresponds to the number of pktgen threads. The per-thread
options are separated using ','.
Example:
thread_option = ['vlan_id 10,vlan_p 2', 'vlan_id 20,vlan_p 3']
Will create two threads, one with VLAN ID 10 and PCP 2, the second with
VLAN ID 20 and PCP 3.
Signed-off-by: Ido Schimmel <idosch(a)mellanox.com>
---
recipes/switchdev/TestLib.py | 12 +++++++++---
test_modules/PktgenTx.py | 8 +++++++-
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/recipes/switchdev/TestLib.py b/recipes/switchdev/TestLib.py
index b16cd9b..88dc0bf 100644
--- a/recipes/switchdev/TestLib.py
+++ b/recipes/switchdev/TestLib.py
@@ -263,7 +263,7 @@ class TestLib:
for i in err_str:
self.custom(i[1].get_host(), "iperf_mc", i[0])
- def pktgen(self, if1, if2, pkt_size, desc=None):
+ def pktgen(self, if1, if2, pkt_size, desc=None, thread_option=[]):
if1.set_mtu(self._mtu)
m1 = if1.get_host()
m1.sync_resources(modules=["PktgenTx"])
@@ -272,10 +272,16 @@ class TestLib:
pktgen_option.append("pkt_size %s" % pkt_size)
pktgen_option.append("dst_mac %s" % if2.get_hwaddr())
pktgen_option.append("dst %s" % if2.get_ip(0))
+ if not thread_option:
+ dev_names = if1.get_devname()
+ else:
+ dev_names = ["{}(a){}".format(if1.get_devname(), idx) for idx in
+ range(len(thread_option))]
pktgen_mod = self._ctl.get_module("PktgenTx",
options={
- "netdev_name": if1.get_devname(),
- "pktgen_option": pktgen_option})
+ "netdev_name": dev_names,
+ "pktgen_option": pktgen_option,
+ "thread_option": thread_option})
m1.run(pktgen_mod, desc=desc, netns=if1.get_netns())
diff --git a/test_modules/PktgenTx.py b/test_modules/PktgenTx.py
index cf35b5f..71c2870 100644
--- a/test_modules/PktgenTx.py
+++ b/test_modules/PktgenTx.py
@@ -65,6 +65,7 @@ class PktgenTx(TestGeneric):
def run(self):
dev_names = self.get_multi_mopt("netdev_name")
pktgen_options = self.get_multi_mopt("pktgen_option")
+ thread_options = self.get_multi_opt("thread_option")
default_pktgen_options = [
"count 10000000",
@@ -80,11 +81,16 @@ class PktgenTx(TestGeneric):
pgwrkr = PktgenWorkers()
try:
- for dev_name in dev_names:
+ for idx, dev_name in enumerate(dev_names):
pgwrkr.add_device(dev_name)
pg = Pktgen("/proc/net/pktgen/%s" % dev_name)
for pktgen_option in pktgen_options:
pg.set(pktgen_option)
+ if not thread_options:
+ continue
+ for thread_option in re.split(",", thread_options[idx]):
+ pg.set(thread_option)
+
pgctl.set("start")
except ExecCmdFail:
res_data = {"msg": "pktgen failed"}
--
2.7.4