mbuf: make raw free function public
authorOlivier Matz <olivier.matz@6wind.com>
Tue, 4 Apr 2017 16:28:01 +0000 (18:28 +0200)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Wed, 5 Apr 2017 09:30:29 +0000 (11:30 +0200)
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 <olivier.matz@6wind.com>
drivers/net/ena/ena_ethdev.c
drivers/net/mlx5/mlx5_rxtx.c
lib/librte_mbuf/rte_mbuf.h

index b5e6db6..5dd44d7 100644 (file)
@@ -680,7 +680,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++;
        }
index 87eec2e..3cbf63f 100644 (file)
@@ -2000,7 +2000,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;
@@ -2011,13 +2011,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;
                        }
index e153785..2dc4d8b 100644 (file)
@@ -797,20 +797,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 */
 
 /**
@@ -1217,7 +1227,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);
 }
 
 /**
@@ -1272,7 +1282,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);
        }
 }