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 332BAA054F; Tue, 16 Mar 2021 17:58:33 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EAD62406A2; Tue, 16 Mar 2021 17:58:32 +0100 (CET) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 53CA14069F for ; Tue, 16 Mar 2021 17:58:31 +0100 (CET) IronPort-SDR: u2kcpxPa3L/JnqreaySRPBKL0i6vO/EYaScSm9MWecsBtU+c1oCEKOhmuyiZdOKU/D/1COv5Q1 xr5kbAWm/9mQ== X-IronPort-AV: E=McAfee;i="6000,8403,9925"; a="250660423" X-IronPort-AV: E=Sophos;i="5.81,254,1610438400"; d="scan'208";a="250660423" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Mar 2021 09:58:29 -0700 IronPort-SDR: cy3GsXGyY5gzi2b3jqt+YMFODR/T8fskSa6kDqSyIEzUG086lT0pJzaUmj0BKcZO5dyZRQU18N yeySaWpUVNYA== X-IronPort-AV: E=Sophos;i="5.81,254,1610438400"; d="scan'208";a="405601799" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.252.11.157]) ([10.252.11.157]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Mar 2021 09:58:27 -0700 To: Ivan Malov , dev@dpdk.org Cc: Andrew Rybchenko , Andy Moreton , Ori Kam , Thomas Monjalon References: <20210312093143.28186-1-ivan.malov@oktetlabs.ru> <20210312110745.31721-1-ivan.malov@oktetlabs.ru> From: Ferruh Yigit X-User: ferruhy Message-ID: <6018293f-65e5-29cc-a9bf-467db1739ff3@intel.com> Date: Tue, 16 Mar 2021 16:58:23 +0000 MIME-Version: 1.0 In-Reply-To: <20210312110745.31721-1-ivan.malov@oktetlabs.ru> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH v2 01/10] ethdev: reuse header definition in flow pattern item ETH 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 3/12/2021 11:07 AM, Ivan Malov wrote: > One ought to reuse existing header structs in flow items. > This particular item contains non-header fields, so it's > important to keep the header fields in a separate struct. > > Signed-off-by: Ivan Malov > Reviewed-by: Andrew Rybchenko > Reviewed-by: Andy Moreton > --- > lib/librte_ethdev/rte_flow.h | 44 ++++++++++++++++++++++-------------- > 1 file changed, 27 insertions(+), 17 deletions(-) > > diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h > index 669e677e9..96fd93ee1 100644 > --- a/lib/librte_ethdev/rte_flow.h > +++ b/lib/librte_ethdev/rte_flow.h > @@ -728,22 +728,32 @@ static const struct rte_flow_item_raw rte_flow_item_raw_mask = { > * > * Matches an Ethernet header. > * > - * The @p type field either stands for "EtherType" or "TPID" when followed > - * by so-called layer 2.5 pattern items such as RTE_FLOW_ITEM_TYPE_VLAN. In > - * the latter case, @p type refers to that of the outer header, with the > - * inner EtherType/TPID provided by the subsequent pattern item. This is the > - * same order as on the wire. > - * If the @p type field contains a TPID value, then only tagged packets with the > - * specified TPID will match the pattern. > - * The field @p has_vlan can be used to match any type of tagged packets, > - * instead of using the @p type field. > - * If the @p type and @p has_vlan fields are not specified, then both tagged > - * and untagged packets will match the pattern. > + * Inside @p hdr field, the sub-field @p ether_type stands either for EtherType > + * or TPID, depending on whether the item is followed by a VLAN item or not. If > + * two VLAN items follow, the sub-field refers to the outer one, which, in turn, > + * contains the inner TPID in the similar header field. The innermost VLAN item > + * contains a layer-3 EtherType. All of that follows the order seen on the wire. > + * > + * If the field in question contains a TPID value, only tagged packets with the > + * specified TPID will match the pattern. Alternatively, it's possible to match > + * any type of tagged packets by means of the field @p has_vlan rather than use > + * the EtherType/TPID field. Also, it's possible to leave the two fields unused. > + * If this is the case, both tagged and untagged packets will match the pattern. > */ It seems Ivan can do his magic with preexisting text too :) > +RTE_STD_C11 > struct rte_flow_item_eth { > - struct rte_ether_addr dst; /**< Destination MAC. */ > - struct rte_ether_addr src; /**< Source MAC. */ > - rte_be16_t type; /**< EtherType or TPID. */ > + union { > + struct { > + /* > + * These fields are retained for compatibility. > + * Please switch to the new header field below. > + */ > + struct rte_ether_addr dst; /**< Destination MAC. */ > + struct rte_ether_addr src; /**< Source MAC. */ > + rte_be16_t type; /**< EtherType or TPID. */ > + }; > + struct rte_ether_hdr hdr; > + }; > uint32_t has_vlan:1; /**< Packet header contains at least one VLAN. */ > uint32_t reserved:31; /**< Reserved, must be zero. */ > }; > @@ -751,9 +761,9 @@ struct rte_flow_item_eth { > /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */ > #ifndef __cplusplus > static const struct rte_flow_item_eth rte_flow_item_eth_mask = { > - .dst.addr_bytes = "\xff\xff\xff\xff\xff\xff", > - .src.addr_bytes = "\xff\xff\xff\xff\xff\xff", > - .type = RTE_BE16(0x0000), > + .hdr.d_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff", > + .hdr.s_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff", > + .hdr.ether_type = RTE_BE16(0x0000), > }; > #endif > > Reviewed-by: Ferruh Yigit