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 26A78A0096 for ; Wed, 8 May 2019 11:32:25 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CA667378B; Wed, 8 May 2019 11:32:24 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 6E3DA3772 for ; Wed, 8 May 2019 11:32:22 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 May 2019 02:32:21 -0700 X-ExtLoop1: 1 Received: from unknown (HELO localhost.localdomain.sh.intel.com) ([10.240.176.135]) by orsmga002.jf.intel.com with ESMTP; 08 May 2019 02:32:20 -0700 From: "xiao,qimai" To: dts@dpdk.org Cc: "xiao,qimai" Date: Wed, 8 May 2019 17:36:42 +0800 Message-Id: <1557308202-34139-1-git-send-email-qimaix.xiao@intel.com> X-Mailer: git-send-email 1.9.3 Subject: [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" add tests/TestSuite_runtime_vf_queue_number_kernel.py 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 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 = 'all' + + +class TestRuntimeVfQueueNumberKernel(TestCase): + supported_vf_driver = ['pci-stub', 'vfio-pci'] + max_queue = 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 = self.dut.get_ports(self.nic) + self.verify(len(self.dut_ports) > 1, "Insufficient ports") + self.vm0 = None + + # 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', '#') + + self.setup_1pf_2vf_1vm_env_flag = 0 + self.setup_1pf_2vf_1vm_env(driver='') + self.vm0_dut_ports = self.vm_dut_0.get_ports('any') + self.portMask = utils.create_mask([self.vm0_dut_ports[0]]) + self.vm_dut_0.vm_pci0 = self.vm_dut_0.ports_info[0]['pci'] + + def set_up(self): + pass + def setup_1pf_2vf_1vm_env(self,driver="default"): + + self.used_dut_port = self.dut_ports[0] + self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 2,driver=driver) + self.sriov_vfs_port = 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 = {'opt_host': self.sriov_vfs_port[0].pci} + vf1_prop = {'opt_host': self.sriov_vfs_port[1].pci} + if driver == 'igb_uio': + # start testpmd without the two VFs on the host + self.host_testpmd = PmdOutput(self.dut) + eal_param = '-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=eal_param) + # set up VM0 ENV + self.vm0 = VM(self.dut, 'vm0', 'runtime_vf_queue_number_kernel') + self.vm0.set_vm_device(driver=self.vf_assign_method, **vf0_prop) + self.vm0.set_vm_device(driver=self.vf_assign_method, **vf1_prop) + self.vm_dut_0 = self.vm0.start() + if self.vm_dut_0 is None: + raise Exception("Set up VM0 ENV failed!") + + self.setup_1pf_2vf_1vm_env_flag = 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 = None + self.vm0_dut_ports = None + # destroy vm0 + self.vm0.stop() + self.dut.virt_exit() + self.vm0 = None + if getattr(self, 'host_testpmd', None): + self.host_testpmd.execute_cmd('quit', '# ') + self.host_testpmd = None + + if getattr(self, 'used_dut_port', None) != 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 + + for port_id in self.dut_ports: + port = self.dut.ports_info[port_id]['port'] + port.bind_driver() + + self.setup_1pf_2vf_1vm_env_flag = 0 + + def send_packet2different_queue(self, dts, src, iface, count): + self.tester.scapy_foreground() + for i in range(count): + pkt = 'sendp([Ether(dst="%s", src="%s")/IP(src="10.0.0.1",dst="192.168.13.%d")/("test"*10)],iface="%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 == 1: + self.verify('port 0/queue 0: received 1 packets' in out, "queue %s can not receive pkt" % (nr_queue - 1)) + else: + for i in range(nr_queue): + if i < 10: + i = ' ' + str(i) + self.verify('Queue=%s' % i in out2, "queue %s can not receive pkt" % i) + self.verify(pkts_num == count, + 'Received incorrect pkts number! send %d pkts,received %d pkts' % (count, pkts_num)) + self.verify('RX-total: %d' % (count + misc) in out2 and 'TX-total: %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 = random.randint(2, 15) + queue_nums = [1, random_queue, self.max_queue] + for nr_queue in queue_nums: + self.vm0_testpmd = PmdOutput(self.vm_dut_0) + eal_param = '-w %(vf0)s' % {'vf0': self.vm_dut_0.vm_pci0} + tx_port = self.tester.get_local_port(self.dut_ports[0]) + tester_mac = self.tester.get_mac(tx_port) + iface = self.tester.get_interface(tx_port) + count = nr_queue * 20 + times = 3 + + # try tree times to make sure testpmd launched normally + while times > 0: + out = self.vm0_testpmd.start_testpmd("all", "--rss-ip --txq=%s --rxq=%s" % (nr_queue, nr_queue), eal_param=eal_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 -= 1 + time.sleep(3) + else: + times = 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 = self.vm0_testpmd.execute_cmd('start') + vf0_mac = 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 = self.vm0_testpmd.get_output() + out2 = self.vm0_testpmd.execute_cmd('stop') + pkts_num = out.count("src=%s - dst=%s"%(tester_mac.upper(),vf0_mac.upper())) + misc = out.count("dst=FF: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 = [0, 17] + for i in invalid_queue_num: + self.vm0_testpmd = PmdOutput(self.vm_dut_0) + self.vm_dut_0.session_secondary = self.vm_dut_0.new_session() + out = self.vm_dut_0.session_secondary.send_expect( + './x86_64-native-linuxapp-gcc/app/testpmd -c 0xf -n 1 -w %s -- -i --txq=%s --rxq=%s' % ( + self.vm_dut_0.vm_pci0, i, i), '# ', 40) + if i == 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 >=0, to be fixed... + self.verify('txq 17 invalid - must be >= 0 && <= 16' in out, "queue number is too big") + + def test_set_valid_vf_queue_num_with_function(self): + random_queue = random.randint(2, 15) + queue_nums = [1, random_queue, self.max_queue] + self.vm0_testpmd = PmdOutput(self.vm_dut_0) + eal_param = '-w %(vf0)s' % {'vf0': self.vm_dut_0.vm_pci0} + tx_port = self.tester.get_local_port(self.dut_ports[0]) + tester_mac = self.tester.get_mac(tx_port) + iface = self.tester.get_interface(tx_port) + for nr_queue in queue_nums: + times = 3 + count = nr_queue * 20 + + #try tree times to make sure testpmd launched normally + while times > 0: + self.vm0_testpmd = PmdOutput(self.vm_dut_0) + out = self.vm0_testpmd.start_testpmd("all", eal_param=eal_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 = 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 -= 1 + time.sleep(3) + self.vm0_testpmd.quit() + else: + times = 0 + + self.vm0_testpmd.execute_cmd("clear port stats all") + out = self.vm0_testpmd.execute_cmd("start") + self.logger.info(out) + vf0_mac = 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 = self.vm0_testpmd.get_output() + out2 = self.vm0_testpmd.execute_cmd('stop') + pkts_num=out.count("src=%s - dst=%s"%(tester_mac.upper(),vf0_mac.upper())) + misc = out.count("dst=FF: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 = [0, 17] + self.vm0_testpmd = PmdOutput(self.vm_dut_0) + eal_param = '-w %(vf0)s' % {'vf0': self.vm_dut_0.vm_pci0} + self.vm0_testpmd.start_testpmd("all", eal_param=eal_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 == 0: + out1 = self.vm0_testpmd.execute_cmd("port config all rxq %s" % i) + # when set rxq or txq to 0 alone, dpdk didn't show warning, 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 = self.vm0_testpmd.execute_cmd("port config all txq %s" % i) + self.verify('Either rx or tx queues should be non zero' in out, "queue number can't be zero") + else: + out = self.vm0_testpmd.execute_cmd("port config all rxq %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 == 1: + self.destroy_1pf_2vf_1vm_env() -- 2.17.1