From patchwork Mon Sep 19 16:16:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yaqi Tang X-Patchwork-Id: 116437 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 28314A00C3; Mon, 19 Sep 2022 18:16:24 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 22CBD410EE; Mon, 19 Sep 2022 18:16:24 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id BF40D40141 for ; Mon, 19 Sep 2022 18:16:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663604182; x=1695140182; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gOlkk9W/c6KtBlWwbBNp68gsFK0sQkqHqIb0zVbeB2o=; b=MnfJl0CDBFgSYjGaYp6ZkIYi/HIlniMeNr8K/tFp8rwUDAuuDV/CZqIT TWDa63dRRQWmYNR37A9bdERdmXLQJFkQSJaKvK0jTHd4FHeOq2BKg72pi bflojXQz3t1My0P69NqxvLf1QRXqt5lZngtzYdwG12mHWXY3G8WvCkIGr CAQ7s4ZXJfi2oMVe6mClbym5sQgyNtJCXHgd+/nIwI+jLjinzrIASQk1C kCRHmS8fxUPvF8174Knd16nPHod3PvEH3kKdOwBxorhHlefYHSPAoAuwH NBTzGulbAEErxK6Nr1PElSsTQhfx2UfFBnPx3uB0q3Z2z7JctkKp0Tnr+ w==; X-IronPort-AV: E=McAfee;i="6500,9779,10475"; a="286488498" X-IronPort-AV: E=Sophos;i="5.93,328,1654585200"; d="scan'208";a="286488498" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Sep 2022 09:16:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,328,1654585200"; d="scan'208";a="649208687" Received: from dpdk-yaqi.sh.intel.com ([10.67.119.213]) by orsmga008.jf.intel.com with ESMTP; 19 Sep 2022 09:16:20 -0700 From: Yaqi Tang To: dts@dpdk.org Cc: Yaqi Tang Subject: [dts][PATCH V4 3/3] tests/ice_iavf_rx_timestamp: ice iavf support rx timestamp Date: Mon, 19 Sep 2022 16:16:09 +0000 Message-Id: <20220919161609.269836-4-yaqi.tang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220919161609.269836-1-yaqi.tang@intel.com> References: <20220919161609.269836-1-yaqi.tang@intel.com> 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 The IAVF driver is able to enable rx timestamp offload. Signed-off-by: Yaqi Tang Reviewed-by: Lijuan Tu --- tests/TestSuite_ice_iavf_rx_timestamp.py | 221 +++++++++++++++++++++++ 1 file changed, 221 insertions(+) create mode 100644 tests/TestSuite_ice_iavf_rx_timestamp.py diff --git a/tests/TestSuite_ice_iavf_rx_timestamp.py b/tests/TestSuite_ice_iavf_rx_timestamp.py new file mode 100644 index 00000000..56463215 --- /dev/null +++ b/tests/TestSuite_ice_iavf_rx_timestamp.py @@ -0,0 +1,221 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2022 Intel Corporation +# + +import copy +import os +import re +import time + +from framework.packet import Packet +from framework.pmd_output import PmdOutput +from framework.test_case import TestCase +from framework.utils import GREEN, RED + +tv_packets_basic = { + "tv_mac": 'Ether(dst="00:11:22:33:44:55")/("X"*480)', + "tv_mac_ipv4": 'Ether(dst="00:11:22:33:44:55")/IP(src="192.168.0.2",dst="192.168.0.3")/("X"*480)', + "tv_mac_ipv6": 'Ether(dst="00:11:22:33:44:55")/IPv6(src="2001::2", dst="2001::3")/("X"*480)', + "tv_mac_ipv4_udp": 'Ether(dst="00:11:22:33:44:55")/IP(src="192.168.0.2", dst="192.168.0.3")/UDP(sport=1026, dport=1027)/("X"*480)', + "tv_mac_ipv6_udp": 'Ether(dst="00:11:22:33:44:55")/IPv6(src="2001::2", dst="2001::3")/UDP(sport=1026, dport=1027)/("X"*480)', + "tv_mac_ipv4_tcp": 'Ether(dst="00:11:22:33:44:55")/IP(src="192.168.0.2", dst="192.168.0.3")/TCP(sport=1026, dport=1027)/("X"*480)', + "tv_mac_ipv6_tcp": 'Ether(dst="00:11:22:33:44:55")/IPv6(src="2001::2", dst="2001::3")/TCP(sport=1026, dport=1027)/("X"*480)', + "tv_mac_ipv4_sctp": 'Ether(dst="00:11:22:33:44:55")/IP(src="192.168.0.2", dst="192.168.0.3")/SCTP(sport=1026, dport=1027)/("X"*480)', + "tv_mac_ipv6_sctp": 'Ether(dst="00:11:22:33:44:55")/IPv6(src="2001::2", dst="2001::3")/SCTP(sport=1026, dport=1027)/("X"*480)', +} + +command_line_option_with_timestamp = { + "port_id": 0, + "test": [ + { + "send_packet": tv_packets_basic["tv_mac"], + "action": {"check_timestamp": "ether"}, + }, + { + "send_packet": tv_packets_basic["tv_mac_ipv4"], + "action": {"check_timestamp": "ipv4"}, + }, + { + "send_packet": tv_packets_basic["tv_mac_ipv6"], + "action": {"check_timestamp": "ipv6"}, + }, + { + "send_packet": tv_packets_basic["tv_mac_ipv4_udp"], + "action": {"check_timestamp": "ipv4-udp"}, + }, + { + "send_packet": tv_packets_basic["tv_mac_ipv6_udp"], + "action": {"check_timestamp": "ipv6-udp"}, + }, + { + "send_packet": tv_packets_basic["tv_mac_ipv4_tcp"], + "action": {"check_timestamp": "ipv4-tcp"}, + }, + { + "send_packet": tv_packets_basic["tv_mac_ipv6_tcp"], + "action": {"check_timestamp": "ipv6-tcp"}, + }, + { + "send_packet": tv_packets_basic["tv_mac_ipv4_sctp"], + "action": {"check_timestamp": "ipv4-sctp"}, + }, + { + "send_packet": tv_packets_basic["tv_mac_ipv6_sctp"], + "action": {"check_timestamp": "ipv6-sctp"}, + }, + ], +} + + +class IAVFTimestampConfigureTest(TestCase): + def set_up_all(self): + """ + Run at the start of each test suite. + Generic filter Prerequistites + """ + self.verify( + self.nic in ["ICE_25G-E810C_SFP", "ICE_100G-E810C_QSFP"], + "%s nic not support vf timestamp" % self.nic, + ) + self.dut_ports = self.dut.get_ports(self.nic) + self.ports_socket = self.dut.get_numa_id(self.dut_ports[0]) + # Verify that enough ports are available + self.verify(len(self.dut_ports) >= 1, "Insufficient ports") + self.tester_port0 = self.tester.get_local_port(self.dut_ports[0]) + self.tester_iface0 = self.tester.get_interface(self.tester_port0) + self.pkt = Packet() + self.pmdout = PmdOutput(self.dut) + + self.vf_driver = self.get_suite_cfg()["vf_driver"] + if self.vf_driver is None: + self.vf_driver = "vfio-pci" + self.pf0_intf = self.dut.ports_info[self.dut_ports[0]]["intf"] + self.create_vf() + + def set_up(self): + """ + Run before each test case. + """ + pass + + def launch_testpmd(self, line_option=""): + """ + start testpmd + """ + # Prepare testpmd EAL and parameters + self.pmdout.start_testpmd( + param=line_option, + eal_param=f"-a {self.vf0_pci}", + socket=self.ports_socket, + ) + # test link status + res = self.pmdout.wait_link_status_up("all", timeout=15) + self.verify(res is True, "there have port link is down") + self.pmdout.execute_cmd("set fwd rxonly") + self.pmdout.execute_cmd("set verbose 1") + self.pmdout.execute_cmd("start") + + def create_vf(self): + self.dut.bind_interfaces_linux("ice") + self.dut.generate_sriov_vfs_by_port(self.dut_ports[0], 1) + self.sriov_vfs_port = self.dut.ports_info[self.dut_ports[0]]["vfs_port"] + self.dut.send_expect("ifconfig %s up" % self.pf0_intf, "# ") + self.dut.send_expect( + "ip link set %s vf 0 mac 00:11:22:33:44:55" % self.pf0_intf, "#" + ) + self.vf0_pci = self.sriov_vfs_port[0].pci + try: + for port in self.sriov_vfs_port: + port.bind_driver(self.vf_driver) + except Exception as e: + self.destroy_vf() + raise Exception(e) + + def destroy_vf(self): + """ + destroy the setup VFs + """ + self.dut.destroy_sriov_vfs_by_port(self.dut_ports[0]) + + def check_timestamp_increment(self, out): + timestamps = self.get_timestamp(out) + if len(timestamps) == 0: + error_msg = "There is no timestamp value" + self.logger.error(error_msg) + self.error_msgs.append(error_msg) + else: + for i in range(len(timestamps) - 1): + if timestamps[i + 1] <= timestamps[i]: + error_msg = "The timestamp values should be increment" + self.logger.error(error_msg) + self.error_msgs.append(error_msg) + + def check_no_timestamp(self, out): + timestamps = self.get_timestamp(out) + if len(timestamps) != 0: + error_msg = "The timestamp value should be empty" + self.logger.error(error_msg) + self.error_msgs.append(error_msg) + + def send_pkt_get_output(self, pkts, port_id=0, count=3): + self.logger.info("----------send packet-------------") + self.logger.info("{}".format(pkts)) + self.pkt.update_pkt(pkts) + self.pkt.send_pkt(crb=self.tester, tx_port=self.tester_iface0, count=count) + out = self.pmdout.get_output(timeout=1) + pkt_pattern = ( + "port\s%d/queue\s\d+:\sreceived\s(\d+)\spackets.+?\n.*length=\d{2,}\s" + % port_id + ) + reveived_data = re.findall(pkt_pattern, out) + reveived_pkts = sum(map(int, [i[0] for i in reveived_data])) + return out + + def get_timestamp(self, out): + timestamp_pat = ".*timestamp\s(\w+)" + timestamp_infos = re.findall(timestamp_pat, out, re.M) + timestamp_infos = list(map(int, timestamp_infos)) + self.logger.info("timestamp_infos: {}".format(timestamp_infos)) + return timestamp_infos + + def handle_timestamp_case(self, case_info, enable_timestamp=True): + self.error_msgs = [] + out = "" + # handle tests + tests = case_info["test"] + for test in tests: + if "send_packet" in test: + out = self.send_pkt_get_output(test["send_packet"]) + if "action" in test: + if enable_timestamp: + self.check_timestamp_increment(out) + else: + self.check_no_timestamp(out) + self.verify(not self.error_msgs, "some cases failed") + + def test_iavf_without_timestamp(self): + self.launch_testpmd(line_option="--rxq=16 --txq=16") + self.handle_timestamp_case( + command_line_option_with_timestamp, enable_timestamp=False + ) + + def test_iavf_single_queue_with_timestamp(self): + self.launch_testpmd(line_option="--enable-rx-timestamp") + self.handle_timestamp_case(command_line_option_with_timestamp) + + def test_iavf_multi_queues_with_timestamp(self): + self.launch_testpmd(line_option="--rxq=16 --txq=16 --enable-rx-timestamp") + self.handle_timestamp_case(command_line_option_with_timestamp) + + def tear_down(self): + """ + Run after each test case. + """ + self.pmdout.execute_cmd("quit", "#") + + def tear_down_all(self): + """ + Run after each test suite. + """ + self.destroy_vf() + self.dut.kill_all()