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 DD6B9A05D3 for ; Mon, 22 Apr 2019 12:01:01 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AA81A1B395; Mon, 22 Apr 2019 12:01:01 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 821FE1B0FF for ; Mon, 22 Apr 2019 12:00:59 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Apr 2019 03:00:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,381,1549958400"; d="scan'208";a="144783066" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga007.fm.intel.com with ESMTP; 22 Apr 2019 02:55:58 -0700 Received: from fmsmsx155.amr.corp.intel.com (10.18.116.71) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 22 Apr 2019 02:55:58 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX155.amr.corp.intel.com (10.18.116.71) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 22 Apr 2019 02:55:57 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.93]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.164]) with mapi id 14.03.0415.000; Mon, 22 Apr 2019 17:55:55 +0800 From: "Xiao, QimaiX" To: "Mei, JianweiX" , "dts@dpdk.org" CC: "Mei, JianweiX" Thread-Topic: [dts] [PATCH V1] tests/runtime_vf_queue_number:add testsuite for runtime vf queue number Thread-Index: AQHU+Lp4v9vxIFh24UW2M7m/tXMP76ZH66Mg Date: Mon, 22 Apr 2019 09:55:55 +0000 Message-ID: <5C5FA1EBCC0D164EAD0302E258A5234B6EF3AE@SHSMSX103.ccr.corp.intel.com> References: <1555903525-3272-1-git-send-email-jianweix.mei@intel.com> In-Reply-To: <1555903525-3272-1-git-send-email-jianweix.mei@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: 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] tests/runtime_vf_queue_number:add testsuite for runtime vf queue number 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" Tested-by: xiao, qimai -----Original Message----- From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Jianwei Mei Sent: Monday, April 22, 2019 11:25 AM To: dts@dpdk.org Cc: Mei, JianweiX Subject: [dts] [PATCH V1] tests/runtime_vf_queue_number:add testsuite for r= untime vf queue number add testsuite for runtime vf queue number Signed-off-by: Jianwei Mei --- tests/TestSuite_runtime_vf_queue_number.py | 507 +++++++++++++++++++++ 1 file changed, 507 insertions(+) create mode 100644 tests/TestSuite_runtime_vf_queue_number.py diff --git a/tests/TestSuite_runtime_vf_queue_number.py b/tests/TestSuite_r= untime_vf_queue_number.py new file mode 100644 index 0000000..3e03020 --- /dev/null +++ b/tests/TestSuite_runtime_vf_queue_number.py @@ -0,0 +1,507 @@ +# BSD LICENSE +# +# Copyright(c) 2010-2019 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. + +''' + +import time +import re +from qemu_kvm import QEMUKvm +from test_case import TestCase +from pmd_output import PmdOutput + +VM_CORES_MASK =3D 'all' + +class TestRuntimeVfQn(TestCase): + supported_vf_driver =3D ['pci-stub', 'vfio-pci'] + def set_up_all(self): + self.dut_ports =3D self.dut.get_ports(self.nic) + self.verify(len(self.dut_ports) >=3D 1, 'Insufficient ports') + self.src_intf =3D self.tester.get_interface(self.tester.get_local_= port(0)) + self.src_mac =3D self.tester.get_mac(self.tester.get_local_port(0= )) + self.dst_mac =3D self.dut.get_mac_address(0) + self.vm0 =3D None + self.pf_pci =3D self.dut.ports_info[self.dut_ports[0]]['pci'] + self.host_testpmd =3D PmdOutput(self.dut) + self.used_dut_port =3D self.dut_ports[0] + self.vf_mac =3D "00:11:22:33:44:55" + + def set_up(self): + self.dut.kill_all() + + def setup_vm_env(self, driver=3D'default'): + ''' + setup qemu virtual environment,this is to set up 1pf and 2vfs envi= ronment, the pf can be bond to + kernel driver or dpdk driver. + ''' + self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 2, driver= =3Ddriver) + self.sriov_vfs_port_0 =3D=20 + self.dut.ports_info[self.used_dut_port]['vfs_port'] + + # 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, "Unspporte= d 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', '#') + + try: + for port in self.sriov_vfs_port_0: + port.bind_driver(self.vf_driver) + + time.sleep(1) + vf0_prop =3D {'opt_host': self.sriov_vfs_port_0[0].pci} + vf1_prop =3D {'opt_host': self.sriov_vfs_port_0[1].pci} + + # set up VM0 ENV + self.vm0 =3D QEMUKvm(self.dut, 'vm0', 'vf_queue_number') + self.vm0.set_vm_device(driver=3Dself.vf_assign_method, **vf0_p= rop) + self.vm_dut_0 =3D self.vm0.start() + if self.vm_dut_0 is None: + raise Exception('Set up VM0 ENV failed!') + except Exception as e: + print e + self.destroy_vm_env() + raise Exception(e) + + def destroy_vm_env(self): + #destroy vm0 + if getattr(self, 'vm0', None) and self.vm0: + self.vm0_dut_ports =3D None + self.vm0.stop() + self.vm0 =3D None + + #destroy host testpmd + if getattr(self, 'host_testpmd', None): + self.host_testpmd.execute_cmd('quit', '# ') + self.host_testpmd =3D None + + # reset used port's sriov + if getattr(self, 'used_dut_port', 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 + + # bind used ports with default driver + for port_id in self.dut_ports: + port =3D self.dut.ports_info[port_id]['port'] + port.bind_driver() + + def preset_host_testpmd(self, core_mask, eal_param): + self.host_testpmd.start_testpmd(core_mask, param=3D'', eal_param= =3Deal_param) + time.sleep(2) + + def send_packet(self, vf_mac, itf, integer): + """ + Sends packets. + """ + self.tester.scapy_foreground() + time.sleep(2) + for i in range(integer): + packet =3D r'sendp([Ether(dst=3D"%s", src=3Dget_if_hwaddr("%s"= ))/IP(src=3D"10.0.0.1", dst=3D"192.168.0.%d")], iface=3D"%s")' % ( + vf_mac, itf, i + 1, itf) + self.tester.scapy_append(packet) + self.tester.scapy_execute() + time.sleep(2) + + def check_packet_queue(self, out): + """ + get the queue which packet enter. + """ + self.verify("Queue=3D 0" in out and "Queue=3D 1" in out and "Queue= =3D 2" in out and "Queue=3D 3" in out + and "Queue=3D 4" in out and "Queue=3D 5" in out and "Q= ueue=3D 6" in out and "Queue=3D 7" in out, + "there is some queues doesn't work") + lines =3D out.split("\r\n") + reta_line =3D {} + queue_flag =3D 0 + packet_sumnum =3D 0 + # collect the hash result and the queue id + for line in lines: + line =3D line.strip() + if queue_flag =3D=3D 1: + result_scanner =3D r"RX-packets:\s?([0-9]+)" + scanner =3D re.compile(result_scanner, re.DOTALL) + m =3D scanner.search(line) + packet_num =3D m.group(1) + packet_sumnum =3D packet_sumnum + int(packet_num) + queue_flag =3D 0 + elif line.strip().startswith("------- Forward"): + queue_flag =3D 1 + elif line.strip().startswith("RX-packets"): + result_scanner =3D r"RX-packets:\s?([0-9]+)" + scanner =3D re.compile(result_scanner, re.DOTALL) + m =3D scanner.search(line) + packet_rec =3D m.group(1) + + self.verify(packet_sumnum =3D=3D int(packet_rec) =3D=3D 254, "Ther= e are=20 + some packets lost.") + + def stop_vm0(self): + if getattr(self, 'vm0', None) and self.vm0: + self.vm0_dut_ports =3D None + self.vm0.stop() + self.vm0 =3D None + + def execute_testpmd_cmd(self, cmds): + if len(cmds) =3D=3D 0: + return + for item in cmds: + if len(item) =3D=3D 2: + self.vm0_testpmd.execute_cmd(item[0], int(item[1])) + else: + self.vm0_testpmd.execute_cmd(item[0]) + + def test_set_valid_vf_qn(self): + """ + Test case 1: reserve valid vf queue number + :return: + """ + self.stop_vm0() + self.setup_vm_env(driver=3D'igb_uio') + host_eal_param =3D '-w %s,queue-num-per-vf=3D4 --file-prefix=3Dtes= t1 --socket-mem 1024,1024' % self.pf_pci + self.preset_host_testpmd(VM_CORES_MASK,=20 + eal_param=3Dhost_eal_param) + + gest_eal_param =3D '-w %s --file-prefix=3Dtest2' % self.vm_dut_0.p= orts_info[0]['pci'] + self.vm0_testpmd =3D PmdOutput(self.vm_dut_0) + self.vm0_testpmd.start_testpmd(VM_CORES_MASK, eal_param=3Dgest_eal= _param, param=3D'') + time.sleep(1) + guest_cmds =3D [['stop'], + ['port stop all'], + ['port config all txq 4'], + ['port config all rxq 4'], + ['port start all']] + self.execute_testpmd_cmd(guest_cmds) + outstring =3D self.vm0_testpmd.execute_cmd("start", "testpmd> ", 1= 20) + time.sleep(2) + self.verify("port 0: RX queue number: 4 Tx queue number: 4" in out= string, "The RX/TX queue number error.") + time.sleep(10) + guest_cmds1 =3D [['stop'], + ['port stop all'], + ['port config all txq 5'], + ['port config all rxq 5'], + ['port start all']] + self.execute_testpmd_cmd(guest_cmds1) + outstring1 =3D self.vm0_testpmd.execute_cmd("start", "testpmd> ", = 120) + time.sleep(2) + self.verify("port 0: RX queue number: 5 Tx queue number: 5" in out= string1, "The RX/TX queue number error.") + time.sleep(2) + self.vm0_testpmd.execute_cmd('quit', '# ') + self.dut.send_expect("quit", "# ") + + def test_set_invalid_vf_qn(self): + """ + Test case 2: reserve invalid VF queue number + :return: + """ + eal_param =3D '-w %s,queue-num-per-vf=3D0 --file-prefix=3Dtest1 --= socket-mem 1024,1024' % self.pf_pci + testpmd_out =3D self.host_testpmd.start_testpmd(VM_CORES_MASK, par= am=3D'', eal_param=3Deal_param) + self.verify("it must be power of 2 and equal or less than 16" in t= estpmd_out, "there is no 'Wrong VF queue number =3D 0' logs.") + self.dut.send_expect("quit", "# ") + + def test_set_valid_vf_qn_in_testpmd(self): + """ + Test case 3: set valid VF queue number in testpmd command-line opt= ions + :return: + """ + self.stop_vm0() + self.setup_vm_env(driver=3D'igb_uio') + host_eal_param =3D '-w %s --file-prefix=3Dtest1 --socket-mem 1024,= 1024' % self.pf_pci + self.preset_host_testpmd(VM_CORES_MASK,=20 + eal_param=3Dhost_eal_param) + + gest_eal_param =3D '-w %s --file-prefix=3Dtest2' % self.vm_dut_0.p= orts_info[0]['pci'] + self.vm0_testpmd =3D PmdOutput(self.vm_dut_0) + self.vm0_testpmd.start_testpmd(VM_CORES_MASK, eal_param=3Dgest_eal= _param, param=3D' --rxq=3D3 --txq=3D3') + time.sleep(1) + self.vm0_testpmd.execute_cmd("set promisc all off", "testpmd> ") + self.vm0_testpmd.execute_cmd("set fwd mac", "testpmd> ") + outstring =3D self.vm0_testpmd.execute_cmd("start", "testpmd> ", 1= 20) + time.sleep(2) + self.verify("port 0: RX queue number: 3 Tx queue number: 3" in=20 + outstring, "The RX/TX queue number error.") + + self.vm0_dut_ports =3D self.vm_dut_0.get_ports('any') + self.vf_mac =3D self.vm0_testpmd.get_port_mac(self.vm0_dut_ports[0= ]) + self.send_packet(self.vf_mac, self.src_intf, 3) + outstring1 =3D self.vm0_testpmd.execute_cmd("stop", "testpmd> ", 1= 20) + time.sleep(2) + self.verify("Queue=3D 0" in outstring1 or "Queue=3D 1" in outstrin= g1 or "Queue=3D 2" in outstring1, "there is some queues doesn't work") + self.vm0_testpmd.execute_cmd('quit', '# ') + self.dut.send_expect("quit", "# ") + + def test_set_valid_min_vf_qn_in_testpmd(self): + """ + Test case 3: set mininum valid VF queue number in testpmd command-= line options + :return: + """ + self.stop_vm0() + self.setup_vm_env(driver=3D'igb_uio') + host_eal_param =3D '-w %s --file-prefix=3Dtest1 --socket-mem 1024,= 1024' % self.pf_pci + self.preset_host_testpmd(VM_CORES_MASK,=20 + eal_param=3Dhost_eal_param) + + gest_eal_param =3D '-w %s --file-prefix=3Dtest2' % self.vm_dut_0.p= orts_info[0]['pci'] + self.vm0_testpmd =3D PmdOutput(self.vm_dut_0) + self.vm0_testpmd.start_testpmd(VM_CORES_MASK, eal_param=3Dgest_eal= _param, param=3D' --rxq=3D1 --txq=3D1') + time.sleep(1) + self.vm0_testpmd.execute_cmd("set promisc all off", "testpmd> ") + self.vm0_testpmd.execute_cmd("set fwd mac", "testpmd> ") + outstring =3D self.vm0_testpmd.execute_cmd("start", "testpmd> ", 1= 20) + time.sleep(2) + self.verify("port 0: RX queue number: 1 Tx queue number: 1" in out= string, "The RX/TX queue number error.") + self.vm0_dut_ports =3D self.vm_dut_0.get_ports('any') + self.vf_mac =3D=20 + self.vm0_testpmd.get_port_mac(self.vm0_dut_ports[0]) + + self.send_packet(self.vf_mac, self.src_intf, 3) + outstring1 =3D self.vm0_testpmd.execute_cmd("stop", "testpmd> ", 1= 20) + time.sleep(2) + self.verify("RX-packets: 3" in outstring1 and "TX-packets: 3" in o= utstring1, "the count of packets is incorrect.") + self.vm0_testpmd.execute_cmd('quit', '# ') + self.dut.send_expect("quit", "# ") + + def test_set_valid_max_vf_qn_in_testpmd(self): + """ + Test case 3: set maximum valid VF queue number in testpmd command-= line options + :return: + """ + self.stop_vm0() + self.setup_vm_env(driver=3D'igb_uio') + host_eal_param =3D '-w %s --file-prefix=3Dtest1 --socket-mem 1024,= 1024' % self.pf_pci + self.preset_host_testpmd(VM_CORES_MASK,=20 + eal_param=3Dhost_eal_param) + + gest_eal_param =3D '-w %s --file-prefix=3Dtest2' % self.vm_dut_0.p= orts_info[0]['pci'] + self.vm0_testpmd =3D PmdOutput(self.vm_dut_0) + self.vm0_testpmd.start_testpmd(VM_CORES_MASK, eal_param=3Dgest_eal= _param, param=3D' --rxq=3D16 --txq=3D16') + time.sleep(10) + self.vm0_testpmd.execute_cmd("set promisc all off", "testpmd> ") + self.vm0_testpmd.execute_cmd("set fwd mac", "testpmd> ") + outstring =3D self.vm0_testpmd.execute_cmd("start", "testpmd> ", 1= 20) + time.sleep(2) + self.verify("port 0: RX queue number: 16 Tx queue number: 16" in o= utstring, "The RX/TX queue number error.") + self.vm0_dut_ports =3D self.vm_dut_0.get_ports('any') + self.vf_mac =3D=20 + self.vm0_testpmd.get_port_mac(self.vm0_dut_ports[0]) + + self.send_packet(self.vf_mac, self.src_intf, 254) + outstring1 =3D self.vm0_testpmd.execute_cmd("stop", "testpmd> ", 1= 20) + self.check_packet_queue(outstring1) + self.vm0_testpmd.execute_cmd('quit', '# ') + self.dut.send_expect("quit", "# ") + + def test_set_invalid_vf_qn_in_testpmd(self): + """ + Test case 4: set invalid VF queue number in testpmd command-line o= ptions + :return: + """ + self.stop_vm0() + self.setup_vm_env(driver=3D'igb_uio') + host_eal_param =3D '-w %s --file-prefix=3Dtest1 --socket-mem 1024,= 1024' % self.pf_pci + self.preset_host_testpmd(VM_CORES_MASK, eal_param=3Dhost_eal_param= ) + gest_eal_param =3D '-w %s --file-prefix=3Dtest2' % self.vm_dut_0.p= orts_info[0]['pci'] + self.vm0_testpmd =3D PmdOutput(self.vm_dut_0) + + command_0 =3D "./%s/app/testpmd -c %s -n %d %s -- -i %s" \ + % (self.dut.target, '0xf', self.dut.get_memory_channels(= ), gest_eal_param, ' --rxq=3D0 --txq=3D0') + outstring =3D self.vm0_testpmd.execute_cmd(command_0, expected=3D'= # ', timeout=3D120) + time.sleep(10) + self.verify("Either rx or tx queues should be non-zero" in outstri= ng, "The output of testpmd start is different from expect when set invalid = VF queue number 0.") + time.sleep(2) + command_17 =3D "./%s/app/testpmd -c %s -n %d %s -- -i %s" \ + % (self.dut.target, '0xf', self.dut.get_memory_channels(= ), gest_eal_param, ' --rxq=3D17 --txq=3D17') + outstring1 =3D self.vm0_testpmd.execute_cmd(command_17, expected= =3D'# ', timeout=3D120) + time.sleep(10) + self.verify("rxq 17 invalid - must be >=3D 0 && <=3D 16" in outstr= ing1, + "The output of testpmd start is different from expect = when set invalid VF queue number 17.") + self.dut.send_expect("quit", "# ") + + def test_set_valid_vf_qn_with_testpmd_func_cmd(self): + """ + Test case 5: set valid VF queue number with testpmd function comma= nd + :return: + """ + self.stop_vm0() + self.setup_vm_env(driver=3D'igb_uio') + host_eal_param =3D '-w %s --file-prefix=3Dtest1 --socket-mem 1024,= 1024' % self.pf_pci + self.preset_host_testpmd(VM_CORES_MASK,=20 + eal_param=3Dhost_eal_param) + + gest_eal_param =3D '-w %s --file-prefix=3Dtest2' % self.vm_dut_0.p= orts_info[0]['pci'] + self.vm0_testpmd =3D PmdOutput(self.vm_dut_0) + self.vm0_testpmd.start_testpmd(VM_CORES_MASK, eal_param=3Dgest_eal= _param, param=3D'') + time.sleep(10) + guest_cmds =3D [['set promisc all off'], + ['set fwd mac'], + ['stop'], + ['port stop all'], + ['port config all txq 3'], + ['port config all rxq 3'], + ['port start all']] + self.execute_testpmd_cmd(guest_cmds) + outstring =3D self.vm0_testpmd.execute_cmd("start", "testpmd> ", 1= 20) + time.sleep(2) + self.verify("port 0: RX queue number: 3 Tx queue number: 3" in out= string, "The RX/TX queue number error.") + self.vm0_dut_ports =3D self.vm_dut_0.get_ports('any') + self.vf_mac =3D=20 + self.vm0_testpmd.get_port_mac(self.vm0_dut_ports[0]) + + self.send_packet(self.vf_mac, self.src_intf, 3) + outstring1 =3D self.vm0_testpmd.execute_cmd("stop", "testpmd> ", 1= 20) + time.sleep(2) + self.verify("Queue=3D 0" in outstring1 or "Queue=3D 1" in outstrin= g1 or "Queue=3D 2" in outstring1, + "there is some queues doesn't work") + + self.vm0_testpmd.execute_cmd('quit', '# ') + self.dut.send_expect("quit", "# ") + + def test_set_min_vf_qn_with_testpmd_func_cmd(self): + """ + Test case 5: set mininum valid VF queue number with testpmd functi= on command + :return: + """ + self.stop_vm0() + self.setup_vm_env(driver=3D'igb_uio') + host_eal_param =3D '-w %s --file-prefix=3Dtest1 --socket-mem 1024,= 1024' % self.pf_pci + self.preset_host_testpmd(VM_CORES_MASK,=20 + eal_param=3Dhost_eal_param) + + gest_eal_param =3D '-w %s --file-prefix=3Dtest2' % self.vm_dut_0.p= orts_info[0]['pci'] + self.vm0_testpmd =3D PmdOutput(self.vm_dut_0) + self.vm0_testpmd.start_testpmd(VM_CORES_MASK, eal_param=3Dgest_eal= _param, param=3D'') + time.sleep(10) + guest_cmds =3D [['set promisc all off'], + ['set fwd mac'], + ['stop'], + ['port stop all'], + ['port config all txq 1'], + ['port config all rxq 1'], + ['port start all']] + self.execute_testpmd_cmd(guest_cmds) + outstring =3D self.vm0_testpmd.execute_cmd("start", "testpmd> ", 1= 20) + time.sleep(2) + self.verify("port 0: RX queue number: 1 Tx queue number: 1" in out= string, "The RX/TX queue number error.") + self.vm0_dut_ports =3D self.vm_dut_0.get_ports('any') + self.vf_mac =3D=20 + self.vm0_testpmd.get_port_mac(self.vm0_dut_ports[0]) + + self.send_packet(self.vf_mac, self.src_intf, 3) + outstring1 =3D self.vm0_testpmd.execute_cmd("stop", "testpmd> ", 1= 20) + time.sleep(2) + self.verify("RX-packets: 3" in outstring1 and "TX-packets: 3" in o= utstring1, + "the count of packets is incorrect.") + + self.vm0_testpmd.execute_cmd('quit', '# ') + self.dut.send_expect("quit", "# ") + + def test_set_max_vf_qn_with_testpmd_func_cmd(self): + """ + Test case 5: set maximum valid VF queue number with testpmd functi= on command + :return: + """ + self.stop_vm0() + self.setup_vm_env(driver=3D'igb_uio') + host_eal_param =3D '-w %s --file-prefix=3Dtest1 --socket-mem 1024,= 1024' % self.pf_pci + self.preset_host_testpmd(VM_CORES_MASK,=20 + eal_param=3Dhost_eal_param) + + gest_eal_param =3D '-w %s --file-prefix=3Dtest2' % self.vm_dut_0.p= orts_info[0]['pci'] + self.vm0_testpmd =3D PmdOutput(self.vm_dut_0) + self.vm0_testpmd.start_testpmd(VM_CORES_MASK, eal_param=3Dgest_eal= _param, param=3D'') + time.sleep(10) + guest_cmds =3D [['set promisc all off'], + ['set fwd mac'], + ['stop'], + ['port stop all'], + ['port config all txq 16'], + ['port config all rxq 16'], + ['port start all']] + self.execute_testpmd_cmd(guest_cmds) + outstring =3D self.vm0_testpmd.execute_cmd("start", "testpmd> ", 1= 20) + time.sleep(2) + self.verify("port 0: RX queue number: 16 Tx queue number: 16" in o= utstring, "The RX/TX queue number error.") + self.vm0_dut_ports =3D self.vm_dut_0.get_ports('any') + self.vf_mac =3D=20 + self.vm0_testpmd.get_port_mac(self.vm0_dut_ports[0]) + + self.send_packet(self.vf_mac, self.src_intf, 254) + outstring1 =3D self.vm0_testpmd.execute_cmd("stop", "testpmd> ", 1= 20) + self.check_packet_queue(outstring1) + self.vm0_testpmd.execute_cmd('quit', '# ') + self.dut.send_expect("quit", "# ") + + def test_set_invalid_vf_qn_with_testpmd_func_cmd(self): + """ + Test case 6: set invalid VF queue number with testpmd function com= mand + :return: + """ + # There is a bug of this test case, so the function hasn't been im= plemented. + pass + + def test_reserve_vf_qn(self): + """ + Test case 7: Reserve VF queue number when VF bind to kernel driver + :return: + """ + self.stop_vm0() + self.setup_vm_env(driver=3D'igb_uio') + host_eal_param =3D '-w %s,queue-num-per-vf=3D2 --file-prefix=3Dtes= t1 --socket-mem 1024,1024' % self.pf_pci + self.preset_host_testpmd(VM_CORES_MASK,=20 + eal_param=3Dhost_eal_param) + + gest_eal_param =3D '-w %s --file-prefix=3Dtest2' % self.vm_dut_0.p= orts_info[0]['pci'] + self.vm0_testpmd =3D PmdOutput(self.vm_dut_0) + self.vm0_testpmd.start_testpmd(VM_CORES_MASK, eal_param=3Dgest_eal= _param, param=3D'') + time.sleep(1) + intf =3D self.vm_dut_0.ports_info[0]['intf'] + if intf !=3D 'N/A' and intf !=3D '': + self.vm0_testpmd.execute_cmd('quit', '# ') + command =3D "./usertools/dpdk-devbind.py -b i40evf %s" % self.= vm_dut_0.ports_info[0]['pci'] + self.vm0_testpmd.execute_cmd(command, expected=3D'# ', timeout= =3D120) + output =3D self.vm0_testpmd.execute_cmd("ethtool -S %s" % intf= , expected=3D'# ', timeout=3D120) + self.verify("tx-0.packets: 0" in output and "tx-1.packets: 0" = in output, "VF0 rxq and txq number is not 2.") + else: + time.sleep(120) + self.vm0_testpmd.execute_cmd('quit', '# ') + command =3D "./usertools/dpdk-devbind.py -b i40evf %s" % self.= vm_dut_0.ports_info[0]['pci'] + self.vm0_testpmd.execute_cmd(command, expected=3D'# ', timeout= =3D120) + nic_info =3D self.vm0_testpmd.execute_cmd("./usertools/dpdk-de= vbind.py -s | grep %s" % self.vm_dut_0.ports_info[0]['pci'], expected=3D'# = ', timeout=3D120) + time.sleep(2) + inf_str =3D nic_info.split("if=3D")[1] + inf =3D inf_str.split(" ")[0] + if "drv" not in inf and inf !=3D "": + output =3D self.vm0_testpmd.execute_cmd("ethtool -S %s" % = inf, expected=3D'# ', timeout=3D120) + else: + output =3D "" + self.verify("tx-0.packets: 0" in output and "tx-1.packets: 0" = in output, "VF0 rxq and txq number is not 2.") + self.dut.send_expect("quit", "# ") + + def tear_down(self): + pass + + def tear_down_all(self): + self.destroy_vm_env() + for port_id in self.dut_ports: + self.dut.destroy_sriov_vfs_by_port(port_id) + + self.tester.send_expect("kill -9 $(ps aux | grep -i qemu | grep=20 + -v grep | awk {'print $2'})", '# ', 5) -- 2.17.2