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 DDAC0A2F67 for ; Fri, 4 Oct 2019 23:48:16 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5BCE51C438; Fri, 4 Oct 2019 23:47:57 +0200 (CEST) Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by dpdk.org (Postfix) with ESMTP id 4EA041C2EE for ; Fri, 4 Oct 2019 23:47:54 +0200 (CEST) Received: by mail-pg1-f195.google.com with SMTP id q7so4460007pgi.12 for ; Fri, 04 Oct 2019 14:47:54 -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=zxcyCp/RJwDdLRu+ORBLRDdv/Ir5nLTZyoyCxr19E5Q=; b=eAI3frkOtNkqc+FX9VKvjeQIrtEKNLpljJOCSXEQo3VcXGPNPfzBs5CTorGuoyeoO/ AwdHfZz1RoPfY1Gl3NSoHzwOIN7QphTVDjWHtHVuvOYucj/qEy67YYiWpr0bmDrtjBuX Wn2pRjd58GviQZCExm24bL1+bet39nIraElk3zeETQq19bt58t0pEnRHtXVHaN55fY5X JXG56iFXqS5Mc4tdDIOsCxh9stPgjGHxsIyzkYN0RG8MMDUt7GXFf/V/9IyMkCefbqZ1 1tvE/RzWWM01lSO9ZHBaDaPA9IpNLapgc8UyWmh9xPk2OWDXq6YD78hugaylEuny+lwU r09A== 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=zxcyCp/RJwDdLRu+ORBLRDdv/Ir5nLTZyoyCxr19E5Q=; b=tyf5gvRiI0XS5QRqs2iZC+kYFQTGRdrRS7di5x4ahqCC2+yH6PGLzGNayWbu7ewEKI IqBODzvMJWdEgDEAIiTEHS2zHskix9osozbuSSvLCtYKCxSfWdoGqHgoDkEAoaFquZ3S GBvHh74JmJMUxrRViB49O1ObaQV04ZBlDdk6sZMah03khoG3HPcsn1o8hPQE9tEnsW14 BNDEQiXm72ihuCko71U/9052JxYu40I5jdJF9Bqo/Qys8jwxd8nN89jyKGdDFguLkELJ 8WRPdxiiA23nF5y0RhX9PlWvip2QM0i6G5IoUdzLVuufqCQeZTqYrELAiNNBztYbsJHQ eDVg== X-Gm-Message-State: APjAAAXxCb0+9Tbvs0TCBx5bSg9+kECsBPQ4bKvKV1u+90mFrmx7W5+4 PRuJvh/l+gdK1oMj6AUUi+PULsdCcsfcFw== X-Google-Smtp-Source: APXvYqxxZBqgHx/uzdjdVgXIFnUCKhxbjHKWYWcS70ibyZjn7Ln/osaIBRxfqrKrfIrM2EDvvu4gtw== X-Received: by 2002:a17:90a:fb85:: with SMTP id cp5mr19553110pjb.42.1570225673092; Fri, 04 Oct 2019 14:47:53 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id q71sm6191355pjb.26.2019.10.04.14.47.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Oct 2019 14:47:52 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Andrew Rybchenko Date: Fri, 4 Oct 2019 14:47:42 -0700 Message-Id: <20191004214743.24686-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191004214743.24686-1-stephen@networkplumber.org> References: <20190928003758.18489-1-stephen@networkplumber.org> <20191004214743.24686-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v4 3/4] 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 --- 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