From patchwork Fri Jan 6 14:51:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jiale, SongX" X-Patchwork-Id: 121654 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 96009A00C2; Fri, 6 Jan 2023 07:53:32 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 907274067C; Fri, 6 Jan 2023 07:53:32 +0100 (CET) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mails.dpdk.org (Postfix) with ESMTP id 0A2194021F for ; Fri, 6 Jan 2023 07:53:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672988011; x=1704524011; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=RADC4sV60AAhc8gGQvh/SYZV/KHnnuBN0MjIRsK88LA=; b=VqAVtf/rbA7CzSAdM2TadedA21aOAYjJvp1uCPiK5gGytKZSX4nFiBfq mh2e2UvGJ7LOVtYlGPtOpVXmOiD23Luw84Z2v1mJuk/ZQ7FI8IbDZfEFk ANppl209oIFR7Wj+KCTmKrZYgxWKXaHBdyWdDq8rAqiVFfoITWNNeY9Yn fqStrcT3u7a0c7wK/fIUMM9NdNRSaDCiKpZLjZ/GZf5BkCNFwzwZz74OP xFSbzWRVUlvWJFsLkT7c4cadwc62E7AbQI3T/hLfnQ79h4gNLuw82bkaq MDbrJo85pE0YutgJRzo7Svcws9m4jmufVW7TyaaiyfYqRFruJ/vncXt/s Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10581"; a="408675068" X-IronPort-AV: E=Sophos;i="5.96,304,1665471600"; d="scan'208";a="408675068" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jan 2023 22:53:29 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10581"; a="649244518" X-IronPort-AV: E=Sophos;i="5.96,304,1665471600"; d="scan'208";a="649244518" Received: from unknown (HELO localhost.localdomain) ([10.239.252.20]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jan 2023 22:53:28 -0800 From: Song Jiale To: dts@dpdk.org Cc: Song Jiale Subject: [dts] [PATCH V1] tests/kernelpf_iavf: optimize scripts Date: Fri, 6 Jan 2023 14:51:18 +0000 Message-Id: <20230106145118.344192-1-songx.jiale@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dts-bounces@dpdk.org 1. check the link status and ensure that the port link status is up. 2. add a method to detect the packets captured by tcpdump. 3. the dcf mode ensures that vf port is trusted. Signed-off-by: Song Jiale Acked-by: Lijuan Tu --- tests/TestSuite_kernelpf_iavf.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/tests/TestSuite_kernelpf_iavf.py b/tests/TestSuite_kernelpf_iavf.py index 2cc0ff7d..d8a3f55c 100644 --- a/tests/TestSuite_kernelpf_iavf.py +++ b/tests/TestSuite_kernelpf_iavf.py @@ -109,6 +109,9 @@ class TestKernelpfIavf(TestCase): ) self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 1, driver=driver) self.sriov_vfs_port = self.dut.ports_info[self.used_dut_port]["vfs_port"] + self.dut.send_expect("ifconfig %s up" % self.host_intf, "#") + res = self.dut.is_interface_up(self.host_intf) + self.verify(res, "%s link status is down" % self.host_intf) out = self.dut.send_expect("ethtool %s" % self.host_intf, "#") self.speed = int(re.findall("Speed: (\d*)", out)[0]) // 1000 if self.is_eth_series_nic(800): @@ -130,12 +133,12 @@ class TestKernelpfIavf(TestCase): self.dut.send_expect( "ip link set %s vf 0 trust on" % (self.host_intf), "# " ) + time.sleep(1) try: for port in self.sriov_vfs_port: port.bind_driver(self.vf_driver) - time.sleep(1) vf_popt = {"opt_host": self.sriov_vfs_port[0].pci} # set up VM ENV @@ -168,8 +171,6 @@ class TestKernelpfIavf(TestCase): self.dut.destroy_sriov_vfs_by_port(self.used_dut_port) self.used_dut_port = None - self.bind_nic_driver(self.dut_ports, driver=self.drivername) - self.env_done = False def jumboframes_get_stat(self, portid, rx_tx): @@ -184,23 +185,28 @@ class TestKernelpfIavf(TestCase): else: return None - def send_random_pkt(self, dts, count=1): + def send_random_pkt(self, dts, count=1, allow_miss=False): tgen_ports = [] tx_port = self.tester.get_local_port(self.dut_ports[0]) - rx_port = self.tester.get_local_port(self.dut_ports[1]) + rx_port = self.tester.get_local_port(self.dut_ports[0]) tgen_ports.append((tx_port, rx_port)) src_mac = self.tester.get_mac(tx_port) dst_mac = dts pkt_param = [("ether", {"dst": dst_mac, "src": src_mac})] + self.vm_testpmd.wait_link_status_up(0, timeout=15) result = self.tester.check_random_pkts( - tgen_ports, pktnum=count, allow_miss=False, params=pkt_param + tgen_ports, pktnum=count, allow_miss=allow_miss, params=pkt_param ) return result + self.verify(result, "tcpdump not capture %s packets" % count) def launch_testpmd(self, **kwargs): dcf_flag = kwargs.get("dcf_flag") param = kwargs.get("param") if kwargs.get("param") else "" if dcf_flag == "enable": + self.dut.send_expect( + "ip link set dev %s vf 0 trust on" % self.host_intf, "# " + ) out = self.vm_testpmd.start_testpmd( "all", param=param, @@ -283,7 +289,7 @@ class TestKernelpfIavf(TestCase): out = self.vm_dut.get_session_output() self.verify(self.vf_mac in out, "vf receive pkt fail with current mac") # send packet with wrong mac, vf can not receive and forward packet - self.send_random_pkt(self.wrong_mac, count=1) + self.send_random_pkt(self.wrong_mac, count=1, allow_miss=True) out = self.vm_dut.get_session_output() self.verify(self.wrong_mac not in out, "vf receive pkt with wrong mac") @@ -296,7 +302,6 @@ class TestKernelpfIavf(TestCase): self.send_random_pkt(self.wrong_mac, count=1) out = self.vm_dut.get_session_output() self.verify(self.wrong_mac in out, "vf receive pkt fail with wrong mac") - self.dut.send_expect("ip link set dev %s vf 0 trust off" % self.host_intf, "# ") def test_vf_multicast(self): """ @@ -313,7 +318,7 @@ class TestKernelpfIavf(TestCase): self.send_random_pkt(self.vf_mac, count=1) out = self.vm_dut.get_session_output() self.verify(self.vf_mac in out, "vf receive pkt fail with current mac") - self.send_random_pkt(multicast_mac, count=1) + self.send_random_pkt(multicast_mac, count=1, allow_miss=True) out = self.vm_dut.get_session_output() self.verify(multicast_mac not in out, "vf receive pkt with multicast mac") @@ -650,6 +655,7 @@ class TestKernelpfIavf(TestCase): def get_tcpdump_package(self): time.sleep(1) self.tester.send_expect("killall tcpdump", "#") + time.sleep(1) return self.tester.send_expect( "tcpdump -A -nn -e -vv -r getPackageByTcpdump.cap", "#" ) @@ -910,3 +916,4 @@ class TestKernelpfIavf(TestCase): % (self.host_intf, self.flag, self.default_stats), "# ", ) + self.bind_nic_driver(self.dut_ports, driver=self.drivername)