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 189B3A0C4B; Thu, 14 Oct 2021 20:16:35 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C437240041; Thu, 14 Oct 2021 20:16:34 +0200 (CEST) Received: from mail-io1-f54.google.com (mail-io1-f54.google.com [209.85.166.54]) by mails.dpdk.org (Postfix) with ESMTP id 1CF3F4003C for ; Thu, 14 Oct 2021 20:16:33 +0200 (CEST) Received: by mail-io1-f54.google.com with SMTP id h196so4879589iof.2 for ; Thu, 14 Oct 2021 11:16:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Z5C7FWQV9vllAM8BgHiiqe7aQ52WBBFXZG65onYE/7I=; b=GlIYc0yZLzyBrEthMKWl02qY84AdA5M9W7jdUV17lY1+faRJCvYQAhKGJLZklk9sdw YIQ6SH4F54NEUJX48N05aVgmC61BTLMjS5uOPyhU1i5Wu28n2XMHuEVI4UXMPsp2a4Cb wdgGwtjZT0L40ydFJvGEShrqiZih/3OOEIbt8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Z5C7FWQV9vllAM8BgHiiqe7aQ52WBBFXZG65onYE/7I=; b=Us7dlzmsYlEzBkSrIhj9Oy3W0pEvOP/5kq5tNeE5QJ95+6NHzcFnAs6k+msIu0ZpTg +FbNKEXZlxo+1D+h/byl5L8VNrx67VL6g8sDqgEOyblWQZ8aszR5QRVCIae6kGfoIGvL FrKrGkNrLxp6pkajzp1V3CcLMra41VjQH3LdOSIwv3rMQIWT34iEprtKbOSEoxTmsO+n xqsUdT8JpC4k8FzyvpEs34+rLFFOwKhYIJI27a8S7kc7cRRcJPuZFMZAl1WBNC9EHkIN 5KwDZPUHyB9kDz/BC1F2yNF+biaoS4w54r4VkG0MTK3cKj0R1aOZ/tf1WBQght0XGyDQ SZdQ== X-Gm-Message-State: AOAM530RL6di44do/6pWWSP73Ko4cEtK1LSqsfJuQGgHzfyLeIpynJ8K PGJBKrSWAkPXRLAH1oF9QA4F/fa2oPPiQKnENDw9FQ== X-Google-Smtp-Source: ABdhPJyWpgvVGtZOvuvN/zvN64/0ZmJ9UXfXawb6dASlOF6BDtXM2ksLMNFXMSngQgRSXLgFW5ZEkcVbdGs6eNl4IhM= X-Received: by 2002:a05:6638:3389:: with SMTP id h9mr1221357jav.4.1634235392298; Thu, 14 Oct 2021 11:16:32 -0700 (PDT) MIME-Version: 1.0 References: <20210527152858.13312-1-getelson@nvidia.com> <20211014174113.10237-1-getelson@nvidia.com> <20211014174113.10237-3-getelson@nvidia.com> In-Reply-To: <20211014174113.10237-3-getelson@nvidia.com> From: Ajit Khaparde Date: Thu, 14 Oct 2021 11:16:15 -0700 Message-ID: To: Gregory Etelson Cc: dpdk-dev , Matan Azrad , Raslan Darawsheh , Olivier Matz , Thomas Monjalon , Ferruh Yigit , Ray Kinsella , Bernard Iremonger Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-dev] [PATCH v7 2/2] 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" On Thu, Oct 14, 2021 at 10:42 AM Gregory Etelson wrote: > > 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 > Acked-by: Olivier Matz > Acked-by: Ray Kinsella Acked-by: Ajit Khaparde > --- > v2: Add dependency. > v3: Add comments. > v4: Update release notes. > v5: Remove deprecation notice. > Update the patch comment. > v6: split the patch into 2 parts: > 1: update the announce. > 2: implement the IPv4 header changes. > v7: Remove `#else`. > --- > app/test/test_flow_classify.c | 8 ++++---- > doc/guides/rel_notes/deprecation.rst | 3 --- > doc/guides/rel_notes/release_21_11.rst | 3 +++ > lib/net/rte_ip.h | 14 +++++++++++++- > 4 files changed, 20 insertions(+), 8 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/deprecation.rst b/doc/guides/rel_notes/deprecation.rst > index 841653fe30..d1f3faac39 100644 > --- a/doc/guides/rel_notes/deprecation.rst > +++ b/doc/guides/rel_notes/deprecation.rst > @@ -158,9 +158,6 @@ Deprecation Notices > consistent with existing outer header checksum status flag naming, which > should help in reducing confusion about its usage. > > -* net: The structure ``rte_ipv4_hdr`` will have a union for > - existing ``version_ihl`` byte and new bitfield for ``version`` and ``ihl``. > - > * vhost: ``rte_vdpa_register_device``, ``rte_vdpa_unregister_device``, > ``rte_vhost_host_notifier_ctrl`` and ``rte_vdpa_relay_vring_used`` vDPA > driver interface will be marked as internal in DPDK v21.11. > diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst > index e1726774ba..fa60fd9a85 100644 > --- a/doc/guides/rel_notes/release_21_11.rst > +++ b/doc/guides/rel_notes/release_21_11.rst > @@ -216,6 +216,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 b3d45e85db..0ef2430607 100644 > --- a/lib/net/rte_ip.h > +++ b/lib/net/rte_ip.h > @@ -39,7 +39,19 @@ 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 */ > +#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 >