test suite reviews and discussions
 help / color / Atom feed
* [dts] [PATCH V1] tests:add new test suite mdd
@ 2019-09-16  9:27 zhang,yan
  2019-09-17  1:18 ` Yao, Lei A
  2019-09-20  6:31 ` Tu, Lijuan
  0 siblings, 2 replies; 3+ messages in thread
From: zhang,yan @ 2019-09-16  9:27 UTC (permalink / raw)
  To: dts; +Cc: lei.a.yao, zhang,yan

add new test suite mdd.

Signed-off-by: zhang,yan <yanx.a.zhang@intel.com>
---
 tests/TestSuite_mdd.py | 206 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 206 insertions(+)
 create mode 100644 tests/TestSuite_mdd.py

diff --git a/tests/TestSuite_mdd.py b/tests/TestSuite_mdd.py
new file mode 100644
index 0000000..7baea2c
--- /dev/null
+++ b/tests/TestSuite_mdd.py
@@ -0,0 +1,206 @@
+# <COPYRIGHT_TAG>
+
+import re
+import time
+from packet import Packet
+from virt_common import VM
+from test_case import TestCase
+from pmd_output import PmdOutput
+
+VM_CORES_MASK = 'all'
+send_pks_num = 2000
+
+class TestMDD(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.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.dut.send_expect('dmesg -c', '#')
+
+        self.port_id_0 = 0
+        self.port_id_1 = 1
+
+        self.tx_port = self.tester.get_local_port(self.dut_ports[0])
+        self.rx_port = self.tester.get_local_port(self.dut_ports[1])
+
+    def set_up(self):
+        pass
+
+    def setup_2pf_2vf_1vm_env(self):
+        self.used_dut_port_0 = self.dut_ports[0]
+        self.dut.generate_sriov_vfs_by_port(self.used_dut_port_0, 1, driver='ixgbe')
+        self.sriov_vfs_port_0 = self.dut.ports_info[self.used_dut_port_0]['vfs_port']
+        self.used_dut_port_1 = self.dut_ports[1]
+        self.dut.generate_sriov_vfs_by_port(self.used_dut_port_1, 1, driver='ixgbe')
+        self.sriov_vfs_port_1 = self.dut.ports_info[self.used_dut_port_1]['vfs_port']
+
+        try:
+
+            for port in self.sriov_vfs_port_0:
+                port.bind_driver(self.vf_driver)
+
+            for port in self.sriov_vfs_port_1:
+                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_1[0].pci}
+            # not support driver=igb_uio,because driver is kernel driver
+            # set up VM0 ENV
+            self.vm0 = VM(self.dut, 'vm0', 'mdd')
+            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!")
+
+        except Exception as e:
+            self.destroy_2pf_2vf_1vm_env()
+            raise Exception(e)
+
+    def destroy_2pf_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
+
+        self.dut.virt_exit()
+
+        if getattr(self, 'used_dut_port_0', None) != None:
+            self.dut.destroy_sriov_vfs_by_port(self.used_dut_port_0)
+            port = self.dut.ports_info[self.used_dut_port_0]['port']
+            port.bind_driver()
+            self.used_dut_port_0 = None
+
+        if getattr(self, 'used_dut_port_1', None) != None:
+            self.dut.destroy_sriov_vfs_by_port(self.used_dut_port_1)
+            port = self.dut.ports_info[self.used_dut_port_1]['port']
+            port.bind_driver()
+            self.used_dut_port_1 = None
+
+        for port_id in self.dut_ports:
+            port = self.dut.ports_info[port_id]['port']
+            port.bind_driver()
+
+    def start_testpmd_in_vm(self, txoffload=''):
+        self.vm0_dut_ports = self.vm_dut_0.get_ports('any')
+        self.vm0_testpmd = PmdOutput(self.vm_dut_0)
+
+        self.vm0_testpmd.start_testpmd(VM_CORES_MASK, "--portmask=0x3 --tx-offloads=%s" % txoffload)
+        self.vm0_testpmd.execute_cmd('set fwd mac')
+        self.vm0_testpmd.execute_cmd('set promisc all off')
+        self.vm0_testpmd.execute_cmd('start')
+
+    def send_packets(self):
+
+        tgen_ports = []
+        self.tester_intf = self.tester.get_interface(self.tx_port)
+        tgen_ports.append((self.tx_port, self.rx_port))
+        self.pmd_vf0_mac = self.vm0_testpmd.get_port_mac(self.port_id_0)
+
+        dst_mac = self.pmd_vf0_mac
+        src_mac = self.tester.get_mac(self.tx_port)
+
+        pkt = Packet(pkt_type='UDP', pkt_len=64)
+        pkt.config_layer('ether', {'dst': dst_mac, 'src': src_mac})
+        time.sleep(2)
+        self.vm0_testpmd.execute_cmd('clear port stats all')
+        self.vm0_testpmd.execute_cmd('show port stats all')
+        pkt.send_pkt(tx_port=self.tester_intf, count=send_pks_num)
+        time.sleep(2)
+
+    def result_verify(self, pkt_fwd=True):
+        pmd0_vf0_stats = self.vm0_testpmd.get_pmd_stats(self.port_id_0)
+        pmd0_vf1_stats = self.vm0_testpmd.get_pmd_stats(self.port_id_1)
+        time.sleep(2)
+
+        vf0_rx_cnt = pmd0_vf0_stats['RX-packets']
+        self.verify(vf0_rx_cnt >= send_pks_num, "no packet was received by vm0_VF0")
+
+        vf0_rx_err = pmd0_vf0_stats['RX-errors']
+        self.verify(vf0_rx_err == 0, "vm0_VF0 rx-errors")
+
+        vf1_tx_cnt = pmd0_vf1_stats['TX-packets']
+        if pkt_fwd:
+            self.verify(vf1_tx_cnt == send_pks_num, "Packet forwarding failed")
+        else:
+            self.verify(vf1_tx_cnt == 0, "Packet is forwarded")
+
+    def config_mdd(self, value):
+        self.dut.restore_interfaces()
+        self.dut.send_expect("rmmod ixgbe", "# ", 10)
+        time.sleep(2)
+        count = self.dut.send_expect("./usertools/dpdk-devbind.py -s | grep ixgbe | wc -l", "#")
+        m = [value for i in range(int(count))]
+        mdd = "MDD=" + str(m).replace("[", "").replace("]", "").replace(" ", "")
+        self.dut.send_expect("modprobe ixgbe %s" % mdd, "# ", 10)
+        time.sleep(5)
+        for port_info in self.dut.ports_info:
+            port = port_info['port']
+            intf = port.get_interface_name()
+            self.dut.send_expect("ifconfig %s up" % intf, "# ", 10)
+            time.sleep(2)
+
+    def test_1enable_mdd_dpdk_disable(self):
+        self.config_mdd(1)
+        self.setup_2pf_2vf_1vm_env()
+        self.start_testpmd_in_vm(txoffload='0x1')
+        self.send_packets()
+        self.result_verify(False)
+        dmesg = self.dut.send_expect("dmesg -c |grep 'event'", "# ", 10)
+        self.verify("Malicious event" in dmesg,"mdd error")
+
+    def test_2enable_mdd_dpdk_enable(self):
+        self.config_mdd(1)
+        self.setup_2pf_2vf_1vm_env()
+        self.start_testpmd_in_vm(txoffload='0x0')
+        self.send_packets()
+        self.result_verify(False)
+        dmesg = self.dut.send_expect("dmesg -c |grep 'event'", "# ", 10)
+        self.verify("Malicious event" in dmesg,"mdd error")
+
+    def test_3disable_mdd_dpdk_disable(self):
+        self.config_mdd(0)
+        self.setup_2pf_2vf_1vm_env()
+        self.start_testpmd_in_vm(txoffload='0x1')
+        self.send_packets()
+        self.result_verify(True)
+        dmesg = self.dut.send_expect("dmesg -c |grep 'event'", "# ", 10)
+        self.verify("Malicious event" not in dmesg,"mdd error")
+
+    def test_4disable_mdd_dpdk_enable(self):
+        self.config_mdd(0)
+        self.setup_2pf_2vf_1vm_env()
+        self.start_testpmd_in_vm(txoffload='0x0')
+        self.send_packets()
+        self.result_verify(True)
+        dmesg = self.dut.send_expect("dmesg -c |grep 'event'", "# ", 10)
+        self.verify("Malicious event" not in dmesg,"mdd error")
+
+    def tear_down(self):
+        self.destroy_2pf_2vf_1vm_env()
+
+    def tear_down_all(self):
+        pass
-- 
2.17.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dts] [PATCH V1] tests:add new test suite mdd
  2019-09-16  9:27 [dts] [PATCH V1] tests:add new test suite mdd zhang,yan
@ 2019-09-17  1:18 ` Yao, Lei A
  2019-09-20  6:31 ` Tu, Lijuan
  1 sibling, 0 replies; 3+ messages in thread
From: Yao, Lei A @ 2019-09-17  1:18 UTC (permalink / raw)
  To: Zhang, YanX A, dts



> -----Original Message-----
> From: Zhang, YanX A
> Sent: Monday, September 16, 2019 5:27 PM
> To: dts@dpdk.org
> Cc: Yao, Lei A <lei.a.yao@intel.com>; Zhang, YanX A
> <yanx.a.zhang@intel.com>
> Subject: [dts][PATCH V1] tests:add new test suite mdd
> 
> add new test suite mdd.
> 
> Signed-off-by: zhang,yan <yanx.a.zhang@intel.com>
Acked-by: lei yao<lei.a.yao@intel.com>
> ---
>  tests/TestSuite_mdd.py | 206
> +++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 206 insertions(+)
>  create mode 100644 tests/TestSuite_mdd.py
> 
> diff --git a/tests/TestSuite_mdd.py b/tests/TestSuite_mdd.py new file mode
> 100644 index 0000000..7baea2c
> --- /dev/null
> +++ b/tests/TestSuite_mdd.py
> @@ -0,0 +1,206 @@
> +# <COPYRIGHT_TAG>
> +
> +import re
> +import time
> +from packet import Packet
> +from virt_common import VM
> +from test_case import TestCase
> +from pmd_output import PmdOutput
> +
> +VM_CORES_MASK = 'all'
> +send_pks_num = 2000
> +
> +class TestMDD(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.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.dut.send_expect('dmesg -c', '#')
> +
> +        self.port_id_0 = 0
> +        self.port_id_1 = 1
> +
> +        self.tx_port = self.tester.get_local_port(self.dut_ports[0])
> +        self.rx_port = self.tester.get_local_port(self.dut_ports[1])
> +
> +    def set_up(self):
> +        pass
> +
> +    def setup_2pf_2vf_1vm_env(self):
> +        self.used_dut_port_0 = self.dut_ports[0]
> +        self.dut.generate_sriov_vfs_by_port(self.used_dut_port_0, 1,
> driver='ixgbe')
> +        self.sriov_vfs_port_0 =
> self.dut.ports_info[self.used_dut_port_0]['vfs_port']
> +        self.used_dut_port_1 = self.dut_ports[1]
> +        self.dut.generate_sriov_vfs_by_port(self.used_dut_port_1, 1,
> driver='ixgbe')
> +        self.sriov_vfs_port_1 =
> + self.dut.ports_info[self.used_dut_port_1]['vfs_port']
> +
> +        try:
> +
> +            for port in self.sriov_vfs_port_0:
> +                port.bind_driver(self.vf_driver)
> +
> +            for port in self.sriov_vfs_port_1:
> +                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_1[0].pci}
> +            # not support driver=igb_uio,because driver is kernel driver
> +            # set up VM0 ENV
> +            self.vm0 = VM(self.dut, 'vm0', 'mdd')
> +            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!")
> +
> +        except Exception as e:
> +            self.destroy_2pf_2vf_1vm_env()
> +            raise Exception(e)
> +
> +    def destroy_2pf_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
> +
> +        self.dut.virt_exit()
> +
> +        if getattr(self, 'used_dut_port_0', None) != None:
> +            self.dut.destroy_sriov_vfs_by_port(self.used_dut_port_0)
> +            port = self.dut.ports_info[self.used_dut_port_0]['port']
> +            port.bind_driver()
> +            self.used_dut_port_0 = None
> +
> +        if getattr(self, 'used_dut_port_1', None) != None:
> +            self.dut.destroy_sriov_vfs_by_port(self.used_dut_port_1)
> +            port = self.dut.ports_info[self.used_dut_port_1]['port']
> +            port.bind_driver()
> +            self.used_dut_port_1 = None
> +
> +        for port_id in self.dut_ports:
> +            port = self.dut.ports_info[port_id]['port']
> +            port.bind_driver()
> +
> +    def start_testpmd_in_vm(self, txoffload=''):
> +        self.vm0_dut_ports = self.vm_dut_0.get_ports('any')
> +        self.vm0_testpmd = PmdOutput(self.vm_dut_0)
> +
> +        self.vm0_testpmd.start_testpmd(VM_CORES_MASK, "--portmask=0x3
> --tx-offloads=%s" % txoffload)
> +        self.vm0_testpmd.execute_cmd('set fwd mac')
> +        self.vm0_testpmd.execute_cmd('set promisc all off')
> +        self.vm0_testpmd.execute_cmd('start')
> +
> +    def send_packets(self):
> +
> +        tgen_ports = []
> +        self.tester_intf = self.tester.get_interface(self.tx_port)
> +        tgen_ports.append((self.tx_port, self.rx_port))
> +        self.pmd_vf0_mac =
> + self.vm0_testpmd.get_port_mac(self.port_id_0)
> +
> +        dst_mac = self.pmd_vf0_mac
> +        src_mac = self.tester.get_mac(self.tx_port)
> +
> +        pkt = Packet(pkt_type='UDP', pkt_len=64)
> +        pkt.config_layer('ether', {'dst': dst_mac, 'src': src_mac})
> +        time.sleep(2)
> +        self.vm0_testpmd.execute_cmd('clear port stats all')
> +        self.vm0_testpmd.execute_cmd('show port stats all')
> +        pkt.send_pkt(tx_port=self.tester_intf, count=send_pks_num)
> +        time.sleep(2)
> +
> +    def result_verify(self, pkt_fwd=True):
> +        pmd0_vf0_stats = self.vm0_testpmd.get_pmd_stats(self.port_id_0)
> +        pmd0_vf1_stats = self.vm0_testpmd.get_pmd_stats(self.port_id_1)
> +        time.sleep(2)
> +
> +        vf0_rx_cnt = pmd0_vf0_stats['RX-packets']
> +        self.verify(vf0_rx_cnt >= send_pks_num, "no packet was received
> + by vm0_VF0")
> +
> +        vf0_rx_err = pmd0_vf0_stats['RX-errors']
> +        self.verify(vf0_rx_err == 0, "vm0_VF0 rx-errors")
> +
> +        vf1_tx_cnt = pmd0_vf1_stats['TX-packets']
> +        if pkt_fwd:
> +            self.verify(vf1_tx_cnt == send_pks_num, "Packet forwarding failed")
> +        else:
> +            self.verify(vf1_tx_cnt == 0, "Packet is forwarded")
> +
> +    def config_mdd(self, value):
> +        self.dut.restore_interfaces()
> +        self.dut.send_expect("rmmod ixgbe", "# ", 10)
> +        time.sleep(2)
> +        count = self.dut.send_expect("./usertools/dpdk-devbind.py -s | grep
> ixgbe | wc -l", "#")
> +        m = [value for i in range(int(count))]
> +        mdd = "MDD=" + str(m).replace("[", "").replace("]", "").replace(" ", "")
> +        self.dut.send_expect("modprobe ixgbe %s" % mdd, "# ", 10)
> +        time.sleep(5)
> +        for port_info in self.dut.ports_info:
> +            port = port_info['port']
> +            intf = port.get_interface_name()
> +            self.dut.send_expect("ifconfig %s up" % intf, "# ", 10)
> +            time.sleep(2)
> +
> +    def test_1enable_mdd_dpdk_disable(self):
> +        self.config_mdd(1)
> +        self.setup_2pf_2vf_1vm_env()
> +        self.start_testpmd_in_vm(txoffload='0x1')
> +        self.send_packets()
> +        self.result_verify(False)
> +        dmesg = self.dut.send_expect("dmesg -c |grep 'event'", "# ", 10)
> +        self.verify("Malicious event" in dmesg,"mdd error")
> +
> +    def test_2enable_mdd_dpdk_enable(self):
> +        self.config_mdd(1)
> +        self.setup_2pf_2vf_1vm_env()
> +        self.start_testpmd_in_vm(txoffload='0x0')
> +        self.send_packets()
> +        self.result_verify(False)
> +        dmesg = self.dut.send_expect("dmesg -c |grep 'event'", "# ", 10)
> +        self.verify("Malicious event" in dmesg,"mdd error")
> +
> +    def test_3disable_mdd_dpdk_disable(self):
> +        self.config_mdd(0)
> +        self.setup_2pf_2vf_1vm_env()
> +        self.start_testpmd_in_vm(txoffload='0x1')
> +        self.send_packets()
> +        self.result_verify(True)
> +        dmesg = self.dut.send_expect("dmesg -c |grep 'event'", "# ", 10)
> +        self.verify("Malicious event" not in dmesg,"mdd error")
> +
> +    def test_4disable_mdd_dpdk_enable(self):
> +        self.config_mdd(0)
> +        self.setup_2pf_2vf_1vm_env()
> +        self.start_testpmd_in_vm(txoffload='0x0')
> +        self.send_packets()
> +        self.result_verify(True)
> +        dmesg = self.dut.send_expect("dmesg -c |grep 'event'", "# ", 10)
> +        self.verify("Malicious event" not in dmesg,"mdd error")
> +
> +    def tear_down(self):
> +        self.destroy_2pf_2vf_1vm_env()
> +
> +    def tear_down_all(self):
> +        pass
> --
> 2.17.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dts] [PATCH V1] tests:add new test suite mdd
  2019-09-16  9:27 [dts] [PATCH V1] tests:add new test suite mdd zhang,yan
  2019-09-17  1:18 ` Yao, Lei A
@ 2019-09-20  6:31 ` Tu, Lijuan
  1 sibling, 0 replies; 3+ messages in thread
From: Tu, Lijuan @ 2019-09-20  6:31 UTC (permalink / raw)
  To: Zhang, YanX A, dts; +Cc: Yao, Lei A, Zhang, YanX A

Applied, thanks

> -----Original Message-----
> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of zhang,yan
> Sent: Monday, September 16, 2019 5:27 PM
> To: dts@dpdk.org
> Cc: Yao, Lei A <lei.a.yao@intel.com>; Zhang, YanX A
> <yanx.a.zhang@intel.com>
> Subject: [dts] [PATCH V1] tests:add new test suite mdd
> 
> add new test suite mdd.
> 
> Signed-off-by: zhang,yan <yanx.a.zhang@intel.com>
> ---
>  tests/TestSuite_mdd.py | 206
> +++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 206 insertions(+)
>  create mode 100644 tests/TestSuite_mdd.py
> 
> diff --git a/tests/TestSuite_mdd.py b/tests/TestSuite_mdd.py new file mode
> 100644 index 0000000..7baea2c
> --- /dev/null
> +++ b/tests/TestSuite_mdd.py
> @@ -0,0 +1,206 @@
> +# <COPYRIGHT_TAG>
> +
> +import re
> +import time
> +from packet import Packet
> +from virt_common import VM
> +from test_case import TestCase
> +from pmd_output import PmdOutput
> +
> +VM_CORES_MASK = 'all'
> +send_pks_num = 2000
> +
> +class TestMDD(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.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.dut.send_expect('dmesg -c', '#')
> +
> +        self.port_id_0 = 0
> +        self.port_id_1 = 1
> +
> +        self.tx_port = self.tester.get_local_port(self.dut_ports[0])
> +        self.rx_port = self.tester.get_local_port(self.dut_ports[1])
> +
> +    def set_up(self):
> +        pass
> +
> +    def setup_2pf_2vf_1vm_env(self):
> +        self.used_dut_port_0 = self.dut_ports[0]
> +        self.dut.generate_sriov_vfs_by_port(self.used_dut_port_0, 1,
> driver='ixgbe')
> +        self.sriov_vfs_port_0 =
> self.dut.ports_info[self.used_dut_port_0]['vfs_port']
> +        self.used_dut_port_1 = self.dut_ports[1]
> +        self.dut.generate_sriov_vfs_by_port(self.used_dut_port_1, 1,
> driver='ixgbe')
> +        self.sriov_vfs_port_1 =
> + self.dut.ports_info[self.used_dut_port_1]['vfs_port']
> +
> +        try:
> +
> +            for port in self.sriov_vfs_port_0:
> +                port.bind_driver(self.vf_driver)
> +
> +            for port in self.sriov_vfs_port_1:
> +                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_1[0].pci}
> +            # not support driver=igb_uio,because driver is kernel driver
> +            # set up VM0 ENV
> +            self.vm0 = VM(self.dut, 'vm0', 'mdd')
> +            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!")
> +
> +        except Exception as e:
> +            self.destroy_2pf_2vf_1vm_env()
> +            raise Exception(e)
> +
> +    def destroy_2pf_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
> +
> +        self.dut.virt_exit()
> +
> +        if getattr(self, 'used_dut_port_0', None) != None:
> +            self.dut.destroy_sriov_vfs_by_port(self.used_dut_port_0)
> +            port = self.dut.ports_info[self.used_dut_port_0]['port']
> +            port.bind_driver()
> +            self.used_dut_port_0 = None
> +
> +        if getattr(self, 'used_dut_port_1', None) != None:
> +            self.dut.destroy_sriov_vfs_by_port(self.used_dut_port_1)
> +            port = self.dut.ports_info[self.used_dut_port_1]['port']
> +            port.bind_driver()
> +            self.used_dut_port_1 = None
> +
> +        for port_id in self.dut_ports:
> +            port = self.dut.ports_info[port_id]['port']
> +            port.bind_driver()
> +
> +    def start_testpmd_in_vm(self, txoffload=''):
> +        self.vm0_dut_ports = self.vm_dut_0.get_ports('any')
> +        self.vm0_testpmd = PmdOutput(self.vm_dut_0)
> +
> +        self.vm0_testpmd.start_testpmd(VM_CORES_MASK, "--portmask=0x3 --
> tx-offloads=%s" % txoffload)
> +        self.vm0_testpmd.execute_cmd('set fwd mac')
> +        self.vm0_testpmd.execute_cmd('set promisc all off')
> +        self.vm0_testpmd.execute_cmd('start')
> +
> +    def send_packets(self):
> +
> +        tgen_ports = []
> +        self.tester_intf = self.tester.get_interface(self.tx_port)
> +        tgen_ports.append((self.tx_port, self.rx_port))
> +        self.pmd_vf0_mac =
> + self.vm0_testpmd.get_port_mac(self.port_id_0)
> +
> +        dst_mac = self.pmd_vf0_mac
> +        src_mac = self.tester.get_mac(self.tx_port)
> +
> +        pkt = Packet(pkt_type='UDP', pkt_len=64)
> +        pkt.config_layer('ether', {'dst': dst_mac, 'src': src_mac})
> +        time.sleep(2)
> +        self.vm0_testpmd.execute_cmd('clear port stats all')
> +        self.vm0_testpmd.execute_cmd('show port stats all')
> +        pkt.send_pkt(tx_port=self.tester_intf, count=send_pks_num)
> +        time.sleep(2)
> +
> +    def result_verify(self, pkt_fwd=True):
> +        pmd0_vf0_stats = self.vm0_testpmd.get_pmd_stats(self.port_id_0)
> +        pmd0_vf1_stats = self.vm0_testpmd.get_pmd_stats(self.port_id_1)
> +        time.sleep(2)
> +
> +        vf0_rx_cnt = pmd0_vf0_stats['RX-packets']
> +        self.verify(vf0_rx_cnt >= send_pks_num, "no packet was received
> + by vm0_VF0")
> +
> +        vf0_rx_err = pmd0_vf0_stats['RX-errors']
> +        self.verify(vf0_rx_err == 0, "vm0_VF0 rx-errors")
> +
> +        vf1_tx_cnt = pmd0_vf1_stats['TX-packets']
> +        if pkt_fwd:
> +            self.verify(vf1_tx_cnt == send_pks_num, "Packet forwarding failed")
> +        else:
> +            self.verify(vf1_tx_cnt == 0, "Packet is forwarded")
> +
> +    def config_mdd(self, value):
> +        self.dut.restore_interfaces()
> +        self.dut.send_expect("rmmod ixgbe", "# ", 10)
> +        time.sleep(2)
> +        count = self.dut.send_expect("./usertools/dpdk-devbind.py -s | grep
> ixgbe | wc -l", "#")
> +        m = [value for i in range(int(count))]
> +        mdd = "MDD=" + str(m).replace("[", "").replace("]", "").replace(" ", "")
> +        self.dut.send_expect("modprobe ixgbe %s" % mdd, "# ", 10)
> +        time.sleep(5)
> +        for port_info in self.dut.ports_info:
> +            port = port_info['port']
> +            intf = port.get_interface_name()
> +            self.dut.send_expect("ifconfig %s up" % intf, "# ", 10)
> +            time.sleep(2)
> +
> +    def test_1enable_mdd_dpdk_disable(self):
> +        self.config_mdd(1)
> +        self.setup_2pf_2vf_1vm_env()
> +        self.start_testpmd_in_vm(txoffload='0x1')
> +        self.send_packets()
> +        self.result_verify(False)
> +        dmesg = self.dut.send_expect("dmesg -c |grep 'event'", "# ", 10)
> +        self.verify("Malicious event" in dmesg,"mdd error")
> +
> +    def test_2enable_mdd_dpdk_enable(self):
> +        self.config_mdd(1)
> +        self.setup_2pf_2vf_1vm_env()
> +        self.start_testpmd_in_vm(txoffload='0x0')
> +        self.send_packets()
> +        self.result_verify(False)
> +        dmesg = self.dut.send_expect("dmesg -c |grep 'event'", "# ", 10)
> +        self.verify("Malicious event" in dmesg,"mdd error")
> +
> +    def test_3disable_mdd_dpdk_disable(self):
> +        self.config_mdd(0)
> +        self.setup_2pf_2vf_1vm_env()
> +        self.start_testpmd_in_vm(txoffload='0x1')
> +        self.send_packets()
> +        self.result_verify(True)
> +        dmesg = self.dut.send_expect("dmesg -c |grep 'event'", "# ", 10)
> +        self.verify("Malicious event" not in dmesg,"mdd error")
> +
> +    def test_4disable_mdd_dpdk_enable(self):
> +        self.config_mdd(0)
> +        self.setup_2pf_2vf_1vm_env()
> +        self.start_testpmd_in_vm(txoffload='0x0')
> +        self.send_packets()
> +        self.result_verify(True)
> +        dmesg = self.dut.send_expect("dmesg -c |grep 'event'", "# ", 10)
> +        self.verify("Malicious event" not in dmesg,"mdd error")
> +
> +    def tear_down(self):
> +        self.destroy_2pf_2vf_1vm_env()
> +
> +    def tear_down_all(self):
> +        pass
> --
> 2.17.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-16  9:27 [dts] [PATCH V1] tests:add new test suite mdd zhang,yan
2019-09-17  1:18 ` Yao, Lei A
2019-09-20  6:31 ` Tu, Lijuan

test suite reviews and discussions

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/dts/0 dts/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dts dts/ http://inbox.dpdk.org/dts \
		dts@dpdk.org
	public-inbox-index dts


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dts


AGPL code for this site: git clone https://public-inbox.org/ public-inbox