test suite reviews and discussions
 help / color / mirror / Atom feed
From: "xu,gang" <gangx.xu@intel.com>
To: dts@dpdk.org
Cc: "xu,gang" <gangx.xu@intel.com>
Subject: [dts] [PATCH V1] add test suite pf pass through
Date: Thu, 18 May 2017 17:24:02 +0800	[thread overview]
Message-ID: <1495099443-51344-2-git-send-email-gangx.xu@intel.com> (raw)
In-Reply-To: <1495099443-51344-1-git-send-email-gangx.xu@intel.com>

Signed-off-by: xu,gang <gangx.xu@intel.com>
---
 tests/TestSuite_pf_pass_through.py | 121 +++++++++++++++++++++++++++++++++++++
 1 file changed, 121 insertions(+)
 create mode 100644 tests/TestSuite_pf_pass_through.py

diff --git a/tests/TestSuite_pf_pass_through.py b/tests/TestSuite_pf_pass_through.py
new file mode 100644
index 0000000..8885744
--- /dev/null
+++ b/tests/TestSuite_pf_pass_through.py
@@ -0,0 +1,121 @@
+# <COPYRIGHT_TAG>
+
+import re
+import time
+
+from qemu_kvm import QEMUKvm
+from test_case import TestCase
+from pmd_output import PmdOutput
+
+VM_CORES_MASK = 'all'
+
+
+class TestPfPassThrough(TestCase):
+
+    def set_up_all(self):
+        '''
+        Run at the start of each test suite.
+        '''
+        self.dut_ports = self.dut.get_ports(self.nic)
+        self.verify(len(self.dut_ports) > 1, "Insufficient ports")
+        self.vm0 = None
+        self.env_done = False
+        self.dut.send_expect("modprobe vfio", "#", 5)
+        self.dut.send_expect("modprobe vfio-pci", "#", 5)
+
+    def set_up(self):
+        '''
+        Run before each test case.
+        '''
+        self.setup_vm_env()
+
+    def setup_vm_env(self, driver='default'):
+
+        # Start vm with the two PFs on the DUT
+        self.used_dut_port_0 = self.dut_ports[0]
+        port = self.dut.ports_info[self.used_dut_port_0]['port']
+        port.bind_driver('vfio-pci')
+
+        self.used_dut_port_1 = self.dut_ports[1]
+        port = self.dut.ports_info[self.used_dut_port_1]['port']
+        port.bind_driver('vfio-pci')
+
+        try:
+
+            time.sleep(1)
+            self.pci0 = self.dut.ports_info[self.used_dut_port_0]['pci']
+            self.pci1 = self.dut.ports_info[self.used_dut_port_1]['pci']
+            vf0_prop = {'opt_host': self.pci0}
+            vf1_prop = {'opt_host': self.pci1}
+
+            # Set up VM0 ENV
+            self.vm0 = QEMUKvm(self.dut, 'vm0', 'pf_pass_through')
+            self.vm0.set_vm_device(driver='vfio-pci', **vf0_prop)
+            self.vm0.set_vm_device(driver='vfio-pci', **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_vm_env()
+            raise Exception(e)
+
+        self.env_done = True
+
+    def destroy_vm_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()
+        time.sleep(3)
+
+        for port_id in self.dut_ports:
+            port = self.dut.ports_info[port_id]['port']
+            port.bind_driver()
+
+        self.env_done = False
+
+    def test_pf_pass_through(self):
+
+        self.verify(
+            self.kdriver in ["ixgbe", "i40e"], "%s NIC not support pf pass-through" % self.kdriver)
+        # Start testpmd in VM
+        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)
+        self.vm0_testpmd.execute_cmd('set fwd mac')
+        self.vm0_testpmd.execute_cmd('start')
+
+        tgen_ports = []
+        tx_port = self.tester.get_local_port(self.dut_ports[0])
+        rx_port = self.tester.get_local_port(self.dut_ports[1])
+        tgen_ports.append((tx_port, rx_port))
+
+        dst_mac = self.vm0_testpmd.get_port_mac(0)
+        src_mac = self.tester.get_mac(tx_port)
+        pkt_param = [("ether", {'dst': dst_mac, 'src': src_mac})]
+
+        result = self.tester.check_random_pkts(
+            tgen_ports, allow_miss=False, params=pkt_param)
+        self.verify(result != False, "VF0 failed to forward packets to VF1")
+
+    def tear_down(self):
+        """
+        Run after each test case.
+        """
+        pass
+
+    def tear_down_all(self):
+        """
+        Run after each test suite.
+        """
+        self.destroy_vm_env()
+        pass
-- 
1.9.3

  reply	other threads:[~2017-05-18  9:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-18  9:24 [dts] [PATCH V1] add VM vfio_pci driver options xu,gang
2017-05-18  9:24 ` xu,gang [this message]
2017-05-18  9:24 ` [dts] [PATCH V1] add test plan pass through xu,gang
2017-06-09 12:44   ` Liu, Yong
2017-05-22 10:07 ` [dts] [PATCH V1] add VM vfio_pci driver options Liu, Yong

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=1495099443-51344-2-git-send-email-gangx.xu@intel.com \
    --to=gangx.xu@intel.com \
    --cc=dts@dpdk.org \
    /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).