From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id A03178E83 for ; Thu, 14 Jan 2016 12:52:00 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP; 14 Jan 2016 03:51:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,294,1449561600"; d="scan'208";a="633316670" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by FMSMGA003.fm.intel.com with ESMTP; 14 Jan 2016 03:52:00 -0800 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 14 Jan 2016 03:51:59 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.172]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.218]) with mapi id 14.03.0248.002; Thu, 14 Jan 2016 19:51:57 +0800 From: "Pei, Yulong" To: "Xu, HuilongX" , "dts@dpdk.org" Thread-Topic: [dts] [PATCH V1 3/3] add vf rss test script Thread-Index: AQHRTSgfCaIkzly2JE+VmnslTs7tFZ766GFA Date: Thu, 14 Jan 2016 11:51:56 +0000 Message-ID: <188971FCDA171749BED5DA74ABF3E6F003528C64@shsmsx102.ccr.corp.intel.com> References: <1452595994-16505-1-git-send-email-huilongx.xu@intel.com> <1452595994-16505-3-git-send-email-huilongx.xu@intel.com> In-Reply-To: <1452595994-16505-3-git-send-email-huilongx.xu@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNWMwODlmZDMtYzFkZS00OWNmLWFiNDAtM2I1ZTFmYmQ3MDAzIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjQuMTAuMTkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiQjZCcGV2dHYzZU1ISTY0TkxRMlkzdGpHYVV2MUgzV0RORjlpZGFJZzBsTT0ifQ== x-ctpclassification: CTP_IC 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: Thu, 14 Jan 2016 11:52:01 -0000 Hi, -----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 Signed-off-by: xu,huilong --- tests/TestSuite_vf_rss.py | 382 ++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 382 insertions(+) create mode 100644 tests/TestSuite_vf_rss.py 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 #=20 +modification, are permitted provided that the following conditions #=20 +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 #=20 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT #=20 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR #=20 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT #=20 +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, #=20 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT #=20 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, #=20 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY #=20 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT #=20 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE #=20 +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:0= 0: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:0= 0:00")/IP(src=3D"192.168.0.%d", dst=3D"192.168.0.%d")/TCP(sport=3D1024,dpor= t=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:0= 0:00")/IP(src=3D"192.168.0.%d", dst=3D"192.168.0.%d")/UDP(sport=3D1024,dpor= t=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:0= 0: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:0= 0:00")/IPv6(src=3D"3ffe:2501:200:1fff::%d", dst=3D"3ffe:2501:200:3::%d")/TC= P(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:0= 0:00")/IPv6(src=3D"3ffe:2501:200:1fff::%d", dst=3D"3ffe:2501:200:3::%d")/UD= P(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:250= 1:200:1fff::%d", dst=3D"3ffe:2501:200:3::%d")/SCTP(sport=3D1024,dport=3D102= 5,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:250= 1:200:1fff::%d", dst=3D"3ffe:2501:200:3::%d")/SCTP(sport=3D1025,dport=3D102= 4,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=20 + 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) packet= s" + 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() + =20 + + 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',=20 + '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 va= lue. + hash_index =3D int(tmp_reta_line["RSS hash"], 16) % 128 + else: + # compute the hash result of five tuple into the 7 LSBs va= lue. + 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[ha= sh_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=20 + 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)) Can you remove above lines if it is useless? + 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=20 + 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') + =20 + #self.pmdout =3D PmdOutput(self.dut) + Can you remove above lines if it is useless? + 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") Can you remove above lines if it is useless? + pass + def setup_1pf_1vf_1vm_env(self, driver=3D'default'): + =20 + self.used_dut_port_0 =3D self.dut_ports[0] + self.dut.generate_sriov_vfs_by_port(self.used_dut_port_0, 1, drive= r=3Ddriver) + self.sriov_vfs_port_0 =3D=20 + 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",=20 + 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') Can you remove above lines if it is useless? + 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): + =20 + # 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),=20 + 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_en= tries[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,=20 + reta_entries[i]), "testpmd> ") + + self.send_packet(itf, iptype) + + self.vm_dut_0.send_expect("quit", "# ", 30) + def test_vf_pmdrss(self):=20 + 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' Why did not include l2_payload type ? + } + + 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),=20 + 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" % rssty= pe, "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() Can you remove above lines if it is useless? Best Regards Yulong Pei + self.destroy_1pf_1vf_1vm_env() -- 1.9.3