From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 8997842476;
	Tue, 24 Jan 2023 10:06:37 +0100 (CET)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 4A55442D36;
	Tue, 24 Jan 2023 10:06:08 +0100 (CET)
Received: from NAM11-DM6-obe.outbound.protection.outlook.com
 (mail-dm6nam11on2083.outbound.protection.outlook.com [40.107.223.83])
 by mails.dpdk.org (Postfix) with ESMTP id E3E1440684
 for <dev@dpdk.org>; Tue, 24 Jan 2023 10:06:04 +0100 (CET)
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
 b=L4MBb9OKX6sjx+3sM2XnZsTSnEMl+WQvoC0/y7pUD9ia22+2XnpJy7HE6pOuIPqGDOTydbzX5mdI7oq3/fbVp8Vs2h+7aZ3/tm6M6qSPtemhyXuuer0ynK9LFIL8EhqjOjMSBGRIKWZx9/lrsxbdNszuIAREfjS1bDuZi7JKDhj+s0uEX2Ks/P6IrXBUs9RRNOq82PNoXxVrlpab+CNlPznfZ5h8E//RB/DOCjhZppl9ipaqPCJBlF1Lo/AZ/EcSHEMbRxpnqlqLjcDL90N2hL6zp0PZv9Coobkjou5AiBS50S0s6Luttpqf2q/9NsO98xElYW6Nw9qcI92pVWzG5g==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; 
 s=arcselector9901;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
 bh=LFfhf0jL8yex4misse2ZZgB3pTDuf9WSLKJLtZp/Ttw=;
 b=bzYxML6G3XYbtzmEMEyvbCG2IDltAGG7bBMMFU/4u509wqw5Co75crFxW2vg10XOl8y96AHzmFoT4VzsCzpzykO4jwqbf64s7b12r4xOgWqHxvsk/k5jVRnoNIB64WanEB8EBsg7iRlZzGK+Y2dKuHgTdeYmCPCYFDTgSL2RgxrgPtwoDwbphsy25vBHPZIFbLjIYATu+ANn7mMcly7Ph5E2fjOtFYUPht0jUimd/PSJmt8CxVRlcjRaseSp+Q3ykGY4caBUjasIsub2bO2Aw7ZOz62gRH0N5KrTKrqUSRnEnRSMA8AcxsurDR5iMq3JXkeG9sHJ9f38Kx3yY1Qlug==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is
 165.204.84.17) smtp.rcpttodomain=monjalon.net smtp.mailfrom=amd.com;
 dmarc=pass (p=quarantine sp=quarantine pct=100) action=none
 header.from=amd.com; dkim=none (message not signed); arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; 
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=LFfhf0jL8yex4misse2ZZgB3pTDuf9WSLKJLtZp/Ttw=;
 b=LOnakxRGCA6Y7fRddrHWef+WuJdy2Kww1cCG5dHAQz9+AzdWkYhSc1gWfVdgLpR3i0JAIGujYsj2H2LmPXwmBrQqzY3lH2XFH257X61jWxd2/RkmIMEjn78XnVIWWLsh6NaIeLDC2N3gNn5eUecTmt+R/btQ2CF8bnyhW5ad2xU=
Received: from MN2PR20CA0001.namprd20.prod.outlook.com (2603:10b6:208:e8::14)
 by PH7PR12MB6585.namprd12.prod.outlook.com (2603:10b6:510:213::22)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33; Tue, 24 Jan
 2023 09:05:58 +0000
Received: from BL02EPF000108EB.namprd05.prod.outlook.com
 (2603:10b6:208:e8:cafe::d9) by MN2PR20CA0001.outlook.office365.com
 (2603:10b6:208:e8::14) with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33 via Frontend
 Transport; Tue, 24 Jan 2023 09:05:58 +0000
X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17)
 smtp.mailfrom=amd.com; dkim=none (message not signed)
 header.d=none;dmarc=pass action=none header.from=amd.com;
Received-SPF: Pass (protection.outlook.com: domain of amd.com designates
 165.204.84.17 as permitted sender) receiver=protection.outlook.com;
 client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C
Received: from SATLEXMB04.amd.com (165.204.84.17) by
 BL02EPF000108EB.mail.protection.outlook.com (10.167.241.200) with Microsoft
 SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
 15.20.6043.12 via Frontend Transport; Tue, 24 Jan 2023 09:05:58 +0000
Received: from telcodpdk.amd.com (10.180.168.240) by SATLEXMB04.amd.com
 (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 24 Jan
 2023 03:05:46 -0600
From: Ferruh Yigit <ferruh.yigit@amd.com>
To: Thomas Monjalon <thomas@monjalon.net>, Ori Kam <orika@nvidia.com>, Aman
 Singh <aman.deep.singh@intel.com>, Yuying Zhang <yuying.zhang@intel.com>,
 Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
CC: David Marchand <david.marchand@redhat.com>, <dev@dpdk.org>
Subject: [PATCH v3 6/8] ethdev: use ARP protocol struct for flow matching
Date: Tue, 24 Jan 2023 09:02:58 +0000
Message-ID: <20230124090300.247915-7-ferruh.yigit@amd.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20230124090300.247915-1-ferruh.yigit@amd.com>
References: <20221025214410.715864-1-thomas@monjalon.net>
 <20230124090300.247915-1-ferruh.yigit@amd.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [10.180.168.240]
X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com
 (10.181.40.145)
X-EOPAttributedMessage: 0
X-MS-PublicTrafficType: Email
X-MS-TrafficTypeDiagnostic: BL02EPF000108EB:EE_|PH7PR12MB6585:EE_
X-MS-Office365-Filtering-Correlation-Id: a0554b3e-b21c-4422-39b1-08dafdea353a
X-MS-Exchange-SenderADCheck: 1
X-MS-Exchange-AntiSpam-Relay: 0
X-Microsoft-Antispam: BCL:0;
X-Microsoft-Antispam-Message-Info: gN76AWJ1M3cFvfHn5IKsu/rW7Npoqadt/8bnK5OREytgQge1NcY4e8AMZHWhmkHJ6nRcBXSdCVV2L+Enj2wfJkUQRL5ZbcY5rLxNx3BUP8K9SHYEoYKkg8chd85ajK5LIjpDrxKkboQTGSbUDpkXbV7gL+C9h3BHYZQC52CQBA9TH5+op4qPX5EKKyFUwZRrzzLy+ihp9s/R0EidFbnu8E6gzJhWy4vgs9huVfOZtpQ1+prJ1l6OGA+E03O+zen8tn6Bvj5gx0KUaFm7lgD51v9ZTJyhXbnzYXrk2HJ2R+hz9gg1U+WXDbdDhKq09DZJQLgrxQU0IOoF9o0gRW1p0fTotfZ36l8JpmUBbsdf9Qet6H9KFbMyPdb85QeMazRVO2MbtmYfsx5rXPZh2iFPoS5SJYRipGWaxX8PcSuf8I8Gq3tA+g1TUd9zLcNkxQCJvq9abBmqJsvhSr+ty2EkGfQlmfkdascaUgzWpRSl60wVg/DahT3AeXirUlP7pZY5GMiECdhCIw8N+3at91Q+pF+Ha+Jpx0EDYVuRtYEnze+1anTeOrmM2QulMaqfwXobrRuuljYJIlo1QjQuOb71ITGQxR4aqJHvkrJkqqlKgQqfELoK2exa0ax2ud27yMqbjmMf+a1cSfLduysImQPDlD8sUfon6gd+ALzMAR3SPjYEPmVzQuj5GIrqIcnkvLZLQETBmuk2kz0K+g7jJwB8MIsTh2s51nkRnzCrt8QQe5Q=
X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:;
 IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE;
 SFS:(13230022)(4636009)(346002)(396003)(376002)(39860400002)(136003)(451199015)(46966006)(40470700004)(36840700001)(47076005)(426003)(40460700003)(86362001)(316002)(110136005)(478600001)(54906003)(7696005)(36756003)(40480700001)(356005)(82310400005)(1076003)(2616005)(82740400003)(36860700001)(81166007)(83380400001)(336012)(186003)(26005)(16526019)(5660300002)(2906002)(6666004)(44832011)(41300700001)(8936002)(70586007)(70206006)(4326008)(8676002)(36900700001);
 DIR:OUT; SFP:1101; 
X-OriginatorOrg: amd.com
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 09:05:58.3060 (UTC)
X-MS-Exchange-CrossTenant-Network-Message-Id: a0554b3e-b21c-4422-39b1-08dafdea353a
X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d
X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17];
 Helo=[SATLEXMB04.amd.com]
X-MS-Exchange-CrossTenant-AuthSource: BL02EPF000108EB.namprd05.prod.outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Anonymous
X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem
X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6585
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

From: Thomas Monjalon <thomas@monjalon.net>

As announced in the deprecation notice, flow item structures
should re-use the protocol header definitions from the directory lib/net/.

The protocol struct is added in an unnamed union, keeping old field names.

The ARP header struct members are used in testpmd
instead of the redundant fields in the flow items.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 app/test-pmd/cmdline_flow.c          |  8 +++---
 doc/guides/prog_guide/rte_flow.rst   | 10 +-------
 doc/guides/rel_notes/deprecation.rst |  1 -
 lib/ethdev/rte_flow.h                | 37 ++++++++++++++++++----------
 4 files changed, 29 insertions(+), 27 deletions(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index dd6da9d98d9b..1d337a96199d 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -4226,7 +4226,7 @@ static const struct token token_list[] = {
 		.next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_MAC_ADDR),
 			     item_param),
 		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
-					     sha)),
+					     hdr.arp_data.arp_sha)),
 	},
 	[ITEM_ARP_ETH_IPV4_SPA] = {
 		.name = "spa",
@@ -4234,7 +4234,7 @@ static const struct token token_list[] = {
 		.next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
 			     item_param),
 		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
-					     spa)),
+					     hdr.arp_data.arp_sip)),
 	},
 	[ITEM_ARP_ETH_IPV4_THA] = {
 		.name = "tha",
@@ -4242,7 +4242,7 @@ static const struct token token_list[] = {
 		.next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_MAC_ADDR),
 			     item_param),
 		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
-					     tha)),
+					     hdr.arp_data.arp_tha)),
 	},
 	[ITEM_ARP_ETH_IPV4_TPA] = {
 		.name = "tpa",
@@ -4250,7 +4250,7 @@ static const struct token token_list[] = {
 		.next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
 			     item_param),
 		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
-					     tpa)),
+					     hdr.arp_data.arp_tip)),
 	},
 	[ITEM_IPV6_EXT] = {
 		.name = "ipv6_ext",
diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst
index ec2e335fac3d..8bf85df2f611 100644
--- a/doc/guides/prog_guide/rte_flow.rst
+++ b/doc/guides/prog_guide/rte_flow.rst
@@ -1100,15 +1100,7 @@ Item: ``ARP_ETH_IPV4``
 
 Matches an ARP header for Ethernet/IPv4.
 
-- ``hdr``: hardware type, normally 1.
-- ``pro``: protocol type, normally 0x0800.
-- ``hln``: hardware address length, normally 6.
-- ``pln``: protocol address length, normally 4.
-- ``op``: opcode (1 for request, 2 for reply).
-- ``sha``: sender hardware address.
-- ``spa``: sender IPv4 address.
-- ``tha``: target hardware address.
-- ``tpa``: target IPv4 address.
+- ``hdr``:  header definition (``rte_arp.h``).
 - Default ``mask`` matches SHA, SPA, THA and TPA.
 
 Item: ``IPV6_EXT``
diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
index b89450b239ef..8e3683990117 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -64,7 +64,6 @@ Deprecation Notices
   These items are not compliant (not including struct from lib/net/):
 
   - ``rte_flow_item_ah``
-  - ``rte_flow_item_arp_eth_ipv4``
   - ``rte_flow_item_e_tag``
   - ``rte_flow_item_geneve``
   - ``rte_flow_item_geneve_opt``
diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h
index 85ca73d1dc04..a215daa83640 100644
--- a/lib/ethdev/rte_flow.h
+++ b/lib/ethdev/rte_flow.h
@@ -20,6 +20,7 @@
 #include <rte_compat.h>
 #include <rte_common.h>
 #include <rte_ether.h>
+#include <rte_arp.h>
 #include <rte_icmp.h>
 #include <rte_ip.h>
 #include <rte_sctp.h>
@@ -1255,26 +1256,36 @@ static const struct rte_flow_item_vxlan_gpe rte_flow_item_vxlan_gpe_mask = {
  *
  * Matches an ARP header for Ethernet/IPv4.
  */
+RTE_STD_C11
 struct rte_flow_item_arp_eth_ipv4 {
-	rte_be16_t hrd; /**< Hardware type, normally 1. */
-	rte_be16_t pro; /**< Protocol type, normally 0x0800. */
-	uint8_t hln; /**< Hardware address length, normally 6. */
-	uint8_t pln; /**< Protocol address length, normally 4. */
-	rte_be16_t op; /**< Opcode (1 for request, 2 for reply). */
-	struct rte_ether_addr sha; /**< Sender hardware address. */
-	rte_be32_t spa; /**< Sender IPv4 address. */
-	struct rte_ether_addr tha; /**< Target hardware address. */
-	rte_be32_t tpa; /**< Target IPv4 address. */
+	union {
+		struct {
+			/*
+			 * These are old fields kept for compatibility.
+			 * Please prefer hdr field below.
+			 */
+			rte_be16_t hrd; /**< Hardware type, normally 1. */
+			rte_be16_t pro; /**< Protocol type, normally 0x0800. */
+			uint8_t hln; /**< Hardware address length, normally 6. */
+			uint8_t pln; /**< Protocol address length, normally 4. */
+			rte_be16_t op; /**< Opcode (1 for request, 2 for reply). */
+			struct rte_ether_addr sha; /**< Sender hardware address. */
+			rte_be32_t spa; /**< Sender IPv4 address. */
+			struct rte_ether_addr tha; /**< Target hardware address. */
+			rte_be32_t tpa; /**< Target IPv4 address. */
+		};
+		struct rte_arp_hdr hdr; /**< ARP header definition. */
+	};
 };
 
 /** Default mask for RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4. */
 #ifndef __cplusplus
 static const struct rte_flow_item_arp_eth_ipv4
 rte_flow_item_arp_eth_ipv4_mask = {
-	.sha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
-	.spa = RTE_BE32(0xffffffff),
-	.tha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
-	.tpa = RTE_BE32(0xffffffff),
+	.hdr.arp_data.arp_sha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
+	.hdr.arp_data.arp_sip = RTE_BE32(UINT32_MAX),
+	.hdr.arp_data.arp_tha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
+	.hdr.arp_data.arp_tip = RTE_BE32(UINT32_MAX),
 };
 #endif
 
-- 
2.25.1