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 833904242B; Fri, 20 Jan 2023 10:20:56 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3AAD040150; Fri, 20 Jan 2023 10:20:56 +0100 (CET) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id BF0F3400D5 for ; Fri, 20 Jan 2023 10:20:55 +0100 (CET) Received: from [192.168.38.17] (aros.oktetlabs.ru [192.168.38.17]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id 1289550; Fri, 20 Jan 2023 12:20:55 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 1289550 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1674206455; bh=kT0Syz5Fws6aovNB4CYAvjhL7rrzjbV1hplFJHshRU8=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=fXJ3o0f29/A9xdlRV2nhEd/cTsDQwoUJkVdeP/R8GwIUBSh8BS9KDvygF3/rPGjFi 4haIgTpTwaJxprtspf+cmWEnk8DO2/0z+De+7hc1G1Qbr/idLlParydo4Hkm2oZGPU V/eSkuTvbhjiZItCOO9yK6rI64O6NjPM7yxENeuc= Message-ID: <5da6632a-0976-dc1f-facb-f778c8aad8e6@oktetlabs.ru> Date: Fri, 20 Jan 2023 12:20:54 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: Re: [PATCH v2 1/8] ethdev: add IPv6 routing extension header definition Content-Language: en-US To: Rongwei Liu , matan@nvidia.com, viacheslavo@nvidia.com, orika@nvidia.com, thomas@monjalon.net, Aman Singh , Yuying Zhang , Ferruh Yigit , Olivier Matz Cc: dev@dpdk.org, rasland@nvidia.com References: <20221221084304.3680690-2-rongweil@nvidia.com> <20230119031139.621217-1-rongweil@nvidia.com> <20230119031139.621217-2-rongweil@nvidia.com> From: Andrew Rybchenko Organization: OKTET Labs In-Reply-To: <20230119031139.621217-2-rongweil@nvidia.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 On 1/19/23 06:11, Rongwei Liu wrote: > Add IPv6 routing extension header definition and no > TLV support for now. > > At rte_flow layer, there are new items defined for matching > type/nexthdr/segments_left field. > > Add command line support for IPv6 routing extension header > matching: type/nexthdr/segment_list. > > Signed-off-by: Rongwei Liu > Acked-by: Ori Kam [snip] > diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst > index 3e6242803d..ae99036be0 100644 > --- a/doc/guides/prog_guide/rte_flow.rst > +++ b/doc/guides/prog_guide/rte_flow.rst > @@ -1544,6 +1544,15 @@ Matches Color Marker set by a Meter. > > - ``color``: Metering color marker. > > +Item: ``IPV6_ROUTING_EXT`` > +^^^^^^^^^^^^^^^^^^^^^^^^^^ > + > +Matches ipv6 routing extension header. ipv6 -> IPv6 > + > +- ``next_hdr``: Next layer header type. > +- ``type``: IPv6 routing extension header type. > +- ``segments_left``: How many IPv6 destination addresses carries on Why are only 3 fields mentioned above? > + > Actions > ~~~~~~~ > > diff --git a/doc/guides/rel_notes/release_23_03.rst b/doc/guides/rel_notes/release_23_03.rst > index b8c5b68d6c..2a794d598e 100644 > --- a/doc/guides/rel_notes/release_23_03.rst > +++ b/doc/guides/rel_notes/release_23_03.rst > @@ -55,6 +55,11 @@ New Features > Also, make sure to start the actual text at the margin. > ======================================================= > > +* **Added rte_flow support for matching IPv6 routing extension header fields.** > + > + Added ``ipv6_routing_ext`` items in rte_flow to match IPv6 routing extension > + header Missing full stop above. > + > > Removed Items > ------------- > @@ -84,6 +89,11 @@ API Changes > Also, make sure to start the actual text at the margin. > ======================================================= > > +* ethdev: added a new structure: > + > + - IPv6 routing extension header ``rte_flow_item_ipv6_routing_ext`` and > + ``rte_ipv6_routing_ext`` > + If I'm not mistaken, additions should not be here. It is not an API change. > > ABI Changes > ----------- > diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c > index 7d0c24366c..4074b475c8 100644 > --- a/lib/ethdev/rte_flow.c > +++ b/lib/ethdev/rte_flow.c > @@ -76,6 +76,20 @@ rte_flow_item_flex_conv(void *buf, const void *data) > return src->length; > } > > +static size_t > +rte_flow_item_ipv6_routing_ext_conv(void *buf, const void *data) > +{ > + struct rte_flow_item_ipv6_routing_ext *dst = buf; > + const struct rte_flow_item_ipv6_routing_ext *src = data; > + size_t len; > + > + len = src->hdr.hdr_len ? src->hdr.hdr_len << 3 : src->hdr.segments_left << 4; Compare hdr_len vs 0 explicitly. Also I'd add parenthesis around ternary operator values to make it simpler to understand. > + if (buf) Please, compare vs NULL explicitly. May be 'dst' would be better here? > + rte_memcpy((void *)((uintptr_t)(dst->hdr.segments)), > + src->hdr.segments, len); > + return len; > +} > + > /** Generate flow_item[] entry. */ > #define MK_FLOW_ITEM(t, s) \ > [RTE_FLOW_ITEM_TYPE_ ## t] = { \ > @@ -157,6 +171,8 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { > MK_FLOW_ITEM(L2TPV2, sizeof(struct rte_flow_item_l2tpv2)), > MK_FLOW_ITEM(PPP, sizeof(struct rte_flow_item_ppp)), > MK_FLOW_ITEM(METER_COLOR, sizeof(struct rte_flow_item_meter_color)), > + MK_FLOW_ITEM_FN(IPV6_ROUTING_EXT, sizeof(struct rte_flow_item_ipv6_routing_ext), > + rte_flow_item_ipv6_routing_ext_conv), > }; > > /** Generate flow_action[] entry. */ > diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h > index b60987db4b..0120d3e7d2 100644 > --- a/lib/ethdev/rte_flow.h > +++ b/lib/ethdev/rte_flow.h > @@ -624,6 +624,13 @@ enum rte_flow_item_type { > * See struct rte_flow_item_meter_color. > */ > RTE_FLOW_ITEM_TYPE_METER_COLOR, > + > + /** > + * Matches the presence of IPv6 routing extension header. > + * > + * See struct rte_flow_item_ipv6_routing_ext. @see > + */ > + RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT, > }; > > /** > @@ -873,6 +880,18 @@ struct rte_flow_item_ipv6 { > uint32_t reserved:23; > }; > > +/** > + * @warning > + * @b EXPERIMENTAL: this structure may change without prior notice > + * > + * RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT. > + * > + * Matches an IPv6 routing extension header. > + */ > +struct rte_flow_item_ipv6_routing_ext { > + struct rte_ipv6_routing_ext hdr; > +}; > + What about default mask? > /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */ > #ifndef __cplusplus > static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = { > diff --git a/lib/net/rte_ip.h b/lib/net/rte_ip.h > index 9c8e8206f0..158a2f83ce 100644 > --- a/lib/net/rte_ip.h > +++ b/lib/net/rte_ip.h > @@ -539,6 +539,27 @@ struct rte_ipv6_hdr { > uint8_t dst_addr[16]; /**< IP address of destination host(s). */ > } __rte_packed; > > +/** > + * IPv6 Routing Extension Header > + */ > +struct rte_ipv6_routing_ext { > + uint8_t next_hdr; /**< Protocol, next header. */ > + uint8_t hdr_len; /**< Header length. */ > + uint8_t type; /**< Extension header type. */ > + uint8_t segments_left; /**< Valid segments number. */ > + __extension__ > + union { > + uint32_t flags; rte_be32_t ? > + struct { > + uint8_t last_entry; /**< The last_entry field of SRH */ > + uint8_t flag; /**< Packet flag. */ > + uint16_t tag; /**< Packet tag. */ rte_be16_t > + }; > + }; > + __extension__ > + uint32_t segments[0]; /**< Each hop IPv6 address. */ rte_be32_t > +} __rte_packed; > + > /* IPv6 vtc_flow: IPv / TC / flow_label */ > #define RTE_IPV6_HDR_FL_SHIFT 0 > #define RTE_IPV6_HDR_TC_SHIFT 20