From: "zhang,yan" <yanx.a.zhang@intel.com>
To: dts@dpdk.org
Cc: lei.a.yao@intel.com, "zhang,yan" <yanx.a.zhang@intel.com>
Subject: [dts] [PATCH V1] tests:add new test suite mdd
Date: Mon, 16 Sep 2019 17:27:22 +0800 [thread overview]
Message-ID: <1568626042-4315-1-git-send-email-yanx.a.zhang@intel.com> (raw)
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
next reply other threads:[~2019-09-16 9:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-16 9:27 zhang,yan [this message]
2019-09-17 1:18 ` Yao, Lei A
2019-09-20 6:31 ` Tu, Lijuan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1568626042-4315-1-git-send-email-yanx.a.zhang@intel.com \
--to=yanx.a.zhang@intel.com \
--cc=dts@dpdk.org \
--cc=lei.a.yao@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).