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 8F51DA2EDB for ; Mon, 30 Sep 2019 17:28:03 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A599D1BED7; Mon, 30 Sep 2019 17:27:39 +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 69B571BEA6 for ; Mon, 30 Sep 2019 17:27:33 +0200 (CEST) Received: by mail-pl1-f194.google.com with SMTP id d22so4057606pls.0 for ; Mon, 30 Sep 2019 08:27:33 -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=otLljKJLik2d6Cq1uFOqCw0v1a/DuGc5nPCEEs/IOzM=; b=MFA25/EMs8nx36Ph0c3yUeycgRFQMNpWJ0uTLRpWhnl5/9ZXtafOwlg8FCX0j+UUGD DkV5FhDH3RCJABbNUJKPiBDN0yZ0qA58fXz2zpTlDKfYGnzmA8tbk49vXf08or9riVdC X+bwFvbdyFUJXVUy9BwU4VMecOOLaOlYUcD4+fwy1z2JQ9JlX8OlChN+1mAY5/WxZS3E I9usDD4kSHpf1YnuKMf91mhtNghaps+BG55o7zza3TS3xgPBea/tbfz+aXnZp0rozWoM j99ebbZ80k5G9fU6RFT3GSeq/qRYhi0OjnqjDeS516o7paTSlk9yv6F6mWY11Kv8FgtX dU/w== 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=otLljKJLik2d6Cq1uFOqCw0v1a/DuGc5nPCEEs/IOzM=; b=WOYHG5M4RxoAuf2TWKd3+yHdJj/8d+OBjVbA6KMJDp7DxFr/f9Lrzw3y/IOgsF6O4e JX5aygz+PI+Vpmh2tCiTOLDUd/4NVqoW5OD6Hy3sVMB4vuGRMLDvVa/u91CcPlkOy0pX 0Bhj9+93cljQ7QnS6olI0lOyyTRL64+KxIGmkhdOhKsDIvomRZHbtf4JFr78nTiJWlT1 H7daa9jIkUdLZQN0gl0GEoaNsiFZ62zXL0tX5f/S06UFtlus/X6beOUzXE2zotPVWoU5 UxhuwheDe1OvJ/wqmL7TVykDUjuZzWc+odJB8zlyCDPEsb8BOsQIKjjhsF2y1u44PLWh j5NQ== X-Gm-Message-State: APjAAAUp0sEJYe5t4/xDhwW7qSfomSBl7DsKIUxW9ZP4i1HnaFve1pcG 2VEzm9qK6/Nh65V+TvEx5g8tGESuwCo= X-Google-Smtp-Source: APXvYqwe4FF3C2P3IQNh5fDFHfIgGtpvinhmY95E8QeqRH0/SXzWnLCRTtNtHMgRtJmIXnenzqZ+jA== X-Received: by 2002:a17:902:6b07:: with SMTP id o7mr11858899plk.44.1569857252278; Mon, 30 Sep 2019 08:27:32 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id w14sm30521021pge.56.2019.09.30.08.27.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 08:27:31 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Mon, 30 Sep 2019 08:27:18 -0700 Message-Id: <20190930152721.8029-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190930152721.8029-1-stephen@networkplumber.org> References: <20190928003758.18489-1-stephen@networkplumber.org> <20190930152721.8029-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 3/6] 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 528681ba263a..aeec3f90f3fe 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_19.11 { global: + rte_pktmbuf_clone; rte_pktmbuf_linearize; } DPDK_18.08; -- 2.20.1