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 90B92A2EDB for ; Mon, 30 Sep 2019 21:22:02 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 166C61BEB7; Mon, 30 Sep 2019 21:21:18 +0200 (CEST) Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by dpdk.org (Postfix) with ESMTP id 76FF837A2 for ; Mon, 30 Sep 2019 21:21:08 +0200 (CEST) Received: by mail-pg1-f195.google.com with SMTP id e1so2387522pgj.6 for ; Mon, 30 Sep 2019 12:21:08 -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=zdsVTY0D8zVTp25c2Ag/LpUnnCKhJ2sj1djQsUGrXUo=; b=OlUzL+qQFhKQjYreMu1UeCD03JkZCZ7uVrqYHGdY2EufwKgxrdGXaTqrt4C3CPwD27 YxVVH9v5y4Nat4g8FGKrHbeFAoafO15PiKvCyOidxGb00xsG9/NewyO4UqTxt2684zwZ xK8Gq24c7COe/fM/sFDR35ih/3nvC0NI57g5PEV8cn1PgtDh0OpmAsjEpflMu3YTFboW fiaLxO9XVtAgoq1m4CizYL+7k1dQELwY6YiOXb0iwzc2H2CCmXE0xwY1FbWX0dVDx+uz /Yq/W3y/tO4fZnbNPW4PDtZVw0TosJkBJQfv0tewYaDlElNub3MkUfhz4Z593cApOBe/ IEew== 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=zdsVTY0D8zVTp25c2Ag/LpUnnCKhJ2sj1djQsUGrXUo=; b=Dmp0sklCHyBSPgOHYNxnvKwxMjkr/B+eKNVBXhpg0Doftfm1vUmwijdb9TL13n2ZUl iZi/dinfS6C8bHsEeyk2uD12VTMTg5wq0NqnEeE1mGjxBO+WbvhPueQI+vThelFG0mwo E+CKYtCNkLjWMXzpKJ1m5f93QY30+F24WWUZ4k+zy392GS6jahs+N2ANhb522WQ4vopu 9LisSyyebUVihKTdSi+6KVzE/uapqZ+XFd0ePcx0tF1enRKS5ztzjU4TCf04mEN6ag2r bBdeSgfu5bXD3UD1yxEs0z9iXMwxj2s3LwQjVnrkgbiupISj+sR0L2/i9ft7wluj8f2k TN4A== X-Gm-Message-State: APjAAAWrfpBItcUG52t69ELA/Cy/O9+Quv1Af8Z0sbOGFhP3yosn4dyJ ZxRv1KN7rbZ99qtUYq/Sj/k3Cyc6gR8Jfg== X-Google-Smtp-Source: APXvYqyL2AiicPF5R57ZqGXj0bcq4QYOuvIeUa0MfLyniRfm51RMHRbLC7m48PO5Z34hNOMdCL+zGQ== X-Received: by 2002:aa7:9216:: with SMTP id 22mr23747381pfo.214.1569871267400; Mon, 30 Sep 2019 12:21:07 -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.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 12:21:06 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Mon, 30 Sep 2019 12:20:56 -0700 Message-Id: <20190930192056.26828-7-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 6/6] pdump: use new pktmbuf copy function 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" The rte_pktmbuf_copy handles varying size mbuf pools correctly. Signed-off-by: Stephen Hemminger --- lib/librte_pdump/rte_pdump.c | 69 +----------------------------------- 1 file changed, 1 insertion(+), 68 deletions(-) diff --git a/lib/librte_pdump/rte_pdump.c b/lib/librte_pdump/rte_pdump.c index cd24dd010951..c665cf237f65 100644 --- a/lib/librte_pdump/rte_pdump.c +++ b/lib/librte_pdump/rte_pdump.c @@ -64,73 +64,6 @@ static struct pdump_rxtx_cbs { } rx_cbs[RTE_MAX_ETHPORTS][RTE_MAX_QUEUES_PER_PORT], tx_cbs[RTE_MAX_ETHPORTS][RTE_MAX_QUEUES_PER_PORT]; -static inline int -pdump_pktmbuf_copy_data(struct rte_mbuf *seg, const struct rte_mbuf *m) -{ - if (rte_pktmbuf_tailroom(seg) < m->data_len) { - RTE_LOG(ERR, PDUMP, - "User mempool: insufficient data_len of mbuf\n"); - return -EINVAL; - } - - seg->port = m->port; - seg->vlan_tci = m->vlan_tci; - seg->hash = m->hash; - seg->tx_offload = m->tx_offload; - seg->ol_flags = m->ol_flags; - seg->packet_type = m->packet_type; - seg->vlan_tci_outer = m->vlan_tci_outer; - seg->data_len = m->data_len; - seg->pkt_len = seg->data_len; - rte_memcpy(rte_pktmbuf_mtod(seg, void *), - rte_pktmbuf_mtod(m, void *), - rte_pktmbuf_data_len(seg)); - - return 0; -} - -static inline struct rte_mbuf * -pdump_pktmbuf_copy(struct rte_mbuf *m, struct rte_mempool *mp) -{ - struct rte_mbuf *m_dup, *seg, **prev; - uint32_t pktlen; - uint16_t nseg; - - m_dup = rte_pktmbuf_alloc(mp); - if (unlikely(m_dup == NULL)) - return NULL; - - seg = m_dup; - prev = &seg->next; - pktlen = m->pkt_len; - nseg = 0; - - do { - nseg++; - if (pdump_pktmbuf_copy_data(seg, m) < 0) { - if (seg != m_dup) - rte_pktmbuf_free_seg(seg); - rte_pktmbuf_free(m_dup); - return NULL; - } - *prev = seg; - prev = &seg->next; - } while ((m = m->next) != NULL && - (seg = rte_pktmbuf_alloc(mp)) != NULL); - - *prev = NULL; - m_dup->nb_segs = nseg; - m_dup->pkt_len = pktlen; - - /* Allocation of new indirect segment failed */ - if (unlikely(seg == NULL)) { - rte_pktmbuf_free(m_dup); - return NULL; - } - - __rte_mbuf_sanity_check(m_dup, 1); - return m_dup; -} static inline void pdump_copy(struct rte_mbuf **pkts, uint16_t nb_pkts, void *user_params) @@ -148,7 +81,7 @@ pdump_copy(struct rte_mbuf **pkts, uint16_t nb_pkts, void *user_params) ring = cbs->ring; mp = cbs->mp; for (i = 0; i < nb_pkts; i++) { - p = pdump_pktmbuf_copy(pkts[i], mp); + p = rte_pktmbuf_copy(pkts[i], mp, 0, UINT32_MAX); if (p) dup_bufs[d_pkts++] = p; } -- 2.20.1