[v5,06/22] mbuf: add mbuf descriptor accessors
Checks
Commit Message
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
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
@@ -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);