From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26338C48BC1 for ; Wed, 14 Feb 2024 20:16:13 +0000 (UTC) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 29EED43346; Wed, 14 Feb 2024 21:16:13 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 956C942E9F for ; Wed, 14 Feb 2024 21:16:11 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id DFD6F207F207; Wed, 14 Feb 2024 12:16:10 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com DFD6F207F207 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707941770; bh=Zi3J7ip8spRMkAoBvmKObxvfuuw8Z1wTYhorPPoMtyg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=n3aVFfNQRZA7P3HXJKSJAjXjGpECW24tYfWj3jOx1n31RL0yBShn/HhSHIcXacM+L rRNGG5nBo5sIY5uO8DzxBKnWL68VBVnOx2+HCLXML/95LC7H6U2HTiVZmMcQkvdRK0 g1EkOd10h5iV94Pw3ePfV6SPyR2TYAsKI1+xxvOc= Date: Wed, 14 Feb 2024 12:16:10 -0800 From: Tyler Retzlaff To: Morten =?iso-8859-1?Q?Br=F8rup?= Cc: dev@dpdk.org, Andrew Boyer , Andrew Rybchenko , Bruce Richardson , Chenbo Xia , Konstantin Ananyev , Maxime Coquelin Subject: Re: [PATCH v3] mbuf: deprecate GCC marker in rte mbuf struct Message-ID: <20240214201610.GA18474@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <1706657173-26166-2-git-send-email-roretzla@linux.microsoft.com> <1707867209-1901-1-git-send-email-roretzla@linux.microsoft.com> <1707867209-1901-2-git-send-email-roretzla@linux.microsoft.com> <98CBD80474FA8B44BF855DF32C47DC35E9F216@smartserver.smartshare.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35E9F216@smartserver.smartshare.dk> User-Agent: Mutt/1.5.21 (2010-09-15) 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 Wed, Feb 14, 2024 at 11:46:01AM +0100, Morten Brørup wrote: > > From: Tyler Retzlaff [mailto:roretzla@linux.microsoft.com] > > Sent: Wednesday, 14 February 2024 00.33 > > > > Provide a macro that allows conditional expansion of RTE_MARKER fields > > to empty to allow rte_mbuf to be used with MSVC. It is proposed that > > we announce the fields to be __rte_deprecated (currently disabled). > > > > Introduce C11 anonymous unions to permit aliasing of well-known > > offsets by name into the rte_mbuf structure by a *new* name and to > > provide padding for cache alignment. > > > > Signed-off-by: Tyler Retzlaff > > --- > > I think you are nearly there now. Beautiful solution. :-) > > Only one comment inline below. > > > - /* remaining bytes are set on RX when pulling packet from > > descriptor */ > > - RTE_MARKER rx_descriptor_fields1; > > + uint64_t ol_flags; /**< Offload features. */ > > > > - /* > > - * The packet type, which is the combination of outer/inner L2, > > L3, L4 > > - * and tunnel types. The packet_type is about data really present > > in the > > - * mbuf. Example: if vlan stripping is enabled, a received vlan > > packet > > - * would have RTE_PTYPE_L2_ETHER and not RTE_PTYPE_L2_VLAN > > because the > > - * vlan is stripped from the data. > > - */ > > - union { > > - uint32_t packet_type; /**< L2/L3/L4 and tunnel information. > > */ > > - __extension__ > > - struct { > > - uint8_t l2_type:4; /**< (Outer) L2 type. */ > > - uint8_t l3_type:4; /**< (Outer) L3 type. */ > > - uint8_t l4_type:4; /**< (Outer) L4 type. */ > > - uint8_t tun_type:4; /**< Tunnel type. */ > > + /* remaining bytes are set on RX when pulling packet > > from descriptor */ > > + __rte_marker(RTE_MARKER, rx_descriptor_fields1); > > union { > > - uint8_t inner_esp_next_proto; > > - /**< ESP next protocol type, valid if > > - * RTE_PTYPE_TUNNEL_ESP tunnel type is set > > - * on both Tx and Rx. > > - */ > > - __extension__ > > + char mbuf_rx_descriptor_fields1[sizeof(void > > *)]; > > The size of the mbuf_rx_descriptor_fields1 array - and the union it belongs to - may not be accurate. yeah, i just cloned the type out of the marker. but you are right it's garbage. on 32-bit platforms access via that union member probably falls into undefined behavior territory. i'll replace it with [8] since that's the size of the struct member, at least then it's as big as the other union fields. i think my greatest concern at this point is making a mistake in adapting the in-tree consumers to the new field that assumed the named thing was void *[]. sometimes the address is taken, sometimes not, might be okay since we're consistently using arrays now but it will likely need some casts where previously didn't. definitely appreciate careful review. thanks > > The existing rx_descriptor_fields1 effectively has no type/size, and the associated comment "/* remaining bytes are set on RX" doesn't help; it omits how many bytes it refers to. I'll call it "an already existing bug" for the sake of discussion. > I think the struct should go all the way to the pool pointer, to reflect which "remaining bytes" are set on RX. > You might consider taking the opportunity to fix this existing "bug", i.e. update the comment and move more fields into the struct unionized with the mbuf_rx_descriptor_fields1 array. (This suggestion is in the category NICE TO HAVE, and certainly not a requirement!) > > Regardless if you fix this existing "bug" or not, the size of the mbuf_rx_descriptor_fields1 array should match the size of the struct it is unionized with, rather than using sizeof(void*) (which is either 4 or 8 bytes, depending on CPU architecture). > Instinctively, I think that it is a bad idea to carry over the "sizeless" aspect of the rx_descriptor_fields1 marker into the mbuf_rx_descriptor_fields1 array. However, you have been working more in depth with this patch series, so I'm open for arguments for the way you did it! > > > struct { > > - uint8_t inner_l2_type:4; > > - /**< Inner L2 type. */ > > - uint8_t inner_l3_type:4; > > - /**< Inner L3 type. */ > > + /* > > + * The packet type, which is the > > combination of outer/inner L2, L3, L4 > > + * and tunnel types. The packet_type is > > about data really present in the > > + * mbuf. Example: if vlan stripping is > > enabled, a received vlan packet > > + * would have RTE_PTYPE_L2_ETHER and not > > RTE_PTYPE_L2_VLAN because the > > + * vlan is stripped from the data. > > + */ > > + union { > > + uint32_t packet_type; /**< L2/L3/L4 > > and tunnel information. */ > > + __extension__ > > + struct { > > + uint8_t l2_type:4; /**< > > (Outer) L2 type. */ > > + uint8_t l3_type:4; /**< > > (Outer) L3 type. */ > > + uint8_t l4_type:4; /**< > > (Outer) L4 type. */ > > + uint8_t tun_type:4; /**< > > Tunnel type. */ > > + union { > > + uint8_t > > inner_esp_next_proto; > > + /**< ESP next protocol > > type, valid if > > + * RTE_PTYPE_TUNNEL_ESP > > tunnel type is set > > + * on both Tx and Rx. > > + */ > > + __extension__ > > + struct { > > + uint8_t > > inner_l2_type:4; > > + /**< Inner L2 > > type. */ > > + uint8_t > > inner_l3_type:4; > > + /**< Inner L3 > > type. */ > > + }; > > + }; > > + uint8_t inner_l4_type:4; /**< > > Inner L4 type. */ > > + }; > > + }; > > + uint32_t pkt_len; /**< Total pkt > > len: sum of all segments. */ > > }; > > }; > > - uint8_t inner_l4_type:4; /**< Inner L4 type. */ > > - }; > > - }; > > > > - uint32_t pkt_len; /**< Total pkt len: sum of all > > segments. */ > > - uint16_t data_len; /**< Amount of data in segment buffer. > > */ > > - /** VLAN TCI (CPU order), valid if RTE_MBUF_F_RX_VLAN is set. */ > > - uint16_t vlan_tci; > > + uint16_t data_len; /**< Amount of data in > > segment buffer. */ > > + /** VLAN TCI (CPU order), valid if RTE_MBUF_F_RX_VLAN > > is set. */ > > + uint16_t vlan_tci; > > > > - union { > > - union { > > - uint32_t rss; /**< RSS hash result if RSS enabled > > */ > > - struct { > > + union { > > union { > > + uint32_t rss; /**< RSS hash result if > > RSS enabled */ > > struct { > > - uint16_t hash; > > - uint16_t id; > > - }; > > - uint32_t lo; > > - /**< Second 4 flexible bytes */ > > - }; > > - uint32_t hi; > > - /**< First 4 flexible bytes or FD ID, dependent > > - * on RTE_MBUF_F_RX_FDIR_* flag in ol_flags. > > - */ > > - } fdir; /**< Filter identifier if FDIR enabled */ > > - struct rte_mbuf_sched sched; > > - /**< Hierarchical scheduler : 8 bytes */ > > - struct { > > - uint32_t reserved1; > > - uint16_t reserved2; > > - uint16_t txq; > > - /**< The event eth Tx adapter uses this field > > - * to store Tx queue id. > > - * @see rte_event_eth_tx_adapter_txq_set() > > - */ > > - } txadapter; /**< Eventdev ethdev Tx adapter */ > > - uint32_t usr; > > - /**< User defined tags. See rte_distributor_process() > > */ > > - } hash; /**< hash information */ > > - }; > > + union { > > + struct { > > + uint16_t hash; > > + uint16_t id; > > + }; > > + uint32_t lo; > > + /**< Second 4 flexible bytes > > */ > > + }; > > + uint32_t hi; > > + /**< First 4 flexible bytes or FD > > ID, dependent > > + * on RTE_MBUF_F_RX_FDIR_* flag in > > ol_flags. > > + */ > > + } fdir; /**< Filter identifier if > > FDIR enabled */ > > + struct rte_mbuf_sched sched; > > + /**< Hierarchical scheduler : 8 bytes */ > > + struct { > > + uint32_t reserved1; > > + uint16_t reserved2; > > + uint16_t txq; > > + /**< The event eth Tx adapter uses > > this field > > + * to store Tx queue id. > > + * @see > > rte_event_eth_tx_adapter_txq_set() > > + */ > > + } txadapter; /**< Eventdev ethdev Tx > > adapter */ > > + uint32_t usr; > > + /**< User defined tags. See > > rte_distributor_process() */ > > + } hash; /**< hash information > > */ > > + }; > > > > - /** Outer VLAN TCI (CPU order), valid if RTE_MBUF_F_RX_QINQ is > > set. */ > > - uint16_t vlan_tci_outer; > > + /** Outer VLAN TCI (CPU order), valid if > > RTE_MBUF_F_RX_QINQ is set. */ > > + uint16_t vlan_tci_outer; > > > > - uint16_t buf_len; /**< Length of segment buffer. */ > > + uint16_t buf_len; /**< Length of segment > > buffer. */ > > > > - struct rte_mempool *pool; /**< Pool from which mbuf was > > allocated. */ > > + struct rte_mempool *pool; /**< Pool from which mbuf > > was allocated. */ > > + }; > > + }; > > > > /* second cache line - fields only used in slow path or on TX */