From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id E724B20F for ; Thu, 18 May 2017 11:22:42 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga104.jf.intel.com with ESMTP; 18 May 2017 02:22:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,358,1491289200"; d="scan'208";a="1131964209" Received: from unknown (HELO dpdk-fedora20.icx.intel.com) ([10.240.176.135]) by orsmga001.jf.intel.com with ESMTP; 18 May 2017 02:22:40 -0700 From: "xu,gang" To: dts@dpdk.org Cc: "xu,gang" Date: Thu, 18 May 2017 17:24:02 +0800 Message-Id: <1495099443-51344-2-git-send-email-gangx.xu@intel.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1495099443-51344-1-git-send-email-gangx.xu@intel.com> References: <1495099443-51344-1-git-send-email-gangx.xu@intel.com> Subject: [dts] [PATCH V1] add test suite pf pass through X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 May 2017 09:22:43 -0000 Signed-off-by: xu,gang --- 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 @@ +# + +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