From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A8D784292F; Thu, 13 Apr 2023 09:27:50 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A499040FAE; Thu, 13 Apr 2023 09:27:50 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id 7C67E40FAE for ; Thu, 13 Apr 2023 09:27:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681370868; x=1712906868; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=OwKybMlzOiBfkOJAKHsxJIpYRYZLK3gBGEVBgLiU2l8=; b=FkBRgj+VYODx9P90EBcOJYXdKm0hpllXMXABTLRVmxSGduUE8Ga9qk+G XLEImhr9p4v2BeEs1J8xFowS9TAGb7PBnRCohIv5XGQZMQx8hfOdmlTJk NG3p6Bs/9F3Zdh9o2KOQoewDjvFzs1WjVX81jn3WOp3ZA/hF0d+f1SxAA NJMvv2XBKdXR5V1Yd87jEyd2ceoUYZfs3Gr0b0zfw8Bs66ni6Hv4OiwZk oQqoIi6bxBF+b0xW1fjfAxfMoJ2A/eLRvcwwwqiLj+0F6RaJ+2vFZ1fF4 6kGp2ujRTH8vpMvTNiJp9UydnOI1d0y2Fe1GI3l2aD1FAvT33klzQbbnw A==; X-IronPort-AV: E=McAfee;i="6600,9927,10678"; a="345902972" X-IronPort-AV: E=Sophos;i="5.98,339,1673942400"; d="scan'208";a="345902972" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Apr 2023 00:27:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10678"; a="682846631" X-IronPort-AV: E=Sophos;i="5.98,339,1673942400"; d="scan'208";a="682846631" Received: from unknown (HELO localhost.localdomain) ([10.239.252.99]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Apr 2023 00:27:46 -0700 From: Lingli Chen To: dts@dpdk.org Cc: yuan.peng@intel.com, Lingli Chen Subject: [dts][PATCH V1 2/2] tests/vf_queue_start_stop: add a new vf case Date: Thu, 13 Apr 2023 02:17:30 -0400 Message-Id: <20230413061730.69065-2-linglix.chen@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230413061730.69065-1-linglix.chen@intel.com> References: <20230413061730.69065-1-linglix.chen@intel.com> 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 add vf_queue_start_stop test script Signed-off-by: Lingli Chen --- tests/TestSuite_vf_queue_start_stop.py | 174 +++++++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 tests/TestSuite_vf_queue_start_stop.py diff --git a/tests/TestSuite_vf_queue_start_stop.py b/tests/TestSuite_vf_queue_start_stop.py new file mode 100644 index 00000000..80c6a83b --- /dev/null +++ b/tests/TestSuite_vf_queue_start_stop.py @@ -0,0 +1,174 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2023 Intel Corporation +# + +""" +DPDK Test suite. + +Test queue start stop Feature + +""" + +import time + +from framework.packet import Packet, strip_pktload +from framework.pmd_output import PmdOutput +from framework.test_case import TestCase + +# +# +# Test class. +# + + +class TestQueueStartStop(TestCase): + # + # + # + # Test cases. + # + + def set_up_all(self): + """ + Run at the start of each test suite. + """ + self.ports = self.dut.get_ports(self.nic) + self.verify(len(self.ports) >= 1, "Insufficient number of ports.") + + self.core_config = "1S/2C/1T" + self.ports_socket = self.dut.get_numa_id(self.ports[0]) + + def set_up(self): + """ + Run before each test case. + """ + # generate vf + self.dut.bind_interfaces_linux(self.kdriver) + self.dut.generate_sriov_vfs_by_port(self.ports[0], 1) + self.vf_port = self.dut.ports_info[self.ports[0]]["vfs_port"][0] + + self.vf_port.bind_driver(driver="vfio-pci") + self.vf_port_pci = self.dut.ports_info[self.ports[0]]["sriov_vfs_pci"][0] + + def check_forwarding(self, dmac, rx_received=True, received=True): + self.send_packet(0, 0, dmac, rx_received, received) + + def send_packet(self, txPort, rxPort, dmac, rx_received, received=True): + """ + Send packages according to parameters. + """ + rxitf = self.tester.get_interface(self.tester.get_local_port(rxPort)) + txitf = self.tester.get_interface(self.tester.get_local_port(txPort)) + + pkt = Packet(pkt_type="UDP", pkt_len=64) + inst = self.tester.tcpdump_sniff_packets(rxitf) + pkt.config_layer("ether", {"dst": dmac}) + pkt.send_pkt(self.tester, tx_port=txitf, count=4) + sniff_pkts = self.tester.load_tcpdump_sniff_packets(inst) + out = self.dut.get_session_output() + if rx_received: + self.verify( + "port 0/queue 0: received 1 packets" in out, + "start queue revice package failed, out = %s" % out, + ) + else: + self.verify( + "port 0/queue 0: received 1 packets" not in out, + "start queue revice package failed, out = %s" % out, + ) + + if received: + res = strip_pktload(sniff_pkts, layer="L4") + self.verify( + "58 58 58 58 58 58 58 58" in res, "receive queue not work as expected" + ) + else: + self.verify(len(sniff_pkts) == 0, "stop queue not work as expected") + + def test_vf_queue_start_stop(self): + """ + vf queue start/stop test + """ + self.pmd_out = PmdOutput(self.dut) + cores = self.dut.get_core_list(self.core_config, socket=self.ports_socket) + # dpdk start + try: + self.pmd_out.start_testpmd( + cores=cores, + eal_param="-a %s --file-prefix=vf" % self.vf_port_pci, + param="--portmask=0x1 --port-topology=loop", + ) + self.dut.send_expect("set fwd mac", "testpmd>") + self.dut.send_expect("set verbose 1", "testpmd>") + self.dut.send_expect("start", "testpmd>") + self.pmd_out.wait_link_status_up("all") + dmac = self.pmd_out.get_port_mac(0) + self.check_forwarding(dmac) + out = self.dut.send_expect("stop", "testpmd>") + self.verify( + "RX-packets: 4" in out, "Forward statistics for RX-packets is error" + ) + self.verify( + "TX-packets: 4" in out, "Forward statistics for TX-packets is error" + ) + except Exception as e: + raise IOError("dpdk start and first forward failure: %s" % e) + + try: + # stop rx queue test + print("test stop rx queue") + self.dut.send_expect("port 0 rxq 0 stop", "testpmd>") + self.dut.send_expect("start", "testpmd>") + self.check_forwarding(dmac, rx_received=False, received=False) + + out = self.dut.send_expect("stop", "testpmd>") + self.verify( + "RX-packets: 0" in out, "Forward statistics for RX-packets is error" + ) + + # stop tx queue test + print("test start rx queue stop tx queue") + self.dut.send_expect("port 0 rxq 0 start", "testpmd>") + self.dut.send_expect("port 0 txq 0 stop", "testpmd>") + self.dut.send_expect("start", "testpmd>") + self.check_forwarding(dmac, rx_received=False, received=False) + out = self.dut.send_expect("stop", "testpmd>") + self.verify( + "TX-packets: 0" in out, "Forward statistics for TX-packets is error" + ) + except Exception as e: + raise IOError("queue stop forward failure: %s" % e) + + try: + # start tx queue test + print("test start rx and tx queue") + self.dut.send_expect("port 0 txq 0 start", "testpmd>") + self.dut.send_expect("start", "testpmd>") + self.check_forwarding(dmac) + out = self.dut.send_expect("stop", "testpmd>") + self.verify( + "RX-packets: 4" in out, + "restart txq Forward statistics for RX-packets is error", + ) + self.verify( + "TX-packets: 4" in out, + "restart txq Forward statistics for TX-packets is error", + ) + except Exception as e: + raise IOError("queue start forward failure: %s" % e) + + def tear_down(self): + """ + Run after each test case. + """ + try: + self.dut.send_expect("quit", "#") + except: + print("Failed to quit testpmd") + + def tear_down_all(self): + """ + Run after each test suite. + """ + self.dut.kill_all() + self.dut.bind_interfaces_linux(self.drivername) -- 2.17.1