From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f44.google.com (mail-pa0-f44.google.com [209.85.220.44]) by dpdk.org (Postfix) with ESMTP id 67479919B for ; Fri, 22 Jan 2016 18:34:10 +0100 (CET) Received: by mail-pa0-f44.google.com with SMTP id uo6so45760025pac.1 for ; Fri, 22 Jan 2016 09:34:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=Xc30jJlqps/4n/sXviKrSYNRwEe2z7WCSZw4YReChiI=; b=rDCdJNDwJ/UHLMWi1cr6YuCK3kwIOjgxtUZsmutS8xG118rapgmYlCtQw5pOGRGVI/ TmI22KfVJxFisTIsr1WhpnZ9dMCbvVB9x5/AiVtS5ppvEGn1vjnsum76c6uByTX7yC7m vfQl1CdnQlWGERneWgtDwK2jKdPaf1diYF6VOMSNxtp0kn25zfO6db0I66YL52BklG+A vtJHVCatgYKayUZEGigHJgOhr9hCp95uI55SA/iFHVTe6K9WYaw3PDC65I9tWC7/ekU6 DSZL0FuFmTAqDvVBVq/C12yANjOt+41VM3uGNZmFc3CZ8UBSQBIwyamcCuuRI6moO4xn ghYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=Xc30jJlqps/4n/sXviKrSYNRwEe2z7WCSZw4YReChiI=; b=eAc7HpocZN4bJTncedILciEF/QKpXNGuuY2WgFVe1zo8r8+9UhwZSz+MivunaCVDbq etjPVHErkPyaoaVNrKc3dpT43/1zxsTJN58TBGdVn0eEikVKzvRw1+E5JLOGoGz7rpGM c38utJusNA0aVO9G+Q2971gpWZi1ixW+vMi/1PnDzAzeRfgZ5Yxs270lNsAPtXjtPHaj OBnfo094Rz4exhdmh15idW4/3E0u1b/FMcqSXevPuBWHla4/vP8nK52dGhUzFJhB95vd aeTw6IAKf24Anj4RCKqnotfv7pn48UNRsdWRHqa10V7ecahiZ78DXr9CMbXKiJtlnHF2 af3A== X-Gm-Message-State: AG10YOSzhfUXHeOBEeHqSSybdInOt1UEg4DKL9VjUXjKxoj5ZSbijDw/NdQ8mxvp++Jxlg== X-Received: by 10.66.141.109 with SMTP id rn13mr5960563pab.83.1453484049559; Fri, 22 Jan 2016 09:34:09 -0800 (PST) Received: from xeon-e3 (static-50-53-82-155.bvtn.or.frontiernet.net. [50.53.82.155]) by smtp.gmail.com with ESMTPSA id 73sm11132727pfm.10.2016.01.22.09.34.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Jan 2016 09:34:09 -0800 (PST) Date: Fri, 22 Jan 2016 09:33:45 -0800 From: Stephen Hemminger To: "Mrzyglod, DanielX T" Message-ID: <20160122093345.370f8660@xeon-e3> In-Reply-To: <7ADD74816B4C8A45B56203CBA65FE5A63346A5A4@IRSMSX107.ger.corp.intel.com> References: <1436485068-30609-1-git-send-email-stephen@networkplumber.org> <1436485068-30609-2-git-send-email-stephen@networkplumber.org> <7ADD74816B4C8A45B56203CBA65FE5A63346A5A4@IRSMSX107.ger.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: "dev@dpdk.org" , Mike Davison , Stephen Hemminger Subject: Re: [dpdk-dev] [PATCH 1/2] mbuf: Add rte_pktmbuf_copy X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jan 2016 17:34:10 -0000 On Fri, 22 Jan 2016 13:40:44 +0000 "Mrzyglod, DanielX T" wrote: > > > >-----Original Message----- > >From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Stephen Hemminger > >Sent: Friday, July 10, 2015 1:38 AM > >To: dev@dpdk.org > >Cc: Mike Davison ; Stephen Hemminger > > > >Subject: [dpdk-dev] [PATCH 1/2] mbuf: Add rte_pktmbuf_copy > > > >From: Stephen Hemminger > > > >Added rte_pktmbuf_copy() function since copying multi-part > >segments is common issue and can be problematic. > > > >Signed-off-by: Mike Davison > >Reviewed-by: Stephen Hemminger > >--- > > lib/librte_mbuf/rte_mbuf.h | 59 > >++++++++++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 59 insertions(+) > > > >diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h > >index 80419df..f0a543b 100644 > >--- a/lib/librte_mbuf/rte_mbuf.h > >+++ b/lib/librte_mbuf/rte_mbuf.h > >@@ -60,6 +60,7 @@ > > #include > > #include > > #include > >+#include > > > > #ifdef __cplusplus > > extern "C" { > >@@ -1272,6 +1273,64 @@ static inline int rte_pktmbuf_is_contiguous(const > >struct rte_mbuf *m) > > return !!(m->nb_segs == 1); > > } > > > >+/* > >+ * Creates a copy of the given packet mbuf. > >+ * > >+ * Walks through all segments of the given packet mbuf, and for each of them: > >+ * - Creates a new packet mbuf from the given pool. > >+ * - Copy segment to newly created mbuf. > >+ * Then updates pkt_len and nb_segs of the new packet mbuf to match values > >+ * from the original packet mbuf. > >+ * > >+ * @param md > >+ * The packet mbuf to be copied. > >+ * @param mp > >+ * The mempool from which the mbufs are allocated. > >+ * @return > >+ * - The pointer to the new mbuf on success. > >+ * - NULL if allocation fails. > >+ */ > >+static inline struct rte_mbuf *rte_pktmbuf_copy(struct rte_mbuf *md, > >+ struct rte_mempool *mp) > >+{ > >+ struct rte_mbuf *mc = NULL; > >+ struct rte_mbuf **prev = &mc; > >+ > >+ do { > >+ struct rte_mbuf *mi; > >+ > >+ mi = rte_pktmbuf_alloc(mp); > >+ if (unlikely(mi == NULL)) { > >+ rte_pktmbuf_free(mc); > >+ return NULL; > >+ } > >+ > >+ mi->data_off = md->data_off; > >+ mi->data_len = md->data_len; > >+ mi->port = md->port; > >+ mi->vlan_tci = md->vlan_tci; > >+ mi->tx_offload = md->tx_offload; > >+ mi->hash = md->hash; > >+ > >+ mi->next = NULL; > >+ mi->pkt_len = md->pkt_len; > >+ mi->nb_segs = md->nb_segs; > >+ mi->ol_flags = md->ol_flags; > >+ mi->packet_type = md->packet_type; > >+ > >+ rte_memcpy(rte_pktmbuf_mtod(mi, char *), > >+ rte_pktmbuf_mtod(md, char *), > >+ md->data_len); > >+ > >+ *prev = mi; > >+ prev = &mi->next; > >+ } while ((md = md->next) != NULL); > >+ > >+ *prev = NULL; > >+ __rte_mbuf_sanity_check(mc, 1); > >+ return mc; > >+} > >+ > > /** > > * Dump an mbuf structure to the console. > > * > >-- > >2.1.4 > > Hi Stephen :> > This patch look useful in case of backup buffs. > There will be second approach ? I did bother resubmitting it since unless there are users in current code base it would likely rot.