mbuf: deinline clone function
authorStephen Hemminger <stephen@networkplumber.org>
Tue, 8 Oct 2019 16:33:48 +0000 (09:33 -0700)
committerDavid Marchand <david.marchand@redhat.com>
Wed, 16 Oct 2019 10:42:04 +0000 (12:42 +0200)
Cloning mbufs requires allocations and iteration
and therefore should not be an inline.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
lib/librte_mbuf/rte_mbuf.c
lib/librte_mbuf/rte_mbuf.h
lib/librte_mbuf/rte_mbuf_version.map

index e2c661c..9a1a1b5 100644 (file)
@@ -245,6 +245,45 @@ int rte_mbuf_check(const struct rte_mbuf *m, int is_header,
        return 0;
 }
 
+/* Creates a shallow copy of mbuf */
+struct rte_mbuf *
+rte_pktmbuf_clone(struct rte_mbuf *md, struct rte_mempool *mp)
+{
+       struct rte_mbuf *mc, *mi, **prev;
+       uint32_t pktlen;
+       uint16_t nseg;
+
+       mc = rte_pktmbuf_alloc(mp);
+       if (unlikely(mc == NULL))
+               return NULL;
+
+       mi = mc;
+       prev = &mi->next;
+       pktlen = md->pkt_len;
+       nseg = 0;
+
+       do {
+               nseg++;
+               rte_pktmbuf_attach(mi, md);
+               *prev = mi;
+               prev = &mi->next;
+       } while ((md = md->next) != NULL &&
+           (mi = rte_pktmbuf_alloc(mp)) != NULL);
+
+       *prev = NULL;
+       mc->nb_segs = nseg;
+       mc->pkt_len = pktlen;
+
+       /* Allocation of new indirect segment failed */
+       if (unlikely(mi == NULL)) {
+               rte_pktmbuf_free(mc);
+               return NULL;
+       }
+
+       __rte_mbuf_sanity_check(mc, 1);
+       return mc;
+}
+
 /* convert multi-segment mbuf to single mbuf */
 int
 __rte_pktmbuf_linearize(struct rte_mbuf *mbuf)
index bffda1c..6133f12 100644 (file)
@@ -1924,42 +1924,8 @@ static inline void rte_pktmbuf_free(struct rte_mbuf *m)
  *   - The pointer to the new "clone" mbuf on success.
  *   - NULL if allocation fails.
  */
-static inline struct rte_mbuf *rte_pktmbuf_clone(struct rte_mbuf *md,
-               struct rte_mempool *mp)
-{
-       struct rte_mbuf *mc, *mi, **prev;
-       uint32_t pktlen;
-       uint16_t nseg;
-
-       if (unlikely ((mc = rte_pktmbuf_alloc(mp)) == NULL))
-               return NULL;
-
-       mi = mc;
-       prev = &mi->next;
-       pktlen = md->pkt_len;
-       nseg = 0;
-
-       do {
-               nseg++;
-               rte_pktmbuf_attach(mi, md);
-               *prev = mi;
-               prev = &mi->next;
-       } while ((md = md->next) != NULL &&
-           (mi = rte_pktmbuf_alloc(mp)) != NULL);
-
-       *prev = NULL;
-       mc->nb_segs = nseg;
-       mc->pkt_len = pktlen;
-
-       /* Allocation of new indirect segment failed */
-       if (unlikely (mi == NULL)) {
-               rte_pktmbuf_free(mc);
-               return NULL;
-       }
-
-       __rte_mbuf_sanity_check(mc, 1);
-       return mc;
-}
+struct rte_mbuf *
+rte_pktmbuf_clone(struct rte_mbuf *md, struct rte_mempool *mp);
 
 /**
  * Adds given value to the refcnt of all packet mbuf segments.
index f09828c..83148a0 100644 (file)
@@ -50,6 +50,7 @@ DPDK_19.11 {
        global:
 
        __rte_pktmbuf_linearize;
+       rte_pktmbuf_clone;
 
 } DPDK_18.08;