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 B54D3A0546; Thu, 27 May 2021 17:29:19 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A50A240150; Thu, 27 May 2021 17:29:19 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2047.outbound.protection.outlook.com [40.107.220.47]) by mails.dpdk.org (Postfix) with ESMTP id A241E40143 for ; Thu, 27 May 2021 17:29:18 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Kx+Nbk5XKqY06dBqWJIj5xhXU+kjm96BLkh1DGQoBWBtlcBEB5xSFdtEMim1gIKwh9dSUqgA8hykLAgLZd6k7s4vvuxdqpH0TVzhRRrXl6URisCgEI5yVbj6u8+Bqa1R3BV8pDbVYuiNsJfLSZ/tKDvG0639Hif4yXByyzMJ9yu/kz8utFN0CDHSS9fR0VbWbqn74OeIMBef7cPPpUKN7IEf3SbuKskRq+IdlCfGJfk5lgeo6iwb1W2Of95Ahu70Gtl8C5xIk4/+jmhZa6NdCplvobUDE4UC4qQzQwOxtj5Zhc4ORJzM0tIbwt2CpMEoYogBNOkAIUFAh3TzZm4ZvQ== 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-SenderADCheck; bh=CoLY08JFusnLPe4T+BTPkF2eK3WW/bbXshgHMC2tUg4=; b=b1PSCeQTsn+Dw+pw3aXZzQ5jcVAIni5dNy54zwzEmpGuXsSwNgYngZ9kUkhujA9OOyNTXNRsDf6yHM0pBNYJOBOqx3+jkrIIbhEnVaBJOIEcc1g5qCcfYA+UMrYECu1oJylo8Rhvt7JQTjIsumSw5CQt1ex2B3e3uFRyZSlXmIciyvad6LabowjDAltCdUeHOzmbbZ4kSO9krdeofSeblREXYwlVZo+so33zI4AHCX654JmpFrnZmYNwkb2wUD5KJd0cngJChBUR7ctytwuhehIBvslwus6yn6UB60YUuqcqJ2m8eb9e4111zCXDwv1ASnYmxG15zyNTCKt9ca6yXQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=6wind.com smtp.mailfrom=nvidia.com; dmarc=pass (p=none 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=CoLY08JFusnLPe4T+BTPkF2eK3WW/bbXshgHMC2tUg4=; b=Gzlbk34+7nI6lw+zHAYuepJNJPE+dOaXme2a2fml3d48hzVWbngm7O84TifBMxivjoQxANNgouhzdkCuzyq/s5hFzOxzlvepRnaQr9KwMw2u9IsHOVESNdlU88N195Y2q90MJ2QsJOm3QfIMJu3IzrmbcWNUyc2y5dzRSlcMepNk+f0oh2kTuj495jeii0HSIbkp5RdWzoLIs1eLqhEF6HCnKFVeFG0mxb1fiu22yZXRNSk84J1a/waufR+kouVySHpgPkFo0GwlsICqHI8+pI6m9gmmhL+Mu35G+yyqfVmvThZS8Qv1R582JPVlVIE8vzQlpAb+wnLYEG1D8faU9A== Received: from BN9PR03CA0290.namprd03.prod.outlook.com (2603:10b6:408:f5::25) by MN2PR12MB4143.namprd12.prod.outlook.com (2603:10b6:208:1d0::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.21; Thu, 27 May 2021 15:29:17 +0000 Received: from BN8NAM11FT006.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f5:cafe::4c) by BN9PR03CA0290.outlook.office365.com (2603:10b6:408:f5::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.22 via Frontend Transport; Thu, 27 May 2021 15:29:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; 6wind.com; dkim=none (message not signed) header.d=none;6wind.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 BN8NAM11FT006.mail.protection.outlook.com (10.13.177.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4129.25 via Frontend Transport; Thu, 27 May 2021 15:29:16 +0000 Received: from nvidia.com (172.20.145.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 27 May 2021 15:29:14 +0000 From: Gregory Etelson To: CC: , , , , Bernard Iremonger , Olivier Matz Date: Thu, 27 May 2021 18:28:58 +0300 Message-ID: <20210527152858.13312-1-getelson@nvidia.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.145.6] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1ea8f58e-b37a-4180-a0c7-08d9212430bb X-MS-TrafficTypeDiagnostic: MN2PR12MB4143: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:758; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CAK9d2tdq29CaVBSbCPQqjmSbtedV2ZMwKfIEsE9UrzPPQn/K5Xj8y874akmvLNQhy9fMVZZmbjsYLKL5u2qHdy82+xokvs5UKgqs+9BsptAOfV4v0M+9kLT+XKT6vdsO8FqzMnxD1zvujHV5sFBzSHMedtRESfY6BkFlOYZfPUdSXqa1sm3J0JSSvpZlNFwH+Yfbjh86ebqa3vreOn6bnC1kHrY6+VBr67ML/rFVxx+oXZabAvUfuA6zvdxUiig8TEmuci+xNSLWkDSm5r8PGc3U1TW9TbJEXrX1VHjslg9aD+YiiZGLfstpw4yq8Ueh8cresvXBas2nwGX5O98MM0cfiGzxs6az33QycNOHg8QA5vr2F85CV76WNad7hXP0+nAepC4MZJh5jiPOBp3rq985SqZiyOXksFsgWFdd94bA8IhtjpBCQ8dn90njU69IHgJ5tlGLZYBjw2lHvEtzpH9av5xy3fPsLBZbGNl1n4/5Y7vepZmZYWLLUcSRJe7PNAG+JJBCniJdOHXpy96ARwpltTFTwi/3vb6EVnjEdRUeu+3SV+ok5zSsMf4SsggAqQSgiU29kB19ggJ5p+D3taHN1tCiHbfGc71ddMNlQLBpap5/pn8ydZM3tyLnqFKqikuVRckMFcvzmK95HwZnQw1mELgScpuXGCLMb1fJoo= 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)(396003)(39860400002)(136003)(376002)(346002)(46966006)(36840700001)(2906002)(5660300002)(478600001)(82310400003)(7696005)(47076005)(6916009)(186003)(16526019)(426003)(7636003)(336012)(36756003)(356005)(6666004)(26005)(70586007)(316002)(82740400003)(6286002)(2616005)(70206006)(36906005)(1076003)(86362001)(8936002)(8676002)(36860700001)(55016002)(4326008)(83380400001)(54906003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 May 2021 15:29:16.8068 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1ea8f58e-b37a-4180-a0c7-08d9212430bb 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: BN8NAM11FT006.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4143 Subject: [dpdk-dev] [PATCH] 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 --- 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 4b728969c1..684bb028b2 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.31.1