From patchwork Sun Jul 16 13:44:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yaqi Tang X-Patchwork-Id: 129555 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 81AC742E8C; Sun, 16 Jul 2023 15:45:12 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7C36140DFD; Sun, 16 Jul 2023 15:45:12 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id 8F6EC4013F for ; Sun, 16 Jul 2023 15:45:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689515110; x=1721051110; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=r8c2GivBy3q/lSayqU7dOVxL8SelwNOPZIrvo1n5DTg=; b=AfqzrDe604khsl2XMOt6TFapSKppfdvmulLt3fV+xobQfgo7QTYHeKJf W3Q62lJ9t/KGwdgrtz/zEV1zjJ9e5ONrIpiZw4vLQx+YwK6gjRkG45tO8 /E7zCsTPVGrmw96ySX7IXzmafDhS6MpTbtrluMAUy5QTHkisJTMgVskcN cQyOgeG/7XI0NfBf//AlPJeV8gr+m59qA18eEuuuVMPfTglfEBYXtUak4 G+8H0RLXwhErVcC5wwi4DOr89KAlzuZKSgYGBmAbIuO0E5xRfy3XKGTei uHEscslz7Hh0l3ANGHBw3XojNeogUxIP9S+f/uUMtJ56jO1mlyQmD1l5A A==; X-IronPort-AV: E=McAfee;i="6600,9927,10773"; a="368400774" X-IronPort-AV: E=Sophos;i="6.01,210,1684825200"; d="scan'208";a="368400774" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jul 2023 06:45:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10773"; a="1053618695" X-IronPort-AV: E=Sophos;i="6.01,210,1684825200"; d="scan'208";a="1053618695" Received: from dpdk-yaqi.sh.intel.com ([10.67.118.189]) by fmsmga005.fm.intel.com with ESMTP; 16 Jul 2023 06:45:08 -0700 From: Yaqi Tang To: dts@dpdk.org Cc: Yaqi Tang Subject: [PATCH V1 1/3] test_plans/index: add new test plan for mev cpfl support hairpin queue Date: Sun, 16 Jul 2023 13:44:14 +0000 Message-Id: <20230716134416.3220611-2-yaqi.tang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230716134416.3220611-1-yaqi.tang@intel.com> References: <20230716134416.3220611-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 Add new test plan for mev cpfl support hairpin queue. Signed-off-by: Yaqi Tang --- test_plans/index.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/test_plans/index.rst b/test_plans/index.rst index 2ac4850d..3e379ab1 100644 --- a/test_plans/index.rst +++ b/test_plans/index.rst @@ -116,6 +116,7 @@ The following are the test plans for the DPDK DTS automated test system. loopback_vhost_async_perf_dsa_test_plan mac_filter_test_plan macsec_for_ixgbe_test_plan + mev_cpfl_hairpin_queue_test_plan mtu_update_test_plan multiple_pthread_test_plan ntb_test_plan From patchwork Sun Jul 16 13:44:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yaqi Tang X-Patchwork-Id: 129556 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 A4B7542E8C; Sun, 16 Jul 2023 15:45:13 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9B9B742BAC; Sun, 16 Jul 2023 15:45:13 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id 9E8E24013F for ; Sun, 16 Jul 2023 15:45:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689515111; x=1721051111; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aMXU+pmqQBfInUiEblzGrYCq3DHuuyZj9FBycb7FO8M=; b=Bwg0z2o1e5WTtxmraAfLSUjrA5ilm2xgqB8pDdPsRbKrBJRl+rQ7gyFb fRG9I/8vfax+IB8aQqk9PYP4Vd1Xs6gP6tOVYm+Fk9QzKw7hOz7l09+w7 /nMPys2D2l78B9+W1DqUdOlf6LzqJpuLrEiQgcR/R/O0ujh+np5fYOK3h Ak47Gvtuhn/kl7rMFTdKbCHZrdVSqZciNy0jekmBl+HjD4DZ1egKktwPp nqDV/eXC0+k7qt0RqS9kZmMlcLJWEA2NzB2DAGOim0HNKtEoNTYmfeD7h bvo85o8jyla39fI5jV4jyBpzy0eaJihbYMf7D8jScIlpwfNJlgCdZaE3V Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10773"; a="368400779" X-IronPort-AV: E=Sophos;i="6.01,210,1684825200"; d="scan'208";a="368400779" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jul 2023 06:45:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10773"; a="1053618699" X-IronPort-AV: E=Sophos;i="6.01,210,1684825200"; d="scan'208";a="1053618699" Received: from dpdk-yaqi.sh.intel.com ([10.67.118.189]) by fmsmga005.fm.intel.com with ESMTP; 16 Jul 2023 06:45:10 -0700 From: Yaqi Tang To: dts@dpdk.org Cc: Yaqi Tang Subject: [PATCH V1 2/3] test_plans/mev_cpfl_hairpin_queue: mev cpfl support hairpin queue Date: Sun, 16 Jul 2023 13:44:15 +0000 Message-Id: <20230716134416.3220611-3-yaqi.tang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230716134416.3220611-1-yaqi.tang@intel.com> References: <20230716134416.3220611-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 Enabling Port2Port forwarding as hairpin queue implementation in dpdk cpfl PMD. Signed-off-by: Yaqi Tang --- .../mev_cpfl_hairpin_queue_test_plan.rst | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 test_plans/mev_cpfl_hairpin_queue_test_plan.rst diff --git a/test_plans/mev_cpfl_hairpin_queue_test_plan.rst b/test_plans/mev_cpfl_hairpin_queue_test_plan.rst new file mode 100644 index 00000000..62044776 --- /dev/null +++ b/test_plans/mev_cpfl_hairpin_queue_test_plan.rst @@ -0,0 +1,84 @@ +============================== +MEV CPFL Support Hairpin Queue +============================== + +Description +=========== +Enabling Port2Port forwarding as hairpin queue implementation in dpdk cpfl PMD. +launch testpmd not start forwarding, multi hairpin queues receive and transmit packet; +start forwarding, multi data queues receive and transmit packet; + +Prerequisites +============= +1. CI release >= MEV 0.81(3921) + +2. During IMC boot, press 'N' when you see 'start init app and auxiliary script [Y/N]'. + cd /etc/dpcp + cp cfg/cp_init_use_case_2.cfg ./cp_init.cfg + cp cp_init.cfg cp_init.cfg.bak + sed -i 's/pf_allowed_to_create_p2p = 5;/pf_allowed_to_create_p2p = 8;/g' cp_init.cfg + sed -i 's/cpf_host = 4;/cpf_host = 0;/g' cp_init.cfg + +3. Update customized package + Copy package to /etc/dpcp/package/ and rename with default_pkg.pkg. + cd /etc/dpcp/package/ + rm default_pkg.pkg + ssh-keygen -f "/root/.ssh/known_hosts" -R "100.0.0.100" + scp default_pkg.pkg root@100.0.0.100:/etc/dpcp/package/ + +4. Run /etc/init.d/run_default_init_app + +Test Case +========= +Common Steps +------------ +1. Launch testpmd but not start forwarding. + +2. Configure port to receive packets on IMC:: + cli_client --query --config --verbose + devmem 0x202920C100 64 0x804 + +3. Create rule on IMC:: + vi rule_1.txt + opcode=0x1303 prof_id=0x34 sub_prof_id=0x0 cookie=0xa2b87 key=0x18,0x0,00,00,00,00,0xde,0xad,0xbe,0xef,0x20,0x24,0x0,0x0,0x0,0x0,00,00,00,00,00,00,0xa,0x2,0x1d,0x64,00,00,00,00,00,00,00,00,00,00,00,00, + 0xa,0x2,0x1d,0x2,00,00,00,00,00,00,00,00,00,00,00,00 act=set_vsi{act_val=0 val_type=2 dst_pe=0 slot=0x0} act=set_q{qnum=0x151 no_implicit_vsi=1 prec=5} act=count{counter_id=0x10 slot=0x0 prec=0x3} + + cli_client -x -f rule_1.txt + +4. Send match packet from tester and check tester can receive the transmit packet:: + sendp([Ether(dst="de:ad:be:ef:20:24")/IP(src="10.2.29.100", dst="10.2.29.2")/UDP()],iface="ens21f0",count=1) + + tcpdump -i ens21f0 -env + +5. Start testpmd and send mismatch packets, check testpmd can receive and transmit packets:: + testpmd>start + testpmd>set verbose 1 + testpmd>show port stats all + testpmd>stop + testpmd>quit + + Mismatch pkts:: + sendp([Ether(src="00:11:22:33:44:55", dst="02:70:80:C6:67:CE")/IP(src="192.168.0.2",dst="192.168.0.3")/("X"*480)], iface="enp24s0f0") + sendp([Ether(src="00:11:22:33:44:55", dst="02:70:80:C6:67:CE")/IPv6(src="2001::2",dst="2001::3")/("X"*480)], iface="enp24s0f0") + sendp([Ether(src="00:11:22:33:44:55", dst="02:70:80:C6:67:CE")/IP(src="10.2.28.12", dst="10.2.28.22")/UDP(sport=1026, dport=1027)/("X"*480)], iface="enp24s0f0") + sendp([Ether(src="00:11:22:33:44:55", dst="02:70:80:C6:67:CE")/IP(src="10.2.28.12", dst="10.2.28.22")/TCP(sport=1026, dport=1027)/("X"*480)], iface="enp24s0f0") + sendp([Ether(src="00:11:22:33:44:55", dst="02:70:80:C6:67:CE")/IP(src="10.2.28.12", dst="10.2.28.22")/SCTP(sport=1026, dport=1027)/("X"*480)], iface="enp24s0f0") + sendp([Ether(src="00:11:22:33:44:55", dst="02:70:80:C6:67:CE")/IPv6(src="2001::2",dst="2001::3")/UDP(sport=1026, dport=1027)/("X"*480)], iface="enp24s0f0") + sendp([Ether(src="00:11:22:33:44:55", dst="02:70:80:C6:67:CE")/IPv6(src="2001::2",dst="2001::3")/TCP(sport=1026, dport=1027)/("X"*480)], iface="enp24s0f0") + sendp([Ether(src="00:11:22:33:44:55", dst="02:70:80:C6:67:CE")/IPv6(src="2001::2",dst="2001::3")/SCTP(sport=1026, dport=1027)/("X"*480)], iface="enp24s0f0") + +Test case 1: single_data_hairpin_queue +-------------------------------------- +./dpdk-testpmd -l 1-2 -n 4 -a af:00.6,vport=0 -- -i --rxq=1 --txq=1 --hairpinq=1 --hairpin-mode=0 + +Test case 2: multi_data_queues_single_hairpin_queue +--------------------------------------------------- +./dpdk-testpmd -l 1-2 -n 4 -a ca:00.6,vport=0 -- -i --rxq=16 --txq=16 --hairpinq=1 --hairpin-mode=0 + +Test case 3: single_data_queue_multi_hairpin_queues +--------------------------------------------------- +./dpdk-testpmd -l 1-2 -n 4 -a ca:00.6,vport=0 -- -i --rxq=1 --txq=1 --hairpinq=16 --hairpin-mode=0 + +Test case 4: multi_data_hairpin_queues +-------------------------------------- +./dpdk-testpmd -l 1-2 -n 4 -a ca:00.6,vport=0 -- -i --rxq=16 --txq=16 --hairpinq=16 --hairpin-mode=0 From patchwork Sun Jul 16 13:44:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yaqi Tang X-Patchwork-Id: 129557 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 D6D7242E8C; Sun, 16 Jul 2023 15:45:15 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D0F1E42BDA; Sun, 16 Jul 2023 15:45:15 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id 6D2614013F for ; Sun, 16 Jul 2023 15:45:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689515114; x=1721051114; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4fsTvdBDat3PVQIJ7VSlFETWJXnSEaGLenX1uoraLoY=; b=FpWx9UGNXt00ftHlUsunEQZdkwaHXtpHUc95KqEseD0ZiXkApg71C57X oeme1gvYdmq3hCX61A6M5podm0ohNHfAfoS9F/R5zsTZLV85h54YurWXA zgvmIWNwMd1BXOTAYAd150Aut3HQd1A8ojPvgW1cruNWXv0rXK5MnmHH+ 5ysIqQMHdxVWJb0PZAztOfSg7qMsxKyJeeKqJjmmWCbUY01j3OoiXBWvc b/Baz9DvNuRvccRMg9c8sBmrFPWnp+9bua41AIEHGF8FNomZInTyNiw23 tj2iAxnN5scIxTn3j38slwa3Hz7qPwnKVdQq+8k4/GK5Fcd77nX6VJJhi g==; X-IronPort-AV: E=McAfee;i="6600,9927,10773"; a="368400786" X-IronPort-AV: E=Sophos;i="6.01,210,1684825200"; d="scan'208";a="368400786" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jul 2023 06:45:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10773"; a="1053618703" X-IronPort-AV: E=Sophos;i="6.01,210,1684825200"; d="scan'208";a="1053618703" Received: from dpdk-yaqi.sh.intel.com ([10.67.118.189]) by fmsmga005.fm.intel.com with ESMTP; 16 Jul 2023 06:45:12 -0700 From: Yaqi Tang To: dts@dpdk.org Cc: Yaqi Tang Subject: [PATCH V1 3/3] tests/mev_cpfl_hairpin_queue: mev cpfl support hairpin queue Date: Sun, 16 Jul 2023 13:44:16 +0000 Message-Id: <20230716134416.3220611-4-yaqi.tang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230716134416.3220611-1-yaqi.tang@intel.com> References: <20230716134416.3220611-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 Enabling Port2Port forwarding as hairpin queue implementation in dpdk cpfl PMD. Signed-off-by: Yaqi Tang --- tests/TestSuite_mev_cpfl_hairpin_queue.py | 281 ++++++++++++++++++++++ 1 file changed, 281 insertions(+) create mode 100644 tests/TestSuite_mev_cpfl_hairpin_queue.py diff --git a/tests/TestSuite_mev_cpfl_hairpin_queue.py b/tests/TestSuite_mev_cpfl_hairpin_queue.py new file mode 100644 index 00000000..d9cc71f7 --- /dev/null +++ b/tests/TestSuite_mev_cpfl_hairpin_queue.py @@ -0,0 +1,281 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2023 Intel Corporation +# +import re +import time + +from framework.packet import Packet +from framework.pmd_output import PmdOutput +from framework.test_case import TestCase + +match_pkts = { + "rule_1_match_pkt": 'Ether(src="00:11:22:33:44:55", dst="de:ad:be:ef:20:24")/IP(src="10.2.29.100", dst="10.2.29.2")/UDP()', + "rule_2_match_pkt": 'Ether(src="00:11:22:33:44:55", dst="00:06:00:00:02:18")/IP(src="133.133.10.20", dst="133.133.10.10")/UDP()', + "rule_3_match_pkt": 'Ether(src="00:11:22:33:44:55", dst="de:ad:be:ef:05:34")/IP(src="10.2.28.10", dst="10.2.28.20")/UDP()', + "rule_4_match_pkt": 'Ether(src="00:11:22:33:44:55", dst="de:ad:be:ef:10:14")/IP(src="10.2.28.10", dst="10.2.28.20")/TCP()', + "rule_5_match_pkt": 'Ether(src="00:11:22:33:44:55", dst="00:05:00:00:03:17")/IP(src="133.133.10.60", dst="133.133.10.20")/UDP()', + "rule_6_match_pkt": 'Ether(src="00:11:22:33:44:55", dst="de:ad:be:ef:08:84")/IP(src="10.2.28.19", dst="10.2.28.29")/UDP()', + "rule_7_match_pkt": 'Ether(src="00:11:22:33:44:55", dst="00:05:00:00:03:18")/IP(src="133.133.10.60", dst="133.133.10.10")/TCP()', + "rule_8_match_pkt": 'Ether(src="00:11:22:33:44:55", dst="dc:ad:be:ef:04:29")/IP(src="10.2.28.39", dst="10.2.28.49")/UDP()', + "rule_9_match_pkt": 'Ether(src="00:11:22:33:44:55", dst="de:ad:be:ef:10:14")/IP(src="10.2.28.10", dst="10.2.28.20")/TCP()', + "rule_10_match_pkt": 'Ether(src="00:11:22:33:44:55", dst="00:08:00:00:03:19")/IP(src="133.133.10.60", dst="133.133.10.30")/TCP()', + "rule_11_match_pkt": 'Ether(src="00:11:22:33:44:55", dst="00:06:00:00:02:18")/IP(src="10.2.29.100", dst="10.2.29.2")/TCP()', + "rule_12_match_pkt": 'Ether(src="00:11:22:33:44:55", dst="00:07:00:00:05:19")/IP(src="133.133.10.20", dst="133.133.10.10")/TCP()', + "rule_13_match_pkt": 'Ether(src="00:11:22:33:44:55", dst="00:05:00:00:03:17")/IP(src="133.133.10.60", dst="133.133.10.20")/TCP()', + "rule_14_match_pkt": 'Ether(src="00:11:22:33:44:55", dst="dc:ad:be:ef:04:29")/IP(src="10.2.28.39", dst="10.2.28.49")/TCP()', + "rule_15_match_pkt": 'Ether(src="00:11:22:33:44:55", dst="de:ad:be:ef:08:84")/IP(src="10.2.28.19", dst="10.2.28.29")/TCP()', + "rule_16_match_pkt": 'Ether(src="00:11:22:33:44:55", dst="da:ad:be:ef:06:19")/IP(src="10.2.28.29", dst="10.2.28.39")/TCP()', +} + +hairpin_rules = { + "rule_1": "opcode=0x1303 prof_id=0x34 sub_prof_id=0x0 cookie=0xa2b87 key=0x18,0x0,00,00,00,00,0xde,0xad,0xbe,0xef,0x20,0x24,0x0,0x0,0x0,0x0,00,00,00,00,00,00,0xa,0x2,0x1d,0x64,00,00,00,00,00,00,00,00,00,00,00,00,\ +0xa,0x2,0x1d,0x2,00,00,00,00,00,00,00,00,00,00,00,00 act=set_vsi{act_val=0 val_type=2 dst_pe=0 slot=0x0}", + "rule_2": "opcode=0x1303 prof_id=0x34 sub_prof_id=0x0 cookie=0xa2b87 key=0x18,0x0,00,00,00,00,00,0x06,0x00,0x00,0x02,0x18,0x0,0x0,0x0,0x0,00,00,00,00,00,00,0x85,0x85,0xa,0x14,00,00,00,00,00,00,00,00,00,00,00,00,\ +0x85,0x85,0xa,0xa,00,00,00,00,00,00,00,00,00,00,00,00 act=set_vsi{act_val=0 val_type=2 dst_pe=0 slot=0x0}", + "rule_3": "opcode=0x1303 prof_id=0x34 sub_prof_id=0x0 cookie=0xa2b87 key=0x18,0x0,00,00,00,00,0xde,0xad,0xbe,0xef,0x05,0x34,0x0,0x0,0x0,0x0,00,00,00,00,00,00,0xa,0x2,0x1c,0xa,00,00,00,00,00,00,00,00,00,00,00,00,\ +0xa,0x2,0x1c,0x14,00,00,00,00,00,00,00,00,00,00,00,00 act=set_vsi{act_val=0 val_type=2 dst_pe=0 slot=0x0}", + "rule_4": "opcode=0x1303 prof_id=0x32 sub_prof_id=0x0 cookie=0xa2b87 key=0x1a,0x0,00,00,00,00,0xde,0xad,0xbe,0xef,0x10,0x14,0x0,0x0,0x0,0x0,00,00,00,00,00,00,0xa,0x2,0x1c,0xa,00,00,00,00,00,00,00,00,00,00,00,00,\ +0xa,0x2,0x1c,0x14,00,00,00,00,00,00,00,00,00,00,00,00 act=set_vsi{act_val=0 val_type=2 dst_pe=0 slot=0x0}", + "rule_5": "opcode=0x1303 prof_id=0x34 sub_prof_id=0x0 cookie=0xa2b87 key=0x18,0x0,00,00,00,00,00,0x05,0x00,0x00,0x03,0x17,0x0,0x0,0x0,0x0,00,00,00,00,00,00,0x85,0x85,0xa,0x3c,00,00,00,00,00,00,00,00,00,00,00,00,\ +0x85,0x85,0xa,0x14,00,00,00,00,00,00,00,00,00,00,00,00 act=set_vsi{act_val=0 val_type=2 dst_pe=0 slot=0x0}", + "rule_6": "opcode=0x1303 prof_id=0x34 sub_prof_id=0x0 cookie=0xa2b87 key=0x18,0x0,00,00,00,00,0xde,0xad,0xbe,0xef,0x08,0x84,0x0,0x0,0x0,0x0,00,00,00,00,00,00,0xa,0x2,0x1c,0x13,00,00,00,00,00,00,00,00,00,00,00,00,\ +0xa,0x2,0x1c,0x1d,00,00,00,00,00,00,00,00,00,00,00,00 act=set_vsi{act_val=0 val_type=2 dst_pe=0 slot=0x0}", + "rule_7": "opcode=0x1303 prof_id=0x32 sub_prof_id=0x0 cookie=0xa2b87 key=0x1a,0x0,00,00,00,00,00,0x05,0x00,0x00,0x03,0x18,0x0,0x0,0x0,0x0,00,00,00,00,00,00,0x85,0x85,0xa,0x3c,00,00,00,00,00,00,00,00,00,00,00,00,\ +0x85,0x85,0xa,0xa,00,00,00,00,00,00,00,00,00,00,00,00 act=set_vsi{act_val=0 val_type=2 dst_pe=0 slot=0x0}", + "rule_8": "opcode=0x1303 prof_id=0x34 sub_prof_id=0x0 cookie=0xa2b87 key=0x18,0x0,00,00,00,00,0xdc,0xad,0xbe,0xef,0x04,0x29,0x0,0x0,0x0,0x0,00,00,00,00,00,00,0xa,0x2,0x1c,0x27,00,00,00,00,00,00,00,00,00,00,00,00,\ +0xa,0x2,0x1c,0x31,00,00,00,00,00,00,00,00,00,00,00,00 act=set_vsi{act_val=0 val_type=2 dst_pe=0 slot=0x0}", + "rule_9": "opcode=0x1303 prof_id=0x32 sub_prof_id=0x0 cookie=0xa2b87 key=0x1a,0x0,00,00,00,00,0xde,0xad,0xbe,0xef,0x10,0x14,0x0,0x0,0x0,0x0,00,00,00,00,00,00,0xa,0x2,0x1c,0xa,00,00,00,00,00,00,00,00,00,00,00,00,\ +0xa,0x2,0x1c,0x14,00,00,00,00,00,00,00,00,00,00,00,00 act=set_vsi{act_val=0 val_type=2 dst_pe=0 slot=0x0}", + "rule_10": "opcode=0x1303 prof_id=0x32 sub_prof_id=0x0 cookie=0xa2b87 key=0x1a,0x0,00,00,00,00,00,0x08,0x00,0x00,0x03,0x19,0x0,0x0,0x0,0x0,00,00,00,00,00,00,0x85,0x85,0xa,0x3c,00,00,00,00,00,00,00,00,00,00,00,00,\ +0x85,0x85,0xa,0x1e,00,00,00,00,00,00,00,00,00,00,00,00 act=set_vsi{act_val=0 val_type=2 dst_pe=0 slot=0x0}", + "rule_11": "opcode=0x1303 prof_id=0x32 sub_prof_id=0x0 cookie=0xa2b87 key=0x1a,0x0,00,00,00,00,00,0x06,0x00,0x00,0x02,0x18,0x0,0x0,0x0,0x0,00,00,00,00,00,00,0xa,0x2,0x1d,0x64,00,00,00,00,00,00,00,00,00,00,00,00,\ +0xa,0x2,0x1d,0x2,00,00,00,00,00,00,00,00,00,00,00,00 act=set_vsi{act_val=0 val_type=2 dst_pe=0 slot=0x0}", + "rule_12": "opcode=0x1303 prof_id=0x32 sub_prof_id=0x0 cookie=0xa2b87 key=0x1a,0x0,00,00,00,00,00,0x07,0x00,0x00,0x05,0x19,0x0,0x0,0x0,0x0,00,00,00,00,00,00,0x85,0x85,0xa,0x14,00,00,00,00,00,00,00,00,00,00,00,00,\ +0x85,0x85,0xa,0xa,00,00,00,00,00,00,00,00,00,00,00,00 act=set_vsi{act_val=0 val_type=2 dst_pe=0 slot=0x0}", + "rule_13": "opcode=0x1303 prof_id=0x32 sub_prof_id=0x0 cookie=0xa2b87 key=0x1a,0x0,00,00,00,00,00,0x05,0x00,0x00,0x03,0x17,0x0,0x0,0x0,0x0,00,00,00,00,00,00,0x85,0x85,0xa,0x3c,00,00,00,00,00,00,00,00,00,00,00,00,\ +0x85,0x85,0xa,0x14,00,00,00,00,00,00,00,00,00,00,00,00 act=set_vsi{act_val=0 val_type=2 dst_pe=0 slot=0x0}", + "rule_14": "opcode=0x1303 prof_id=0x32 sub_prof_id=0x0 cookie=0xa2b87 key=0x1a,0x0,00,00,00,00,0xdc,0xad,0xbe,0xef,0x04,0x29,0x0,0x0,0x0,0x0,00,00,00,00,00,00,0xa,0x2,0x1c,0x27,00,00,00,00,00,00,00,00,00,00,00,00,\ +0xa,0x2,0x1c,0x31,00,00,00,00,00,00,00,00,00,00,00,00 act=set_vsi{act_val=0 val_type=2 dst_pe=0 slot=0x0}", + "rule_15": "opcode=0x1303 prof_id=0x32 sub_prof_id=0x0 cookie=0xa2b87 key=0x1a,0x0,00,00,00,00,0xde,0xad,0xbe,0xef,0x08,0x84,0x0,0x0,0x0,0x0,00,00,00,00,00,00,0xa,0x2,0x1c,0x13,00,00,00,00,00,00,00,00,00,00,00,00,\ +0xa,0x2,0x1c,0x1d,00,00,00,00,00,00,00,00,00,00,00,00 act=set_vsi{act_val=0 val_type=2 dst_pe=0 slot=0x0}", + "rule_16": "opcode=0x1303 prof_id=0x32 sub_prof_id=0x0 cookie=0xa2b87 key=0x1a,0x0,00,00,00,00,0xda,0xad,0xbe,0xef,0x06,0x19,0x0,0x0,0x0,0x0,00,00,00,00,00,00,0xa,0x2,0x1c,0x1d,00,00,00,00,00,00,00,00,00,00,00,00,\ +0xa,0x2,0x1c,0x27,00,00,00,00,00,00,00,00,00,00,00,00 act=set_vsi{act_val=0 val_type=2 dst_pe=0 slot=0x0}", +} + +mismatch_pkts = { + "mac_ipv4": 'Ether(src="00:11:22:33:44:55", dst="02:70:80:C6:67:CE")/IP(src="192.168.0.2",dst="192.168.0.3")/("X"*480)', + "mac_ipv6": 'Ether(src="00:11:22:33:44:55", dst="02:70:80:C6:67:CE")/IPv6(src="2001::2",dst="2001::3")/("X"*480)', + "mac_ipv4_udp": 'Ether(src="00:11:22:33:44:55", dst="02:70:80:C6:67:CE")/IP(src="10.2.28.12", dst="10.2.28.22")/UDP(sport=1026, dport=1027)/("X"*480)', + "mac_ipv4_tcp": 'Ether(src="00:11:22:33:44:55", dst="02:70:80:C6:67:CE")/IP(src="10.2.28.12", dst="10.2.28.22")/TCP(sport=1026, dport=1027)/("X"*480)', + "mac_ipv4_sctp": 'Ether(src="00:11:22:33:44:55", dst="02:70:80:C6:67:CE")/IP(src="10.2.28.12", dst="10.2.28.22")/SCTP(sport=1026, dport=1027)/("X"*480)', + "mac_ipv6_udp": 'Ether(src="00:11:22:33:44:55", dst="02:70:80:C6:67:CE")/IPv6(src="2001::2",dst="2001::3")/UDP(sport=1026, dport=1027)/("X"*480)', + "mac_ipv6_tcp": 'Ether(src="00:11:22:33:44:55", dst="02:70:80:C6:67:CE")/IPv6(src="2001::2",dst="2001::3")/TCP(sport=1026, dport=1027)/("X"*480)', + "mac_ipv6_sctp": 'Ether(src="00:11:22:33:44:55", dst="02:70:80:C6:67:CE")/IPv6(src="2001::2",dst="2001::3")/SCTP(sport=1026, dport=1027)/("X"*480)', +} + + +class TestHairpinqueue(TestCase): + def set_up_all(self): + """ + Run at the start of each test suite. + Generic filter Prerequistites + """ + self.verify( + self.nic in ["mev-cpfl"], + "%s nic not support hairpin queue" % 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.pf_pci = self.dut.ports_info[self.dut_ports[0]]["pci"] + self.imc_rule_dir = "/home/rule/" + + def set_up(self): + """ + Run before each test case. + """ + pass + + def launch_testpmd(self, rxq, txq, hairpinq): + """ + start testpmd + """ + # Prepare testpmd EAL and parameters + out = self.pmdout.start_testpmd( + "Default", + param="--rxq=%d --txq=%d --hairpinq=%d --hairpin-mode=0" + % (rxq, txq, hairpinq), + ) + qnum = re.findall("hairpin: vport 0, Rxq id (\w+)", out) + print(qnum) + return qnum + + def start_testpmd(self): + self.dut.send_expect("set verbose 1", "testpmd>") + self.dut.send_expect("start", "testpmd>", 10) + # test link status + res = self.pmdout.wait_link_status_up("all", timeout=15) + self.verify(res is True, "There have port link is down") + + def create_imc_session(self): + self.imc_test_session = self.dut.new_session(suite="imc") + self.imc_test_session.send_expect("export TERM=linux-c-nc", "#") + out = self.imc_test_session.send_command( + "sudo minicom -D /dev/ttyUSB2 -b 460800 -w" + ) + if "Device /dev/ttyUSB2 is locked" in out: + self.imc_test_session.send_command( + "ps -ef | grep 'minicom -D /dev/ttyUSB2' | grep -v grep | awk '{print $2}' | xargs kill -9" + ) + self.imc_test_session.send_command( + "sudo minicom -D /dev/ttyUSB2 -b 460800 -w" + ) + if "mev-imc login:" in self.imc_test_session.send_command("\n"): + self.imc_test_session.send_expect("root", "mev-imc") + else: + self.imc_test_session.send_expect("\n", "mev-imc") + self.logger.info("create imc test session successfully") + return self.imc_test_session + + def create_imc_rule(self, count, rules): + self.create_imc_session() + self.imc_test_session.send_expect( + "mkdir -p %s" % (self.imc_rule_dir), "mev-imc" + ) + self.imc_test_session.send_expect("cd %s" % (self.imc_rule_dir), "mev-imc") + self.imc_test_session.send_expect("rm *.txt", "mev-imc") + for i in range(count): + rule = rules["rule_%d" % (i + 1)] + print(rule) + time.sleep(2) + self.imc_test_session.send_command("cat > rule_%d.txt" % (i + 1)) + self.imc_test_session.send_command("%s" % rule) + self.imc_test_session.send_command("^d") + print(self.imc_test_session.send_expect("ls", "#")) + output = self.imc_test_session.send_command( + "cli_client -x -f rule_%d.txt" % (i + 1), 10 + ) + print(output) + time.sleep(2) + self.verify("WARNING" not in output, "Found bad key in rule") + self.verify("File successfully processed" in output, "Create rule failed") + + def delete_imc_rule(self, count): + self.imc_test_session.send_expect("cd %s" % (self.imc_rule_dir), "mev-imc") + print(self.imc_test_session.send_expect("ls", "#")) + for i in range(count): + self.imc_test_session.send_command( + "sed -i 's/opcode=0x1303/opcode=0x1305/g' rule_%d.txt" % (i + 1), 2 + ) + output = self.imc_test_session.send_command( + "cli_client -x -f rule_%d.txt" % (i + 1), 5 + ) + self.verify("WARNING" not in output, "Found bad key in rule") + self.verify("File successfully processed" in output, "Create rule failed") + + def send_packets(self, packets, tx_port, count=1): + self.pkt.update_pkt(packets) + self.pkt.send_pkt(crb=self.tester, tx_port=tx_port, count=count) + + def check_tcpdump_pkts(self, pkts, count): + filters = [{"layer": "ether", "config": {"src": "00:11:22:33:44:55"}}] + inst = self.tester.tcpdump_sniff_packets(self.tester_iface0, filters=filters) + self.dut.send_expect("clear port stats all", "testpmd>", 10) + for i in range(len(pkts)): + pkt = pkts[i] + self.pkt.update_pkt(pkt) + self.pkt.send_pkt(crb=self.tester, tx_port=self.tester_iface0, count=1) + self.dut.send_expect("show port stats all", "testpmd>", 10) + time.sleep(2) + p = self.tester.load_tcpdump_sniff_packets(inst) + print(len(p)) + self.verify( + len(p) == count, + "Send %d packets but received %d packets, not match" % (count, len(p)), + ) + + def validate_hairpin_queue(self, count, rules, match_pkts): + mismatch_pkt = list(mismatch_pkts.values()) + self.create_imc_rule(count, rules) + self.check_tcpdump_pkts(match_pkts, count) + self.start_testpmd() + self.check_tcpdump_pkts(mismatch_pkt, count=8) + self.delete_imc_rule(count) + + def test_single_hairpin_queue(self): + """ + Test Case 1: Launch 1 hairpin queue + """ + self.logger.info( + "===================Test subcase 1: single data queue and single hairpin queue ================" + ) + qnum = self.launch_testpmd(rxq=1, txq=1, hairpinq=1) + rules = {} + match_pkt = [match_pkts["rule_4_match_pkt"]] + rules["rule_1"] = ( + hairpin_rules["rule_4"] + + " act=set_q{qnum=%s no_implicit_vsi=1 prec=5}" % qnum[0] + ) + self.validate_hairpin_queue(count=1, rules=rules, match_pkts=match_pkt) + self.dut.send_expect("stop", "testpmd> ", 10) + self.dut.send_expect("quit", "# ", 10) + + self.logger.info( + "===================Test subcase 2: multi data queues and single hairpin queue ================" + ) + qnum = self.launch_testpmd(rxq=16, txq=16, hairpinq=1) + match_pkt = [match_pkts["rule_1_match_pkt"]] + rules["rule_1"] = ( + hairpin_rules["rule_1"] + + " act=set_q{qnum=%s no_implicit_vsi=1 prec=5}" % qnum[0] + ) + self.validate_hairpin_queue(count=1, rules=rules, match_pkts=match_pkt) + + def test_multi_hairpin_queues(self): + """ + Test Case 2: Launch 16 hairpin queues + """ + self.logger.info( + "===================Test subcase 1: single data queue and multi hairpin queues ================" + ) + qnum = self.launch_testpmd(rxq=1, txq=1, hairpinq=16) + match_pkt = list(match_pkts.values()) + rules = {} + for i in range(16): + rules["rule_%d" % (i + 1)] = ( + hairpin_rules["rule_%d" % (i + 1)] + + " act=set_q{qnum=%s no_implicit_vsi=1 prec=5}" % qnum[i] + ) + self.validate_hairpin_queue(count=16, rules=rules, match_pkts=match_pkt) + self.dut.send_expect("stop", "testpmd> ", 10) + self.dut.send_expect("quit", "# ", 10) + + self.logger.info( + "===================Test subcase 2: multi data queues and multi hairpin queues ================" + ) + qnum = self.launch_testpmd(rxq=16, txq=16, hairpinq=16) + for i in range(16): + rules["rule_%d" % (i + 1)] = ( + hairpin_rules["rule_%d" % (i + 1)] + + " act=set_q{qnum=%s no_implicit_vsi=1 prec=5}" % qnum[i] + ) + self.validate_hairpin_queue(count=16, rules=rules, match_pkts=match_pkt) + + def tear_down(self): + """ + Run after each test case. + """ + self.dut.send_expect("stop", "testpmd> ", 10) + self.dut.send_expect("quit", "# ", 10) + self.dut.kill_all() + + def tear_down_all(self): + """ + Run after each test suite. + """ + self.dut.kill_all()