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 3B771A2EEB for ; Mon, 7 Oct 2019 18:52:52 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AF1DE1D14D; Mon, 7 Oct 2019 18:52:46 +0200 (CEST) Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) by dpdk.org (Postfix) with ESMTP id 775E11C43D for ; Mon, 7 Oct 2019 18:52:43 +0200 (CEST) Received: by mail-pg1-f175.google.com with SMTP id b8so2206743pgm.13 for ; Mon, 07 Oct 2019 09:52:43 -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=1ERzE9iqLfkegqehVqbIwtr+Jl6TULvFqBDzaQIFrpBp8DDaLal0Pbpmp/eZcUguTF YMycl2YZFuaC1Un1525ClbnJJEMSfUbzzqPq8IsVCe7e3Gcsl5mTjmWNGI3iJZa+0K/H 0GXfx3G8Zhqa+9YYoHzhG3c0KL5MCT35ycSbReguc1VD8Ilf1bh/BMEI1UCul/Y85U+S j0fzjd1ZjIlIZGFp6VPWZi4jd0fi2rWq6V48Cf0TZI6qUyFnnCbEwuh1Df7Wl5cnFR1d pQbdQ0/FcngToJd9ixCWL4TJAk4XZLXU1KOcxO8BH7tyIxl3ftHA8EESfBlVlF9OwxX+ GrKw== 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=B4N9zFcY3anU4oFzApAsgAj81SkaQmysid2Y9HzD/+Oc/U7AK8iNVS+WIbyo+cwzbS q2gmMEMbFZmDf9ilu/W4mJjVwuY4LRg5/oIBC5C4GDdabG8Qp4IHxJpeDIYEKwpd2aKD nyheFVP9eGlm0f2dxNxtovPoLJRmDjeyluKSveoUa4cdHqy/D1WVQXUuyfMekwfqftB7 gcggc0+x7OnSUzA/LC6yyqOeGdIOtcs33cC+ql2/xIxtF2knqklA961xVIFPa1o+Txdr 876XkQRoQbJsGPKxrmJqJnY419bCLZ/biBWXDTfptGCUSrgCgVyQ59nWa55tJWaDk2Ia aklA== X-Gm-Message-State: APjAAAUDsjtKWRpvvvYpLkOhnhAwHbNnpMyrxr1xaI1g/Z7f0qR3qaBa 7Pyh+QeXd/6znrP7Lnbs3np440B5NqNmZw== X-Google-Smtp-Source: APXvYqyoRXmuN+rCXmunUWuAHHPvZl8nkl2hcayfWXi5xl8sXihgzS2NqN2xMF0H3PefL/mEqYtj1Q== X-Received: by 2002:a17:90a:db4a:: with SMTP id u10mr306757pjx.30.1570467161998; Mon, 07 Oct 2019 09:52:41 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id w5sm15920979pfn.96.2019.10.07.09.52.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2019 09:52:41 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Mon, 7 Oct 2019 09:52:25 -0700 Message-Id: <20191007165232.14535-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191007165232.14535-1-stephen@networkplumber.org> References: <20191007165232.14535-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [RFC 1/8] 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