From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from proxy.6wind.com (host.76.145.23.62.rev.coltfrance.com [62.23.145.76]) by dpdk.org (Postfix) with ESMTP id E81432BD1 for ; Tue, 24 Jan 2017 16:22:43 +0100 (CET) Received: from glumotte.dev.6wind.com (unknown [10.16.0.195]) by proxy.6wind.com (Postfix) with ESMTP id 8BC1B27489 for ; Tue, 24 Jan 2017 16:22:39 +0100 (CET) From: Olivier Matz To: dev@dpdk.org Date: Tue, 24 Jan 2017 16:19:27 +0100 Message-Id: <1485271173-13408-3-git-send-email-olivier.matz@6wind.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1485271173-13408-1-git-send-email-olivier.matz@6wind.com> References: <1485271173-13408-1-git-send-email-olivier.matz@6wind.com> Subject: [dpdk-dev] [RFC 2/8] mbuf: make raw free function public X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Jan 2017 15:22:44 -0000 Rename __rte_mbuf_raw_free() as rte_mbuf_raw_free() and make it public. The old function is kept for compat but is marked as deprecated. The next commit changes the behavior of rte_mbuf_raw_free() to make it more consistent with rte_mbuf_raw_alloc(). Signed-off-by: Olivier Matz --- drivers/net/ena/ena_ethdev.c | 2 +- drivers/net/mlx5/mlx5_rxtx.c | 6 +++--- drivers/net/mpipe/mpipe_tilegx.c | 2 +- lib/librte_mbuf/rte_mbuf.h | 22 ++++++++++++++++------ 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c index 8497cd7..4aac6a9 100644 --- a/drivers/net/ena/ena_ethdev.c +++ b/drivers/net/ena/ena_ethdev.c @@ -685,7 +685,7 @@ static void ena_rx_queue_release_bufs(struct ena_ring *ring) ring->rx_buffer_info[ring->next_to_clean & ring_mask]; if (m) - __rte_mbuf_raw_free(m); + rte_mbuf_raw_free(m); ring->next_to_clean++; } diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c index 56c7f78..a518a42 100644 --- a/drivers/net/mlx5/mlx5_rxtx.c +++ b/drivers/net/mlx5/mlx5_rxtx.c @@ -1328,7 +1328,7 @@ mlx5_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n) assert(pkt != (*rxq->elts)[idx]); rep = NEXT(pkt); rte_mbuf_refcnt_set(pkt, 0); - __rte_mbuf_raw_free(pkt); + rte_mbuf_raw_free(pkt); pkt = rep; } break; @@ -1339,13 +1339,13 @@ mlx5_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n) &rss_hash_res); if (!len) { rte_mbuf_refcnt_set(rep, 0); - __rte_mbuf_raw_free(rep); + rte_mbuf_raw_free(rep); break; } if (unlikely(len == -1)) { /* RX error, packet is likely too large. */ rte_mbuf_refcnt_set(rep, 0); - __rte_mbuf_raw_free(rep); + rte_mbuf_raw_free(rep); ++rxq->stats.idropped; goto skip; } diff --git a/drivers/net/mpipe/mpipe_tilegx.c b/drivers/net/mpipe/mpipe_tilegx.c index 7bbd168..eedc0b3 100644 --- a/drivers/net/mpipe/mpipe_tilegx.c +++ b/drivers/net/mpipe/mpipe_tilegx.c @@ -549,7 +549,7 @@ mpipe_recv_flush_stack(struct mpipe_dev_priv *priv) mbuf->data_len = 0; mbuf->pkt_len = 0; - __rte_mbuf_raw_free(mbuf); + rte_mbuf_raw_free(mbuf); } } diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index 73b79c0..8ff2290 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -788,20 +788,30 @@ static inline struct rte_mbuf *rte_mbuf_raw_alloc(struct rte_mempool *mp) } /** - * @internal Put mbuf back into its original mempool. - * The use of that function is reserved for RTE internal needs. - * Please use rte_pktmbuf_free(). + * Put mbuf back into its original mempool. + * + * The caller must ensure that the mbuf is direct and that the + * reference counter is 0. * * @param m * The mbuf to be freed. */ static inline void __attribute__((always_inline)) -__rte_mbuf_raw_free(struct rte_mbuf *m) +rte_mbuf_raw_free(struct rte_mbuf *m) { + RTE_ASSERT(RTE_MBUF_DIRECT(m)); RTE_ASSERT(rte_mbuf_refcnt_read(m) == 0); rte_mempool_put(m->pool, m); } +/* compat with older versions */ +__rte_deprecated +static inline void __attribute__((always_inline)) +__rte_mbuf_raw_free(struct rte_mbuf *m) +{ + rte_mbuf_raw_free(m); +} + /* Operations on ctrl mbuf */ /** @@ -1209,7 +1219,7 @@ static inline void rte_pktmbuf_detach(struct rte_mbuf *m) m->ol_flags = 0; if (rte_mbuf_refcnt_update(md, -1) == 0) - __rte_mbuf_raw_free(md); + rte_mbuf_raw_free(md); } /** @@ -1264,7 +1274,7 @@ rte_pktmbuf_free_seg(struct rte_mbuf *m) m = rte_pktmbuf_prefree_seg(m); if (likely(m != NULL)) { m->next = NULL; - __rte_mbuf_raw_free(m); + rte_mbuf_raw_free(m); } } -- 2.8.1