[RFC,3/8] pdump: tag copied mbuf with port
diff mbox series

Message ID 20191007165232.14535-4-stephen@networkplumber.org
State RFC
Headers show
Series
  • Packet Capture enhancements
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Stephen Hemminger Oct. 7, 2019, 4:52 p.m. UTC
Set the port when packets go into ring, so same ring can be
used for multiple ports.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/librte_pdump/rte_pdump.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

Patch
diff mbox series

diff --git a/lib/librte_pdump/rte_pdump.c b/lib/librte_pdump/rte_pdump.c
index cfb8be7ca227..830decef91e2 100644
--- a/lib/librte_pdump/rte_pdump.c
+++ b/lib/librte_pdump/rte_pdump.c
@@ -68,9 +68,9 @@  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 void
-pdump_copy(struct rte_mbuf **pkts, uint16_t nb_pkts, void *user_params)
+static void
+pdump_copy(uint16_t port, struct rte_mbuf **pkts,
+	   uint16_t nb_pkts, void *user_params)
 {
 	unsigned i;
 	int ring_enq;
@@ -86,8 +86,10 @@  pdump_copy(struct rte_mbuf **pkts, uint16_t nb_pkts, void *user_params)
 	mp = cbs->mp;
 	for (i = 0; i < nb_pkts; i++) {
 		p = rte_pktmbuf_copy(pkts[i], mp, 0, UINT32_MAX);
-		if (p)
+		if (p) {
+			p->port = port;
 			dup_bufs[d_pkts++] = p;
+		}
 	}
 
 	ring_enq = rte_ring_enqueue_burst(ring, (void *)dup_bufs, d_pkts, NULL);
@@ -101,20 +103,20 @@  pdump_copy(struct rte_mbuf **pkts, uint16_t nb_pkts, void *user_params)
 }
 
 static uint16_t
-pdump_rx(uint16_t port __rte_unused, uint16_t qidx __rte_unused,
+pdump_rx(uint16_t port, uint16_t qidx __rte_unused,
 	struct rte_mbuf **pkts, uint16_t nb_pkts,
 	uint16_t max_pkts __rte_unused,
 	void *user_params)
 {
-	pdump_copy(pkts, nb_pkts, user_params);
+	pdump_copy(port, pkts, nb_pkts, user_params);
 	return nb_pkts;
 }
 
 static uint16_t
-pdump_tx(uint16_t port __rte_unused, uint16_t qidx __rte_unused,
+pdump_tx(uint16_t port, uint16_t qidx __rte_unused,
 		struct rte_mbuf **pkts, uint16_t nb_pkts, void *user_params)
 {
-	pdump_copy(pkts, nb_pkts, user_params);
+	pdump_copy(port, pkts, nb_pkts, user_params);
 	return nb_pkts;
 }