[dts] [PATCH V2] add case tests/TestSuite_runtime_vf_queue_number_maxinum to dts
Chen, BoX C
box.c.chen at intel.com
Mon Apr 8 12:20:02 CEST 2019
Tested-by: Chen, BoX C <box.c.chen at intel.com>
> -----Original Message-----
> From: dts [mailto:dts-bounces at dpdk.org] On Behalf Of xiao,qimai
> Sent: April 8, 2019 16:55
> To: dts at dpdk.org
> Cc: Xiao, QimaiX <qimaix.xiao at intel.com>
> Subject: [dts] [PATCH V2] add case
> tests/TestSuite_runtime_vf_queue_number_maxinum to dts
>
> Signed-off-by: xiao,qimai <qimaix.xiao at intel.com>
> ---
> ...stSuite_runtime_vf_queue_number_maxinum.py | 280 ++++++++++++++++++
> 1 file changed, 280 insertions(+)
> create mode 100644 tests/TestSuite_runtime_vf_queue_number_maxinum.py
>
> diff --git a/tests/TestSuite_runtime_vf_queue_number_maxinum.py
> b/tests/TestSuite_runtime_vf_queue_number_maxinum.py
> new file mode 100644
> index 0000000..78d02d8
> --- /dev/null
> +++ b/tests/TestSuite_runtime_vf_queue_number_maxinum.py
> @@ -0,0 +1,280 @@
> +# 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 #
> +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_Maxinum
> +
> +"""
> +
> +import re
> +import time
> +import random
> +
> +import utils
> +from pmd_output import PmdOutput
> +from test_case import TestCase
> +from virt_common import VM
> +
> +class TestRuntime_Vf_Queue_Number_Maxinum(TestCase):
> + supported_vf_driver = ['pci-stub', 'vfio-pci']
> +
> + def set_up_all(self):
> + """
> + Run at the start of each test suite.
> + Run time Queue Number Prerequisites
> + """
> + self.verify(self.nic in ["fortville_eagle", "fortville_spirit",
> + "fortville_spirit_single",
> + "fortpark_TLV"], "NIC Unsupported: " + str(self.nic))
> +
> + # Based on h/w type, choose how many ports to use
> + self.dut_ports = self.dut.get_ports(self.nic)
> + self.dut_ports_num = len(self.dut_ports)
> + # Verify that enough ports are available
> + self.verify(self.dut_ports_num >= 1, "Insufficient ports")
> +
> + self.vm0 = None
> + localPort = self.tester.get_local_port(self.dut_ports[0])
> + self.tester_intf = self.tester.get_interface(localPort)
> + self.tester_mac = self.tester.get_mac(localPort)
> + self.pf_interface = self.dut.ports_info[self.dut_ports[0]]['intf']
> + self.pf_mac = self.dut.get_mac_address(0)
> + self.pf_pci0 = self.dut.ports_info[self.dut_ports[0]]['pci']
> + self.pf_pci1 = self.dut.ports_info[self.dut_ports[1]]['pci']
> +
> + # 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.used_dut_port = self.dut_ports[0]
> + if self.dut_ports_num==2:
> + vfs_num = 64
> + else:
> + vfs_num = 32
> + self.dut.generate_sriov_vfs_by_port(self.used_dut_port, vfs_num,
> driver='default')
> + self.sriov_vfs_port = self.dut.ports_info[self.used_dut_port]['vfs_port']
> + self.vfs_ports = random.sample(self.sriov_vfs_port,2)
> + try:
> + for port in self.vfs_ports:
> + port.bind_driver(self.vf_driver)
> + time.sleep(1)
> + except Exception as e:
> + raise Exception(e)
> +
> +
> + def set_up(self):
> +
> + """
> + Run before each test case.
> + """
> + self.setup_1pf_2vf_1vm_env_flag = 0
> +
> + def setup_1pf_2vf_1vm_env(self, driver='default'):
> +
> + try:
> + vf0_prop = {'opt_host': self.vfs_ports[0].pci}
> + vf1_prop = {'opt_host': self.vfs_ports[1].pci}
> +
> + # start testpmd without the two VFs on the host
> + self.host_testpmd = PmdOutput(self.dut)
> + eal_param = '-w %(pf0)s,queue-num-per-vf=8 --file-prefix=test1 --
> socket-mem 1024,1024' % {'pf0': self.pf_pci0}
> + out = self.host_testpmd.start_testpmd("Default", eal_param=eal_param)
> + print(out)
> + time.sleep(2)
> +
> + # set up VM0 ENV
> + self.vm0 = VM(self.dut, 'vm0', 'runtime_vf_queue_number_maxinum')
> + 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
> + if getattr(self, 'vm0_testpmd', None):
> + self.vm0_testpmd.execute_cmd('stop')
> + self.vm0_testpmd.execute_cmd('quit', '# ')
> + self.vm0_testpmd = None
> + self.vm0_dut_ports = None
> + #destroy vm0
> + self.vm0.stop()
> + 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 test_set_VF_max_queue_number_with_max_VFs_on_one_PF_port(self):
> +
> + self.host_testpmd2 = PmdOutput(self.dut)
> + eal_param = '-w %(pf0)s,queue-num-per-vf=16 --file-prefix=test1 --socket-
> mem 1024,1024' % {'pf0': self.pf_pci0}
> + out = self.host_testpmd2.start_testpmd("Default", eal_param=eal_param)
> + print(out)
> + if self.dut_ports_num==4:
> + verify_info = 'i40e_pf_parameter_init(): Failed to allocate 577 queues,
> which exceeds the hardware maximum 384'
> + else:
> + verify_info = 'i40e_pf_parameter_init(): Failed to allocate 1089 queues,
> which exceeds the hardware maximum 768'
> + self.verify(verify_info in out,"start testpmd get wrong info: %s"%out)
> + self.host_testpmd2.execute_cmd("port stop all")
> + time.sleep(3)
> + self.host_testpmd2.execute_cmd('quit', '# ')
> + time.sleep(3)
> + self.host_testpmd2=None
> +
> + 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_pci0 = self.vm_dut_0.ports_info[0]['pci']
> + self.vm_pci1 = self.vm_dut_0.ports_info[1]['pci']
> + time.sleep(2)
> +
> + self.vm0_testpmd = PmdOutput(self.vm_dut_0)
> + eal_param3 = '-w %(vf0)s --file-prefix=test4' % {
> + 'vf0': self.vm_pci0}
> + out = self.vm0_testpmd.start_testpmd("all", "--txq=8 --rxq=8",
> eal_param=eal_param3)
> + print(out)
> + self.vf0_mac =
> self.vm0_testpmd.get_port_mac(self.vm0_dut_ports[0]).lower()
> + self.vm0_testpmd.execute_cmd("set verbose 1")
> + out = self.vm0_testpmd.execute_cmd("show port info all")
> + print(out)
> + self.verify("Current number of TX queues: 8" in out and "Current number of
> RX queues: 8" in out,"set tx or rx queue fail:%s"%out)
> + out = self.vm0_testpmd.execute_cmd('start')
> + print(out)
> + self.verify("port 0: RX queue number: 8 Tx queue number: 8" in out,"start
> failed: %s"%out)
> + pkts_num=256
> + self.send_packet2different_queue(self.vf0_mac, self.tester_mac,
> self.tester_intf, pkts_num)
> + out = self.vm0_testpmd.get_output()
> + out2 = self.vm0_testpmd.execute_cmd('stop')
> + misc = out.count("dst=FF:FF:FF:FF:FF:FF")
> + print("get %d misc packages " % misc)
> + rx_pkts=out.count("src=%s -
> dst=%s"%(self.tester_mac.upper(),self.vf0_mac.upper()))
> + for i in range(8):
> + if i<10:
> + i=' '+str(i)
> + self.verify('RX Port= 0/Queue=%s' % i in out2 and 'TX Port= 0/Queue=%s' %
> i in out2, "queue %s can not rx or tx pkts" % i)
> + self.verify(pkts_num==rx_pkts,'Received incorrect pkts number! send %d
> pkts,received %d pkts'%(pkts_num, rx_pkts))
> + self.verify('RX-total: %d' % (rx_pkts+misc) in out2 and 'TX-total: %d' %
> (rx_pkts+misc) in out2,
> + "statistic shows rx or tx pkts number: %d incorrect" %
> (rx_pkts+misc))
> + self.vm0_testpmd.execute_cmd('port stop all')
> + time.sleep(5)
> + self.vm0_testpmd.execute_cmd('quit', '# ')
> + time.sleep(3)
> +
> + self.vm0_testpmd2 = PmdOutput(self.vm_dut_0)
> + eal_param4 = '-w %(vf1)s --file-prefix=test5' % {
> + 'vf1': self.vm_pci1}
> + out2 = self.vm0_testpmd2.start_testpmd("all", "--txq=6 --rxq=6",
> eal_param=eal_param4)
> + self.vf1_mac =
> self.vm0_testpmd2.get_port_mac(self.vm0_dut_ports[0]).lower()
> + print(out2)
> + self.vm0_testpmd2.execute_cmd("set verbose 1")
> + out = self.vm0_testpmd2.execute_cmd("show port info all")
> + print(out)
> + self.verify("Current number of TX queues: 6" in out and "Current number of
> RX queues: 6" in out,"set tx or rx queue fail:%s"%out)
> + out = self.vm0_testpmd2.execute_cmd('start')
> + print(out)
> + self.verify("port 0: RX queue number: 6 Tx queue number: 6" in out,"start
> failed: %s"%out)
> + out = self.vm0_testpmd2.execute_cmd('stop')
> + self.vm0_testpmd2.execute_cmd('port stop all')
> + self.vm0_testpmd2.execute_cmd('port config all rxq 8')
> + self.vm0_testpmd2.execute_cmd('port config all txq 7')
> + out=self.vm0_testpmd2.execute_cmd('port start all')
> + print(out)
> + out = self.vm0_testpmd2.execute_cmd("show port info all")
> + print(out)
> + self.verify("Current number of TX queues: 7" in out and "Current number of
> RX queues: 8" in out,"set tx or rx queue fail:%s"%out)
> + pkts_num = 256
> + out = self.vm0_testpmd2.execute_cmd('start')
> + print(out)
> + self.send_packet2different_queue(self.vf1_mac, self.tester_mac,
> self.tester_intf, pkts_num)
> + out = self.vm0_testpmd2.get_output()
> + out2 = self.vm0_testpmd2.execute_cmd('stop')
> + misc2 = out.count("dst=FF:FF:FF:FF:FF:FF")
> + print("get %d misc packages " % misc)
> + rx_pkts=out.count("src=%s -
> + dst=%s"%(self.tester_mac.upper(),self.vf1_mac.upper()))
> +
> + for i in range(7):
> + if i<10:
> + i=' '+str(i)
> + self.verify('RX Port= 0/Queue=%s' % i in out2 and 'TX
> + Port= 0/Queue=%s' % i in out2, "queue %s can not rx or tx pkts" % i)
> +
> + self.verify('RX-total: %d' % (pkts_num+misc2) in out2,"statistic shows rx or
> tx pkts number: %d incorrect" % (pkts_num+misc2))
> + self.vm0_testpmd2.execute_cmd('port stop all')
> + time.sleep(5)
> +
> +
> + def tear_down(self):
> +
> + if self.setup_1pf_2vf_1vm_env_flag == 1:
> + self.destroy_1pf_2vf_1vm_env()
> +
> + def tear_down_all(self):
> +
> + if getattr(self, 'vm0', None):
> + self.vm0.stop()
> +
> + self.dut.virt_exit()
> + for port_id in self.dut_ports:
> + self.dut.destroy_sriov_vfs_by_port(port_id)
> --
> 2.19.1
More information about the dts
mailing list