From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id E088CA00E6 for ; Mon, 13 May 2019 10:55:41 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B1BAD2BBE; Mon, 13 May 2019 10:55:41 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 8C1672BBE for ; Mon, 13 May 2019 10:55:39 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 May 2019 01:55:38 -0700 X-ExtLoop1: 1 Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga006.fm.intel.com with ESMTP; 13 May 2019 01:55:38 -0700 Received: from fmsmsx163.amr.corp.intel.com (10.18.125.72) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 13 May 2019 01:55:38 -0700 Received: from shsmsx107.ccr.corp.intel.com (10.239.4.96) by fmsmsx163.amr.corp.intel.com (10.18.125.72) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 13 May 2019 01:55:38 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.129]) by SHSMSX107.ccr.corp.intel.com ([169.254.9.7]) with mapi id 14.03.0415.000; Mon, 13 May 2019 16:55:36 +0800 From: "Tu, Lijuan" To: "Xiao, QimaiX" , "dts@dpdk.org" CC: "Xiao, QimaiX" Thread-Topic: [dts] [PATCH V3] add tests/runtime_vf_queue_number_kernel Thread-Index: AQHVBYEC1EM85teLwEiWQFj6D5N8EKZoyDWA Date: Mon, 13 May 2019 08:55:35 +0000 Message-ID: <8CE3E05A3F976642AAB0F4675D0AD20E0BA7FEB8@SHSMSX101.ccr.corp.intel.com> References: <1557308202-34139-1-git-send-email-qimaix.xiao@intel.com> In-Reply-To: <1557308202-34139-1-git-send-email-qimaix.xiao@intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.600.7 dlp-reaction: no-action x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYjM1ZWI5YzAtNjdmOS00MmU2LTg2YTItMDJlOTlmZTViZjM4IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiTHNHa1ViM2lONThNand3aDFDSUR5ZHdJOFluZnI0SWdpOW9UazFhNE9MSlF2d3ZTd0xOZTZsdUVjZW5pWWx0MSJ9 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 V3] add tests/runtime_vf_queue_number_kernel 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: , Errors-To: dts-bounces@dpdk.org Sender: "dts" Applied, thanks > -----Original Message----- > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of xiao,qimai > Sent: Wednesday, May 8, 2019 5:37 PM > To: dts@dpdk.org > Cc: Xiao, QimaiX > Subject: [dts] [PATCH V3] add tests/runtime_vf_queue_number_kernel >=20 > add tests/TestSuite_runtime_vf_queue_number_kernel.py >=20 > Signed-off-by: xiao,qimai > --- > ...estSuite_runtime_vf_queue_number_kernel.py | 298 > ++++++++++++++++++ > 1 file changed, 298 insertions(+) > create mode 100644 tests/TestSuite_runtime_vf_queue_number_kernel.py >=20 > diff --git a/tests/TestSuite_runtime_vf_queue_number_kernel.py > b/tests/TestSuite_runtime_vf_queue_number_kernel.py > new file mode 100644 > index 0000000..0dfac52 > --- /dev/null > +++ b/tests/TestSuite_runtime_vf_queue_number_kernel.py > @@ -0,0 +1,298 @@ > +# BSD LICENSE > +# > +# Copyright(c) 2019 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. > +runtime_vf_queue_number_kernel test script. > +""" > + > +import random > +import time > + > +import utils > +from pmd_output import PmdOutput > +from test_case import TestCase > +from virt_common import VM > + > +VM_CORES_MASK =3D 'all' > + > + > +class TestRuntimeVfQueueNumberKernel(TestCase): > + supported_vf_driver =3D ['pci-stub', 'vfio-pci'] > + max_queue =3D 16 > + > + def set_up_all(self): > + self.verify(self.nic in ["fortville_eagle", "fortville_spirit", = "fortville_25g", > "fortville_spirit_single"], > + "Only supported by Fortville") > + self.dut_ports =3D self.dut.get_ports(self.nic) > + self.verify(len(self.dut_ports) > 1, "Insufficient ports") > + self.vm0 =3D None > + > + # set vf assign method and vf driver > + self.vf_driver =3D self.get_suite_cfg()['vf_driver'] > + if self.vf_driver is None: > + self.vf_driver =3D 'pci-stub' > + self.verify(self.vf_driver in self.supported_vf_driver, "Unsppor= ted vf > driver") > + if self.vf_driver =3D=3D 'pci-stub': > + self.vf_assign_method =3D 'pci-assign' > + else: > + self.vf_assign_method =3D 'vfio-pci' > + self.dut.send_expect('modprobe vfio-pci', '#') > + > + self.setup_1pf_2vf_1vm_env_flag =3D 0 > + self.setup_1pf_2vf_1vm_env(driver=3D'') > + self.vm0_dut_ports =3D self.vm_dut_0.get_ports('any') > + self.portMask =3D utils.create_mask([self.vm0_dut_ports[0]]) > + self.vm_dut_0.vm_pci0 =3D self.vm_dut_0.ports_info[0]['pci'] > + > + def set_up(self): > + pass > + def setup_1pf_2vf_1vm_env(self,driver=3D"default"): > + > + self.used_dut_port =3D self.dut_ports[0] > + self.dut.generate_sriov_vfs_by_port(self.used_dut_port, > 2,driver=3Ddriver) > + self.sriov_vfs_port =3D self.dut.ports_info[self.used_dut_port][= 'vfs_port'] > + try: > + for port in self.sriov_vfs_port: > + port.bind_driver(self.vf_driver) > + time.sleep(1) > + > + vf0_prop =3D {'opt_host': self.sriov_vfs_port[0].pci} > + vf1_prop =3D {'opt_host': self.sriov_vfs_port[1].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].pci, > + 'vf1': self.sriov= _vfs_port[1].pci} > + self.host_testpmd.start_testpmd("Default", eal_param=3De= al_param) > + # set up VM0 ENV > + self.vm0 =3D VM(self.dut, 'vm0', 'runtime_vf_queue_number_ke= rnel') > + self.vm0.set_vm_device(driver=3Dself.vf_assign_method, **vf0= _prop) > + self.vm0.set_vm_device(driver=3Dself.vf_assign_method, **vf1= _prop) > + self.vm_dut_0 =3D self.vm0.start() > + if self.vm_dut_0 is None: > + raise Exception("Set up VM0 ENV failed!") > + > + self.setup_1pf_2vf_1vm_env_flag =3D 1 > + except Exception as e: > + self.destroy_1pf_2vf_1vm_env() > + raise Exception(e) > + > + def destroy_1pf_2vf_1vm_env(self): > + if getattr(self, 'vm0', None): > + # destroy testpmd in vm0 > + self.vm0_testpmd =3D None > + self.vm0_dut_ports =3D None > + # destroy vm0 > + self.vm0.stop() > + self.dut.virt_exit() > + 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', None) !=3D None: > + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port) > + port =3D self.dut.ports_info[self.used_dut_port]['port'] > + port.bind_driver() > + self.used_dut_port =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 send_packet2different_queue(self, dts, src, iface, count): > + self.tester.scapy_foreground() > + for i in range(count): > + pkt =3D 'sendp([Ether(dst=3D"%s", > src=3D"%s")/IP(src=3D"10.0.0.1",dst=3D"192.168.13.%d")/("test"*10)],iface= =3D"%s")' % ( > + dts, src, (i % 254) + 1, iface) > + self.tester.scapy_append(pkt) > + self.tester.scapy_execute() > + > + def check_result(self, nr_queue, out, out2, pkts_num, count, misc): > + if nr_queue =3D=3D 1: > + self.verify('port 0/queue 0: received 1 packets' in out, "qu= eue %s can > not receive pkt" % (nr_queue - 1)) > + else: > + for i in range(nr_queue): > + if i < 10: > + i =3D ' ' + str(i) > + self.verify('Queue=3D%s' % i in out2, "queue %s can not = receive pkt" % > i) > + self.verify(pkts_num =3D=3D count, > + 'Received incorrect pkts number! send %d pkts,receiv= ed %d > pkts' % (count, pkts_num)) > + self.verify('RX-total: %d' % (count + misc) in out2 and 'TX-tota= l: %d' % > (count + misc) in out2, > + "statistic shows rx or tx pkts number: %d incorrect"= % (count + > misc)) > + self.vm0_testpmd.execute_cmd("clear port stats all") > + self.vm0_testpmd.execute_cmd("port stop all") > + time.sleep(5) > + self.vm0_testpmd.execute_cmd('quit', '# ') > + time.sleep(3) > + > + def test_set_valid_vf_queue_num(self): > + """ > + set valid VF queue number in testpmd command-line options > + """ > + random_queue =3D random.randint(2, 15) > + queue_nums =3D [1, random_queue, self.max_queue] > + for nr_queue in queue_nums: > + self.vm0_testpmd =3D PmdOutput(self.vm_dut_0) > + eal_param =3D '-w %(vf0)s' % {'vf0': self.vm_dut_0.vm_pci0} > + tx_port =3D self.tester.get_local_port(self.dut_ports[0]) > + tester_mac =3D self.tester.get_mac(tx_port) > + iface =3D self.tester.get_interface(tx_port) > + count =3D nr_queue * 20 > + times =3D 3 > + > + # try tree times to make sure testpmd launched normally > + while times > 0: > + out =3D self.vm0_testpmd.start_testpmd("all", "--rss-ip = --txq=3D%s -- > rxq=3D%s" % (nr_queue, nr_queue), eal_param=3Deal_param) > + self.logger.info(out) > + if 'Failed' in out or 'failed' in out: > + self.vm0_testpmd.execute_cmd("port stop all") > + time.sleep(5) > + self.vm0_testpmd.execute_cmd('quit', '# ') > + times -=3D 1 > + time.sleep(3) > + else: > + times =3D 0 > + > + self.vm0_testpmd.execute_cmd('set verbose 1') > + self.vm0_testpmd.execute_cmd('set promisc all off') > + time.sleep(1) > + self.vm0_testpmd.execute_cmd('set fwd mac') > + self.vm0_testpmd.execute_cmd("clear port stats all") > + out =3D self.vm0_testpmd.execute_cmd('start') > + vf0_mac =3D self.vm0_testpmd.get_port_mac(0).lower() > + self.verify("port 0: RX queue number: %s Tx queue number: %s= " % > (nr_queue, nr_queue) in out, "queue number maybe error") > + self.send_packet2different_queue(vf0_mac, tester_mac, iface,= count) > + out =3D self.vm0_testpmd.get_output() > + out2 =3D self.vm0_testpmd.execute_cmd('stop') > + pkts_num =3D out.count("src=3D%s - > dst=3D%s"%(tester_mac.upper(),vf0_mac.upper())) > + misc =3D out.count("dst=3DFF:FF:FF:FF:FF:FF") > + self.logger.info("get %d boadcast misc packages " % misc) > + self.check_result(nr_queue, out, out2, pkts_num, count, > + misc) > + > + def test_set_invalid_vf_queue_num_command_line(self): > + invalid_queue_num =3D [0, 17] > + for i in invalid_queue_num: > + self.vm0_testpmd =3D PmdOutput(self.vm_dut_0) > + self.vm_dut_0.session_secondary =3D self.vm_dut_0.new_sessio= n() > + out =3D self.vm_dut_0.session_secondary.send_expect( > + './x86_64-native-linuxapp-gcc/app/testpmd -c 0xf -n 1 -w= %s -- -i -- > txq=3D%s --rxq=3D%s' % ( > + self.vm_dut_0.vm_pci0, i, i), '# ', 40) > + if i =3D=3D 0: > + self.verify('Either rx or tx queues should be non-zero' = in out, > "queue number can't be zero") > + else: > + # the dpdk output non-zero conflict with >=3D0, to be fi= xed... > + self.verify('txq 17 invalid - must be >=3D 0 && <=3D 16'= in > + out, "queue number is too big") > + > + def test_set_valid_vf_queue_num_with_function(self): > + random_queue =3D random.randint(2, 15) > + queue_nums =3D [1, random_queue, self.max_queue] > + self.vm0_testpmd =3D PmdOutput(self.vm_dut_0) > + eal_param =3D '-w %(vf0)s' % {'vf0': self.vm_dut_0.vm_pci0} > + tx_port =3D self.tester.get_local_port(self.dut_ports[0]) > + tester_mac =3D self.tester.get_mac(tx_port) > + iface =3D self.tester.get_interface(tx_port) > + for nr_queue in queue_nums: > + times =3D 3 > + count =3D nr_queue * 20 > + > + #try tree times to make sure testpmd launched normally > + while times > 0: > + self.vm0_testpmd =3D PmdOutput(self.vm_dut_0) > + out =3D self.vm0_testpmd.start_testpmd("all", > eal_param=3Deal_param) > + self.logger.info(out) > + self.vm0_testpmd.execute_cmd("port stop all") > + self.vm0_testpmd.execute_cmd('set fwd mac') > + self.vm0_testpmd.execute_cmd("set verbose 1") > + self.vm0_testpmd.execute_cmd('set promisc all off') > + time.sleep(1) > + self.vm0_testpmd.execute_cmd("port config all rxq %s" % > nr_queue) > + self.vm0_testpmd.execute_cmd("port config all txq %s" % > nr_queue) > + out =3D self.vm0_testpmd.execute_cmd("port start all") > + self.logger.info(out) > + if 'failed' in out or 'fail to' in out: > + self.vm0_testpmd.execute_cmd("port stop all") > + time.sleep(5) > + self.vm0_testpmd.execute_cmd('quit', '# ') > + times -=3D 1 > + time.sleep(3) > + self.vm0_testpmd.quit() > + else: > + times =3D 0 > + > + self.vm0_testpmd.execute_cmd("clear port stats all") > + out =3D self.vm0_testpmd.execute_cmd("start") > + self.logger.info(out) > + vf0_mac =3D self.vm0_testpmd.get_port_mac(0).lower() > + self.verify("port 0: RX queue number: %s Tx queue number: %s= " % > (nr_queue, nr_queue) in out, > + "queue number %s maybe error" % nr_queue) > + self.send_packet2different_queue(vf0_mac, tester_mac, iface,= count) > + out =3D self.vm0_testpmd.get_output() > + out2 =3D self.vm0_testpmd.execute_cmd('stop') > + pkts_num=3Dout.count("src=3D%s - > dst=3D%s"%(tester_mac.upper(),vf0_mac.upper())) > + misc =3D out.count("dst=3DFF:FF:FF:FF:FF:FF") > + self.logger.info("get %d broadcast misc packages " % misc) > + self.check_result(nr_queue, out, out2, pkts_num, count, > + misc) > + > + def test_set_invalid_vf_queue_num_with_testpmd_command(self): > + invalid_queue_num =3D [0, 17] > + self.vm0_testpmd =3D PmdOutput(self.vm_dut_0) > + eal_param =3D '-w %(vf0)s' % {'vf0': self.vm_dut_0.vm_pci0} > + self.vm0_testpmd.start_testpmd("all", eal_param=3Deal_param) > + self.vm0_testpmd.execute_cmd('set promisc all off') > + self.vm0_testpmd.execute_cmd('set fwd mac') > + self.vm0_testpmd.execute_cmd("port stop all") > + for i in invalid_queue_num: > + if i =3D=3D 0: > + out1 =3D self.vm0_testpmd.execute_cmd("port config all r= xq %s" % i) > + # when set rxq or txq to 0 alone, dpdk didn't show warni= ng, only > when they are both set to 0. > + # so comment out the line below for now. > + # self.verify('Either rx or tx queues should be non zero= ' in out1, > "queue number can't be zero") > + out =3D self.vm0_testpmd.execute_cmd("port config all tx= q %s" % i) > + self.verify('Either rx or tx queues should be non zero' = in out, > "queue number can't be zero") > + else: > + out =3D self.vm0_testpmd.execute_cmd("port config all rx= q %s" % i) > + self.verify("input rxq (17) can't be greater than max_rx= _queues (16) > of port 0" in out, > + "queue number is too big") > + self.vm0_testpmd.execute_cmd("clear port stats all") > + time.sleep(1) > + self.vm0_testpmd.execute_cmd('quit', '# ') > + > + def tear_down(self): > + self.vm0_testpmd.execute_cmd('quit', '# ') > + > + def tear_down_all(self): > + self.logger.info("tear_down_all") > + if self.setup_1pf_2vf_1vm_env_flag =3D=3D 1: > + self.destroy_1pf_2vf_1vm_env() > -- > 2.17.1