test suite reviews and discussions
 help / color / mirror / Atom feed
From: Yinan <yinan.wang@intel.com>
To: dts@dpdk.org
Cc: Wang Yinan <yinan.wang@intel.com>
Subject: [dts] [PATCH v1] tests/vf_interrupt_pmd: add vf multi-queues interrupt test for i40e driver
Date: Thu, 20 Feb 2020 21:49:40 +0000	[thread overview]
Message-ID: <20200220214940.110575-1-yinan.wang@intel.com> (raw)

From: Wang Yinan <yinan.wang@intel.com>

Signed-off-by: Wang Yinan <yinan.wang@intel.com>
---
 tests/TestSuite_vf_interrupt_pmd.py | 184 +++++++++++++++++++++-------
 1 file changed, 143 insertions(+), 41 deletions(-)

diff --git a/tests/TestSuite_vf_interrupt_pmd.py b/tests/TestSuite_vf_interrupt_pmd.py
index ae9abd6..21b24a1 100644
--- a/tests/TestSuite_vf_interrupt_pmd.py
+++ b/tests/TestSuite_vf_interrupt_pmd.py
@@ -38,8 +38,8 @@ Test vf_interrupt_pmd.
 import utils
 import time
 import re
-
-from qemu_kvm import QEMUKvm
+import pdb
+from virt_common import VM
 from test_case import TestCase
 from packet import Packet
 
@@ -55,16 +55,13 @@ class TestVfInterruptPmd(TestCase):
         self.env_done = False
         cores = "1S/4C/1T"
         self.number_of_ports = 1
-
         self.dut_ports = self.dut.get_ports()
         self.ports_socket = self.dut.get_numa_id(self.dut_ports[0])
         ports = []
         for port in range(self.number_of_ports):
             ports.append(self.dut_ports[port])
-
         self.core_list = self.dut.get_core_list(cores, socket=self.ports_socket)
         self.core_user = self.core_list[0]
-
         self.port_mask = utils.create_mask(ports)
         self.core_mask_user = utils.create_mask(self.core_list[0:1])
 
@@ -74,17 +71,14 @@ class TestVfInterruptPmd(TestCase):
         self.rx_intf_0 = self.tester.get_interface(testport_0)
         self.tester_mac = self.tester.get_mac(testport_0)
         self.vf0_mac = "00:12:34:56:78:01"
+        self.vf_mac = "00:12:34:56:78:02"
         self.mac_port_0 = self.dut.get_mac_address(self.dut_ports[0])
-
-        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.queues = 1
+        self.vf_driver = 'vfio-pci'
+        self.vf_assign_method = 'vfio-pci'
+        """
+        If self.vf_driver == 'pci-stub', self.vf_assign_method = 'pci-assign'
+        """
 
     def set_up(self):
         """
@@ -97,8 +91,8 @@ class TestVfInterruptPmd(TestCase):
         Change the DPDK source code and recompile
         """
         use_dut.send_expect(
-                "sed -i -e '/DEV_RX_OFFLOAD_CHECKSUM,/d' ./examples/l3fwd-power/main.c", "#", 10)
-
+                "sed -i -e '/DEV_RX_OFFLOAD_CHECKSUM,/d' \
+                ./examples/l3fwd-power/main.c", "#", 10)
         out = use_dut.send_expect("make -C examples/l3fwd-power", "#")
         self.verify("Error" not in out, "compilation error")
 
@@ -109,7 +103,16 @@ class TestVfInterruptPmd(TestCase):
         pkt = Packet(pkt_type='UDP')
         pkt.config_layer('ether', {'dst': mac, 'src': self.tester_mac})
         pkt.send_pkt(self.tester, tx_port=testinterface)
+        self.out2 = use_dut.get_session_output(timeout=2)
 
+    def send_packet_loop(self, mac, testinterface, use_dut, ip_addr):
+        """
+        Send a packet and verify
+        """
+        pkt = Packet(pkt_type='UDP')
+        pkt.config_layer('ether', {'dst': mac, 'src': self.tester_mac})
+        pkt.config_layer('ipv4', {'dst': '2.1.1.5', 'src': '2.1.1.%s' % ip_addr})
+        pkt.send_pkt(self.tester, tx_port=testinterface)
         self.out2 = use_dut.get_session_output(timeout=2)
 
     def set_NIC_link(self):
@@ -118,7 +121,6 @@ class TestVfInterruptPmd(TestCase):
         """
         self.used_dut_port = self.dut_ports[0]
         self.host_intf = self.dut.ports_info[self.used_dut_port]['intf']
-
         self.dut.send_expect("ifconfig %s up" % self.host_intf, '#', 3)
 
     def begin_l3fwd_power(self, use_dut):
@@ -138,13 +140,34 @@ class TestVfInterruptPmd(TestCase):
         except Exception as e:
             self.logger.error("ERROR: Failed to launch  l3fwd-power sample: %s" % str(e))
 
+    def begin_l3fwd_power_multi_queues(self, use_dut):
+        """
+        begin l3fwd-power
+        """
+        config_info =""
+        for queue in range(self.queues):
+            if config_info != "":
+                config_info += ','
+            config_info += '(0,%d,%d)' % (queue, queue)
+        cmd_vhost_net = "./examples/l3fwd-power/build/l3fwd-power -l 0-%d -n 4 -- -P -p 0x1" % \
+                        queue + " --config='%s'" % config_info
+        try:
+            self.logger.info("Launch l3fwd_sample sample:")
+            self.out = use_dut.send_expect(cmd_vhost_net, "L3FWD_POWER", 60)
+            self.logger.info(self.out)
+            if "Error" in self.out:
+                raise Exception("Launch l3fwd-power sample failed")
+            else:
+                self.logger.info("Launch l3fwd-power sample finished")
+        except Exception as e:
+            self.logger.error("ERROR: Failed to launch l3fwd-power sample: %s" % str(e))
+
     def setup_vm_env(self, driver='default'):
         """
         Start a vm using a virtual NIC
         """
         if self.env_done:
             return
-
         self.used_dut_port_0 = self.dut_ports[0]
         self.dut.generate_sriov_vfs_by_port(
             self.used_dut_port_0, 1, driver=driver)
@@ -160,7 +183,7 @@ class TestVfInterruptPmd(TestCase):
             port.bind_driver(self.vf_driver)
 
         vf0_prop_0 = {'opt_host': self.sriov_vfs_port_0[0].pci}
-        self.vm0 = QEMUKvm(self.dut, 'vm0', 'vf_interrupt_pmd')
+        self.vm0 = VM(self.dut, 'vm0', 'vf_interrupt_pmd')
         self.vm0.set_vm_device(driver=self.vf_assign_method, **vf0_prop_0)
         try:
             self.vm0_dut = self.vm0.start()
@@ -200,7 +223,6 @@ class TestVfInterruptPmd(TestCase):
         self.vm0_dut.send_expect("modprobe -r vfio", '#', 3)
         self.vm0_dut.send_expect("modprobe vfio enable_unsafe_noiommu_mode=1", '#', 3)
         self.vm0_dut.send_expect("modprobe vfio-pci", '#', 3)
-
         self.vm0_dut.bind_interfaces_linux(driver="vfio-pci")
 
     def test_nic_interrupt_VM_vfio_pci(self):
@@ -209,9 +231,9 @@ class TestVfInterruptPmd(TestCase):
         """
         self.setup_vm_env()
         self.prepare_l3fwd_power(self.vm0_dut)
-
+        self.vm0_dut.send_expect("ip link set %s vf 0 mac %s" %
+                                 (self.host_intf0, self.vf0_mac), "# ")
         self.VF0_bind_vfio_pci()
-
         cores = "1S/1C/1T"
         core_list = self.vm0_dut.get_core_list(cores)
         core_user = core_list[0]
@@ -220,42 +242,40 @@ class TestVfInterruptPmd(TestCase):
         cmd = self.path + \
               " -c %s -n %d -- -P  -p 0x01 --config='(0,0,%s)'" % (
                   core_mask_user, self.vm0_dut.get_memory_channels(), core_user)
+
         self.vm0_dut.send_expect(cmd, "L3FWD_POWER", 60)
-        time.sleep(1)
         self.send_packet(self.vf0_mac, self.rx_intf_0, self.vm0_dut)
         self.destroy_vm_env()
-
         self.verify(
-            "lcore %s is waked up from rx interrupt on port 0" % core_user in self.out2, "Wake up failed")
+            "lcore %s is waked up from rx interrupt on port 0" %
+            core_user in self.out2, "Wake up failed")
         self.verify(
-            "lcore %s sleeps until interrupt triggers" % core_user in self.out2, "lcore %s not sleeps" % core_user)
+            "lcore %s sleeps until interrupt triggers" %
+            core_user in self.out2, "lcore %s not sleeps" % core_user)
 
     def test_nic_interrupt_VF_vfio_pci(self, driver='default'):
         """
         Check Interrupt for VF with vfio driver
         """
         self.prepare_l3fwd_power(self.dut)
-
         self.set_NIC_link()
-
         # generate VF and bind to vfio-pci
         self.used_dut_port_0 = self.dut_ports[0]
         self.dut.generate_sriov_vfs_by_port(self.used_dut_port_0, 1, driver=driver)
         self.sriov_vfs_port_0 = self.dut.ports_info[self.used_dut_port_0]['vfs_port']
-
         for port in self.sriov_vfs_port_0:
             port.bind_driver('vfio-pci')
-
+        # set vf mac
+        self.dut.send_expect("ip link set %s vf 0 mac %s" %
+                                 (self.host_intf, self.vf_mac), "# ")
         self.begin_l3fwd_power(self.dut)
-        pattern = re.compile(r"(([A-Fa-f0-9]{2}:){5}[A-Fa-f0-9]{2})")
-        self.vf_mac = pattern.search(self.out).group()
-
         self.send_packet(self.vf_mac, self.rx_intf_0, self.dut)
-
         self.verify(
-            "lcore %s is waked up from rx interrupt on port 0" % self.core_user in self.out2, "Wake up failed")
+            "lcore %s is waked up from rx interrupt on port 0" %
+            self.core_user in self.out2,"Wake up failed")
         self.verify(
-            "lcore %s sleeps until interrupt triggers" % self.core_user in self.out2, "lcore %s not sleeps" % self.core_user)
+            "lcore %s sleeps until interrupt triggers" %
+            self.core_user in self.out2,"lcore %s not sleeps" % self.core_user)
 
     def test_nic_interrupt_PF_vfio_pci(self):
         """
@@ -270,9 +290,11 @@ class TestVfInterruptPmd(TestCase):
         self.send_packet(self.mac_port_0, self.rx_intf_0, self.dut)
 
         self.verify(
-            "lcore %s is waked up from rx interrupt on port 0" % self.core_user in self.out2, "Wake up failed")
+            "lcore %s is waked up from rx interrupt on port 0" %
+            self.core_user in self.out2, "Wake up failed")
         self.verify(
-            "lcore %s sleeps until interrupt triggers" % self.core_user in self.out2, "lcore %s not sleeps" % self.core_user)
+            "lcore %s sleeps until interrupt triggers" %
+            self.core_user in self.out2, "lcore %s not sleeps" % self.core_user)
 
     def test_nic_interrupt_PF_igb_uio(self):
         """
@@ -287,9 +309,89 @@ class TestVfInterruptPmd(TestCase):
         self.send_packet(self.mac_port_0, self.rx_intf_0, self.dut)
 
         self.verify(
-            "lcore %s is waked up from rx interrupt on port 0" % self.core_user in self.out2, "Wake up failed")
+            "lcore %s is waked up from rx interrupt on port 0" % self.core_user in
+            self.out2, "Wake up failed")
         self.verify(
-            "lcore %s sleeps until interrupt triggers" % self.core_user in self.out2, "lcore %s not sleeps" % self.core_user)
+            "lcore %s sleeps until interrupt triggers" % self.core_user in self.out2,
+            "lcore %s not sleeps" % self.core_user)
+
+    def test_nic_multi_queues_interrupt_VF_vfio_pci(self, driver='default'):
+        """
+        Check Interrupt for VF with vfio driver, need test with i40e driver
+        """
+        self.verify(self.nic in ("fortville_spirit"), "the port can not run this suite")
+        self.queues = 4
+        self.prepare_l3fwd_power(self.dut)
+        self.set_NIC_link()
+        # generate VF and bind to vfio-pci
+        self.used_dut_port_0 = self.dut_ports[0]
+        self.dut.generate_sriov_vfs_by_port(self.used_dut_port_0, 1, driver=driver)
+        self.sriov_vfs_port_0 = self.dut.ports_info[self.used_dut_port_0]['vfs_port']
+        for port in self.sriov_vfs_port_0:
+            port.bind_driver('vfio-pci')
+        # set vf mac
+        self.dut.send_expect("ip link set %s vf 0 mac %s" % (self.host_intf, self.vf_mac),
+                             "# ")
+        self.begin_l3fwd_power_multi_queues(self.dut)
+        stroutput = ""
+        for ip in range(2,10):
+            self.send_packet_loop(self.vf_mac, self.rx_intf_0, self.dut, ip)
+            stroutput = stroutput + self.out2
+        for queue in range(self.queues):
+            self.verify(
+                "lcore %d is waked up from rx interrupt on port 0" \
+                % queue in stroutput, "Wake up failed")
+            self.verify(
+                "lcore %d sleeps until interrupt triggers" % queue in stroutput,
+                "lcore %d not sleeps" % queue)
+
+    def test_nic_multi_queues_interrupt_VM_vfio_pci(self):
+        """
+        Check for interrupts within the VM, need test with i40e driver
+        """
+        self.verify(self.nic in ("fortville_spirit"), "the port can not run this suite")
+        self.setup_vm_env()
+        self.vm0_dut.send_expect("ip link set %s vf 0 mac %s" %
+                                 (self.host_intf0, self.vf0_mac), "# ")
+        self.queues = 4
+        self.prepare_l3fwd_power(self.vm0_dut)
+        self.VF0_bind_vfio_pci()
+        cores = "1S/4C/1T"
+        core_list = self.vm0_dut.get_core_list(cores)
+        core_user = core_list[0]
+        core_mask_user = utils.create_mask(core_list)
+        config_info =""
+        for queue in range(self.queues):
+            if config_info != "":
+                config_info += ','
+            config_info += '(0,%d,%d)' % (queue, queue)
+        cmd = "./examples/l3fwd-power/build/l3fwd-power -c %s -n 4 -- -P -p 0x1" \
+              % core_mask_user + \
+        " --config='%s'" % config_info
+        self.vm0_dut.send_expect(cmd, "L3FWD_POWER", 60)
+        time.sleep(1)
+        try:
+            self.logger.info("Launch l3fwd_sample sample:")
+            self.out = self.vm0_dut.send_expect(cmd, "L3FWD_POWER", 60)
+            if "Error" in self.out:
+                raise Exception("Launch l3fwd-power sample failed")
+            else:
+                self.logger.info("Launch l3fwd-power sample finished")
+        except Exception as e:
+            self.logger.error("ERROR: Failed to launch l3fwd-power sample: %s"
+                              % str(e))
+        stroutput = ""
+        for ip in range(2, 10):
+            self.send_packet_loop(self.vf0_mac, self.rx_intf_0, self.vm0_dut, ip)
+            stroutput = stroutput + self.out2
+        self.destroy_vm_env()
+        for queue in range(self.queues):
+            self.verify(
+                "lcore %d is waked up from rx interrupt on port 0"
+                % queue in stroutput, "Wake up failed")
+            self.verify(
+                "lcore %d sleeps until interrupt triggers"
+                % queue in stroutput, "lcore %d not sleeps" % queue)
 
     def tear_down(self):
         """
-- 
2.17.1


             reply	other threads:[~2020-02-21  4:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-20 21:49 Yinan [this message]
2020-02-21  7:57 ` 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=20200220214940.110575-1-yinan.wang@intel.com \
    --to=yinan.wang@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).