[dts] [PATCH V1] tests/runtime_vf_queue_number:add testsuite for runtime vf queue number

Tu, Lijuan lijuan.tu at intel.com
Tue Apr 23 20:28:30 CEST 2019


No matter the VF queue number or reserved vf queue number should be random, not a fixed value.

> -----Original Message-----
> From: dts [mailto:dts-bounces at dpdk.org] On Behalf Of Jianwei Mei
> Sent: Sunday, April 21, 2019 8:25 PM
> To: dts at dpdk.org
> Cc: Mei, JianweiX <jianweix.mei at intel.com>
> Subject: [dts] [PATCH V1] tests/runtime_vf_queue_number:add testsuite for
> runtime vf queue number
> 
> add testsuite for runtime vf queue number
> 
> Signed-off-by: Jianwei Mei <jianweix.mei at intel.com>
> ---
>  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_runtime_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.
[Lijuan] 2010-2019 -> 2019
> +# 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.
> +
> +'''
> +
> +import time
> +import re
> +from qemu_kvm import QEMUKvm
> +from test_case import TestCase
> +from pmd_output import PmdOutput
> +
> +VM_CORES_MASK = 'all'
> +
> +class TestRuntimeVfQn(TestCase):
> +    supported_vf_driver = ['pci-stub', 'vfio-pci']
> +    def set_up_all(self):
> +        self.dut_ports = self.dut.get_ports(self.nic)
> +        self.verify(len(self.dut_ports) >= 1, 'Insufficient ports')
> +        self.src_intf = self.tester.get_interface(self.tester.get_local_port(0))
> +        self.src_mac =  self.tester.get_mac(self.tester.get_local_port(0))
> +        self.dst_mac = self.dut.get_mac_address(0)
> +        self.vm0 = None
> +        self.pf_pci = self.dut.ports_info[self.dut_ports[0]]['pci']
> +        self.host_testpmd = PmdOutput(self.dut)
> +        self.used_dut_port = self.dut_ports[0]
> +        self.vf_mac = "00:11:22:33:44:55"
> +
> +    def set_up(self):
> +        self.dut.kill_all()
> +
> +    def setup_vm_env(self, driver='default'):
> +        '''
> +        setup qemu virtual environment,this is to set up 1pf and 2vfs
> environment, the pf can be bond to
> +        kernel driver or dpdk driver.
> +        '''
> +        self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 2,
> driver=driver)
> +        self.sriov_vfs_port_0 =
> + self.dut.ports_info[self.used_dut_port]['vfs_port']
> +
> +        # set vf assign method and vf driver
> +        self.vf_driver = self.get_suite_cfg()['vf_driver']
> +        if self.vf_driver is None:
> +            self.vf_driver = 'pci-stub'
> +        self.verify(self.vf_driver in self.supported_vf_driver, "Unspported vf
> driver")
> +        if self.vf_driver == 'pci-stub':
> +            self.vf_assign_method = 'pci-assign'
> +        else:
> +            self.vf_assign_method = '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 = {'opt_host': self.sriov_vfs_port_0[0].pci}
> +            vf1_prop = {'opt_host': self.sriov_vfs_port_0[1].pci}
> +
> +            # set up VM0 ENV
> +            self.vm0 = QEMUKvm(self.dut, 'vm0', 'vf_queue_number')
> +            self.vm0.set_vm_device(driver=self.vf_assign_method, **vf0_prop)
> +            self.vm_dut_0 = 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 = None
> +            self.vm0.stop()
> +            self.vm0 = None
> +
> +        #destroy host testpmd
> +        if getattr(self, 'host_testpmd', None):
> +            self.host_testpmd.execute_cmd('quit', '# ')
> +            self.host_testpmd = 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 = self.dut.ports_info[self.used_dut_port]['port']
> +            port.bind_driver()
> +            self.used_dut_port = None
> +
> +        # bind used ports with default driver
> +        for port_id in self.dut_ports:
> +            port = 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='',
> eal_param=eal_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 = r'sendp([Ether(dst="%s",
> src=get_if_hwaddr("%s"))/IP(src="10.0.0.1", dst="192.168.0.%d")],
> iface="%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= 0" in out and "Queue= 1" in out and "Queue= 2" in
> out and "Queue= 3" in out
> +                    and "Queue= 4" in out and "Queue= 5" in out and "Queue= 6"
> in out and "Queue= 7" in out,
> +                    "there is some queues doesn't work")
> +        lines = out.split("\r\n")
> +        reta_line = {}
> +        queue_flag = 0
> +        packet_sumnum = 0
> +        # collect the hash result and the queue id
> +        for line in lines:
> +            line = line.strip()
> +            if queue_flag == 1:
> +                result_scanner = r"RX-packets:\s?([0-9]+)"
> +                scanner = re.compile(result_scanner, re.DOTALL)
> +                m = scanner.search(line)
> +                packet_num = m.group(1)
> +                packet_sumnum = packet_sumnum + int(packet_num)
> +                queue_flag = 0
> +            elif line.strip().startswith("------- Forward"):
> +                queue_flag = 1
> +            elif line.strip().startswith("RX-packets"):
> +                result_scanner = r"RX-packets:\s?([0-9]+)"
> +                scanner = re.compile(result_scanner, re.DOTALL)
> +                m = scanner.search(line)
> +                packet_rec = m.group(1)
> +
> +        self.verify(packet_sumnum == int(packet_rec) == 254, "There are
> + some packets lost.")
> +
> +    def stop_vm0(self):
> +        if getattr(self, 'vm0', None) and self.vm0:
> +            self.vm0_dut_ports = None
> +            self.vm0.stop()
> +            self.vm0 = None
> +
> +    def execute_testpmd_cmd(self, cmds):
> +        if len(cmds) == 0:
> +            return
> +        for item in cmds:
> +            if len(item) == 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()
[Lijuan] move to tear_down()
> +        self.setup_vm_env(driver='igb_uio')
> +        host_eal_param = '-w %s,queue-num-per-vf=4 --file-prefix=test1 --
> socket-mem 1024,1024' % self.pf_pci
> +        self.preset_host_testpmd(VM_CORES_MASK,
> + eal_param=host_eal_param)
> +
> +        gest_eal_param = '-w %s --file-prefix=test2' %
> self.vm_dut_0.ports_info[0]['pci']
> +        self.vm0_testpmd = PmdOutput(self.vm_dut_0)
> +        self.vm0_testpmd.start_testpmd(VM_CORES_MASK,
> eal_param=gest_eal_param, param='')
> +        time.sleep(1)
> +        guest_cmds = [['stop'],
> +                      ['port stop all'],
> +                      ['port config all txq 4'],
> +                      ['port config all rxq 4'],
> +                      ['port start all']]
> +        self.execute_testpmd_cmd(guest_cmds)
> +        outstring = self.vm0_testpmd.execute_cmd("start", "testpmd> ", 120)
> +        time.sleep(2)
> +        self.verify("port 0: RX queue number: 4 Tx queue number: 4" in
> outstring, "The RX/TX queue number error.")
> +        time.sleep(10)
> +        guest_cmds1 = [['stop'],
> +                       ['port stop all'],
> +                       ['port config all txq 5'],
> +                       ['port config all rxq 5'],
> +                       ['port start all']]
> +        self.execute_testpmd_cmd(guest_cmds1)
> +        outstring1 = self.vm0_testpmd.execute_cmd("start", "testpmd> ", 120)
> +        time.sleep(2)
> +        self.verify("port 0: RX queue number: 5 Tx queue number: 5" in
> outstring1, "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 = '-w %s,queue-num-per-vf=0 --file-prefix=test1 --socket-
> mem 1024,1024' % self.pf_pci
> +        testpmd_out = self.host_testpmd.start_testpmd(VM_CORES_MASK,
> param='', eal_param=eal_param)
> +        self.verify("it must be power of 2 and equal or less than 16" in
> testpmd_out, "there is no 'Wrong VF queue number = 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
> options
> +        :return:
> +        """
> +        self.stop_vm0()
> +        self.setup_vm_env(driver='igb_uio')
> +        host_eal_param = '-w %s --file-prefix=test1 --socket-mem 1024,1024' %
> self.pf_pci
> +        self.preset_host_testpmd(VM_CORES_MASK,
> + eal_param=host_eal_param)
> +
> +        gest_eal_param = '-w %s --file-prefix=test2' %
> self.vm_dut_0.ports_info[0]['pci']
> +        self.vm0_testpmd = PmdOutput(self.vm_dut_0)
> +        self.vm0_testpmd.start_testpmd(VM_CORES_MASK,
> eal_param=gest_eal_param, param=' --rxq=3 --txq=3')
> +        time.sleep(1)
> +        self.vm0_testpmd.execute_cmd("set promisc all off", "testpmd> ")
> +        self.vm0_testpmd.execute_cmd("set fwd mac", "testpmd> ")
> +        outstring = self.vm0_testpmd.execute_cmd("start", "testpmd> ", 120)
> +        time.sleep(2)
> +        self.verify("port 0: RX queue number: 3 Tx queue number: 3" in
> + outstring, "The RX/TX queue number error.")
> +
> +        self.vm0_dut_ports = self.vm_dut_0.get_ports('any')
> +        self.vf_mac = self.vm0_testpmd.get_port_mac(self.vm0_dut_ports[0])
> +        self.send_packet(self.vf_mac, self.src_intf, 3)
> +        outstring1 = self.vm0_testpmd.execute_cmd("stop", "testpmd> ", 120)
> +        time.sleep(2)
> +        self.verify("Queue= 0" in outstring1 or "Queue= 1" in outstring1 or
> "Queue= 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='igb_uio')
> +        host_eal_param = '-w %s --file-prefix=test1 --socket-mem 1024,1024' %
> self.pf_pci
> +        self.preset_host_testpmd(VM_CORES_MASK,
> + eal_param=host_eal_param)
> +
> +        gest_eal_param = '-w %s --file-prefix=test2' %
> self.vm_dut_0.ports_info[0]['pci']
> +        self.vm0_testpmd = PmdOutput(self.vm_dut_0)
> +        self.vm0_testpmd.start_testpmd(VM_CORES_MASK,
> eal_param=gest_eal_param, param=' --rxq=1 --txq=1')
> +        time.sleep(1)
> +        self.vm0_testpmd.execute_cmd("set promisc all off", "testpmd> ")
> +        self.vm0_testpmd.execute_cmd("set fwd mac", "testpmd> ")
> +        outstring = self.vm0_testpmd.execute_cmd("start", "testpmd> ", 120)
> +        time.sleep(2)
> +        self.verify("port 0: RX queue number: 1 Tx queue number: 1" in
> outstring, "The RX/TX queue number error.")
> +        self.vm0_dut_ports = self.vm_dut_0.get_ports('any')
> +        self.vf_mac =
> + self.vm0_testpmd.get_port_mac(self.vm0_dut_ports[0])
> +
> +        self.send_packet(self.vf_mac, self.src_intf, 3)
> +        outstring1 = self.vm0_testpmd.execute_cmd("stop", "testpmd> ", 120)
> +        time.sleep(2)
> +        self.verify("RX-packets: 3" in outstring1 and "TX-packets: 3" in
> outstring1, "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='igb_uio')
> +        host_eal_param = '-w %s --file-prefix=test1 --socket-mem 1024,1024' %
> self.pf_pci
> +        self.preset_host_testpmd(VM_CORES_MASK,
> + eal_param=host_eal_param)
> +
> +        gest_eal_param = '-w %s --file-prefix=test2' %
> self.vm_dut_0.ports_info[0]['pci']
> +        self.vm0_testpmd = PmdOutput(self.vm_dut_0)
> +        self.vm0_testpmd.start_testpmd(VM_CORES_MASK,
> eal_param=gest_eal_param, param=' --rxq=16 --txq=16')
> +        time.sleep(10)
> +        self.vm0_testpmd.execute_cmd("set promisc all off", "testpmd> ")
> +        self.vm0_testpmd.execute_cmd("set fwd mac", "testpmd> ")
> +        outstring = self.vm0_testpmd.execute_cmd("start", "testpmd> ", 120)
> +        time.sleep(2)
> +        self.verify("port 0: RX queue number: 16 Tx queue number: 16" in
> outstring, "The RX/TX queue number error.")
> +        self.vm0_dut_ports = self.vm_dut_0.get_ports('any')
> +        self.vf_mac =
> + self.vm0_testpmd.get_port_mac(self.vm0_dut_ports[0])
> +
> +        self.send_packet(self.vf_mac, self.src_intf, 254)
> +        outstring1 = self.vm0_testpmd.execute_cmd("stop", "testpmd> ", 120)
> +        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
> options
> +        :return:
> +        """
> +        self.stop_vm0()
> +        self.setup_vm_env(driver='igb_uio')
> +        host_eal_param = '-w %s --file-prefix=test1 --socket-mem 1024,1024' %
> self.pf_pci
> +        self.preset_host_testpmd(VM_CORES_MASK,
> eal_param=host_eal_param)
> +        gest_eal_param = '-w %s --file-prefix=test2' %
> self.vm_dut_0.ports_info[0]['pci']
> +        self.vm0_testpmd = PmdOutput(self.vm_dut_0)
> +
> +        command_0 = "./%s/app/testpmd -c %s -n %d %s -- -i %s" \
> +                  % (self.dut.target, '0xf', self.dut.get_memory_channels(),
> gest_eal_param, ' --rxq=0 --txq=0')
> +        outstring = self.vm0_testpmd.execute_cmd(command_0, expected='# ',
> timeout=120)
> +        time.sleep(10)
> +        self.verify("Either rx or tx queues should be non-zero" in outstring,
> "The output of testpmd start is different from expect when set invalid VF
> queue number 0.")
> +        time.sleep(2)
> +        command_17 = "./%s/app/testpmd -c %s -n %d %s -- -i %s" \
> +                  % (self.dut.target, '0xf', self.dut.get_memory_channels(),
> gest_eal_param, ' --rxq=17 --txq=17')
> +        outstring1 = self.vm0_testpmd.execute_cmd(command_17,
> expected='# ', timeout=120)
> +        time.sleep(10)
> +        self.verify("rxq 17 invalid - must be >= 0 && <= 16" in outstring1,
> +                    "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
> command
> +        :return:
> +        """
> +        self.stop_vm0()
> +        self.setup_vm_env(driver='igb_uio')
> +        host_eal_param = '-w %s --file-prefix=test1 --socket-mem 1024,1024' %
> self.pf_pci
> +        self.preset_host_testpmd(VM_CORES_MASK,
> + eal_param=host_eal_param)
> +
> +        gest_eal_param = '-w %s --file-prefix=test2' %
> self.vm_dut_0.ports_info[0]['pci']
> +        self.vm0_testpmd = PmdOutput(self.vm_dut_0)
> +        self.vm0_testpmd.start_testpmd(VM_CORES_MASK,
> eal_param=gest_eal_param, param='')
> +        time.sleep(10)
> +        guest_cmds = [['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 = self.vm0_testpmd.execute_cmd("start", "testpmd> ", 120)
> +        time.sleep(2)
> +        self.verify("port 0: RX queue number: 3 Tx queue number: 3" in
> outstring, "The RX/TX queue number error.")
> +        self.vm0_dut_ports = self.vm_dut_0.get_ports('any')
> +        self.vf_mac =
> + self.vm0_testpmd.get_port_mac(self.vm0_dut_ports[0])
> +
> +        self.send_packet(self.vf_mac, self.src_intf, 3)
> +        outstring1 = self.vm0_testpmd.execute_cmd("stop", "testpmd> ", 120)
> +        time.sleep(2)
> +        self.verify("Queue= 0" in outstring1 or "Queue= 1" in outstring1 or
> "Queue= 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
> function command
> +        :return:
> +        """
> +        self.stop_vm0()
> +        self.setup_vm_env(driver='igb_uio')
> +        host_eal_param = '-w %s --file-prefix=test1 --socket-mem 1024,1024' %
> self.pf_pci
> +        self.preset_host_testpmd(VM_CORES_MASK,
> + eal_param=host_eal_param)
> +
> +        gest_eal_param = '-w %s --file-prefix=test2' %
> self.vm_dut_0.ports_info[0]['pci']
> +        self.vm0_testpmd = PmdOutput(self.vm_dut_0)
> +        self.vm0_testpmd.start_testpmd(VM_CORES_MASK,
> eal_param=gest_eal_param, param='')
> +        time.sleep(10)
> +        guest_cmds = [['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 = self.vm0_testpmd.execute_cmd("start", "testpmd> ", 120)
> +        time.sleep(2)
> +        self.verify("port 0: RX queue number: 1 Tx queue number: 1" in
> outstring, "The RX/TX queue number error.")
> +        self.vm0_dut_ports = self.vm_dut_0.get_ports('any')
> +        self.vf_mac =
> + self.vm0_testpmd.get_port_mac(self.vm0_dut_ports[0])
> +
> +        self.send_packet(self.vf_mac, self.src_intf, 3)
> +        outstring1 = self.vm0_testpmd.execute_cmd("stop", "testpmd> ", 120)
> +        time.sleep(2)
> +        self.verify("RX-packets: 3" in outstring1 and "TX-packets: 3" in
> outstring1,
> +                    "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
> function command
> +        :return:
> +        """
> +        self.stop_vm0()
> +        self.setup_vm_env(driver='igb_uio')
> +        host_eal_param = '-w %s --file-prefix=test1 --socket-mem 1024,1024' %
> self.pf_pci
> +        self.preset_host_testpmd(VM_CORES_MASK,
> + eal_param=host_eal_param)
> +
> +        gest_eal_param = '-w %s --file-prefix=test2' %
> self.vm_dut_0.ports_info[0]['pci']
> +        self.vm0_testpmd = PmdOutput(self.vm_dut_0)
> +        self.vm0_testpmd.start_testpmd(VM_CORES_MASK,
> eal_param=gest_eal_param, param='')
> +        time.sleep(10)
> +        guest_cmds = [['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 = self.vm0_testpmd.execute_cmd("start", "testpmd> ", 120)
> +        time.sleep(2)
> +        self.verify("port 0: RX queue number: 16 Tx queue number: 16" in
> outstring, "The RX/TX queue number error.")
> +        self.vm0_dut_ports = self.vm_dut_0.get_ports('any')
> +        self.vf_mac =
> + self.vm0_testpmd.get_port_mac(self.vm0_dut_ports[0])
> +
> +        self.send_packet(self.vf_mac, self.src_intf, 254)
> +        outstring1 = self.vm0_testpmd.execute_cmd("stop", "testpmd> ", 120)
> +        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
> command
> +        :return:
> +        """
> +        # There is a bug of this test case, so the function hasn't been
> implemented.
> +        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='igb_uio')
> +        host_eal_param = '-w %s,queue-num-per-vf=2 --file-prefix=test1 --
> socket-mem 1024,1024' % self.pf_pci
> +        self.preset_host_testpmd(VM_CORES_MASK,
> + eal_param=host_eal_param)
> +
> +        gest_eal_param = '-w %s --file-prefix=test2' %
> self.vm_dut_0.ports_info[0]['pci']
> +        self.vm0_testpmd = PmdOutput(self.vm_dut_0)
> +        self.vm0_testpmd.start_testpmd(VM_CORES_MASK,
> eal_param=gest_eal_param, param='')
> +        time.sleep(1)
> +        intf = self.vm_dut_0.ports_info[0]['intf']
> +        if intf != 'N/A' and intf != '':
> +            self.vm0_testpmd.execute_cmd('quit', '# ')
> +            command = "./usertools/dpdk-devbind.py -b i40evf %s" %
> self.vm_dut_0.ports_info[0]['pci']
> +            self.vm0_testpmd.execute_cmd(command, expected='# ',
> timeout=120)
> +            output = self.vm0_testpmd.execute_cmd("ethtool -S %s" % intf,
> expected='# ', timeout=120)
> +            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 = "./usertools/dpdk-devbind.py -b i40evf %s" %
> self.vm_dut_0.ports_info[0]['pci']
> +            self.vm0_testpmd.execute_cmd(command, expected='# ',
> timeout=120)
> +            nic_info = self.vm0_testpmd.execute_cmd("./usertools/dpdk-
> devbind.py -s | grep %s" % self.vm_dut_0.ports_info[0]['pci'], expected='# ',
> timeout=120)
> +            time.sleep(2)
> +            inf_str = nic_info.split("if=")[1]
> +            inf = inf_str.split(" ")[0]
> +            if "drv" not in inf and inf != "":
> +                output = self.vm0_testpmd.execute_cmd("ethtool -S %s" % inf,
> expected='# ', timeout=120)
> +            else:
> +                output = ""
> +            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
> + -v grep  | awk  {'print $2'})", '# ', 5)
> --
> 2.17.2



More information about the dts mailing list