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 BBB28A0C4D; Mon, 4 Oct 2021 14:13:48 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3C34D4135E; Mon, 4 Oct 2021 14:13:48 +0200 (CEST) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1anam02on2057.outbound.protection.outlook.com [40.107.96.57]) by mails.dpdk.org (Postfix) with ESMTP id 1F1B0410D7 for ; Mon, 4 Oct 2021 14:13:47 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oKUCqMdcqUKB1RIGGRg+x37O6olU0LAgeQ+DHdqb8J7xPZzUX84gZEBn3PBsts4IREyDJ4THqs1IN1wdi2wd5K2LXHjDuVGXMLuI3zUfE+QbwpzAf+TQqM8HKomLeyvVkq7NuDUSe7iNAjxpaaU0cE3JNlc113NDSUopNOzqkmWbDwE6jNkKlOeZwwy5lXOditEpSTRrlCg5yVcJd0HvnSFH9OUM9PGUqYFuNIfmSw+uwmT0OtWy0tipRxjAVrnWW+OEPL3kYRJm07Y3qGQuwCsZDS8Qq3MlVyQqS0o2E6Q3tOq9S2iquGgsHjPp8eZewcTeMdihYi4kTB8622zW8A== 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=+0u1EWlFKI9C4uNMXmB0PUQ4WXG078lckKqlXfoKAjE=; b=e5Ey+2cE+Wz5E6WAtv7IhJgRsYPil9BXz77IHxSIo66m2CPkk9ngcH3kaEtoGvlcHuKyBNI4bebp6OPTu3mBU0mp8mrV3eGIT/uWK5Ab1CLiMmffh/sxgydjCZCQc7BetgnZmgyGieF46/pwnuyP50f+Pew7iQSPkDGN/6sBUD4tLPIswL+6ZdsJK+KybmlOZIm1CJyVny7Hk9DGZQmuPGU/6hkc0YyWZWda4OO102puwmJCKNBG7wO+4g57h7xXDSHnDDhO9EcNfmqf+gAuy3Lh9XGx8IUmy8+YmUeNaY1fN9ZhoUguj5vCPzGgAMdxO3C9uez1apsxUImsovmrng== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=monjalon.net 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=+0u1EWlFKI9C4uNMXmB0PUQ4WXG078lckKqlXfoKAjE=; b=OBya31amIfv7mCs9Ls7gKt30n42Ux5or54DURwcynMoxoeqUHFK82OOw9fjSk6bc6H9C+vhM4cTuvonBqCulmARTivCUGcLoHAq0ZpysCCb+teY5nlAk6ciIBbUJeC00apwnNw58W/oqrJoBxHg3YjbD77118Q3amnaluCUIfz3jiOHSj3Dr1vKqF6cWthnAygKGDMubSmOg/BszXEO0mYEhj/TH/Kofx23lsshaHx5Q1aJzJFZP2NFxfUuzZO26639Deg90x01UroNBe7g44B4vxXyfooUlvG8obqIHGdBErCxdZZy5JDmZXFe4mHEvELQcroZIfibfq3Ufwk/Zrw== Received: from MW4PR03CA0162.namprd03.prod.outlook.com (2603:10b6:303:8d::17) by CH2PR12MB3656.namprd12.prod.outlook.com (2603:10b6:610:15::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.19; Mon, 4 Oct 2021 12:13:45 +0000 Received: from CO1NAM11FT053.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8d:cafe::57) by MW4PR03CA0162.outlook.office365.com (2603:10b6:303:8d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.17 via Frontend Transport; Mon, 4 Oct 2021 12:13:44 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; monjalon.net; dkim=none (message not signed) header.d=none;monjalon.net; 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 CO1NAM11FT053.mail.protection.outlook.com (10.13.175.63) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4566.14 via Frontend Transport; Mon, 4 Oct 2021 12:13:43 +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; Mon, 4 Oct 2021 12:13:41 +0000 From: Gregory Etelson To: , CC: , , , , Bernard Iremonger Date: Mon, 4 Oct 2021 15:13:22 +0300 Message-ID: <20211004121323.6677-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: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b9f6206b-4637-42bf-0ae8-08d987306911 X-MS-TrafficTypeDiagnostic: CH2PR12MB3656: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1824; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: C1Zu7PUn9tsfHrvISBOiAl3BlBGc65UJnmouvLqGPnwcQHdRWjrKtBgOc3f5f1PFFfPVnmeDL5Cv6EqCvfCDflCkWc+aJMqy4k5LXWEP7DUDX4R6EoBYqBoa4nZvZ7GEAhlcEnRUzPsORCDZBfCedTbqgay6ixzOOrRsRfHS/B5weZmx/hv7ZpheETK9sSKbFlY8Wxg3L0iyQxLMMOiFlioCz6TkLVFvEC+SiHZYjRdC/QYpGtJwXVECDHr56MJda+FwYn3VltTZYneDSScXF879p6qsUaFAZowD5u8D74E5jsMrzZjIPQboGKlk0yjh5O9Sa9387JFV8VYRsMamsE4/L4xlDwBrpEx74OvcXwBuOZLi931Mc7oMNlr0x6tay8PBT06CIgCWhnJyMEOUC1VK60gs0GbJ3e8n7L/X3+xrMZK3FMH1svm7tyaDTbkMo5RO7rKKQVm+sjshMl5prNE86FrQKxoBB+XhYrsp2mqRRu2W+oh+KW8i/+sPQbFm/ozQMcpD9VcjiNQrXSEQUn3eV+bU3kpnRVlAsrAgHobvaW+Q/ilgmlVPqmpv6tcR0D7Djc+U3iE6rAKU38ITTcwUd2+2etxmr5+vUjtNSCeJnt8l+S1poG0m2OWASBHgdLr2DXFHHZ81hVe5g5kDNhIJQSD7ewQyFLPzbOgzutzgV8HQp0Y9ywTHfQlpg9IjrVdOSdfKIcW2dYHQLRM/ug== 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)(36840700001)(46966006)(2616005)(336012)(8936002)(356005)(426003)(5660300002)(70586007)(83380400001)(508600001)(36860700001)(82310400003)(186003)(55016002)(316002)(70206006)(16526019)(86362001)(7696005)(7636003)(8676002)(2906002)(36756003)(4326008)(26005)(1076003)(6286002)(54906003)(7049001)(110136005)(6666004)(47076005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2021 12:13:43.8881 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b9f6206b-4637-42bf-0ae8-08d987306911 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: CO1NAM11FT053.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB3656 Subject: [dpdk-dev] [PATCH v4] 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 Depends-on: f7383e7c7ec1 ("net: announce changes in IPv4 header access") Acked-by: Olivier Matz --- v2: Add dependency. v3: Add comments. v4: Update release notes. --- app/test/test_flow_classify.c | 8 ++++---- doc/guides/rel_notes/release_21_11.rst | 3 +++ lib/net/rte_ip.h | 16 +++++++++++++++- 3 files changed, 22 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/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst index 73e377a007..deab44a92a 100644 --- a/doc/guides/rel_notes/release_21_11.rst +++ b/doc/guides/rel_notes/release_21_11.rst @@ -170,6 +170,9 @@ API Changes the crypto/security operation. This field will be used to communicate events such as soft expiry with IPsec in lookaside mode. +* net: Add ``version`` and ``ihl`` bit-fields to ``struct rte_ipv4_hdr``. + Existing ``version_ihl`` field was kept for backward compatibility. + ABI Changes ----------- diff --git a/lib/net/rte_ip.h b/lib/net/rte_ip.h index 05948b69b7..89a68d9433 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; /**< header length */ + uint8_t version:4; /**< version */ +#elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN + uint8_t version:4; /**< version */ + uint8_t ihl:4; /**< header length */ +#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