Skip to contentSkip to conversation

mbuf: add accessor function for private data area

PATCH In review Dan Gora 4 participants 4 messages Jun 18, 2018 – Jul 13, 2018

lore
Share & tools
lore

Dan Gora

author
#0 lore raw

PATCH v2 1/4 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.

---
 lib/librte_mbuf/rte_mbuf.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
lib/librte_mbuf/rte_mbuf.h +18 -0
index 8e6b4d292..08c58335d 100644
@@ -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 md
+ *   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.
Signature · 1 line
2.18.0.rc1.1.g6f333ff2f
Reviewed-by on v2 1/4
#1 lore raw
Quoted 11 lines · Dan Gora

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.

Acked-by on v2 1/4
#2 lore raw
In reply to Dan Gora

Hi Dan,

Quoted 11 lines · Dan Gora

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.

Thank you for this patch.

Few (late) comments to your previous questions:

- about rte_mbuf vs rte_pktmbuf, as Andrew said pktmbuf was used in the past when there was a ctrlmbuf. This one has been removed now, so mbuf should be used.

- I agree that removing the test (m->priv_size == 0) is better for the reasons mentionned, and also because it would add a test in the dataplane area, which would sometimes be useless: the application create the mbuf pools, so it can know that all mbufs have a priv area.

#3 lore raw

26/06/2018 09:39, Olivier Matz:

Quoted 23 lines

Hi Dan,

Quoted 11 lines · Dan Gora

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.

Thank you for this patch.

Few (late) comments to your previous questions:

- about rte_mbuf vs rte_pktmbuf, as Andrew said pktmbuf was used in the past when there was a ctrlmbuf. This one has been removed now, so mbuf should be used.

Quoted 7 lines

- I agree that removing the test (m->priv_size == 0) is better for the reasons mentionned, and also because it would add a test in the dataplane area, which would sometimes be useless: the application create the mbuf pools, so it can know that all mbufs have a priv area.

Series applied