From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 30CD2A2F6B for ; Tue, 8 Oct 2019 18:34:32 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0D4231D50C; Tue, 8 Oct 2019 18:34:09 +0200 (CEST) Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by dpdk.org (Postfix) with ESMTP id E97531D412 for ; Tue, 8 Oct 2019 18:34:01 +0200 (CEST) Received: by mail-pl1-f194.google.com with SMTP id d22so8704331pls.0 for ; Tue, 08 Oct 2019 09:34:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HIvhTcCefGzrscLW8jcFtSXJiWq/6kU5A7DNPu7eb3E=; b=JLZMbp9XDnJhhouLa039NM3SoM7auKc+SbFn2MUrWsNKL38Z/WP/Ko/m7stdBuvinQ uNmn5VAcR9rnEw2XaorjKbya7soRtDvFnxwVBPfn+4VOQ5z8x5lpLxNLTIW7/MvSP6QT wdzHGZ8YYX3l7vqLgxMJeDUwgahRVTzI/A9YulapxA5SueE1U1nZBHbRw2qpFwjHz9mZ XA/M4Q6hapEMTZTcAxwAQzF2nGU1+f0pgy6JKfEeOc1fZ29M02UfKTTKrage+SnX78Hr ypQFYPbgPvzgK1JDQyfnuUO97k7Fcxkr8hBFDUFyWbezJUTw4lomZkMkenN2tPXtTFw2 2x8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HIvhTcCefGzrscLW8jcFtSXJiWq/6kU5A7DNPu7eb3E=; b=ZZYMr/3OsQH2lr33oOUsuBPkj4uuXfiiJOSM57tufgCqcm0As90Gj/o4k7hD1m/Zbo 8Ho663+JZ7pPeQMGmrwf3U5uekhpYjdtHogGFqyOCllMrCc3AhJd2gU51o5CAFq67nhJ ZpvZK3LQZklWuX3y8uFqvFvMkYqH9ZuMoxmj637Ky7ad8epH9i4sKCdZJv17oNhJxl0i TSDiOyydw6K+eSyqZdzGLC+qGMZl+pTpNJLwd9lT/soXZ+0mewjF16EDqkfJmEWL/Sl+ jbLczl54r5WzK03Ktz2utyrDgVxv3A9jJbyspTeeHq9PIBfeqRPcyQupssaGJdWDm6aE y8pw== X-Gm-Message-State: APjAAAU2XxVzohfyYWfUAvhtD69D7L2jlPlRTN6l4I2ao/6OUirOhiDU ezY240kB1yat/Th7Iq6ObtQKEgu+XELabw== X-Google-Smtp-Source: APXvYqwLSrAspG11GjGcQgdhSkOrhTTQQQBvIkNlg4Q1zhi/Vj51J9nXZhWTnmIeThbunwQymK3Ptg== X-Received: by 2002:a17:902:6941:: with SMTP id k1mr33676038plt.252.1570552440528; Tue, 08 Oct 2019 09:34:00 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id 18sm17702551pfp.100.2019.10.08.09.33.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2019 09:33:59 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Andrew Rybchenko , Olivier Matz Date: Tue, 8 Oct 2019 09:33:48 -0700 Message-Id: <20191008163350.20779-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191008163350.20779-1-stephen@networkplumber.org> References: <20190928003758.18489-1-stephen@networkplumber.org> <20191008163350.20779-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v6 3/5] mbuf: deinline rte_pktmbuf_clone 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Cloning mbufs requires allocations and iteration and therefore should not be an inline. Signed-off-by: Stephen Hemminger Acked-by: Andrew Rybchenko Acked-by: Olivier Matz --- lib/librte_mbuf/rte_mbuf.c | 39 ++++++++++++++++++++++++++++ lib/librte_mbuf/rte_mbuf.h | 38 ++------------------------- lib/librte_mbuf/rte_mbuf_version.map | 1 + 3 files changed, 42 insertions(+), 36 deletions(-) diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c index e2c661c97522..9a1a1b5f9468 100644 --- a/lib/librte_mbuf/rte_mbuf.c +++ b/lib/librte_mbuf/rte_mbuf.c @@ -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) diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index bffda1c81fbd..6133f12172ae 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -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. diff --git a/lib/librte_mbuf/rte_mbuf_version.map b/lib/librte_mbuf/rte_mbuf_version.map index 4d0bc9772769..ff5c18a5559b 100644 --- a/lib/librte_mbuf/rte_mbuf_version.map +++ b/lib/librte_mbuf/rte_mbuf_version.map @@ -50,6 +50,7 @@ DPDK_19.11 { global: __rte_pktmbuf_linearize; + rte_pktmbuf_clone; } DPDK_18.08; EXPERIMENTAL { -- 2.20.1