DPDK patches and discussions
 help / color / mirror / Atom feed
From: Raslan Darawsheh <rasland@mellanox.com>
To: jingjing.wu@intel.com
Cc: thomas@monjalon.net, dev@dpdk.org, shahafs@mellanox.com,
	rasland@mellanox.com, xuemingl@mellanox.com, orika@mellanox.com,
	jerin.jacob@caviumnetworks.com, david.marchand@6wind.com,
	bernard.iremonger@intel.com, ferruh.yigit@intel.com
Subject: [dpdk-dev] [PATCH v6 2/3] app/testpmd: add packet dump callback functions
Date: Wed, 17 Oct 2018 18:22:10 +0300	[thread overview]
Message-ID: <1539789731-18409-2-git-send-email-rasland@mellanox.com> (raw)
In-Reply-To: <1539789731-18409-1-git-send-email-rasland@mellanox.com>

add new rx/tx callback functions to be used for dumping the packets.

Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>

---
changes in v6:
	rebase the work on top of the fix for compilation
---
---
 app/test-pmd/config.c  | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++
 app/test-pmd/rxonly.c  |  4 ---
 app/test-pmd/testpmd.h | 15 +++++++++--
 app/test-pmd/util.c    | 19 +++++++++++++-
 4 files changed, 98 insertions(+), 7 deletions(-)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index a6db5df..55fec7f 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -2706,6 +2706,73 @@ set_pkt_forwarding_mode(const char *fwd_mode_name)
 }
 
 void
+add_rx_dump_callbacks(portid_t portid)
+{
+	struct rte_eth_dev_info dev_info;
+	uint16_t queue;
+
+	if (port_id_is_invalid(portid, ENABLED_WARN))
+		return;
+
+	rte_eth_dev_info_get(portid, &dev_info);
+	for (queue = 0; queue < dev_info.nb_rx_queues; queue++)
+		if (!ports[portid].rx_dump_cb[queue])
+			ports[portid].rx_dump_cb[queue] =
+				rte_eth_add_rx_callback(portid, queue,
+					dump_rx_pkts, NULL);
+}
+
+void
+add_tx_dump_callbacks(portid_t portid)
+{
+	struct rte_eth_dev_info dev_info;
+	uint16_t queue;
+
+	if (port_id_is_invalid(portid, ENABLED_WARN))
+		return;
+	rte_eth_dev_info_get(portid, &dev_info);
+	for (queue = 0; queue < dev_info.nb_tx_queues; queue++)
+		if (!ports[portid].tx_dump_cb[queue])
+			ports[portid].tx_dump_cb[queue] =
+				rte_eth_add_tx_callback(portid, queue,
+							dump_tx_pkts, NULL);
+}
+
+void
+remove_rx_dump_callbacks(portid_t portid)
+{
+	struct rte_eth_dev_info dev_info;
+	uint16_t queue;
+
+	if (port_id_is_invalid(portid, ENABLED_WARN))
+		return;
+	rte_eth_dev_info_get(portid, &dev_info);
+	for (queue = 0; queue < dev_info.nb_rx_queues; queue++)
+		if (ports[portid].rx_dump_cb[queue]) {
+			rte_eth_remove_rx_callback(portid, queue,
+				ports[portid].rx_dump_cb[queue]);
+			ports[portid].rx_dump_cb[queue] = NULL;
+		}
+}
+
+void
+remove_tx_dump_callbacks(portid_t portid)
+{
+	struct rte_eth_dev_info dev_info;
+	uint16_t queue;
+
+	if (port_id_is_invalid(portid, ENABLED_WARN))
+		return;
+	rte_eth_dev_info_get(portid, &dev_info);
+	for (queue = 0; queue < dev_info.nb_tx_queues; queue++)
+		if (ports[portid].tx_dump_cb[queue]) {
+			rte_eth_remove_tx_callback(portid, queue,
+				ports[portid].tx_dump_cb[queue]);
+			ports[portid].tx_dump_cb[queue] = NULL;
+		}
+}
+
+void
 set_verbose_level(uint16_t vb_level)
 {
 	printf("Change verbose level from %u to %u\n",
diff --git a/app/test-pmd/rxonly.c b/app/test-pmd/rxonly.c
index 3eca89c..5c65fc4 100644
--- a/app/test-pmd/rxonly.c
+++ b/app/test-pmd/rxonly.c
@@ -70,10 +70,6 @@ pkt_burst_receive(struct fwd_stream *fs)
 	fs->rx_burst_stats.pkt_burst_spread[nb_rx]++;
 #endif
 	fs->rx_packets += nb_rx;
-
-	/*
-	 * Dump each received packet if verbose_level > 0.
-	 */
 	for (i = 0; i < nb_rx; i++)
 		rte_pktmbuf_free(pkts_burst[i]);
 
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index cba9640..c07bee8 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -191,6 +191,8 @@ struct rte_port {
 	uint32_t                mc_addr_nb; /**< nb. of addr. in mc_addr_pool */
 	uint8_t                 slave_flag; /**< bonding slave port */
 	struct port_flow        *flow_list; /**< Associated flows. */
+	const struct rte_eth_rxtx_callback *rx_dump_cb[MAX_QUEUE_ID+1];
+	const struct rte_eth_rxtx_callback *tx_dump_cb[MAX_QUEUE_ID+1];
 #ifdef SOFTNIC
 	struct softnic_port     softport;  /**< softnic params */
 #endif
@@ -764,8 +766,17 @@ int check_nb_rxq(queueid_t rxq);
 queueid_t get_allowed_max_nb_txq(portid_t *pid);
 int check_nb_txq(queueid_t txq);
 
-void dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],
-	 uint16_t nb_pkts, int is_rx);
+uint16_t dump_rx_pkts(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],
+		      uint16_t nb_pkts, __rte_unused uint16_t max_pkts,
+		      __rte_unused void *user_param);
+
+uint16_t dump_tx_pkts(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],
+		      uint16_t nb_pkts, __rte_unused void *user_param);
+
+void add_rx_dump_callbacks(portid_t portid);
+void remove_rx_dump_callbacks(portid_t portid);
+void add_tx_dump_callbacks(portid_t portid);
+void remove_tx_dump_callbacks(portid_t portid);
 
 /*
  * Work-around of a compilation error with ICC on invocations of the
diff --git a/app/test-pmd/util.c b/app/test-pmd/util.c
index 3ba3b58..f4125df 100644
--- a/app/test-pmd/util.c
+++ b/app/test-pmd/util.c
@@ -21,7 +21,7 @@ print_ether_addr(const char *what, struct ether_addr *eth_addr)
 	printf("%s%s", what, buf);
 }
 
-void
+static inline void
 dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],
 	      uint16_t nb_pkts, int is_rx)
 {
@@ -149,3 +149,20 @@ dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],
 		printf("  ol_flags: %s\n", buf);
 	}
 }
+
+uint16_t
+dump_rx_pkts(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],
+	     uint16_t nb_pkts, __rte_unused uint16_t max_pkts,
+	     __rte_unused void *user_param)
+{
+	dump_pkt_burst(port_id, queue, pkts, nb_pkts, 1);
+	return nb_pkts;
+}
+
+uint16_t
+dump_tx_pkts(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],
+	     uint16_t nb_pkts, __rte_unused void *user_param)
+{
+	dump_pkt_burst(port_id, queue, pkts, nb_pkts, 0);
+	return nb_pkts;
+}
-- 
2.7.4

  reply	other threads:[~2018-10-17 15:22 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-12  8:06 [dpdk-dev] [PATCH 1/2] app/testpmd: add a generic way for dumping packets Raslan Darawsheh
2018-09-12  8:06 ` [dpdk-dev] [PATCH 2/2] app/testpmd: use the generic function to dump packets Raslan Darawsheh
2018-09-13 16:43   ` David Marchand
2018-09-14  6:35     ` Jerin Jacob
2018-09-17 14:18       ` Raslan Darawsheh
2018-09-24 12:49   ` [dpdk-dev] [PATCH v2 1/3] app/testpmd: move dumping packets to a separate function Raslan Darawsheh
2018-09-24 12:49     ` [dpdk-dev] [PATCH v2 2/3] app/testpmd: add packet dump callback functions Raslan Darawsheh
2018-09-24 12:49     ` [dpdk-dev] [PATCH v2 3/3] app/testpmd: set packet dump based on verbosity level Raslan Darawsheh
2018-10-02 13:35     ` [dpdk-dev] [PATCH v2 1/3] app/testpmd: move dumping packets to a separate function Iremonger, Bernard
2018-10-03 15:11       ` Raslan Darawsheh
2018-10-03 15:16     ` [dpdk-dev] [PATCH v3 " Raslan Darawsheh
2018-10-03 15:16       ` [dpdk-dev] [PATCH v3 2/3] app/testpmd: add packet dump callback functions Raslan Darawsheh
2018-10-03 15:16       ` [dpdk-dev] [PATCH v3 3/3] app/testpmd: set packet dump based on verbosity level Raslan Darawsheh
2018-10-04 14:43       ` [dpdk-dev] [PATCH v3 1/3] app/testpmd: move dumping packets to a separate function Iremonger, Bernard
2018-10-07  7:38         ` Raslan Darawsheh
2018-10-07  7:38     ` [dpdk-dev] [PATCH v4 " Raslan Darawsheh
2018-10-07  7:38       ` [dpdk-dev] [PATCH v4 2/3] app/testpmd: add packet dump callback functions Raslan Darawsheh
2018-10-08 10:03         ` Iremonger, Bernard
2018-10-11 14:58         ` Ferruh Yigit
2018-10-16 10:11           ` Raslan Darawsheh
2018-10-07  7:38       ` [dpdk-dev] [PATCH v4 3/3] app/testpmd: set packet dump based on verbosity level Raslan Darawsheh
2018-10-08 10:04         ` Iremonger, Bernard
2018-10-11 15:00         ` Ferruh Yigit
2018-10-11 15:24           ` Iremonger, Bernard
2018-10-11 15:52             ` Ferruh Yigit
2018-10-11 16:39               ` Iremonger, Bernard
2018-10-17 12:34                 ` Ferruh Yigit
2018-10-08 10:01       ` [dpdk-dev] [PATCH v4 1/3] app/testpmd: move dumping packets to a separate function Iremonger, Bernard
2018-10-11 14:56       ` Ferruh Yigit
2018-10-16 10:10         ` Raslan Darawsheh
2018-10-16 13:11           ` Ferruh Yigit
2018-10-17  7:27       ` [dpdk-dev] [PATCH v5 " Raslan Darawsheh
2018-10-17  7:27         ` [dpdk-dev] [PATCH v5 2/3] app/testpmd: add packet dump callback functions Raslan Darawsheh
2018-10-17  7:27         ` [dpdk-dev] [PATCH v5 3/3] app/testpmd: set packet dump based on verbosity level Raslan Darawsheh
2018-10-17 12:27         ` [dpdk-dev] [PATCH v5 1/3] app/testpmd: move dumping packets to a separate function Ferruh Yigit
2018-10-17 12:59           ` Iremonger, Bernard
2018-10-17 15:22             ` Raslan Darawsheh
2018-10-17 15:22       ` [dpdk-dev] [PATCH v6 " Raslan Darawsheh
2018-10-17 15:22         ` Raslan Darawsheh [this message]
2018-10-17 15:22         ` [dpdk-dev] [PATCH v6 3/3] app/testpmd: set packet dump based on verbosity level Raslan Darawsheh
2018-10-17 16:24           ` Iremonger, Bernard
2018-10-17 16:33             ` Ferruh Yigit
2018-10-18  8:19               ` Raslan Darawsheh
2018-10-18  8:33                 ` Ferruh Yigit
2018-10-18  8:47                   ` Raslan Darawsheh
2018-10-17 16:22         ` [dpdk-dev] [PATCH v6 1/3] app/testpmd: move dumping packets to a separate function Ferruh Yigit
2018-09-12 15:00 ` [dpdk-dev] [PATCH 1/2] app/testpmd: add a generic way for dumping packets Thomas Monjalon

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=1539789731-18409-2-git-send-email-rasland@mellanox.com \
    --to=rasland@mellanox.com \
    --cc=bernard.iremonger@intel.com \
    --cc=david.marchand@6wind.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=jerin.jacob@caviumnetworks.com \
    --cc=jingjing.wu@intel.com \
    --cc=orika@mellanox.com \
    --cc=shahafs@mellanox.com \
    --cc=thomas@monjalon.net \
    --cc=xuemingl@mellanox.com \
    /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).