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 37710A0C53;
	Fri,  3 Sep 2021 09:30:31 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id A187640DDE;
	Fri,  3 Sep 2021 09:30:30 +0200 (CEST)
Received: from NAM10-MW2-obe.outbound.protection.outlook.com
 (mail-mw2nam10on2042.outbound.protection.outlook.com [40.107.94.42])
 by mails.dpdk.org (Postfix) with ESMTP id D517A406B4
 for <dev@dpdk.org>; Fri,  3 Sep 2021 09:30:28 +0200 (CEST)
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
 b=kSxXVBWydV0KDd80RYFcDsPB1cg3DCyjmpWNHq33QaU+8G2GUqRem1rq2Z7btRM9SbWXIdAk3u6VtZGNsHpH1t3Q0tfEVcLVUObKj5vX23EcN08TwgMdmpamMxqW8olqznOy/sJTHnw9J5WbFXiMetreuASiV04cnuOM+663FLX7mJWcu8em6KUgdS1ZznwzPaPaKMRXACRvyFnLZqnkV/A1+RFC7Su+k15CeIBtCwe4jQlDzRzC0oWWN6C7cS8SAihAqA9P/22ZVaBh3uCnj2MAKe+orH1Q0mFxRt17Fw/XU2uVljxLtGdDL3EC/7Nxj3su/tK2TihVUZ/ppyUnBw==
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; 
 bh=7GZgne5FwO1ef3gngjgcrDp7Er8qV1RU8/y7M0DI2gA=;
 b=fM6Xn7HcdZMPswLNhUGnsK0/roV37Z5V1Aq+nhBUhIfC741q9Ul3ZIwAwcpWZ5e/P755dw2KMtPKM2WZ9GVw5OU78Nk2/k2nWeIUlgimdIV40zE8Vtjuc4MxQjJhv2vT4so9VtbwnnJaN3yabO0YFMGTyey8gJAWVq/LQUCSjC9sMWR2WjBPm17YDoqflGqZC/Vt5vVsNh7824lZwkmyJdkF9PgxNcDnHOEcObQyWrkka93TBpDcHCxlfBPHze1owOWS4QCesH9j2YXN0UBMPUxNNl2/33KfzuhAGs0n2klsBT5TyLfgdw0dtu7ATeeUEQ+/8GQleHuLHKzcoRBv7w==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is
 216.228.112.34) smtp.rcpttodomain=intel.com smtp.mailfrom=nvidia.com;
 dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; 
 dkim=none (message not signed); arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com;
 s=selector2;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=7GZgne5FwO1ef3gngjgcrDp7Er8qV1RU8/y7M0DI2gA=;
 b=bRX8JAB/XliQhUNikqqOT5r0TTpQYaLH1v7+zdo3yf6N/PNRhvsEy3EiqhWb3vX3MX0oCM3ZXU1e/M0ugLAqOzSv7gxIVIoGknqabw6Rzk+hOSZj6DrUmg7bpOfn1cRr8FyqRJ7tRSP9p5l8F7j0SbxwzjKRq8lkFvYaHf16D71qLoQWykqtCzFE60hIEbJQEKTUeFSVcPvlsAbGvnRXwnpwmlfOUn0kvEPB8qHmyJ6qW38D2ew89pkZi/aDWbcqIdKh35RfdrpW259gZ4l275Hs4mxjafcTbWMj86b85F+ZxXI/J3aw/fh+uQ75RzPyTGlCsVL6G5aYw8yO3nacHA==
Received: from BN0PR03CA0054.namprd03.prod.outlook.com (2603:10b6:408:e7::29)
 by MW2PR12MB2425.namprd12.prod.outlook.com (2603:10b6:907:f::26) with
 Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19; Fri, 3 Sep
 2021 07:30:23 +0000
Received: from BN8NAM11FT019.eop-nam11.prod.protection.outlook.com
 (2603:10b6:408:e7:cafe::57) by BN0PR03CA0054.outlook.office365.com
 (2603:10b6:408:e7::29) with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19 via Frontend
 Transport; Fri, 3 Sep 2021 07:30:23 +0000
X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34)
 smtp.mailfrom=nvidia.com; intel.com; dkim=none (message not signed)
 header.d=none;intel.com; dmarc=pass action=none header.from=nvidia.com;
Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates
 216.228.112.34 as permitted sender) receiver=protection.outlook.com;
 client-ip=216.228.112.34; helo=mail.nvidia.com;
Received: from mail.nvidia.com (216.228.112.34) by
 BN8NAM11FT019.mail.protection.outlook.com (10.13.176.158) with Microsoft SMTP
 Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id
 15.20.4478.19 via Frontend Transport; Fri, 3 Sep 2021 07:30:23 +0000
Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com
 (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Fri, 3 Sep
 2021 07:30:17 +0000
From: getelson <getelson@nvidia.com>
To: <dev@dpdk.org>, <getelson@nvidia.com>
CC: <thomas@monjalon.net>, <bernard.iremonger@intel.com>,
 <olivier.matz@6wind.com>, <rasland@nvidia.com>, <matan@nvidia.com>
Date: Fri, 3 Sep 2021 10:30:03 +0300
Message-ID: <20210903073003.31400-1-getelson@nvidia.com>
X-Mailer: git-send-email 2.33.0
In-Reply-To: <20210527152858.13312-1-getelson@nvidia.com>
References: <20210527152858.13312-1-getelson@nvidia.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [172.20.187.5]
X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To
 HQMAIL107.nvidia.com (172.20.187.13)
X-EOPAttributedMessage: 0
X-MS-PublicTrafficType: Email
X-MS-Office365-Filtering-Correlation-Id: b23670e2-fdb1-44d1-9188-08d96eacb104
X-MS-TrafficTypeDiagnostic: MW2PR12MB2425:
X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr
X-Microsoft-Antispam-PRVS: <MW2PR12MB242595F2FCDC73739B233888A5CF9@MW2PR12MB2425.namprd12.prod.outlook.com>
X-MS-Oob-TLC-OOBClassifiers: OLM:901;
X-MS-Exchange-SenderADCheck: 1
X-MS-Exchange-AntiSpam-Relay: 0
X-Microsoft-Antispam: BCL:0;
X-Microsoft-Antispam-Message-Info: bW8eFejT5HvQlhB8Wkdg2bZIYq23MKZVQBTpAZfbIJs1A8BP6uYCisD3A6CQJHRIEod+MKOhGKwDmsTMQAul0yvTsyWn3B/FkaBNEfK5XQAC8mtTeF7Gq2mCsbMSRFOPGAZ8ViAYb4U+pAMrv6UHR1cBky65O5j0O0OVBP1tXLEMw8rCiVp/+BRzTZXbr1/sRBu+efVtsoDGHOyGvsLwtiwQYbopwMq4d2xaM34F+Z+//cEnJPTPzN+4Sx+/hQpkUyPkoiQ9Hw4KSz1+B3KlOI13pUNk853/KmuhvOal/ApOZpavxReG2B8oPK7z4xsUBXD6JvmDoS1Jm1NJPJkjoK8k0TO0Apl/X6GoqAO8hZlPT3dgSlNxkRmezijdtLXKSaAhDQu3vEWKZJeOPnTRpb+7EtrF4V/AVHi0JBCKcEvP03V2Rnb9UHmmkY8smrdwHNnnBr5Gd30I33hP+opt/EzmBNRx66vKwpKRcffFbqB0WnHDTR3qJLi8Z9eEpZPg2IGQ5jyqZSNzOpUSZlAt9mXh5lCXyOUTSnTwCTHKiilvzKNhP8PPxdVGpsuACKs6DuizStKoWOCah3jT/sNnhDdO6Q6NHwKYnncbJjrfhgbwajpjsEnOHET21p/m815Y0IN2eeq3YDbz+pbRSen6yXOZZJOrpJ+JX0IJPPjG6YO/dDp6dOmPQH3OPalYrsKLPI0mrf1x4n/N4lT3wPt87A==
X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:;
 IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE;
 SFS:(4636009)(39860400002)(136003)(376002)(346002)(396003)(36840700001)(46966006)(8676002)(8936002)(16526019)(186003)(107886003)(356005)(110136005)(36756003)(336012)(82740400003)(83380400001)(36906005)(4326008)(55016002)(7636003)(54906003)(5660300002)(82310400003)(2616005)(26005)(426003)(47076005)(70206006)(478600001)(7049001)(70586007)(36860700001)(2906002)(6666004)(7696005)(86362001)(6286002)(316002)(1076003);
 DIR:OUT; SFP:1101; 
X-OriginatorOrg: Nvidia.com
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Sep 2021 07:30:23.1313 (UTC)
X-MS-Exchange-CrossTenant-Network-Message-Id: b23670e2-fdb1-44d1-9188-08d96eacb104
X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a
X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34];
 Helo=[mail.nvidia.com]
X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT019.eop-nam11.prod.protection.outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Anonymous
X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem
X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR12MB2425
Subject: [dpdk-dev] [PATCH v2] net: introduce IPv4 ihl and version fields
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
Sender: "dev" <dev-bounces@dpdk.org>

From: Gregory Etelson <getelson@nvidia.com>

RTE IPv4 header definition combines the `version' and `ihl'  fields
into a single structure member.
This patch introduces dedicated structure members for both `version'
and `ihl' IPv4 fields. Separated header fields definitions allow to
create simplified code to match on the IHL value in a flow rule.
The original `version_ihl' structure member is kept for backward
compatibility.

Signed-off-by: Gregory Etelson <getelson@nvidia.com>

Depends-on: f7383e7c7ec1 ("net: announce changes in IPv4 header access")
---
v2: add dependency
---
 app/test/test_flow_classify.c |  8 ++++----
 lib/net/rte_ip.h              | 16 +++++++++++++++-
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/app/test/test_flow_classify.c b/app/test/test_flow_classify.c
index 951606f248..4f64be5357 100644
--- a/app/test/test_flow_classify.c
+++ b/app/test/test_flow_classify.c
@@ -95,7 +95,7 @@ static struct rte_acl_field_def ipv4_defs[NUM_FIELDS_IPV4] = {
  *  dst mask 255.255.255.00 / udp src is 32 dst is 33 / end"
  */
 static struct rte_flow_item_ipv4 ipv4_udp_spec_1 = {
-	{ 0, 0, 0, 0, 0, 0, IPPROTO_UDP, 0,
+	{ { .version_ihl = 0}, 0, 0, 0, 0, 0, IPPROTO_UDP, 0,
 	  RTE_IPV4(2, 2, 2, 3), RTE_IPV4(2, 2, 2, 7)}
 };
 static const struct rte_flow_item_ipv4 ipv4_mask_24 = {
@@ -131,7 +131,7 @@ static struct rte_flow_item  end_item = { RTE_FLOW_ITEM_TYPE_END,
  *  dst mask 255.255.255.00 / tcp src is 16 dst is 17 / end"
  */
 static struct rte_flow_item_ipv4 ipv4_tcp_spec_1 = {
-	{ 0, 0, 0, 0, 0, 0, IPPROTO_TCP, 0,
+	{ { .version_ihl = 0}, 0, 0, 0, 0, 0, IPPROTO_TCP, 0,
 	  RTE_IPV4(1, 2, 3, 4), RTE_IPV4(5, 6, 7, 8)}
 };
 
@@ -150,8 +150,8 @@ static struct rte_flow_item  tcp_item_1 = { RTE_FLOW_ITEM_TYPE_TCP,
  *  dst mask 255.255.255.00 / sctp src is 16 dst is 17/ end"
  */
 static struct rte_flow_item_ipv4 ipv4_sctp_spec_1 = {
-	{ 0, 0, 0, 0, 0, 0, IPPROTO_SCTP, 0, RTE_IPV4(11, 12, 13, 14),
-	RTE_IPV4(15, 16, 17, 18)}
+	{ { .version_ihl = 0}, 0, 0, 0, 0, 0, IPPROTO_SCTP, 0,
+	RTE_IPV4(11, 12, 13, 14), RTE_IPV4(15, 16, 17, 18)}
 };
 
 static struct rte_flow_item_sctp sctp_spec_1 = {
diff --git a/lib/net/rte_ip.h b/lib/net/rte_ip.h
index 05948b69b7..ee6ec67f5d 100644
--- a/lib/net/rte_ip.h
+++ b/lib/net/rte_ip.h
@@ -38,7 +38,21 @@ extern "C" {
  * IPv4 Header
  */
 struct rte_ipv4_hdr {
-	uint8_t  version_ihl;		/**< version and header length */
+	__extension__
+	union {
+		uint8_t version_ihl;    /**< version and header length */
+		struct {
+#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
+			uint8_t ihl:4;
+			uint8_t version:4;
+#elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN
+			uint8_t version:4;
+			uint8_t ihl:4;
+#else
+#error "setup endian definition"
+#endif
+		};
+	};
 	uint8_t  type_of_service;	/**< type of service */
 	rte_be16_t total_length;	/**< length of packet */
 	rte_be16_t packet_id;		/**< packet ID */
-- 
2.33.0