test suite reviews and discussions
 help / color / Atom feed
* [dts] [PATCH v2]Add RSS Key Update Feature
       [not found] <f08663d0b11bfc1487f7461dd7c952bab652d9e8>
@ 2020-07-15 20:08 ` David Liu
  2020-07-24  2:01   ` Tu, Lijuan
  0 siblings, 1 reply; 3+ messages in thread
From: David Liu @ 2020-07-15 20:08 UTC (permalink / raw)
  To: dts; +Cc: lylavoie, David Liu

 Merge duplicated code. Add flag in send packet and verify
 result to identify symmetric used.

Signed-off-by: David Liu <dliu@iol.unh.edu>
---
 tests/TestSuite_rss_key_update.py | 183 ++++++++----------------------
 1 file changed, 46 insertions(+), 137 deletions(-)

diff --git a/tests/TestSuite_rss_key_update.py b/tests/TestSuite_rss_key_update.py
index 0985f30..adb44f1 100644
--- a/tests/TestSuite_rss_key_update.py
+++ b/tests/TestSuite_rss_key_update.py
@@ -39,7 +39,6 @@ Test the support of RSS Key Update by Poll Mode Drivers.
 
 import time
 import re
-import packet
 import random
 import utils
 
@@ -63,85 +62,37 @@ iptypes = {'ipv4-sctp': 'sctp',
 
 class TestRssKeyUpdate(TestCase):
 
-    def send_packet(self, itf, tran_type):
+    def send_packet(self, itf, tran_type, symmetric):
         """
         Sends packets.
         """
+        packet_list = {
+            'ipv4-sctp': 'IP(src="192.168.0.%d", dst="192.168.0.%d")/SCTP(sport=1024,dport=1024,tag=1)',
+            'ipv4-other': 'IP(src="192.168.0.%d", dst="192.168.0.%d")',
+            'ipv4-frag': 'IP(src="192.168.0.%d", dst="192.168.0.%d",frag=1,flags="MF")',
+            'ipv4-udp': 'IP(src="192.168.0.%d", dst="192.168.0.%d")/UDP(sport=1024,dport=1024)',
+            'ipv4-tcp': 'IP(src="192.168.0.%d", dst="192.168.0.%d")/TCP(sport=1024,dport=1024)',
+            'ipv6-other':'IPv6(src="3ffe:2501:200:1fff::%d", dst="3ffe:2501:200:3::%d")',
+            'ipv6-sctp': 'IPv6(src="3ffe:2501:200:1fff::%d", dst="3ffe:2501:200:3::%d", nh=132)/SCTP(sport=1024,dport=1024,tag=1)',
+            'ipv6-udp': 'IPv6(src="3ffe:2501:200:1fff::%d", dst="3ffe:2501:200:3::%d")/UDP(sport=1024,dport=1024)',
+            'ipv6-tcp': 'IPv6(src="3ffe:2501:200:1fff::%d", dst="3ffe:2501:200:3::%d")/TCP(sport=1024,dport=1024)',
+            'ipv6-frag': 'IPv6(src="3ffe:2501:200:1fff::%d", dst="3ffe:2501:200:3::%d",nh=44)/IPv6ExtHdrFragment()'
+        }
+
         received_pkts = []
         self.tester.scapy_foreground()
         self.dut.send_expect("start", "testpmd>")
         mac = self.dut.get_mac_address(0)
 
         # send packet with different source and dest ip
-        if tran_type == "ipv4-other":
-            for i in range(10):
-                packet = r'sendp([Ether(dst="%s", src=get_if_hwaddr("%s"))/IP(src="192.168.0.%d", dst="192.168.0.%d")], iface="%s")' % (
-                    mac, itf, i + 1, i + 2, itf)
-                self.tester.scapy_append(packet)
-            self.tester.scapy_execute()
-            time.sleep(.5)
-        elif tran_type == "ipv4-tcp":
-            for i in range(10):
-                packet = r'sendp([Ether(dst="%s", src=get_if_hwaddr("%s"))/IP(src="192.168.0.%d", dst="192.168.0.%d")/TCP(sport=1024,dport=1024)], iface="%s")' % (
-                    mac, itf, i + 1, i + 2, itf)
-                self.tester.scapy_append(packet)
-            self.tester.scapy_execute()
-            time.sleep(.5)
-        elif tran_type == "ipv4-udp":
-            for i in range(10):
-                packet = r'sendp([Ether(dst="%s", src=get_if_hwaddr("%s"))/IP(src="192.168.0.%d", dst="192.168.0.%d")/UDP(sport=1024,dport=1024)], iface="%s")' % (
-                    mac, itf, i + 1, i + 2, itf)
-                self.tester.scapy_append(packet)
-            self.tester.scapy_execute()
-            time.sleep(.5)
-        elif tran_type == "ipv4-sctp":
-            for i in range(10):
-                packet = r'sendp([Ether(dst="%s", src=get_if_hwaddr("%s"))/IP(src="192.168.0.%d", dst="192.168.0.%d")/SCTP(sport=1024,dport=1024,tag=1)], iface="%s")' % (
-                    mac, itf, i + 1, i + 2, itf)
-                self.tester.scapy_append(packet)
-            self.tester.scapy_execute()
-            time.sleep(.5)
-        elif tran_type == "ipv4-frag":
-            for i in range(10):
-                packet = r'sendp([Ether(dst="%s", src=get_if_hwaddr("%s"))/IP(src="192.168.0.%d", dst="192.168.0.%d",frag=1,flags="MF")], iface="%s")' % (
-                    mac, itf, i + 1, i + 2, itf)
-                self.tester.scapy_append(packet)
-            self.tester.scapy_execute()
-            time.sleep(.5)
-
-        elif tran_type == "ipv6-other":
-            for i in range(10):
-                packet = r'sendp([Ether(dst="%s", src=get_if_hwaddr("%s"))/IPv6(src="3ffe:2501:200:1fff::%d", dst="3ffe:2501:200:3::%d")], iface="%s")' % (
-                    mac, itf, i + 1, i + 2, itf)
-                self.tester.scapy_append(packet)
-            self.tester.scapy_execute()
-            time.sleep(.5)
-        elif tran_type == "ipv6-tcp":
-            for i in range(10):
-                packet = r'sendp([Ether(dst="%s", src=get_if_hwaddr("%s"))/IPv6(src="3ffe:2501:200:1fff::%d", dst="3ffe:2501:200:3::%d")/TCP(sport=1024,dport=1024)], iface="%s")' % (
-                    mac, itf, i + 1, i + 2, itf)
-                self.tester.scapy_append(packet)
-            self.tester.scapy_execute()
-            time.sleep(.5)
-        elif tran_type == "ipv6-udp":
-            for i in range(10):
-                packet = r'sendp([Ether(dst="%s", src=get_if_hwaddr("%s"))/IPv6(src="3ffe:2501:200:1fff::%d", dst="3ffe:2501:200:3::%d")/UDP(sport=1024,dport=1024)], iface="%s")' % (
-                    mac, itf, i + 1, i + 2, itf)
-                self.tester.scapy_append(packet)
-            self.tester.scapy_execute()
-            time.sleep(.5)
-        elif tran_type == "ipv6-sctp":
+        if tran_type in packet_list.keys():
+            packet_temp = r'sendp([Ether(dst="%s", src=get_if_hwaddr("%s"))/%s], iface="%s")' % (mac, itf, packet_list[tran_type], itf)
             for i in range(10):
-                packet = r'sendp([Ether(dst="%s", src=get_if_hwaddr("%s"))/IPv6(src="3ffe:2501:200:1fff::%d", dst="3ffe:2501:200:3::%d", nh=132)/SCTP(sport=1024,dport=1024,tag=1)], iface="%s")' % (
-                    mac, itf, i + 1, i + 2, itf)
-                self.tester.scapy_append(packet)
-            self.tester.scapy_execute()
-            time.sleep(.5)
-        elif tran_type == "ipv6-frag":
-            for i in range(10):
-                packet = r'sendp([Ether(dst="%s", src=get_if_hwaddr("%s"))/IPv6(src="3ffe:2501:200:1fff::%d", dst="3ffe:2501:200:3::%d",nh=44)/IPv6ExtHdrFragment()], iface="%s")' % (
-                    mac, itf, i + 1, i + 2, itf)
+                packet = packet_temp % (i + 1, i + 2)
                 self.tester.scapy_append(packet)
+                if symmetric:
+                    packet2 = packet_list[tran_type] % (mac, itf, i + 2, i + 1, itf)
+                    self.tester.scapy_append(packet2)
             self.tester.scapy_execute()
             time.sleep(.5)
         else:
@@ -154,102 +105,64 @@ class TestRssKeyUpdate(TestCase):
         # collect the hash result and the queue id
         for line in lines:
             line = line.strip()
-            if len(line) != 0 and line.strip().startswith("port "):
+            if len(line) != 0 and line.startswith("port "):
                 reta_line = {}
-                rexp = r"port (\d)/queue (\d{1,2}): received (\d) packets"
-                m = re.match(rexp, line.strip())
+                rexp = r"port (\d+)/queue (\d+): received (\d+) packets"
+                m = re.match(rexp, line)
                 if m:
                     reta_line["port"] = m.group(1)
                     reta_line["queue"] = m.group(2)
 
-            elif len(line) != 0 and line.startswith(("src=",)):
+            elif len(line) != 0 and line.startswith("src="):
                 if "RSS hash" not in line:
                     continue
                 for item in line.split("-"):
                     item = item.strip()
-                    if(item.startswith("RSS hash")):
+                    if item.startswith("RSS hash"):
                         name, value = item.split("=", 1)
 
                 reta_line[name.strip()] = value.strip()
                 received_pkts.append(reta_line)
 
-        return(self.verifyResult(received_pkts))
+        return(self.verifyResult(received_pkts, symmetric))
 
-    def verifyResult(self, reta_lines):
+    def verifyResult(self, reta_lines, symmetric):
         """
         Verify whether or not the result passes.
         """
-
-        global reta_num
         result = []
         key_id = {}
         self.verify(len(reta_lines) > 0, 'No packet received!')
         self.result_table_create(
             ['packet index', 'hash value', 'hash index', 'queue id', 'actual queue id', 'pass '])
 
-        i = 0
-
-        for tmp_reta_line in reta_lines:
+        for i, tmp_reta_line in enumerate(reta_lines):
             status = "false"
             # compute the hash result of five tuple into the 7 LSBs value.
             hash_index = int(tmp_reta_line["RSS hash"], 16) % reta_num
-            print(reta_entries[hash_index], tmp_reta_line)
             if(reta_entries[hash_index] == int(tmp_reta_line["queue"])):
                 status = "true"
                 result.insert(i, 0)
+                if symmetric:
+                    if(i % 2 == 1):
+                        if(pre_RSS_hash == tmp_reta_line["RSS hash"]):
+                            status = "true"
+                            result.insert(len(reta_lines) + (i - 1) // 2, 0)
+                        else:
+                            status = "fail"
+                            result.insert(len(reta_lines) + (i - 1) // 2, 1)
+                    pre_RSS_hash = tmp_reta_line["RSS hash"]
             else:
                 status = "fail"
                 result.insert(i, 1)
             self.result_table_add(
                 [i, tmp_reta_line["RSS hash"], hash_index, reta_entries[hash_index], tmp_reta_line["queue"], status])
-            i = i + 1
-            key_id[tmp_reta_line["RSS hash"]]=reta_entries[hash_index]
+            key_id[tmp_reta_line["RSS hash"]] = reta_entries[hash_index]
 
         self.result_table_print()
         self.verify(sum(result) == 0, "the reta update function failed!")
         return key_id
 
-    def verifyResult_symmetric(self, reta_lines):
-        """
-        Verify whether or not the result passes.
-        """
-
-        global reta_num
-        result = []
-        key_id = {}
-        self.verify(len(reta_lines) > 0, 'No packet received!')
-        self.result_table_create(
-            ['packet index', 'RSS hash', 'hash index', 'queue id', 'actual queue id', 'pass '])
-
-        i = 0
-        for tmp_reta_line in reta_lines:
-            status = "false"
-            # compute the hash result of five tuple into the 7 LSBs value.
-            hash_index = int(tmp_reta_line["RSS hash"], 16) % reta_num
-            if(reta_entries[hash_index] == int(tmp_reta_line["queue"])):
-                status = "true"
-                result.insert(i, 0)
-                if(i % 2 == 1):
-                    if(pre_RSS_hash == tmp_reta_line["RSS hash"]):
-                        status = "true"
-                        result.insert(len(reta_lines) + (i - 1) // 2, 0)
-                    else:
-                        status = "fail"
-                        result.insert(len(reta_lines) + (i - 1) // 2, 1)
-                pre_RSS_hash = tmp_reta_line["RSS hash"]
-            else:
-                status = "fail"
-                result.insert(i, 1)
-            self.result_table_add(
-                [i, tmp_reta_line["RSS hash"], hash_index, reta_entries[hash_index], tmp_reta_line["queue"], status])
-            i = i + 1
-            key_id[tmp_reta_line["RSS hash"]]=reta_entries[hash_index]
-
-        self.result_table_print()
-        self.verify(
-            sum(result) == 0, "the symmetric RSS hash function failed!")
-        return key_id
-
     def set_up_all(self):
         """
         Run at the start of each test suite.
@@ -282,7 +195,7 @@ class TestRssKeyUpdate(TestCase):
         elif self.nic in ["redrockcanyou", "atwood", "boulderrapid"]:
             reta_num = 128
         else:
-            self.verify(False, f"NIC Unsupported:{self.nic}")
+            self.verify(False, f"NIC Unsupported: {self.nic}")
 
         cores = self.dut.get_core_list("all")
         self.coremask = utils.create_mask(cores)
@@ -300,8 +213,6 @@ class TestRssKeyUpdate(TestCase):
         dutPorts = self.dut.get_ports(self.nic)
         localPort = self.tester.get_local_port(dutPorts[0])
         self.itf = self.tester.get_interface(localPort)
-        global reta_num
-        global iptypes
 
         self.dut.kill_all()
 
@@ -326,12 +237,12 @@ class TestRssKeyUpdate(TestCase):
                 reta_entries.insert(i, random.randint(0, queue - 1))
                 self.dut.send_expect(f"port config 0 rss reta ({i},{reta_entries[i]})", "testpmd> ")
 
-            ori_output = self.send_packet(self.itf, iptype)
+            ori_output = self.send_packet(self.itf, iptype, False)
 
             self.dut.send_expect("show port 0 rss-hash key", "testpmd> ")
             self.dut.send_expect(f"port config 0 rss-hash-key {iptype} 4439796BB54C50f3B675EF5B124F9F30B8A2C0FFFFDC4D02A08C9B334FF64A4C05C6FA343958D855FFF9583AE138C92E81150FFF", "testpmd> ")
 
-            new_output = self.send_packet(self.itf, iptype)
+            new_output = self.send_packet(self.itf, iptype, False)
 
             self.verify(ori_output != new_output, "before and after results are the same, hash key configuration failed!")
 
@@ -356,16 +267,15 @@ class TestRssKeyUpdate(TestCase):
                 reta_entries.insert(i, random.randint(0, queue - 1))
                 self.dut.send_expect(f"port config 0 rss reta ({i},{reta_entries[i]})", "testpmd> ")
 
-            ori_output = self.send_packet(self.itf, iptype)
+            ori_output = self.send_packet(self.itf, iptype, True)
 
             out = self.dut.send_expect("show port 0 rss-hash key", "testpmd> ")
             self.verify("rss disable" not in out, "rss is disable!")
             self.dut.send_expect(f"port config 0 rss-hash-key {iptype} 4439796BB54C50f3B675EF5B124F9F30B8A2C0FFFFDC4D02A08C9B334FF64A4C05C6FA343958D855FFF9583AE138C92E81150FFF", "testpmd> ")
 
-            new_output = self.send_packet(self.itf, iptype)
+            new_output = self.send_packet(self.itf, iptype, True)
 
             self.verify(ori_output != new_output, "before and after results are the same, hash key configuration failed!")
-        self.dut.send_expect("quit", "# ", 30)
 
     def test_set_hash_key_short_long(self):
 
@@ -384,26 +294,25 @@ class TestRssKeyUpdate(TestCase):
         out = self.dut.send_expect("show port info all", "testpmd> ", 120)
         self.verify(f"Hash key size in bytes: {nic_rss_key_size[self.nic]}" in out, "not expected hash key size!")
 
-        test_keies = {
+        test_keys = {
             "4439796BB54C50f3B675EF5B124F9F30B8A2C0FFFFDC4D02A08C9B334FF64A4C05C6FA343958D855FFF9583AE138C92E81150FFFFF": "longer",
             "4439796BB54C50f3B675EF5B124F9F30B8A2C0DC4D02A08C9B334FF64A4C05C6FA343958D855FFF9583AE138C92E81150FFF": "shorter",
         }
 
         # config key length longer/shorter than 104 hexa-decimal numbers
-        for key, error in test_keies.items():
+        for key, error in test_keys.items():
             out = self.dut.send_expect(f"port config 0 rss-hash-key ipv4-udp {key}", "testpmd> ")
             self.verify("invalid" in out, f"Try to set hash key {error} than 104 hexa-decimal numbers!")
 
         # config ket length same as 104 hex-decimal numbers and keep the config
         key = "4439796BB54C50f3B675EF5B124F9F30B8A2C0FFFFDC4D02A08C9B334FF64A4C05C6FA343958D855FFF9583AE138C92E81150FFF"
         out = self.dut.send_expect(f"port config 0 rss-hash-key ipv4-udp {key}", "testpmd> ")
-        self.dut.send_expect("quit", "# ", 30)
 
     def tear_down(self):
         """
         Run after each test case.
         """
-        self.dut.send_expect("quit", "# ", 30)
+        self.pmdout.quit()
 
     def tear_down_all(self):
         """
-- 
2.17.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dts] [PATCH v2]Add RSS Key Update Feature
  2020-07-15 20:08 ` [dts] [PATCH v2]Add RSS Key Update Feature David Liu
@ 2020-07-24  2:01   ` Tu, Lijuan
  2020-07-24 20:45     ` David Liu
  0 siblings, 1 reply; 3+ messages in thread
From: Tu, Lijuan @ 2020-07-24  2:01 UTC (permalink / raw)
  To: David Liu, dts; +Cc: lylavoie

Hi David,

V2 should be also based on DTS remote master, but not your local code.

When V1 are not merged, we submit V2, V2 should cover V1+ fix comments based on DTS remote code, maintainer will ignore V1 and merge V2. It's not make sense to merge patches with obvious defect. 

> -----Original Message-----
> From: dts <dts-bounces@dpdk.org> On Behalf Of David Liu
> Sent: 2020^[$BG/^[(B7^[$B7n^[(B16^[$BF|^[(B 4:09
> To: dts@dpdk.org
> Cc: lylavoie@iol.unh.edu; David Liu <dliu@iol.unh.edu>
> Subject: [dts] [PATCH v2]Add RSS Key Update Feature
> 
>  Merge duplicated code. Add flag in send packet and verify  result to identify
> symmetric used.
> 
> Signed-off-by: David Liu <dliu@iol.unh.edu>
> ---
>  tests/TestSuite_rss_key_update.py | 183 ++++++++----------------------
>  1 file changed, 46 insertions(+), 137 deletions(-)
> 
> diff --git a/tests/TestSuite_rss_key_update.py
> b/tests/TestSuite_rss_key_update.py
> index 0985f30..adb44f1 100644
> --- a/tests/TestSuite_rss_key_update.py
> +++ b/tests/TestSuite_rss_key_update.py
> @@ -39,7 +39,6 @@ Test the support of RSS Key Update by Poll Mode Drivers.
> 
>  import time
>  import re
> -import packet
>  import random
>  import utils
> 
> @@ -63,85 +62,37 @@ iptypes = {'ipv4-sctp': 'sctp',
> 
>  class TestRssKeyUpdate(TestCase):
> 
> -    def send_packet(self, itf, tran_type):
> +    def send_packet(self, itf, tran_type, symmetric):
>          """
>          Sends packets.
>          """
> +        packet_list = {
> +            'ipv4-sctp': 'IP(src="192.168.0.%d",
> dst="192.168.0.%d")/SCTP(sport=1024,dport=1024,tag=1)',
> +            'ipv4-other': 'IP(src="192.168.0.%d", dst="192.168.0.%d")',
> +            'ipv4-frag': 'IP(src="192.168.0.%d",
> dst="192.168.0.%d",frag=1,flags="MF")',
> +            'ipv4-udp': 'IP(src="192.168.0.%d",
> dst="192.168.0.%d")/UDP(sport=1024,dport=1024)',
> +            'ipv4-tcp': 'IP(src="192.168.0.%d",
> dst="192.168.0.%d")/TCP(sport=1024,dport=1024)',
> +            'ipv6-other':'IPv6(src="3ffe:2501:200:1fff::%d",
> dst="3ffe:2501:200:3::%d")',
> +            'ipv6-sctp': 'IPv6(src="3ffe:2501:200:1fff::%d",
> dst="3ffe:2501:200:3::%d", nh=132)/SCTP(sport=1024,dport=1024,tag=1)',
> +            'ipv6-udp': 'IPv6(src="3ffe:2501:200:1fff::%d",
> dst="3ffe:2501:200:3::%d")/UDP(sport=1024,dport=1024)',
> +            'ipv6-tcp': 'IPv6(src="3ffe:2501:200:1fff::%d",
> dst="3ffe:2501:200:3::%d")/TCP(sport=1024,dport=1024)',
> +            'ipv6-frag': 'IPv6(src="3ffe:2501:200:1fff::%d",
> dst="3ffe:2501:200:3::%d",nh=44)/IPv6ExtHdrFragment()'
> +        }
> +
>          received_pkts = []
>          self.tester.scapy_foreground()
>          self.dut.send_expect("start", "testpmd>")
>          mac = self.dut.get_mac_address(0)
> 
>          # send packet with different source and dest ip
> -        if tran_type == "ipv4-other":
> -            for i in range(10):
> -                packet = r'sendp([Ether(dst="%s",
> src=get_if_hwaddr("%s"))/IP(src="192.168.0.%d", dst="192.168.0.%d")],
> iface="%s")' % (
> -                    mac, itf, i + 1, i + 2, itf)
> -                self.tester.scapy_append(packet)
> -            self.tester.scapy_execute()
> -            time.sleep(.5)
> -        elif tran_type == "ipv4-tcp":
> -            for i in range(10):
> -                packet = r'sendp([Ether(dst="%s",
> src=get_if_hwaddr("%s"))/IP(src="192.168.0.%d",
> dst="192.168.0.%d")/TCP(sport=1024,dport=1024)], iface="%s")' % (
> -                    mac, itf, i + 1, i + 2, itf)
> -                self.tester.scapy_append(packet)
> -            self.tester.scapy_execute()
> -            time.sleep(.5)
> -        elif tran_type == "ipv4-udp":
> -            for i in range(10):
> -                packet = r'sendp([Ether(dst="%s",
> src=get_if_hwaddr("%s"))/IP(src="192.168.0.%d",
> dst="192.168.0.%d")/UDP(sport=1024,dport=1024)], iface="%s")' % (
> -                    mac, itf, i + 1, i + 2, itf)
> -                self.tester.scapy_append(packet)
> -            self.tester.scapy_execute()
> -            time.sleep(.5)
> -        elif tran_type == "ipv4-sctp":
> -            for i in range(10):
> -                packet = r'sendp([Ether(dst="%s",
> src=get_if_hwaddr("%s"))/IP(src="192.168.0.%d",
> dst="192.168.0.%d")/SCTP(sport=1024,dport=1024,tag=1)], iface="%s")' % (
> -                    mac, itf, i + 1, i + 2, itf)
> -                self.tester.scapy_append(packet)
> -            self.tester.scapy_execute()
> -            time.sleep(.5)
> -        elif tran_type == "ipv4-frag":
> -            for i in range(10):
> -                packet = r'sendp([Ether(dst="%s",
> src=get_if_hwaddr("%s"))/IP(src="192.168.0.%d",
> dst="192.168.0.%d",frag=1,flags="MF")], iface="%s")' % (
> -                    mac, itf, i + 1, i + 2, itf)
> -                self.tester.scapy_append(packet)
> -            self.tester.scapy_execute()
> -            time.sleep(.5)
> -
> -        elif tran_type == "ipv6-other":
> -            for i in range(10):
> -                packet = r'sendp([Ether(dst="%s",
> src=get_if_hwaddr("%s"))/IPv6(src="3ffe:2501:200:1fff::%d",
> dst="3ffe:2501:200:3::%d")], iface="%s")' % (
> -                    mac, itf, i + 1, i + 2, itf)
> -                self.tester.scapy_append(packet)
> -            self.tester.scapy_execute()
> -            time.sleep(.5)
> -        elif tran_type == "ipv6-tcp":
> -            for i in range(10):
> -                packet = r'sendp([Ether(dst="%s",
> src=get_if_hwaddr("%s"))/IPv6(src="3ffe:2501:200:1fff::%d",
> dst="3ffe:2501:200:3::%d")/TCP(sport=1024,dport=1024)], iface="%s")' % (
> -                    mac, itf, i + 1, i + 2, itf)
> -                self.tester.scapy_append(packet)
> -            self.tester.scapy_execute()
> -            time.sleep(.5)
> -        elif tran_type == "ipv6-udp":
> -            for i in range(10):
> -                packet = r'sendp([Ether(dst="%s",
> src=get_if_hwaddr("%s"))/IPv6(src="3ffe:2501:200:1fff::%d",
> dst="3ffe:2501:200:3::%d")/UDP(sport=1024,dport=1024)], iface="%s")' % (
> -                    mac, itf, i + 1, i + 2, itf)
> -                self.tester.scapy_append(packet)
> -            self.tester.scapy_execute()
> -            time.sleep(.5)
> -        elif tran_type == "ipv6-sctp":
> +        if tran_type in packet_list.keys():
> +            packet_temp = r'sendp([Ether(dst="%s",
> + src=get_if_hwaddr("%s"))/%s], iface="%s")' % (mac, itf,
> + packet_list[tran_type], itf)
>              for i in range(10):
> -                packet = r'sendp([Ether(dst="%s",
> src=get_if_hwaddr("%s"))/IPv6(src="3ffe:2501:200:1fff::%d",
> dst="3ffe:2501:200:3::%d", nh=132)/SCTP(sport=1024,dport=1024,tag=1)],
> iface="%s")' % (
> -                    mac, itf, i + 1, i + 2, itf)
> -                self.tester.scapy_append(packet)
> -            self.tester.scapy_execute()
> -            time.sleep(.5)
> -        elif tran_type == "ipv6-frag":
> -            for i in range(10):
> -                packet = r'sendp([Ether(dst="%s",
> src=get_if_hwaddr("%s"))/IPv6(src="3ffe:2501:200:1fff::%d",
> dst="3ffe:2501:200:3::%d",nh=44)/IPv6ExtHdrFragment()], iface="%s")' % (
> -                    mac, itf, i + 1, i + 2, itf)
> +                packet = packet_temp % (i + 1, i + 2)
>                  self.tester.scapy_append(packet)
> +                if symmetric:
> +                    packet2 = packet_list[tran_type] % (mac, itf, i + 2, i + 1, itf)
> +                    self.tester.scapy_append(packet2)
>              self.tester.scapy_execute()
>              time.sleep(.5)
>          else:
> @@ -154,102 +105,64 @@ class TestRssKeyUpdate(TestCase):
>          # collect the hash result and the queue id
>          for line in lines:
>              line = line.strip()
> -            if len(line) != 0 and line.strip().startswith("port "):
> +            if len(line) != 0 and line.startswith("port "):
>                  reta_line = {}
> -                rexp = r"port (\d)/queue (\d{1,2}): received (\d) packets"
> -                m = re.match(rexp, line.strip())
> +                rexp = r"port (\d+)/queue (\d+): received (\d+) packets"
> +                m = re.match(rexp, line)
>                  if m:
>                      reta_line["port"] = m.group(1)
>                      reta_line["queue"] = m.group(2)
> 
> -            elif len(line) != 0 and line.startswith(("src=",)):
> +            elif len(line) != 0 and line.startswith("src="):
>                  if "RSS hash" not in line:
>                      continue
>                  for item in line.split("-"):
>                      item = item.strip()
> -                    if(item.startswith("RSS hash")):
> +                    if item.startswith("RSS hash"):
>                          name, value = item.split("=", 1)
> 
>                  reta_line[name.strip()] = value.strip()
>                  received_pkts.append(reta_line)
> 
> -        return(self.verifyResult(received_pkts))
> +        return(self.verifyResult(received_pkts, symmetric))
> 
> -    def verifyResult(self, reta_lines):
> +    def verifyResult(self, reta_lines, symmetric):
>          """
>          Verify whether or not the result passes.
>          """
> -
> -        global reta_num
>          result = []
>          key_id = {}
>          self.verify(len(reta_lines) > 0, 'No packet received!')
>          self.result_table_create(
>              ['packet index', 'hash value', 'hash index', 'queue id', 'actual queue id',
> 'pass '])
> 
> -        i = 0
> -
> -        for tmp_reta_line in reta_lines:
> +        for i, tmp_reta_line in enumerate(reta_lines):
>              status = "false"
>              # compute the hash result of five tuple into the 7 LSBs value.
>              hash_index = int(tmp_reta_line["RSS hash"], 16) % reta_num
> -            print(reta_entries[hash_index], tmp_reta_line)
>              if(reta_entries[hash_index] == int(tmp_reta_line["queue"])):
>                  status = "true"
>                  result.insert(i, 0)
> +                if symmetric:
> +                    if(i % 2 == 1):
> +                        if(pre_RSS_hash == tmp_reta_line["RSS hash"]):
> +                            status = "true"
> +                            result.insert(len(reta_lines) + (i - 1) // 2, 0)
> +                        else:
> +                            status = "fail"
> +                            result.insert(len(reta_lines) + (i - 1) // 2, 1)
> +                    pre_RSS_hash = tmp_reta_line["RSS hash"]
>              else:
>                  status = "fail"
>                  result.insert(i, 1)
>              self.result_table_add(
>                  [i, tmp_reta_line["RSS hash"], hash_index, reta_entries[hash_index],
> tmp_reta_line["queue"], status])
> -            i = i + 1
> -            key_id[tmp_reta_line["RSS hash"]]=reta_entries[hash_index]
> +            key_id[tmp_reta_line["RSS hash"]] =
> + reta_entries[hash_index]
> 
>          self.result_table_print()
>          self.verify(sum(result) == 0, "the reta update function failed!")
>          return key_id
> 
> -    def verifyResult_symmetric(self, reta_lines):
> -        """
> -        Verify whether or not the result passes.
> -        """
> -
> -        global reta_num
> -        result = []
> -        key_id = {}
> -        self.verify(len(reta_lines) > 0, 'No packet received!')
> -        self.result_table_create(
> -            ['packet index', 'RSS hash', 'hash index', 'queue id', 'actual queue id', 'pass
> '])
> -
> -        i = 0
> -        for tmp_reta_line in reta_lines:
> -            status = "false"
> -            # compute the hash result of five tuple into the 7 LSBs value.
> -            hash_index = int(tmp_reta_line["RSS hash"], 16) % reta_num
> -            if(reta_entries[hash_index] == int(tmp_reta_line["queue"])):
> -                status = "true"
> -                result.insert(i, 0)
> -                if(i % 2 == 1):
> -                    if(pre_RSS_hash == tmp_reta_line["RSS hash"]):
> -                        status = "true"
> -                        result.insert(len(reta_lines) + (i - 1) // 2, 0)
> -                    else:
> -                        status = "fail"
> -                        result.insert(len(reta_lines) + (i - 1) // 2, 1)
> -                pre_RSS_hash = tmp_reta_line["RSS hash"]
> -            else:
> -                status = "fail"
> -                result.insert(i, 1)
> -            self.result_table_add(
> -                [i, tmp_reta_line["RSS hash"], hash_index, reta_entries[hash_index],
> tmp_reta_line["queue"], status])
> -            i = i + 1
> -            key_id[tmp_reta_line["RSS hash"]]=reta_entries[hash_index]
> -
> -        self.result_table_print()
> -        self.verify(
> -            sum(result) == 0, "the symmetric RSS hash function failed!")
> -        return key_id
> -
>      def set_up_all(self):
>          """
>          Run at the start of each test suite.
> @@ -282,7 +195,7 @@ class TestRssKeyUpdate(TestCase):
>          elif self.nic in ["redrockcanyou", "atwood", "boulderrapid"]:
>              reta_num = 128
>          else:
> -            self.verify(False, f"NIC Unsupported:{self.nic}")
> +            self.verify(False, f"NIC Unsupported: {self.nic}")
> 
>          cores = self.dut.get_core_list("all")
>          self.coremask = utils.create_mask(cores) @@ -300,8 +213,6 @@ class
> TestRssKeyUpdate(TestCase):
>          dutPorts = self.dut.get_ports(self.nic)
>          localPort = self.tester.get_local_port(dutPorts[0])
>          self.itf = self.tester.get_interface(localPort)
> -        global reta_num
> -        global iptypes
> 
>          self.dut.kill_all()
> 
> @@ -326,12 +237,12 @@ class TestRssKeyUpdate(TestCase):
>                  reta_entries.insert(i, random.randint(0, queue - 1))
>                  self.dut.send_expect(f"port config 0 rss reta ({i},{reta_entries[i]})",
> "testpmd> ")
> 
> -            ori_output = self.send_packet(self.itf, iptype)
> +            ori_output = self.send_packet(self.itf, iptype, False)
> 
>              self.dut.send_expect("show port 0 rss-hash key", "testpmd> ")
>              self.dut.send_expect(f"port config 0 rss-hash-key {iptype}
> 4439796BB54C50f3B675EF5B124F9F30B8A2C0FFFFDC4D02A08C9B334FF64A4C
> 05C6FA343958D855FFF9583AE138C92E81150FFF", "testpmd> ")
> 
> -            new_output = self.send_packet(self.itf, iptype)
> +            new_output = self.send_packet(self.itf, iptype, False)
> 
>              self.verify(ori_output != new_output, "before and after results are the
> same, hash key configuration failed!")
> 
> @@ -356,16 +267,15 @@ class TestRssKeyUpdate(TestCase):
>                  reta_entries.insert(i, random.randint(0, queue - 1))
>                  self.dut.send_expect(f"port config 0 rss reta ({i},{reta_entries[i]})",
> "testpmd> ")
> 
> -            ori_output = self.send_packet(self.itf, iptype)
> +            ori_output = self.send_packet(self.itf, iptype, True)
> 
>              out = self.dut.send_expect("show port 0 rss-hash key", "testpmd> ")
>              self.verify("rss disable" not in out, "rss is disable!")
>              self.dut.send_expect(f"port config 0 rss-hash-key {iptype}
> 4439796BB54C50f3B675EF5B124F9F30B8A2C0FFFFDC4D02A08C9B334FF64A4C
> 05C6FA343958D855FFF9583AE138C92E81150FFF", "testpmd> ")
> 
> -            new_output = self.send_packet(self.itf, iptype)
> +            new_output = self.send_packet(self.itf, iptype, True)
> 
>              self.verify(ori_output != new_output, "before and after results are the
> same, hash key configuration failed!")
> -        self.dut.send_expect("quit", "# ", 30)
> 
>      def test_set_hash_key_short_long(self):
> 
> @@ -384,26 +294,25 @@ class TestRssKeyUpdate(TestCase):
>          out = self.dut.send_expect("show port info all", "testpmd> ", 120)
>          self.verify(f"Hash key size in bytes: {nic_rss_key_size[self.nic]}" in out, "not
> expected hash key size!")
> 
> -        test_keies = {
> +        test_keys = {
> 
> "4439796BB54C50f3B675EF5B124F9F30B8A2C0FFFFDC4D02A08C9B334FF64A4
> C05C6FA343958D855FFF9583AE138C92E81150FFFFF": "longer",
> 
> "4439796BB54C50f3B675EF5B124F9F30B8A2C0DC4D02A08C9B334FF64A4C05C
> 6FA343958D855FFF9583AE138C92E81150FFF": "shorter",
>          }
> 
>          # config key length longer/shorter than 104 hexa-decimal numbers
> -        for key, error in test_keies.items():
> +        for key, error in test_keys.items():
>              out = self.dut.send_expect(f"port config 0 rss-hash-key ipv4-udp {key}",
> "testpmd> ")
>              self.verify("invalid" in out, f"Try to set hash key {error} than 104 hexa-
> decimal numbers!")
> 
>          # config ket length same as 104 hex-decimal numbers and keep the config
>          key =
> "4439796BB54C50f3B675EF5B124F9F30B8A2C0FFFFDC4D02A08C9B334FF64A4
> C05C6FA343958D855FFF9583AE138C92E81150FFF"
>          out = self.dut.send_expect(f"port config 0 rss-hash-key ipv4-udp {key}",
> "testpmd> ")
> -        self.dut.send_expect("quit", "# ", 30)
> 
>      def tear_down(self):
>          """
>          Run after each test case.
>          """
> -        self.dut.send_expect("quit", "# ", 30)
> +        self.pmdout.quit()
> 
>      def tear_down_all(self):
>          """
> --
> 2.17.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dts] [PATCH v2]Add RSS Key Update Feature
  2020-07-24  2:01   ` Tu, Lijuan
@ 2020-07-24 20:45     ` David Liu
  0 siblings, 0 replies; 3+ messages in thread
From: David Liu @ 2020-07-24 20:45 UTC (permalink / raw)
  To: Tu, Lijuan; +Cc: dts, lylavoie

[-- Attachment #1: Type: text/plain, Size: 18815 bytes --]

Hi Lijuan,

Sorry, what you suggested makes sense. The V2 I send was some changes that
will make the code cleaner by combining some duplicated code in the V1. To
solve this issue, I will submit a patch that combines both of these
versions.

Thanks
David

On Thu, Jul 23, 2020 at 10:01 PM Tu, Lijuan <lijuan.tu@intel.com> wrote:

> Hi David,
>
> V2 should be also based on DTS remote master, but not your local code.
>
> When V1 are not merged, we submit V2, V2 should cover V1+ fix comments
> based on DTS remote code, maintainer will ignore V1 and merge V2. It's not
> make sense to merge patches with obvious defect.
>
> > -----Original Message-----
> > From: dts <dts-bounces@dpdk.org> On Behalf Of David Liu
> > Sent: 2020年7月16日 4:09
> > To: dts@dpdk.org
> > Cc: lylavoie@iol.unh.edu; David Liu <dliu@iol.unh.edu>
> > Subject: [dts] [PATCH v2]Add RSS Key Update Feature
> >
> >  Merge duplicated code. Add flag in send packet and verify  result to
> identify
> > symmetric used.
> >
> > Signed-off-by: David Liu <dliu@iol.unh.edu>
> > ---
> >  tests/TestSuite_rss_key_update.py | 183 ++++++++----------------------
> >  1 file changed, 46 insertions(+), 137 deletions(-)
> >
> > diff --git a/tests/TestSuite_rss_key_update.py
> > b/tests/TestSuite_rss_key_update.py
> > index 0985f30..adb44f1 100644
> > --- a/tests/TestSuite_rss_key_update.py
> > +++ b/tests/TestSuite_rss_key_update.py
> > @@ -39,7 +39,6 @@ Test the support of RSS Key Update by Poll Mode
> Drivers.
> >
> >  import time
> >  import re
> > -import packet
> >  import random
> >  import utils
> >
> > @@ -63,85 +62,37 @@ iptypes = {'ipv4-sctp': 'sctp',
> >
> >  class TestRssKeyUpdate(TestCase):
> >
> > -    def send_packet(self, itf, tran_type):
> > +    def send_packet(self, itf, tran_type, symmetric):
> >          """
> >          Sends packets.
> >          """
> > +        packet_list = {
> > +            'ipv4-sctp': 'IP(src="192.168.0.%d",
> > dst="192.168.0.%d")/SCTP(sport=1024,dport=1024,tag=1)',
> > +            'ipv4-other': 'IP(src="192.168.0.%d", dst="192.168.0.%d")',
> > +            'ipv4-frag': 'IP(src="192.168.0.%d",
> > dst="192.168.0.%d",frag=1,flags="MF")',
> > +            'ipv4-udp': 'IP(src="192.168.0.%d",
> > dst="192.168.0.%d")/UDP(sport=1024,dport=1024)',
> > +            'ipv4-tcp': 'IP(src="192.168.0.%d",
> > dst="192.168.0.%d")/TCP(sport=1024,dport=1024)',
> > +            'ipv6-other':'IPv6(src="3ffe:2501:200:1fff::%d",
> > dst="3ffe:2501:200:3::%d")',
> > +            'ipv6-sctp': 'IPv6(src="3ffe:2501:200:1fff::%d",
> > dst="3ffe:2501:200:3::%d", nh=132)/SCTP(sport=1024,dport=1024,tag=1)',
> > +            'ipv6-udp': 'IPv6(src="3ffe:2501:200:1fff::%d",
> > dst="3ffe:2501:200:3::%d")/UDP(sport=1024,dport=1024)',
> > +            'ipv6-tcp': 'IPv6(src="3ffe:2501:200:1fff::%d",
> > dst="3ffe:2501:200:3::%d")/TCP(sport=1024,dport=1024)',
> > +            'ipv6-frag': 'IPv6(src="3ffe:2501:200:1fff::%d",
> > dst="3ffe:2501:200:3::%d",nh=44)/IPv6ExtHdrFragment()'
> > +        }
> > +
> >          received_pkts = []
> >          self.tester.scapy_foreground()
> >          self.dut.send_expect("start", "testpmd>")
> >          mac = self.dut.get_mac_address(0)
> >
> >          # send packet with different source and dest ip
> > -        if tran_type == "ipv4-other":
> > -            for i in range(10):
> > -                packet = r'sendp([Ether(dst="%s",
> > src=get_if_hwaddr("%s"))/IP(src="192.168.0.%d", dst="192.168.0.%d")],
> > iface="%s")' % (
> > -                    mac, itf, i + 1, i + 2, itf)
> > -                self.tester.scapy_append(packet)
> > -            self.tester.scapy_execute()
> > -            time.sleep(.5)
> > -        elif tran_type == "ipv4-tcp":
> > -            for i in range(10):
> > -                packet = r'sendp([Ether(dst="%s",
> > src=get_if_hwaddr("%s"))/IP(src="192.168.0.%d",
> > dst="192.168.0.%d")/TCP(sport=1024,dport=1024)], iface="%s")' % (
> > -                    mac, itf, i + 1, i + 2, itf)
> > -                self.tester.scapy_append(packet)
> > -            self.tester.scapy_execute()
> > -            time.sleep(.5)
> > -        elif tran_type == "ipv4-udp":
> > -            for i in range(10):
> > -                packet = r'sendp([Ether(dst="%s",
> > src=get_if_hwaddr("%s"))/IP(src="192.168.0.%d",
> > dst="192.168.0.%d")/UDP(sport=1024,dport=1024)], iface="%s")' % (
> > -                    mac, itf, i + 1, i + 2, itf)
> > -                self.tester.scapy_append(packet)
> > -            self.tester.scapy_execute()
> > -            time.sleep(.5)
> > -        elif tran_type == "ipv4-sctp":
> > -            for i in range(10):
> > -                packet = r'sendp([Ether(dst="%s",
> > src=get_if_hwaddr("%s"))/IP(src="192.168.0.%d",
> > dst="192.168.0.%d")/SCTP(sport=1024,dport=1024,tag=1)], iface="%s")' % (
> > -                    mac, itf, i + 1, i + 2, itf)
> > -                self.tester.scapy_append(packet)
> > -            self.tester.scapy_execute()
> > -            time.sleep(.5)
> > -        elif tran_type == "ipv4-frag":
> > -            for i in range(10):
> > -                packet = r'sendp([Ether(dst="%s",
> > src=get_if_hwaddr("%s"))/IP(src="192.168.0.%d",
> > dst="192.168.0.%d",frag=1,flags="MF")], iface="%s")' % (
> > -                    mac, itf, i + 1, i + 2, itf)
> > -                self.tester.scapy_append(packet)
> > -            self.tester.scapy_execute()
> > -            time.sleep(.5)
> > -
> > -        elif tran_type == "ipv6-other":
> > -            for i in range(10):
> > -                packet = r'sendp([Ether(dst="%s",
> > src=get_if_hwaddr("%s"))/IPv6(src="3ffe:2501:200:1fff::%d",
> > dst="3ffe:2501:200:3::%d")], iface="%s")' % (
> > -                    mac, itf, i + 1, i + 2, itf)
> > -                self.tester.scapy_append(packet)
> > -            self.tester.scapy_execute()
> > -            time.sleep(.5)
> > -        elif tran_type == "ipv6-tcp":
> > -            for i in range(10):
> > -                packet = r'sendp([Ether(dst="%s",
> > src=get_if_hwaddr("%s"))/IPv6(src="3ffe:2501:200:1fff::%d",
> > dst="3ffe:2501:200:3::%d")/TCP(sport=1024,dport=1024)], iface="%s")' % (
> > -                    mac, itf, i + 1, i + 2, itf)
> > -                self.tester.scapy_append(packet)
> > -            self.tester.scapy_execute()
> > -            time.sleep(.5)
> > -        elif tran_type == "ipv6-udp":
> > -            for i in range(10):
> > -                packet = r'sendp([Ether(dst="%s",
> > src=get_if_hwaddr("%s"))/IPv6(src="3ffe:2501:200:1fff::%d",
> > dst="3ffe:2501:200:3::%d")/UDP(sport=1024,dport=1024)], iface="%s")' % (
> > -                    mac, itf, i + 1, i + 2, itf)
> > -                self.tester.scapy_append(packet)
> > -            self.tester.scapy_execute()
> > -            time.sleep(.5)
> > -        elif tran_type == "ipv6-sctp":
> > +        if tran_type in packet_list.keys():
> > +            packet_temp = r'sendp([Ether(dst="%s",
> > + src=get_if_hwaddr("%s"))/%s], iface="%s")' % (mac, itf,
> > + packet_list[tran_type], itf)
> >              for i in range(10):
> > -                packet = r'sendp([Ether(dst="%s",
> > src=get_if_hwaddr("%s"))/IPv6(src="3ffe:2501:200:1fff::%d",
> > dst="3ffe:2501:200:3::%d", nh=132)/SCTP(sport=1024,dport=1024,tag=1)],
> > iface="%s")' % (
> > -                    mac, itf, i + 1, i + 2, itf)
> > -                self.tester.scapy_append(packet)
> > -            self.tester.scapy_execute()
> > -            time.sleep(.5)
> > -        elif tran_type == "ipv6-frag":
> > -            for i in range(10):
> > -                packet = r'sendp([Ether(dst="%s",
> > src=get_if_hwaddr("%s"))/IPv6(src="3ffe:2501:200:1fff::%d",
> > dst="3ffe:2501:200:3::%d",nh=44)/IPv6ExtHdrFragment()], iface="%s")' % (
> > -                    mac, itf, i + 1, i + 2, itf)
> > +                packet = packet_temp % (i + 1, i + 2)
> >                  self.tester.scapy_append(packet)
> > +                if symmetric:
> > +                    packet2 = packet_list[tran_type] % (mac, itf, i +
> 2, i + 1, itf)
> > +                    self.tester.scapy_append(packet2)
> >              self.tester.scapy_execute()
> >              time.sleep(.5)
> >          else:
> > @@ -154,102 +105,64 @@ class TestRssKeyUpdate(TestCase):
> >          # collect the hash result and the queue id
> >          for line in lines:
> >              line = line.strip()
> > -            if len(line) != 0 and line.strip().startswith("port "):
> > +            if len(line) != 0 and line.startswith("port "):
> >                  reta_line = {}
> > -                rexp = r"port (\d)/queue (\d{1,2}): received (\d)
> packets"
> > -                m = re.match(rexp, line.strip())
> > +                rexp = r"port (\d+)/queue (\d+): received (\d+) packets"
> > +                m = re.match(rexp, line)
> >                  if m:
> >                      reta_line["port"] = m.group(1)
> >                      reta_line["queue"] = m.group(2)
> >
> > -            elif len(line) != 0 and line.startswith(("src=",)):
> > +            elif len(line) != 0 and line.startswith("src="):
> >                  if "RSS hash" not in line:
> >                      continue
> >                  for item in line.split("-"):
> >                      item = item.strip()
> > -                    if(item.startswith("RSS hash")):
> > +                    if item.startswith("RSS hash"):
> >                          name, value = item.split("=", 1)
> >
> >                  reta_line[name.strip()] = value.strip()
> >                  received_pkts.append(reta_line)
> >
> > -        return(self.verifyResult(received_pkts))
> > +        return(self.verifyResult(received_pkts, symmetric))
> >
> > -    def verifyResult(self, reta_lines):
> > +    def verifyResult(self, reta_lines, symmetric):
> >          """
> >          Verify whether or not the result passes.
> >          """
> > -
> > -        global reta_num
> >          result = []
> >          key_id = {}
> >          self.verify(len(reta_lines) > 0, 'No packet received!')
> >          self.result_table_create(
> >              ['packet index', 'hash value', 'hash index', 'queue id',
> 'actual queue id',
> > 'pass '])
> >
> > -        i = 0
> > -
> > -        for tmp_reta_line in reta_lines:
> > +        for i, tmp_reta_line in enumerate(reta_lines):
> >              status = "false"
> >              # compute the hash result of five tuple into the 7 LSBs
> value.
> >              hash_index = int(tmp_reta_line["RSS hash"], 16) % reta_num
> > -            print(reta_entries[hash_index], tmp_reta_line)
> >              if(reta_entries[hash_index] == int(tmp_reta_line["queue"])):
> >                  status = "true"
> >                  result.insert(i, 0)
> > +                if symmetric:
> > +                    if(i % 2 == 1):
> > +                        if(pre_RSS_hash == tmp_reta_line["RSS hash"]):
> > +                            status = "true"
> > +                            result.insert(len(reta_lines) + (i - 1) //
> 2, 0)
> > +                        else:
> > +                            status = "fail"
> > +                            result.insert(len(reta_lines) + (i - 1) //
> 2, 1)
> > +                    pre_RSS_hash = tmp_reta_line["RSS hash"]
> >              else:
> >                  status = "fail"
> >                  result.insert(i, 1)
> >              self.result_table_add(
> >                  [i, tmp_reta_line["RSS hash"], hash_index,
> reta_entries[hash_index],
> > tmp_reta_line["queue"], status])
> > -            i = i + 1
> > -            key_id[tmp_reta_line["RSS hash"]]=reta_entries[hash_index]
> > +            key_id[tmp_reta_line["RSS hash"]] =
> > + reta_entries[hash_index]
> >
> >          self.result_table_print()
> >          self.verify(sum(result) == 0, "the reta update function
> failed!")
> >          return key_id
> >
> > -    def verifyResult_symmetric(self, reta_lines):
> > -        """
> > -        Verify whether or not the result passes.
> > -        """
> > -
> > -        global reta_num
> > -        result = []
> > -        key_id = {}
> > -        self.verify(len(reta_lines) > 0, 'No packet received!')
> > -        self.result_table_create(
> > -            ['packet index', 'RSS hash', 'hash index', 'queue id',
> 'actual queue id', 'pass
> > '])
> > -
> > -        i = 0
> > -        for tmp_reta_line in reta_lines:
> > -            status = "false"
> > -            # compute the hash result of five tuple into the 7 LSBs
> value.
> > -            hash_index = int(tmp_reta_line["RSS hash"], 16) % reta_num
> > -            if(reta_entries[hash_index] == int(tmp_reta_line["queue"])):
> > -                status = "true"
> > -                result.insert(i, 0)
> > -                if(i % 2 == 1):
> > -                    if(pre_RSS_hash == tmp_reta_line["RSS hash"]):
> > -                        status = "true"
> > -                        result.insert(len(reta_lines) + (i - 1) // 2, 0)
> > -                    else:
> > -                        status = "fail"
> > -                        result.insert(len(reta_lines) + (i - 1) // 2, 1)
> > -                pre_RSS_hash = tmp_reta_line["RSS hash"]
> > -            else:
> > -                status = "fail"
> > -                result.insert(i, 1)
> > -            self.result_table_add(
> > -                [i, tmp_reta_line["RSS hash"], hash_index,
> reta_entries[hash_index],
> > tmp_reta_line["queue"], status])
> > -            i = i + 1
> > -            key_id[tmp_reta_line["RSS hash"]]=reta_entries[hash_index]
> > -
> > -        self.result_table_print()
> > -        self.verify(
> > -            sum(result) == 0, "the symmetric RSS hash function failed!")
> > -        return key_id
> > -
> >      def set_up_all(self):
> >          """
> >          Run at the start of each test suite.
> > @@ -282,7 +195,7 @@ class TestRssKeyUpdate(TestCase):
> >          elif self.nic in ["redrockcanyou", "atwood", "boulderrapid"]:
> >              reta_num = 128
> >          else:
> > -            self.verify(False, f"NIC Unsupported:{self.nic}")
> > +            self.verify(False, f"NIC Unsupported: {self.nic}")
> >
> >          cores = self.dut.get_core_list("all")
> >          self.coremask = utils.create_mask(cores) @@ -300,8 +213,6 @@
> class
> > TestRssKeyUpdate(TestCase):
> >          dutPorts = self.dut.get_ports(self.nic)
> >          localPort = self.tester.get_local_port(dutPorts[0])
> >          self.itf = self.tester.get_interface(localPort)
> > -        global reta_num
> > -        global iptypes
> >
> >          self.dut.kill_all()
> >
> > @@ -326,12 +237,12 @@ class TestRssKeyUpdate(TestCase):
> >                  reta_entries.insert(i, random.randint(0, queue - 1))
> >                  self.dut.send_expect(f"port config 0 rss reta
> ({i},{reta_entries[i]})",
> > "testpmd> ")
> >
> > -            ori_output = self.send_packet(self.itf, iptype)
> > +            ori_output = self.send_packet(self.itf, iptype, False)
> >
> >              self.dut.send_expect("show port 0 rss-hash key", "testpmd>
> ")
> >              self.dut.send_expect(f"port config 0 rss-hash-key {iptype}
> > 4439796BB54C50f3B675EF5B124F9F30B8A2C0FFFFDC4D02A08C9B334FF64A4C
> > 05C6FA343958D855FFF9583AE138C92E81150FFF", "testpmd> ")
> >
> > -            new_output = self.send_packet(self.itf, iptype)
> > +            new_output = self.send_packet(self.itf, iptype, False)
> >
> >              self.verify(ori_output != new_output, "before and after
> results are the
> > same, hash key configuration failed!")
> >
> > @@ -356,16 +267,15 @@ class TestRssKeyUpdate(TestCase):
> >                  reta_entries.insert(i, random.randint(0, queue - 1))
> >                  self.dut.send_expect(f"port config 0 rss reta
> ({i},{reta_entries[i]})",
> > "testpmd> ")
> >
> > -            ori_output = self.send_packet(self.itf, iptype)
> > +            ori_output = self.send_packet(self.itf, iptype, True)
> >
> >              out = self.dut.send_expect("show port 0 rss-hash key",
> "testpmd> ")
> >              self.verify("rss disable" not in out, "rss is disable!")
> >              self.dut.send_expect(f"port config 0 rss-hash-key {iptype}
> > 4439796BB54C50f3B675EF5B124F9F30B8A2C0FFFFDC4D02A08C9B334FF64A4C
> > 05C6FA343958D855FFF9583AE138C92E81150FFF", "testpmd> ")
> >
> > -            new_output = self.send_packet(self.itf, iptype)
> > +            new_output = self.send_packet(self.itf, iptype, True)
> >
> >              self.verify(ori_output != new_output, "before and after
> results are the
> > same, hash key configuration failed!")
> > -        self.dut.send_expect("quit", "# ", 30)
> >
> >      def test_set_hash_key_short_long(self):
> >
> > @@ -384,26 +294,25 @@ class TestRssKeyUpdate(TestCase):
> >          out = self.dut.send_expect("show port info all", "testpmd> ",
> 120)
> >          self.verify(f"Hash key size in bytes:
> {nic_rss_key_size[self.nic]}" in out, "not
> > expected hash key size!")
> >
> > -        test_keies = {
> > +        test_keys = {
> >
> > "4439796BB54C50f3B675EF5B124F9F30B8A2C0FFFFDC4D02A08C9B334FF64A4
> > C05C6FA343958D855FFF9583AE138C92E81150FFFFF": "longer",
> >
> > "4439796BB54C50f3B675EF5B124F9F30B8A2C0DC4D02A08C9B334FF64A4C05C
> > 6FA343958D855FFF9583AE138C92E81150FFF": "shorter",
> >          }
> >
> >          # config key length longer/shorter than 104 hexa-decimal numbers
> > -        for key, error in test_keies.items():
> > +        for key, error in test_keys.items():
> >              out = self.dut.send_expect(f"port config 0 rss-hash-key
> ipv4-udp {key}",
> > "testpmd> ")
> >              self.verify("invalid" in out, f"Try to set hash key {error}
> than 104 hexa-
> > decimal numbers!")
> >
> >          # config ket length same as 104 hex-decimal numbers and keep
> the config
> >          key =
> > "4439796BB54C50f3B675EF5B124F9F30B8A2C0FFFFDC4D02A08C9B334FF64A4
> > C05C6FA343958D855FFF9583AE138C92E81150FFF"
> >          out = self.dut.send_expect(f"port config 0 rss-hash-key
> ipv4-udp {key}",
> > "testpmd> ")
> > -        self.dut.send_expect("quit", "# ", 30)
> >
> >      def tear_down(self):
> >          """
> >          Run after each test case.
> >          """
> > -        self.dut.send_expect("quit", "# ", 30)
> > +        self.pmdout.quit()
> >
> >      def tear_down_all(self):
> >          """
> > --
> > 2.17.1
>
>

[-- Attachment #2: Type: text/html, Size: 25384 bytes --]

<div dir="ltr">Hi Lijuan,<br><div><br></div><div>Sorry, what you suggested makes sense. The V2 I send was some changes that will make the code cleaner by combining some duplicated code in the V1. To solve this issue, I will submit a patch that combines both of these versions. </div><div><br></div><div>Thanks</div><div>David</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jul 23, 2020 at 10:01 PM Tu, Lijuan &lt;<a href="mailto:lijuan.tu@intel.com" target="_blank">lijuan.tu@intel.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi David,<br>
<br>
V2 should be also based on DTS remote master, but not your local code.<br>
<br>
When V1 are not merged, we submit V2, V2 should cover V1+ fix comments based on DTS remote code, maintainer will ignore V1 and merge V2. It&#39;s not make sense to merge patches with obvious defect. <br>
<br>
&gt; -----Original Message-----<br>
&gt; From: dts &lt;<a href="mailto:dts-bounces@dpdk.org" target="_blank">dts-bounces@dpdk.org</a>&gt; On Behalf Of David Liu<br>
&gt; Sent: 2020年7月16日 4:09<br>
&gt; To: <a href="mailto:dts@dpdk.org" target="_blank">dts@dpdk.org</a><br>
&gt; Cc: <a href="mailto:lylavoie@iol.unh.edu" target="_blank">lylavoie@iol.unh.edu</a>; David Liu &lt;<a href="mailto:dliu@iol.unh.edu" target="_blank">dliu@iol.unh.edu</a>&gt;<br>
&gt; Subject: [dts] [PATCH v2]Add RSS Key Update Feature<br>
&gt; <br>
&gt;  Merge duplicated code. Add flag in send packet and verify  result to identify<br>
&gt; symmetric used.<br>
&gt; <br>
&gt; Signed-off-by: David Liu &lt;<a href="mailto:dliu@iol.unh.edu" target="_blank">dliu@iol.unh.edu</a>&gt;<br>
&gt; ---<br>
&gt;  tests/TestSuite_rss_key_update.py | 183 ++++++++----------------------<br>
&gt;  1 file changed, 46 insertions(+), 137 deletions(-)<br>
&gt; <br>
&gt; diff --git a/tests/TestSuite_rss_key_update.py<br>
&gt; b/tests/TestSuite_rss_key_update.py<br>
&gt; index 0985f30..adb44f1 100644<br>
&gt; --- a/tests/TestSuite_rss_key_update.py<br>
&gt; +++ b/tests/TestSuite_rss_key_update.py<br>
&gt; @@ -39,7 +39,6 @@ Test the support of RSS Key Update by Poll Mode Drivers.<br>
&gt; <br>
&gt;  import time<br>
&gt;  import re<br>
&gt; -import packet<br>
&gt;  import random<br>
&gt;  import utils<br>
&gt; <br>
&gt; @@ -63,85 +62,37 @@ iptypes = {&#39;ipv4-sctp&#39;: &#39;sctp&#39;,<br>
&gt; <br>
&gt;  class TestRssKeyUpdate(TestCase):<br>
&gt; <br>
&gt; -    def send_packet(self, itf, tran_type):<br>
&gt; +    def send_packet(self, itf, tran_type, symmetric):<br>
&gt;          &quot;&quot;&quot;<br>
&gt;          Sends packets.<br>
&gt;          &quot;&quot;&quot;<br>
&gt; +        packet_list = {<br>
&gt; +            &#39;ipv4-sctp&#39;: &#39;IP(src=&quot;192.168.0.%d&quot;,<br>
&gt; dst=&quot;192.168.0.%d&quot;)/SCTP(sport=1024,dport=1024,tag=1)&#39;,<br>
&gt; +            &#39;ipv4-other&#39;: &#39;IP(src=&quot;192.168.0.%d&quot;, dst=&quot;192.168.0.%d&quot;)&#39;,<br>
&gt; +            &#39;ipv4-frag&#39;: &#39;IP(src=&quot;192.168.0.%d&quot;,<br>
&gt; dst=&quot;192.168.0.%d&quot;,frag=1,flags=&quot;MF&quot;)&#39;,<br>
&gt; +            &#39;ipv4-udp&#39;: &#39;IP(src=&quot;192.168.0.%d&quot;,<br>
&gt; dst=&quot;192.168.0.%d&quot;)/UDP(sport=1024,dport=1024)&#39;,<br>
&gt; +            &#39;ipv4-tcp&#39;: &#39;IP(src=&quot;192.168.0.%d&quot;,<br>
&gt; dst=&quot;192.168.0.%d&quot;)/TCP(sport=1024,dport=1024)&#39;,<br>
&gt; +            &#39;ipv6-other&#39;:&#39;IPv6(src=&quot;3ffe:2501:200:1fff::%d&quot;,<br>
&gt; dst=&quot;3ffe:2501:200:3::%d&quot;)&#39;,<br>
&gt; +            &#39;ipv6-sctp&#39;: &#39;IPv6(src=&quot;3ffe:2501:200:1fff::%d&quot;,<br>
&gt; dst=&quot;3ffe:2501:200:3::%d&quot;, nh=132)/SCTP(sport=1024,dport=1024,tag=1)&#39;,<br>
&gt; +            &#39;ipv6-udp&#39;: &#39;IPv6(src=&quot;3ffe:2501:200:1fff::%d&quot;,<br>
&gt; dst=&quot;3ffe:2501:200:3::%d&quot;)/UDP(sport=1024,dport=1024)&#39;,<br>
&gt; +            &#39;ipv6-tcp&#39;: &#39;IPv6(src=&quot;3ffe:2501:200:1fff::%d&quot;,<br>
&gt; dst=&quot;3ffe:2501:200:3::%d&quot;)/TCP(sport=1024,dport=1024)&#39;,<br>
&gt; +            &#39;ipv6-frag&#39;: &#39;IPv6(src=&quot;3ffe:2501:200:1fff::%d&quot;,<br>
&gt; dst=&quot;3ffe:2501:200:3::%d&quot;,nh=44)/IPv6ExtHdrFragment()&#39;<br>
&gt; +        }<br>
&gt; +<br>
&gt;          received_pkts = []<br>
&gt;          self.tester.scapy_foreground()<br>
&gt;          self.dut.send_expect(&quot;start&quot;, &quot;testpmd&gt;&quot;)<br>
&gt;          mac = self.dut.get_mac_address(0)<br>
&gt; <br>
&gt;          # send packet with different source and dest ip<br>
&gt; -        if tran_type == &quot;ipv4-other&quot;:<br>
&gt; -            for i in range(10):<br>
&gt; -                packet = r&#39;sendp([Ether(dst=&quot;%s&quot;,<br>
&gt; src=get_if_hwaddr(&quot;%s&quot;))/IP(src=&quot;192.168.0.%d&quot;, dst=&quot;192.168.0.%d&quot;)],<br>
&gt; iface=&quot;%s&quot;)&#39; % (<br>
&gt; -                    mac, itf, i + 1, i + 2, itf)<br>
&gt; -                self.tester.scapy_append(packet)<br>
&gt; -            self.tester.scapy_execute()<br>
&gt; -            time.sleep(.5)<br>
&gt; -        elif tran_type == &quot;ipv4-tcp&quot;:<br>
&gt; -            for i in range(10):<br>
&gt; -                packet = r&#39;sendp([Ether(dst=&quot;%s&quot;,<br>
&gt; src=get_if_hwaddr(&quot;%s&quot;))/IP(src=&quot;192.168.0.%d&quot;,<br>
&gt; dst=&quot;192.168.0.%d&quot;)/TCP(sport=1024,dport=1024)], iface=&quot;%s&quot;)&#39; % (<br>
&gt; -                    mac, itf, i + 1, i + 2, itf)<br>
&gt; -                self.tester.scapy_append(packet)<br>
&gt; -            self.tester.scapy_execute()<br>
&gt; -            time.sleep(.5)<br>
&gt; -        elif tran_type == &quot;ipv4-udp&quot;:<br>
&gt; -            for i in range(10):<br>
&gt; -                packet = r&#39;sendp([Ether(dst=&quot;%s&quot;,<br>
&gt; src=get_if_hwaddr(&quot;%s&quot;))/IP(src=&quot;192.168.0.%d&quot;,<br>
&gt; dst=&quot;192.168.0.%d&quot;)/UDP(sport=1024,dport=1024)], iface=&quot;%s&quot;)&#39; % (<br>
&gt; -                    mac, itf, i + 1, i + 2, itf)<br>
&gt; -                self.tester.scapy_append(packet)<br>
&gt; -            self.tester.scapy_execute()<br>
&gt; -            time.sleep(.5)<br>
&gt; -        elif tran_type == &quot;ipv4-sctp&quot;:<br>
&gt; -            for i in range(10):<br>
&gt; -                packet = r&#39;sendp([Ether(dst=&quot;%s&quot;,<br>
&gt; src=get_if_hwaddr(&quot;%s&quot;))/IP(src=&quot;192.168.0.%d&quot;,<br>
&gt; dst=&quot;192.168.0.%d&quot;)/SCTP(sport=1024,dport=1024,tag=1)], iface=&quot;%s&quot;)&#39; % (<br>
&gt; -                    mac, itf, i + 1, i + 2, itf)<br>
&gt; -                self.tester.scapy_append(packet)<br>
&gt; -            self.tester.scapy_execute()<br>
&gt; -            time.sleep(.5)<br>
&gt; -        elif tran_type == &quot;ipv4-frag&quot;:<br>
&gt; -            for i in range(10):<br>
&gt; -                packet = r&#39;sendp([Ether(dst=&quot;%s&quot;,<br>
&gt; src=get_if_hwaddr(&quot;%s&quot;))/IP(src=&quot;192.168.0.%d&quot;,<br>
&gt; dst=&quot;192.168.0.%d&quot;,frag=1,flags=&quot;MF&quot;)], iface=&quot;%s&quot;)&#39; % (<br>
&gt; -                    mac, itf, i + 1, i + 2, itf)<br>
&gt; -                self.tester.scapy_append(packet)<br>
&gt; -            self.tester.scapy_execute()<br>
&gt; -            time.sleep(.5)<br>
&gt; -<br>
&gt; -        elif tran_type == &quot;ipv6-other&quot;:<br>
&gt; -            for i in range(10):<br>
&gt; -                packet = r&#39;sendp([Ether(dst=&quot;%s&quot;,<br>
&gt; src=get_if_hwaddr(&quot;%s&quot;))/IPv6(src=&quot;3ffe:2501:200:1fff::%d&quot;,<br>
&gt; dst=&quot;3ffe:2501:200:3::%d&quot;)], iface=&quot;%s&quot;)&#39; % (<br>
&gt; -                    mac, itf, i + 1, i + 2, itf)<br>
&gt; -                self.tester.scapy_append(packet)<br>
&gt; -            self.tester.scapy_execute()<br>
&gt; -            time.sleep(.5)<br>
&gt; -        elif tran_type == &quot;ipv6-tcp&quot;:<br>
&gt; -            for i in range(10):<br>
&gt; -                packet = r&#39;sendp([Ether(dst=&quot;%s&quot;,<br>
&gt; src=get_if_hwaddr(&quot;%s&quot;))/IPv6(src=&quot;3ffe:2501:200:1fff::%d&quot;,<br>
&gt; dst=&quot;3ffe:2501:200:3::%d&quot;)/TCP(sport=1024,dport=1024)], iface=&quot;%s&quot;)&#39; % (<br>
&gt; -                    mac, itf, i + 1, i + 2, itf)<br>
&gt; -                self.tester.scapy_append(packet)<br>
&gt; -            self.tester.scapy_execute()<br>
&gt; -            time.sleep(.5)<br>
&gt; -        elif tran_type == &quot;ipv6-udp&quot;:<br>
&gt; -            for i in range(10):<br>
&gt; -                packet = r&#39;sendp([Ether(dst=&quot;%s&quot;,<br>
&gt; src=get_if_hwaddr(&quot;%s&quot;))/IPv6(src=&quot;3ffe:2501:200:1fff::%d&quot;,<br>
&gt; dst=&quot;3ffe:2501:200:3::%d&quot;)/UDP(sport=1024,dport=1024)], iface=&quot;%s&quot;)&#39; % (<br>
&gt; -                    mac, itf, i + 1, i + 2, itf)<br>
&gt; -                self.tester.scapy_append(packet)<br>
&gt; -            self.tester.scapy_execute()<br>
&gt; -            time.sleep(.5)<br>
&gt; -        elif tran_type == &quot;ipv6-sctp&quot;:<br>
&gt; +        if tran_type in packet_list.keys():<br>
&gt; +            packet_temp = r&#39;sendp([Ether(dst=&quot;%s&quot;,<br>
&gt; + src=get_if_hwaddr(&quot;%s&quot;))/%s], iface=&quot;%s&quot;)&#39; % (mac, itf,<br>
&gt; + packet_list[tran_type], itf)<br>
&gt;              for i in range(10):<br>
&gt; -                packet = r&#39;sendp([Ether(dst=&quot;%s&quot;,<br>
&gt; src=get_if_hwaddr(&quot;%s&quot;))/IPv6(src=&quot;3ffe:2501:200:1fff::%d&quot;,<br>
&gt; dst=&quot;3ffe:2501:200:3::%d&quot;, nh=132)/SCTP(sport=1024,dport=1024,tag=1)],<br>
&gt; iface=&quot;%s&quot;)&#39; % (<br>
&gt; -                    mac, itf, i + 1, i + 2, itf)<br>
&gt; -                self.tester.scapy_append(packet)<br>
&gt; -            self.tester.scapy_execute()<br>
&gt; -            time.sleep(.5)<br>
&gt; -        elif tran_type == &quot;ipv6-frag&quot;:<br>
&gt; -            for i in range(10):<br>
&gt; -                packet = r&#39;sendp([Ether(dst=&quot;%s&quot;,<br>
&gt; src=get_if_hwaddr(&quot;%s&quot;))/IPv6(src=&quot;3ffe:2501:200:1fff::%d&quot;,<br>
&gt; dst=&quot;3ffe:2501:200:3::%d&quot;,nh=44)/IPv6ExtHdrFragment()], iface=&quot;%s&quot;)&#39; % (<br>
&gt; -                    mac, itf, i + 1, i + 2, itf)<br>
&gt; +                packet = packet_temp % (i + 1, i + 2)<br>
&gt;                  self.tester.scapy_append(packet)<br>
&gt; +                if symmetric:<br>
&gt; +                    packet2 = packet_list[tran_type] % (mac, itf, i + 2, i + 1, itf)<br>
&gt; +                    self.tester.scapy_append(packet2)<br>
&gt;              self.tester.scapy_execute()<br>
&gt;              time.sleep(.5)<br>
&gt;          else:<br>
&gt; @@ -154,102 +105,64 @@ class TestRssKeyUpdate(TestCase):<br>
&gt;          # collect the hash result and the queue id<br>
&gt;          for line in lines:<br>
&gt;              line = line.strip()<br>
&gt; -            if len(line) != 0 and line.strip().startswith(&quot;port &quot;):<br>
&gt; +            if len(line) != 0 and line.startswith(&quot;port &quot;):<br>
&gt;                  reta_line = {}<br>
&gt; -                rexp = r&quot;port (\d)/queue (\d{1,2}): received (\d) packets&quot;<br>
&gt; -                m = re.match(rexp, line.strip())<br>
&gt; +                rexp = r&quot;port (\d+)/queue (\d+): received (\d+) packets&quot;<br>
&gt; +                m = re.match(rexp, line)<br>
&gt;                  if m:<br>
&gt;                      reta_line[&quot;port&quot;] = m.group(1)<br>
&gt;                      reta_line[&quot;queue&quot;] = m.group(2)<br>
&gt; <br>
&gt; -            elif len(line) != 0 and line.startswith((&quot;src=&quot;,)):<br>
&gt; +            elif len(line) != 0 and line.startswith(&quot;src=&quot;):<br>
&gt;                  if &quot;RSS hash&quot; not in line:<br>
&gt;                      continue<br>
&gt;                  for item in line.split(&quot;-&quot;):<br>
&gt;                      item = item.strip()<br>
&gt; -                    if(item.startswith(&quot;RSS hash&quot;)):<br>
&gt; +                    if item.startswith(&quot;RSS hash&quot;):<br>
&gt;                          name, value = item.split(&quot;=&quot;, 1)<br>
&gt; <br>
&gt;                  reta_line[name.strip()] = value.strip()<br>
&gt;                  received_pkts.append(reta_line)<br>
&gt; <br>
&gt; -        return(self.verifyResult(received_pkts))<br>
&gt; +        return(self.verifyResult(received_pkts, symmetric))<br>
&gt; <br>
&gt; -    def verifyResult(self, reta_lines):<br>
&gt; +    def verifyResult(self, reta_lines, symmetric):<br>
&gt;          &quot;&quot;&quot;<br>
&gt;          Verify whether or not the result passes.<br>
&gt;          &quot;&quot;&quot;<br>
&gt; -<br>
&gt; -        global reta_num<br>
&gt;          result = []<br>
&gt;          key_id = {}<br>
&gt;          self.verify(len(reta_lines) &gt; 0, &#39;No packet received!&#39;)<br>
&gt;          self.result_table_create(<br>
&gt;              [&#39;packet index&#39;, &#39;hash value&#39;, &#39;hash index&#39;, &#39;queue id&#39;, &#39;actual queue id&#39;,<br>
&gt; &#39;pass &#39;])<br>
&gt; <br>
&gt; -        i = 0<br>
&gt; -<br>
&gt; -        for tmp_reta_line in reta_lines:<br>
&gt; +        for i, tmp_reta_line in enumerate(reta_lines):<br>
&gt;              status = &quot;false&quot;<br>
&gt;              # compute the hash result of five tuple into the 7 LSBs value.<br>
&gt;              hash_index = int(tmp_reta_line[&quot;RSS hash&quot;], 16) % reta_num<br>
&gt; -            print(reta_entries[hash_index], tmp_reta_line)<br>
&gt;              if(reta_entries[hash_index] == int(tmp_reta_line[&quot;queue&quot;])):<br>
&gt;                  status = &quot;true&quot;<br>
&gt;                  result.insert(i, 0)<br>
&gt; +                if symmetric:<br>
&gt; +                    if(i % 2 == 1):<br>
&gt; +                        if(pre_RSS_hash == tmp_reta_line[&quot;RSS hash&quot;]):<br>
&gt; +                            status = &quot;true&quot;<br>
&gt; +                            result.insert(len(reta_lines) + (i - 1) // 2, 0)<br>
&gt; +                        else:<br>
&gt; +                            status = &quot;fail&quot;<br>
&gt; +                            result.insert(len(reta_lines) + (i - 1) // 2, 1)<br>
&gt; +                    pre_RSS_hash = tmp_reta_line[&quot;RSS hash&quot;]<br>
&gt;              else:<br>
&gt;                  status = &quot;fail&quot;<br>
&gt;                  result.insert(i, 1)<br>
&gt;              self.result_table_add(<br>
&gt;                  [i, tmp_reta_line[&quot;RSS hash&quot;], hash_index, reta_entries[hash_index],<br>
&gt; tmp_reta_line[&quot;queue&quot;], status])<br>
&gt; -            i = i + 1<br>
&gt; -            key_id[tmp_reta_line[&quot;RSS hash&quot;]]=reta_entries[hash_index]<br>
&gt; +            key_id[tmp_reta_line[&quot;RSS hash&quot;]] =<br>
&gt; + reta_entries[hash_index]<br>
&gt; <br>
&gt;          self.result_table_print()<br>
&gt;          self.verify(sum(result) == 0, &quot;the reta update function failed!&quot;)<br>
&gt;          return key_id<br>
&gt; <br>
&gt; -    def verifyResult_symmetric(self, reta_lines):<br>
&gt; -        &quot;&quot;&quot;<br>
&gt; -        Verify whether or not the result passes.<br>
&gt; -        &quot;&quot;&quot;<br>
&gt; -<br>
&gt; -        global reta_num<br>
&gt; -        result = []<br>
&gt; -        key_id = {}<br>
&gt; -        self.verify(len(reta_lines) &gt; 0, &#39;No packet received!&#39;)<br>
&gt; -        self.result_table_create(<br>
&gt; -            [&#39;packet index&#39;, &#39;RSS hash&#39;, &#39;hash index&#39;, &#39;queue id&#39;, &#39;actual queue id&#39;, &#39;pass<br>
&gt; &#39;])<br>
&gt; -<br>
&gt; -        i = 0<br>
&gt; -        for tmp_reta_line in reta_lines:<br>
&gt; -            status = &quot;false&quot;<br>
&gt; -            # compute the hash result of five tuple into the 7 LSBs value.<br>
&gt; -            hash_index = int(tmp_reta_line[&quot;RSS hash&quot;], 16) % reta_num<br>
&gt; -            if(reta_entries[hash_index] == int(tmp_reta_line[&quot;queue&quot;])):<br>
&gt; -                status = &quot;true&quot;<br>
&gt; -                result.insert(i, 0)<br>
&gt; -                if(i % 2 == 1):<br>
&gt; -                    if(pre_RSS_hash == tmp_reta_line[&quot;RSS hash&quot;]):<br>
&gt; -                        status = &quot;true&quot;<br>
&gt; -                        result.insert(len(reta_lines) + (i - 1) // 2, 0)<br>
&gt; -                    else:<br>
&gt; -                        status = &quot;fail&quot;<br>
&gt; -                        result.insert(len(reta_lines) + (i - 1) // 2, 1)<br>
&gt; -                pre_RSS_hash = tmp_reta_line[&quot;RSS hash&quot;]<br>
&gt; -            else:<br>
&gt; -                status = &quot;fail&quot;<br>
&gt; -                result.insert(i, 1)<br>
&gt; -            self.result_table_add(<br>
&gt; -                [i, tmp_reta_line[&quot;RSS hash&quot;], hash_index, reta_entries[hash_index],<br>
&gt; tmp_reta_line[&quot;queue&quot;], status])<br>
&gt; -            i = i + 1<br>
&gt; -            key_id[tmp_reta_line[&quot;RSS hash&quot;]]=reta_entries[hash_index]<br>
&gt; -<br>
&gt; -        self.result_table_print()<br>
&gt; -        self.verify(<br>
&gt; -            sum(result) == 0, &quot;the symmetric RSS hash function failed!&quot;)<br>
&gt; -        return key_id<br>
&gt; -<br>
&gt;      def set_up_all(self):<br>
&gt;          &quot;&quot;&quot;<br>
&gt;          Run at the start of each test suite.<br>
&gt; @@ -282,7 +195,7 @@ class TestRssKeyUpdate(TestCase):<br>
&gt;          elif self.nic in [&quot;redrockcanyou&quot;, &quot;atwood&quot;, &quot;boulderrapid&quot;]:<br>
&gt;              reta_num = 128<br>
&gt;          else:<br>
&gt; -            self.verify(False, f&quot;NIC Unsupported:{self.nic}&quot;)<br>
&gt; +            self.verify(False, f&quot;NIC Unsupported: {self.nic}&quot;)<br>
&gt; <br>
&gt;          cores = self.dut.get_core_list(&quot;all&quot;)<br>
&gt;          self.coremask = utils.create_mask(cores) @@ -300,8 +213,6 @@ class<br>
&gt; TestRssKeyUpdate(TestCase):<br>
&gt;          dutPorts = self.dut.get_ports(self.nic)<br>
&gt;          localPort = self.tester.get_local_port(dutPorts[0])<br>
&gt;          self.itf = self.tester.get_interface(localPort)<br>
&gt; -        global reta_num<br>
&gt; -        global iptypes<br>
&gt; <br>
&gt;          self.dut.kill_all()<br>
&gt; <br>
&gt; @@ -326,12 +237,12 @@ class TestRssKeyUpdate(TestCase):<br>
&gt;                  reta_entries.insert(i, random.randint(0, queue - 1))<br>
&gt;                  self.dut.send_expect(f&quot;port config 0 rss reta ({i},{reta_entries[i]})&quot;,<br>
&gt; &quot;testpmd&gt; &quot;)<br>
&gt; <br>
&gt; -            ori_output = self.send_packet(self.itf, iptype)<br>
&gt; +            ori_output = self.send_packet(self.itf, iptype, False)<br>
&gt; <br>
&gt;              self.dut.send_expect(&quot;show port 0 rss-hash key&quot;, &quot;testpmd&gt; &quot;)<br>
&gt;              self.dut.send_expect(f&quot;port config 0 rss-hash-key {iptype}<br>
&gt; 4439796BB54C50f3B675EF5B124F9F30B8A2C0FFFFDC4D02A08C9B334FF64A4C<br>
&gt; 05C6FA343958D855FFF9583AE138C92E81150FFF&quot;, &quot;testpmd&gt; &quot;)<br>
&gt; <br>
&gt; -            new_output = self.send_packet(self.itf, iptype)<br>
&gt; +            new_output = self.send_packet(self.itf, iptype, False)<br>
&gt; <br>
&gt;              self.verify(ori_output != new_output, &quot;before and after results are the<br>
&gt; same, hash key configuration failed!&quot;)<br>
&gt; <br>
&gt; @@ -356,16 +267,15 @@ class TestRssKeyUpdate(TestCase):<br>
&gt;                  reta_entries.insert(i, random.randint(0, queue - 1))<br>
&gt;                  self.dut.send_expect(f&quot;port config 0 rss reta ({i},{reta_entries[i]})&quot;,<br>
&gt; &quot;testpmd&gt; &quot;)<br>
&gt; <br>
&gt; -            ori_output = self.send_packet(self.itf, iptype)<br>
&gt; +            ori_output = self.send_packet(self.itf, iptype, True)<br>
&gt; <br>
&gt;              out = self.dut.send_expect(&quot;show port 0 rss-hash key&quot;, &quot;testpmd&gt; &quot;)<br>
&gt;              self.verify(&quot;rss disable&quot; not in out, &quot;rss is disable!&quot;)<br>
&gt;              self.dut.send_expect(f&quot;port config 0 rss-hash-key {iptype}<br>
&gt; 4439796BB54C50f3B675EF5B124F9F30B8A2C0FFFFDC4D02A08C9B334FF64A4C<br>
&gt; 05C6FA343958D855FFF9583AE138C92E81150FFF&quot;, &quot;testpmd&gt; &quot;)<br>
&gt; <br>
&gt; -            new_output = self.send_packet(self.itf, iptype)<br>
&gt; +            new_output = self.send_packet(self.itf, iptype, True)<br>
&gt; <br>
&gt;              self.verify(ori_output != new_output, &quot;before and after results are the<br>
&gt; same, hash key configuration failed!&quot;)<br>
&gt; -        self.dut.send_expect(&quot;quit&quot;, &quot;# &quot;, 30)<br>
&gt; <br>
&gt;      def test_set_hash_key_short_long(self):<br>
&gt; <br>
&gt; @@ -384,26 +294,25 @@ class TestRssKeyUpdate(TestCase):<br>
&gt;          out = self.dut.send_expect(&quot;show port info all&quot;, &quot;testpmd&gt; &quot;, 120)<br>
&gt;          self.verify(f&quot;Hash key size in bytes: {nic_rss_key_size[self.nic]}&quot; in out, &quot;not<br>
&gt; expected hash key size!&quot;)<br>
&gt; <br>
&gt; -        test_keies = {<br>
&gt; +        test_keys = {<br>
&gt; <br>
&gt; &quot;4439796BB54C50f3B675EF5B124F9F30B8A2C0FFFFDC4D02A08C9B334FF64A4<br>
&gt; C05C6FA343958D855FFF9583AE138C92E81150FFFFF&quot;: &quot;longer&quot;,<br>
&gt; <br>
&gt; &quot;4439796BB54C50f3B675EF5B124F9F30B8A2C0DC4D02A08C9B334FF64A4C05C<br>
&gt; 6FA343958D855FFF9583AE138C92E81150FFF&quot;: &quot;shorter&quot;,<br>
&gt;          }<br>
&gt; <br>
&gt;          # config key length longer/shorter than 104 hexa-decimal numbers<br>
&gt; -        for key, error in test_keies.items():<br>
&gt; +        for key, error in test_keys.items():<br>
&gt;              out = self.dut.send_expect(f&quot;port config 0 rss-hash-key ipv4-udp {key}&quot;,<br>
&gt; &quot;testpmd&gt; &quot;)<br>
&gt;              self.verify(&quot;invalid&quot; in out, f&quot;Try to set hash key {error} than 104 hexa-<br>
&gt; decimal numbers!&quot;)<br>
&gt; <br>
&gt;          # config ket length same as 104 hex-decimal numbers and keep the config<br>
&gt;          key =<br>
&gt; &quot;4439796BB54C50f3B675EF5B124F9F30B8A2C0FFFFDC4D02A08C9B334FF64A4<br>
&gt; C05C6FA343958D855FFF9583AE138C92E81150FFF&quot;<br>
&gt;          out = self.dut.send_expect(f&quot;port config 0 rss-hash-key ipv4-udp {key}&quot;,<br>
&gt; &quot;testpmd&gt; &quot;)<br>
&gt; -        self.dut.send_expect(&quot;quit&quot;, &quot;# &quot;, 30)<br>
&gt; <br>
&gt;      def tear_down(self):<br>
&gt;          &quot;&quot;&quot;<br>
&gt;          Run after each test case.<br>
&gt;          &quot;&quot;&quot;<br>
&gt; -        self.dut.send_expect(&quot;quit&quot;, &quot;# &quot;, 30)<br>
&gt; +        self.pmdout.quit()<br>
&gt; <br>
&gt;      def tear_down_all(self):<br>
&gt;          &quot;&quot;&quot;<br>
&gt; --<br>
&gt; 2.17.1<br>
<br>
</blockquote></div>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <f08663d0b11bfc1487f7461dd7c952bab652d9e8>
2020-07-15 20:08 ` [dts] [PATCH v2]Add RSS Key Update Feature David Liu
2020-07-24  2:01   ` Tu, Lijuan
2020-07-24 20:45     ` David Liu

test suite reviews and discussions

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/dts/0 dts/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dts dts/ http://inbox.dpdk.org/dts \
		dts@dpdk.org
	public-inbox-index dts


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dts


AGPL code for this site: git clone https://public-inbox.org/ public-inbox