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 188F7A0C4C; Mon, 4 Oct 2021 10:46:32 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BA4A2412E3; Mon, 4 Oct 2021 10:46:31 +0200 (CEST) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2051.outbound.protection.outlook.com [40.107.243.51]) by mails.dpdk.org (Postfix) with ESMTP id 79288412E1 for ; Mon, 4 Oct 2021 10:46:30 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fH8REQ0DQLCSsnDGs4hBmcZf3P60Y7vsnFImWZl9KAwV+rU2mUIv3g3ihR707WekjmwsKa+rJ4RBlQ9CyBnvlr1nsTFq8k0Zlatur/9P+qTf3MJi/Re4QWuXb3c8+eN5vjVNrU/1tyVyS47J/P07NOo83imdqMLUZEZXY1Fboxryh5OM77JHg1V95bLu70esdg/LIo6mYNhvDDS8q1pjimBbyrrkaTcmTKKgIG2ohs3LQYBpmLZqys2c9QZI9wxXijbUUiPAsVRSYDbkNPHlKOTdntKdkqxbkqml5OilacOPhdfgIOL2Fb1tmAF0RuyGLj68GvVYYS6JMFxPQI5R7A== 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=E7s7KlIrj+3v5iYCCkhx8S1zk1q0thwncl2ASANxfpY=; b=F6kMo5IW6KXh6Y3UcEwldLC1/bM+YgOqJWWo1GH3e7sqjXJZ4iqn0v4KIbiCX8bkyBs8EqKhO/Ab9JcA9ceg7nomvF5erqryInv6uOEhBAeDanrvg7FnNEwskznQiNTkAv7Pz//CBuQ2Ps2nQ9wUDgSCImbRI5eCcVwHpwi52d9gepk3L5OeySb8JpJmqGL1qXVRr3ClINULFP68K2to3O8wh9XzrxCm1pmacI8KlZNtywtZZUisvbwNdth/YMEj4kTPnKW6jFy79frSaRrQKX1Tz35PBGAGbViQY9PBVGcUhC2UKp28DLD4UgdL4Jag9wDhQNZVcPYfmH4Zk1IeTw== 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=E7s7KlIrj+3v5iYCCkhx8S1zk1q0thwncl2ASANxfpY=; b=lsT6QbZZJg7soPocMUtRiaQ0uOsT5v5QqLWEQELDOL6RYTMyAEfWdGbSxIXC9yEvVRFOazB9Xd8Y8F8y2CPwrNGF6wNAWORBOiUw2TWLWm75qdG3xiKhzQ52qd4KL7rKhfW6nGWwFAm6wDvw6N2dCikFBZVWBzyPUTOJ3yMaPnPzRgJzeTpOVTE1JgooKKlf1Pd52nvEZ11TX2fbuQN1tKiw2LEp00w714uUEjWLCXwnhWHZZcS7JqDq0tJ3nPk5HnyucKPw25Vf4FoqfJup0aBQCqgjjWLKhuVMlAzDbm4SRWROLJzvnS5jMa97Umnc8dqs5I3DWJd7qnEYFu5B6A== Received: from MW4PR03CA0337.namprd03.prod.outlook.com (2603:10b6:303:dc::12) by DM6PR12MB4731.namprd12.prod.outlook.com (2603:10b6:5:35::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13; Mon, 4 Oct 2021 08:46:28 +0000 Received: from CO1NAM11FT011.eop-nam11.prod.protection.outlook.com (2603:10b6:303:dc:cafe::4) by MW4PR03CA0337.outlook.office365.com (2603:10b6:303:dc::12) 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 08:46:28 +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 CO1NAM11FT011.mail.protection.outlook.com (10.13.175.186) 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 08:46:27 +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 08:46:25 +0000 From: Gregory Etelson To: , CC: , , , , Bernard Iremonger Date: Mon, 4 Oct 2021 11:46:08 +0300 Message-ID: <20211004084608.22181-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: 0087847f-552b-4b6a-b981-08d98713749e X-MS-TrafficTypeDiagnostic: DM6PR12MB4731: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: 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: +lGwodFKv4LDRFzMZusySZKgawUTpxwDQDQTBcP3lI5dnTniNYpzSELPp5IM9MpV5jcr8+wArqZCErBpii72/MsXtZHsK4bTGExtIcP4LyQCNiCpNsZqhERsBfpNPt60ZbxeXejqiN5Qr3Xv7Of4oWLwSyZwL9JJFWHFqE00HF7plZI+UrrPQ3XsHUVDm649XCqUo0OpLQR990QQOk8ntgfZrIvsrsFEpepoWakke3s0YTV6GA6h3pUJCjn62IMI5cHYmb064P2QV2Gq5lvtq1XeADzGYt/ZdGhzQ1Q0QxdnUNoVgeycG/DpOqauDjZDyY8GB3x5J/yOI6A1VcTJM02nT/JIIXI1NL2giZRMetYQ/G4zArAx+LVdeZp20cNBgoeZuiz9uUhNhqaZKdnU2/gOzxokt8LGfQkw5W59SSio3P0d3NAm7KZU083ECW/pmqUKb804zO0WyissN+EQkhZ1yuJs1kPbE8UDS+4YS+2uqYfQvlsOkWMLwhWcBm+h8avci582G4QR3zDzRYDHHiJOuoCkeTHKj+EHOTtf+o/er5P0FbkqRwNFbWvWrcWJjm26UfAEpR4Ue8vMOnzsp4kluzMe0zWzQPwj94A7SjlISH8xv26khvQjlItmDXkdlnTXuBL6z1GFV8cjFF9sBB3xt18+jmRwOnwbAynWkAHGCvBcsNVIJmlKdn14fedj60XPRP2ypJuUxCc7+uWMgA== 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)(36756003)(5660300002)(426003)(110136005)(1076003)(26005)(356005)(7636003)(6666004)(70586007)(70206006)(54906003)(82310400003)(2906002)(6286002)(336012)(16526019)(83380400001)(186003)(86362001)(8676002)(7696005)(8936002)(316002)(47076005)(508600001)(55016002)(2616005)(4326008)(36860700001)(7049001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2021 08:46:27.9285 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0087847f-552b-4b6a-b981-08d98713749e 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: CO1NAM11FT011.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4731 Subject: [dpdk-dev] [PATCH v3] 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. --- 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..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