DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 1/2] app/testpmd: add a generic way for dumping packets
@ 2018-09-12  8:06 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-12 15:00 ` [dpdk-dev] [PATCH 1/2] app/testpmd: add a generic way for dumping packets Thomas Monjalon
  0 siblings, 2 replies; 47+ messages in thread
From: Raslan Darawsheh @ 2018-09-12  8:06 UTC (permalink / raw)
  To: jingjing.wu; +Cc: thomas, dev, shahafs, rasland, xuemingl

verbosity for the received/sent packets is needed in all of the
forwarding engines so moving it to be in a separate function.

Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
---
 app/test-pmd/Makefile  |   1 +
 app/test-pmd/testpmd.h |   2 +
 app/test-pmd/util.c    | 143 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 146 insertions(+)
 create mode 100644 app/test-pmd/util.c

diff --git a/app/test-pmd/Makefile b/app/test-pmd/Makefile
index 2b4d604..e2c7845 100644
--- a/app/test-pmd/Makefile
+++ b/app/test-pmd/Makefile
@@ -35,6 +35,7 @@ SRCS-y += csumonly.c
 SRCS-y += icmpecho.c
 SRCS-$(CONFIG_RTE_LIBRTE_IEEE1588) += ieee1588fwd.c
 SRCS-$(CONFIG_RTE_LIBRTE_BPF) += bpf_cmd.c
+SRCS-y += util.c
 
 ifeq ($(CONFIG_RTE_LIBRTE_PMD_SOFTNIC), y)
 SRCS-y += softnicfwd.c
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index a1f6614..a0d9ce1 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -743,6 +743,8 @@ 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(struct fwd_stream *fs, struct rte_mbuf *pkts_burst[],
+		    uint16_t nb_rx, int direction);
 /*
  * Work-around of a compilation error with ICC on invocations of the
  * rte_be_to_cpu_16() function.
diff --git a/app/test-pmd/util.c b/app/test-pmd/util.c
new file mode 100644
index 0000000..87cbbcd
--- /dev/null
+++ b/app/test-pmd/util.c
@@ -0,0 +1,143 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2018 Mellanox technology.
+ */
+
+#include <stdio.h>
+
+#include <rte_net.h>
+#include <rte_mbuf.h>
+#include <rte_ether.h>
+#include <rte_ethdev.h>
+#include <rte_flow.h>
+
+#include "testpmd.h"
+
+static inline void
+print_ether_addr(const char *what, struct ether_addr *eth_addr)
+{
+	char buf[ETHER_ADDR_FMT_SIZE];
+	ether_format_addr(buf, ETHER_ADDR_FMT_SIZE, eth_addr);
+	printf("%s%s", what, buf);
+}
+
+void
+dump_pkt_burst(struct fwd_stream *fs, struct rte_mbuf **pkts_burst,
+	       uint16_t nb_pkts, int direction)
+{
+	struct rte_mbuf  *mb;
+	struct ether_hdr *eth_hdr;
+	uint16_t eth_type;
+	uint64_t ol_flags;
+	uint16_t i, packet_type;
+	uint16_t is_encapsulation;
+	char buf[256];
+	struct rte_net_hdr_lens hdr_lens;
+	uint32_t sw_packet_type;
+
+	printf("port %u/queue %u: %s %u packets\n",
+	       direction ? fs->rx_port : fs->tx_port,
+	       direction ? (unsigned int) fs->rx_queue :
+	       (unsigned int) fs->tx_queue,
+	       direction ? "received" : "sent",
+	       (unsigned int) nb_pkts);
+	for (i = 0; i < nb_pkts; i++) {
+		mb = pkts_burst[i];
+		eth_hdr = rte_pktmbuf_mtod(mb, struct ether_hdr *);
+		eth_type = RTE_BE_TO_CPU_16(eth_hdr->ether_type);
+		ol_flags = mb->ol_flags;
+		packet_type = mb->packet_type;
+		is_encapsulation = RTE_ETH_IS_TUNNEL_PKT(packet_type);
+
+		print_ether_addr("  src=", &eth_hdr->s_addr);
+		print_ether_addr(" - dst=", &eth_hdr->d_addr);
+		printf(" - type=0x%04x - length=%u - nb_segs=%d",
+		       eth_type, (unsigned int) mb->pkt_len,
+		       (int)mb->nb_segs);
+		printf(" - RSS hash=0x%x", (unsigned int) mb->hash.rss);
+		printf(" - RSS queue=0x%x", (unsigned int) fs->rx_queue);
+		if (ol_flags & PKT_RX_FDIR) {
+			printf(" - FDIR matched ");
+			if (ol_flags & PKT_RX_FDIR_ID)
+				printf("ID=0x%x",
+				       mb->hash.fdir.hi);
+			else if (ol_flags & PKT_RX_FDIR_FLX)
+				printf("flex bytes=0x%08x %08x",
+				       mb->hash.fdir.hi, mb->hash.fdir.lo);
+			else
+				printf("hash=0x%x ID=0x%x ",
+				       mb->hash.fdir.hash, mb->hash.fdir.id);
+		}
+		if (ol_flags & PKT_RX_TIMESTAMP)
+			printf(" - timestamp %"PRIu64" ", mb->timestamp);
+		if (ol_flags & PKT_RX_VLAN_STRIPPED)
+			printf(" - VLAN tci=0x%x", mb->vlan_tci);
+		if (ol_flags & PKT_RX_QINQ_STRIPPED)
+			printf(" - QinQ VLAN tci=0x%x, VLAN tci outer=0x%x",
+			       mb->vlan_tci, mb->vlan_tci_outer);
+		if (mb->packet_type) {
+			rte_get_ptype_name(mb->packet_type, buf, sizeof(buf));
+			printf(" - hw ptype: %s", buf);
+		}
+		sw_packet_type = rte_net_get_ptype(mb, &hdr_lens,
+						   RTE_PTYPE_ALL_MASK);
+		rte_get_ptype_name(sw_packet_type, buf, sizeof(buf));
+		printf(" - sw ptype: %s", buf);
+		if (sw_packet_type & RTE_PTYPE_L2_MASK)
+			printf(" - l2_len=%d", hdr_lens.l2_len);
+		if (sw_packet_type & RTE_PTYPE_L3_MASK)
+
+			printf(" - l4_len=%d", hdr_lens.l4_len);
+		if (sw_packet_type & RTE_PTYPE_TUNNEL_MASK)
+			printf(" - tunnel_len=%d", hdr_lens.tunnel_len);
+		if (sw_packet_type & RTE_PTYPE_INNER_L2_MASK)
+			printf(" - inner_l2_len=%d", hdr_lens.inner_l2_len);
+		if (sw_packet_type & RTE_PTYPE_INNER_L4_MASK)
+			printf(" - inner_l4_len=%d", hdr_lens.inner_l4_len);
+		if (is_encapsulation) {
+			struct ipv4_hdr *ipv4_hdr;
+			struct ipv6_hdr *ipv6_hdr;
+			struct udp_hdr *udp_hdr;
+			uint8_t l2_len;
+			uint8_t l3_len;
+			uint8_t l4_len;
+			uint8_t l4_proto;
+			struct  vxlan_hdr *vxlan_hdr;
+
+			l2_len  = sizeof(struct ether_hdr);
+
+			/* Do not support ipv4 option field */
+			if (RTE_ETH_IS_IPV4_HDR(packet_type)) {
+				l3_len = sizeof(struct ipv4_hdr);
+				ipv4_hdr = rte_pktmbuf_mtod_offset(mb,
+				struct ipv4_hdr *,
+				l2_len);
+				l4_proto = ipv4_hdr->next_proto_id;
+			} else {
+				l3_len = sizeof(struct ipv6_hdr);
+				ipv6_hdr = rte_pktmbuf_mtod_offset(mb,
+				struct ipv6_hdr *,
+				l2_len);
+				l4_proto = ipv6_hdr->proto;
+			}
+			if (l4_proto == IPPROTO_UDP) {
+				udp_hdr = rte_pktmbuf_mtod_offset(mb,
+				struct udp_hdr *,
+				l2_len + l3_len);
+				l4_len = sizeof(struct udp_hdr);
+				vxlan_hdr = rte_pktmbuf_mtod_offset(mb,
+				struct vxlan_hdr *,
+				l2_len + l3_len + l4_len);
+
+				printf(" - VXLAN packet: packet type =%d, "
+				       "Destination UDP port =%d, VNI = %d",
+				       packet_type,
+				       RTE_BE_TO_CPU_16(udp_hdr->dst_port),
+				       rte_be_to_cpu_32(vxlan_hdr->vx_vni) >> 8);
+			}
+		}
+		printf(" - Receive queue=0x%x", (unsigned int) fs->rx_queue);
+		printf("\n");
+		rte_get_rx_ol_flag_list(mb->ol_flags, buf, sizeof(buf));
+		printf("  ol_flags: %s\n", buf);
+	}
+}
-- 
2.7.4

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH 2/2] app/testpmd: use the generic function to dump packets
  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 ` Raslan Darawsheh
  2018-09-13 16:43   ` David Marchand
  2018-09-24 12:49   ` [dpdk-dev] [PATCH v2 1/3] app/testpmd: move dumping packets to a separate function Raslan Darawsheh
  2018-09-12 15:00 ` [dpdk-dev] [PATCH 1/2] app/testpmd: add a generic way for dumping packets Thomas Monjalon
  1 sibling, 2 replies; 47+ messages in thread
From: Raslan Darawsheh @ 2018-09-12  8:06 UTC (permalink / raw)
  To: jingjing.wu; +Cc: thomas, dev, shahafs, rasland, xuemingl

use the generic function to dump packets for several forwarding
engines.

To dump received packets first bit of verbosity need to be set and for sent
packets verbosity second bit need to be set.

for example:
	dump rx : set verbose 1
	dump tx : set verbose 2
	dump rx and tx : set verbose 3

Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
---
 app/test-pmd/iofwd.c   |   2 +
 app/test-pmd/macfwd.c  |   4 ++
 app/test-pmd/macswap.c |   4 ++
 app/test-pmd/rxonly.c  | 136 ++-----------------------------------------------
 4 files changed, 15 insertions(+), 131 deletions(-)

diff --git a/app/test-pmd/iofwd.c b/app/test-pmd/iofwd.c
index 9dce76e..7c09271 100644
--- a/app/test-pmd/iofwd.c
+++ b/app/test-pmd/iofwd.c
@@ -69,6 +69,8 @@ pkt_burst_io_forward(struct fwd_stream *fs)
 	if (unlikely(nb_rx == 0))
 		return;
 	fs->rx_packets += nb_rx;
+	if (unlikely(verbose_level & 0x1))
+		dump_pkt_burst(fs, pkts_burst, nb_rx, 1);
 
 #ifdef RTE_TEST_PMD_RECORD_BURST_STATS
 	fs->rx_burst_stats.pkt_burst_spread[nb_rx]++;
diff --git a/app/test-pmd/macfwd.c b/app/test-pmd/macfwd.c
index 7cac757..b1b00bc 100644
--- a/app/test-pmd/macfwd.c
+++ b/app/test-pmd/macfwd.c
@@ -78,6 +78,8 @@ pkt_burst_mac_forward(struct fwd_stream *fs)
 	fs->rx_burst_stats.pkt_burst_spread[nb_rx]++;
 #endif
 	fs->rx_packets += nb_rx;
+	if (unlikely(verbose_level & 0x1))
+		dump_pkt_burst(fs, pkts_burst, nb_rx, 1);
 	txp = &ports[fs->tx_port];
 	tx_offloads = txp->dev_conf.txmode.offloads;
 	if (tx_offloads	& DEV_TX_OFFLOAD_VLAN_INSERT)
@@ -117,6 +119,8 @@ pkt_burst_mac_forward(struct fwd_stream *fs)
 	}
 
 	fs->tx_packets += nb_tx;
+	if (unlikely(verbose_level & 0x2))
+		dump_pkt_burst(fs, pkts_burst, nb_tx, 0);
 #ifdef RTE_TEST_PMD_RECORD_BURST_STATS
 	fs->tx_burst_stats.pkt_burst_spread[nb_tx]++;
 #endif
diff --git a/app/test-pmd/macswap.c b/app/test-pmd/macswap.c
index a8384d5..5611bf8 100644
--- a/app/test-pmd/macswap.c
+++ b/app/test-pmd/macswap.c
@@ -107,6 +107,8 @@ pkt_burst_mac_swap(struct fwd_stream *fs)
 	fs->rx_burst_stats.pkt_burst_spread[nb_rx]++;
 #endif
 	fs->rx_packets += nb_rx;
+	if (unlikely(verbose_level & 0x1))
+		dump_pkt_burst(fs, pkts_burst, nb_rx, 1);
 	txp = &ports[fs->tx_port];
 	tx_offloads = txp->dev_conf.txmode.offloads;
 	if (tx_offloads	& DEV_TX_OFFLOAD_VLAN_INSERT)
@@ -147,6 +149,8 @@ pkt_burst_mac_swap(struct fwd_stream *fs)
 		}
 	}
 	fs->tx_packets += nb_tx;
+	if (unlikely(verbose_level & 0x2))
+		dump_pkt_burst(fs, pkts_burst, nb_tx, 0);
 #ifdef RTE_TEST_PMD_RECORD_BURST_STATS
 	fs->tx_burst_stats.pkt_burst_spread[nb_tx]++;
 #endif
diff --git a/app/test-pmd/rxonly.c b/app/test-pmd/rxonly.c
index a93d806..f9bfdeb 100644
--- a/app/test-pmd/rxonly.c
+++ b/app/test-pmd/rxonly.c
@@ -40,14 +40,6 @@
 
 #include "testpmd.h"
 
-static inline void
-print_ether_addr(const char *what, struct ether_addr *eth_addr)
-{
-	char buf[ETHER_ADDR_FMT_SIZE];
-	ether_format_addr(buf, ETHER_ADDR_FMT_SIZE, eth_addr);
-	printf("%s%s", what, buf);
-}
-
 /*
  * Received a burst of packets.
  */
@@ -55,16 +47,8 @@ static void
 pkt_burst_receive(struct fwd_stream *fs)
 {
 	struct rte_mbuf  *pkts_burst[MAX_PKT_BURST];
-	struct rte_mbuf  *mb;
-	struct ether_hdr *eth_hdr;
-	uint16_t eth_type;
-	uint64_t ol_flags;
 	uint16_t nb_rx;
-	uint16_t i, packet_type;
-	uint16_t is_encapsulation;
-	char buf[256];
-	struct rte_net_hdr_lens hdr_lens;
-	uint32_t sw_packet_type;
+	uint16_t i;
 
 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
 	uint64_t start_tsc;
@@ -90,120 +74,10 @@ pkt_burst_receive(struct fwd_stream *fs)
 	/*
 	 * Dump each received packet if verbose_level > 0.
 	 */
-	if (verbose_level > 0)
-		printf("port %u/queue %u: received %u packets\n",
-		       fs->rx_port,
-		       (unsigned) fs->rx_queue,
-		       (unsigned) nb_rx);
-	for (i = 0; i < nb_rx; i++) {
-		mb = pkts_burst[i];
-		if (verbose_level == 0) {
-			rte_pktmbuf_free(mb);
-			continue;
-		}
-		eth_hdr = rte_pktmbuf_mtod(mb, struct ether_hdr *);
-		eth_type = RTE_BE_TO_CPU_16(eth_hdr->ether_type);
-		ol_flags = mb->ol_flags;
-		packet_type = mb->packet_type;
-		is_encapsulation = RTE_ETH_IS_TUNNEL_PKT(packet_type);
-
-		print_ether_addr("  src=", &eth_hdr->s_addr);
-		print_ether_addr(" - dst=", &eth_hdr->d_addr);
-		printf(" - type=0x%04x - length=%u - nb_segs=%d",
-		       eth_type, (unsigned) mb->pkt_len,
-		       (int)mb->nb_segs);
-		if (ol_flags & PKT_RX_RSS_HASH) {
-			printf(" - RSS hash=0x%x", (unsigned) mb->hash.rss);
-			printf(" - RSS queue=0x%x",(unsigned) fs->rx_queue);
-		}
-		if (ol_flags & PKT_RX_FDIR) {
-			printf(" - FDIR matched ");
-			if (ol_flags & PKT_RX_FDIR_ID)
-				printf("ID=0x%x",
-				       mb->hash.fdir.hi);
-			else if (ol_flags & PKT_RX_FDIR_FLX)
-				printf("flex bytes=0x%08x %08x",
-				       mb->hash.fdir.hi, mb->hash.fdir.lo);
-			else
-				printf("hash=0x%x ID=0x%x ",
-				       mb->hash.fdir.hash, mb->hash.fdir.id);
-		}
-		if (ol_flags & PKT_RX_TIMESTAMP)
-			printf(" - timestamp %"PRIu64" ", mb->timestamp);
-		if (ol_flags & PKT_RX_VLAN_STRIPPED)
-			printf(" - VLAN tci=0x%x", mb->vlan_tci);
-		if (ol_flags & PKT_RX_QINQ_STRIPPED)
-			printf(" - QinQ VLAN tci=0x%x, VLAN tci outer=0x%x",
-					mb->vlan_tci, mb->vlan_tci_outer);
-		if (mb->packet_type) {
-			rte_get_ptype_name(mb->packet_type, buf, sizeof(buf));
-			printf(" - hw ptype: %s", buf);
-		}
-		sw_packet_type = rte_net_get_ptype(mb, &hdr_lens,
-			RTE_PTYPE_ALL_MASK);
-		rte_get_ptype_name(sw_packet_type, buf, sizeof(buf));
-		printf(" - sw ptype: %s", buf);
-		if (sw_packet_type & RTE_PTYPE_L2_MASK)
-			printf(" - l2_len=%d", hdr_lens.l2_len);
-		if (sw_packet_type & RTE_PTYPE_L3_MASK)
-			printf(" - l3_len=%d", hdr_lens.l3_len);
-		if (sw_packet_type & RTE_PTYPE_L4_MASK)
-			printf(" - l4_len=%d", hdr_lens.l4_len);
-		if (sw_packet_type & RTE_PTYPE_TUNNEL_MASK)
-			printf(" - tunnel_len=%d", hdr_lens.tunnel_len);
-		if (sw_packet_type & RTE_PTYPE_INNER_L2_MASK)
-			printf(" - inner_l2_len=%d", hdr_lens.inner_l2_len);
-		if (sw_packet_type & RTE_PTYPE_INNER_L3_MASK)
-			printf(" - inner_l3_len=%d", hdr_lens.inner_l3_len);
-		if (sw_packet_type & RTE_PTYPE_INNER_L4_MASK)
-			printf(" - inner_l4_len=%d", hdr_lens.inner_l4_len);
-		if (is_encapsulation) {
-			struct ipv4_hdr *ipv4_hdr;
-			struct ipv6_hdr *ipv6_hdr;
-			struct udp_hdr *udp_hdr;
-			uint8_t l2_len;
-			uint8_t l3_len;
-			uint8_t l4_len;
-			uint8_t l4_proto;
-			struct  vxlan_hdr *vxlan_hdr;
-
-			l2_len  = sizeof(struct ether_hdr);
-
-			 /* Do not support ipv4 option field */
-			if (RTE_ETH_IS_IPV4_HDR(packet_type)) {
-				l3_len = sizeof(struct ipv4_hdr);
-				ipv4_hdr = rte_pktmbuf_mtod_offset(mb,
-								   struct ipv4_hdr *,
-								   l2_len);
-				l4_proto = ipv4_hdr->next_proto_id;
-			} else {
-				l3_len = sizeof(struct ipv6_hdr);
-				ipv6_hdr = rte_pktmbuf_mtod_offset(mb,
-								   struct ipv6_hdr *,
-								   l2_len);
-				l4_proto = ipv6_hdr->proto;
-			}
-			if (l4_proto == IPPROTO_UDP) {
-				udp_hdr = rte_pktmbuf_mtod_offset(mb,
-								  struct udp_hdr *,
-								  l2_len + l3_len);
-				l4_len = sizeof(struct udp_hdr);
-				vxlan_hdr = rte_pktmbuf_mtod_offset(mb,
-								    struct vxlan_hdr *,
-								    l2_len + l3_len + l4_len);
-
-				printf(" - VXLAN packet: packet type =%d, "
-					"Destination UDP port =%d, VNI = %d",
-					packet_type, RTE_BE_TO_CPU_16(udp_hdr->dst_port),
-					rte_be_to_cpu_32(vxlan_hdr->vx_vni) >> 8);
-			}
-		}
-		printf(" - Receive queue=0x%x", (unsigned) fs->rx_queue);
-		printf("\n");
-		rte_get_rx_ol_flag_list(mb->ol_flags, buf, sizeof(buf));
-		printf("  ol_flags: %s\n", buf);
-		rte_pktmbuf_free(mb);
-	}
+	if (unlikely(verbose_level & 0x1))
+		dump_pkt_burst(fs, pkts_burst, nb_rx, 1);
+	for (i = 0; i < nb_rx; i++)
+		rte_pktmbuf_free(pkts_burst[i]);
 
 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
 	end_tsc = rte_rdtsc();
-- 
2.7.4

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH 1/2] app/testpmd: add a generic way for dumping packets
  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-12 15:00 ` Thomas Monjalon
  1 sibling, 0 replies; 47+ messages in thread
From: Thomas Monjalon @ 2018-09-12 15:00 UTC (permalink / raw)
  To: Raslan Darawsheh; +Cc: jingjing.wu, dev, shahafs, xuemingl

12/09/2018 10:06, Raslan Darawsheh:
> verbosity for the received/sent packets is needed in all of the
> forwarding engines so moving it to be in a separate function.
> 
> Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
> ---
>  app/test-pmd/Makefile  |   1 +
>  app/test-pmd/testpmd.h |   2 +
>  app/test-pmd/util.c    | 143 +++++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 146 insertions(+)

If you are moving code from app/test-pmd/rxonly.c, you should
update this file in the same patch, so it will appear more clearly as a move.
Then the second patch would be only about adding the feature to more engines.

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH 2/2] app/testpmd: use the generic function to dump packets
  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-24 12:49   ` [dpdk-dev] [PATCH v2 1/3] app/testpmd: move dumping packets to a separate function Raslan Darawsheh
  1 sibling, 1 reply; 47+ messages in thread
From: David Marchand @ 2018-09-13 16:43 UTC (permalink / raw)
  To: Raslan Darawsheh
  Cc: Wu, Jingjing, Thomas Monjalon, dev, Shahaf Shuler, xuemingl

On Wed, Sep 12, 2018 at 10:06 AM, Raslan Darawsheh <rasland@mellanox.com> wrote:
> use the generic function to dump packets for several forwarding
> engines.

Rather than patching some engines, how about putting this in rx/tx callbacks ?
A bit like something I sent earlier ?

http://patches.dpdk.org/patch/44465/


-- 
David Marchand

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH 2/2] app/testpmd: use the generic function to dump packets
  2018-09-13 16:43   ` David Marchand
@ 2018-09-14  6:35     ` Jerin Jacob
  2018-09-17 14:18       ` Raslan Darawsheh
  0 siblings, 1 reply; 47+ messages in thread
From: Jerin Jacob @ 2018-09-14  6:35 UTC (permalink / raw)
  To: David Marchand
  Cc: Raslan Darawsheh, Wu, Jingjing, Thomas Monjalon, dev,
	Shahaf Shuler, xuemingl

-----Original Message-----
> Date: Thu, 13 Sep 2018 18:43:02 +0200
> From: David Marchand <david.marchand@6wind.com>
> To: Raslan Darawsheh <rasland@mellanox.com>
> Cc: "Wu, Jingjing" <jingjing.wu@intel.com>, Thomas Monjalon
>  <thomas@monjalon.net>, dev@dpdk.org, Shahaf Shuler <shahafs@mellanox.com>,
>  xuemingl@mellanox.com
> Subject: Re: [dpdk-dev] [PATCH 2/2] app/testpmd: use the generic function
>  to dump packets
> 
> 
> On Wed, Sep 12, 2018 at 10:06 AM, Raslan Darawsheh <rasland@mellanox.com> wrote:
> > use the generic function to dump packets for several forwarding
> > engines.
> 
> Rather than patching some engines, how about putting this in rx/tx callbacks ?

+1 to have zero performance impact on forward engines.

> A bit like something I sent earlier ?
> 
> http://patches.dpdk.org/patch/44465/
> 
> 
> --
> David Marchand

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH 2/2] app/testpmd: use the generic function to dump packets
  2018-09-14  6:35     ` Jerin Jacob
@ 2018-09-17 14:18       ` Raslan Darawsheh
  0 siblings, 0 replies; 47+ messages in thread
From: Raslan Darawsheh @ 2018-09-17 14:18 UTC (permalink / raw)
  To: Jerin Jacob, David Marchand
  Cc: Wu, Jingjing, Thomas Monjalon, dev, Shahaf Shuler, Xueming(Steven) Li

Hi David, 

Thx for this feedback I'll be sending a new version with your suggestion. 

Kindest regards,
Raslan Darawsheh

-----Original Message-----
From: Jerin Jacob <jerin.jacob@caviumnetworks.com> 
Sent: Friday, September 14, 2018 9:35 AM
To: David Marchand <david.marchand@6wind.com>
Cc: Raslan Darawsheh <rasland@mellanox.com>; Wu, Jingjing <jingjing.wu@intel.com>; Thomas Monjalon <thomas@monjalon.net>; dev@dpdk.org; Shahaf Shuler <shahafs@mellanox.com>; Xueming(Steven) Li <xuemingl@mellanox.com>
Subject: Re: [dpdk-dev] [PATCH 2/2] app/testpmd: use the generic function to dump packets

-----Original Message-----
> Date: Thu, 13 Sep 2018 18:43:02 +0200
> From: David Marchand <david.marchand@6wind.com>
> To: Raslan Darawsheh <rasland@mellanox.com>
> Cc: "Wu, Jingjing" <jingjing.wu@intel.com>, Thomas Monjalon  
> <thomas@monjalon.net>, dev@dpdk.org, Shahaf Shuler 
> <shahafs@mellanox.com>,  xuemingl@mellanox.com
> Subject: Re: [dpdk-dev] [PATCH 2/2] app/testpmd: use the generic 
> function  to dump packets
> 
> 
> On Wed, Sep 12, 2018 at 10:06 AM, Raslan Darawsheh <rasland@mellanox.com> wrote:
> > use the generic function to dump packets for several forwarding 
> > engines.
> 
> Rather than patching some engines, how about putting this in rx/tx callbacks ?

+1 to have zero performance impact on forward engines.

> A bit like something I sent earlier ?
> 
> https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpatc
> hes.dpdk.org%2Fpatch%2F44465%2F&amp;data=02%7C01%7Crasland%40mellanox.
> com%7C9bbd72a1f31b4555b0be08d61a0c4402%7Ca652971c7d2e4d9ba6a4d149256f4
> 61b%7C0%7C0%7C636725037336863883&amp;sdata=bWeN5Rsi0vrX5oPZYI5%2FChCZ4
> VogpRAiY6doOkT0Q8s%3D&amp;reserved=0
> 
> 
> --
> David Marchand

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH v2 1/3] app/testpmd: move dumping packets to a separate function
  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-24 12:49   ` Raslan Darawsheh
  2018-09-24 12:49     ` [dpdk-dev] [PATCH v2 2/3] app/testpmd: add packet dump callback functions Raslan Darawsheh
                       ` (4 more replies)
  1 sibling, 5 replies; 47+ messages in thread
From: Raslan Darawsheh @ 2018-09-24 12:49 UTC (permalink / raw)
  To: jingjing.wu
  Cc: Thomas Monjalon, dev, Shahaf Shuler, Raslan Darawsheh,
	Xueming(Steven) Li, Ori Katz, jerin.jacob, david.marchand

verbosity for the received/sent packets is needed in all of the
forwarding engines so moving it to be in a separate function

Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
---
 app/test-pmd/Makefile |   1 +
 app/test-pmd/rxonly.c | 134 ++--------------------------------------------
 app/test-pmd/util.c   | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 148 insertions(+), 131 deletions(-)
 create mode 100644 app/test-pmd/util.c

diff --git a/app/test-pmd/Makefile b/app/test-pmd/Makefile
index 2b4d604..e2c7845 100644
--- a/app/test-pmd/Makefile
+++ b/app/test-pmd/Makefile
@@ -35,6 +35,7 @@ SRCS-y += csumonly.c
 SRCS-y += icmpecho.c
 SRCS-$(CONFIG_RTE_LIBRTE_IEEE1588) += ieee1588fwd.c
 SRCS-$(CONFIG_RTE_LIBRTE_BPF) += bpf_cmd.c
+SRCS-y += util.c
 
 ifeq ($(CONFIG_RTE_LIBRTE_PMD_SOFTNIC), y)
 SRCS-y += softnicfwd.c
diff --git a/app/test-pmd/rxonly.c b/app/test-pmd/rxonly.c
index a93d806..3eca89c 100644
--- a/app/test-pmd/rxonly.c
+++ b/app/test-pmd/rxonly.c
@@ -40,14 +40,6 @@
 
 #include "testpmd.h"
 
-static inline void
-print_ether_addr(const char *what, struct ether_addr *eth_addr)
-{
-	char buf[ETHER_ADDR_FMT_SIZE];
-	ether_format_addr(buf, ETHER_ADDR_FMT_SIZE, eth_addr);
-	printf("%s%s", what, buf);
-}
-
 /*
  * Received a burst of packets.
  */
@@ -55,16 +47,8 @@ static void
 pkt_burst_receive(struct fwd_stream *fs)
 {
 	struct rte_mbuf  *pkts_burst[MAX_PKT_BURST];
-	struct rte_mbuf  *mb;
-	struct ether_hdr *eth_hdr;
-	uint16_t eth_type;
-	uint64_t ol_flags;
 	uint16_t nb_rx;
-	uint16_t i, packet_type;
-	uint16_t is_encapsulation;
-	char buf[256];
-	struct rte_net_hdr_lens hdr_lens;
-	uint32_t sw_packet_type;
+	uint16_t i;
 
 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
 	uint64_t start_tsc;
@@ -90,120 +74,8 @@ pkt_burst_receive(struct fwd_stream *fs)
 	/*
 	 * Dump each received packet if verbose_level > 0.
 	 */
-	if (verbose_level > 0)
-		printf("port %u/queue %u: received %u packets\n",
-		       fs->rx_port,
-		       (unsigned) fs->rx_queue,
-		       (unsigned) nb_rx);
-	for (i = 0; i < nb_rx; i++) {
-		mb = pkts_burst[i];
-		if (verbose_level == 0) {
-			rte_pktmbuf_free(mb);
-			continue;
-		}
-		eth_hdr = rte_pktmbuf_mtod(mb, struct ether_hdr *);
-		eth_type = RTE_BE_TO_CPU_16(eth_hdr->ether_type);
-		ol_flags = mb->ol_flags;
-		packet_type = mb->packet_type;
-		is_encapsulation = RTE_ETH_IS_TUNNEL_PKT(packet_type);
-
-		print_ether_addr("  src=", &eth_hdr->s_addr);
-		print_ether_addr(" - dst=", &eth_hdr->d_addr);
-		printf(" - type=0x%04x - length=%u - nb_segs=%d",
-		       eth_type, (unsigned) mb->pkt_len,
-		       (int)mb->nb_segs);
-		if (ol_flags & PKT_RX_RSS_HASH) {
-			printf(" - RSS hash=0x%x", (unsigned) mb->hash.rss);
-			printf(" - RSS queue=0x%x",(unsigned) fs->rx_queue);
-		}
-		if (ol_flags & PKT_RX_FDIR) {
-			printf(" - FDIR matched ");
-			if (ol_flags & PKT_RX_FDIR_ID)
-				printf("ID=0x%x",
-				       mb->hash.fdir.hi);
-			else if (ol_flags & PKT_RX_FDIR_FLX)
-				printf("flex bytes=0x%08x %08x",
-				       mb->hash.fdir.hi, mb->hash.fdir.lo);
-			else
-				printf("hash=0x%x ID=0x%x ",
-				       mb->hash.fdir.hash, mb->hash.fdir.id);
-		}
-		if (ol_flags & PKT_RX_TIMESTAMP)
-			printf(" - timestamp %"PRIu64" ", mb->timestamp);
-		if (ol_flags & PKT_RX_VLAN_STRIPPED)
-			printf(" - VLAN tci=0x%x", mb->vlan_tci);
-		if (ol_flags & PKT_RX_QINQ_STRIPPED)
-			printf(" - QinQ VLAN tci=0x%x, VLAN tci outer=0x%x",
-					mb->vlan_tci, mb->vlan_tci_outer);
-		if (mb->packet_type) {
-			rte_get_ptype_name(mb->packet_type, buf, sizeof(buf));
-			printf(" - hw ptype: %s", buf);
-		}
-		sw_packet_type = rte_net_get_ptype(mb, &hdr_lens,
-			RTE_PTYPE_ALL_MASK);
-		rte_get_ptype_name(sw_packet_type, buf, sizeof(buf));
-		printf(" - sw ptype: %s", buf);
-		if (sw_packet_type & RTE_PTYPE_L2_MASK)
-			printf(" - l2_len=%d", hdr_lens.l2_len);
-		if (sw_packet_type & RTE_PTYPE_L3_MASK)
-			printf(" - l3_len=%d", hdr_lens.l3_len);
-		if (sw_packet_type & RTE_PTYPE_L4_MASK)
-			printf(" - l4_len=%d", hdr_lens.l4_len);
-		if (sw_packet_type & RTE_PTYPE_TUNNEL_MASK)
-			printf(" - tunnel_len=%d", hdr_lens.tunnel_len);
-		if (sw_packet_type & RTE_PTYPE_INNER_L2_MASK)
-			printf(" - inner_l2_len=%d", hdr_lens.inner_l2_len);
-		if (sw_packet_type & RTE_PTYPE_INNER_L3_MASK)
-			printf(" - inner_l3_len=%d", hdr_lens.inner_l3_len);
-		if (sw_packet_type & RTE_PTYPE_INNER_L4_MASK)
-			printf(" - inner_l4_len=%d", hdr_lens.inner_l4_len);
-		if (is_encapsulation) {
-			struct ipv4_hdr *ipv4_hdr;
-			struct ipv6_hdr *ipv6_hdr;
-			struct udp_hdr *udp_hdr;
-			uint8_t l2_len;
-			uint8_t l3_len;
-			uint8_t l4_len;
-			uint8_t l4_proto;
-			struct  vxlan_hdr *vxlan_hdr;
-
-			l2_len  = sizeof(struct ether_hdr);
-
-			 /* Do not support ipv4 option field */
-			if (RTE_ETH_IS_IPV4_HDR(packet_type)) {
-				l3_len = sizeof(struct ipv4_hdr);
-				ipv4_hdr = rte_pktmbuf_mtod_offset(mb,
-								   struct ipv4_hdr *,
-								   l2_len);
-				l4_proto = ipv4_hdr->next_proto_id;
-			} else {
-				l3_len = sizeof(struct ipv6_hdr);
-				ipv6_hdr = rte_pktmbuf_mtod_offset(mb,
-								   struct ipv6_hdr *,
-								   l2_len);
-				l4_proto = ipv6_hdr->proto;
-			}
-			if (l4_proto == IPPROTO_UDP) {
-				udp_hdr = rte_pktmbuf_mtod_offset(mb,
-								  struct udp_hdr *,
-								  l2_len + l3_len);
-				l4_len = sizeof(struct udp_hdr);
-				vxlan_hdr = rte_pktmbuf_mtod_offset(mb,
-								    struct vxlan_hdr *,
-								    l2_len + l3_len + l4_len);
-
-				printf(" - VXLAN packet: packet type =%d, "
-					"Destination UDP port =%d, VNI = %d",
-					packet_type, RTE_BE_TO_CPU_16(udp_hdr->dst_port),
-					rte_be_to_cpu_32(vxlan_hdr->vx_vni) >> 8);
-			}
-		}
-		printf(" - Receive queue=0x%x", (unsigned) fs->rx_queue);
-		printf("\n");
-		rte_get_rx_ol_flag_list(mb->ol_flags, buf, sizeof(buf));
-		printf("  ol_flags: %s\n", buf);
-		rte_pktmbuf_free(mb);
-	}
+	for (i = 0; i < nb_rx; i++)
+		rte_pktmbuf_free(pkts_burst[i]);
 
 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
 	end_tsc = rte_rdtsc();
diff --git a/app/test-pmd/util.c b/app/test-pmd/util.c
new file mode 100644
index 0000000..97c8349
--- /dev/null
+++ b/app/test-pmd/util.c
@@ -0,0 +1,144 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2018 Mellanox technology.
+ */
+
+#include <stdio.h>
+
+#include <rte_net.h>
+#include <rte_mbuf.h>
+#include <rte_ether.h>
+#include <rte_ethdev.h>
+#include <rte_flow.h>
+
+#include "testpmd.h"
+
+static inline void
+print_ether_addr(const char *what, struct ether_addr *eth_addr)
+{
+	char buf[ETHER_ADDR_FMT_SIZE];
+	ether_format_addr(buf, ETHER_ADDR_FMT_SIZE, eth_addr);
+	printf("%s%s", what, buf);
+}
+
+static  inline void
+dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],
+	      uint16_t nb_pkts, int is_rx)
+{
+	struct rte_mbuf  *mb;
+	struct ether_hdr *eth_hdr;
+	uint16_t eth_type;
+	uint64_t ol_flags;
+	uint16_t i, packet_type;
+	uint16_t is_encapsulation;
+	char buf[256];
+	struct rte_net_hdr_lens hdr_lens;
+	uint32_t sw_packet_type;
+
+	if (!nb_pkts)
+		return;
+	printf("port %u/queue %u: %s %u packets\n",
+		port_id, queue,
+	       is_rx ? "received" : "sent",
+	       (unsigned int) nb_pkts);
+	for (i = 0; i < nb_pkts; i++) {
+		mb = pkts[i];
+		eth_hdr = rte_pktmbuf_mtod(mb, struct ether_hdr *);
+		eth_type = RTE_BE_TO_CPU_16(eth_hdr->ether_type);
+		ol_flags = mb->ol_flags;
+		packet_type = mb->packet_type;
+		is_encapsulation = RTE_ETH_IS_TUNNEL_PKT(packet_type);
+
+		print_ether_addr("  src=", &eth_hdr->s_addr);
+		print_ether_addr(" - dst=", &eth_hdr->d_addr);
+		printf(" - type=0x%04x - length=%u - nb_segs=%d",
+		       eth_type, (unsigned int) mb->pkt_len,
+		       (int)mb->nb_segs);
+		printf(" - RSS hash=0x%x", (unsigned int) mb->hash.rss);
+		printf(" - RSS queue=0x%x", (unsigned int) queue);
+		if (ol_flags & PKT_RX_FDIR) {
+			printf(" - FDIR matched ");
+			if (ol_flags & PKT_RX_FDIR_ID)
+				printf("ID=0x%x",
+				       mb->hash.fdir.hi);
+			else if (ol_flags & PKT_RX_FDIR_FLX)
+				printf("flex bytes=0x%08x %08x",
+				       mb->hash.fdir.hi, mb->hash.fdir.lo);
+			else
+				printf("hash=0x%x ID=0x%x ",
+				       mb->hash.fdir.hash, mb->hash.fdir.id);
+		}
+		if (ol_flags & PKT_RX_TIMESTAMP)
+			printf(" - timestamp %"PRIu64" ", mb->timestamp);
+		if (ol_flags & PKT_RX_VLAN_STRIPPED)
+			printf(" - VLAN tci=0x%x", mb->vlan_tci);
+		if (ol_flags & PKT_RX_QINQ_STRIPPED)
+			printf(" - QinQ VLAN tci=0x%x, VLAN tci outer=0x%x",
+			       mb->vlan_tci, mb->vlan_tci_outer);
+		if (mb->packet_type) {
+			rte_get_ptype_name(mb->packet_type, buf, sizeof(buf));
+			printf(" - hw ptype: %s", buf);
+		}
+		sw_packet_type = rte_net_get_ptype(mb, &hdr_lens,
+						   RTE_PTYPE_ALL_MASK);
+		rte_get_ptype_name(sw_packet_type, buf, sizeof(buf));
+		printf(" - sw ptype: %s", buf);
+		if (sw_packet_type & RTE_PTYPE_L2_MASK)
+			printf(" - l2_len=%d", hdr_lens.l2_len);
+		if (sw_packet_type & RTE_PTYPE_L3_MASK)
+
+			printf(" - l4_len=%d", hdr_lens.l4_len);
+		if (sw_packet_type & RTE_PTYPE_TUNNEL_MASK)
+			printf(" - tunnel_len=%d", hdr_lens.tunnel_len);
+		if (sw_packet_type & RTE_PTYPE_INNER_L2_MASK)
+			printf(" - inner_l2_len=%d", hdr_lens.inner_l2_len);
+		if (sw_packet_type & RTE_PTYPE_INNER_L4_MASK)
+			printf(" - inner_l4_len=%d", hdr_lens.inner_l4_len);
+		if (is_encapsulation) {
+			struct ipv4_hdr *ipv4_hdr;
+			struct ipv6_hdr *ipv6_hdr;
+			struct udp_hdr *udp_hdr;
+			uint8_t l2_len;
+			uint8_t l3_len;
+			uint8_t l4_len;
+			uint8_t l4_proto;
+			struct  vxlan_hdr *vxlan_hdr;
+
+			l2_len  = sizeof(struct ether_hdr);
+
+			/* Do not support ipv4 option field */
+			if (RTE_ETH_IS_IPV4_HDR(packet_type)) {
+				l3_len = sizeof(struct ipv4_hdr);
+				ipv4_hdr = rte_pktmbuf_mtod_offset(mb,
+				struct ipv4_hdr *,
+				l2_len);
+				l4_proto = ipv4_hdr->next_proto_id;
+			} else {
+				l3_len = sizeof(struct ipv6_hdr);
+				ipv6_hdr = rte_pktmbuf_mtod_offset(mb,
+				struct ipv6_hdr *,
+				l2_len);
+				l4_proto = ipv6_hdr->proto;
+			}
+			if (l4_proto == IPPROTO_UDP) {
+				udp_hdr = rte_pktmbuf_mtod_offset(mb,
+				struct udp_hdr *,
+				l2_len + l3_len);
+				l4_len = sizeof(struct udp_hdr);
+				vxlan_hdr = rte_pktmbuf_mtod_offset(mb,
+				struct vxlan_hdr *,
+				l2_len + l3_len + l4_len);
+
+				printf(" - VXLAN packet: packet type =%d, "
+				       "Destination UDP port =%d, VNI = %d",
+				       packet_type,
+				       RTE_BE_TO_CPU_16(udp_hdr->dst_port),
+				       rte_be_to_cpu_32(vxlan_hdr->vx_vni) >> 8);
+			}
+		}
+		printf(" - %s queue=0x%x", is_rx ? "Receive" : "Send",
+			(unsigned int) queue);
+		printf("\n");
+		rte_get_rx_ol_flag_list(mb->ol_flags, buf, sizeof(buf));
+		printf("  ol_flags: %s\n", buf);
+	}
+}
-- 
2.7.4

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH v2 2/3] app/testpmd: add packet dump callback functions
  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     ` Raslan Darawsheh
  2018-09-24 12:49     ` [dpdk-dev] [PATCH v2 3/3] app/testpmd: set packet dump based on verbosity level Raslan Darawsheh
                       ` (3 subsequent siblings)
  4 siblings, 0 replies; 47+ messages in thread
From: Raslan Darawsheh @ 2018-09-24 12:49 UTC (permalink / raw)
  To: jingjing.wu
  Cc: Thomas Monjalon, dev, Shahaf Shuler, Raslan Darawsheh,
	Xueming(Steven) Li, Ori Katz, jerin.jacob, david.marchand

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

Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
---
 app/test-pmd/config.c  | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++
 app/test-pmd/testpmd.h | 15 +++++++++++
 app/test-pmd/util.c    | 17 +++++++++++++
 3 files changed, 99 insertions(+)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index a0f9349..fb45fea 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -2896,6 +2896,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/testpmd.h b/app/test-pmd/testpmd.h
index a1f6614..c0d7656 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -180,6 +180,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
@@ -743,6 +745,19 @@ int check_nb_rxq(queueid_t rxq);
 queueid_t get_allowed_max_nb_txq(portid_t *pid);
 int check_nb_txq(queueid_t txq);
 
+
+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
  * rte_be_to_cpu_16() function.
diff --git a/app/test-pmd/util.c b/app/test-pmd/util.c
index 97c8349..9a40ec7 100644
--- a/app/test-pmd/util.c
+++ b/app/test-pmd/util.c
@@ -142,3 +142,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

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH v2 3/3] app/testpmd: set packet dump based on verbosity level
  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     ` Raslan Darawsheh
  2018-10-02 13:35     ` [dpdk-dev] [PATCH v2 1/3] app/testpmd: move dumping packets to a separate function Iremonger, Bernard
                       ` (2 subsequent siblings)
  4 siblings, 0 replies; 47+ messages in thread
From: Raslan Darawsheh @ 2018-09-24 12:49 UTC (permalink / raw)
  To: jingjing.wu
  Cc: Thomas Monjalon, dev, Shahaf Shuler, Raslan Darawsheh,
	Xueming(Steven) Li, Ori Katz, jerin.jacob, david.marchand

when changing verbosity level it will configure rx/tx callbacks to dump
packets based on the verbosity value as following:
    1- dump only received packets:
       testpmd> set verbose 1
    2- dump only sent packets:
       testpmd> set verbose 2
    3- dump sent and received packets:
       testpmd> set verbose (any number > 2)
    4- disable dump
       testpmd> set verbose 0

Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
---
 app/test-pmd/config.c  | 25 +++++++++++++++++++++++++
 app/test-pmd/testpmd.c |  4 ++--
 app/test-pmd/testpmd.h |  1 +
 3 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index fb45fea..f402e04 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -50,6 +50,7 @@
 #endif
 #include <rte_gro.h>
 #include <cmdline_parse_etheraddr.h>
+#include <rte_config.h>
 
 #include "testpmd.h"
 
@@ -2963,11 +2964,35 @@ remove_tx_dump_callbacks(portid_t portid)
 }
 
 void
+configure_rxtx_dump_callbacks(uint16_t verbose)
+{
+	portid_t portid;
+
+#ifndef RTE_ETHDEV_RXTX_CALLBACKS
+		TESTPMD_LOG(ERR, "setting rxtx callbacks is not enabled\n");
+		return;
+#endif
+
+	RTE_ETH_FOREACH_DEV(portid)
+	{
+		if (verbose == 1 || verbose > 2)
+			add_rx_dump_callbacks(portid);
+		else
+			remove_rx_dump_callbacks(portid);
+		if (verbose >= 2)
+			add_tx_dump_callbacks(portid);
+		else
+			remove_tx_dump_callbacks(portid);
+	}
+}
+
+void
 set_verbose_level(uint16_t vb_level)
 {
 	printf("Change verbose level from %u to %u\n",
 	       (unsigned int) verbose_level, (unsigned int) vb_level);
 	verbose_level = vb_level;
+	configure_rxtx_dump_callbacks(verbose_level);
 }
 
 void
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 571ecb4..538723c 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -1665,7 +1665,7 @@ start_port(portid_t pid)
 					return -1;
 				}
 			}
-
+			configure_rxtx_dump_callbacks(0);
 			printf("Configuring Port %d (socket %u)\n", pi,
 					port->socket_id);
 			/* configure port */
@@ -1764,7 +1764,7 @@ start_port(portid_t pid)
 				return -1;
 			}
 		}
-
+		configure_rxtx_dump_callbacks(verbose_level);
 		/* start port */
 		if (rte_eth_dev_start(pi) < 0) {
 			printf("Fail to start port %d\n", pi);
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index c0d7656..e68710d 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -757,6 +757,7 @@ 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);
+void configure_rxtx_dump_callbacks(uint16_t verbose);
 
 /*
  * Work-around of a compilation error with ICC on invocations of the
-- 
2.7.4

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH v2 1/3] app/testpmd: move dumping packets to a separate function
  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     ` Iremonger, Bernard
  2018-10-03 15:11       ` Raslan Darawsheh
  2018-10-03 15:16     ` [dpdk-dev] [PATCH v3 " Raslan Darawsheh
  2018-10-07  7:38     ` [dpdk-dev] [PATCH v4 " Raslan Darawsheh
  4 siblings, 1 reply; 47+ messages in thread
From: Iremonger, Bernard @ 2018-10-02 13:35 UTC (permalink / raw)
  To: Raslan Darawsheh, Wu, Jingjing
  Cc: Thomas Monjalon, dev, Shahaf Shuler, Xueming(Steven) Li,
	Ori Katz, jerin.jacob, david.marchand

Hi Raslan,

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Raslan Darawsheh
> Sent: Monday, September 24, 2018 1:49 PM
> To: Wu, Jingjing <jingjing.wu@intel.com>
> Cc: Thomas Monjalon <thomas@monjalon.net>; dev@dpdk.org; Shahaf Shuler
> <shahafs@mellanox.com>; Raslan Darawsheh <rasland@mellanox.com>;
> Xueming(Steven) Li <xuemingl@mellanox.com>; Ori Katz <orik@mellanox.com>;
> jerin.jacob@caviumnetworks.com; david.marchand@6wind.com
> Subject: [dpdk-dev] [PATCH v2 1/3] app/testpmd: move dumping packets to a
> separate function
> 
> verbosity for the received/sent packets is needed in all of the forwarding
> engines so moving it to be in a separate function
> 
> Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
> ---
>  app/test-pmd/Makefile |   1 +

The app/test-pmd/meson.build  should be updated for the util.c file.

>  app/test-pmd/rxonly.c | 134 ++--------------------------------------------
>  app/test-pmd/util.c   | 144
> ++++++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 148 insertions(+), 131 deletions(-)  create mode 100644
> app/test-pmd/util.c
> 
<snip>
> diff --git a/app/test-pmd/util.c b/app/test-pmd/util.c new file mode 100644
> index 0000000..97c8349
> --- /dev/null
> +++ b/app/test-pmd/util.c
> @@ -0,0 +1,144 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2010-2018 Mellanox technology.
> + */
> +
> +#include <stdio.h>
> +
> +#include <rte_net.h>
> +#include <rte_mbuf.h>
> +#include <rte_ether.h>
> +#include <rte_ethdev.h>
> +#include <rte_flow.h>
> +
> +#include "testpmd.h"
> +
> +static inline void
> +print_ether_addr(const char *what, struct ether_addr *eth_addr) {
> +	char buf[ETHER_ADDR_FMT_SIZE];
> +	ether_format_addr(buf, ETHER_ADDR_FMT_SIZE, eth_addr);
> +	printf("%s%s", what, buf);
> +}
> +
> +static  inline void
> +dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],
> +	      uint16_t nb_pkts, int is_rx)
> +{
> +	struct rte_mbuf  *mb;
> +	struct ether_hdr *eth_hdr;
> +	uint16_t eth_type;
> +	uint64_t ol_flags;
> +	uint16_t i, packet_type;
> +	uint16_t is_encapsulation;
> +	char buf[256];
> +	struct rte_net_hdr_lens hdr_lens;
> +	uint32_t sw_packet_type;
> +
> +	if (!nb_pkts)
> +		return;
> +	printf("port %u/queue %u: %s %u packets\n",
> +		port_id, queue,
> +	       is_rx ? "received" : "sent",
> +	       (unsigned int) nb_pkts);
> +	for (i = 0; i < nb_pkts; i++) {
> +		mb = pkts[i];
> +		eth_hdr = rte_pktmbuf_mtod(mb, struct ether_hdr *);
> +		eth_type = RTE_BE_TO_CPU_16(eth_hdr->ether_type);
> +		ol_flags = mb->ol_flags;
> +		packet_type = mb->packet_type;
> +		is_encapsulation = RTE_ETH_IS_TUNNEL_PKT(packet_type);
> +
> +		print_ether_addr("  src=", &eth_hdr->s_addr);
> +		print_ether_addr(" - dst=", &eth_hdr->d_addr);
> +		printf(" - type=0x%04x - length=%u - nb_segs=%d",
> +		       eth_type, (unsigned int) mb->pkt_len,
> +		       (int)mb->nb_segs);

Should the following line be reinstated here:
		if (ol_flags & PKT_RX_RSS_HASH) {

> +		printf(" - RSS hash=0x%x", (unsigned int) mb->hash.rss);
> +		printf(" - RSS queue=0x%x", (unsigned int) queue);

Should the following line be reinstated here:
		}

> +		if (ol_flags & PKT_RX_FDIR) {
> +			printf(" - FDIR matched ");
> +			if (ol_flags & PKT_RX_FDIR_ID)
> +				printf("ID=0x%x",
> +				       mb->hash.fdir.hi);
> +			else if (ol_flags & PKT_RX_FDIR_FLX)
> +				printf("flex bytes=0x%08x %08x",
> +				       mb->hash.fdir.hi, mb->hash.fdir.lo);
> +			else
> +				printf("hash=0x%x ID=0x%x ",
> +				       mb->hash.fdir.hash, mb->hash.fdir.id);
> +		}
> +		if (ol_flags & PKT_RX_TIMESTAMP)
> +			printf(" - timestamp %"PRIu64" ", mb->timestamp);
> +		if (ol_flags & PKT_RX_VLAN_STRIPPED)
> +			printf(" - VLAN tci=0x%x", mb->vlan_tci);
> +		if (ol_flags & PKT_RX_QINQ_STRIPPED)
> +			printf(" - QinQ VLAN tci=0x%x, VLAN tci outer=0x%x",
> +			       mb->vlan_tci, mb->vlan_tci_outer);
> +		if (mb->packet_type) {
> +			rte_get_ptype_name(mb->packet_type, buf,
> sizeof(buf));
> +			printf(" - hw ptype: %s", buf);
> +		}
> +		sw_packet_type = rte_net_get_ptype(mb, &hdr_lens,
> +						   RTE_PTYPE_ALL_MASK);
> +		rte_get_ptype_name(sw_packet_type, buf, sizeof(buf));
> +		printf(" - sw ptype: %s", buf);
> +		if (sw_packet_type & RTE_PTYPE_L2_MASK)
> +			printf(" - l2_len=%d", hdr_lens.l2_len);
> +		if (sw_packet_type & RTE_PTYPE_L3_MASK)

The following blank line can be removed:

> +
> +			printf(" - l4_len=%d", hdr_lens.l4_len);
> +		if (sw_packet_type & RTE_PTYPE_TUNNEL_MASK)
> +			printf(" - tunnel_len=%d", hdr_lens.tunnel_len);
> +		if (sw_packet_type & RTE_PTYPE_INNER_L2_MASK)
> +			printf(" - inner_l2_len=%d", hdr_lens.inner_l2_len);
> +		if (sw_packet_type & RTE_PTYPE_INNER_L4_MASK)
> +			printf(" - inner_l4_len=%d", hdr_lens.inner_l4_len);
> +		if (is_encapsulation) {
> +			struct ipv4_hdr *ipv4_hdr;
> +			struct ipv6_hdr *ipv6_hdr;
> +			struct udp_hdr *udp_hdr;
> +			uint8_t l2_len;
> +			uint8_t l3_len;
> +			uint8_t l4_len;
> +			uint8_t l4_proto;
> +			struct  vxlan_hdr *vxlan_hdr;
> +
> +			l2_len  = sizeof(struct ether_hdr);
> +
> +			/* Do not support ipv4 option field */
> +			if (RTE_ETH_IS_IPV4_HDR(packet_type)) {
> +				l3_len = sizeof(struct ipv4_hdr);
> +				ipv4_hdr = rte_pktmbuf_mtod_offset(mb,
> +				struct ipv4_hdr *,
> +				l2_len);
> +				l4_proto = ipv4_hdr->next_proto_id;
> +			} else {
> +				l3_len = sizeof(struct ipv6_hdr);
> +				ipv6_hdr = rte_pktmbuf_mtod_offset(mb,
> +				struct ipv6_hdr *,
> +				l2_len);
> +				l4_proto = ipv6_hdr->proto;
> +			}
> +			if (l4_proto == IPPROTO_UDP) {
> +				udp_hdr = rte_pktmbuf_mtod_offset(mb,
> +				struct udp_hdr *,
> +				l2_len + l3_len);
> +				l4_len = sizeof(struct udp_hdr);
> +				vxlan_hdr = rte_pktmbuf_mtod_offset(mb,
> +				struct vxlan_hdr *,
> +				l2_len + l3_len + l4_len);
> +
> +				printf(" - VXLAN packet: packet type =%d, "
> +				       "Destination UDP port =%d, VNI = %d",
> +				       packet_type,

Suggest using local variables for be_to_cpu conversions to solve long line issue.

> +				       RTE_BE_TO_CPU_16(udp_hdr->dst_port),
> +				       rte_be_to_cpu_32(vxlan_hdr->vx_vni) >>
> 8);
> +			}
> +		}
> +		printf(" - %s queue=0x%x", is_rx ? "Receive" : "Send",
> +			(unsigned int) queue);
> +		printf("\n");
> +		rte_get_rx_ol_flag_list(mb->ol_flags, buf, sizeof(buf));
> +		printf("  ol_flags: %s\n", buf);
> +	}
> +}
> --
> 2.7.4

Regards,

Bernard.

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH v2 1/3] app/testpmd: move dumping packets to a separate function
  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
  0 siblings, 0 replies; 47+ messages in thread
From: Raslan Darawsheh @ 2018-10-03 15:11 UTC (permalink / raw)
  To: Iremonger, Bernard, Wu, Jingjing
  Cc: Thomas Monjalon, dev, Shahaf Shuler, Xueming(Steven) Li,
	Ori Katz, jerin.jacob, david.marchand

Hi Iremonger Berrnard, 

Thx for the review, you are right about that I'm fixing these issues and I'm sending a new version with the fixes now.

Kindest regards,
Raslan Darawsheh

> -----Original Message-----
> From: Iremonger, Bernard <bernard.iremonger@intel.com>
> Sent: Tuesday, October 2, 2018 4:36 PM
> To: Raslan Darawsheh <rasland@mellanox.com>; Wu, Jingjing
> <jingjing.wu@intel.com>
> Cc: Thomas Monjalon <thomas@monjalon.net>; dev@dpdk.org; Shahaf
> Shuler <shahafs@mellanox.com>; Xueming(Steven) Li
> <xuemingl@mellanox.com>; Ori Katz <orik@mellanox.com>;
> jerin.jacob@caviumnetworks.com; david.marchand@6wind.com
> Subject: RE: [PATCH v2 1/3] app/testpmd: move dumping packets to a
> separate function
> 
> Hi Raslan,
> 
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Raslan
> Darawsheh
> > Sent: Monday, September 24, 2018 1:49 PM
> > To: Wu, Jingjing <jingjing.wu@intel.com>
> > Cc: Thomas Monjalon <thomas@monjalon.net>; dev@dpdk.org; Shahaf
> Shuler
> > <shahafs@mellanox.com>; Raslan Darawsheh <rasland@mellanox.com>;
> > Xueming(Steven) Li <xuemingl@mellanox.com>; Ori Katz
> > <orik@mellanox.com>; jerin.jacob@caviumnetworks.com;
> > david.marchand@6wind.com
> > Subject: [dpdk-dev] [PATCH v2 1/3] app/testpmd: move dumping packets
> > to a separate function
> >
> > verbosity for the received/sent packets is needed in all of the
> > forwarding engines so moving it to be in a separate function
> >
> > Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
> > ---
> >  app/test-pmd/Makefile |   1 +
> 
> The app/test-pmd/meson.build  should be updated for the util.c file.
> 
> >  app/test-pmd/rxonly.c | 134 ++--------------------------------------------
> >  app/test-pmd/util.c   | 144
> > ++++++++++++++++++++++++++++++++++++++++++++++++++
> >  3 files changed, 148 insertions(+), 131 deletions(-)  create mode
> > 100644 app/test-pmd/util.c
> >
> <snip>
> > diff --git a/app/test-pmd/util.c b/app/test-pmd/util.c new file mode
> > 100644 index 0000000..97c8349
> > --- /dev/null
> > +++ b/app/test-pmd/util.c
> > @@ -0,0 +1,144 @@
> > +/* SPDX-License-Identifier: BSD-3-Clause
> > + * Copyright(c) 2010-2018 Mellanox technology.
> > + */
> > +
> > +#include <stdio.h>
> > +
> > +#include <rte_net.h>
> > +#include <rte_mbuf.h>
> > +#include <rte_ether.h>
> > +#include <rte_ethdev.h>
> > +#include <rte_flow.h>
> > +
> > +#include "testpmd.h"
> > +
> > +static inline void
> > +print_ether_addr(const char *what, struct ether_addr *eth_addr) {
> > +	char buf[ETHER_ADDR_FMT_SIZE];
> > +	ether_format_addr(buf, ETHER_ADDR_FMT_SIZE, eth_addr);
> > +	printf("%s%s", what, buf);
> > +}
> > +
> > +static  inline void
> > +dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf
> *pkts[],
> > +	      uint16_t nb_pkts, int is_rx)
> > +{
> > +	struct rte_mbuf  *mb;
> > +	struct ether_hdr *eth_hdr;
> > +	uint16_t eth_type;
> > +	uint64_t ol_flags;
> > +	uint16_t i, packet_type;
> > +	uint16_t is_encapsulation;
> > +	char buf[256];
> > +	struct rte_net_hdr_lens hdr_lens;
> > +	uint32_t sw_packet_type;
> > +
> > +	if (!nb_pkts)
> > +		return;
> > +	printf("port %u/queue %u: %s %u packets\n",
> > +		port_id, queue,
> > +	       is_rx ? "received" : "sent",
> > +	       (unsigned int) nb_pkts);
> > +	for (i = 0; i < nb_pkts; i++) {
> > +		mb = pkts[i];
> > +		eth_hdr = rte_pktmbuf_mtod(mb, struct ether_hdr *);
> > +		eth_type = RTE_BE_TO_CPU_16(eth_hdr->ether_type);
> > +		ol_flags = mb->ol_flags;
> > +		packet_type = mb->packet_type;
> > +		is_encapsulation = RTE_ETH_IS_TUNNEL_PKT(packet_type);
> > +
> > +		print_ether_addr("  src=", &eth_hdr->s_addr);
> > +		print_ether_addr(" - dst=", &eth_hdr->d_addr);
> > +		printf(" - type=0x%04x - length=%u - nb_segs=%d",
> > +		       eth_type, (unsigned int) mb->pkt_len,
> > +		       (int)mb->nb_segs);
> 
> Should the following line be reinstated here:
> 		if (ol_flags & PKT_RX_RSS_HASH) {
> 
> > +		printf(" - RSS hash=0x%x", (unsigned int) mb->hash.rss);
> > +		printf(" - RSS queue=0x%x", (unsigned int) queue);
> 
> Should the following line be reinstated here:
> 		}
> 
> > +		if (ol_flags & PKT_RX_FDIR) {
> > +			printf(" - FDIR matched ");
> > +			if (ol_flags & PKT_RX_FDIR_ID)
> > +				printf("ID=0x%x",
> > +				       mb->hash.fdir.hi);
> > +			else if (ol_flags & PKT_RX_FDIR_FLX)
> > +				printf("flex bytes=0x%08x %08x",
> > +				       mb->hash.fdir.hi, mb->hash.fdir.lo);
> > +			else
> > +				printf("hash=0x%x ID=0x%x ",
> > +				       mb->hash.fdir.hash, mb->hash.fdir.id);
> > +		}
> > +		if (ol_flags & PKT_RX_TIMESTAMP)
> > +			printf(" - timestamp %"PRIu64" ", mb->timestamp);
> > +		if (ol_flags & PKT_RX_VLAN_STRIPPED)
> > +			printf(" - VLAN tci=0x%x", mb->vlan_tci);
> > +		if (ol_flags & PKT_RX_QINQ_STRIPPED)
> > +			printf(" - QinQ VLAN tci=0x%x, VLAN tci outer=0x%x",
> > +			       mb->vlan_tci, mb->vlan_tci_outer);
> > +		if (mb->packet_type) {
> > +			rte_get_ptype_name(mb->packet_type, buf,
> > sizeof(buf));
> > +			printf(" - hw ptype: %s", buf);
> > +		}
> > +		sw_packet_type = rte_net_get_ptype(mb, &hdr_lens,
> > +						   RTE_PTYPE_ALL_MASK);
> > +		rte_get_ptype_name(sw_packet_type, buf, sizeof(buf));
> > +		printf(" - sw ptype: %s", buf);
> > +		if (sw_packet_type & RTE_PTYPE_L2_MASK)
> > +			printf(" - l2_len=%d", hdr_lens.l2_len);
> > +		if (sw_packet_type & RTE_PTYPE_L3_MASK)
> 
> The following blank line can be removed:
> 
> > +
> > +			printf(" - l4_len=%d", hdr_lens.l4_len);
> > +		if (sw_packet_type & RTE_PTYPE_TUNNEL_MASK)
> > +			printf(" - tunnel_len=%d", hdr_lens.tunnel_len);
> > +		if (sw_packet_type & RTE_PTYPE_INNER_L2_MASK)
> > +			printf(" - inner_l2_len=%d", hdr_lens.inner_l2_len);
> > +		if (sw_packet_type & RTE_PTYPE_INNER_L4_MASK)
> > +			printf(" - inner_l4_len=%d", hdr_lens.inner_l4_len);
> > +		if (is_encapsulation) {
> > +			struct ipv4_hdr *ipv4_hdr;
> > +			struct ipv6_hdr *ipv6_hdr;
> > +			struct udp_hdr *udp_hdr;
> > +			uint8_t l2_len;
> > +			uint8_t l3_len;
> > +			uint8_t l4_len;
> > +			uint8_t l4_proto;
> > +			struct  vxlan_hdr *vxlan_hdr;
> > +
> > +			l2_len  = sizeof(struct ether_hdr);
> > +
> > +			/* Do not support ipv4 option field */
> > +			if (RTE_ETH_IS_IPV4_HDR(packet_type)) {
> > +				l3_len = sizeof(struct ipv4_hdr);
> > +				ipv4_hdr = rte_pktmbuf_mtod_offset(mb,
> > +				struct ipv4_hdr *,
> > +				l2_len);
> > +				l4_proto = ipv4_hdr->next_proto_id;
> > +			} else {
> > +				l3_len = sizeof(struct ipv6_hdr);
> > +				ipv6_hdr = rte_pktmbuf_mtod_offset(mb,
> > +				struct ipv6_hdr *,
> > +				l2_len);
> > +				l4_proto = ipv6_hdr->proto;
> > +			}
> > +			if (l4_proto == IPPROTO_UDP) {
> > +				udp_hdr = rte_pktmbuf_mtod_offset(mb,
> > +				struct udp_hdr *,
> > +				l2_len + l3_len);
> > +				l4_len = sizeof(struct udp_hdr);
> > +				vxlan_hdr = rte_pktmbuf_mtod_offset(mb,
> > +				struct vxlan_hdr *,
> > +				l2_len + l3_len + l4_len);
> > +
> > +				printf(" - VXLAN packet: packet type =%d, "
> > +				       "Destination UDP port =%d, VNI = %d",
> > +				       packet_type,
> 
> Suggest using local variables for be_to_cpu conversions to solve long line
> issue.
> 
> > +				       RTE_BE_TO_CPU_16(udp_hdr-
> >dst_port),
> > +				       rte_be_to_cpu_32(vxlan_hdr->vx_vni)
> >>
> > 8);
> > +			}
> > +		}
> > +		printf(" - %s queue=0x%x", is_rx ? "Receive" : "Send",
> > +			(unsigned int) queue);
> > +		printf("\n");
> > +		rte_get_rx_ol_flag_list(mb->ol_flags, buf, sizeof(buf));
> > +		printf("  ol_flags: %s\n", buf);
> > +	}
> > +}
> > --
> > 2.7.4
> 
> Regards,
> 
> Bernard.
> 

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH v3 1/3] app/testpmd: move dumping packets to a separate function
  2018-09-24 12:49   ` [dpdk-dev] [PATCH v2 1/3] app/testpmd: move dumping packets to a separate function Raslan Darawsheh
                       ` (2 preceding siblings ...)
  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:16     ` Raslan Darawsheh
  2018-10-03 15:16       ` [dpdk-dev] [PATCH v3 2/3] app/testpmd: add packet dump callback functions Raslan Darawsheh
                         ` (2 more replies)
  2018-10-07  7:38     ` [dpdk-dev] [PATCH v4 " Raslan Darawsheh
  4 siblings, 3 replies; 47+ messages in thread
From: Raslan Darawsheh @ 2018-10-03 15:16 UTC (permalink / raw)
  To: jingjing.wu
  Cc: Thomas Monjalon, dev, Shahaf Shuler, Raslan Darawsheh,
	Xueming(Steven) Li, Ori Kam, jerin.jacob, david.marchand,
	bernard.iremonger

verbosity for the received/sent packets is needed in all of the
forwarding engines so moving it to be in a separate function

Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>

---
changes in v3:
	- add util.c in the mason.build file
	- restore missing check for ol_flags & PKT_RX_RSS_HASH.
	- add local variables for rte_be_to_cpu to avoid long
	  lines.
---
---
 app/test-pmd/Makefile    |   1 +
 app/test-pmd/meson.build |   3 +-
 app/test-pmd/rxonly.c    | 134 +------------------------------------------
 app/test-pmd/util.c      | 146 +++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 152 insertions(+), 132 deletions(-)
 create mode 100644 app/test-pmd/util.c

diff --git a/app/test-pmd/Makefile b/app/test-pmd/Makefile
index 2b4d604..e2c7845 100644
--- a/app/test-pmd/Makefile
+++ b/app/test-pmd/Makefile
@@ -35,6 +35,7 @@ SRCS-y += csumonly.c
 SRCS-y += icmpecho.c
 SRCS-$(CONFIG_RTE_LIBRTE_IEEE1588) += ieee1588fwd.c
 SRCS-$(CONFIG_RTE_LIBRTE_BPF) += bpf_cmd.c
+SRCS-y += util.c
 
 ifeq ($(CONFIG_RTE_LIBRTE_PMD_SOFTNIC), y)
 SRCS-y += softnicfwd.c
diff --git a/app/test-pmd/meson.build b/app/test-pmd/meson.build
index a0b3be0..b96ab97 100644
--- a/app/test-pmd/meson.build
+++ b/app/test-pmd/meson.build
@@ -20,7 +20,8 @@ sources = files('cmdline.c',
 	'parameters.c',
 	'rxonly.c',
 	'testpmd.c',
-	'txonly.c')
+	'txonly.c',
+	'util.c')
 
 deps = ['ethdev', 'gro', 'gso', 'cmdline', 'metrics', 'meter', 'bus_pci']
 if dpdk_conf.has('RTE_LIBRTE_PDUMP')
diff --git a/app/test-pmd/rxonly.c b/app/test-pmd/rxonly.c
index a93d806..3eca89c 100644
--- a/app/test-pmd/rxonly.c
+++ b/app/test-pmd/rxonly.c
@@ -40,14 +40,6 @@
 
 #include "testpmd.h"
 
-static inline void
-print_ether_addr(const char *what, struct ether_addr *eth_addr)
-{
-	char buf[ETHER_ADDR_FMT_SIZE];
-	ether_format_addr(buf, ETHER_ADDR_FMT_SIZE, eth_addr);
-	printf("%s%s", what, buf);
-}
-
 /*
  * Received a burst of packets.
  */
@@ -55,16 +47,8 @@ static void
 pkt_burst_receive(struct fwd_stream *fs)
 {
 	struct rte_mbuf  *pkts_burst[MAX_PKT_BURST];
-	struct rte_mbuf  *mb;
-	struct ether_hdr *eth_hdr;
-	uint16_t eth_type;
-	uint64_t ol_flags;
 	uint16_t nb_rx;
-	uint16_t i, packet_type;
-	uint16_t is_encapsulation;
-	char buf[256];
-	struct rte_net_hdr_lens hdr_lens;
-	uint32_t sw_packet_type;
+	uint16_t i;
 
 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
 	uint64_t start_tsc;
@@ -90,120 +74,8 @@ pkt_burst_receive(struct fwd_stream *fs)
 	/*
 	 * Dump each received packet if verbose_level > 0.
 	 */
-	if (verbose_level > 0)
-		printf("port %u/queue %u: received %u packets\n",
-		       fs->rx_port,
-		       (unsigned) fs->rx_queue,
-		       (unsigned) nb_rx);
-	for (i = 0; i < nb_rx; i++) {
-		mb = pkts_burst[i];
-		if (verbose_level == 0) {
-			rte_pktmbuf_free(mb);
-			continue;
-		}
-		eth_hdr = rte_pktmbuf_mtod(mb, struct ether_hdr *);
-		eth_type = RTE_BE_TO_CPU_16(eth_hdr->ether_type);
-		ol_flags = mb->ol_flags;
-		packet_type = mb->packet_type;
-		is_encapsulation = RTE_ETH_IS_TUNNEL_PKT(packet_type);
-
-		print_ether_addr("  src=", &eth_hdr->s_addr);
-		print_ether_addr(" - dst=", &eth_hdr->d_addr);
-		printf(" - type=0x%04x - length=%u - nb_segs=%d",
-		       eth_type, (unsigned) mb->pkt_len,
-		       (int)mb->nb_segs);
-		if (ol_flags & PKT_RX_RSS_HASH) {
-			printf(" - RSS hash=0x%x", (unsigned) mb->hash.rss);
-			printf(" - RSS queue=0x%x",(unsigned) fs->rx_queue);
-		}
-		if (ol_flags & PKT_RX_FDIR) {
-			printf(" - FDIR matched ");
-			if (ol_flags & PKT_RX_FDIR_ID)
-				printf("ID=0x%x",
-				       mb->hash.fdir.hi);
-			else if (ol_flags & PKT_RX_FDIR_FLX)
-				printf("flex bytes=0x%08x %08x",
-				       mb->hash.fdir.hi, mb->hash.fdir.lo);
-			else
-				printf("hash=0x%x ID=0x%x ",
-				       mb->hash.fdir.hash, mb->hash.fdir.id);
-		}
-		if (ol_flags & PKT_RX_TIMESTAMP)
-			printf(" - timestamp %"PRIu64" ", mb->timestamp);
-		if (ol_flags & PKT_RX_VLAN_STRIPPED)
-			printf(" - VLAN tci=0x%x", mb->vlan_tci);
-		if (ol_flags & PKT_RX_QINQ_STRIPPED)
-			printf(" - QinQ VLAN tci=0x%x, VLAN tci outer=0x%x",
-					mb->vlan_tci, mb->vlan_tci_outer);
-		if (mb->packet_type) {
-			rte_get_ptype_name(mb->packet_type, buf, sizeof(buf));
-			printf(" - hw ptype: %s", buf);
-		}
-		sw_packet_type = rte_net_get_ptype(mb, &hdr_lens,
-			RTE_PTYPE_ALL_MASK);
-		rte_get_ptype_name(sw_packet_type, buf, sizeof(buf));
-		printf(" - sw ptype: %s", buf);
-		if (sw_packet_type & RTE_PTYPE_L2_MASK)
-			printf(" - l2_len=%d", hdr_lens.l2_len);
-		if (sw_packet_type & RTE_PTYPE_L3_MASK)
-			printf(" - l3_len=%d", hdr_lens.l3_len);
-		if (sw_packet_type & RTE_PTYPE_L4_MASK)
-			printf(" - l4_len=%d", hdr_lens.l4_len);
-		if (sw_packet_type & RTE_PTYPE_TUNNEL_MASK)
-			printf(" - tunnel_len=%d", hdr_lens.tunnel_len);
-		if (sw_packet_type & RTE_PTYPE_INNER_L2_MASK)
-			printf(" - inner_l2_len=%d", hdr_lens.inner_l2_len);
-		if (sw_packet_type & RTE_PTYPE_INNER_L3_MASK)
-			printf(" - inner_l3_len=%d", hdr_lens.inner_l3_len);
-		if (sw_packet_type & RTE_PTYPE_INNER_L4_MASK)
-			printf(" - inner_l4_len=%d", hdr_lens.inner_l4_len);
-		if (is_encapsulation) {
-			struct ipv4_hdr *ipv4_hdr;
-			struct ipv6_hdr *ipv6_hdr;
-			struct udp_hdr *udp_hdr;
-			uint8_t l2_len;
-			uint8_t l3_len;
-			uint8_t l4_len;
-			uint8_t l4_proto;
-			struct  vxlan_hdr *vxlan_hdr;
-
-			l2_len  = sizeof(struct ether_hdr);
-
-			 /* Do not support ipv4 option field */
-			if (RTE_ETH_IS_IPV4_HDR(packet_type)) {
-				l3_len = sizeof(struct ipv4_hdr);
-				ipv4_hdr = rte_pktmbuf_mtod_offset(mb,
-								   struct ipv4_hdr *,
-								   l2_len);
-				l4_proto = ipv4_hdr->next_proto_id;
-			} else {
-				l3_len = sizeof(struct ipv6_hdr);
-				ipv6_hdr = rte_pktmbuf_mtod_offset(mb,
-								   struct ipv6_hdr *,
-								   l2_len);
-				l4_proto = ipv6_hdr->proto;
-			}
-			if (l4_proto == IPPROTO_UDP) {
-				udp_hdr = rte_pktmbuf_mtod_offset(mb,
-								  struct udp_hdr *,
-								  l2_len + l3_len);
-				l4_len = sizeof(struct udp_hdr);
-				vxlan_hdr = rte_pktmbuf_mtod_offset(mb,
-								    struct vxlan_hdr *,
-								    l2_len + l3_len + l4_len);
-
-				printf(" - VXLAN packet: packet type =%d, "
-					"Destination UDP port =%d, VNI = %d",
-					packet_type, RTE_BE_TO_CPU_16(udp_hdr->dst_port),
-					rte_be_to_cpu_32(vxlan_hdr->vx_vni) >> 8);
-			}
-		}
-		printf(" - Receive queue=0x%x", (unsigned) fs->rx_queue);
-		printf("\n");
-		rte_get_rx_ol_flag_list(mb->ol_flags, buf, sizeof(buf));
-		printf("  ol_flags: %s\n", buf);
-		rte_pktmbuf_free(mb);
-	}
+	for (i = 0; i < nb_rx; i++)
+		rte_pktmbuf_free(pkts_burst[i]);
 
 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
 	end_tsc = rte_rdtsc();
diff --git a/app/test-pmd/util.c b/app/test-pmd/util.c
new file mode 100644
index 0000000..12bbe91
--- /dev/null
+++ b/app/test-pmd/util.c
@@ -0,0 +1,146 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2018 Mellanox technology.
+ */
+
+#include <stdio.h>
+
+#include <rte_net.h>
+#include <rte_mbuf.h>
+#include <rte_ether.h>
+#include <rte_ethdev.h>
+#include <rte_flow.h>
+
+#include "testpmd.h"
+
+static inline void
+print_ether_addr(const char *what, struct ether_addr *eth_addr)
+{
+	char buf[ETHER_ADDR_FMT_SIZE];
+	ether_format_addr(buf, ETHER_ADDR_FMT_SIZE, eth_addr);
+	printf("%s%s", what, buf);
+}
+
+static  inline void
+dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],
+	      uint16_t nb_pkts, int is_rx)
+{
+	struct rte_mbuf  *mb;
+	struct ether_hdr *eth_hdr;
+	uint16_t eth_type;
+	uint64_t ol_flags;
+	uint16_t i, packet_type;
+	uint16_t is_encapsulation;
+	char buf[256];
+	struct rte_net_hdr_lens hdr_lens;
+	uint32_t sw_packet_type;
+	uint16_t udp_port;
+	uint32_t vx_vni;
+
+	if (!nb_pkts)
+		return;
+	printf("port %u/queue %u: %s %u packets\n",
+		port_id, queue,
+	       is_rx ? "received" : "sent",
+	       (unsigned int) nb_pkts);
+	for (i = 0; i < nb_pkts; i++) {
+		mb = pkts[i];
+		eth_hdr = rte_pktmbuf_mtod(mb, struct ether_hdr *);
+		eth_type = RTE_BE_TO_CPU_16(eth_hdr->ether_type);
+		ol_flags = mb->ol_flags;
+		packet_type = mb->packet_type;
+		is_encapsulation = RTE_ETH_IS_TUNNEL_PKT(packet_type);
+
+		print_ether_addr("  src=", &eth_hdr->s_addr);
+		print_ether_addr(" - dst=", &eth_hdr->d_addr);
+		printf(" - type=0x%04x - length=%u - nb_segs=%d",
+		       eth_type, (unsigned int) mb->pkt_len,
+		       (int)mb->nb_segs);
+		if (ol_flags & PKT_RX_RSS_HASH) {
+			printf(" - RSS hash=0x%x", (unsigned int) mb->hash.rss);
+			printf(" - RSS queue=0x%x", (unsigned int) queue);
+		}
+		if (ol_flags & PKT_RX_FDIR) {
+			printf(" - FDIR matched ");
+			if (ol_flags & PKT_RX_FDIR_ID)
+				printf("ID=0x%x",
+				       mb->hash.fdir.hi);
+			else if (ol_flags & PKT_RX_FDIR_FLX)
+				printf("flex bytes=0x%08x %08x",
+				       mb->hash.fdir.hi, mb->hash.fdir.lo);
+			else
+				printf("hash=0x%x ID=0x%x ",
+				       mb->hash.fdir.hash, mb->hash.fdir.id);
+		}
+		if (ol_flags & PKT_RX_TIMESTAMP)
+			printf(" - timestamp %"PRIu64" ", mb->timestamp);
+		if (ol_flags & PKT_RX_VLAN_STRIPPED)
+			printf(" - VLAN tci=0x%x", mb->vlan_tci);
+		if (ol_flags & PKT_RX_QINQ_STRIPPED)
+			printf(" - QinQ VLAN tci=0x%x, VLAN tci outer=0x%x",
+			       mb->vlan_tci, mb->vlan_tci_outer);
+		if (mb->packet_type) {
+			rte_get_ptype_name(mb->packet_type, buf, sizeof(buf));
+			printf(" - hw ptype: %s", buf);
+		}
+		sw_packet_type = rte_net_get_ptype(mb, &hdr_lens,
+						   RTE_PTYPE_ALL_MASK);
+		rte_get_ptype_name(sw_packet_type, buf, sizeof(buf));
+		printf(" - sw ptype: %s", buf);
+		if (sw_packet_type & RTE_PTYPE_L2_MASK)
+			printf(" - l2_len=%d", hdr_lens.l2_len);
+		if (sw_packet_type & RTE_PTYPE_L3_MASK)
+			printf(" - l4_len=%d", hdr_lens.l4_len);
+		if (sw_packet_type & RTE_PTYPE_TUNNEL_MASK)
+			printf(" - tunnel_len=%d", hdr_lens.tunnel_len);
+		if (sw_packet_type & RTE_PTYPE_INNER_L2_MASK)
+			printf(" - inner_l2_len=%d", hdr_lens.inner_l2_len);
+		if (sw_packet_type & RTE_PTYPE_INNER_L4_MASK)
+			printf(" - inner_l4_len=%d", hdr_lens.inner_l4_len);
+		if (is_encapsulation) {
+			struct ipv4_hdr *ipv4_hdr;
+			struct ipv6_hdr *ipv6_hdr;
+			struct udp_hdr *udp_hdr;
+			uint8_t l2_len;
+			uint8_t l3_len;
+			uint8_t l4_len;
+			uint8_t l4_proto;
+			struct  vxlan_hdr *vxlan_hdr;
+
+			l2_len  = sizeof(struct ether_hdr);
+
+			/* Do not support ipv4 option field */
+			if (RTE_ETH_IS_IPV4_HDR(packet_type)) {
+				l3_len = sizeof(struct ipv4_hdr);
+				ipv4_hdr = rte_pktmbuf_mtod_offset(mb,
+				struct ipv4_hdr *,
+				l2_len);
+				l4_proto = ipv4_hdr->next_proto_id;
+			} else {
+				l3_len = sizeof(struct ipv6_hdr);
+				ipv6_hdr = rte_pktmbuf_mtod_offset(mb,
+				struct ipv6_hdr *,
+				l2_len);
+				l4_proto = ipv6_hdr->proto;
+			}
+			if (l4_proto == IPPROTO_UDP) {
+				udp_hdr = rte_pktmbuf_mtod_offset(mb,
+				struct udp_hdr *,
+				l2_len + l3_len);
+				l4_len = sizeof(struct udp_hdr);
+				vxlan_hdr = rte_pktmbuf_mtod_offset(mb,
+				struct vxlan_hdr *,
+				l2_len + l3_len + l4_len);
+				udp_port = RTE_BE_TO_CPU_16(udp_hdr->dst_port);
+				vx_vni = rte_be_to_cpu_32(vxlan_hdr->vx_vni);
+				printf(" - VXLAN packet: packet type =%d, "
+				       "Destination UDP port =%d, VNI = %d",
+				       packet_type, udp_port, vx_vni >> 8);
+			}
+		}
+		printf(" - %s queue=0x%x", is_rx ? "Receive" : "Send",
+			(unsigned int) queue);
+		printf("\n");
+		rte_get_rx_ol_flag_list(mb->ol_flags, buf, sizeof(buf));
+		printf("  ol_flags: %s\n", buf);
+	}
+}
-- 
2.7.4

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH v3 2/3] app/testpmd: add packet dump callback functions
  2018-10-03 15:16     ` [dpdk-dev] [PATCH v3 " Raslan Darawsheh
@ 2018-10-03 15:16       ` 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
  2 siblings, 0 replies; 47+ messages in thread
From: Raslan Darawsheh @ 2018-10-03 15:16 UTC (permalink / raw)
  To: jingjing.wu
  Cc: Thomas Monjalon, dev, Shahaf Shuler, Raslan Darawsheh,
	Xueming(Steven) Li, Ori Kam, jerin.jacob, david.marchand,
	bernard.iremonger

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

Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
---
 app/test-pmd/config.c  | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++
 app/test-pmd/testpmd.h | 15 +++++++++++
 app/test-pmd/util.c    | 17 +++++++++++++
 3 files changed, 99 insertions(+)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index a0f9349..fb45fea 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -2896,6 +2896,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/testpmd.h b/app/test-pmd/testpmd.h
index a1f6614..c0d7656 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -180,6 +180,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
@@ -743,6 +745,19 @@ int check_nb_rxq(queueid_t rxq);
 queueid_t get_allowed_max_nb_txq(portid_t *pid);
 int check_nb_txq(queueid_t txq);
 
+
+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
  * rte_be_to_cpu_16() function.
diff --git a/app/test-pmd/util.c b/app/test-pmd/util.c
index 12bbe91..3d111a2 100644
--- a/app/test-pmd/util.c
+++ b/app/test-pmd/util.c
@@ -144,3 +144,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

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH v3 3/3] app/testpmd: set packet dump based on verbosity level
  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       ` Raslan Darawsheh
  2018-10-04 14:43       ` [dpdk-dev] [PATCH v3 1/3] app/testpmd: move dumping packets to a separate function Iremonger, Bernard
  2 siblings, 0 replies; 47+ messages in thread
From: Raslan Darawsheh @ 2018-10-03 15:16 UTC (permalink / raw)
  To: jingjing.wu
  Cc: Thomas Monjalon, dev, Shahaf Shuler, Raslan Darawsheh,
	Xueming(Steven) Li, Ori Kam, jerin.jacob, david.marchand,
	bernard.iremonger

when changing verbosity level it will configure rx/tx callbacks to dump
packets based on the verbosity value as following:
    1- dump only received packets:
       testpmd> set verbose 1
    2- dump only sent packets:
       testpmd> set verbose 2
    3- dump sent and received packets:
       testpmd> set verbose (any number > 2)
    4- disable dump
       testpmd> set verbose 0

Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
---
 app/test-pmd/config.c  | 25 +++++++++++++++++++++++++
 app/test-pmd/testpmd.c |  4 ++--
 app/test-pmd/testpmd.h |  1 +
 3 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index fb45fea..f402e04 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -50,6 +50,7 @@
 #endif
 #include <rte_gro.h>
 #include <cmdline_parse_etheraddr.h>
+#include <rte_config.h>
 
 #include "testpmd.h"
 
@@ -2963,11 +2964,35 @@ remove_tx_dump_callbacks(portid_t portid)
 }
 
 void
+configure_rxtx_dump_callbacks(uint16_t verbose)
+{
+	portid_t portid;
+
+#ifndef RTE_ETHDEV_RXTX_CALLBACKS
+		TESTPMD_LOG(ERR, "setting rxtx callbacks is not enabled\n");
+		return;
+#endif
+
+	RTE_ETH_FOREACH_DEV(portid)
+	{
+		if (verbose == 1 || verbose > 2)
+			add_rx_dump_callbacks(portid);
+		else
+			remove_rx_dump_callbacks(portid);
+		if (verbose >= 2)
+			add_tx_dump_callbacks(portid);
+		else
+			remove_tx_dump_callbacks(portid);
+	}
+}
+
+void
 set_verbose_level(uint16_t vb_level)
 {
 	printf("Change verbose level from %u to %u\n",
 	       (unsigned int) verbose_level, (unsigned int) vb_level);
 	verbose_level = vb_level;
+	configure_rxtx_dump_callbacks(verbose_level);
 }
 
 void
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 571ecb4..538723c 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -1665,7 +1665,7 @@ start_port(portid_t pid)
 					return -1;
 				}
 			}
-
+			configure_rxtx_dump_callbacks(0);
 			printf("Configuring Port %d (socket %u)\n", pi,
 					port->socket_id);
 			/* configure port */
@@ -1764,7 +1764,7 @@ start_port(portid_t pid)
 				return -1;
 			}
 		}
-
+		configure_rxtx_dump_callbacks(verbose_level);
 		/* start port */
 		if (rte_eth_dev_start(pi) < 0) {
 			printf("Fail to start port %d\n", pi);
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index c0d7656..e68710d 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -757,6 +757,7 @@ 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);
+void configure_rxtx_dump_callbacks(uint16_t verbose);
 
 /*
  * Work-around of a compilation error with ICC on invocations of the
-- 
2.7.4

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH v3 1/3] app/testpmd: move dumping packets to a separate function
  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       ` Iremonger, Bernard
  2018-10-07  7:38         ` Raslan Darawsheh
  2 siblings, 1 reply; 47+ messages in thread
From: Iremonger, Bernard @ 2018-10-04 14:43 UTC (permalink / raw)
  To: Raslan Darawsheh, Wu, Jingjing
  Cc: Thomas Monjalon, dev, Shahaf Shuler, Xueming(Steven) Li, Ori Kam,
	jerin.jacob, david.marchand

Hi Raslan,

> -----Original Message-----
> From: Raslan Darawsheh [mailto:rasland@mellanox.com]
> Sent: Wednesday, October 3, 2018 4:16 PM
> To: Wu, Jingjing <jingjing.wu@intel.com>
> Cc: Thomas Monjalon <thomas@monjalon.net>; dev@dpdk.org; Shahaf
> Shuler <shahafs@mellanox.com>; Raslan Darawsheh
> <rasland@mellanox.com>; Xueming(Steven) Li <xuemingl@mellanox.com>;
> Ori Kam <orika@mellanox.com>; jerin.jacob@caviumnetworks.com;
> david.marchand@6wind.com; Iremonger, Bernard
> <bernard.iremonger@intel.com>
> Subject: [PATCH v3 1/3] app/testpmd: move dumping packets to a separate
> function
> 
> verbosity for the received/sent packets is needed in all of the forwarding
> engines so moving it to be in a separate function
> 
> Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
> 
> ---
> changes in v3:
> 	- add util.c in the mason.build file
> 	- restore missing check for ol_flags & PKT_RX_RSS_HASH.
> 	- add local variables for rte_be_to_cpu to avoid long
> 	  lines.
> ---
<snip>
> diff --git a/app/test-pmd/util.c b/app/test-pmd/util.c new file mode 100644
> index 0000000..12bbe91
> --- /dev/null
> +++ b/app/test-pmd/util.c
> @@ -0,0 +1,146 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2010-2018 Mellanox technology.
> + */
> +
> +#include <stdio.h>
> +
> +#include <rte_net.h>
> +#include <rte_mbuf.h>
> +#include <rte_ether.h>
> +#include <rte_ethdev.h>
> +#include <rte_flow.h>
> +
> +#include "testpmd.h"
> +
> +static inline void
> +print_ether_addr(const char *what, struct ether_addr *eth_addr) {
> +	char buf[ETHER_ADDR_FMT_SIZE];
> +	ether_format_addr(buf, ETHER_ADDR_FMT_SIZE, eth_addr);
> +	printf("%s%s", what, buf);
> +}
> +
> +static  inline void
> +dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf
> *pkts[],
> +	      uint16_t nb_pkts, int is_rx)
> +{
> +	struct rte_mbuf  *mb;
> +	struct ether_hdr *eth_hdr;
> +	uint16_t eth_type;
> +	uint64_t ol_flags;
> +	uint16_t i, packet_type;
> +	uint16_t is_encapsulation;
> +	char buf[256];
> +	struct rte_net_hdr_lens hdr_lens;
> +	uint32_t sw_packet_type;
> +	uint16_t udp_port;
> +	uint32_t vx_vni;
> +
> +	if (!nb_pkts)
> +		return;
> +	printf("port %u/queue %u: %s %u packets\n",
> +		port_id, queue,
> +	       is_rx ? "received" : "sent",
> +	       (unsigned int) nb_pkts);
> +	for (i = 0; i < nb_pkts; i++) {
> +		mb = pkts[i];
> +		eth_hdr = rte_pktmbuf_mtod(mb, struct ether_hdr *);
> +		eth_type = RTE_BE_TO_CPU_16(eth_hdr->ether_type);
> +		ol_flags = mb->ol_flags;
> +		packet_type = mb->packet_type;
> +		is_encapsulation = RTE_ETH_IS_TUNNEL_PKT(packet_type);
> +
> +		print_ether_addr("  src=", &eth_hdr->s_addr);
> +		print_ether_addr(" - dst=", &eth_hdr->d_addr);
> +		printf(" - type=0x%04x - length=%u - nb_segs=%d",
> +		       eth_type, (unsigned int) mb->pkt_len,
> +		       (int)mb->nb_segs);
> +		if (ol_flags & PKT_RX_RSS_HASH) {
> +			printf(" - RSS hash=0x%x", (unsigned int) mb-
> >hash.rss);
> +			printf(" - RSS queue=0x%x", (unsigned int) queue);
> +		}
> +		if (ol_flags & PKT_RX_FDIR) {
> +			printf(" - FDIR matched ");
> +			if (ol_flags & PKT_RX_FDIR_ID)
> +				printf("ID=0x%x",
> +				       mb->hash.fdir.hi);
> +			else if (ol_flags & PKT_RX_FDIR_FLX)
> +				printf("flex bytes=0x%08x %08x",
> +				       mb->hash.fdir.hi, mb->hash.fdir.lo);
> +			else
> +				printf("hash=0x%x ID=0x%x ",
> +				       mb->hash.fdir.hash, mb->hash.fdir.id);
> +		}
> +		if (ol_flags & PKT_RX_TIMESTAMP)
> +			printf(" - timestamp %"PRIu64" ", mb->timestamp);
> +		if (ol_flags & PKT_RX_VLAN_STRIPPED)
> +			printf(" - VLAN tci=0x%x", mb->vlan_tci);
> +		if (ol_flags & PKT_RX_QINQ_STRIPPED)
> +			printf(" - QinQ VLAN tci=0x%x, VLAN tci outer=0x%x",
> +			       mb->vlan_tci, mb->vlan_tci_outer);
> +		if (mb->packet_type) {
> +			rte_get_ptype_name(mb->packet_type, buf,
> sizeof(buf));
> +			printf(" - hw ptype: %s", buf);
> +		}
> +		sw_packet_type = rte_net_get_ptype(mb, &hdr_lens,
> +						   RTE_PTYPE_ALL_MASK);
> +		rte_get_ptype_name(sw_packet_type, buf, sizeof(buf));
> +		printf(" - sw ptype: %s", buf);
> +		if (sw_packet_type & RTE_PTYPE_L2_MASK)
> +			printf(" - l2_len=%d", hdr_lens.l2_len);
> +		if (sw_packet_type & RTE_PTYPE_L3_MASK)

The l3 data is missing and the check for RTE_PTYPE_L4_MASK is missing.

> +			printf(" - l4_len=%d", hdr_lens.l4_len);
> +		if (sw_packet_type & RTE_PTYPE_TUNNEL_MASK)
> +			printf(" - tunnel_len=%d", hdr_lens.tunnel_len);
> +		if (sw_packet_type & RTE_PTYPE_INNER_L2_MASK)
> +			printf(" - inner_l2_len=%d", hdr_lens.inner_l2_len);

The inner l3 data is missing and the check for RTE_PTYPE_INNER_L3_MASK is missing

> +		if (sw_packet_type & RTE_PTYPE_INNER_L4_MASK)
> +			printf(" - inner_l4_len=%d", hdr_lens.inner_l4_len);
> +		if (is_encapsulation) {
> +			struct ipv4_hdr *ipv4_hdr;
> +			struct ipv6_hdr *ipv6_hdr;
> +			struct udp_hdr *udp_hdr;
> +			uint8_t l2_len;
> +			uint8_t l3_len;
> +			uint8_t l4_len;
> +			uint8_t l4_proto;
> +			struct  vxlan_hdr *vxlan_hdr;
> +
> +			l2_len  = sizeof(struct ether_hdr);
> +
> +			/* Do not support ipv4 option field */
> +			if (RTE_ETH_IS_IPV4_HDR(packet_type)) {
> +				l3_len = sizeof(struct ipv4_hdr);
> +				ipv4_hdr = rte_pktmbuf_mtod_offset(mb,
> +				struct ipv4_hdr *,
> +				l2_len);
> +				l4_proto = ipv4_hdr->next_proto_id;
> +			} else {
> +				l3_len = sizeof(struct ipv6_hdr);
> +				ipv6_hdr = rte_pktmbuf_mtod_offset(mb,
> +				struct ipv6_hdr *,
> +				l2_len);
> +				l4_proto = ipv6_hdr->proto;
> +			}
> +			if (l4_proto == IPPROTO_UDP) {
> +				udp_hdr = rte_pktmbuf_mtod_offset(mb,
> +				struct udp_hdr *,
> +				l2_len + l3_len);
> +				l4_len = sizeof(struct udp_hdr);
> +				vxlan_hdr = rte_pktmbuf_mtod_offset(mb,
> +				struct vxlan_hdr *,
> +				l2_len + l3_len + l4_len);
> +				udp_port = RTE_BE_TO_CPU_16(udp_hdr-
> >dst_port);
> +				vx_vni = rte_be_to_cpu_32(vxlan_hdr-
> >vx_vni);
> +				printf(" - VXLAN packet: packet type =%d, "
> +				       "Destination UDP port =%d, VNI = %d",
> +				       packet_type, udp_port, vx_vni >> 8);
> +			}
> +		}
> +		printf(" - %s queue=0x%x", is_rx ? "Receive" : "Send",
> +			(unsigned int) queue);
> +		printf("\n");
> +		rte_get_rx_ol_flag_list(mb->ol_flags, buf, sizeof(buf));
> +		printf("  ol_flags: %s\n", buf);
> +	}
> +}
> --
> 2.7.4

Regards,

Bernard.

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH v3 1/3] app/testpmd: move dumping packets to a separate function
  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
  0 siblings, 0 replies; 47+ messages in thread
From: Raslan Darawsheh @ 2018-10-07  7:38 UTC (permalink / raw)
  To: Iremonger, Bernard, Wu, Jingjing
  Cc: Thomas Monjalon, dev, Shahaf Shuler, Xueming(Steven) Li, Ori Kam,
	jerin.jacob, david.marchand

You are right about that, I'm sending a V4 now with the fixes. 

Kindest regards,
Raslan Darawsheh

> -----Original Message-----
> From: Iremonger, Bernard <bernard.iremonger@intel.com>
> Sent: Thursday, October 4, 2018 5:44 PM
> To: Raslan Darawsheh <rasland@mellanox.com>; Wu, Jingjing
> <jingjing.wu@intel.com>
> Cc: Thomas Monjalon <thomas@monjalon.net>; dev@dpdk.org; Shahaf
> Shuler <shahafs@mellanox.com>; Xueming(Steven) Li
> <xuemingl@mellanox.com>; Ori Kam <orika@mellanox.com>;
> jerin.jacob@caviumnetworks.com; david.marchand@6wind.com
> Subject: RE: [PATCH v3 1/3] app/testpmd: move dumping packets to a
> separate function
> 
> Hi Raslan,
> 
> > -----Original Message-----
> > From: Raslan Darawsheh [mailto:rasland@mellanox.com]
> > Sent: Wednesday, October 3, 2018 4:16 PM
> > To: Wu, Jingjing <jingjing.wu@intel.com>
> > Cc: Thomas Monjalon <thomas@monjalon.net>; dev@dpdk.org; Shahaf
> Shuler
> > <shahafs@mellanox.com>; Raslan Darawsheh <rasland@mellanox.com>;
> > Xueming(Steven) Li <xuemingl@mellanox.com>; Ori Kam
> > <orika@mellanox.com>; jerin.jacob@caviumnetworks.com;
> > david.marchand@6wind.com; Iremonger, Bernard
> > <bernard.iremonger@intel.com>
> > Subject: [PATCH v3 1/3] app/testpmd: move dumping packets to a
> > separate function
> >
> > verbosity for the received/sent packets is needed in all of the
> > forwarding engines so moving it to be in a separate function
> >
> > Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
> >
> > ---
> > changes in v3:
> > 	- add util.c in the mason.build file
> > 	- restore missing check for ol_flags & PKT_RX_RSS_HASH.
> > 	- add local variables for rte_be_to_cpu to avoid long
> > 	  lines.
> > ---
> <snip>
> > diff --git a/app/test-pmd/util.c b/app/test-pmd/util.c new file mode
> > 100644 index 0000000..12bbe91
> > --- /dev/null
> > +++ b/app/test-pmd/util.c
> > @@ -0,0 +1,146 @@
> > +/* SPDX-License-Identifier: BSD-3-Clause
> > + * Copyright(c) 2010-2018 Mellanox technology.
> > + */
> > +
> > +#include <stdio.h>
> > +
> > +#include <rte_net.h>
> > +#include <rte_mbuf.h>
> > +#include <rte_ether.h>
> > +#include <rte_ethdev.h>
> > +#include <rte_flow.h>
> > +
> > +#include "testpmd.h"
> > +
> > +static inline void
> > +print_ether_addr(const char *what, struct ether_addr *eth_addr) {
> > +	char buf[ETHER_ADDR_FMT_SIZE];
> > +	ether_format_addr(buf, ETHER_ADDR_FMT_SIZE, eth_addr);
> > +	printf("%s%s", what, buf);
> > +}
> > +
> > +static  inline void
> > +dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf
> > *pkts[],
> > +	      uint16_t nb_pkts, int is_rx)
> > +{
> > +	struct rte_mbuf  *mb;
> > +	struct ether_hdr *eth_hdr;
> > +	uint16_t eth_type;
> > +	uint64_t ol_flags;
> > +	uint16_t i, packet_type;
> > +	uint16_t is_encapsulation;
> > +	char buf[256];
> > +	struct rte_net_hdr_lens hdr_lens;
> > +	uint32_t sw_packet_type;
> > +	uint16_t udp_port;
> > +	uint32_t vx_vni;
> > +
> > +	if (!nb_pkts)
> > +		return;
> > +	printf("port %u/queue %u: %s %u packets\n",
> > +		port_id, queue,
> > +	       is_rx ? "received" : "sent",
> > +	       (unsigned int) nb_pkts);
> > +	for (i = 0; i < nb_pkts; i++) {
> > +		mb = pkts[i];
> > +		eth_hdr = rte_pktmbuf_mtod(mb, struct ether_hdr *);
> > +		eth_type = RTE_BE_TO_CPU_16(eth_hdr->ether_type);
> > +		ol_flags = mb->ol_flags;
> > +		packet_type = mb->packet_type;
> > +		is_encapsulation = RTE_ETH_IS_TUNNEL_PKT(packet_type);
> > +
> > +		print_ether_addr("  src=", &eth_hdr->s_addr);
> > +		print_ether_addr(" - dst=", &eth_hdr->d_addr);
> > +		printf(" - type=0x%04x - length=%u - nb_segs=%d",
> > +		       eth_type, (unsigned int) mb->pkt_len,
> > +		       (int)mb->nb_segs);
> > +		if (ol_flags & PKT_RX_RSS_HASH) {
> > +			printf(" - RSS hash=0x%x", (unsigned int) mb-
> > >hash.rss);
> > +			printf(" - RSS queue=0x%x", (unsigned int) queue);
> > +		}
> > +		if (ol_flags & PKT_RX_FDIR) {
> > +			printf(" - FDIR matched ");
> > +			if (ol_flags & PKT_RX_FDIR_ID)
> > +				printf("ID=0x%x",
> > +				       mb->hash.fdir.hi);
> > +			else if (ol_flags & PKT_RX_FDIR_FLX)
> > +				printf("flex bytes=0x%08x %08x",
> > +				       mb->hash.fdir.hi, mb->hash.fdir.lo);
> > +			else
> > +				printf("hash=0x%x ID=0x%x ",
> > +				       mb->hash.fdir.hash, mb->hash.fdir.id);
> > +		}
> > +		if (ol_flags & PKT_RX_TIMESTAMP)
> > +			printf(" - timestamp %"PRIu64" ", mb->timestamp);
> > +		if (ol_flags & PKT_RX_VLAN_STRIPPED)
> > +			printf(" - VLAN tci=0x%x", mb->vlan_tci);
> > +		if (ol_flags & PKT_RX_QINQ_STRIPPED)
> > +			printf(" - QinQ VLAN tci=0x%x, VLAN tci outer=0x%x",
> > +			       mb->vlan_tci, mb->vlan_tci_outer);
> > +		if (mb->packet_type) {
> > +			rte_get_ptype_name(mb->packet_type, buf,
> > sizeof(buf));
> > +			printf(" - hw ptype: %s", buf);
> > +		}
> > +		sw_packet_type = rte_net_get_ptype(mb, &hdr_lens,
> > +						   RTE_PTYPE_ALL_MASK);
> > +		rte_get_ptype_name(sw_packet_type, buf, sizeof(buf));
> > +		printf(" - sw ptype: %s", buf);
> > +		if (sw_packet_type & RTE_PTYPE_L2_MASK)
> > +			printf(" - l2_len=%d", hdr_lens.l2_len);
> > +		if (sw_packet_type & RTE_PTYPE_L3_MASK)
> 
> The l3 data is missing and the check for RTE_PTYPE_L4_MASK is missing.
> 
> > +			printf(" - l4_len=%d", hdr_lens.l4_len);
> > +		if (sw_packet_type & RTE_PTYPE_TUNNEL_MASK)
> > +			printf(" - tunnel_len=%d", hdr_lens.tunnel_len);
> > +		if (sw_packet_type & RTE_PTYPE_INNER_L2_MASK)
> > +			printf(" - inner_l2_len=%d", hdr_lens.inner_l2_len);
> 
> The inner l3 data is missing and the check for RTE_PTYPE_INNER_L3_MASK is
> missing
> 
> > +		if (sw_packet_type & RTE_PTYPE_INNER_L4_MASK)
> > +			printf(" - inner_l4_len=%d", hdr_lens.inner_l4_len);
> > +		if (is_encapsulation) {
> > +			struct ipv4_hdr *ipv4_hdr;
> > +			struct ipv6_hdr *ipv6_hdr;
> > +			struct udp_hdr *udp_hdr;
> > +			uint8_t l2_len;
> > +			uint8_t l3_len;
> > +			uint8_t l4_len;
> > +			uint8_t l4_proto;
> > +			struct  vxlan_hdr *vxlan_hdr;
> > +
> > +			l2_len  = sizeof(struct ether_hdr);
> > +
> > +			/* Do not support ipv4 option field */
> > +			if (RTE_ETH_IS_IPV4_HDR(packet_type)) {
> > +				l3_len = sizeof(struct ipv4_hdr);
> > +				ipv4_hdr = rte_pktmbuf_mtod_offset(mb,
> > +				struct ipv4_hdr *,
> > +				l2_len);
> > +				l4_proto = ipv4_hdr->next_proto_id;
> > +			} else {
> > +				l3_len = sizeof(struct ipv6_hdr);
> > +				ipv6_hdr = rte_pktmbuf_mtod_offset(mb,
> > +				struct ipv6_hdr *,
> > +				l2_len);
> > +				l4_proto = ipv6_hdr->proto;
> > +			}
> > +			if (l4_proto == IPPROTO_UDP) {
> > +				udp_hdr = rte_pktmbuf_mtod_offset(mb,
> > +				struct udp_hdr *,
> > +				l2_len + l3_len);
> > +				l4_len = sizeof(struct udp_hdr);
> > +				vxlan_hdr = rte_pktmbuf_mtod_offset(mb,
> > +				struct vxlan_hdr *,
> > +				l2_len + l3_len + l4_len);
> > +				udp_port = RTE_BE_TO_CPU_16(udp_hdr-
> > >dst_port);
> > +				vx_vni = rte_be_to_cpu_32(vxlan_hdr-
> > >vx_vni);
> > +				printf(" - VXLAN packet: packet type =%d, "
> > +				       "Destination UDP port =%d, VNI = %d",
> > +				       packet_type, udp_port, vx_vni >> 8);
> > +			}
> > +		}
> > +		printf(" - %s queue=0x%x", is_rx ? "Receive" : "Send",
> > +			(unsigned int) queue);
> > +		printf("\n");
> > +		rte_get_rx_ol_flag_list(mb->ol_flags, buf, sizeof(buf));
> > +		printf("  ol_flags: %s\n", buf);
> > +	}
> > +}
> > --
> > 2.7.4
> 
> Regards,
> 
> Bernard.

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH v4 1/3] app/testpmd: move dumping packets to a separate function
  2018-09-24 12:49   ` [dpdk-dev] [PATCH v2 1/3] app/testpmd: move dumping packets to a separate function Raslan Darawsheh
                       ` (3 preceding siblings ...)
  2018-10-03 15:16     ` [dpdk-dev] [PATCH v3 " Raslan Darawsheh
@ 2018-10-07  7:38     ` Raslan Darawsheh
  2018-10-07  7:38       ` [dpdk-dev] [PATCH v4 2/3] app/testpmd: add packet dump callback functions Raslan Darawsheh
                         ` (5 more replies)
  4 siblings, 6 replies; 47+ messages in thread
From: Raslan Darawsheh @ 2018-10-07  7:38 UTC (permalink / raw)
  To: jingjing.wu
  Cc: Thomas Monjalon, dev, Shahaf Shuler, Raslan Darawsheh,
	Xueming(Steven) Li, Ori Kam, jerin.jacob, david.marchand,
	bernard.iremonger

verbosity for the received/sent packets is needed in all of the
forwarding engines so moving it to be in a separate function

---
changes in v3:
	- add util.c in the mason.build file
	- restore missing check for ol_flags & PKT_RX_RSS_HASH.
	- add local variables for rte_be_to_cpu to avoid long
	  lines.

changes in v4:
	- add missing l3 and l4 checks
---

Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
---
 app/test-pmd/Makefile    |   1 +
 app/test-pmd/meson.build |   3 +-
 app/test-pmd/rxonly.c    | 134 +-----------------------------------------
 app/test-pmd/util.c      | 150 +++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 156 insertions(+), 132 deletions(-)
 create mode 100644 app/test-pmd/util.c

diff --git a/app/test-pmd/Makefile b/app/test-pmd/Makefile
index 2b4d604..e2c7845 100644
--- a/app/test-pmd/Makefile
+++ b/app/test-pmd/Makefile
@@ -35,6 +35,7 @@ SRCS-y += csumonly.c
 SRCS-y += icmpecho.c
 SRCS-$(CONFIG_RTE_LIBRTE_IEEE1588) += ieee1588fwd.c
 SRCS-$(CONFIG_RTE_LIBRTE_BPF) += bpf_cmd.c
+SRCS-y += util.c
 
 ifeq ($(CONFIG_RTE_LIBRTE_PMD_SOFTNIC), y)
 SRCS-y += softnicfwd.c
diff --git a/app/test-pmd/meson.build b/app/test-pmd/meson.build
index a0b3be0..b96ab97 100644
--- a/app/test-pmd/meson.build
+++ b/app/test-pmd/meson.build
@@ -20,7 +20,8 @@ sources = files('cmdline.c',
 	'parameters.c',
 	'rxonly.c',
 	'testpmd.c',
-	'txonly.c')
+	'txonly.c',
+	'util.c')
 
 deps = ['ethdev', 'gro', 'gso', 'cmdline', 'metrics', 'meter', 'bus_pci']
 if dpdk_conf.has('RTE_LIBRTE_PDUMP')
diff --git a/app/test-pmd/rxonly.c b/app/test-pmd/rxonly.c
index a93d806..3eca89c 100644
--- a/app/test-pmd/rxonly.c
+++ b/app/test-pmd/rxonly.c
@@ -40,14 +40,6 @@
 
 #include "testpmd.h"
 
-static inline void
-print_ether_addr(const char *what, struct ether_addr *eth_addr)
-{
-	char buf[ETHER_ADDR_FMT_SIZE];
-	ether_format_addr(buf, ETHER_ADDR_FMT_SIZE, eth_addr);
-	printf("%s%s", what, buf);
-}
-
 /*
  * Received a burst of packets.
  */
@@ -55,16 +47,8 @@ static void
 pkt_burst_receive(struct fwd_stream *fs)
 {
 	struct rte_mbuf  *pkts_burst[MAX_PKT_BURST];
-	struct rte_mbuf  *mb;
-	struct ether_hdr *eth_hdr;
-	uint16_t eth_type;
-	uint64_t ol_flags;
 	uint16_t nb_rx;
-	uint16_t i, packet_type;
-	uint16_t is_encapsulation;
-	char buf[256];
-	struct rte_net_hdr_lens hdr_lens;
-	uint32_t sw_packet_type;
+	uint16_t i;
 
 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
 	uint64_t start_tsc;
@@ -90,120 +74,8 @@ pkt_burst_receive(struct fwd_stream *fs)
 	/*
 	 * Dump each received packet if verbose_level > 0.
 	 */
-	if (verbose_level > 0)
-		printf("port %u/queue %u: received %u packets\n",
-		       fs->rx_port,
-		       (unsigned) fs->rx_queue,
-		       (unsigned) nb_rx);
-	for (i = 0; i < nb_rx; i++) {
-		mb = pkts_burst[i];
-		if (verbose_level == 0) {
-			rte_pktmbuf_free(mb);
-			continue;
-		}
-		eth_hdr = rte_pktmbuf_mtod(mb, struct ether_hdr *);
-		eth_type = RTE_BE_TO_CPU_16(eth_hdr->ether_type);
-		ol_flags = mb->ol_flags;
-		packet_type = mb->packet_type;
-		is_encapsulation = RTE_ETH_IS_TUNNEL_PKT(packet_type);
-
-		print_ether_addr("  src=", &eth_hdr->s_addr);
-		print_ether_addr(" - dst=", &eth_hdr->d_addr);
-		printf(" - type=0x%04x - length=%u - nb_segs=%d",
-		       eth_type, (unsigned) mb->pkt_len,
-		       (int)mb->nb_segs);
-		if (ol_flags & PKT_RX_RSS_HASH) {
-			printf(" - RSS hash=0x%x", (unsigned) mb->hash.rss);
-			printf(" - RSS queue=0x%x",(unsigned) fs->rx_queue);
-		}
-		if (ol_flags & PKT_RX_FDIR) {
-			printf(" - FDIR matched ");
-			if (ol_flags & PKT_RX_FDIR_ID)
-				printf("ID=0x%x",
-				       mb->hash.fdir.hi);
-			else if (ol_flags & PKT_RX_FDIR_FLX)
-				printf("flex bytes=0x%08x %08x",
-				       mb->hash.fdir.hi, mb->hash.fdir.lo);
-			else
-				printf("hash=0x%x ID=0x%x ",
-				       mb->hash.fdir.hash, mb->hash.fdir.id);
-		}
-		if (ol_flags & PKT_RX_TIMESTAMP)
-			printf(" - timestamp %"PRIu64" ", mb->timestamp);
-		if (ol_flags & PKT_RX_VLAN_STRIPPED)
-			printf(" - VLAN tci=0x%x", mb->vlan_tci);
-		if (ol_flags & PKT_RX_QINQ_STRIPPED)
-			printf(" - QinQ VLAN tci=0x%x, VLAN tci outer=0x%x",
-					mb->vlan_tci, mb->vlan_tci_outer);
-		if (mb->packet_type) {
-			rte_get_ptype_name(mb->packet_type, buf, sizeof(buf));
-			printf(" - hw ptype: %s", buf);
-		}
-		sw_packet_type = rte_net_get_ptype(mb, &hdr_lens,
-			RTE_PTYPE_ALL_MASK);
-		rte_get_ptype_name(sw_packet_type, buf, sizeof(buf));
-		printf(" - sw ptype: %s", buf);
-		if (sw_packet_type & RTE_PTYPE_L2_MASK)
-			printf(" - l2_len=%d", hdr_lens.l2_len);
-		if (sw_packet_type & RTE_PTYPE_L3_MASK)
-			printf(" - l3_len=%d", hdr_lens.l3_len);
-		if (sw_packet_type & RTE_PTYPE_L4_MASK)
-			printf(" - l4_len=%d", hdr_lens.l4_len);
-		if (sw_packet_type & RTE_PTYPE_TUNNEL_MASK)
-			printf(" - tunnel_len=%d", hdr_lens.tunnel_len);
-		if (sw_packet_type & RTE_PTYPE_INNER_L2_MASK)
-			printf(" - inner_l2_len=%d", hdr_lens.inner_l2_len);
-		if (sw_packet_type & RTE_PTYPE_INNER_L3_MASK)
-			printf(" - inner_l3_len=%d", hdr_lens.inner_l3_len);
-		if (sw_packet_type & RTE_PTYPE_INNER_L4_MASK)
-			printf(" - inner_l4_len=%d", hdr_lens.inner_l4_len);
-		if (is_encapsulation) {
-			struct ipv4_hdr *ipv4_hdr;
-			struct ipv6_hdr *ipv6_hdr;
-			struct udp_hdr *udp_hdr;
-			uint8_t l2_len;
-			uint8_t l3_len;
-			uint8_t l4_len;
-			uint8_t l4_proto;
-			struct  vxlan_hdr *vxlan_hdr;
-
-			l2_len  = sizeof(struct ether_hdr);
-
-			 /* Do not support ipv4 option field */
-			if (RTE_ETH_IS_IPV4_HDR(packet_type)) {
-				l3_len = sizeof(struct ipv4_hdr);
-				ipv4_hdr = rte_pktmbuf_mtod_offset(mb,
-								   struct ipv4_hdr *,
-								   l2_len);
-				l4_proto = ipv4_hdr->next_proto_id;
-			} else {
-				l3_len = sizeof(struct ipv6_hdr);
-				ipv6_hdr = rte_pktmbuf_mtod_offset(mb,
-								   struct ipv6_hdr *,
-								   l2_len);
-				l4_proto = ipv6_hdr->proto;
-			}
-			if (l4_proto == IPPROTO_UDP) {
-				udp_hdr = rte_pktmbuf_mtod_offset(mb,
-								  struct udp_hdr *,
-								  l2_len + l3_len);
-				l4_len = sizeof(struct udp_hdr);
-				vxlan_hdr = rte_pktmbuf_mtod_offset(mb,
-								    struct vxlan_hdr *,
-								    l2_len + l3_len + l4_len);
-
-				printf(" - VXLAN packet: packet type =%d, "
-					"Destination UDP port =%d, VNI = %d",
-					packet_type, RTE_BE_TO_CPU_16(udp_hdr->dst_port),
-					rte_be_to_cpu_32(vxlan_hdr->vx_vni) >> 8);
-			}
-		}
-		printf(" - Receive queue=0x%x", (unsigned) fs->rx_queue);
-		printf("\n");
-		rte_get_rx_ol_flag_list(mb->ol_flags, buf, sizeof(buf));
-		printf("  ol_flags: %s\n", buf);
-		rte_pktmbuf_free(mb);
-	}
+	for (i = 0; i < nb_rx; i++)
+		rte_pktmbuf_free(pkts_burst[i]);
 
 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
 	end_tsc = rte_rdtsc();
diff --git a/app/test-pmd/util.c b/app/test-pmd/util.c
new file mode 100644
index 0000000..e56b712
--- /dev/null
+++ b/app/test-pmd/util.c
@@ -0,0 +1,150 @@
+/* SPDX-License-Identifie.r: BSD-3-Clause
+ * Copyri.ght(c) 2010-2018 Mellanox technology.
+ */
+
+#include <stdio.h>
+
+#include <rte_net.h>
+#include <rte_mbuf.h>
+#include <rte_ether.h>
+#include <rte_ethdev.h>
+#include <rte_flow.h>
+
+#include "testpmd.h"
+
+static inline void
+print_ether_addr(const char *what, struct ether_addr *eth_addr)
+{
+	char buf[ETHER_ADDR_FMT_SIZE];
+	ether_format_addr(buf, ETHER_ADDR_FMT_SIZE, eth_addr);
+	printf("%s%s", what, buf);
+}
+
+static  inline void
+dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],
+	      uint16_t nb_pkts, int is_rx)
+{
+	struct rte_mbuf  *mb;
+	struct ether_hdr *eth_hdr;
+	uint16_t eth_type;
+	uint64_t ol_flags;
+	uint16_t i, packet_type;
+	uint16_t is_encapsulation;
+	char buf[256];
+	struct rte_net_hdr_lens hdr_lens;
+	uint32_t sw_packet_type;
+	uint16_t udp_port;
+	uint32_t vx_vni;
+
+	if (!nb_pkts)
+		return;
+	printf("port %u/queue %u: %s %u packets\n",
+		port_id, queue,
+	       is_rx ? "received" : "sent",
+	       (unsigned int) nb_pkts);
+	for (i = 0; i < nb_pkts; i++) {
+		mb = pkts[i];
+		eth_hdr = rte_pktmbuf_mtod(mb, struct ether_hdr *);
+		eth_type = RTE_BE_TO_CPU_16(eth_hdr->ether_type);
+		ol_flags = mb->ol_flags;
+		packet_type = mb->packet_type;
+		is_encapsulation = RTE_ETH_IS_TUNNEL_PKT(packet_type);
+
+		print_ether_addr("  src=", &eth_hdr->s_addr);
+		print_ether_addr(" - dst=", &eth_hdr->d_addr);
+		printf(" - type=0x%04x - length=%u - nb_segs=%d",
+		       eth_type, (unsigned int) mb->pkt_len,
+		       (int)mb->nb_segs);
+		if (ol_flags & PKT_RX_RSS_HASH) {
+			printf(" - RSS hash=0x%x", (unsigned int) mb->hash.rss);
+			printf(" - RSS queue=0x%x", (unsigned int) queue);
+		}
+		if (ol_flags & PKT_RX_FDIR) {
+			printf(" - FDIR matched ");
+			if (ol_flags & PKT_RX_FDIR_ID)
+				printf("ID=0x%x",
+				       mb->hash.fdir.hi);
+			else if (ol_flags & PKT_RX_FDIR_FLX)
+				printf("flex bytes=0x%08x %08x",
+				       mb->hash.fdir.hi, mb->hash.fdir.lo);
+			else
+				printf("hash=0x%x ID=0x%x ",
+				       mb->hash.fdir.hash, mb->hash.fdir.id);
+		}
+		if (ol_flags & PKT_RX_TIMESTAMP)
+			printf(" - timestamp %"PRIu64" ", mb->timestamp);
+		if (ol_flags & PKT_RX_VLAN_STRIPPED)
+			printf(" - VLAN tci=0x%x", mb->vlan_tci);
+		if (ol_flags & PKT_RX_QINQ_STRIPPED)
+			printf(" - QinQ VLAN tci=0x%x, VLAN tci outer=0x%x",
+			       mb->vlan_tci, mb->vlan_tci_outer);
+		if (mb->packet_type) {
+			rte_get_ptype_name(mb->packet_type, buf, sizeof(buf));
+			printf(" - hw ptype: %s", buf);
+		}
+		sw_packet_type = rte_net_get_ptype(mb, &hdr_lens,
+						   RTE_PTYPE_ALL_MASK);
+		rte_get_ptype_name(sw_packet_type, buf, sizeof(buf));
+		printf(" - sw ptype: %s", buf);
+		if (sw_packet_type & RTE_PTYPE_L2_MASK)
+			printf(" - l2_len=%d", hdr_lens.l2_len);
+		if (sw_packet_type & RTE_PTYPE_L3_MASK)
+			printf(" - l3_len=%d", hdr_lens.l3_len);
+		if (sw_packet_type & RTE_PTYPE_L4_MASK)
+			printf(" - l4_len=%d", hdr_lens.l4_len);
+		if (sw_packet_type & RTE_PTYPE_TUNNEL_MASK)
+			printf(" - tunnel_len=%d", hdr_lens.tunnel_len);
+		if (sw_packet_type & RTE_PTYPE_INNER_L2_MASK)
+			printf(" - inner_l2_len=%d", hdr_lens.inner_l2_len);
+		if (sw_packet_type & RTE_PTYPE_INNER_L3_MASK)
+			printf(" - inner_l3_len=%d", hdr_lens.inner_l3_len);
+		if (sw_packet_type & RTE_PTYPE_INNER_L4_MASK)
+			printf(" - inner_l4_len=%d", hdr_lens.inner_l4_len);
+		if (is_encapsulation) {
+			struct ipv4_hdr *ipv4_hdr;
+			struct ipv6_hdr *ipv6_hdr;
+			struct udp_hdr *udp_hdr;
+			uint8_t l2_len;
+			uint8_t l3_len;
+			uint8_t l4_len;
+			uint8_t l4_proto;
+			struct  vxlan_hdr *vxlan_hdr;
+
+			l2_len  = sizeof(struct ether_hdr);
+
+			/* Do not support ipv4 option field */
+			if (RTE_ETH_IS_IPV4_HDR(packet_type)) {
+				l3_len = sizeof(struct ipv4_hdr);
+				ipv4_hdr = rte_pktmbuf_mtod_offset(mb,
+				struct ipv4_hdr *,
+				l2_len);
+				l4_proto = ipv4_hdr->next_proto_id;
+			} else {
+				l3_len = sizeof(struct ipv6_hdr);
+				ipv6_hdr = rte_pktmbuf_mtod_offset(mb,
+				struct ipv6_hdr *,
+				l2_len);
+				l4_proto = ipv6_hdr->proto;
+			}
+			if (l4_proto == IPPROTO_UDP) {
+				udp_hdr = rte_pktmbuf_mtod_offset(mb,
+				struct udp_hdr *,
+				l2_len + l3_len);
+				l4_len = sizeof(struct udp_hdr);
+				vxlan_hdr = rte_pktmbuf_mtod_offset(mb,
+				struct vxlan_hdr *,
+				l2_len + l3_len + l4_len);
+				udp_port = RTE_BE_TO_CPU_16(udp_hdr->dst_port);
+				vx_vni = rte_be_to_cpu_32(vxlan_hdr->vx_vni);
+				printf(" - VXLAN packet: packet type =%d, "
+				       "Destination UDP port =%d, VNI = %d",
+				       packet_type, udp_port, vx_vni >> 8);
+			}
+		}
+		printf(" - %s queue=0x%x", is_rx ? "Receive" : "Send",
+			(unsigned int) queue);
+		printf("\n");
+		rte_get_rx_ol_flag_list(mb->ol_flags, buf, sizeof(buf));
+		printf("  ol_flags: %s\n", buf);
+	}
+}
-- 
2.7.4

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH v4 2/3] app/testpmd: add packet dump callback functions
  2018-10-07  7:38     ` [dpdk-dev] [PATCH v4 " Raslan Darawsheh
@ 2018-10-07  7:38       ` Raslan Darawsheh
  2018-10-08 10:03         ` Iremonger, Bernard
  2018-10-11 14:58         ` Ferruh Yigit
  2018-10-07  7:38       ` [dpdk-dev] [PATCH v4 3/3] app/testpmd: set packet dump based on verbosity level Raslan Darawsheh
                         ` (4 subsequent siblings)
  5 siblings, 2 replies; 47+ messages in thread
From: Raslan Darawsheh @ 2018-10-07  7:38 UTC (permalink / raw)
  To: jingjing.wu
  Cc: Thomas Monjalon, dev, Shahaf Shuler, Raslan Darawsheh,
	Xueming(Steven) Li, Ori Kam, jerin.jacob, david.marchand,
	bernard.iremonger

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

Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
---
 app/test-pmd/config.c  | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++
 app/test-pmd/testpmd.h | 15 +++++++++++
 app/test-pmd/util.c    | 17 +++++++++++++
 3 files changed, 99 insertions(+)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index a0f9349..fb45fea 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -2896,6 +2896,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/testpmd.h b/app/test-pmd/testpmd.h
index a1f6614..c0d7656 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -180,6 +180,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
@@ -743,6 +745,19 @@ int check_nb_rxq(queueid_t rxq);
 queueid_t get_allowed_max_nb_txq(portid_t *pid);
 int check_nb_txq(queueid_t txq);
 
+
+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
  * rte_be_to_cpu_16() function.
diff --git a/app/test-pmd/util.c b/app/test-pmd/util.c
index e56b712..6fa2284 100644
--- a/app/test-pmd/util.c
+++ b/app/test-pmd/util.c
@@ -148,3 +148,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

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH v4 3/3] app/testpmd: set packet dump based on verbosity level
  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-07  7:38       ` Raslan Darawsheh
  2018-10-08 10:04         ` Iremonger, Bernard
  2018-10-11 15:00         ` Ferruh Yigit
  2018-10-08 10:01       ` [dpdk-dev] [PATCH v4 1/3] app/testpmd: move dumping packets to a separate function Iremonger, Bernard
                         ` (3 subsequent siblings)
  5 siblings, 2 replies; 47+ messages in thread
From: Raslan Darawsheh @ 2018-10-07  7:38 UTC (permalink / raw)
  To: jingjing.wu
  Cc: Thomas Monjalon, dev, Shahaf Shuler, Raslan Darawsheh,
	Xueming(Steven) Li, Ori Kam, jerin.jacob, david.marchand,
	bernard.iremonger

when changing verbosity level it will configure rx/tx callbacks to dump
packets based on the verbosity value as following:
    1- dump only received packets:
       testpmd> set verbose 1
    2- dump only sent packets:
       testpmd> set verbose 2
    3- dump sent and received packets:
       testpmd> set verbose (any number > 2)
    4- disable dump
       testpmd> set verbose 0

Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
---
 app/test-pmd/config.c  | 25 +++++++++++++++++++++++++
 app/test-pmd/testpmd.c |  4 ++--
 app/test-pmd/testpmd.h |  1 +
 3 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index fb45fea..f402e04 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -50,6 +50,7 @@
 #endif
 #include <rte_gro.h>
 #include <cmdline_parse_etheraddr.h>
+#include <rte_config.h>
 
 #include "testpmd.h"
 
@@ -2963,11 +2964,35 @@ remove_tx_dump_callbacks(portid_t portid)
 }
 
 void
+configure_rxtx_dump_callbacks(uint16_t verbose)
+{
+	portid_t portid;
+
+#ifndef RTE_ETHDEV_RXTX_CALLBACKS
+		TESTPMD_LOG(ERR, "setting rxtx callbacks is not enabled\n");
+		return;
+#endif
+
+	RTE_ETH_FOREACH_DEV(portid)
+	{
+		if (verbose == 1 || verbose > 2)
+			add_rx_dump_callbacks(portid);
+		else
+			remove_rx_dump_callbacks(portid);
+		if (verbose >= 2)
+			add_tx_dump_callbacks(portid);
+		else
+			remove_tx_dump_callbacks(portid);
+	}
+}
+
+void
 set_verbose_level(uint16_t vb_level)
 {
 	printf("Change verbose level from %u to %u\n",
 	       (unsigned int) verbose_level, (unsigned int) vb_level);
 	verbose_level = vb_level;
+	configure_rxtx_dump_callbacks(verbose_level);
 }
 
 void
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 571ecb4..538723c 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -1665,7 +1665,7 @@ start_port(portid_t pid)
 					return -1;
 				}
 			}
-
+			configure_rxtx_dump_callbacks(0);
 			printf("Configuring Port %d (socket %u)\n", pi,
 					port->socket_id);
 			/* configure port */
@@ -1764,7 +1764,7 @@ start_port(portid_t pid)
 				return -1;
 			}
 		}
-
+		configure_rxtx_dump_callbacks(verbose_level);
 		/* start port */
 		if (rte_eth_dev_start(pi) < 0) {
 			printf("Fail to start port %d\n", pi);
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index c0d7656..e68710d 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -757,6 +757,7 @@ 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);
+void configure_rxtx_dump_callbacks(uint16_t verbose);
 
 /*
  * Work-around of a compilation error with ICC on invocations of the
-- 
2.7.4

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH v4 1/3] app/testpmd: move dumping packets to a separate function
  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-07  7:38       ` [dpdk-dev] [PATCH v4 3/3] app/testpmd: set packet dump based on verbosity level Raslan Darawsheh
@ 2018-10-08 10:01       ` Iremonger, Bernard
  2018-10-11 14:56       ` Ferruh Yigit
                         ` (2 subsequent siblings)
  5 siblings, 0 replies; 47+ messages in thread
From: Iremonger, Bernard @ 2018-10-08 10:01 UTC (permalink / raw)
  To: Raslan Darawsheh, Wu, Jingjing
  Cc: Thomas Monjalon, dev, Shahaf Shuler, Xueming(Steven) Li, Ori Kam,
	jerin.jacob, david.marchand

> -----Original Message-----
> From: Raslan Darawsheh [mailto:rasland@mellanox.com]
> Sent: Sunday, October 7, 2018 8:38 AM
> To: Wu, Jingjing <jingjing.wu@intel.com>
> Cc: Thomas Monjalon <thomas@monjalon.net>; dev@dpdk.org; Shahaf Shuler
> <shahafs@mellanox.com>; Raslan Darawsheh <rasland@mellanox.com>;
> Xueming(Steven) Li <xuemingl@mellanox.com>; Ori Kam
> <orika@mellanox.com>; jerin.jacob@caviumnetworks.com;
> david.marchand@6wind.com; Iremonger, Bernard
> <bernard.iremonger@intel.com>
> Subject: [PATCH v4 1/3] app/testpmd: move dumping packets to a separate
> function
> 
> verbosity for the received/sent packets is needed in all of the forwarding
> engines so moving it to be in a separate function
> 
> ---
> changes in v3:
> 	- add util.c in the mason.build file
> 	- restore missing check for ol_flags & PKT_RX_RSS_HASH.
> 	- add local variables for rte_be_to_cpu to avoid long
> 	  lines.
> 
> changes in v4:
> 	- add missing l3 and l4 checks
> ---
> 
> Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>

Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH v4 2/3] app/testpmd: add packet dump callback functions
  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
  1 sibling, 0 replies; 47+ messages in thread
From: Iremonger, Bernard @ 2018-10-08 10:03 UTC (permalink / raw)
  To: Raslan Darawsheh, Wu, Jingjing
  Cc: Thomas Monjalon, dev, Shahaf Shuler, Xueming(Steven) Li, Ori Kam,
	jerin.jacob, david.marchand

> -----Original Message-----
> From: Raslan Darawsheh [mailto:rasland@mellanox.com]
> Sent: Sunday, October 7, 2018 8:38 AM
> To: Wu, Jingjing <jingjing.wu@intel.com>
> Cc: Thomas Monjalon <thomas@monjalon.net>; dev@dpdk.org; Shahaf Shuler
> <shahafs@mellanox.com>; Raslan Darawsheh <rasland@mellanox.com>;
> Xueming(Steven) Li <xuemingl@mellanox.com>; Ori Kam
> <orika@mellanox.com>; jerin.jacob@caviumnetworks.com;
> david.marchand@6wind.com; Iremonger, Bernard
> <bernard.iremonger@intel.com>
> Subject: [PATCH v4 2/3] app/testpmd: add packet dump callback functions
> 
> 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>

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH v4 3/3] app/testpmd: set packet dump based on verbosity level
  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
  1 sibling, 0 replies; 47+ messages in thread
From: Iremonger, Bernard @ 2018-10-08 10:04 UTC (permalink / raw)
  To: Raslan Darawsheh, Wu, Jingjing
  Cc: Thomas Monjalon, dev, Shahaf Shuler, Xueming(Steven) Li, Ori Kam,
	jerin.jacob, david.marchand

> -----Original Message-----
> From: Raslan Darawsheh [mailto:rasland@mellanox.com]
> Sent: Sunday, October 7, 2018 8:38 AM
> To: Wu, Jingjing <jingjing.wu@intel.com>
> Cc: Thomas Monjalon <thomas@monjalon.net>; dev@dpdk.org; Shahaf Shuler
> <shahafs@mellanox.com>; Raslan Darawsheh <rasland@mellanox.com>;
> Xueming(Steven) Li <xuemingl@mellanox.com>; Ori Kam
> <orika@mellanox.com>; jerin.jacob@caviumnetworks.com;
> david.marchand@6wind.com; Iremonger, Bernard
> <bernard.iremonger@intel.com>
> Subject: [PATCH v4 3/3] app/testpmd: set packet dump based on verbosity level
> 
> when changing verbosity level it will configure rx/tx callbacks to dump packets
> based on the verbosity value as following:
>     1- dump only received packets:
>        testpmd> set verbose 1
>     2- dump only sent packets:
>        testpmd> set verbose 2
>     3- dump sent and received packets:
>        testpmd> set verbose (any number > 2)
>     4- disable dump
>        testpmd> set verbose 0
> 
> Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>

Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH v4 1/3] app/testpmd: move dumping packets to a separate function
  2018-10-07  7:38     ` [dpdk-dev] [PATCH v4 " Raslan Darawsheh
                         ` (2 preceding siblings ...)
  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-17  7:27       ` [dpdk-dev] [PATCH v5 " Raslan Darawsheh
  2018-10-17 15:22       ` [dpdk-dev] [PATCH v6 " Raslan Darawsheh
  5 siblings, 1 reply; 47+ messages in thread
From: Ferruh Yigit @ 2018-10-11 14:56 UTC (permalink / raw)
  To: Raslan Darawsheh, jingjing.wu
  Cc: Thomas Monjalon, dev, Shahaf Shuler, Xueming(Steven) Li, Ori Kam,
	jerin.jacob, david.marchand, bernard.iremonger

On 10/7/2018 8:38 AM, Raslan Darawsheh wrote:
> verbosity for the received/sent packets is needed in all of the
> forwarding engines so moving it to be in a separate function

+1, this is good idea.

> ---
> changes in v3:
> 	- add util.c in the mason.build file
> 	- restore missing check for ol_flags & PKT_RX_RSS_HASH.
> 	- add local variables for rte_be_to_cpu to avoid long
> 	  lines.
> 
> changes in v4:
> 	- add missing l3 and l4 checks
> ---
> 
> Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>

<...>

> @@ -0,0 +1,150 @@
> +/* SPDX-License-Identifie.r: BSD-3-Clause
> + * Copyri.ght(c) 2010-2018 Mellanox technology.

It can be good to keep original Copyright owner when moving some code from one
file another.

<...>

> +		sw_packet_type = rte_net_get_ptype(mb, &hdr_lens,
> +						   RTE_PTYPE_ALL_MASK);

DPDK coding convention requires a single tab in next line, instead of alligning
to the parenthesis.

<...>

> +			/* Do not support ipv4 option field */
> +			if (RTE_ETH_IS_IPV4_HDR(packet_type)) {
> +				l3_len = sizeof(struct ipv4_hdr);
> +				ipv4_hdr = rte_pktmbuf_mtod_offset(mb,
> +				struct ipv4_hdr *,
> +				l2_len);
> +				l4_proto = ipv4_hdr->next_proto_id;

The syntax broken here.

<...>

> +		}
> +		printf(" - %s queue=0x%x", is_rx ? "Receive" : "Send",
> +			(unsigned int) queue);

Isn't this same information with initial header line, does this add any
extra/new information?

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH v4 2/3] app/testpmd: add packet dump callback functions
  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
  1 sibling, 1 reply; 47+ messages in thread
From: Ferruh Yigit @ 2018-10-11 14:58 UTC (permalink / raw)
  To: Raslan Darawsheh, jingjing.wu
  Cc: Thomas Monjalon, dev, Shahaf Shuler, Xueming(Steven) Li, Ori Kam,
	jerin.jacob, david.marchand, bernard.iremonger

On 10/7/2018 8:38 AM, Raslan Darawsheh wrote:
> add new rx/tx callback functions to be used for dumping the packets.
> 
> Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>

<...>

> +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);

You can add an enum or define to clarify what last param 0/1 is.

> +	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;
> +}
> 

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH v4 3/3] app/testpmd: set packet dump based on verbosity level
  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
  1 sibling, 1 reply; 47+ messages in thread
From: Ferruh Yigit @ 2018-10-11 15:00 UTC (permalink / raw)
  To: Raslan Darawsheh, jingjing.wu
  Cc: Thomas Monjalon, dev, Shahaf Shuler, Xueming(Steven) Li, Ori Kam,
	jerin.jacob, david.marchand, bernard.iremonger

On 10/7/2018 8:38 AM, Raslan Darawsheh wrote:
> when changing verbosity level it will configure rx/tx callbacks to dump
> packets based on the verbosity value as following:
>     1- dump only received packets:
>        testpmd> set verbose 1
>     2- dump only sent packets:
>        testpmd> set verbose 2
>     3- dump sent and received packets:
>        testpmd> set verbose (any number > 2)
>     4- disable dump
>        testpmd> set verbose 0

It is good to able to enable Rx/Tx separately but you are overloading "verbose"
meaning here. "verbose" is kind of log_level internal to testpmd and can be used
by many testpmd debug log.

Why not create a separate setting for it, perhaps like pkt_verbose?

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH v4 3/3] app/testpmd: set packet dump based on verbosity level
  2018-10-11 15:00         ` Ferruh Yigit
@ 2018-10-11 15:24           ` Iremonger, Bernard
  2018-10-11 15:52             ` Ferruh Yigit
  0 siblings, 1 reply; 47+ messages in thread
From: Iremonger, Bernard @ 2018-10-11 15:24 UTC (permalink / raw)
  To: Yigit, Ferruh, Raslan Darawsheh, Wu, Jingjing
  Cc: Thomas Monjalon, dev, Shahaf Shuler, Xueming(Steven) Li, Ori Kam,
	jerin.jacob, david.marchand

Hi Feruh,

> -----Original Message-----
> From: Yigit, Ferruh
> Sent: Thursday, October 11, 2018 4:00 PM
> To: Raslan Darawsheh <rasland@mellanox.com>; Wu, Jingjing
> <jingjing.wu@intel.com>
> Cc: Thomas Monjalon <thomas@monjalon.net>; dev@dpdk.org; Shahaf Shuler
> <shahafs@mellanox.com>; Xueming(Steven) Li <xuemingl@mellanox.com>; Ori
> Kam <orika@mellanox.com>; jerin.jacob@caviumnetworks.com;
> david.marchand@6wind.com; Iremonger, Bernard
> <bernard.iremonger@intel.com>
> Subject: Re: [dpdk-dev] [PATCH v4 3/3] app/testpmd: set packet dump based on
> verbosity level
> 
> On 10/7/2018 8:38 AM, Raslan Darawsheh wrote:
> > when changing verbosity level it will configure rx/tx callbacks to
> > dump packets based on the verbosity value as following:
> >     1- dump only received packets:
> >        testpmd> set verbose 1
> >     2- dump only sent packets:
> >        testpmd> set verbose 2
> >     3- dump sent and received packets:
> >        testpmd> set verbose (any number > 2)
> >     4- disable dump
> >        testpmd> set verbose 0
> 
> It is good to able to enable Rx/Tx separately but you are overloading "verbose"
> meaning here. "verbose" is kind of log_level internal to testpmd and can be used
> by many testpmd debug log.
> 
> Why not create a separate setting for it, perhaps like pkt_verbose?

The original code in rxonly.c used the verbose level, I don't think it is good idea to add a new pkt_verbose.
Users will be expecting it to work as before.

Regards,

Bernard.


^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH v4 3/3] app/testpmd: set packet dump based on verbosity level
  2018-10-11 15:24           ` Iremonger, Bernard
@ 2018-10-11 15:52             ` Ferruh Yigit
  2018-10-11 16:39               ` Iremonger, Bernard
  0 siblings, 1 reply; 47+ messages in thread
From: Ferruh Yigit @ 2018-10-11 15:52 UTC (permalink / raw)
  To: Iremonger, Bernard, Raslan Darawsheh, Wu, Jingjing
  Cc: Thomas Monjalon, dev, Shahaf Shuler, Xueming(Steven) Li, Ori Kam,
	jerin.jacob, david.marchand

On 10/11/2018 4:24 PM, Iremonger, Bernard wrote:
> Hi Feruh,
> 
>> -----Original Message-----
>> From: Yigit, Ferruh
>> Sent: Thursday, October 11, 2018 4:00 PM
>> To: Raslan Darawsheh <rasland@mellanox.com>; Wu, Jingjing
>> <jingjing.wu@intel.com>
>> Cc: Thomas Monjalon <thomas@monjalon.net>; dev@dpdk.org; Shahaf Shuler
>> <shahafs@mellanox.com>; Xueming(Steven) Li <xuemingl@mellanox.com>; Ori
>> Kam <orika@mellanox.com>; jerin.jacob@caviumnetworks.com;
>> david.marchand@6wind.com; Iremonger, Bernard
>> <bernard.iremonger@intel.com>
>> Subject: Re: [dpdk-dev] [PATCH v4 3/3] app/testpmd: set packet dump based on
>> verbosity level
>>
>> On 10/7/2018 8:38 AM, Raslan Darawsheh wrote:
>>> when changing verbosity level it will configure rx/tx callbacks to
>>> dump packets based on the verbosity value as following:
>>>     1- dump only received packets:
>>>        testpmd> set verbose 1
>>>     2- dump only sent packets:
>>>        testpmd> set verbose 2
>>>     3- dump sent and received packets:
>>>        testpmd> set verbose (any number > 2)
>>>     4- disable dump
>>>        testpmd> set verbose 0
>>
>> It is good to able to enable Rx/Tx separately but you are overloading "verbose"
>> meaning here. "verbose" is kind of log_level internal to testpmd and can be used
>> by many testpmd debug log.
>>
>> Why not create a separate setting for it, perhaps like pkt_verbose?
> 
> The original code in rxonly.c used the verbose level, I don't think it is good idea to add a new pkt_verbose.
> Users will be expecting it to work as before.

In same logic they won't expect verbose=1 only for Rx and verbose=2 only for Tx,
previously this was on/off setting.

since we are touching here already clarifying this with its own config item
makes more sense to me.
And user may not be wanting to have testpmd verbose level 3 and related logs but
only Rx/Tx packets.

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH v4 3/3] app/testpmd: set packet dump based on verbosity level
  2018-10-11 15:52             ` Ferruh Yigit
@ 2018-10-11 16:39               ` Iremonger, Bernard
  2018-10-17 12:34                 ` Ferruh Yigit
  0 siblings, 1 reply; 47+ messages in thread
From: Iremonger, Bernard @ 2018-10-11 16:39 UTC (permalink / raw)
  To: Yigit, Ferruh, Raslan Darawsheh, Wu, Jingjing
  Cc: Thomas Monjalon, dev, Shahaf Shuler, Xueming(Steven) Li, Ori Kam,
	jerin.jacob, david.marchand

Hi Ferruh

<snip>
> >> Subject: Re: [dpdk-dev] [PATCH v4 3/3] app/testpmd: set packet dump
> >> based on verbosity level
> >>
> >> On 10/7/2018 8:38 AM, Raslan Darawsheh wrote:
> >>> when changing verbosity level it will configure rx/tx callbacks to
> >>> dump packets based on the verbosity value as following:
> >>>     1- dump only received packets:
> >>>        testpmd> set verbose 1
> >>>     2- dump only sent packets:
> >>>        testpmd> set verbose 2
> >>>     3- dump sent and received packets:
> >>>        testpmd> set verbose (any number > 2)
> >>>     4- disable dump
> >>>        testpmd> set verbose 0
> >>
> >> It is good to able to enable Rx/Tx separately but you are overloading
> "verbose"
> >> meaning here. "verbose" is kind of log_level internal to testpmd and
> >> can be used by many testpmd debug log.
> >>
> >> Why not create a separate setting for it, perhaps like pkt_verbose?
> >
> > The original code in rxonly.c used the verbose level, I don't think it is good idea
> to add a new pkt_verbose.
> > Users will be expecting it to work as before.
> 
> In same logic they won't expect verbose=1 only for Rx and verbose=2 only for
> Tx, previously this was on/off setting.
> 
> since we are touching here already clarifying this with its own config item makes
> more sense to me.
> And user may not be wanting to have testpmd verbose level 3 and related logs
> but only Rx/Tx packets.

Previously: 
Set verbose 1, dumped rx packets.
Set verbose 0, disabled dump of rx packets.

Now:
Set verbose 2, dumps tx packets (new functionality, not dumped previously)
Set verbose 3, dumps tx and rx packets (new functionality)

I am ok with this.
I think more opinions are needed.

Regards,

Bernard.



^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH v4 1/3] app/testpmd: move dumping packets to a separate function
  2018-10-11 14:56       ` Ferruh Yigit
@ 2018-10-16 10:10         ` Raslan Darawsheh
  2018-10-16 13:11           ` Ferruh Yigit
  0 siblings, 1 reply; 47+ messages in thread
From: Raslan Darawsheh @ 2018-10-16 10:10 UTC (permalink / raw)
  To: Ferruh Yigit, jingjing.wu
  Cc: Thomas Monjalon, dev, Shahaf Shuler, Xueming(Steven) Li, Ori Kam,
	jerin.jacob, david.marchand, bernard.iremonger

Hi Ferruh,

PSB.

Kindest regards,
Raslan Darawsheh

> -----Original Message-----
> From: Ferruh Yigit <ferruh.yigit@intel.com>
> Sent: Thursday, October 11, 2018 5:56 PM
> To: Raslan Darawsheh <rasland@mellanox.com>; jingjing.wu@intel.com
> Cc: Thomas Monjalon <thomas@monjalon.net>; dev@dpdk.org; Shahaf
> Shuler <shahafs@mellanox.com>; Xueming(Steven) Li
> <xuemingl@mellanox.com>; Ori Kam <orika@mellanox.com>;
> jerin.jacob@caviumnetworks.com; david.marchand@6wind.com;
> bernard.iremonger@intel.com
> Subject: Re: [dpdk-dev] [PATCH v4 1/3] app/testpmd: move dumping
> packets to a separate function
> 
> On 10/7/2018 8:38 AM, Raslan Darawsheh wrote:
> > verbosity for the received/sent packets is needed in all of the
> > forwarding engines so moving it to be in a separate function
> 
> +1, this is good idea.
> 
> > ---
> > changes in v3:
> > 	- add util.c in the mason.build file
> > 	- restore missing check for ol_flags & PKT_RX_RSS_HASH.
> > 	- add local variables for rte_be_to_cpu to avoid long
> > 	  lines.
> >
> > changes in v4:
> > 	- add missing l3 and l4 checks
> > ---
> >
> > Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
> 
> <...>
> 
> > @@ -0,0 +1,150 @@
> > +/* SPDX-License-Identifie.r: BSD-3-Clause
> > + * Copyri.ght(c) 2010-2018 Mellanox technology.
> 
> It can be good to keep original Copyright owner when moving some code
> from one file another.
I added a new copy right since it contains some new functionality as well not only the original one.
> 
> <...>
> 
> > +		sw_packet_type = rte_net_get_ptype(mb, &hdr_lens,
> > +						   RTE_PTYPE_ALL_MASK);
> 
> DPDK coding convention requires a single tab in next line, instead of alligning
> to the parenthesis.
Will send a new version with these fixed.
> 
> <...>
> 
> > +			/* Do not support ipv4 option field */
> > +			if (RTE_ETH_IS_IPV4_HDR(packet_type)) {
> > +				l3_len = sizeof(struct ipv4_hdr);
> > +				ipv4_hdr = rte_pktmbuf_mtod_offset(mb,
> > +				struct ipv4_hdr *,
> > +				l2_len);
> > +				l4_proto = ipv4_hdr->next_proto_id;
> 
> The syntax broken here.
This is the same as present in rxonly file nothing changed
> 
> <...>
> 
> > +		}
> > +		printf(" - %s queue=0x%x", is_rx ? "Receive" : "Send",
> > +			(unsigned int) queue);
> 
> Isn't this same information with initial header line, does this add any
> extra/new information?

This is as of per packet, since you can get more than one packet printed when you have RSS the first one will be a print for the entire burst,
and then you'll get this print for each packet printed.

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH v4 2/3] app/testpmd: add packet dump callback functions
  2018-10-11 14:58         ` Ferruh Yigit
@ 2018-10-16 10:11           ` Raslan Darawsheh
  0 siblings, 0 replies; 47+ messages in thread
From: Raslan Darawsheh @ 2018-10-16 10:11 UTC (permalink / raw)
  To: Ferruh Yigit, jingjing.wu
  Cc: Thomas Monjalon, dev, Shahaf Shuler, Xueming(Steven) Li, Ori Kam,
	jerin.jacob, david.marchand, bernard.iremonger

Hi Ferruh,

This is a good point I'll fix it and send a new version for it. 

Kindest regards,
Raslan Darawsheh

> -----Original Message-----
> From: Ferruh Yigit <ferruh.yigit@intel.com>
> Sent: Thursday, October 11, 2018 5:58 PM
> To: Raslan Darawsheh <rasland@mellanox.com>; jingjing.wu@intel.com
> Cc: Thomas Monjalon <thomas@monjalon.net>; dev@dpdk.org; Shahaf
> Shuler <shahafs@mellanox.com>; Xueming(Steven) Li
> <xuemingl@mellanox.com>; Ori Kam <orika@mellanox.com>;
> jerin.jacob@caviumnetworks.com; david.marchand@6wind.com;
> bernard.iremonger@intel.com
> Subject: Re: [dpdk-dev] [PATCH v4 2/3] app/testpmd: add packet dump
> callback functions
> 
> On 10/7/2018 8:38 AM, Raslan Darawsheh wrote:
> > add new rx/tx callback functions to be used for dumping the packets.
> >
> > Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
> 
> <...>
> 
> > +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);
> 
> You can add an enum or define to clarify what last param 0/1 is.
> 
> > +	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;
> > +}
> >


^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH v4 1/3] app/testpmd: move dumping packets to a separate function
  2018-10-16 10:10         ` Raslan Darawsheh
@ 2018-10-16 13:11           ` Ferruh Yigit
  0 siblings, 0 replies; 47+ messages in thread
From: Ferruh Yigit @ 2018-10-16 13:11 UTC (permalink / raw)
  To: Raslan Darawsheh, jingjing.wu
  Cc: Thomas Monjalon, dev, Shahaf Shuler, Xueming(Steven) Li, Ori Kam,
	jerin.jacob, david.marchand, bernard.iremonger

On 10/16/2018 11:10 AM, Raslan Darawsheh wrote:
> Hi Ferruh,
> 
> PSB.
> 
> Kindest regards,
> Raslan Darawsheh
> 
>> -----Original Message-----
>> From: Ferruh Yigit <ferruh.yigit@intel.com>
>> Sent: Thursday, October 11, 2018 5:56 PM
>> To: Raslan Darawsheh <rasland@mellanox.com>; jingjing.wu@intel.com
>> Cc: Thomas Monjalon <thomas@monjalon.net>; dev@dpdk.org; Shahaf
>> Shuler <shahafs@mellanox.com>; Xueming(Steven) Li
>> <xuemingl@mellanox.com>; Ori Kam <orika@mellanox.com>;
>> jerin.jacob@caviumnetworks.com; david.marchand@6wind.com;
>> bernard.iremonger@intel.com
>> Subject: Re: [dpdk-dev] [PATCH v4 1/3] app/testpmd: move dumping
>> packets to a separate function
>>
>> On 10/7/2018 8:38 AM, Raslan Darawsheh wrote:
>>> verbosity for the received/sent packets is needed in all of the
>>> forwarding engines so moving it to be in a separate function
>>
>> +1, this is good idea.
>>
>>> ---
>>> changes in v3:
>>> 	- add util.c in the mason.build file
>>> 	- restore missing check for ol_flags & PKT_RX_RSS_HASH.
>>> 	- add local variables for rte_be_to_cpu to avoid long
>>> 	  lines.
>>>
>>> changes in v4:
>>> 	- add missing l3 and l4 checks
>>> ---
>>>
>>> Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
>>
>> <...>
>>
>>> @@ -0,0 +1,150 @@
>>> +/* SPDX-License-Identifie.r: BSD-3-Clause
>>> + * Copyri.ght(c) 2010-2018 Mellanox technology.
>>
>> It can be good to keep original Copyright owner when moving some code
>> from one file another.
> I added a new copy right since it contains some new functionality as well not only the original one.

What is the new functionality added to "dump_pkt_burst()" ? Overall there is a
new feature but not into this file.
I think better to keep the original copyright when you are copying something
from one file to another and append your copyright when added a significant
contribution to that file.

>>
>> <...>
>>
>>> +		sw_packet_type = rte_net_get_ptype(mb, &hdr_lens,
>>> +						   RTE_PTYPE_ALL_MASK);
>>
>> DPDK coding convention requires a single tab in next line, instead of alligning
>> to the parenthesis.
> Will send a new version with these fixed.
>>
>> <...>
>>
>>> +			/* Do not support ipv4 option field */
>>> +			if (RTE_ETH_IS_IPV4_HDR(packet_type)) {
>>> +				l3_len = sizeof(struct ipv4_hdr);
>>> +				ipv4_hdr = rte_pktmbuf_mtod_offset(mb,
>>> +				struct ipv4_hdr *,
>>> +				l2_len);
>>> +				l4_proto = ipv4_hdr->next_proto_id;
>>
>> The syntax broken here.
> This is the same as present in rxonly file nothing changed
>>
>> <...>
>>
>>> +		}
>>> +		printf(" - %s queue=0x%x", is_rx ? "Receive" : "Send",
>>> +			(unsigned int) queue);
>>
>> Isn't this same information with initial header line, does this add any
>> extra/new information?
> 
> This is as of per packet, since you can get more than one packet printed when you have RSS the first one will be a print for the entire burst,
> and then you'll get this print for each packet printed.
> 

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH v5 1/3] app/testpmd: move dumping packets to a separate function
  2018-10-07  7:38     ` [dpdk-dev] [PATCH v4 " Raslan Darawsheh
                         ` (3 preceding siblings ...)
  2018-10-11 14:56       ` Ferruh Yigit
@ 2018-10-17  7:27       ` Raslan Darawsheh
  2018-10-17  7:27         ` [dpdk-dev] [PATCH v5 2/3] app/testpmd: add packet dump callback functions Raslan Darawsheh
                           ` (2 more replies)
  2018-10-17 15:22       ` [dpdk-dev] [PATCH v6 " Raslan Darawsheh
  5 siblings, 3 replies; 47+ messages in thread
From: Raslan Darawsheh @ 2018-10-17  7:27 UTC (permalink / raw)
  To: jingjing.wu
  Cc: thomas, dev, shahafs, rasland, xuemingl, orika, jerin.jacob,
	david.marchand, bernard.iremonger, ferruh.yigit

verbosity for the received/sent packets is needed in all of the
forwarding engines so moving it to be in a separate function

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

---
changes in v5:
	fix alligning convention
	fix copyright
---
---
 app/test-pmd/Makefile    |   1 +
 app/test-pmd/meson.build |   3 +-
 app/test-pmd/rxonly.c    | 134 +----------------------------------------
 app/test-pmd/util.c      | 151 +++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 157 insertions(+), 132 deletions(-)
 create mode 100644 app/test-pmd/util.c

diff --git a/app/test-pmd/Makefile b/app/test-pmd/Makefile
index e2581ca..8e4ff5b 100644
--- a/app/test-pmd/Makefile
+++ b/app/test-pmd/Makefile
@@ -36,6 +36,7 @@ SRCS-y += icmpecho.c
 SRCS-y += noisy_vnf.c
 SRCS-$(CONFIG_RTE_LIBRTE_IEEE1588) += ieee1588fwd.c
 SRCS-$(CONFIG_RTE_LIBRTE_BPF) += bpf_cmd.c
+SRCS-y += util.c
 
 ifeq ($(CONFIG_RTE_LIBRTE_PMD_SOFTNIC), y)
 SRCS-y += softnicfwd.c
diff --git a/app/test-pmd/meson.build b/app/test-pmd/meson.build
index 9ef6ed9..cd66618 100644
--- a/app/test-pmd/meson.build
+++ b/app/test-pmd/meson.build
@@ -21,7 +21,8 @@ sources = files('cmdline.c',
 	'parameters.c',
 	'rxonly.c',
 	'testpmd.c',
-	'txonly.c')
+	'txonly.c',
+	'util.c')
 
 deps = ['ethdev', 'gro', 'gso', 'cmdline', 'metrics', 'meter', 'bus_pci']
 if dpdk_conf.has('RTE_LIBRTE_PDUMP')
diff --git a/app/test-pmd/rxonly.c b/app/test-pmd/rxonly.c
index 41db0ff..3eca89c 100644
--- a/app/test-pmd/rxonly.c
+++ b/app/test-pmd/rxonly.c
@@ -40,14 +40,6 @@
 
 #include "testpmd.h"
 
-static inline void
-print_ether_addr(const char *what, struct ether_addr *eth_addr)
-{
-	char buf[ETHER_ADDR_FMT_SIZE];
-	ether_format_addr(buf, ETHER_ADDR_FMT_SIZE, eth_addr);
-	printf("%s%s", what, buf);
-}
-
 /*
  * Received a burst of packets.
  */
@@ -55,16 +47,8 @@ static void
 pkt_burst_receive(struct fwd_stream *fs)
 {
 	struct rte_mbuf  *pkts_burst[MAX_PKT_BURST];
-	struct rte_mbuf  *mb;
-	struct ether_hdr *eth_hdr;
-	uint16_t eth_type;
-	uint64_t ol_flags;
 	uint16_t nb_rx;
-	uint16_t i, packet_type;
-	uint16_t is_encapsulation;
-	char buf[256];
-	struct rte_net_hdr_lens hdr_lens;
-	uint32_t sw_packet_type;
+	uint16_t i;
 
 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
 	uint64_t start_tsc;
@@ -90,120 +74,8 @@ pkt_burst_receive(struct fwd_stream *fs)
 	/*
 	 * Dump each received packet if verbose_level > 0.
 	 */
-	if (verbose_level > 0)
-		printf("port %u/queue %u: received %u packets\n",
-		       fs->rx_port,
-		       (unsigned) fs->rx_queue,
-		       (unsigned) nb_rx);
-	for (i = 0; i < nb_rx; i++) {
-		mb = pkts_burst[i];
-		if (verbose_level == 0) {
-			rte_pktmbuf_free(mb);
-			continue;
-		}
-		eth_hdr = rte_pktmbuf_mtod(mb, struct ether_hdr *);
-		eth_type = RTE_BE_TO_CPU_16(eth_hdr->ether_type);
-		ol_flags = mb->ol_flags;
-		packet_type = mb->packet_type;
-		is_encapsulation = RTE_ETH_IS_TUNNEL_PKT(packet_type);
-
-		print_ether_addr("  src=", &eth_hdr->s_addr);
-		print_ether_addr(" - dst=", &eth_hdr->d_addr);
-		printf(" - type=0x%04x - length=%u - nb_segs=%d",
-		       eth_type, (unsigned) mb->pkt_len,
-		       (int)mb->nb_segs);
-		if (ol_flags & PKT_RX_RSS_HASH) {
-			printf(" - RSS hash=0x%x", (unsigned) mb->hash.rss);
-			printf(" - RSS queue=0x%x",(unsigned) fs->rx_queue);
-		}
-		if (ol_flags & PKT_RX_FDIR) {
-			printf(" - FDIR matched ");
-			if (ol_flags & PKT_RX_FDIR_ID)
-				printf("ID=0x%x",
-				       mb->hash.fdir.hi);
-			else if (ol_flags & PKT_RX_FDIR_FLX)
-				printf("flex bytes=0x%08x %08x",
-				       mb->hash.fdir.hi, mb->hash.fdir.lo);
-			else
-				printf("hash=0x%x ID=0x%x ",
-				       mb->hash.fdir.hash, mb->hash.fdir.id);
-		}
-		if (ol_flags & PKT_RX_TIMESTAMP)
-			printf(" - timestamp %"PRIu64" ", mb->timestamp);
-		if (ol_flags & PKT_RX_QINQ)
-			printf(" - QinQ VLAN tci=0x%x, VLAN tci outer=0x%x",
-					mb->vlan_tci, mb->vlan_tci_outer);
-		else if (ol_flags & PKT_RX_VLAN)
-			printf(" - VLAN tci=0x%x", mb->vlan_tci);
-		if (mb->packet_type) {
-			rte_get_ptype_name(mb->packet_type, buf, sizeof(buf));
-			printf(" - hw ptype: %s", buf);
-		}
-		sw_packet_type = rte_net_get_ptype(mb, &hdr_lens,
-			RTE_PTYPE_ALL_MASK);
-		rte_get_ptype_name(sw_packet_type, buf, sizeof(buf));
-		printf(" - sw ptype: %s", buf);
-		if (sw_packet_type & RTE_PTYPE_L2_MASK)
-			printf(" - l2_len=%d", hdr_lens.l2_len);
-		if (sw_packet_type & RTE_PTYPE_L3_MASK)
-			printf(" - l3_len=%d", hdr_lens.l3_len);
-		if (sw_packet_type & RTE_PTYPE_L4_MASK)
-			printf(" - l4_len=%d", hdr_lens.l4_len);
-		if (sw_packet_type & RTE_PTYPE_TUNNEL_MASK)
-			printf(" - tunnel_len=%d", hdr_lens.tunnel_len);
-		if (sw_packet_type & RTE_PTYPE_INNER_L2_MASK)
-			printf(" - inner_l2_len=%d", hdr_lens.inner_l2_len);
-		if (sw_packet_type & RTE_PTYPE_INNER_L3_MASK)
-			printf(" - inner_l3_len=%d", hdr_lens.inner_l3_len);
-		if (sw_packet_type & RTE_PTYPE_INNER_L4_MASK)
-			printf(" - inner_l4_len=%d", hdr_lens.inner_l4_len);
-		if (is_encapsulation) {
-			struct ipv4_hdr *ipv4_hdr;
-			struct ipv6_hdr *ipv6_hdr;
-			struct udp_hdr *udp_hdr;
-			uint8_t l2_len;
-			uint8_t l3_len;
-			uint8_t l4_len;
-			uint8_t l4_proto;
-			struct  vxlan_hdr *vxlan_hdr;
-
-			l2_len  = sizeof(struct ether_hdr);
-
-			 /* Do not support ipv4 option field */
-			if (RTE_ETH_IS_IPV4_HDR(packet_type)) {
-				l3_len = sizeof(struct ipv4_hdr);
-				ipv4_hdr = rte_pktmbuf_mtod_offset(mb,
-								   struct ipv4_hdr *,
-								   l2_len);
-				l4_proto = ipv4_hdr->next_proto_id;
-			} else {
-				l3_len = sizeof(struct ipv6_hdr);
-				ipv6_hdr = rte_pktmbuf_mtod_offset(mb,
-								   struct ipv6_hdr *,
-								   l2_len);
-				l4_proto = ipv6_hdr->proto;
-			}
-			if (l4_proto == IPPROTO_UDP) {
-				udp_hdr = rte_pktmbuf_mtod_offset(mb,
-								  struct udp_hdr *,
-								  l2_len + l3_len);
-				l4_len = sizeof(struct udp_hdr);
-				vxlan_hdr = rte_pktmbuf_mtod_offset(mb,
-								    struct vxlan_hdr *,
-								    l2_len + l3_len + l4_len);
-
-				printf(" - VXLAN packet: packet type =%d, "
-					"Destination UDP port =%d, VNI = %d",
-					packet_type, RTE_BE_TO_CPU_16(udp_hdr->dst_port),
-					rte_be_to_cpu_32(vxlan_hdr->vx_vni) >> 8);
-			}
-		}
-		printf(" - Receive queue=0x%x", (unsigned) fs->rx_queue);
-		printf("\n");
-		rte_get_rx_ol_flag_list(mb->ol_flags, buf, sizeof(buf));
-		printf("  ol_flags: %s\n", buf);
-		rte_pktmbuf_free(mb);
-	}
+	for (i = 0; i < nb_rx; i++)
+		rte_pktmbuf_free(pkts_burst[i]);
 
 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
 	end_tsc = rte_rdtsc();
diff --git a/app/test-pmd/util.c b/app/test-pmd/util.c
new file mode 100644
index 0000000..4fcb2f9
--- /dev/null
+++ b/app/test-pmd/util.c
@@ -0,0 +1,151 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation
+ * Copyright(c) 2018 Mellanox Technology
+ */
+
+#include <stdio.h>
+
+#include <rte_net.h>
+#include <rte_mbuf.h>
+#include <rte_ether.h>
+#include <rte_ethdev.h>
+#include <rte_flow.h>
+
+#include "testpmd.h"
+
+static inline void
+print_ether_addr(const char *what, struct ether_addr *eth_addr)
+{
+	char buf[ETHER_ADDR_FMT_SIZE];
+	ether_format_addr(buf, ETHER_ADDR_FMT_SIZE, eth_addr);
+	printf("%s%s", what, buf);
+}
+
+static  inline void
+dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],
+	      uint16_t nb_pkts, int is_rx)
+{
+	struct rte_mbuf  *mb;
+	struct ether_hdr *eth_hdr;
+	uint16_t eth_type;
+	uint64_t ol_flags;
+	uint16_t i, packet_type;
+	uint16_t is_encapsulation;
+	char buf[256];
+	struct rte_net_hdr_lens hdr_lens;
+	uint32_t sw_packet_type;
+	uint16_t udp_port;
+	uint32_t vx_vni;
+
+	if (!nb_pkts)
+		return;
+	printf("port %u/queue %u: %s %u packets\n",
+		port_id, queue,
+	       is_rx ? "received" : "sent",
+	       (unsigned int) nb_pkts);
+	for (i = 0; i < nb_pkts; i++) {
+		mb = pkts[i];
+		eth_hdr = rte_pktmbuf_mtod(mb, struct ether_hdr *);
+		eth_type = RTE_BE_TO_CPU_16(eth_hdr->ether_type);
+		ol_flags = mb->ol_flags;
+		packet_type = mb->packet_type;
+		is_encapsulation = RTE_ETH_IS_TUNNEL_PKT(packet_type);
+
+		print_ether_addr("  src=", &eth_hdr->s_addr);
+		print_ether_addr(" - dst=", &eth_hdr->d_addr);
+		printf(" - type=0x%04x - length=%u - nb_segs=%d",
+		       eth_type, (unsigned int) mb->pkt_len,
+		       (int)mb->nb_segs);
+		if (ol_flags & PKT_RX_RSS_HASH) {
+			printf(" - RSS hash=0x%x", (unsigned int) mb->hash.rss);
+			printf(" - RSS queue=0x%x", (unsigned int) queue);
+		}
+		if (ol_flags & PKT_RX_FDIR) {
+			printf(" - FDIR matched ");
+			if (ol_flags & PKT_RX_FDIR_ID)
+				printf("ID=0x%x",
+				       mb->hash.fdir.hi);
+			else if (ol_flags & PKT_RX_FDIR_FLX)
+				printf("flex bytes=0x%08x %08x",
+				       mb->hash.fdir.hi, mb->hash.fdir.lo);
+			else
+				printf("hash=0x%x ID=0x%x ",
+				       mb->hash.fdir.hash, mb->hash.fdir.id);
+		}
+		if (ol_flags & PKT_RX_TIMESTAMP)
+			printf(" - timestamp %"PRIu64" ", mb->timestamp);
+		if (ol_flags & PKT_RX_QINQ)
+			printf(" - QinQ VLAN tci=0x%x, VLAN tci outer=0x%x",
+			       mb->vlan_tci, mb->vlan_tci_outer);
+		else if (ol_flags & PKT_RX_VLAN)
+			printf(" - VLAN tci=0x%x", mb->vlan_tci);
+		if (mb->packet_type) {
+			rte_get_ptype_name(mb->packet_type, buf, sizeof(buf));
+			printf(" - hw ptype: %s", buf);
+		}
+		sw_packet_type = rte_net_get_ptype(mb, &hdr_lens,
+					RTE_PTYPE_ALL_MASK);
+		rte_get_ptype_name(sw_packet_type, buf, sizeof(buf));
+		printf(" - sw ptype: %s", buf);
+		if (sw_packet_type & RTE_PTYPE_L2_MASK)
+			printf(" - l2_len=%d", hdr_lens.l2_len);
+		if (sw_packet_type & RTE_PTYPE_L3_MASK)
+			printf(" - l3_len=%d", hdr_lens.l3_len);
+		if (sw_packet_type & RTE_PTYPE_L4_MASK)
+			printf(" - l4_len=%d", hdr_lens.l4_len);
+		if (sw_packet_type & RTE_PTYPE_TUNNEL_MASK)
+			printf(" - tunnel_len=%d", hdr_lens.tunnel_len);
+		if (sw_packet_type & RTE_PTYPE_INNER_L2_MASK)
+			printf(" - inner_l2_len=%d", hdr_lens.inner_l2_len);
+		if (sw_packet_type & RTE_PTYPE_INNER_L3_MASK)
+			printf(" - inner_l3_len=%d", hdr_lens.inner_l3_len);
+		if (sw_packet_type & RTE_PTYPE_INNER_L4_MASK)
+			printf(" - inner_l4_len=%d", hdr_lens.inner_l4_len);
+		if (is_encapsulation) {
+			struct ipv4_hdr *ipv4_hdr;
+			struct ipv6_hdr *ipv6_hdr;
+			struct udp_hdr *udp_hdr;
+			uint8_t l2_len;
+			uint8_t l3_len;
+			uint8_t l4_len;
+			uint8_t l4_proto;
+			struct  vxlan_hdr *vxlan_hdr;
+
+			l2_len  = sizeof(struct ether_hdr);
+
+			/* Do not support ipv4 option field */
+			if (RTE_ETH_IS_IPV4_HDR(packet_type)) {
+				l3_len = sizeof(struct ipv4_hdr);
+				ipv4_hdr = rte_pktmbuf_mtod_offset(mb,
+				struct ipv4_hdr *,
+				l2_len);
+				l4_proto = ipv4_hdr->next_proto_id;
+			} else {
+				l3_len = sizeof(struct ipv6_hdr);
+				ipv6_hdr = rte_pktmbuf_mtod_offset(mb,
+				struct ipv6_hdr *,
+				l2_len);
+				l4_proto = ipv6_hdr->proto;
+			}
+			if (l4_proto == IPPROTO_UDP) {
+				udp_hdr = rte_pktmbuf_mtod_offset(mb,
+				struct udp_hdr *,
+				l2_len + l3_len);
+				l4_len = sizeof(struct udp_hdr);
+				vxlan_hdr = rte_pktmbuf_mtod_offset(mb,
+				struct vxlan_hdr *,
+				l2_len + l3_len + l4_len);
+				udp_port = RTE_BE_TO_CPU_16(udp_hdr->dst_port);
+				vx_vni = rte_be_to_cpu_32(vxlan_hdr->vx_vni);
+				printf(" - VXLAN packet: packet type =%d, "
+				       "Destination UDP port =%d, VNI = %d",
+				       packet_type, udp_port, vx_vni >> 8);
+			}
+		}
+		printf(" - %s queue=0x%x", is_rx ? "Receive" : "Send",
+			(unsigned int) queue);
+		printf("\n");
+		rte_get_rx_ol_flag_list(mb->ol_flags, buf, sizeof(buf));
+		printf("  ol_flags: %s\n", buf);
+	}
+}
-- 
2.7.4

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH v5 2/3] app/testpmd: add packet dump callback functions
  2018-10-17  7:27       ` [dpdk-dev] [PATCH v5 " Raslan Darawsheh
@ 2018-10-17  7:27         ` 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
  2 siblings, 0 replies; 47+ messages in thread
From: Raslan Darawsheh @ 2018-10-17  7:27 UTC (permalink / raw)
  To: jingjing.wu
  Cc: thomas, dev, shahafs, rasland, xuemingl, orika, jerin.jacob,
	david.marchand, bernard.iremonger, ferruh.yigit

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>
---
 app/test-pmd/config.c  | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++
 app/test-pmd/testpmd.h | 15 +++++++++++
 app/test-pmd/util.c    | 17 +++++++++++++
 3 files changed, 99 insertions(+)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index bf3cd0a..431fa2a 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/testpmd.h b/app/test-pmd/testpmd.h
index 121b756..0e923d7 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,6 +766,19 @@ int check_nb_rxq(queueid_t rxq);
 queueid_t get_allowed_max_nb_txq(portid_t *pid);
 int check_nb_txq(queueid_t txq);
 
+
+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
  * rte_be_to_cpu_16() function.
diff --git a/app/test-pmd/util.c b/app/test-pmd/util.c
index 4fcb2f9..27908c6 100644
--- a/app/test-pmd/util.c
+++ b/app/test-pmd/util.c
@@ -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

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH v5 3/3] app/testpmd: set packet dump based on verbosity level
  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         ` Raslan Darawsheh
  2018-10-17 12:27         ` [dpdk-dev] [PATCH v5 1/3] app/testpmd: move dumping packets to a separate function Ferruh Yigit
  2 siblings, 0 replies; 47+ messages in thread
From: Raslan Darawsheh @ 2018-10-17  7:27 UTC (permalink / raw)
  To: jingjing.wu
  Cc: thomas, dev, shahafs, rasland, xuemingl, orika, jerin.jacob,
	david.marchand, bernard.iremonger, ferruh.yigit

when changing verbosity level it will configure rx/tx callbacks to dump
packets based on the verbosity value as following:
    1- dump only received packets:
       testpmd> set verbose 1
    2- dump only sent packets:
       testpmd> set verbose 2
    3- dump sent and received packets:
       testpmd> set verbose (any number > 2)
    4- disable dump
       testpmd> set verbose 0

Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 app/test-pmd/config.c  | 25 +++++++++++++++++++++++++
 app/test-pmd/testpmd.c |  4 ++--
 app/test-pmd/testpmd.h |  1 +
 3 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 431fa2a..87a90ad 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -50,6 +50,7 @@
 #endif
 #include <rte_gro.h>
 #include <cmdline_parse_etheraddr.h>
+#include <rte_config.h>
 
 #include "testpmd.h"
 
@@ -2773,11 +2774,35 @@ remove_tx_dump_callbacks(portid_t portid)
 }
 
 void
+configure_rxtx_dump_callbacks(uint16_t verbose)
+{
+	portid_t portid;
+
+#ifndef RTE_ETHDEV_RXTX_CALLBACKS
+		TESTPMD_LOG(ERR, "setting rxtx callbacks is not enabled\n");
+		return;
+#endif
+
+	RTE_ETH_FOREACH_DEV(portid)
+	{
+		if (verbose == 1 || verbose > 2)
+			add_rx_dump_callbacks(portid);
+		else
+			remove_rx_dump_callbacks(portid);
+		if (verbose >= 2)
+			add_tx_dump_callbacks(portid);
+		else
+			remove_tx_dump_callbacks(portid);
+	}
+}
+
+void
 set_verbose_level(uint16_t vb_level)
 {
 	printf("Change verbose level from %u to %u\n",
 	       (unsigned int) verbose_level, (unsigned int) vb_level);
 	verbose_level = vb_level;
+	configure_rxtx_dump_callbacks(verbose_level);
 }
 
 void
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index d550bda..20582e4 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -1991,7 +1991,7 @@ start_port(portid_t pid)
 					return -1;
 				}
 			}
-
+			configure_rxtx_dump_callbacks(0);
 			printf("Configuring Port %d (socket %u)\n", pi,
 					port->socket_id);
 			/* configure port */
@@ -2090,7 +2090,7 @@ start_port(portid_t pid)
 				return -1;
 			}
 		}
-
+		configure_rxtx_dump_callbacks(verbose_level);
 		/* start port */
 		if (rte_eth_dev_start(pi) < 0) {
 			printf("Fail to start port %d\n", pi);
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 0e923d7..1ca7c6a 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -778,6 +778,7 @@ 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);
+void configure_rxtx_dump_callbacks(uint16_t verbose);
 
 /*
  * Work-around of a compilation error with ICC on invocations of the
-- 
2.7.4

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH v5 1/3] app/testpmd: move dumping packets to a separate function
  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         ` Ferruh Yigit
  2018-10-17 12:59           ` Iremonger, Bernard
  2 siblings, 1 reply; 47+ messages in thread
From: Ferruh Yigit @ 2018-10-17 12:27 UTC (permalink / raw)
  To: Raslan Darawsheh, jingjing.wu
  Cc: thomas, dev, shahafs, xuemingl, orika, jerin.jacob,
	david.marchand, bernard.iremonger

On 10/17/2018 8:27 AM, Raslan Darawsheh wrote:
> verbosity for the received/sent packets is needed in all of the
> forwarding engines so moving it to be in a separate function
> 
> Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
> Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>

<...>

> +static  inline void
> +dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],
> +	      uint16_t nb_pkts, int is_rx)
> +{

This is causing build error when only this patch applied:

.../app/test-pmd/util.c:25:1: error: unused function 'dump_pkt_burst'
[-Werror,-Wunused-function]
dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],
^

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH v4 3/3] app/testpmd: set packet dump based on verbosity level
  2018-10-11 16:39               ` Iremonger, Bernard
@ 2018-10-17 12:34                 ` Ferruh Yigit
  0 siblings, 0 replies; 47+ messages in thread
From: Ferruh Yigit @ 2018-10-17 12:34 UTC (permalink / raw)
  To: Iremonger, Bernard, Raslan Darawsheh, Wu, Jingjing
  Cc: Thomas Monjalon, dev, Shahaf Shuler, Xueming(Steven) Li, Ori Kam,
	jerin.jacob, david.marchand

On 10/11/2018 5:39 PM, Iremonger, Bernard wrote:
> Hi Ferruh
> 
> <snip>
>>>> Subject: Re: [dpdk-dev] [PATCH v4 3/3] app/testpmd: set packet dump
>>>> based on verbosity level
>>>>
>>>> On 10/7/2018 8:38 AM, Raslan Darawsheh wrote:
>>>>> when changing verbosity level it will configure rx/tx callbacks to
>>>>> dump packets based on the verbosity value as following:
>>>>>     1- dump only received packets:
>>>>>        testpmd> set verbose 1
>>>>>     2- dump only sent packets:
>>>>>        testpmd> set verbose 2
>>>>>     3- dump sent and received packets:
>>>>>        testpmd> set verbose (any number > 2)
>>>>>     4- disable dump
>>>>>        testpmd> set verbose 0
>>>>
>>>> It is good to able to enable Rx/Tx separately but you are overloading
>> "verbose"
>>>> meaning here. "verbose" is kind of log_level internal to testpmd and
>>>> can be used by many testpmd debug log.
>>>>
>>>> Why not create a separate setting for it, perhaps like pkt_verbose?
>>>
>>> The original code in rxonly.c used the verbose level, I don't think it is good idea
>> to add a new pkt_verbose.
>>> Users will be expecting it to work as before.
>>
>> In same logic they won't expect verbose=1 only for Rx and verbose=2 only for
>> Tx, previously this was on/off setting.
>>
>> since we are touching here already clarifying this with its own config item makes
>> more sense to me.
>> And user may not be wanting to have testpmd verbose level 3 and related logs
>> but only Rx/Tx packets.
> 
> Previously: 
> Set verbose 1, dumped rx packets.
> Set verbose 0, disabled dump of rx packets.
> 
> Now:
> Set verbose 2, dumps tx packets (new functionality, not dumped previously)
> Set verbose 3, dumps tx and rx packets (new functionality)
> 
> I am ok with this.
> I think more opinions are needed.

OK, what I understand was `verbose` is not for just dumping Rx/Tx packets, it is
a log level for testpmd.
But OK it seems it only used for printing packets and only level 0 & 1 used, so
agreed there won't be any issue to use verbose for this purpose.

But Raslan, can you please document this somewhere proper in testpmd
documentation, this information shouldn't be available only commit log.

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH v5 1/3] app/testpmd: move dumping packets to a separate function
  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
  0 siblings, 1 reply; 47+ messages in thread
From: Iremonger, Bernard @ 2018-10-17 12:59 UTC (permalink / raw)
  To: Yigit, Ferruh, Raslan Darawsheh, Wu, Jingjing
  Cc: thomas, dev, shahafs, xuemingl, orika, jerin.jacob, david.marchand

Hi Raslan,

> -----Original Message-----
> From: Yigit, Ferruh
> Sent: Wednesday, October 17, 2018 1:28 PM
> To: Raslan Darawsheh <rasland@mellanox.com>; Wu, Jingjing
> <jingjing.wu@intel.com>
> Cc: thomas@monjalon.net; dev@dpdk.org; shahafs@mellanox.com;
> xuemingl@mellanox.com; orika@mellanox.com;
> jerin.jacob@caviumnetworks.com; david.marchand@6wind.com; Iremonger,
> Bernard <bernard.iremonger@intel.com>
> Subject: Re: [PATCH v5 1/3] app/testpmd: move dumping packets to a separate
> function
> 
> On 10/17/2018 8:27 AM, Raslan Darawsheh wrote:
> > verbosity for the received/sent packets is needed in all of the
> > forwarding engines so moving it to be in a separate function
> >
> > Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
> > Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
> 
> <...>
> 
> > +static  inline void
> > +dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],
> > +	      uint16_t nb_pkts, int is_rx)
> > +{
> 
> This is causing build error when only this patch applied:
> 
> .../app/test-pmd/util.c:25:1: error: unused function 'dump_pkt_burst'
> [-Werror,-Wunused-function]
> dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[], ^

Builds ok with gcc but fails with clang

Regards,

Bernard.


^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH v6 1/3] app/testpmd: move dumping packets to a separate function
  2018-10-07  7:38     ` [dpdk-dev] [PATCH v4 " Raslan Darawsheh
                         ` (4 preceding siblings ...)
  2018-10-17  7:27       ` [dpdk-dev] [PATCH v5 " Raslan Darawsheh
@ 2018-10-17 15:22       ` Raslan Darawsheh
  2018-10-17 15:22         ` [dpdk-dev] [PATCH v6 2/3] app/testpmd: add packet dump callback functions Raslan Darawsheh
                           ` (2 more replies)
  5 siblings, 3 replies; 47+ messages in thread
From: Raslan Darawsheh @ 2018-10-17 15:22 UTC (permalink / raw)
  To: jingjing.wu
  Cc: thomas, dev, shahafs, rasland, xuemingl, orika, jerin.jacob,
	david.marchand, bernard.iremonger, ferruh.yigit

verbosity for the received/sent packets is needed in all of the
forwarding engines so moving it to be in a separate function

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

---
changes in v6:
	- fix compilation issue for patch
---
---
 app/test-pmd/Makefile    |   1 +
 app/test-pmd/meson.build |   3 +-
 app/test-pmd/rxonly.c    | 134 +----------------------------------------
 app/test-pmd/testpmd.h   |   3 +
 app/test-pmd/util.c      | 151 +++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 160 insertions(+), 132 deletions(-)
 create mode 100644 app/test-pmd/util.c

diff --git a/app/test-pmd/Makefile b/app/test-pmd/Makefile
index e2581ca..8e4ff5b 100644
--- a/app/test-pmd/Makefile
+++ b/app/test-pmd/Makefile
@@ -36,6 +36,7 @@ SRCS-y += icmpecho.c
 SRCS-y += noisy_vnf.c
 SRCS-$(CONFIG_RTE_LIBRTE_IEEE1588) += ieee1588fwd.c
 SRCS-$(CONFIG_RTE_LIBRTE_BPF) += bpf_cmd.c
+SRCS-y += util.c
 
 ifeq ($(CONFIG_RTE_LIBRTE_PMD_SOFTNIC), y)
 SRCS-y += softnicfwd.c
diff --git a/app/test-pmd/meson.build b/app/test-pmd/meson.build
index 9ef6ed9..cd66618 100644
--- a/app/test-pmd/meson.build
+++ b/app/test-pmd/meson.build
@@ -21,7 +21,8 @@ sources = files('cmdline.c',
 	'parameters.c',
 	'rxonly.c',
 	'testpmd.c',
-	'txonly.c')
+	'txonly.c',
+	'util.c')
 
 deps = ['ethdev', 'gro', 'gso', 'cmdline', 'metrics', 'meter', 'bus_pci']
 if dpdk_conf.has('RTE_LIBRTE_PDUMP')
diff --git a/app/test-pmd/rxonly.c b/app/test-pmd/rxonly.c
index 41db0ff..3eca89c 100644
--- a/app/test-pmd/rxonly.c
+++ b/app/test-pmd/rxonly.c
@@ -40,14 +40,6 @@
 
 #include "testpmd.h"
 
-static inline void
-print_ether_addr(const char *what, struct ether_addr *eth_addr)
-{
-	char buf[ETHER_ADDR_FMT_SIZE];
-	ether_format_addr(buf, ETHER_ADDR_FMT_SIZE, eth_addr);
-	printf("%s%s", what, buf);
-}
-
 /*
  * Received a burst of packets.
  */
@@ -55,16 +47,8 @@ static void
 pkt_burst_receive(struct fwd_stream *fs)
 {
 	struct rte_mbuf  *pkts_burst[MAX_PKT_BURST];
-	struct rte_mbuf  *mb;
-	struct ether_hdr *eth_hdr;
-	uint16_t eth_type;
-	uint64_t ol_flags;
 	uint16_t nb_rx;
-	uint16_t i, packet_type;
-	uint16_t is_encapsulation;
-	char buf[256];
-	struct rte_net_hdr_lens hdr_lens;
-	uint32_t sw_packet_type;
+	uint16_t i;
 
 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
 	uint64_t start_tsc;
@@ -90,120 +74,8 @@ pkt_burst_receive(struct fwd_stream *fs)
 	/*
 	 * Dump each received packet if verbose_level > 0.
 	 */
-	if (verbose_level > 0)
-		printf("port %u/queue %u: received %u packets\n",
-		       fs->rx_port,
-		       (unsigned) fs->rx_queue,
-		       (unsigned) nb_rx);
-	for (i = 0; i < nb_rx; i++) {
-		mb = pkts_burst[i];
-		if (verbose_level == 0) {
-			rte_pktmbuf_free(mb);
-			continue;
-		}
-		eth_hdr = rte_pktmbuf_mtod(mb, struct ether_hdr *);
-		eth_type = RTE_BE_TO_CPU_16(eth_hdr->ether_type);
-		ol_flags = mb->ol_flags;
-		packet_type = mb->packet_type;
-		is_encapsulation = RTE_ETH_IS_TUNNEL_PKT(packet_type);
-
-		print_ether_addr("  src=", &eth_hdr->s_addr);
-		print_ether_addr(" - dst=", &eth_hdr->d_addr);
-		printf(" - type=0x%04x - length=%u - nb_segs=%d",
-		       eth_type, (unsigned) mb->pkt_len,
-		       (int)mb->nb_segs);
-		if (ol_flags & PKT_RX_RSS_HASH) {
-			printf(" - RSS hash=0x%x", (unsigned) mb->hash.rss);
-			printf(" - RSS queue=0x%x",(unsigned) fs->rx_queue);
-		}
-		if (ol_flags & PKT_RX_FDIR) {
-			printf(" - FDIR matched ");
-			if (ol_flags & PKT_RX_FDIR_ID)
-				printf("ID=0x%x",
-				       mb->hash.fdir.hi);
-			else if (ol_flags & PKT_RX_FDIR_FLX)
-				printf("flex bytes=0x%08x %08x",
-				       mb->hash.fdir.hi, mb->hash.fdir.lo);
-			else
-				printf("hash=0x%x ID=0x%x ",
-				       mb->hash.fdir.hash, mb->hash.fdir.id);
-		}
-		if (ol_flags & PKT_RX_TIMESTAMP)
-			printf(" - timestamp %"PRIu64" ", mb->timestamp);
-		if (ol_flags & PKT_RX_QINQ)
-			printf(" - QinQ VLAN tci=0x%x, VLAN tci outer=0x%x",
-					mb->vlan_tci, mb->vlan_tci_outer);
-		else if (ol_flags & PKT_RX_VLAN)
-			printf(" - VLAN tci=0x%x", mb->vlan_tci);
-		if (mb->packet_type) {
-			rte_get_ptype_name(mb->packet_type, buf, sizeof(buf));
-			printf(" - hw ptype: %s", buf);
-		}
-		sw_packet_type = rte_net_get_ptype(mb, &hdr_lens,
-			RTE_PTYPE_ALL_MASK);
-		rte_get_ptype_name(sw_packet_type, buf, sizeof(buf));
-		printf(" - sw ptype: %s", buf);
-		if (sw_packet_type & RTE_PTYPE_L2_MASK)
-			printf(" - l2_len=%d", hdr_lens.l2_len);
-		if (sw_packet_type & RTE_PTYPE_L3_MASK)
-			printf(" - l3_len=%d", hdr_lens.l3_len);
-		if (sw_packet_type & RTE_PTYPE_L4_MASK)
-			printf(" - l4_len=%d", hdr_lens.l4_len);
-		if (sw_packet_type & RTE_PTYPE_TUNNEL_MASK)
-			printf(" - tunnel_len=%d", hdr_lens.tunnel_len);
-		if (sw_packet_type & RTE_PTYPE_INNER_L2_MASK)
-			printf(" - inner_l2_len=%d", hdr_lens.inner_l2_len);
-		if (sw_packet_type & RTE_PTYPE_INNER_L3_MASK)
-			printf(" - inner_l3_len=%d", hdr_lens.inner_l3_len);
-		if (sw_packet_type & RTE_PTYPE_INNER_L4_MASK)
-			printf(" - inner_l4_len=%d", hdr_lens.inner_l4_len);
-		if (is_encapsulation) {
-			struct ipv4_hdr *ipv4_hdr;
-			struct ipv6_hdr *ipv6_hdr;
-			struct udp_hdr *udp_hdr;
-			uint8_t l2_len;
-			uint8_t l3_len;
-			uint8_t l4_len;
-			uint8_t l4_proto;
-			struct  vxlan_hdr *vxlan_hdr;
-
-			l2_len  = sizeof(struct ether_hdr);
-
-			 /* Do not support ipv4 option field */
-			if (RTE_ETH_IS_IPV4_HDR(packet_type)) {
-				l3_len = sizeof(struct ipv4_hdr);
-				ipv4_hdr = rte_pktmbuf_mtod_offset(mb,
-								   struct ipv4_hdr *,
-								   l2_len);
-				l4_proto = ipv4_hdr->next_proto_id;
-			} else {
-				l3_len = sizeof(struct ipv6_hdr);
-				ipv6_hdr = rte_pktmbuf_mtod_offset(mb,
-								   struct ipv6_hdr *,
-								   l2_len);
-				l4_proto = ipv6_hdr->proto;
-			}
-			if (l4_proto == IPPROTO_UDP) {
-				udp_hdr = rte_pktmbuf_mtod_offset(mb,
-								  struct udp_hdr *,
-								  l2_len + l3_len);
-				l4_len = sizeof(struct udp_hdr);
-				vxlan_hdr = rte_pktmbuf_mtod_offset(mb,
-								    struct vxlan_hdr *,
-								    l2_len + l3_len + l4_len);
-
-				printf(" - VXLAN packet: packet type =%d, "
-					"Destination UDP port =%d, VNI = %d",
-					packet_type, RTE_BE_TO_CPU_16(udp_hdr->dst_port),
-					rte_be_to_cpu_32(vxlan_hdr->vx_vni) >> 8);
-			}
-		}
-		printf(" - Receive queue=0x%x", (unsigned) fs->rx_queue);
-		printf("\n");
-		rte_get_rx_ol_flag_list(mb->ol_flags, buf, sizeof(buf));
-		printf("  ol_flags: %s\n", buf);
-		rte_pktmbuf_free(mb);
-	}
+	for (i = 0; i < nb_rx; i++)
+		rte_pktmbuf_free(pkts_burst[i]);
 
 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
 	end_tsc = rte_rdtsc();
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 121b756..cba9640 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -764,6 +764,9 @@ 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);
+
 /*
  * Work-around of a compilation error with ICC on invocations of the
  * rte_be_to_cpu_16() function.
diff --git a/app/test-pmd/util.c b/app/test-pmd/util.c
new file mode 100644
index 0000000..3ba3b58
--- /dev/null
+++ b/app/test-pmd/util.c
@@ -0,0 +1,151 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation
+ * Copyright(c) 2018 Mellanox Technology
+ */
+
+#include <stdio.h>
+
+#include <rte_net.h>
+#include <rte_mbuf.h>
+#include <rte_ether.h>
+#include <rte_ethdev.h>
+#include <rte_flow.h>
+
+#include "testpmd.h"
+
+static inline void
+print_ether_addr(const char *what, struct ether_addr *eth_addr)
+{
+	char buf[ETHER_ADDR_FMT_SIZE];
+	ether_format_addr(buf, ETHER_ADDR_FMT_SIZE, eth_addr);
+	printf("%s%s", what, buf);
+}
+
+void
+dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf *pkts[],
+	      uint16_t nb_pkts, int is_rx)
+{
+	struct rte_mbuf  *mb;
+	struct ether_hdr *eth_hdr;
+	uint16_t eth_type;
+	uint64_t ol_flags;
+	uint16_t i, packet_type;
+	uint16_t is_encapsulation;
+	char buf[256];
+	struct rte_net_hdr_lens hdr_lens;
+	uint32_t sw_packet_type;
+	uint16_t udp_port;
+	uint32_t vx_vni;
+
+	if (!nb_pkts)
+		return;
+	printf("port %u/queue %u: %s %u packets\n",
+		port_id, queue,
+	       is_rx ? "received" : "sent",
+	       (unsigned int) nb_pkts);
+	for (i = 0; i < nb_pkts; i++) {
+		mb = pkts[i];
+		eth_hdr = rte_pktmbuf_mtod(mb, struct ether_hdr *);
+		eth_type = RTE_BE_TO_CPU_16(eth_hdr->ether_type);
+		ol_flags = mb->ol_flags;
+		packet_type = mb->packet_type;
+		is_encapsulation = RTE_ETH_IS_TUNNEL_PKT(packet_type);
+
+		print_ether_addr("  src=", &eth_hdr->s_addr);
+		print_ether_addr(" - dst=", &eth_hdr->d_addr);
+		printf(" - type=0x%04x - length=%u - nb_segs=%d",
+		       eth_type, (unsigned int) mb->pkt_len,
+		       (int)mb->nb_segs);
+		if (ol_flags & PKT_RX_RSS_HASH) {
+			printf(" - RSS hash=0x%x", (unsigned int) mb->hash.rss);
+			printf(" - RSS queue=0x%x", (unsigned int) queue);
+		}
+		if (ol_flags & PKT_RX_FDIR) {
+			printf(" - FDIR matched ");
+			if (ol_flags & PKT_RX_FDIR_ID)
+				printf("ID=0x%x",
+				       mb->hash.fdir.hi);
+			else if (ol_flags & PKT_RX_FDIR_FLX)
+				printf("flex bytes=0x%08x %08x",
+				       mb->hash.fdir.hi, mb->hash.fdir.lo);
+			else
+				printf("hash=0x%x ID=0x%x ",
+				       mb->hash.fdir.hash, mb->hash.fdir.id);
+		}
+		if (ol_flags & PKT_RX_TIMESTAMP)
+			printf(" - timestamp %"PRIu64" ", mb->timestamp);
+		if (ol_flags & PKT_RX_QINQ)
+			printf(" - QinQ VLAN tci=0x%x, VLAN tci outer=0x%x",
+			       mb->vlan_tci, mb->vlan_tci_outer);
+		else if (ol_flags & PKT_RX_VLAN)
+			printf(" - VLAN tci=0x%x", mb->vlan_tci);
+		if (mb->packet_type) {
+			rte_get_ptype_name(mb->packet_type, buf, sizeof(buf));
+			printf(" - hw ptype: %s", buf);
+		}
+		sw_packet_type = rte_net_get_ptype(mb, &hdr_lens,
+					RTE_PTYPE_ALL_MASK);
+		rte_get_ptype_name(sw_packet_type, buf, sizeof(buf));
+		printf(" - sw ptype: %s", buf);
+		if (sw_packet_type & RTE_PTYPE_L2_MASK)
+			printf(" - l2_len=%d", hdr_lens.l2_len);
+		if (sw_packet_type & RTE_PTYPE_L3_MASK)
+			printf(" - l3_len=%d", hdr_lens.l3_len);
+		if (sw_packet_type & RTE_PTYPE_L4_MASK)
+			printf(" - l4_len=%d", hdr_lens.l4_len);
+		if (sw_packet_type & RTE_PTYPE_TUNNEL_MASK)
+			printf(" - tunnel_len=%d", hdr_lens.tunnel_len);
+		if (sw_packet_type & RTE_PTYPE_INNER_L2_MASK)
+			printf(" - inner_l2_len=%d", hdr_lens.inner_l2_len);
+		if (sw_packet_type & RTE_PTYPE_INNER_L3_MASK)
+			printf(" - inner_l3_len=%d", hdr_lens.inner_l3_len);
+		if (sw_packet_type & RTE_PTYPE_INNER_L4_MASK)
+			printf(" - inner_l4_len=%d", hdr_lens.inner_l4_len);
+		if (is_encapsulation) {
+			struct ipv4_hdr *ipv4_hdr;
+			struct ipv6_hdr *ipv6_hdr;
+			struct udp_hdr *udp_hdr;
+			uint8_t l2_len;
+			uint8_t l3_len;
+			uint8_t l4_len;
+			uint8_t l4_proto;
+			struct  vxlan_hdr *vxlan_hdr;
+
+			l2_len  = sizeof(struct ether_hdr);
+
+			/* Do not support ipv4 option field */
+			if (RTE_ETH_IS_IPV4_HDR(packet_type)) {
+				l3_len = sizeof(struct ipv4_hdr);
+				ipv4_hdr = rte_pktmbuf_mtod_offset(mb,
+				struct ipv4_hdr *,
+				l2_len);
+				l4_proto = ipv4_hdr->next_proto_id;
+			} else {
+				l3_len = sizeof(struct ipv6_hdr);
+				ipv6_hdr = rte_pktmbuf_mtod_offset(mb,
+				struct ipv6_hdr *,
+				l2_len);
+				l4_proto = ipv6_hdr->proto;
+			}
+			if (l4_proto == IPPROTO_UDP) {
+				udp_hdr = rte_pktmbuf_mtod_offset(mb,
+				struct udp_hdr *,
+				l2_len + l3_len);
+				l4_len = sizeof(struct udp_hdr);
+				vxlan_hdr = rte_pktmbuf_mtod_offset(mb,
+				struct vxlan_hdr *,
+				l2_len + l3_len + l4_len);
+				udp_port = RTE_BE_TO_CPU_16(udp_hdr->dst_port);
+				vx_vni = rte_be_to_cpu_32(vxlan_hdr->vx_vni);
+				printf(" - VXLAN packet: packet type =%d, "
+				       "Destination UDP port =%d, VNI = %d",
+				       packet_type, udp_port, vx_vni >> 8);
+			}
+		}
+		printf(" - %s queue=0x%x", is_rx ? "Receive" : "Send",
+			(unsigned int) queue);
+		printf("\n");
+		rte_get_rx_ol_flag_list(mb->ol_flags, buf, sizeof(buf));
+		printf("  ol_flags: %s\n", buf);
+	}
+}
-- 
2.7.4

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH v6 2/3] app/testpmd: add packet dump callback functions
  2018-10-17 15:22       ` [dpdk-dev] [PATCH v6 " Raslan Darawsheh
@ 2018-10-17 15:22         ` Raslan Darawsheh
  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:22         ` [dpdk-dev] [PATCH v6 1/3] app/testpmd: move dumping packets to a separate function Ferruh Yigit
  2 siblings, 0 replies; 47+ messages in thread
From: Raslan Darawsheh @ 2018-10-17 15:22 UTC (permalink / raw)
  To: jingjing.wu
  Cc: thomas, dev, shahafs, rasland, xuemingl, orika, jerin.jacob,
	david.marchand, bernard.iremonger, ferruh.yigit

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

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [dpdk-dev] [PATCH v6 3/3] app/testpmd: set packet dump based on verbosity level
  2018-10-17 15:22       ` [dpdk-dev] [PATCH v6 " Raslan Darawsheh
  2018-10-17 15:22         ` [dpdk-dev] [PATCH v6 2/3] app/testpmd: add packet dump callback functions Raslan Darawsheh
@ 2018-10-17 15:22         ` Raslan Darawsheh
  2018-10-17 16:24           ` Iremonger, Bernard
  2018-10-17 16:22         ` [dpdk-dev] [PATCH v6 1/3] app/testpmd: move dumping packets to a separate function Ferruh Yigit
  2 siblings, 1 reply; 47+ messages in thread
From: Raslan Darawsheh @ 2018-10-17 15:22 UTC (permalink / raw)
  To: jingjing.wu
  Cc: thomas, dev, shahafs, rasland, xuemingl, orika, jerin.jacob,
	david.marchand, bernard.iremonger, ferruh.yigit

when changing verbosity level it will configure rx/tx callbacks to dump
packets based on the verbosity value as following:
    1- dump only received packets:
       testpmd> set verbose 1
    2- dump only sent packets:
       testpmd> set verbose 2
    3- dump sent and received packets:
       testpmd> set verbose (any number > 2)
    4- disable dump
       testpmd> set verbose 0

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

---
changes in v6:
	add documentation for the packet dump
---
---
 app/test-pmd/config.c                       | 25 +++++++++++++++++++++++++
 app/test-pmd/testpmd.c                      |  4 ++--
 app/test-pmd/testpmd.h                      |  1 +
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  6 +++++-
 4 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 55fec7f..1696623 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -50,6 +50,7 @@
 #endif
 #include <rte_gro.h>
 #include <cmdline_parse_etheraddr.h>
+#include <rte_config.h>
 
 #include "testpmd.h"
 
@@ -2773,11 +2774,35 @@ remove_tx_dump_callbacks(portid_t portid)
 }
 
 void
+configure_rxtx_dump_callbacks(uint16_t verbose)
+{
+	portid_t portid;
+
+#ifndef RTE_ETHDEV_RXTX_CALLBACKS
+		TESTPMD_LOG(ERR, "setting rxtx callbacks is not enabled\n");
+		return;
+#endif
+
+	RTE_ETH_FOREACH_DEV(portid)
+	{
+		if (verbose == 1 || verbose > 2)
+			add_rx_dump_callbacks(portid);
+		else
+			remove_rx_dump_callbacks(portid);
+		if (verbose >= 2)
+			add_tx_dump_callbacks(portid);
+		else
+			remove_tx_dump_callbacks(portid);
+	}
+}
+
+void
 set_verbose_level(uint16_t vb_level)
 {
 	printf("Change verbose level from %u to %u\n",
 	       (unsigned int) verbose_level, (unsigned int) vb_level);
 	verbose_level = vb_level;
+	configure_rxtx_dump_callbacks(verbose_level);
 }
 
 void
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 5dbbf78..3c42924 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -1988,7 +1988,7 @@ start_port(portid_t pid)
 					return -1;
 				}
 			}
-
+			configure_rxtx_dump_callbacks(0);
 			printf("Configuring Port %d (socket %u)\n", pi,
 					port->socket_id);
 			/* configure port */
@@ -2087,7 +2087,7 @@ start_port(portid_t pid)
 				return -1;
 			}
 		}
-
+		configure_rxtx_dump_callbacks(verbose_level);
 		/* start port */
 		if (rte_eth_dev_start(pi) < 0) {
 			printf("Fail to start port %d\n", pi);
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index c07bee8..3da728c 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -777,6 +777,7 @@ 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);
+void configure_rxtx_dump_callbacks(uint16_t verbose);
 
 /*
  * Work-around of a compilation error with ICC on invocations of the
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index ca060e1..60855c6 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -449,7 +449,11 @@ Set the debug verbosity level::
 
    testpmd> set verbose (level)
 
-Currently the only available levels are 0 (silent except for error) and 1 (fully verbose).
+Available levels are as following:
+* ``0`` silent except for error.
+* ``1`` fully verbose except for Tx packets.
+* ``2`` fully verbose except for Rx packets.
+* ``> 2`` fully verbose.
 
 set log
 ~~~~~~~
-- 
2.7.4

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH v5 1/3] app/testpmd: move dumping packets to a separate function
  2018-10-17 12:59           ` Iremonger, Bernard
@ 2018-10-17 15:22             ` Raslan Darawsheh
  0 siblings, 0 replies; 47+ messages in thread
From: Raslan Darawsheh @ 2018-10-17 15:22 UTC (permalink / raw)
  To: Iremonger, Bernard, Yigit, Ferruh, Wu, Jingjing
  Cc: Thomas Monjalon, dev, Shahaf Shuler, Xueming(Steven) Li, Ori Kam,
	jerin.jacob, david.marchand

Sending a newer version with the fix. 

Kindest regards,
Raslan Darawsheh

> -----Original Message-----
> From: Iremonger, Bernard <bernard.iremonger@intel.com>
> Sent: Wednesday, October 17, 2018 3:59 PM
> To: Yigit, Ferruh <ferruh.yigit@intel.com>; Raslan Darawsheh
> <rasland@mellanox.com>; Wu, Jingjing <jingjing.wu@intel.com>
> Cc: Thomas Monjalon <thomas@monjalon.net>; dev@dpdk.org; Shahaf
> Shuler <shahafs@mellanox.com>; Xueming(Steven) Li
> <xuemingl@mellanox.com>; Ori Kam <orika@mellanox.com>;
> jerin.jacob@caviumnetworks.com; david.marchand@6wind.com
> Subject: RE: [PATCH v5 1/3] app/testpmd: move dumping packets to a
> separate function
> 
> Hi Raslan,
> 
> > -----Original Message-----
> > From: Yigit, Ferruh
> > Sent: Wednesday, October 17, 2018 1:28 PM
> > To: Raslan Darawsheh <rasland@mellanox.com>; Wu, Jingjing
> > <jingjing.wu@intel.com>
> > Cc: thomas@monjalon.net; dev@dpdk.org; shahafs@mellanox.com;
> > xuemingl@mellanox.com; orika@mellanox.com;
> > jerin.jacob@caviumnetworks.com; david.marchand@6wind.com;
> Iremonger,
> > Bernard <bernard.iremonger@intel.com>
> > Subject: Re: [PATCH v5 1/3] app/testpmd: move dumping packets to a
> > separate function
> >
> > On 10/17/2018 8:27 AM, Raslan Darawsheh wrote:
> > > verbosity for the received/sent packets is needed in all of the
> > > forwarding engines so moving it to be in a separate function
> > >
> > > Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
> > > Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
> >
> > <...>
> >
> > > +static  inline void
> > > +dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf
> *pkts[],
> > > +	      uint16_t nb_pkts, int is_rx) {
> >
> > This is causing build error when only this patch applied:
> >
> > .../app/test-pmd/util.c:25:1: error: unused function 'dump_pkt_burst'
> > [-Werror,-Wunused-function]
> > dump_pkt_burst(uint16_t port_id, uint16_t queue, struct rte_mbuf
> > *pkts[], ^
> 
> Builds ok with gcc but fails with clang
> 
> Regards,
> 
> Bernard.


^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH v6 1/3] app/testpmd: move dumping packets to a separate function
  2018-10-17 15:22       ` [dpdk-dev] [PATCH v6 " Raslan Darawsheh
  2018-10-17 15:22         ` [dpdk-dev] [PATCH v6 2/3] app/testpmd: add packet dump callback functions Raslan Darawsheh
  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:22         ` Ferruh Yigit
  2 siblings, 0 replies; 47+ messages in thread
From: Ferruh Yigit @ 2018-10-17 16:22 UTC (permalink / raw)
  To: Raslan Darawsheh, jingjing.wu
  Cc: thomas, dev, shahafs, xuemingl, orika, jerin.jacob,
	david.marchand, bernard.iremonger

On 10/17/2018 4:22 PM, Raslan Darawsheh wrote:
> verbosity for the received/sent packets is needed in all of the
> forwarding engines so moving it to be in a separate function
> 
> Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
> Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>

Series applied to dpdk-next-net/master, thanks.

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH v6 3/3] app/testpmd: set packet dump based on verbosity level
  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
  0 siblings, 1 reply; 47+ messages in thread
From: Iremonger, Bernard @ 2018-10-17 16:24 UTC (permalink / raw)
  To: Raslan Darawsheh, Wu, Jingjing
  Cc: thomas, dev, shahafs, xuemingl, orika, jerin.jacob,
	david.marchand, Yigit, Ferruh

Hi Raslan,

> -----Original Message-----
> From: Raslan Darawsheh [mailto:rasland@mellanox.com]
> Sent: Wednesday, October 17, 2018 4:22 PM
> To: Wu, Jingjing <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; Iremonger,
> Bernard <bernard.iremonger@intel.com>; Yigit, Ferruh <ferruh.yigit@intel.com>
> Subject: [PATCH v6 3/3] app/testpmd: set packet dump based on verbosity level
> 
> when changing verbosity level it will configure rx/tx callbacks to dump packets
> based on the verbosity value as following:
>     1- dump only received packets:
>        testpmd> set verbose 1
>     2- dump only sent packets:
>        testpmd> set verbose 2
>     3- dump sent and received packets:
>        testpmd> set verbose (any number > 2)
>     4- disable dump
>        testpmd> set verbose 0
> 
> Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
> Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
> 
> ---
> changes in v6:
> 	add documentation for the packet dump
> ---
> ---
>  app/test-pmd/config.c                       | 25 +++++++++++++++++++++++++
>  app/test-pmd/testpmd.c                      |  4 ++--
>  app/test-pmd/testpmd.h                      |  1 +
>  doc/guides/testpmd_app_ug/testpmd_funcs.rst |  6 +++++-
>  4 files changed, 33 insertions(+), 3 deletions(-)
> 
> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index
> 55fec7f..1696623 100644
> --- a/app/test-pmd/config.c
> +++ b/app/test-pmd/config.c
> @@ -50,6 +50,7 @@
>  #endif
>  #include <rte_gro.h>
>  #include <cmdline_parse_etheraddr.h>
> +#include <rte_config.h>
> 
>  #include "testpmd.h"
> 
> @@ -2773,11 +2774,35 @@ remove_tx_dump_callbacks(portid_t portid)  }
> 
>  void
> +configure_rxtx_dump_callbacks(uint16_t verbose) {
> +	portid_t portid;
> +
> +#ifndef RTE_ETHDEV_RXTX_CALLBACKS
> +		TESTPMD_LOG(ERR, "setting rxtx callbacks is not enabled\n");
> +		return;
> +#endif
> +
> +	RTE_ETH_FOREACH_DEV(portid)
> +	{
> +		if (verbose == 1 || verbose > 2)
> +			add_rx_dump_callbacks(portid);
> +		else
> +			remove_rx_dump_callbacks(portid);
> +		if (verbose >= 2)
> +			add_tx_dump_callbacks(portid);
> +		else
> +			remove_tx_dump_callbacks(portid);
> +	}
> +}
> +
> +void
>  set_verbose_level(uint16_t vb_level)
>  {
>  	printf("Change verbose level from %u to %u\n",
>  	       (unsigned int) verbose_level, (unsigned int) vb_level);
>  	verbose_level = vb_level;
> +	configure_rxtx_dump_callbacks(verbose_level);
>  }
> 
>  void
> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index
> 5dbbf78..3c42924 100644
> --- a/app/test-pmd/testpmd.c
> +++ b/app/test-pmd/testpmd.c
> @@ -1988,7 +1988,7 @@ start_port(portid_t pid)
>  					return -1;
>  				}
>  			}
> -
> +			configure_rxtx_dump_callbacks(0);
>  			printf("Configuring Port %d (socket %u)\n", pi,
>  					port->socket_id);
>  			/* configure port */
> @@ -2087,7 +2087,7 @@ start_port(portid_t pid)
>  				return -1;
>  			}
>  		}
> -
> +		configure_rxtx_dump_callbacks(verbose_level);
>  		/* start port */
>  		if (rte_eth_dev_start(pi) < 0) {
>  			printf("Fail to start port %d\n", pi); diff --git a/app/test-
> pmd/testpmd.h b/app/test-pmd/testpmd.h index c07bee8..3da728c 100644
> --- a/app/test-pmd/testpmd.h
> +++ b/app/test-pmd/testpmd.h
> @@ -777,6 +777,7 @@ 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);
> +void configure_rxtx_dump_callbacks(uint16_t verbose);
> 
>  /*
>   * Work-around of a compilation error with ICC on invocations of the diff --git
> a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> index ca060e1..60855c6 100644
> --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> @@ -449,7 +449,11 @@ Set the debug verbosity level::
> 
>     testpmd> set verbose (level)
> 
> -Currently the only available levels are 0 (silent except for error) and 1 (fully
> verbose).
> +Available levels are as following:
> +* ``0`` silent except for error.
> +* ``1`` fully verbose except for Tx packets.
> +* ``2`` fully verbose except for Rx packets.
> +* ``> 2`` fully verbose.
> 

The html output is probably not what you intended:

Available levels are as following: * 0 silent except for error. * 1 fully verbose except for Tx packets. * 2 fully verbose except for Rx packets. * > 2 fully verbose.

A blank line is needed between each line.

>  set log
>  ~~~~~~~
> --
> 2.7.4

Regards,

Bernard.

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH v6 3/3] app/testpmd: set packet dump based on verbosity level
  2018-10-17 16:24           ` Iremonger, Bernard
@ 2018-10-17 16:33             ` Ferruh Yigit
  2018-10-18  8:19               ` Raslan Darawsheh
  0 siblings, 1 reply; 47+ messages in thread
From: Ferruh Yigit @ 2018-10-17 16:33 UTC (permalink / raw)
  To: Iremonger, Bernard, Raslan Darawsheh, Wu, Jingjing
  Cc: thomas, dev, shahafs, xuemingl, orika, jerin.jacob, david.marchand

On 10/17/2018 5:24 PM, Iremonger, Bernard wrote:
> Hi Raslan,
> 
>> -----Original Message-----
>> From: Raslan Darawsheh [mailto:rasland@mellanox.com]
>> Sent: Wednesday, October 17, 2018 4:22 PM
>> To: Wu, Jingjing <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; Iremonger,
>> Bernard <bernard.iremonger@intel.com>; Yigit, Ferruh <ferruh.yigit@intel.com>
>> Subject: [PATCH v6 3/3] app/testpmd: set packet dump based on verbosity level
>>
>> when changing verbosity level it will configure rx/tx callbacks to dump packets
>> based on the verbosity value as following:
>>     1- dump only received packets:
>>        testpmd> set verbose 1
>>     2- dump only sent packets:
>>        testpmd> set verbose 2
>>     3- dump sent and received packets:
>>        testpmd> set verbose (any number > 2)
>>     4- disable dump
>>        testpmd> set verbose 0
>>
>> Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
>> Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
>>
>> ---
>> changes in v6:
>> 	add documentation for the packet dump
>> ---
>> ---
>>  app/test-pmd/config.c                       | 25 +++++++++++++++++++++++++
>>  app/test-pmd/testpmd.c                      |  4 ++--
>>  app/test-pmd/testpmd.h                      |  1 +
>>  doc/guides/testpmd_app_ug/testpmd_funcs.rst |  6 +++++-
>>  4 files changed, 33 insertions(+), 3 deletions(-)
>>
>> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index
>> 55fec7f..1696623 100644
>> --- a/app/test-pmd/config.c
>> +++ b/app/test-pmd/config.c
>> @@ -50,6 +50,7 @@
>>  #endif
>>  #include <rte_gro.h>
>>  #include <cmdline_parse_etheraddr.h>
>> +#include <rte_config.h>
>>
>>  #include "testpmd.h"
>>
>> @@ -2773,11 +2774,35 @@ remove_tx_dump_callbacks(portid_t portid)  }
>>
>>  void
>> +configure_rxtx_dump_callbacks(uint16_t verbose) {
>> +	portid_t portid;
>> +
>> +#ifndef RTE_ETHDEV_RXTX_CALLBACKS
>> +		TESTPMD_LOG(ERR, "setting rxtx callbacks is not enabled\n");
>> +		return;
>> +#endif
>> +
>> +	RTE_ETH_FOREACH_DEV(portid)
>> +	{
>> +		if (verbose == 1 || verbose > 2)
>> +			add_rx_dump_callbacks(portid);
>> +		else
>> +			remove_rx_dump_callbacks(portid);
>> +		if (verbose >= 2)
>> +			add_tx_dump_callbacks(portid);
>> +		else
>> +			remove_tx_dump_callbacks(portid);
>> +	}
>> +}
>> +
>> +void
>>  set_verbose_level(uint16_t vb_level)
>>  {
>>  	printf("Change verbose level from %u to %u\n",
>>  	       (unsigned int) verbose_level, (unsigned int) vb_level);
>>  	verbose_level = vb_level;
>> +	configure_rxtx_dump_callbacks(verbose_level);
>>  }
>>
>>  void
>> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index
>> 5dbbf78..3c42924 100644
>> --- a/app/test-pmd/testpmd.c
>> +++ b/app/test-pmd/testpmd.c
>> @@ -1988,7 +1988,7 @@ start_port(portid_t pid)
>>  					return -1;
>>  				}
>>  			}
>> -
>> +			configure_rxtx_dump_callbacks(0);
>>  			printf("Configuring Port %d (socket %u)\n", pi,
>>  					port->socket_id);
>>  			/* configure port */
>> @@ -2087,7 +2087,7 @@ start_port(portid_t pid)
>>  				return -1;
>>  			}
>>  		}
>> -
>> +		configure_rxtx_dump_callbacks(verbose_level);
>>  		/* start port */
>>  		if (rte_eth_dev_start(pi) < 0) {
>>  			printf("Fail to start port %d\n", pi); diff --git a/app/test-
>> pmd/testpmd.h b/app/test-pmd/testpmd.h index c07bee8..3da728c 100644
>> --- a/app/test-pmd/testpmd.h
>> +++ b/app/test-pmd/testpmd.h
>> @@ -777,6 +777,7 @@ 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);
>> +void configure_rxtx_dump_callbacks(uint16_t verbose);
>>
>>  /*
>>   * Work-around of a compilation error with ICC on invocations of the diff --git
>> a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
>> b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
>> index ca060e1..60855c6 100644
>> --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
>> +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
>> @@ -449,7 +449,11 @@ Set the debug verbosity level::
>>
>>     testpmd> set verbose (level)
>>
>> -Currently the only available levels are 0 (silent except for error) and 1 (fully
>> verbose).
>> +Available levels are as following:
>> +* ``0`` silent except for error.
>> +* ``1`` fully verbose except for Tx packets.
>> +* ``2`` fully verbose except for Rx packets.
>> +* ``> 2`` fully verbose.
>>
> 
> The html output is probably not what you intended:
> 
> Available levels are as following: * 0 silent except for error. * 1 fully verbose except for Tx packets. * 2 fully verbose except for Rx packets. * > 2 fully verbose.
> 
> A blank line is needed between each line.

You a right, output is broken. I updated in the tree, just one blank line before
list seems did the work.
Raslan can you please confirm the latest doc in the tree?

> 
>>  set log
>>  ~~~~~~~
>> --
>> 2.7.4
> 
> Regards,
> 
> Bernard.
> 
> 

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH v6 3/3] app/testpmd: set packet dump based on verbosity level
  2018-10-17 16:33             ` Ferruh Yigit
@ 2018-10-18  8:19               ` Raslan Darawsheh
  2018-10-18  8:33                 ` Ferruh Yigit
  0 siblings, 1 reply; 47+ messages in thread
From: Raslan Darawsheh @ 2018-10-18  8:19 UTC (permalink / raw)
  To: Ferruh Yigit, Iremonger, Bernard, Wu, Jingjing
  Cc: Thomas Monjalon, dev, Shahaf Shuler, Xueming(Steven) Li, Ori Kam,
	jerin.jacob, david.marchand

Hi,

> -----Original Message-----
> From: Ferruh Yigit <ferruh.yigit@intel.com>
> Sent: Wednesday, October 17, 2018 7:33 PM
> To: Iremonger, Bernard <bernard.iremonger@intel.com>; Raslan Darawsheh
> <rasland@mellanox.com>; Wu, Jingjing <jingjing.wu@intel.com>
> Cc: Thomas Monjalon <thomas@monjalon.net>; dev@dpdk.org; Shahaf
> Shuler <shahafs@mellanox.com>; Xueming(Steven) Li
> <xuemingl@mellanox.com>; Ori Kam <orika@mellanox.com>;
> jerin.jacob@caviumnetworks.com; david.marchand@6wind.com
> Subject: Re: [PATCH v6 3/3] app/testpmd: set packet dump based on
> verbosity level
> 
> On 10/17/2018 5:24 PM, Iremonger, Bernard wrote:
> > Hi Raslan,
> >
> >> -----Original Message-----
> >> From: Raslan Darawsheh [mailto:rasland@mellanox.com]
> >> Sent: Wednesday, October 17, 2018 4:22 PM
> >> To: Wu, Jingjing <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;
> Iremonger,
> >> Bernard <bernard.iremonger@intel.com>; Yigit, Ferruh
> >> <ferruh.yigit@intel.com>
> >> Subject: [PATCH v6 3/3] app/testpmd: set packet dump based on
> >> verbosity level
> >>
> >> when changing verbosity level it will configure rx/tx callbacks to
> >> dump packets based on the verbosity value as following:
> >>     1- dump only received packets:
> >>        testpmd> set verbose 1
> >>     2- dump only sent packets:
> >>        testpmd> set verbose 2
> >>     3- dump sent and received packets:
> >>        testpmd> set verbose (any number > 2)
> >>     4- disable dump
> >>        testpmd> set verbose 0
> >>
> >> Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
> >> Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
> >>
> >> ---
> >> changes in v6:
> >> 	add documentation for the packet dump
> >> ---
> >> ---
> >>  app/test-pmd/config.c                       | 25 +++++++++++++++++++++++++
> >>  app/test-pmd/testpmd.c                      |  4 ++--
> >>  app/test-pmd/testpmd.h                      |  1 +
> >>  doc/guides/testpmd_app_ug/testpmd_funcs.rst |  6 +++++-
> >>  4 files changed, 33 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index
> >> 55fec7f..1696623 100644
> >> --- a/app/test-pmd/config.c
> >> +++ b/app/test-pmd/config.c
> >> @@ -50,6 +50,7 @@
> >>  #endif
> >>  #include <rte_gro.h>
> >>  #include <cmdline_parse_etheraddr.h>
> >> +#include <rte_config.h>
> >>
> >>  #include "testpmd.h"
> >>
> >> @@ -2773,11 +2774,35 @@ remove_tx_dump_callbacks(portid_t portid)
> }
> >>
> >>  void
> >> +configure_rxtx_dump_callbacks(uint16_t verbose) {
> >> +	portid_t portid;
> >> +
> >> +#ifndef RTE_ETHDEV_RXTX_CALLBACKS
> >> +		TESTPMD_LOG(ERR, "setting rxtx callbacks is not
> enabled\n");
> >> +		return;
> >> +#endif
> >> +
> >> +	RTE_ETH_FOREACH_DEV(portid)
> >> +	{
> >> +		if (verbose == 1 || verbose > 2)
> >> +			add_rx_dump_callbacks(portid);
> >> +		else
> >> +			remove_rx_dump_callbacks(portid);
> >> +		if (verbose >= 2)
> >> +			add_tx_dump_callbacks(portid);
> >> +		else
> >> +			remove_tx_dump_callbacks(portid);
> >> +	}
> >> +}
> >> +
> >> +void
> >>  set_verbose_level(uint16_t vb_level)  {
> >>  	printf("Change verbose level from %u to %u\n",
> >>  	       (unsigned int) verbose_level, (unsigned int) vb_level);
> >>  	verbose_level = vb_level;
> >> +	configure_rxtx_dump_callbacks(verbose_level);
> >>  }
> >>
> >>  void
> >> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index
> >> 5dbbf78..3c42924 100644
> >> --- a/app/test-pmd/testpmd.c
> >> +++ b/app/test-pmd/testpmd.c
> >> @@ -1988,7 +1988,7 @@ start_port(portid_t pid)
> >>  					return -1;
> >>  				}
> >>  			}
> >> -
> >> +			configure_rxtx_dump_callbacks(0);
> >>  			printf("Configuring Port %d (socket %u)\n", pi,
> >>  					port->socket_id);
> >>  			/* configure port */
> >> @@ -2087,7 +2087,7 @@ start_port(portid_t pid)
> >>  				return -1;
> >>  			}
> >>  		}
> >> -
> >> +		configure_rxtx_dump_callbacks(verbose_level);
> >>  		/* start port */
> >>  		if (rte_eth_dev_start(pi) < 0) {
> >>  			printf("Fail to start port %d\n", pi); diff --git
> a/app/test-
> >> pmd/testpmd.h b/app/test-pmd/testpmd.h index c07bee8..3da728c
> 100644
> >> --- a/app/test-pmd/testpmd.h
> >> +++ b/app/test-pmd/testpmd.h
> >> @@ -777,6 +777,7 @@ 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);
> >> +void configure_rxtx_dump_callbacks(uint16_t verbose);
> >>
> >>  /*
> >>   * Work-around of a compilation error with ICC on invocations of the
> >> diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> >> b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> >> index ca060e1..60855c6 100644
> >> --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> >> +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> >> @@ -449,7 +449,11 @@ Set the debug verbosity level::
> >>
> >>     testpmd> set verbose (level)
> >>
> >> -Currently the only available levels are 0 (silent except for error)
> >> and 1 (fully verbose).
> >> +Available levels are as following:
> >> +* ``0`` silent except for error.
> >> +* ``1`` fully verbose except for Tx packets.
> >> +* ``2`` fully verbose except for Rx packets.
> >> +* ``> 2`` fully verbose.
> >>
> >
> > The html output is probably not what you intended:
> >
> > Available levels are as following: * 0 silent except for error. * 1 fully verbose
> except for Tx packets. * 2 fully verbose except for Rx packets. * > 2 fully
> verbose.
> >
> > A blank line is needed between each line.
> 
> You a right, output is broken. I updated in the tree, just one blank line before
> list seems did the work.
> Raslan can you please confirm the latest doc in the tree?

I see it's merged in dpdk-next/master but, it doesn't have the missing blank lines.

> 
> >
> >>  set log
> >>  ~~~~~~~
> >> --
> >> 2.7.4
> >
> > Regards,
> >
> > Bernard.
> >
> >


Kindest regards,
Raslan Darawsheh

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH v6 3/3] app/testpmd: set packet dump based on verbosity level
  2018-10-18  8:19               ` Raslan Darawsheh
@ 2018-10-18  8:33                 ` Ferruh Yigit
  2018-10-18  8:47                   ` Raslan Darawsheh
  0 siblings, 1 reply; 47+ messages in thread
From: Ferruh Yigit @ 2018-10-18  8:33 UTC (permalink / raw)
  To: Raslan Darawsheh, Iremonger, Bernard, Wu, Jingjing
  Cc: Thomas Monjalon, dev, Shahaf Shuler, Xueming(Steven) Li, Ori Kam,
	jerin.jacob, david.marchand

On 10/18/2018 9:19 AM, Raslan Darawsheh wrote:
> Hi,
> 
>> -----Original Message-----
>> From: Ferruh Yigit <ferruh.yigit@intel.com>
>> Sent: Wednesday, October 17, 2018 7:33 PM
>> To: Iremonger, Bernard <bernard.iremonger@intel.com>; Raslan Darawsheh
>> <rasland@mellanox.com>; Wu, Jingjing <jingjing.wu@intel.com>
>> Cc: Thomas Monjalon <thomas@monjalon.net>; dev@dpdk.org; Shahaf
>> Shuler <shahafs@mellanox.com>; Xueming(Steven) Li
>> <xuemingl@mellanox.com>; Ori Kam <orika@mellanox.com>;
>> jerin.jacob@caviumnetworks.com; david.marchand@6wind.com
>> Subject: Re: [PATCH v6 3/3] app/testpmd: set packet dump based on
>> verbosity level
>>
>> On 10/17/2018 5:24 PM, Iremonger, Bernard wrote:
>>> Hi Raslan,
>>>
>>>> -----Original Message-----
>>>> From: Raslan Darawsheh [mailto:rasland@mellanox.com]
>>>> Sent: Wednesday, October 17, 2018 4:22 PM
>>>> To: Wu, Jingjing <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;
>> Iremonger,
>>>> Bernard <bernard.iremonger@intel.com>; Yigit, Ferruh
>>>> <ferruh.yigit@intel.com>
>>>> Subject: [PATCH v6 3/3] app/testpmd: set packet dump based on
>>>> verbosity level
>>>>
>>>> when changing verbosity level it will configure rx/tx callbacks to
>>>> dump packets based on the verbosity value as following:
>>>>     1- dump only received packets:
>>>>        testpmd> set verbose 1
>>>>     2- dump only sent packets:
>>>>        testpmd> set verbose 2
>>>>     3- dump sent and received packets:
>>>>        testpmd> set verbose (any number > 2)
>>>>     4- disable dump
>>>>        testpmd> set verbose 0
>>>>
>>>> Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
>>>> Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
>>>>
>>>> ---
>>>> changes in v6:
>>>> 	add documentation for the packet dump
>>>> ---
>>>> ---
>>>>  app/test-pmd/config.c                       | 25 +++++++++++++++++++++++++
>>>>  app/test-pmd/testpmd.c                      |  4 ++--
>>>>  app/test-pmd/testpmd.h                      |  1 +
>>>>  doc/guides/testpmd_app_ug/testpmd_funcs.rst |  6 +++++-
>>>>  4 files changed, 33 insertions(+), 3 deletions(-)
>>>>
>>>> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index
>>>> 55fec7f..1696623 100644
>>>> --- a/app/test-pmd/config.c
>>>> +++ b/app/test-pmd/config.c
>>>> @@ -50,6 +50,7 @@
>>>>  #endif
>>>>  #include <rte_gro.h>
>>>>  #include <cmdline_parse_etheraddr.h>
>>>> +#include <rte_config.h>
>>>>
>>>>  #include "testpmd.h"
>>>>
>>>> @@ -2773,11 +2774,35 @@ remove_tx_dump_callbacks(portid_t portid)
>> }
>>>>
>>>>  void
>>>> +configure_rxtx_dump_callbacks(uint16_t verbose) {
>>>> +	portid_t portid;
>>>> +
>>>> +#ifndef RTE_ETHDEV_RXTX_CALLBACKS
>>>> +		TESTPMD_LOG(ERR, "setting rxtx callbacks is not
>> enabled\n");
>>>> +		return;
>>>> +#endif
>>>> +
>>>> +	RTE_ETH_FOREACH_DEV(portid)
>>>> +	{
>>>> +		if (verbose == 1 || verbose > 2)
>>>> +			add_rx_dump_callbacks(portid);
>>>> +		else
>>>> +			remove_rx_dump_callbacks(portid);
>>>> +		if (verbose >= 2)
>>>> +			add_tx_dump_callbacks(portid);
>>>> +		else
>>>> +			remove_tx_dump_callbacks(portid);
>>>> +	}
>>>> +}
>>>> +
>>>> +void
>>>>  set_verbose_level(uint16_t vb_level)  {
>>>>  	printf("Change verbose level from %u to %u\n",
>>>>  	       (unsigned int) verbose_level, (unsigned int) vb_level);
>>>>  	verbose_level = vb_level;
>>>> +	configure_rxtx_dump_callbacks(verbose_level);
>>>>  }
>>>>
>>>>  void
>>>> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index
>>>> 5dbbf78..3c42924 100644
>>>> --- a/app/test-pmd/testpmd.c
>>>> +++ b/app/test-pmd/testpmd.c
>>>> @@ -1988,7 +1988,7 @@ start_port(portid_t pid)
>>>>  					return -1;
>>>>  				}
>>>>  			}
>>>> -
>>>> +			configure_rxtx_dump_callbacks(0);
>>>>  			printf("Configuring Port %d (socket %u)\n", pi,
>>>>  					port->socket_id);
>>>>  			/* configure port */
>>>> @@ -2087,7 +2087,7 @@ start_port(portid_t pid)
>>>>  				return -1;
>>>>  			}
>>>>  		}
>>>> -
>>>> +		configure_rxtx_dump_callbacks(verbose_level);
>>>>  		/* start port */
>>>>  		if (rte_eth_dev_start(pi) < 0) {
>>>>  			printf("Fail to start port %d\n", pi); diff --git
>> a/app/test-
>>>> pmd/testpmd.h b/app/test-pmd/testpmd.h index c07bee8..3da728c
>> 100644
>>>> --- a/app/test-pmd/testpmd.h
>>>> +++ b/app/test-pmd/testpmd.h
>>>> @@ -777,6 +777,7 @@ 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);
>>>> +void configure_rxtx_dump_callbacks(uint16_t verbose);
>>>>
>>>>  /*
>>>>   * Work-around of a compilation error with ICC on invocations of the
>>>> diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
>>>> b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
>>>> index ca060e1..60855c6 100644
>>>> --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
>>>> +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
>>>> @@ -449,7 +449,11 @@ Set the debug verbosity level::
>>>>
>>>>     testpmd> set verbose (level)
>>>>
>>>> -Currently the only available levels are 0 (silent except for error)
>>>> and 1 (fully verbose).
>>>> +Available levels are as following:
>>>> +* ``0`` silent except for error.
>>>> +* ``1`` fully verbose except for Tx packets.
>>>> +* ``2`` fully verbose except for Rx packets.
>>>> +* ``> 2`` fully verbose.
>>>>
>>>
>>> The html output is probably not what you intended:
>>>
>>> Available levels are as following: * 0 silent except for error. * 1 fully verbose
>> except for Tx packets. * 2 fully verbose except for Rx packets. * > 2 fully
>> verbose.
>>>
>>> A blank line is needed between each line.
>>
>> You a right, output is broken. I updated in the tree, just one blank line before
>> list seems did the work.
>> Raslan can you please confirm the latest doc in the tree?
> 
> I see it's merged in dpdk-next/master but, it doesn't have the missing blank lines.

In repo it is:

"
 Available levels are as following:







 * ``0`` silent except for error.
 * ``1`` fully verbose except for Tx packets.
 * ``2`` fully verbose except for Rx packets.
 * ``> 2`` fully verbose.
"

In original patch:
"
 +Available levels are as following:
 +* ``0`` silent except for error.
 +* ``1`` fully verbose except for Tx packets.
 +* ``2`` fully verbose except for Rx packets.
 +* ``> 2`` fully verbose.
"

Please, compile both and observe the difference.

> 
>>
>>>
>>>>  set log
>>>>  ~~~~~~~
>>>> --
>>>> 2.7.4
>>>
>>> Regards,
>>>
>>> Bernard.
>>>
>>>
> 
> 
> Kindest regards,
> Raslan Darawsheh
> 

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [dpdk-dev] [PATCH v6 3/3] app/testpmd: set packet dump based on verbosity level
  2018-10-18  8:33                 ` Ferruh Yigit
@ 2018-10-18  8:47                   ` Raslan Darawsheh
  0 siblings, 0 replies; 47+ messages in thread
From: Raslan Darawsheh @ 2018-10-18  8:47 UTC (permalink / raw)
  To: Ferruh Yigit, Iremonger, Bernard, Wu, Jingjing
  Cc: Thomas Monjalon, dev, Shahaf Shuler, Xueming(Steven) Li, Ori Kam,
	jerin.jacob, david.marchand

You are right about that my mistake. 

Kindest regards,
Raslan Darawsheh

> -----Original Message-----
> From: Ferruh Yigit <ferruh.yigit@intel.com>
> Sent: Thursday, October 18, 2018 11:34 AM
> To: Raslan Darawsheh <rasland@mellanox.com>; Iremonger, Bernard
> <bernard.iremonger@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>
> Cc: Thomas Monjalon <thomas@monjalon.net>; dev@dpdk.org; Shahaf
> Shuler <shahafs@mellanox.com>; Xueming(Steven) Li
> <xuemingl@mellanox.com>; Ori Kam <orika@mellanox.com>;
> jerin.jacob@caviumnetworks.com; david.marchand@6wind.com
> Subject: Re: [dpdk-dev] [PATCH v6 3/3] app/testpmd: set packet dump
> based on verbosity level
> 
> On 10/18/2018 9:19 AM, Raslan Darawsheh wrote:
> > Hi,
> >
> >> -----Original Message-----
> >> From: Ferruh Yigit <ferruh.yigit@intel.com>
> >> Sent: Wednesday, October 17, 2018 7:33 PM
> >> To: Iremonger, Bernard <bernard.iremonger@intel.com>; Raslan
> >> Darawsheh <rasland@mellanox.com>; Wu, Jingjing
> >> <jingjing.wu@intel.com>
> >> Cc: Thomas Monjalon <thomas@monjalon.net>; dev@dpdk.org; Shahaf
> >> Shuler <shahafs@mellanox.com>; Xueming(Steven) Li
> >> <xuemingl@mellanox.com>; Ori Kam <orika@mellanox.com>;
> >> jerin.jacob@caviumnetworks.com; david.marchand@6wind.com
> >> Subject: Re: [PATCH v6 3/3] app/testpmd: set packet dump based on
> >> verbosity level
> >>
> >> On 10/17/2018 5:24 PM, Iremonger, Bernard wrote:
> >>> Hi Raslan,
> >>>
> >>>> -----Original Message-----
> >>>> From: Raslan Darawsheh [mailto:rasland@mellanox.com]
> >>>> Sent: Wednesday, October 17, 2018 4:22 PM
> >>>> To: Wu, Jingjing <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;
> >> Iremonger,
> >>>> Bernard <bernard.iremonger@intel.com>; Yigit, Ferruh
> >>>> <ferruh.yigit@intel.com>
> >>>> Subject: [PATCH v6 3/3] app/testpmd: set packet dump based on
> >>>> verbosity level
> >>>>
> >>>> when changing verbosity level it will configure rx/tx callbacks to
> >>>> dump packets based on the verbosity value as following:
> >>>>     1- dump only received packets:
> >>>>        testpmd> set verbose 1
> >>>>     2- dump only sent packets:
> >>>>        testpmd> set verbose 2
> >>>>     3- dump sent and received packets:
> >>>>        testpmd> set verbose (any number > 2)
> >>>>     4- disable dump
> >>>>        testpmd> set verbose 0
> >>>>
> >>>> Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
> >>>> Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
> >>>>
> >>>> ---
> >>>> changes in v6:
> >>>> 	add documentation for the packet dump
> >>>> ---
> >>>> ---
> >>>>  app/test-pmd/config.c                       | 25
> +++++++++++++++++++++++++
> >>>>  app/test-pmd/testpmd.c                      |  4 ++--
> >>>>  app/test-pmd/testpmd.h                      |  1 +
> >>>>  doc/guides/testpmd_app_ug/testpmd_funcs.rst |  6 +++++-
> >>>>  4 files changed, 33 insertions(+), 3 deletions(-)
> >>>>
> >>>> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index
> >>>> 55fec7f..1696623 100644
> >>>> --- a/app/test-pmd/config.c
> >>>> +++ b/app/test-pmd/config.c
> >>>> @@ -50,6 +50,7 @@
> >>>>  #endif
> >>>>  #include <rte_gro.h>
> >>>>  #include <cmdline_parse_etheraddr.h>
> >>>> +#include <rte_config.h>
> >>>>
> >>>>  #include "testpmd.h"
> >>>>
> >>>> @@ -2773,11 +2774,35 @@ remove_tx_dump_callbacks(portid_t
> portid)
> >> }
> >>>>
> >>>>  void
> >>>> +configure_rxtx_dump_callbacks(uint16_t verbose) {
> >>>> +	portid_t portid;
> >>>> +
> >>>> +#ifndef RTE_ETHDEV_RXTX_CALLBACKS
> >>>> +		TESTPMD_LOG(ERR, "setting rxtx callbacks is not
> >> enabled\n");
> >>>> +		return;
> >>>> +#endif
> >>>> +
> >>>> +	RTE_ETH_FOREACH_DEV(portid)
> >>>> +	{
> >>>> +		if (verbose == 1 || verbose > 2)
> >>>> +			add_rx_dump_callbacks(portid);
> >>>> +		else
> >>>> +			remove_rx_dump_callbacks(portid);
> >>>> +		if (verbose >= 2)
> >>>> +			add_tx_dump_callbacks(portid);
> >>>> +		else
> >>>> +			remove_tx_dump_callbacks(portid);
> >>>> +	}
> >>>> +}
> >>>> +
> >>>> +void
> >>>>  set_verbose_level(uint16_t vb_level)  {
> >>>>  	printf("Change verbose level from %u to %u\n",
> >>>>  	       (unsigned int) verbose_level, (unsigned int) vb_level);
> >>>>  	verbose_level = vb_level;
> >>>> +	configure_rxtx_dump_callbacks(verbose_level);
> >>>>  }
> >>>>
> >>>>  void
> >>>> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index
> >>>> 5dbbf78..3c42924 100644
> >>>> --- a/app/test-pmd/testpmd.c
> >>>> +++ b/app/test-pmd/testpmd.c
> >>>> @@ -1988,7 +1988,7 @@ start_port(portid_t pid)
> >>>>  					return -1;
> >>>>  				}
> >>>>  			}
> >>>> -
> >>>> +			configure_rxtx_dump_callbacks(0);
> >>>>  			printf("Configuring Port %d (socket %u)\n", pi,
> >>>>  					port->socket_id);
> >>>>  			/* configure port */
> >>>> @@ -2087,7 +2087,7 @@ start_port(portid_t pid)
> >>>>  				return -1;
> >>>>  			}
> >>>>  		}
> >>>> -
> >>>> +		configure_rxtx_dump_callbacks(verbose_level);
> >>>>  		/* start port */
> >>>>  		if (rte_eth_dev_start(pi) < 0) {
> >>>>  			printf("Fail to start port %d\n", pi); diff --git
> >> a/app/test-
> >>>> pmd/testpmd.h b/app/test-pmd/testpmd.h index c07bee8..3da728c
> >> 100644
> >>>> --- a/app/test-pmd/testpmd.h
> >>>> +++ b/app/test-pmd/testpmd.h
> >>>> @@ -777,6 +777,7 @@ 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);
> >>>> +void configure_rxtx_dump_callbacks(uint16_t verbose);
> >>>>
> >>>>  /*
> >>>>   * Work-around of a compilation error with ICC on invocations of
> >>>> the diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> >>>> b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> >>>> index ca060e1..60855c6 100644
> >>>> --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> >>>> +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> >>>> @@ -449,7 +449,11 @@ Set the debug verbosity level::
> >>>>
> >>>>     testpmd> set verbose (level)
> >>>>
> >>>> -Currently the only available levels are 0 (silent except for
> >>>> error) and 1 (fully verbose).
> >>>> +Available levels are as following:
> >>>> +* ``0`` silent except for error.
> >>>> +* ``1`` fully verbose except for Tx packets.
> >>>> +* ``2`` fully verbose except for Rx packets.
> >>>> +* ``> 2`` fully verbose.
> >>>>
> >>>
> >>> The html output is probably not what you intended:
> >>>
> >>> Available levels are as following: * 0 silent except for error. * 1
> >>> fully verbose
> >> except for Tx packets. * 2 fully verbose except for Rx packets. * > 2
> >> fully verbose.
> >>>
> >>> A blank line is needed between each line.
> >>
> >> You a right, output is broken. I updated in the tree, just one blank
> >> line before list seems did the work.
> >> Raslan can you please confirm the latest doc in the tree?
> >
> > I see it's merged in dpdk-next/master but, it doesn't have the missing blank
> lines.
> 
> In repo it is:
> 
> "
>  Available levels are as following:
> 
> 
> 
> 
> 
> 
> 
>  * ``0`` silent except for error.
>  * ``1`` fully verbose except for Tx packets.
>  * ``2`` fully verbose except for Rx packets.
>  * ``> 2`` fully verbose.
> "
> 
> In original patch:
> "
>  +Available levels are as following:
>  +* ``0`` silent except for error.
>  +* ``1`` fully verbose except for Tx packets.
>  +* ``2`` fully verbose except for Rx packets.
>  +* ``> 2`` fully verbose.
> "
> 
> Please, compile both and observe the difference.
> 
> >
> >>
> >>>
> >>>>  set log
> >>>>  ~~~~~~~
> >>>> --
> >>>> 2.7.4
> >>>
> >>> Regards,
> >>>
> >>> Bernard.
> >>>
> >>>
> >
> >
> > Kindest regards,
> > Raslan Darawsheh
> >


^ permalink raw reply	[flat|nested] 47+ messages in thread

end of thread, other threads:[~2018-10-18  8:47 UTC | newest]

Thread overview: 47+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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         ` [dpdk-dev] [PATCH v6 2/3] app/testpmd: add packet dump callback functions Raslan Darawsheh
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

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).