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 31EE3A00E6 for ; Tue, 14 May 2019 04:47:21 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E5C1D5920; Tue, 14 May 2019 04:47:20 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 093FB2B89 for ; Tue, 14 May 2019 04:47:18 +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 fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 May 2019 19:47:17 -0700 X-ExtLoop1: 1 Received: from npg-dpdk-project-yinanwang-1.sh.intel.com ([10.67.110.176]) by fmsmga007.fm.intel.com with ESMTP; 13 May 2019 19:47:16 -0700 From: Yinan To: dts@dpdk.org Cc: Jianwei Mei Date: Mon, 13 May 2019 19:44:47 +0000 Message-Id: <20190513194447.43251-1-yinan.wang@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dts] [PATCH v1] tests: and test script TestSuite_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" From: Jianwei Mei add testsuite for runtime vf queue number Signed-off-by: Jianwei Mei --- tests/TestSuite_runtime_vf_queue_number.py | 522 +++++++++++++++++++++ 1 file changed, 522 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..f48625e --- /dev/null +++ b/tests/TestSuite_runtime_vf_queue_number.py @@ -0,0 +1,522 @@ +# 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. + +''' + +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.used_dut_port = self.dut_ports[0] + self.vf_mac = "00:11:22:33:44:55" + + def set_up(self): + self.dut.kill_all() + self.host_testpmd = PmdOutput(self.dut) + self.setup_vm_env(driver='igb_uio') + + 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 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") + 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 get_queue_number_info(self, outstring): + queue_info = [] + lines = outstring.split("\r\n") + for line in lines: + line = line.strip() + if line.strip().startswith("------- Forward"): + result_scanner = r"Queue=\s?([0-9]+)" + scanner = re.compile(result_scanner, re.DOTALL) + m = scanner.search(line) + queue_info.append(m.group(0)) + else: + continue + return queue_info + + 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: + """ + valid_qn = (1, 2, 4, 8, 16,) + for qn in valid_qn: + host_eal_param = '-w %s,queue-num-per-vf=%d --file-prefix=test1 --socket-mem 1024,1024' % (self.pf_pci, qn) + self.host_testpmd.start_testpmd(VM_CORES_MASK, param='', 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 %d' % qn], + ['port config all rxq %d' % qn], + ['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: %d Tx queue number: %d" % (qn, qn) in outstring, "The RX/TX queue number error.") + time.sleep(10) + if (qn + 1) == 17: + self.vm0_testpmd.execute_cmd("stop", "testpmd> ", 120) + self.vm0_testpmd.execute_cmd("port stop all", "testpmd> ", 120) + result1 = self.vm0_testpmd.execute_cmd("port config all txq 17", "testpmd> ", 120) + self.verify("Fail: input txq (17) can't be greater than max_tx_queues (16) of port 0" in result1, "The RX/TX queue number error.") + result2 = self.vm0_testpmd.execute_cmd("port config all rxq 17", "testpmd> ", 120) + self.verify("Fail: input rxq (17) can't be greater than max_rx_queues (16) of port 0" in result2, "The RX/TX queue number error.") + self.vm0_testpmd.execute_cmd('quit', '# ') + time.sleep(5) + self.dut.send_expect("quit", "# ") + time.sleep(5) + else: + guest_cmds1 = [['stop'], + ['port stop all'], + ['port config all txq %d' % (qn + 1)], + ['port config all rxq %d' % (qn + 1)], + ['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: %d Tx queue number: %d" % ((qn + 1), (qn + 1)) in outstring1, "The RX/TX queue number error.") + self.vm0_testpmd.execute_cmd('quit', '# ') + time.sleep(5) + self.dut.send_expect("quit", "# ") + time.sleep(5) + + def test_set_invalid_vf_qn(self): + """ + Test case 2: reserve invalid VF queue number + :return: + """ + for invalid_qn in (0, 3, 5, 6, 7, 9, 11, 15, 17, 25,): + eal_param = '-w %s,queue-num-per-vf=%d --file-prefix=test1 --socket-mem 1024,1024' % (self.pf_pci, invalid_qn) + 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", "# ") + time.sleep(2) + + def test_set_valid_vf_qn_in_testpmd(self): + """ + Test case 3: set valid VF queue number in testpmd command-line options + :return: + """ + host_eal_param = '-w %s --file-prefix=test1 --socket-mem 1024,1024' % self.pf_pci + self.host_testpmd.start_testpmd(VM_CORES_MASK, param='', 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) + for valid_qn in range(1, 17): + self.vm0_testpmd.start_testpmd(VM_CORES_MASK, eal_param=gest_eal_param, param=' --rxq=%d --txq=%d' % (valid_qn, valid_qn)) + 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: %d Tx queue number: %d" % (valid_qn, valid_qn) 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) + if valid_qn == 1: + self.verify("RX-packets: 3" in outstring1 and "TX-packets: 3" in outstring1, "there are some packets lost.") + else: + queue_info = self.get_queue_number_info(outstring1) + self.verify(len(queue_info) != 0, "there are some queues doesn't work.") + self.verify("RX-packets: 3" in outstring1 and "TX-packets: 3" in outstring1,"there are some packets lost.") + self.vm0_testpmd.execute_cmd('quit', '# ') + time.sleep(1) + + 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: + """ + host_eal_param = '-w %s --file-prefix=test1 --socket-mem 1024,1024' % self.pf_pci + self.host_testpmd.start_testpmd(VM_CORES_MASK, param='', 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', '# ') + + 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: + """ + host_eal_param = '-w %s --file-prefix=test1 --socket-mem 1024,1024' % self.pf_pci + self.host_testpmd.start_testpmd(VM_CORES_MASK, param='', 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', '# ') + + def test_set_invalid_vf_qn_in_testpmd(self): + """ + Test case 4: set invalid VF queue number in testpmd command-line options + :return: + """ + host_eal_param = '-w %s --file-prefix=test1 --socket-mem 1024,1024' % self.pf_pci + self.host_testpmd.start_testpmd(VM_CORES_MASK, param='', 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.") + + def test_set_valid_vf_qn_with_testpmd_func_cmd(self): + """ + Test case 5: set valid VF queue number with testpmd function command + :return: + """ + host_eal_param = '-w %s --file-prefix=test1 --socket-mem 1024,1024' % self.pf_pci + self.host_testpmd.start_testpmd(VM_CORES_MASK, param='', 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) + for valid_qn in range(1, 17): + guest_cmds = [['set promisc all off'], + ['set fwd mac'], + ['stop'], + ['port stop all'], + ['port config all txq %d' % valid_qn], + ['port config all rxq %d' % valid_qn], + ['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: %d Tx queue number: %d" % (valid_qn, valid_qn) 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) + if valid_qn == 1: + self.verify("RX-packets: 3" in outstring1 and "TX-packets: 3" in outstring1, "there are some packets lost.") + else: + queue_info = self.get_queue_number_info(outstring1) + self.verify(len(queue_info) != 0, "there are some queues doesn't work.") + self.verify("RX-packets: 3" in outstring1 and "TX-packets: 3" in outstring1, "there are some packets lost.") + self.vm0_testpmd.execute_cmd('quit', '# ') + time.sleep(1) + + 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: + """ + host_eal_param = '-w %s --file-prefix=test1 --socket-mem 1024,1024' % self.pf_pci + self.host_testpmd.start_testpmd(VM_CORES_MASK, param='', 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', '# ') + + 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: + """ + host_eal_param = '-w %s --file-prefix=test1 --socket-mem 1024,1024' % self.pf_pci + self.host_testpmd.start_testpmd(VM_CORES_MASK, param='', 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', '# ') + + 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: + """ + host_eal_param = '-w %s,queue-num-per-vf=2 --file-prefix=test1 --socket-mem 1024,1024' % self.pf_pci + self.host_testpmd.start_testpmd(VM_CORES_MASK, param='', eal_param=host_eal_param) + time.sleep(1) + 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) + print nic_info + 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.") + + def tear_down(self): + self.stop_vm0() + self.dut.send_expect("quit", "# ") + + 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.1