[dpdk-dev] [PATCH 1/3] mbuf: Use EXTERNAL_MBUF to indicate external buffer

Ouyang Changchun changchun.ouyang at intel.com
Fri Oct 24 10:10:07 CEST 2014


mbuf uses EXTERNAL_MBUF in ol_flags to indicate it is an
external buffer, when freeing such kind of mbuf, just need put mbuf itself
back into mempool, doesn't free the attached external buffer, user/caller
need take care of detaching and freeing the external buffer.

Signed-off-by: Changchun Ouyang <changchun.ouyang at intel.com>
---
 lib/librte_mbuf/rte_mbuf.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index ddadc21..8cee8fa 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -114,6 +114,9 @@ extern "C" {
 /* Bit 51 - IEEE1588*/
 #define PKT_TX_IEEE1588_TMST (1ULL << 51) /**< TX IEEE1588 packet to timestamp. */
 
+/* Bit 62 - Indicate it is external buffer */
+#define EXTERNAL_MBUF        (1ULL << 62) /**< External buffer. */
+
 /* Use final bit of flags to indicate a control mbuf */
 #define CTRL_MBUF_FLAG       (1ULL << 63) /**< Mbuf contains control data */
 
@@ -670,7 +673,7 @@ __rte_pktmbuf_prefree_seg(struct rte_mbuf *m)
 		 *  - detach mbuf
 		 *  - free attached mbuf segment
 		 */
-		if (unlikely (md != m)) {
+		if (unlikely((md != m) && !(m->ol_flags & EXTERNAL_MBUF))) {
 			rte_pktmbuf_detach(m);
 			if (rte_mbuf_refcnt_update(md, -1) == 0)
 				__rte_mbuf_raw_free(md);
-- 
1.8.4.2



More information about the dev mailing list