From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id CFD85593A for ; Fri, 15 Jan 2016 07:03:21 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP; 14 Jan 2016 22:03:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,298,1449561600"; d="scan'208";a="727501353" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga003.jf.intel.com with ESMTP; 14 Jan 2016 22:03:20 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 14 Jan 2016 22:03:19 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.215]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.231]) with mapi id 14.03.0248.002; Fri, 15 Jan 2016 14:03:17 +0800 From: "Xu, HuilongX" To: "Pei, Yulong" , "dts@dpdk.org" Thread-Topic: [dts] [PATCH V1 3/3] add vf rss test script Thread-Index: AQHRTSgfCaIkzly2JE+VmnslTs7tFZ766GFAgAExI2A= Date: Fri, 15 Jan 2016 06:03:17 +0000 Message-ID: References: <1452595994-16505-1-git-send-email-huilongx.xu@intel.com> <1452595994-16505-3-git-send-email-huilongx.xu@intel.com> <188971FCDA171749BED5DA74ABF3E6F003528C64@shsmsx102.ccr.corp.intel.com> In-Reply-To: <188971FCDA171749BED5DA74ABF3E6F003528C64@shsmsx102.ccr.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-cr-hashedpuzzle: ArWV CVr1 Cmm5 DAtG E/oh GFgI GFsM G5Ky Hrji H32K IXiK I3Ci JizA J+25 KnJb K/rl; 1; ZAB0AHMAQABkAHAAZABrAC4AbwByAGcA; Sosha1_v1; 7; {FFC2901D-0C69-4046-9E08-8BB109638537}; aAB1AGkAbABvAG4AZwB4AC4AeAB1AEAAaQBuAHQAZQBsAC4AYwBvAG0A; Fri, 15 Jan 2016 06:03:15 GMT; UgBFADoAIABbAGQAdABzAF0AIABbAFAAQQBUAEMASAAgAFYAMQAgADMALwAzAF0AIABhAGQAZAAgAHYAZgAgAHIAcwBzACAAdABlAHMAdAAgAHMAYwByAGkAcAB0AA== x-cr-puzzleid: {FFC2901D-0C69-4046-9E08-8BB109638537} x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dts] [PATCH V1 3/3] add vf rss test script X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jan 2016 06:03:22 -0000 Hi yulong, Thanks a lot for you review my patch, pls check my comments. thanks > -----Original Message----- > From: Pei, Yulong > Sent: Thursday, January 14, 2016 7:52 PM > To: Xu, HuilongX; dts@dpdk.org > Subject: RE: [dts] [PATCH V1 3/3] add vf rss test script >=20 > Hi, >=20 > -----Original Message----- > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of xu,huilong > Sent: Tuesday, January 12, 2016 6:53 PM > To: dts@dpdk.org > Subject: [dts] [PATCH V1 3/3] add vf rss test script >=20 > Signed-off-by: xu,huilong > --- > tests/TestSuite_vf_rss.py | 382 > ++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 382 insertions(+) > create mode 100644 tests/TestSuite_vf_rss.py >=20 > diff --git a/tests/TestSuite_vf_rss.py b/tests/TestSuite_vf_rss.py new > file mode 100644 index 0000000..a59516d > --- /dev/null > +++ b/tests/TestSuite_vf_rss.py > @@ -0,0 +1,382 @@ > +# BSD LICENSE > +# > +# Copyright(c) 2010-2014 Intel Corporation. All rights reserved. > +# All rights reserved. > +# > +# Redistribution and use in source and binary forms, with or without # > +modification, are permitted provided that the following conditions # > +are met: > +# > +# * Redistributions of source code must retain the above copyright > +# notice, this list of conditions and the following disclaimer. > +# * Redistributions in binary form must reproduce the above copyright > +# notice, this list of conditions and the following disclaimer in > +# the documentation and/or other materials provided with the > +# distribution. > +# * Neither the name of Intel Corporation nor the names of its > +# contributors may be used to endorse or promote products derived > +# from this software without specific prior written permission. > +# > +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # > +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # > +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # > +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # > +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # > +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # > +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # > +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # > +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # > +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # > +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > + > +""" > +DPDK Test suite. > +Test RSS reta (redirection table) update function. > +""" > +import time > +import random > +import re > +import dts > +testQueues =3D [4] > +reta_entries =3D [] > +reta_lines =3D [] > + > +# Use scapy to send packets with different source and dest ip. > +# and collect the hash result of five tuple and the queue id. > +from test_case import TestCase > +from pmd_output import PmdOutput > +from qemu_kvm import QEMUKvm > + > +class TestVfRss(TestCase): > + def send_packet(self, itf, tran_type): > + """ > + Sends packets. > + """ > + global reta_lines > + reta_lines =3D [] > + self.tester.scapy_foreground() > + self.tester.scapy_append('sys.path.append("./")') > + self.tester.scapy_append('from sctp import *') > + self.vm_dut_0.send_expect("start", "testpmd>") > + mac =3D self.vm_dut_0.get_mac_address(0) > + # send packet with different source and dest ip > + if tran_type =3D=3D "ipv4-other": > + for i in range(16): > + packet =3D r'sendp([Ether(dst=3D"%s", > src=3D"02:00:00:00:00:00")/IP(src=3D"192.168.0.%d", dst=3D"192.168.0.%d")= ], > iface=3D"%s")' % ( > + mac, i + 1, i + 2, itf) > + self.tester.scapy_append(packet) > + self.tester.scapy_execute() > + time.sleep(.5) > + elif tran_type =3D=3D "ipv4-tcp": > + for i in range(16): > + packet =3D r'sendp([Ether(dst=3D"%s", > src=3D"02:00:00:00:00:00")/IP(src=3D"192.168.0.%d", > dst=3D"192.168.0.%d")/TCP(sport=3D1024,dport=3D1024)], iface=3D"%s")' % ( > + mac, i + 1, i + 2, itf) > + self.tester.scapy_append(packet) > + self.tester.scapy_execute() > + time.sleep(.5) > + elif tran_type =3D=3D "ipv4-udp": > + for i in range(16): > + packet =3D r'sendp([Ether(dst=3D"%s", > src=3D"02:00:00:00:00:00")/IP(src=3D"192.168.0.%d", > dst=3D"192.168.0.%d")/UDP(sport=3D1024,dport=3D1024)], iface=3D"%s")' % ( > + mac, i + 1, i + 2, itf) > + self.tester.scapy_append(packet) > + self.tester.scapy_execute() > + time.sleep(.5) > + elif tran_type =3D=3D "ipv4-sctp": > + for i in range(16): > + packet =3D r'sendp([Ether(dst=3D"%s")/IP(src=3D"192.168.= 0.%d", > dst=3D"192.168.0.%d")/SCTP(sport=3D1024,dport=3D1025,tag=3D1)], iface=3D"= %s")' % ( > + mac, i + 1, i + 2, itf) > + self.tester.scapy_append(packet) > + self.tester.scapy_execute() > + time.sleep(.5) > + packet =3D r'sendp([Ether(dst=3D"%s")/IP(src=3D"192.168.= 0.%d", > dst=3D"192.168.0.%d")/SCTP(sport=3D1025,dport=3D1024,tag=3D1)], iface=3D"= %s")' % ( > + mac, i + 2, i + 1, itf) > + self.tester.scapy_append(packet) > + self.tester.scapy_execute() > + time.sleep(.5) > + elif tran_type =3D=3D "l2_payload": > + for i in range(16): > + packet =3D > r'sendp([Ether(src=3D"00:00:00:00:00:%02d",dst=3D"%s")], iface=3D"%s")' %= ( > + i + 1, mac, itf) > + self.tester.scapy_append(packet) > + self.tester.scapy_execute() > + time.sleep(.5) > + > + elif tran_type =3D=3D "ipv6-other": > + for i in range(16): > + packet =3D r'sendp([Ether(dst=3D"%s", > src=3D"02:00:00:00:00:00")/IPv6(src=3D"3ffe:2501:200:1fff::%d", > dst=3D"3ffe:2501:200:3::%d")], iface=3D"%s")' % ( > + mac, i + 1, i + 2, itf) > + self.tester.scapy_append(packet) > + self.tester.scapy_execute() > + time.sleep(.5) > + elif tran_type =3D=3D "ipv6-tcp": > + for i in range(16): > + packet =3D r'sendp([Ether(dst=3D"%s", > src=3D"02:00:00:00:00:00")/IPv6(src=3D"3ffe:2501:200:1fff::%d", > dst=3D"3ffe:2501:200:3::%d")/TCP(sport=3D1024,dport=3D1024)], iface=3D"%s= ")' % ( > + mac, i + 1, i + 2, itf) > + self.tester.scapy_append(packet) > + self.tester.scapy_execute() > + time.sleep(.5) > + elif tran_type =3D=3D "ipv6-udp": > + for i in range(16): > + packet =3D r'sendp([Ether(dst=3D"%s", > src=3D"02:00:00:00:00:00")/IPv6(src=3D"3ffe:2501:200:1fff::%d", > dst=3D"3ffe:2501:200:3::%d")/UDP(sport=3D1024,dport=3D1024)], iface=3D"%s= ")' % ( > + mac, i + 1, i + 2, itf) > + self.tester.scapy_append(packet) > + self.tester.scapy_execute() > + time.sleep(.5) > + elif tran_type =3D=3D "ipv6-sctp": > + for i in range(16): > + packet =3D > r'sendp([Ether(dst=3D"%s")/IPv6(src=3D"3ffe:2501:200:1fff::%d", > dst=3D"3ffe:2501:200:3::%d")/SCTP(sport=3D1024,dport=3D1025,tag=3D1)], > iface=3D"%s")' % ( > + mac, i + 1, i + 2, itf) > + self.tester.scapy_append(packet) > + self.tester.scapy_execute() > + time.sleep(.5) > + packet =3D > r'sendp([Ether(dst=3D"%s")/IPv6(src=3D"3ffe:2501:200:1fff::%d", > dst=3D"3ffe:2501:200:3::%d")/SCTP(sport=3D1025,dport=3D1024,tag=3D1)], > iface=3D"%s")' % ( > + mac, i + 2, i + 1, itf) > + self.tester.scapy_append(packet) > + self.tester.scapy_execute() > + time.sleep(.5) > + > + else: > + print "\ntran_type error!\n" > + > + #out =3D self.vm_dut_0.send_expect("stop", "testpmd>") > + out =3D self.vm_dut_0.get_session_output() > + print '*******************************************' > + print out > + if not reta_entries: > + self.verify('RSS hash=3D' in out, 'rss faied') > + return > + lines =3D out.split("\r\n") > + out =3D '' > + reta_line =3D {} > + > + # collect the hash result of five tuple and the queue id > + for line in lines: > + line =3D line.strip() > + if len(line) !=3D 0 and line.startswith(("src=3D",)): > + for item in line.split("-"): > + item =3D item.strip() > + if(item.startswith("RSS hash")): > + name, value =3D item.split("=3D", 1) > + print name + "-" + value > + > + reta_line[name.strip()] =3D value.strip() > + reta_lines.append(reta_line) > + reta_line =3D {} > + elif len(line) !=3D 0 and line.strip().startswith("port "): > + rexp =3D r"port (\d)/queue (\d{1,2}): received (\d) > packets" > + m =3D re.match(rexp, line.strip()) > + if m: > + reta_line["port"] =3D m.group(1) > + reta_line["queue"] =3D m.group(2) > + elif len(line) !=3D 0 and line.startswith("stop"): > + break > + else: > + pass > + self.verifyResult() > + > + > + def verifyResult(self): > + """ > + Verify whether or not the result passes. > + """ > + > + global reta_lines > + result =3D [] > + dts.results_table_add_header( > + ['packet index', 'hash value', 'hash index', 'queue id', > + 'actual queue id', 'pass ']) > + > + i =3D 0 > + for tmp_reta_line in reta_lines: > + status =3D "false" > + if(self.nic in ["niantic", "redrockcanyou"]): > + # compute the hash result of five tuple into the 7 LSBs > value. > + hash_index =3D int(tmp_reta_line["RSS hash"], 16) % 128 > + else: > + # compute the hash result of five tuple into the 7 LSBs > value. > + hash_index =3D int(tmp_reta_line["RSS hash"], 16) % 512 > + if(reta_entries[hash_index] =3D=3D int(tmp_reta_line["queue"= ])): > + status =3D "true" > + result.insert(i, 0) > + else: > + status =3D "fail" > + result.insert(i, 1) > + dts.results_table_add_row( > + [i, tmp_reta_line["RSS hash"], hash_index, > reta_entries[hash_index], tmp_reta_line["queue"], status]) > + i =3D i + 1 > + > + dts.results_table_print() > + reta_lines =3D [] > + self.verify(sum(result) =3D=3D 0, "the reta update function > + failed!") > + > + def set_up_all(self): > + """ > + Run at the start of each test suite. > + """ > + > + #self.verify( > + # self.nic in ["niantic", "fortville_eagle", > "fortville_spirit", "fortville_spirit_single"], > + # "NIC Unsupported: " + str(self.nic)) >=20 > Can you remove above lines if it is useless? >=20 > + self.dut_ports =3D self.dut.get_ports(self.nic) > + self.ports_socket =3D self.dut.get_numa_id(self.dut_ports[0]) > + self.verify(len(self.dut_ports) >=3D 1, "Not enough ports > + available") > + > + self.vm0 =3D None > + self.setup_1pf_1vf_1vm_env_flag =3D 0 > + self.setup_1pf_1vf_1vm_env(driver=3D'') > + #self.vm0_dut_ports =3D self.vm_dut_0.get_ports('any') > + > + #self.pmdout =3D PmdOutput(self.dut) > + >=20 > Can you remove above lines if it is useless? > yes, I will remove it next version. > + def set_up(self): > + """ > + Run before each test case. > + """ > + #self.vm0_testpmd =3D PmdOutput(self.vm_dut_0) > + #self.vm0_testpmd.start_testpmd(VM_CORES_MASK,param =3D "--rxq= =3D4 -- > rxq=3D4") >=20 > Can you remove above lines if it is useless? > yes, I will remove it next version > + pass > + def setup_1pf_1vf_1vm_env(self, driver=3D'default'): > + > + self.used_dut_port_0 =3D self.dut_ports[0] > + self.dut.generate_sriov_vfs_by_port(self.used_dut_port_0, 1, > driver=3Ddriver) > + self.sriov_vfs_port_0 =3D > + self.dut.ports_info[self.used_dut_port_0]['vfs_port'] > + > + try: > + > + for port in self.sriov_vfs_port_0: > + port.bind_driver('pci-stub') > + > + time.sleep(1) > + vf0_prot =3D {'opt_host': self.sriov_vfs_port_0[0].pci} > + > + if driver =3D=3D 'igb_uio': > + # start testpmd without the two VFs on the host > + self.host_testpmd =3D PmdOutput(self.dut) > + eal_param =3D '-b %(vf0)s -b %(vf1)s' % {'vf0': > self.sriov_vfs_port_0[0].pci} > + self.host_testpmd.start_testpmd("1S/2C/2T", > + eal_param=3Deal_param) > + > + # set up VM0 ENV > + self.vm0 =3D QEMUKvm(self.dut, 'vm0', 'vf_rss') > + self.vm0.set_vm_device(driver=3D'pci-assign', **vf0_prot) > + > + self.vm_dut_0 =3D self.vm0.start() > + self.vm0_testpmd =3D PmdOutput(self.vm_dut_0) > + if self.vm_dut_0 is None: > + raise Exception("Set up VM0 ENV failed!") > + > + self.setup_1pf_1vf_1vm_env_flag =3D 1 > + except Exception as e: > + self.destroy_1pf_1vf_1vm_env() > + raise Exception(e) > + > + def destroy_1pf_1vf_1vm_env(self): > + if getattr(self, 'vm0', None): > + #destroy testpmd in vm0 > + #self.vm0_testpmd.execute_cmd('stop') >=20 > Can you remove above lines if it is useless? > yes I will remove it next version > + self.vm0_testpmd.execute_cmd('quit', '# ') > + self.vm0_testpmd =3D None > + self.vm0_dut_ports =3D None > + #destroy vm0 > + self.vm0.stop() > + self.vm0 =3D None > + > + if getattr(self, 'host_testpmd', None): > + self.host_testpmd.execute_cmd('quit', '# ') > + self.host_testpmd =3D None > + > + if getattr(self, 'used_dut_port_0', None): > + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port_0) > + port =3D self.dut.ports_info[self.used_dut_port_0]['port'] > + port.bind_driver() > + self.used_dut_port_0 =3D None > + > + for port_id in self.dut_ports: > + port =3D self.dut.ports_info[port_id]['port'] > + port.bind_driver() > + > + self.setup_1pf_2vf_1vm_env_flag =3D 0 > + > + def test_vf_pmdrss_reta(self): > + > + # niantic kernel host driver not support this case > + if self.nic is 'niantic' and not self.host_testpmd: > + return > + vm0dutPorts =3D self.vm_dut_0.get_ports('any') > + localPort =3D self.tester.get_local_port(vm0dutPorts[0]) > + itf =3D self.tester.get_interface(localPort) > + iptypes =3D ['IPV4'] > + > + self.vm_dut_0.kill_all() > + > + # test with different rss queues > + for queue in testQueues: > + > + self.vm0_testpmd.start_testpmd( > + "all", "--rxq=3D%d --txq=3D%d" % (queue, queue), > + socket=3Dself.ports_socket) > + > + for iptype in iptypes: > + self.vm_dut_0.send_expect("set verbose 8", "testpmd> ") > + self.vm_dut_0.send_expect("set fwd rxonly", "testpmd> ") > + self.vm_dut_0.send_expect( > + "set nbcore %d" % (queue + 1), "testpmd> ") > + > + # configure the reta with specific mappings. > + if(self.nic in ["niantic", "redrockcanyou"]): > + for i in range(128): > + reta_entries.insert(i, random.randint(0, queue - > 1)) > + self.vm_dut_0.send_expect( > + "port config 0 rss reta (%d,%d)" % (i, > reta_entries[i]), "testpmd> ") > + else: > + for i in range(512): > + reta_entries.insert(i, random.randint(0, queue - > 1)) > + self.vm_dut_0.send_expect( > + "port config 0 rss reta (%d,%d)" % (i, > + reta_entries[i]), "testpmd> ") > + > + self.send_packet(itf, iptype) > + > + self.vm_dut_0.send_expect("quit", "# ", 30) > + def test_vf_pmdrss(self): > + vm0dutPorts =3D self.vm_dut_0.get_ports('any') > + localPort =3D self.tester.get_local_port(vm0dutPorts[0]) > + itf =3D self.tester.get_interface(localPort) > + iptypes =3D {'ipv4-sctp':'ip', > + 'ipv4-other':'ip', > + 'ipv4-udp':'udp', > + 'ipv4-tcp':'tcp', > + 'ipv4-sctp':'sctp', > + 'ipv6-other':'ip', > + 'ipv6-udp':'udp', > + 'ipv6-tcp':'tcp', > + 'ipv6-sctp':'sctp', > + # 'l2_payload':'ether' >=20 > Why did not include l2_payload type ? > l2_payload hash type, it looks not support on niantic vf NIC, I will chec= k it with development. > + } > + > + self.vm_dut_0.kill_all() > + > + # test with different rss queues > + for queue in testQueues: > + > + self.vm0_testpmd.start_testpmd( > + "all", "--rxq=3D%d --txq=3D%d" % (queue, queue), > + socket=3Dself.ports_socket) > + > + for iptype,rsstype in iptypes.items(): > + self.vm_dut_0.send_expect("set verbose 8", "testpmd> ") > + self.vm_dut_0.send_expect("set fwd rxonly", "testpmd> ") > + self.vm_dut_0.send_expect("port config all rss %s" % > rsstype, "testpmd> ") > + self.vm_dut_0.send_expect( > + "set nbcore %d" % (queue + 1), "testpmd> ") > + > + self.send_packet(itf, iptype) > + > + self.vm_dut_0.send_expect("quit", "# ", 30) > + def tear_down(self): > + """ > + Run after each test case. > + """ > + pass > + > + def tear_down_all(self): > + """ > + Run after each test suite. > + """ > + #self.vm_dut_0.kill_all() >=20 > Can you remove above lines if it is useless? > yes I will remove it next version > Best Regards > Yulong Pei >=20 > + self.destroy_1pf_1vf_1vm_env() > -- > 1.9.3