From: Bruce Richardson Date: Mon, 17 Feb 2014 19:15:19 +0000 (+0100) Subject: mbuf: rework check on mbuf freeing X-Git-Tag: spdx-start~11037 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=48a0cc25f1752fab08e0c0c7bef3fb71241cb843;p=dpdk.git mbuf: rework check on mbuf freeing Allow poll-mode drivers to maintain their own caches of mbufs, by allowing them to check if it's ok to free an mbuf (to their local cache) without actually freeing it back to the memory pool itself. Signed-off-by: Bruce Richardson Signed-off-by: David Marchand --- diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index 22ddccbbe7..954e990c5f 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -659,17 +659,9 @@ static inline void rte_pktmbuf_detach(struct rte_mbuf *m) #endif /* RTE_MBUF_SCATTER_GATHER */ -/** - * Free a segment of a packet mbuf into its original mempool. - * - * Free an mbuf, without parsing other segments in case of chained - * buffers. - * - * @param m - * The packet mbuf segment to be freed. - */ -static inline void __attribute__((always_inline)) -rte_pktmbuf_free_seg(struct rte_mbuf *m) + +static inline struct rte_mbuf* __attribute__((always_inline)) +__rte_pktmbuf_prefree_seg(struct rte_mbuf *m) { __rte_mbuf_sanity_check(m, RTE_MBUF_PKT, 0); @@ -690,12 +682,29 @@ rte_pktmbuf_free_seg(struct rte_mbuf *m) __rte_mbuf_raw_free(md); } #endif - __rte_mbuf_raw_free(m); + return(m); #ifdef RTE_MBUF_SCATTER_GATHER } + return (NULL); #endif } +/** + * Free a segment of a packet mbuf into its original mempool. + * + * Free an mbuf, without parsing other segments in case of chained + * buffers. + * + * @param m + * The packet mbuf segment to be freed. + */ +static inline void __attribute__((always_inline)) +rte_pktmbuf_free_seg(struct rte_mbuf *m) +{ + if (likely(NULL != (m = __rte_pktmbuf_prefree_seg(m)))) + __rte_mbuf_raw_free(m); +} + /** * Free a packet mbuf back into its original mempool. *