[v5,06/22] mbuf: add mbuf descriptor accessors

Message ID 1708762927-14126-7-git-send-email-roretzla@linux.microsoft.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series stop using RTE_MARKER extensions |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Tyler Retzlaff Feb. 24, 2024, 8:21 a.m. UTC
  Provide inline functions to access rearm data and rx descriptor fields
in rte_mbuf struct.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 lib/mbuf/rte_mbuf.h | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
  

Comments

Thomas Monjalon Feb. 24, 2024, 11:01 a.m. UTC | #1
24/02/2024 09:21, Tyler Retzlaff:
> Provide inline functions to access rearm data and rx descriptor fields
> in rte_mbuf struct.
[...]
> +static inline
> +uint64_t *
> +rte_mbuf_rearm_data(struct rte_mbuf *m)
> +{
> +	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, ol_flags) !=
> +			 offsetof(struct rte_mbuf, data_off) + 8);
> +	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, rearm_data) !=
> +			 RTE_ALIGN(offsetof(struct rte_mbuf,
> +					    data_off),
> +					    16));
> +
> +	return (uint64_t *)&m->data_off;
> +}
> +
> +static inline
> +void *
> +rte_mbuf_rx_descriptor_fields1(struct rte_mbuf *m)
> +{
> +	return &m->packet_type;
> +}

We need to enforce usage of these accessors.
Please add these 2 things:
1/ comments in the mbuf structure to encourage using these functions
2/ checkpatch warning if using the markers directly in new code
  

Patch

diff --git a/lib/mbuf/rte_mbuf.h b/lib/mbuf/rte_mbuf.h
index 04cde0f..7993730 100644
--- a/lib/mbuf/rte_mbuf.h
+++ b/lib/mbuf/rte_mbuf.h
@@ -136,6 +136,26 @@ 
 #endif
 }
 
+static inline
+uint64_t *
+rte_mbuf_rearm_data(struct rte_mbuf *m)
+{
+	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, ol_flags) !=
+			 offsetof(struct rte_mbuf, data_off) + 8);
+	RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, rearm_data) !=
+			 RTE_ALIGN(offsetof(struct rte_mbuf,
+					    data_off),
+					    16));
+
+	return (uint64_t *)&m->data_off;
+}
+
+static inline
+void *
+rte_mbuf_rx_descriptor_fields1(struct rte_mbuf *m)
+{
+	return &m->packet_type;
+}
 
 static inline uint16_t rte_pktmbuf_priv_size(struct rte_mempool *mp);