From f5f45caeb049ea52b6e8fd2abe0a46c204dea533 Mon Sep 17 00:00:00 2001 From: Dan Gora Date: Mon, 18 Jun 2018 16:35:34 -0700 Subject: [PATCH] mbuf: add accessor function for private data area Add an inline accessor function to return the starting address of the private data area in the supplied mbuf. This allows applications to easily access the private data area between the struct rte_mbuf and the data buffer in the specified mbuf without creating private macros or accessor functions. No checks are made to ensure that a private data area actually exists in the buffer. Signed-off-by: Dan Gora Reviewed-by: Andrew Rybchenko Acked-by: Olivier Matz --- lib/librte_mbuf/rte_mbuf.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index 8e6b4d2923..00793edbba 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -728,6 +728,24 @@ rte_mbuf_to_baddr(struct rte_mbuf *md) return buffer_addr; } +/** + * Return the starting address of the private data area embedded in + * the given mbuf. + * + * Note that no check is made to ensure that a private data area + * actually exists in the supplied mbuf. + * + * @param m + * The pointer to the mbuf. + * @return + * The starting address of the private data area of the given mbuf. + */ +static inline void * __rte_experimental +rte_mbuf_to_priv(struct rte_mbuf *m) +{ + return RTE_PTR_ADD(m, sizeof(struct rte_mbuf)); +} + /** * Returns TRUE if given mbuf is cloned by mbuf indirection, or FALSE * otherwise. -- 2.20.1