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 37078A2EFD for ; Sat, 28 Sep 2019 02:38:30 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7CF291BE92; Sat, 28 Sep 2019 02:38:12 +0200 (CEST) Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by dpdk.org (Postfix) with ESMTP id 299961B948 for ; Sat, 28 Sep 2019 02:38:05 +0200 (CEST) Received: by mail-pf1-f195.google.com with SMTP id y5so2440956pfo.4 for ; Fri, 27 Sep 2019 17:38:05 -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=90mHwihb7xMUiaegFDWqrOBXKk/uRYtwHzVS8GpuEk8=; b=Ym4JrbANbpoSR17acvpPNZQYy83yAzDSJzUtNM+LSBo/Xf0zxeFI1UvEYL6zu0hN/o XYj6l13myqzbu0z+O5nBjYmsZtS+cUmAmOGAQhaeKxc0rnODpOz9RuzgoixosFPq9wkC TwwVS7g0sf3jVmdosy5Fdzj9o7HnCGKGFlbY/wmAB2Q8YrvwHOlDkZ4yLugLWKPm1vnM p0PovZxeau7UP2BclaL9clpswDnbWuw5MSNUTG1SdCqWSvthuqvJFmTCDjG3NcBjK18j kg2ZnHOFfdpbq5d6D/WdO98JA0wzJhPmuoSfUB7FVETewquT8CGJpqbn/BelOG0/oxCq IVPQ== 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=90mHwihb7xMUiaegFDWqrOBXKk/uRYtwHzVS8GpuEk8=; b=U1/PUfGUIDMrBhrGnJPAb4FfR7SJ9a/0g3sIJFkMf9CU7zQXjYjY2ImJk9fFDIFun5 v+w+PCVHVQj6e8ujDo/yiGA0ZlagaOVNVahu4xFeDfSOnfDv/xljKCWtulpuAMyEzhhN Qr//6jYiu0MBm+lSUfWmWtToULtzpkAVRRyPKwwW1LFsSmmwjp5jU++F/ju8QGBfgJ+0 i/U+KH6atPaIEKAebh0hbUpX83K/8PneLDriZHAT/zw7msTBmmrwv11BH97QiqAvIE/V DgKbzpW8VVuS3pdQocQHvDaDGrqz1SCYZKk7lLpg8zA8NoG5PLhevCW4Tksrekr7Tcc6 ofqg== X-Gm-Message-State: APjAAAWPRwVjKMu649r9wh9/Pz9jOoraVSHnLUIk1sUVYXGH5wf4rJC8 lDjQ7Yb76LzJ+3Sziq9ZX2UbKKS+WTs= X-Google-Smtp-Source: APXvYqxH+wcVavVK5o1zp/NYIgvH2w5hRDmdhag+MypkJ6Ignzyn/JoaGMIXB28yJHIv6novN3WvDw== X-Received: by 2002:a63:ab05:: with SMTP id p5mr12264336pgf.414.1569631084781; Fri, 27 Sep 2019 17:38:04 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id t13sm3494942pfh.12.2019.09.27.17.38.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Sep 2019 17:38:03 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Fri, 27 Sep 2019 17:37:56 -0700 Message-Id: <20190928003758.18489-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190928003758.18489-1-stephen@networkplumber.org> References: <20190928003758.18489-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 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 --- 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 922bce6f0f93..12d0258a120d 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 d25356b58cba..a6e78e4ea7a6 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 7af410a4f687..9cc43e24bfa4 100644 --- a/lib/librte_mbuf/rte_mbuf_version.map +++ b/lib/librte_mbuf/rte_mbuf_version.map @@ -49,6 +49,7 @@ DPDK_18.08 { DPDK_18.11 { global: + rte_pktmbuf_clone; rte_pktmbuf_linearize; } DPDK_18.08; -- 2.20.1