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 37912A2EEB for ; Mon, 7 Oct 2019 17:44:20 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5309F1C29D; Mon, 7 Oct 2019 17:44:01 +0200 (CEST) Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by dpdk.org (Postfix) with ESMTP id EFB381C1C6 for ; Mon, 7 Oct 2019 17:43:55 +0200 (CEST) Received: by mail-pg1-f193.google.com with SMTP id e1so8450980pgj.6 for ; Mon, 07 Oct 2019 08:43:55 -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=UW2Q8BMSu302YJMIJqQw/LN+tjqUhFqQCW9wYr2K/ZlujztUktMFseegtv8n9Wp8iq SfpW1QJSRIEtn0YhAkVMzLBbFlpCTS6CQK03QywmyiqmEIkWCkuZmHDp4yjgtEr/Rub+ LnCGfeoBTSP+Am1KfvU+7E9OLZ/uZXCd/y0kx+ltTr4tjlbXCcn8AUIVCGyfUDTgLxpq CCKmh1U2LsmlwNv2FiRPKFbNw/Sr3TDkb6tp1dfCPRxwW3b0wUw+FmNFuMTF+uDItSOR N65mMdoO+DpOIDNysWu3l9gJwqZEfDHDmkxcSZ9YcpnbM9gTYd5TI5kEiotBS5Y2Rx1Z Mi/g== 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=aW47qldgoAsEjF5RQDTaTBt/D973VBD3DzsgbfJUdl2DYEz2m9hWTrpvQWQtUo1KHQ zmKv3A9CUpwLhHV9DOOjdctisNpfvCRbhwjdMKcJVJDS1rMJTJMsPan1QBfLmwigEpau 5aahpRBZFkTs4zj3PANASxsQDxeSKYr5Nrk8YQMkQbZyN0o8+7aSL7X62hhnGL9i0Wcs fp+6C2oXntDLo1xIFb3Pzo7HpxOk6IpIS4dZYCvBCkET34djX/l2Vl/wtQDgr7GoiJQZ KFbJollFMmMCw+fc20Lib1a8Wn0tGg6g7OzrZAsxoGXKdO3dUNHYy80nYT/D9Auhw7U6 jfZA== X-Gm-Message-State: APjAAAWXV3UdYAjnnbr/2DJ0f9ZHgrBPmwUcaTsPg/CauZFT+7o9teAd fIwbIBYrCzAyclRtsUorPyuJTGt/nGYcWQ== X-Google-Smtp-Source: APXvYqw8qx4zQ6E8dUT5ZLNWlxIuQkVDnTYnblbCNBrsjFBjfX/57FwWPbWTvd/sx0vNam+mg3Ibeg== X-Received: by 2002:a63:fc60:: with SMTP id r32mr17205297pgk.160.1570463034747; Mon, 07 Oct 2019 08:43:54 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id k5sm20779345pfp.109.2019.10.07.08.43.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2019 08:43:53 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Andrew Rybchenko Date: Mon, 7 Oct 2019 08:43:41 -0700 Message-Id: <20191007154343.8556-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191007154343.8556-1-stephen@networkplumber.org> References: <20190928003758.18489-1-stephen@networkplumber.org> <20191007154343.8556-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v5 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 --- 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