From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [dpdk-dev] [PATCH v2 6/6] pdump: use new pktmbuf copy function
Date: Mon, 30 Sep 2019 08:27:21 -0700 [thread overview]
Message-ID: <20190930152721.8029-7-stephen@networkplumber.org> (raw)
In-Reply-To: <20190930152721.8029-1-stephen@networkplumber.org>
The rte_pktmbuf_copy handles varying size mbuf pools correctly.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
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
next prev parent reply other threads:[~2019-09-30 15:28 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-28 0:37 [dpdk-dev] [PATCH 0/5] mbuf related patches Stephen Hemminger
2019-09-28 0:37 ` [dpdk-dev] [PATCH 1/5] mbuf: don't generate invalid mbuf in clone test Stephen Hemminger
2019-09-28 0:37 ` [dpdk-dev] [PATCH 2/5] mbuf: delinline rte_pktmbuf_linearize Stephen Hemminger
2019-09-28 15:38 ` Stephen Hemminger
2019-09-30 9:00 ` Morten Brørup
2019-09-28 0:37 ` [dpdk-dev] [PATCH 3/5] mbuf: deinline rte_pktmbuf_clone Stephen Hemminger
2019-09-28 0:37 ` [dpdk-dev] [PATCH 4/5] mbuf: add a pktmbuf copy routine Stephen Hemminger
2019-09-30 13:26 ` Morten Brørup
2019-09-28 0:37 ` [dpdk-dev] [PATCH 5/5] mbuf: add pktmbuf copy test Stephen Hemminger
2019-09-30 15:27 ` [dpdk-dev] [PATCH v2 0/6] mbuf copy related enhancements Stephen Hemminger
2019-09-30 15:27 ` [dpdk-dev] [PATCH v2 1/6] mbuf: don't generate invalid mbuf in clone test Stephen Hemminger
2019-09-30 15:27 ` [dpdk-dev] [PATCH v2 2/6] mbuf: delinline rte_pktmbuf_linearize Stephen Hemminger
2019-09-30 15:27 ` [dpdk-dev] [PATCH v2 3/6] mbuf: deinline rte_pktmbuf_clone Stephen Hemminger
2019-09-30 15:27 ` [dpdk-dev] [PATCH v2 4/6] mbuf: add a pktmbuf copy routine Stephen Hemminger
2019-09-30 15:27 ` [dpdk-dev] [PATCH v2 5/6] mbuf: add pktmbuf copy test Stephen Hemminger
2019-09-30 15:27 ` Stephen Hemminger [this message]
2019-09-30 19:20 ` [dpdk-dev] [PATCH v3 0/6] mbuf copy/cloning enhancements Stephen Hemminger
2019-09-30 19:20 ` [dpdk-dev] [PATCH v3 1/6] mbuf: don't generate invalid mbuf in clone test Stephen Hemminger
2019-09-30 19:20 ` [dpdk-dev] [PATCH v3 2/6] mbuf: delinline rte_pktmbuf_linearize Stephen Hemminger
2019-10-01 13:41 ` Andrew Rybchenko
2019-09-30 19:20 ` [dpdk-dev] [PATCH v3 3/6] mbuf: deinline rte_pktmbuf_clone Stephen Hemminger
2019-10-01 13:42 ` Andrew Rybchenko
2019-09-30 19:20 ` [dpdk-dev] [PATCH v3 4/6] mbuf: add a pktmbuf copy routine Stephen Hemminger
2019-10-01 14:03 ` Andrew Rybchenko
2019-10-01 17:36 ` Slava Ovsiienko
2019-10-01 23:29 ` Stephen Hemminger
2019-09-30 19:20 ` [dpdk-dev] [PATCH v3 5/6] mbuf: add pktmbuf copy test Stephen Hemminger
2019-09-30 19:20 ` [dpdk-dev] [PATCH v3 6/6] pdump: use new pktmbuf copy function Stephen Hemminger
2019-10-04 21:47 ` [dpdk-dev] [PATCH v4 0/4] mbuf copy/cloning enhancements Stephen Hemminger
2019-10-04 21:47 ` [dpdk-dev] [PATCH v4 1/4] mbuf: don't generate invalid mbuf in clone test Stephen Hemminger
2019-10-04 21:47 ` [dpdk-dev] [PATCH v4 2/4] mbuf: delinline rte_pktmbuf_linearize Stephen Hemminger
2019-10-04 21:47 ` [dpdk-dev] [PATCH v4 3/4] mbuf: deinline rte_pktmbuf_clone Stephen Hemminger
2019-10-04 21:47 ` [dpdk-dev] [PATCH v4 4/4] mbuf: add a pktmbuf copy routine Stephen Hemminger
2019-10-07 15:43 ` [dpdk-dev] [PATCH v5 0/5] mbuf copy/cloning enhancements Stephen Hemminger
2019-10-07 15:43 ` [dpdk-dev] [PATCH v5 1/5] mbuf: don't generate invalid mbuf in clone test Stephen Hemminger
2019-10-08 8:13 ` Olivier Matz
2019-10-07 15:43 ` [dpdk-dev] [PATCH v5 2/5] mbuf: delinline rte_pktmbuf_linearize Stephen Hemminger
2019-10-08 8:14 ` Olivier Matz
2019-10-07 15:43 ` [dpdk-dev] [PATCH v5 3/5] mbuf: deinline rte_pktmbuf_clone Stephen Hemminger
2019-10-08 8:15 ` Olivier Matz
2019-10-07 15:43 ` [dpdk-dev] [PATCH v5 4/5] mbuf: add a pktmbuf copy routine Stephen Hemminger
2019-10-08 9:03 ` Olivier Matz
2019-10-08 15:27 ` Stephen Hemminger
2019-10-07 15:43 ` [dpdk-dev] [PATCH v5 5/5] mbuf: add pktmbuf copy test Stephen Hemminger
2019-10-08 9:04 ` Olivier Matz
2019-10-08 16:33 ` [dpdk-dev] [PATCH v6 0/5] mbuf: copy/cloning enhancements Stephen Hemminger
2019-10-08 16:33 ` [dpdk-dev] [PATCH v6 1/5] mbuf: don't generate invalid mbuf in clone test Stephen Hemminger
2019-10-17 5:01 ` David Marchand
2019-10-08 16:33 ` [dpdk-dev] [PATCH v6 2/5] mbuf: delinline rte_pktmbuf_linearize Stephen Hemminger
2019-10-17 5:01 ` David Marchand
2019-10-08 16:33 ` [dpdk-dev] [PATCH v6 3/5] mbuf: deinline rte_pktmbuf_clone Stephen Hemminger
2019-10-17 5:01 ` David Marchand
2019-10-08 16:33 ` [dpdk-dev] [PATCH v6 4/5] mbuf: add a pktmbuf copy routine Stephen Hemminger
2019-10-16 6:58 ` Olivier Matz
2019-10-17 5:01 ` David Marchand
2019-10-08 16:33 ` [dpdk-dev] [PATCH v6 5/5] mbuf: add pktmbuf copy test Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190930152721.8029-7-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).