[dts] [PATCH V1] add vfio-pci driver cases to vf_packet_rxtx test suite
Liu, Yong
yong.liu at intel.com
Thu Sep 28 04:54:03 CEST 2017
Yuwei,
One comment below.
> -----Original Message-----
> From: dts [mailto:dts-bounces at dpdk.org] On Behalf Of Yuwei Zhang
> Sent: Tuesday, September 26, 2017 11:24 PM
> To: dts at dpdk.org
> Cc: Zhang, Yuwei1 <yuwei1.zhang at intel.com>
> Subject: [dts] [PATCH V1] add vfio-pci driver cases to vf_packet_rxtx test
> suite
>
> Signed-off-by: Yuwei Zhang <yuwei1.zhang at intel.com>
> ---
> conf/global_suite_conf.cfg | 3 +++
> framework/config.py | 28 ++++++++++++++++++++++++++++
> tests/TestSuite_vf_packet_rxtx.py | 31 +++++++++++++++++++++++--------
> 3 files changed, 54 insertions(+), 8 deletions(-)
> create mode 100644 conf/global_suite_conf.cfg
>
> diff --git a/conf/global_suite_conf.cfg b/conf/global_suite_conf.cfg
> new file mode 100644
> index 0000000..2d15c03
> --- /dev/null
> +++ b/conf/global_suite_conf.cfg
> @@ -0,0 +1,3 @@
> +# global suite configuration
> +[vf]
> +driver=pci-stub
> \ No newline at end of file
> diff --git a/framework/config.py b/framework/config.py
> index 9e514a7..411c653 100644
> --- a/framework/config.py
> +++ b/framework/config.py
> @@ -45,6 +45,7 @@ CRBCONF = "%s/crbs.cfg" % CONFIG_ROOT_PATH
> VIRTCONF = "%s/virt_global.cfg" % CONFIG_ROOT_PATH
> IXIACONF = "%s/ixia.cfg" % CONFIG_ROOT_PATH
> SUITECONF_SAMPLE = "%s/suite_sample.cfg" % CONFIG_ROOT_PATH
> +GLOBAL_SUITE_CONF = "%s/global_suite_conf.cfg" % CONFIG_ROOT_PATH
>
>
> class UserConf():
> @@ -87,6 +88,33 @@ class UserConf():
> paramDict[key] = value
> return paramDict
>
> +class GlobalSuiteConf(UserConf):
> +
> + def __init__(self):
> + try:
> + self.global_suite_conf = UserConf(GLOBAL_SUITE_CONF)
> + except ConfigParseException:
> + self.global_suite_conf = None
> +
> + def load_config(self, section_name, param_name):
> + if self.global_suite_conf is None:
> + return self.global_suite_cfg
> +
> + try:
> + section_conf =
> self.global_suite_conf.load_section(section_name)
> + except:
> + print "FAILED FIND SECTION[%s] CONFIG!!!" % section_name
> + return section_conf
> +
> + if section_conf is None:
> + return section_conf
> +
> + conf = dict(section_conf)
> + if param_name in conf.keys():
> + return conf[param_name]
> + else:
> + return None
> +
>
> class SuiteConf(UserConf):
> def __init__(self, suite_name=""):
> diff --git a/tests/TestSuite_vf_packet_rxtx.py
> b/tests/TestSuite_vf_packet_rxtx.py
> index 50451f6..5ff1a2b 100644
> --- a/tests/TestSuite_vf_packet_rxtx.py
> +++ b/tests/TestSuite_vf_packet_rxtx.py
> @@ -6,6 +6,7 @@ import time
> from qemu_kvm import QEMUKvm
> from test_case import TestCase
> from pmd_output import PmdOutput
> +from config import GlobalSuiteConf
>
> VM_CORES_MASK = 'all'
>
> @@ -18,6 +19,18 @@ class TestVfPacketRxtx(TestCase):
> self.verify(len(self.dut_ports) > 1, "Insufficient ports")
> self.vm0 = None
> self.vm1 = None
> + supported_vf_driver = ['vfio-pci', 'pci-stub']
> +
> + global_suite_conf = GlobalSuiteConf()
> + self.vf_driver = global_suite_conf.load_config('vf', 'driver')
Do not need to load global configuration in each suite, you can combine this action into SuiteConf class.
> + if self.vf_driver == None:
> + self.vf_driver = 'pci-stub'
> + self.verify(self.vf_driver in supported_vf_driver, 'Unsupported
> VF Driver!')
> + if self.vf_driver == 'vfio-pci':
> + self.vf_assign_method = 'vfio-pci'
> + self.dut.send_expect('modprobe vfio-pci', '#')
> + else:
> + self.vf_assign_method = 'pci-assign'
>
> def set_up(self):
>
> @@ -37,10 +50,10 @@ class TestVfPacketRxtx(TestCase):
> try:
>
> for port in self.sriov_vfs_port_0:
> - port.bind_driver('pci-stub')
> + port.bind_driver(self.vf_driver)
>
> for port in self.sriov_vfs_port_1:
> - port.bind_driver('pci-stub')
> + port.bind_driver(self.vf_driver)
>
> time.sleep(1)
> vf0_prop = {'opt_host': self.sriov_vfs_port_0[0].pci}
> @@ -59,8 +72,8 @@ class TestVfPacketRxtx(TestCase):
>
> # set up VM0 ENV
> self.vm0 = QEMUKvm(self.dut, 'vm0', 'vf_packet_rxtx')
> - self.vm0.set_vm_device(driver='pci-assign', **vf0_prop)
> - self.vm0.set_vm_device(driver='pci-assign', **vf1_prop)
> + 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!")
> @@ -144,6 +157,7 @@ class TestVfPacketRxtx(TestCase):
>
> self.packet_rx_tx(driver='')
>
> + """
> ######2. test case for dpdk pf and dpdk vf 2pf_2vf_1vm scenario packet rx
> tx.
> def test_dpdk_2pf_2vf_1vm(self):
>
> @@ -159,7 +173,7 @@ class TestVfPacketRxtx(TestCase):
>
> for port in self.sriov_vfs_port:
> print port.pci
> - port.bind_driver('pci-stub')
> + port.bind_driver(self.vf_driver)
>
> time.sleep(1)
> vf0_prop = {'opt_host': self.sriov_vfs_port[0].pci}
> @@ -181,14 +195,14 @@ class TestVfPacketRxtx(TestCase):
>
> # set up VM0 ENV
> self.vm0 = QEMUKvm(self.dut, 'vm0', 'vf_packet_rxtx')
> - self.vm0.set_vm_device(driver='pci-assign', **vf0_prop)
> - self.vm0.set_vm_device(driver='pci-assign', **vf1_prop)
> + 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!")
> # set up VM1 ENV
> self.vm1 = QEMUKvm(self.dut, 'vm1', 'vf_packet_rxtx')
> - self.vm1.set_vm_device(driver='pci-assign', **vf2_prop)
> + self.vm1.set_vm_device(driver=self.vf_assign_method,
> **vf2_prop)
> self.vm_dut_1 = self.vm1.start()
> if self.vm_dut_1 is None:
> raise Exception("Set up VM1 ENV failed!")
> @@ -291,6 +305,7 @@ class TestVfPacketRxtx(TestCase):
> self.verify(vf1_tx_err == 0, "vm0_VF0 tx-errors")
>
> self.verify(vf0_rx_cnt == vf1_tx_cnt, "vm0_VF0 failed to forward
> packets to vm0_VF1 when reset vm1_VF0 frequently")
> + """
>
> def tear_down(self):
>
> --
> 2.14.1.windows.1
More information about the dts
mailing list