From: Dan Gora Date: Mon, 18 Jun 2018 23:35:34 +0000 (-0700) Subject: mbuf: add accessor function for private data area X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=f5f45caeb049ea52b6e8fd2abe0a46c204dea533;p=dpdk.git 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 --- 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.