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 C1389A2EDB for ; Mon, 30 Sep 2019 21:21:29 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 903171BE96; Mon, 30 Sep 2019 21:21:10 +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 C4DDF8F96 for ; Mon, 30 Sep 2019 21:21:04 +0200 (CEST) Received: by mail-pg1-f193.google.com with SMTP id y35so7931047pgl.1 for ; Mon, 30 Sep 2019 12:21:04 -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=KpzPqcTLgFfQHsFswOqlQ5Y4gmJb1270gFhqcWJieus=; b=WMDvMlfTuMr8upsL6SbqbsZA4E4bzjZ7WOZxxekejejFvqLpdv9haz41ZU0cCJ5nRt 0xQP+jHjQjQJkj+fYdqfSRZYWB1ZluIMzpq+YOsccfZgJ5UkUVczNzJvKaak5Nvm5HPf 1oOyLzAF3qBtVilpSfwurdzWF2YEQTgTw/QQhQZuoLH1D3UCxGfWNvCInZ9RSqS6dHIR xFplqAA3H6LwBddBsNAxA5qy8zhFZ3ehl9rqHxdUJgVKgwrsrl/R91s0XEJKIlqMpDDb grmecFoqPG+JiapWDNTT3cmwBry0Jg76l7dQapB9KVknfZsm5tT8633/SDVFi0BkbEz2 WCYw== 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=KpzPqcTLgFfQHsFswOqlQ5Y4gmJb1270gFhqcWJieus=; b=ufA5sb9tC8JWAXpjz+Bhr0cHymzD101tl5CamckWI4IkSwpwc6FgerSbyHnk/ss/oX 6k9DXI2N/CWUfewvVdHOjieig/rxgy5Z1Hf3s/TAXkioYizCyCL3NI1ApLusZd23Jm32 SCBitvXqujhY/vh81fqfK29X7s/UL2qg7mGJce6UcGMkwEUuibLZtIGuoGf5jNV6Q4Me 3H4MutDILYON2cKT2MLM5PpldgK5yAzTH00M5th+58LVQ7XTzfJyR61tigbIEmZC2uuY aRN/ldOtVdsfv/FPwLQJZcevwYRIFn5jgBQJKXBBb5oAEbb3GlrmYTbQ8rBEOt5kE+fg /x6Q== X-Gm-Message-State: APjAAAX2SPMkwmBcZ1GHc5Ssxt6snTuisiCNBllKpqJXEbb0chxjoLla 7mOR655zBPI8EDOOBtdizJm9St/ftyICUQ== X-Google-Smtp-Source: APXvYqy5KEmCLHRxt0AP32Rz0A8/wvjvj4Ddex8iY21gb6gVT4BWEtMoo/pry1TFX7f9HWUWrcmW5Q== X-Received: by 2002:a63:6c89:: with SMTP id h131mr26508762pgc.322.1569871263644; Mon, 30 Sep 2019 12:21:03 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id c64sm14788304pfc.19.2019.09.30.12.21.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 12:21:02 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Mon, 30 Sep 2019 12:20:53 -0700 Message-Id: <20190930192056.26828-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190930192056.26828-1-stephen@networkplumber.org> References: <20190928003758.18489-1-stephen@networkplumber.org> <20190930192056.26828-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 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 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