DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v2 0/8] Misc enhancements in testpmd
@ 2016-09-09  7:55 Olivier Matz
  2016-09-09  7:55 ` [dpdk-dev] [PATCH v2 1/8] mbuf: add function to dump ol flag list Olivier Matz
                   ` (9 more replies)
  0 siblings, 10 replies; 40+ messages in thread
From: Olivier Matz @ 2016-09-09  7:55 UTC (permalink / raw)
  To: dev, pablo.de.lara.guarch

This patchset introduces several enhancements or minor fixes
in testpmd. It is targetted for v16.11, and applies on top of
software ptype v2 patchset [1].

These patches are useful to validate the virtio offload
patchset [2] (to be rebased).

[1] http://dpdk.org/ml/archives/dev/2016-August/045876.html
[2] http://dpdk.org/ml/archives/dev/2016-July/044404.html

changes v1 -> v2:
- rebase on top of sw ptype v2 patch

Olivier Matz (8):
  mbuf: add function to dump ol flag list
  app/testpmd: use new function to dump offload flags
  app/testpmd: dump rx flags in csum engine
  app/testpmd: add option to enable lro
  app/testpmd: do not change ip addrs in csum engine
  app/testpmd: display rx port in csum engine
  app/testpmd: don't use tso if packet is too small
  app/testpmd: hide segsize when unrelevant in csum engine

 app/test-pmd/csumonly.c                | 96 ++++++++++++----------------------
 app/test-pmd/parameters.c              |  4 ++
 app/test-pmd/rxonly.c                  | 15 +-----
 doc/guides/rel_notes/release_16_11.rst |  5 ++
 lib/librte_mbuf/rte_mbuf.c             | 91 ++++++++++++++++++++++++++++++++
 lib/librte_mbuf/rte_mbuf.h             | 28 ++++++++++
 lib/librte_mbuf/rte_mbuf_version.map   |  2 +
 7 files changed, 164 insertions(+), 77 deletions(-)

-- 
2.8.1

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

* [dpdk-dev] [PATCH v2 1/8] mbuf: add function to dump ol flag list
  2016-09-09  7:55 [dpdk-dev] [PATCH v2 0/8] Misc enhancements in testpmd Olivier Matz
@ 2016-09-09  7:55 ` Olivier Matz
  2016-10-05  6:45   ` De Lara Guarch, Pablo
  2016-10-06  8:42   ` [dpdk-dev] [PATCH v3] " Olivier Matz
  2016-09-09  7:55 ` [dpdk-dev] [PATCH v2 2/8] app/testpmd: use new function to dump offload flags Olivier Matz
                   ` (8 subsequent siblings)
  9 siblings, 2 replies; 40+ messages in thread
From: Olivier Matz @ 2016-09-09  7:55 UTC (permalink / raw)
  To: dev, pablo.de.lara.guarch

The functions rte_get_rx_ol_flag_name() and rte_get_tx_ol_flag_name()
can dump one flag, or set of flag that are part of the same mask (ex:
PKT_TX_UDP_CKSUM, part of PKT_TX_L4_MASK). But they are not designed to
dump the list of flags contained in mbuf->ol_flags.

This commit introduce new functions to do that. Similarly to the packet
type dump functions, the goal is to factorize the code that could be
used in several applications and reduce the risk of desynchronization
between the flags and the dump functions.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 doc/guides/rel_notes/release_16_11.rst |  5 ++
 lib/librte_mbuf/rte_mbuf.c             | 91 ++++++++++++++++++++++++++++++++++
 lib/librte_mbuf/rte_mbuf.h             | 28 +++++++++++
 lib/librte_mbuf/rte_mbuf_version.map   |  2 +
 4 files changed, 126 insertions(+)

diff --git a/doc/guides/rel_notes/release_16_11.rst b/doc/guides/rel_notes/release_16_11.rst
index 36111f3..a877e58 100644
--- a/doc/guides/rel_notes/release_16_11.rst
+++ b/doc/guides/rel_notes/release_16_11.rst
@@ -50,6 +50,11 @@ New Features
 
   Added new functions ``rte_get_ptype_*()`` to dump a packet type as a string.
 
+* **Added functions to dump the offload flags as a string.**
+
+  Added two new functions ``rte_get_rx_ol_flag_list()`` and
+  ``rte_get_tx_ol_flag_list()`` to dump offload flags as a string.
+
 Resolved Issues
 ---------------
 
diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index fb2b962..56f37e6 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -319,6 +319,53 @@ const char *rte_get_rx_ol_flag_name(uint64_t mask)
 	}
 }
 
+struct flag_mask {
+	uint64_t flag;
+	uint64_t mask;
+	const char *default_name;
+};
+
+/* write the list of rx ol flags in buffer buf */
+int rte_get_rx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
+{
+	const struct flag_mask rx_flags[] = {
+		{ PKT_RX_VLAN_PKT, PKT_RX_VLAN_PKT, NULL },
+		{ PKT_RX_RSS_HASH, PKT_RX_RSS_HASH, NULL },
+		{ PKT_RX_FDIR, PKT_RX_FDIR, NULL },
+		{ PKT_RX_L4_CKSUM_BAD, PKT_RX_L4_CKSUM_BAD, NULL },
+		{ PKT_RX_IP_CKSUM_BAD, PKT_RX_IP_CKSUM_BAD, NULL },
+		{ PKT_RX_EIP_CKSUM_BAD, PKT_RX_EIP_CKSUM_BAD, NULL },
+		{ PKT_RX_VLAN_STRIPPED, PKT_RX_VLAN_STRIPPED, NULL },
+		{ PKT_RX_IEEE1588_PTP, PKT_RX_IEEE1588_PTP, NULL },
+		{ PKT_RX_IEEE1588_TMST, PKT_RX_IEEE1588_TMST, NULL },
+		{ PKT_RX_QINQ_STRIPPED, PKT_RX_QINQ_STRIPPED, NULL },
+	};
+	const char *name;
+	unsigned int i;
+	int ret;
+
+	if (buflen == 0)
+		return -1;
+
+	buf[0] = '\0';
+	for (i = 0; i < RTE_DIM(rx_flags); i++) {
+		if ((mask & rx_flags[i].mask) != rx_flags[i].flag)
+			continue;
+		name = rte_get_rx_ol_flag_name(rx_flags[i].flag);
+		if (name == NULL)
+			name = rx_flags[i].default_name;
+		ret = snprintf(buf, buflen, "%s ", name);
+		if (ret < 0)
+			return -1;
+		if ((size_t)ret >= buflen)
+			return -1;
+		buf += ret;
+		buflen -= ret;
+	}
+
+	return 0;
+}
+
 /*
  * Get the name of a TX offload flag. Must be kept synchronized with flag
  * definitions in rte_mbuf.h.
@@ -341,3 +388,47 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask)
 	default: return NULL;
 	}
 }
+
+/* write the list of tx ol flags in buffer buf */
+int rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
+{
+	const struct flag_mask tx_flags[] = {
+		{ PKT_TX_VLAN_PKT, PKT_TX_VLAN_PKT, NULL },
+		{ PKT_TX_IP_CKSUM, PKT_TX_IP_CKSUM, NULL },
+		{ PKT_TX_TCP_CKSUM, PKT_TX_L4_MASK, NULL },
+		{ PKT_TX_SCTP_CKSUM, PKT_TX_L4_MASK, NULL },
+		{ PKT_TX_UDP_CKSUM, PKT_TX_L4_MASK, NULL },
+		{ PKT_TX_L4_NO_CKSUM, PKT_TX_L4_MASK, "PKT_TX_L4_NO_CKSUM" },
+		{ PKT_TX_IEEE1588_TMST, PKT_TX_IEEE1588_TMST, NULL },
+		{ PKT_TX_TCP_SEG, PKT_TX_TCP_SEG, NULL },
+		{ PKT_TX_IPV4, PKT_TX_IPV4, NULL },
+		{ PKT_TX_IPV6, PKT_TX_IPV6, NULL },
+		{ PKT_TX_OUTER_IP_CKSUM, PKT_TX_OUTER_IP_CKSUM, NULL },
+		{ PKT_TX_OUTER_IPV4, PKT_TX_OUTER_IPV4, NULL },
+		{ PKT_TX_OUTER_IPV6, PKT_TX_OUTER_IPV6, NULL },
+	};
+	const char *name;
+	unsigned int i;
+	int ret;
+
+	if (buflen == 0)
+		return -1;
+
+	buf[0] = '\0';
+	for (i = 0; i < RTE_DIM(tx_flags); i++) {
+		if ((mask & tx_flags[i].mask) != tx_flags[i].flag)
+			continue;
+		name = rte_get_tx_ol_flag_name(tx_flags[i].flag);
+		if (name == NULL)
+			name = tx_flags[i].default_name;
+		ret = snprintf(buf, buflen, "%s ", name);
+		if (ret < 0)
+			return -1;
+		if ((size_t)ret >= buflen)
+			return -1;
+		buf += ret;
+		buflen -= ret;
+	}
+
+	return 0;
+}
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 758af23..c42d798 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -240,6 +240,20 @@ extern "C" {
 const char *rte_get_rx_ol_flag_name(uint64_t mask);
 
 /**
+ * Dump the list of RX offload flags in a buffer
+ *
+ * @param mask
+ *   The mask describing the RX flags.
+ * @param buf
+ *   The ouput buffer.
+ * @param buflen
+ *   The length of the buffer.
+ * @return
+ *   0 on success, (-1) on error.
+ */
+int rte_get_rx_ol_flag_list(uint64_t mask, char *buf, size_t buflen);
+
+/**
  * Get the name of a TX offload flag
  *
  * @param mask
@@ -252,6 +266,20 @@ const char *rte_get_rx_ol_flag_name(uint64_t mask);
 const char *rte_get_tx_ol_flag_name(uint64_t mask);
 
 /**
+ * Dump the list of TX offload flags in a buffer
+ *
+ * @param mask
+ *   The mask describing the TX flags.
+ * @param buf
+ *   The ouput buffer.
+ * @param buflen
+ *   The length of the buffer.
+ * @return
+ *   0 on success, (-1) on error.
+ */
+int rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen);
+
+/**
  * Some NICs need at least 2KB buffer to RX standard Ethernet frame without
  * splitting it into multiple segments.
  * So, for mbufs that planned to be involved into RX/TX, the recommended
diff --git a/lib/librte_mbuf/rte_mbuf_version.map b/lib/librte_mbuf/rte_mbuf_version.map
index 5455ba6..6e2ea84 100644
--- a/lib/librte_mbuf/rte_mbuf_version.map
+++ b/lib/librte_mbuf/rte_mbuf_version.map
@@ -31,5 +31,7 @@ DPDK_16.11 {
 	rte_get_ptype_l4_name;
 	rte_get_ptype_name;
 	rte_get_ptype_tunnel_name;
+	rte_get_rx_ol_flag_list;
+	rte_get_tx_ol_flag_list;
 
 } DPDK_2.1;
-- 
2.8.1

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

* [dpdk-dev] [PATCH v2 2/8] app/testpmd: use new function to dump offload flags
  2016-09-09  7:55 [dpdk-dev] [PATCH v2 0/8] Misc enhancements in testpmd Olivier Matz
  2016-09-09  7:55 ` [dpdk-dev] [PATCH v2 1/8] mbuf: add function to dump ol flag list Olivier Matz
@ 2016-09-09  7:55 ` Olivier Matz
  2016-09-09  7:55 ` [dpdk-dev] [PATCH v2 3/8] app/testpmd: dump rx flags in csum engine Olivier Matz
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 40+ messages in thread
From: Olivier Matz @ 2016-09-09  7:55 UTC (permalink / raw)
  To: dev, pablo.de.lara.guarch

Use the functions introduced in the previous commit to dump the offload
flags.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 app/test-pmd/csumonly.c | 27 +++------------------------
 app/test-pmd/rxonly.c   | 15 ++-------------
 2 files changed, 5 insertions(+), 37 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index ac4bd8f..7cc51df 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -792,23 +792,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 
 		/* if verbose mode is enabled, dump debug info */
 		if (verbose_level > 0) {
-			struct {
-				uint64_t flag;
-				uint64_t mask;
-			} tx_flags[] = {
-				{ PKT_TX_IP_CKSUM, PKT_TX_IP_CKSUM },
-				{ PKT_TX_UDP_CKSUM, PKT_TX_L4_MASK },
-				{ PKT_TX_TCP_CKSUM, PKT_TX_L4_MASK },
-				{ PKT_TX_SCTP_CKSUM, PKT_TX_L4_MASK },
-				{ PKT_TX_IPV4, PKT_TX_IPV4 },
-				{ PKT_TX_IPV6, PKT_TX_IPV6 },
-				{ PKT_TX_OUTER_IP_CKSUM, PKT_TX_OUTER_IP_CKSUM },
-				{ PKT_TX_OUTER_IPV4, PKT_TX_OUTER_IPV4 },
-				{ PKT_TX_OUTER_IPV6, PKT_TX_OUTER_IPV6 },
-				{ PKT_TX_TCP_SEG, PKT_TX_TCP_SEG },
-			};
-			unsigned j;
-			const char *name;
+			char buf[256];
 
 			printf("-----------------\n");
 			printf("mbuf=%p, pkt_len=%u, nb_segs=%hhu:\n",
@@ -838,13 +822,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 					m->outer_l2_len, m->outer_l3_len);
 			if (info.tso_segsz != 0)
 				printf("tx: m->tso_segsz=%d\n", m->tso_segsz);
-			printf("tx: flags=");
-			for (j = 0; j < sizeof(tx_flags)/sizeof(*tx_flags); j++) {
-				name = rte_get_tx_ol_flag_name(tx_flags[j].flag);
-				if ((m->ol_flags & tx_flags[j].mask) ==
-					tx_flags[j].flag)
-					printf("%s ", name);
-			}
+			rte_get_tx_ol_flag_list(m->ol_flags, buf, sizeof(buf));
+			printf("tx: flags=%s", buf);
 			printf("\n");
 		}
 	}
diff --git a/app/test-pmd/rxonly.c b/app/test-pmd/rxonly.c
index b83d0c7..3886000 100644
--- a/app/test-pmd/rxonly.c
+++ b/app/test-pmd/rxonly.c
@@ -230,19 +230,8 @@ pkt_burst_receive(struct fwd_stream *fs)
 		}
 		printf(" - Receive queue=0x%x", (unsigned) fs->rx_queue);
 		printf("\n");
-		if (ol_flags != 0) {
-			unsigned rxf;
-			const char *name;
-
-			for (rxf = 0; rxf < sizeof(mb->ol_flags) * 8; rxf++) {
-				if ((ol_flags & (1ULL << rxf)) == 0)
-					continue;
-				name = rte_get_rx_ol_flag_name(1ULL << rxf);
-				if (name == NULL)
-					continue;
-				printf("  %s\n", name);
-			}
-		}
+		rte_get_rx_ol_flag_list(mb->ol_flags, buf, sizeof(buf));
+		printf("  ol_flags: %s\n", buf);
 		rte_pktmbuf_free(mb);
 	}
 
-- 
2.8.1

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

* [dpdk-dev] [PATCH v2 3/8] app/testpmd: dump rx flags in csum engine
  2016-09-09  7:55 [dpdk-dev] [PATCH v2 0/8] Misc enhancements in testpmd Olivier Matz
  2016-09-09  7:55 ` [dpdk-dev] [PATCH v2 1/8] mbuf: add function to dump ol flag list Olivier Matz
  2016-09-09  7:55 ` [dpdk-dev] [PATCH v2 2/8] app/testpmd: use new function to dump offload flags Olivier Matz
@ 2016-09-09  7:55 ` Olivier Matz
  2016-09-09  7:55 ` [dpdk-dev] [PATCH v2 4/8] app/testpmd: add option to enable lro Olivier Matz
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 40+ messages in thread
From: Olivier Matz @ 2016-09-09  7:55 UTC (permalink / raw)
  To: dev, pablo.de.lara.guarch

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 app/test-pmd/csumonly.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index 7cc51df..a484b18 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -641,7 +641,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 	uint16_t nb_rx;
 	uint16_t nb_tx;
 	uint16_t i;
-	uint64_t ol_flags;
+	uint64_t rx_ol_flags, tx_ol_flags;
 	uint16_t testpmd_ol_flags;
 	uint32_t retry;
 	uint32_t rx_bad_ip_csum;
@@ -681,13 +681,14 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 			rte_prefetch0(rte_pktmbuf_mtod(pkts_burst[i + 1],
 						       void *));
 
-		ol_flags = 0;
-		info.is_tunnel = 0;
 		m = pkts_burst[i];
+		info.is_tunnel = 0;
+		tx_ol_flags = 0;
+		rx_ol_flags = m->ol_flags;
 
 		/* Update the L3/L4 checksum error packet statistics */
-		rx_bad_ip_csum += ((m->ol_flags & PKT_RX_IP_CKSUM_BAD) != 0);
-		rx_bad_l4_csum += ((m->ol_flags & PKT_RX_L4_CKSUM_BAD) != 0);
+		rx_bad_ip_csum += ((rx_ol_flags & PKT_RX_IP_CKSUM_BAD) != 0);
+		rx_bad_l4_csum += ((rx_ol_flags & PKT_RX_L4_CKSUM_BAD) != 0);
 
 		/* step 1: dissect packet, parsing optional vlan, ip4/ip6, vxlan
 		 * and inner headers */
@@ -738,13 +739,13 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 		 * is configured, prepare the mbuf for TCP segmentation. */
 
 		/* process checksums of inner headers first */
-		ol_flags |= process_inner_cksums(l3_hdr, &info, testpmd_ol_flags);
+		tx_ol_flags |= process_inner_cksums(l3_hdr, &info, testpmd_ol_flags);
 
 		/* Then process outer headers if any. Note that the software
 		 * checksum will be wrong if one of the inner checksums is
 		 * processed in hardware. */
 		if (info.is_tunnel == 1) {
-			ol_flags |= process_outer_cksums(outer_l3_hdr, &info,
+			tx_ol_flags |= process_outer_cksums(outer_l3_hdr, &info,
 				testpmd_ol_flags);
 		}
 
@@ -778,7 +779,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 			m->l4_len = info.l4_len;
 		}
 		m->tso_segsz = info.tso_segsz;
-		m->ol_flags = ol_flags;
+		m->ol_flags = tx_ol_flags;
 
 		/* Do split & copy for the packet. */
 		if (tx_pkt_split != TX_PKT_SPLIT_OFF) {
@@ -798,10 +799,11 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 			printf("mbuf=%p, pkt_len=%u, nb_segs=%hhu:\n",
 				m, m->pkt_len, m->nb_segs);
 			/* dump rx parsed packet info */
+			rte_get_rx_ol_flag_list(rx_ol_flags, buf, sizeof(buf));
 			printf("rx: l2_len=%d ethertype=%x l3_len=%d "
-				"l4_proto=%d l4_len=%d\n",
+				"l4_proto=%d l4_len=%d flags=%s\n",
 				info.l2_len, rte_be_to_cpu_16(info.ethertype),
-				info.l3_len, info.l4_proto, info.l4_len);
+				info.l3_len, info.l4_proto, info.l4_len, buf);
 			if (info.is_tunnel == 1)
 				printf("rx: outer_l2_len=%d outer_ethertype=%x "
 					"outer_l3_len=%d\n", info.outer_l2_len,
-- 
2.8.1

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

* [dpdk-dev] [PATCH v2 4/8] app/testpmd: add option to enable lro
  2016-09-09  7:55 [dpdk-dev] [PATCH v2 0/8] Misc enhancements in testpmd Olivier Matz
                   ` (2 preceding siblings ...)
  2016-09-09  7:55 ` [dpdk-dev] [PATCH v2 3/8] app/testpmd: dump rx flags in csum engine Olivier Matz
@ 2016-09-09  7:55 ` Olivier Matz
  2016-10-05  6:26   ` De Lara Guarch, Pablo
  2016-10-06  8:44   ` [dpdk-dev] [PATCH v3] " Olivier Matz
  2016-09-09  7:55 ` [dpdk-dev] [PATCH v2 5/8] app/testpmd: do not change ip addrs in csum engine Olivier Matz
                   ` (5 subsequent siblings)
  9 siblings, 2 replies; 40+ messages in thread
From: Olivier Matz @ 2016-09-09  7:55 UTC (permalink / raw)
  To: dev, pablo.de.lara.guarch

Introduce a new argument '--enable-lro' to ask testpmd to enable the LRO
feature on enabled ports, like it's done for '--enable-rx-cksum' for
instance.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 app/test-pmd/parameters.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
index 8792c2c..612ad37 100644
--- a/app/test-pmd/parameters.c
+++ b/app/test-pmd/parameters.c
@@ -150,6 +150,7 @@ usage(char* progname)
 	       "If the drop-queue doesn't exist, the packet is dropped. "
 	       "By default drop-queue=127.\n");
 	printf("  --crc-strip: enable CRC stripping by hardware.\n");
+	printf("  --enable-lro: enable large receive offload.\n");
 	printf("  --enable-rx-cksum: enable rx hardware checksum offload.\n");
 	printf("  --disable-hw-vlan: disable hardware vlan.\n");
 	printf("  --disable-hw-vlan-filter: disable hardware vlan filter.\n");
@@ -525,6 +526,7 @@ launch_args_parse(int argc, char** argv)
 		{ "pkt-filter-size",            1, 0, 0 },
 		{ "pkt-filter-drop-queue",      1, 0, 0 },
 		{ "crc-strip",                  0, 0, 0 },
+		{ "enable-lro",                 0, 0, 0 },
 		{ "enable-rx-cksum",            0, 0, 0 },
 		{ "enable-scatter",             0, 0, 0 },
 		{ "disable-hw-vlan",            0, 0, 0 },
@@ -765,6 +767,8 @@ launch_args_parse(int argc, char** argv)
 			}
 			if (!strcmp(lgopts[opt_idx].name, "crc-strip"))
 				rx_mode.hw_strip_crc = 1;
+			if (!strcmp(lgopts[opt_idx].name, "enable-lro"))
+				rx_mode.enable_lro = 1;
 			if (!strcmp(lgopts[opt_idx].name, "enable-scatter"))
 				rx_mode.enable_scatter = 1;
 			if (!strcmp(lgopts[opt_idx].name, "enable-rx-cksum"))
-- 
2.8.1

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

* [dpdk-dev] [PATCH v2 5/8] app/testpmd: do not change ip addrs in csum engine
  2016-09-09  7:55 [dpdk-dev] [PATCH v2 0/8] Misc enhancements in testpmd Olivier Matz
                   ` (3 preceding siblings ...)
  2016-09-09  7:55 ` [dpdk-dev] [PATCH v2 4/8] app/testpmd: add option to enable lro Olivier Matz
@ 2016-09-09  7:55 ` Olivier Matz
  2016-09-09  7:55 ` [dpdk-dev] [PATCH v2 6/8] app/testpmd: display rx port " Olivier Matz
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 40+ messages in thread
From: Olivier Matz @ 2016-09-09  7:55 UTC (permalink / raw)
  To: dev, pablo.de.lara.guarch

The csum forward engine was updated to change the IP addresses in the
packet data in
commit 51f694dd40f5 ("app/testpmd: rework checksum forward engine")

This was done to ensure that the checksum is correctly reprocessed when
using hardware checksum offload. But the functions
process_inner_cksums() and process_outer_cksums() already reset the
checksum field to 0, so this is not necessary.

Moreover, this makes the engine more complex than needed, and prevents
to easily use it to forward traffic (like iperf) as it modifies the
packets.

This patch drops this behavior.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 app/test-pmd/csumonly.c | 30 ++++--------------------------
 1 file changed, 4 insertions(+), 26 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index a484b18..ee98724 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -318,21 +318,6 @@ parse_encap_ip(void *encap_ip, struct testpmd_offload_info *info)
 	info->l2_len = 0;
 }
 
-/* modify the IPv4 or IPv4 source address of a packet */
-static void
-change_ip_addresses(void *l3_hdr, uint16_t ethertype)
-{
-	struct ipv4_hdr *ipv4_hdr = l3_hdr;
-	struct ipv6_hdr *ipv6_hdr = l3_hdr;
-
-	if (ethertype == _htons(ETHER_TYPE_IPv4)) {
-		ipv4_hdr->src_addr =
-			rte_cpu_to_be_32(rte_be_to_cpu_32(ipv4_hdr->src_addr) + 1);
-	} else if (ethertype == _htons(ETHER_TYPE_IPv6)) {
-		ipv6_hdr->src_addr[15] = ipv6_hdr->src_addr[15] + 1;
-	}
-}
-
 /* if possible, calculate the checksum of a packet in hw or sw,
  * depending on the testpmd command line configuration */
 static uint64_t
@@ -609,7 +594,6 @@ pkt_copy_split(const struct rte_mbuf *pkt)
  * Receive a burst of packets, and for each packet:
  *  - parse packet, and try to recognize a supported packet type (1)
  *  - if it's not a supported packet type, don't touch the packet, else:
- *  - modify the IPs in inner headers and in outer headers if any
  *  - reprocess the checksum of all supported layers. This is done in SW
  *    or HW, depending on testpmd command line configuration
  *  - if TSO is enabled in testpmd command line, also flag the mbuf for TCP
@@ -726,20 +710,14 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 			l3_hdr = (char *)l3_hdr + info.outer_l3_len + info.l2_len;
 		}
 
-		/* step 2: change all source IPs (v4 or v6) so we need
-		 * to recompute the chksums even if they were correct */
-
-		change_ip_addresses(l3_hdr, info.ethertype);
-		if (info.is_tunnel == 1)
-			change_ip_addresses(outer_l3_hdr, info.outer_ethertype);
-
-		/* step 3: depending on user command line configuration,
+		/* step 2: depending on user command line configuration,
 		 * recompute checksum either in software or flag the
 		 * mbuf to offload the calculation to the NIC. If TSO
 		 * is configured, prepare the mbuf for TCP segmentation. */
 
 		/* process checksums of inner headers first */
-		tx_ol_flags |= process_inner_cksums(l3_hdr, &info, testpmd_ol_flags);
+		tx_ol_flags |= process_inner_cksums(l3_hdr, &info,
+			testpmd_ol_flags);
 
 		/* Then process outer headers if any. Note that the software
 		 * checksum will be wrong if one of the inner checksums is
@@ -749,7 +727,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 				testpmd_ol_flags);
 		}
 
-		/* step 4: fill the mbuf meta data (flags and header lengths) */
+		/* step 3: fill the mbuf meta data (flags and header lengths) */
 
 		if (info.is_tunnel == 1) {
 			if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) {
-- 
2.8.1

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

* [dpdk-dev] [PATCH v2 6/8] app/testpmd: display rx port in csum engine
  2016-09-09  7:55 [dpdk-dev] [PATCH v2 0/8] Misc enhancements in testpmd Olivier Matz
                   ` (4 preceding siblings ...)
  2016-09-09  7:55 ` [dpdk-dev] [PATCH v2 5/8] app/testpmd: do not change ip addrs in csum engine Olivier Matz
@ 2016-09-09  7:55 ` Olivier Matz
  2016-09-09  7:55 ` [dpdk-dev] [PATCH v2 7/8] app/testpmd: don't use tso if packet is too small Olivier Matz
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 40+ messages in thread
From: Olivier Matz @ 2016-09-09  7:55 UTC (permalink / raw)
  To: dev, pablo.de.lara.guarch

This information is useful when debugging, especially with
bidirectional traffic.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 app/test-pmd/csumonly.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index ee98724..35edf1d 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -774,8 +774,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 			char buf[256];
 
 			printf("-----------------\n");
-			printf("mbuf=%p, pkt_len=%u, nb_segs=%hhu:\n",
-				m, m->pkt_len, m->nb_segs);
+			printf("port=%u, mbuf=%p, pkt_len=%u, nb_segs=%hhu:\n",
+				fs->rx_port, m, m->pkt_len, m->nb_segs);
 			/* dump rx parsed packet info */
 			rte_get_rx_ol_flag_list(rx_ol_flags, buf, sizeof(buf));
 			printf("rx: l2_len=%d ethertype=%x l3_len=%d "
-- 
2.8.1

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

* [dpdk-dev] [PATCH v2 7/8] app/testpmd: don't use tso if packet is too small
  2016-09-09  7:55 [dpdk-dev] [PATCH v2 0/8] Misc enhancements in testpmd Olivier Matz
                   ` (5 preceding siblings ...)
  2016-09-09  7:55 ` [dpdk-dev] [PATCH v2 6/8] app/testpmd: display rx port " Olivier Matz
@ 2016-09-09  7:55 ` Olivier Matz
  2016-09-09  7:55 ` [dpdk-dev] [PATCH v2 8/8] app/testpmd: hide segsize when unrelevant in csum engine Olivier Matz
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 40+ messages in thread
From: Olivier Matz @ 2016-09-09  7:55 UTC (permalink / raw)
  To: dev, pablo.de.lara.guarch

Asking for TSO (TCP Segmentation Offload) on packets that are already
smaller than (headers + MSS) does not work, for instance on ixgbe.

Fix the csumonly engine to only set the TSO flag when a segmentation
offload is really required, i.e. when packet is large enough.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 app/test-pmd/csumonly.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index 35edf1d..9938150 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -102,6 +102,7 @@ struct testpmd_offload_info {
 	uint16_t outer_l3_len;
 	uint8_t outer_l4_proto;
 	uint16_t tso_segsz;
+	uint32_t pkt_len;
 };
 
 /* simplified GRE header */
@@ -329,13 +330,20 @@ process_inner_cksums(void *l3_hdr, const struct testpmd_offload_info *info,
 	struct tcp_hdr *tcp_hdr;
 	struct sctp_hdr *sctp_hdr;
 	uint64_t ol_flags = 0;
+	uint32_t max_pkt_len, tso_segsz = 0;
+
+	/* ensure packet is large enough to require tso */
+	max_pkt_len = info->l2_len + info->l3_len + info->l4_len +
+		info->tso_segsz;
+	if (info->tso_segsz != 0 && info->pkt_len > max_pkt_len)
+		tso_segsz = info->tso_segsz;
 
 	if (info->ethertype == _htons(ETHER_TYPE_IPv4)) {
 		ipv4_hdr = l3_hdr;
 		ipv4_hdr->hdr_checksum = 0;
 
 		ol_flags |= PKT_TX_IPV4;
-		if (info->tso_segsz != 0 && info->l4_proto == IPPROTO_TCP) {
+		if (tso_segsz != 0 && info->l4_proto == IPPROTO_TCP) {
 			ol_flags |= PKT_TX_IP_CKSUM;
 		} else {
 			if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM)
@@ -367,7 +375,7 @@ process_inner_cksums(void *l3_hdr, const struct testpmd_offload_info *info,
 	} else if (info->l4_proto == IPPROTO_TCP) {
 		tcp_hdr = (struct tcp_hdr *)((char *)l3_hdr + info->l3_len);
 		tcp_hdr->cksum = 0;
-		if (info->tso_segsz != 0) {
+		if (tso_segsz != 0) {
 			ol_flags |= PKT_TX_TCP_SEG;
 			tcp_hdr->cksum = get_psd_sum(l3_hdr, info->ethertype,
 				ol_flags);
@@ -667,6 +675,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 
 		m = pkts_burst[i];
 		info.is_tunnel = 0;
+		info.pkt_len = rte_pktmbuf_pkt_len(m);
 		tx_ol_flags = 0;
 		rx_ol_flags = m->ol_flags;
 
-- 
2.8.1

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

* [dpdk-dev] [PATCH v2 8/8] app/testpmd: hide segsize when unrelevant in csum engine
  2016-09-09  7:55 [dpdk-dev] [PATCH v2 0/8] Misc enhancements in testpmd Olivier Matz
                   ` (6 preceding siblings ...)
  2016-09-09  7:55 ` [dpdk-dev] [PATCH v2 7/8] app/testpmd: don't use tso if packet is too small Olivier Matz
@ 2016-09-09  7:55 ` Olivier Matz
  2016-10-03  9:02 ` [dpdk-dev] [PATCH v2 0/8] Misc enhancements in testpmd Olivier Matz
  2016-10-07 16:05 ` [dpdk-dev] [PATCH v5 " Olivier Matz
  9 siblings, 0 replies; 40+ messages in thread
From: Olivier Matz @ 2016-09-09  7:55 UTC (permalink / raw)
  To: dev, pablo.de.lara.guarch

When TSO is not asked, hide the segment size.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 app/test-pmd/csumonly.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index 9938150..4b36d74 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -809,7 +809,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 				(testpmd_ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
 				printf("tx: m->outer_l2_len=%d m->outer_l3_len=%d\n",
 					m->outer_l2_len, m->outer_l3_len);
-			if (info.tso_segsz != 0)
+			if (info.tso_segsz != 0 && (m->ol_flags & PKT_TX_TCP_SEG))
 				printf("tx: m->tso_segsz=%d\n", m->tso_segsz);
 			rte_get_tx_ol_flag_list(m->ol_flags, buf, sizeof(buf));
 			printf("tx: flags=%s", buf);
-- 
2.8.1

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

* Re: [dpdk-dev] [PATCH v2 0/8] Misc enhancements in testpmd
  2016-09-09  7:55 [dpdk-dev] [PATCH v2 0/8] Misc enhancements in testpmd Olivier Matz
                   ` (7 preceding siblings ...)
  2016-09-09  7:55 ` [dpdk-dev] [PATCH v2 8/8] app/testpmd: hide segsize when unrelevant in csum engine Olivier Matz
@ 2016-10-03  9:02 ` Olivier Matz
  2016-10-07 16:05 ` [dpdk-dev] [PATCH v5 " Olivier Matz
  9 siblings, 0 replies; 40+ messages in thread
From: Olivier Matz @ 2016-10-03  9:02 UTC (permalink / raw)
  To: dev, pablo.de.lara.guarch

Hello,

On 09/09/2016 09:55 AM, Olivier Matz wrote:
> This patchset introduces several enhancements or minor fixes
> in testpmd. It is targetted for v16.11, and applies on top of
> software ptype v2 patchset [1].
> 
> These patches are useful to validate the virtio offload
> patchset [2] (to be rebased).
> 
> [1] http://dpdk.org/ml/archives/dev/2016-August/045876.html
> [2] http://dpdk.org/ml/archives/dev/2016-July/044404.html
> 
> changes v1 -> v2:
> - rebase on top of sw ptype v2 patch

Any comment on this patchset?


Thanks,
Olivier

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

* Re: [dpdk-dev] [PATCH v2 4/8] app/testpmd: add option to enable lro
  2016-09-09  7:55 ` [dpdk-dev] [PATCH v2 4/8] app/testpmd: add option to enable lro Olivier Matz
@ 2016-10-05  6:26   ` De Lara Guarch, Pablo
  2016-10-05 14:18     ` Olivier Matz
  2016-10-06  8:44   ` [dpdk-dev] [PATCH v3] " Olivier Matz
  1 sibling, 1 reply; 40+ messages in thread
From: De Lara Guarch, Pablo @ 2016-10-05  6:26 UTC (permalink / raw)
  To: Olivier Matz, dev

Hi Olivier,

> -----Original Message-----
> From: Olivier Matz [mailto:olivier.matz@6wind.com]
> Sent: Friday, September 09, 2016 12:56 AM
> To: dev@dpdk.org; De Lara Guarch, Pablo
> Subject: [PATCH v2 4/8] app/testpmd: add option to enable lro
> 
> Introduce a new argument '--enable-lro' to ask testpmd to enable the LRO
> feature on enabled ports, like it's done for '--enable-rx-cksum' for
> instance.
> 
> Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
> ---
>  app/test-pmd/parameters.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
> index 8792c2c..612ad37 100644
> --- a/app/test-pmd/parameters.c
> +++ b/app/test-pmd/parameters.c
> @@ -150,6 +150,7 @@ usage(char* progname)
>  	       "If the drop-queue doesn't exist, the packet is dropped. "
>  	       "By default drop-queue=127.\n");
>  	printf("  --crc-strip: enable CRC stripping by hardware.\n");
> +	printf("  --enable-lro: enable large receive offload.\n");
>  	printf("  --enable-rx-cksum: enable rx hardware checksum
> offload.\n");
>  	printf("  --disable-hw-vlan: disable hardware vlan.\n");
>  	printf("  --disable-hw-vlan-filter: disable hardware vlan filter.\n");
> @@ -525,6 +526,7 @@ launch_args_parse(int argc, char** argv)
>  		{ "pkt-filter-size",            1, 0, 0 },
>  		{ "pkt-filter-drop-queue",      1, 0, 0 },
>  		{ "crc-strip",                  0, 0, 0 },
> +		{ "enable-lro",                 0, 0, 0 },
>  		{ "enable-rx-cksum",            0, 0, 0 },
>  		{ "enable-scatter",             0, 0, 0 },
>  		{ "disable-hw-vlan",            0, 0, 0 },
> @@ -765,6 +767,8 @@ launch_args_parse(int argc, char** argv)
>  			}
>  			if (!strcmp(lgopts[opt_idx].name, "crc-strip"))
>  				rx_mode.hw_strip_crc = 1;
> +			if (!strcmp(lgopts[opt_idx].name, "enable-lro"))
> +				rx_mode.enable_lro = 1;
>  			if (!strcmp(lgopts[opt_idx].name, "enable-scatter"))
>  				rx_mode.enable_scatter = 1;
>  			if (!strcmp(lgopts[opt_idx].name, "enable-rx-cksum"))
> --
> 2.8.1

Could you add this new parameter in the testpmd documentation?

Thanks,
Pablo

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

* Re: [dpdk-dev] [PATCH v2 1/8] mbuf: add function to dump ol flag list
  2016-09-09  7:55 ` [dpdk-dev] [PATCH v2 1/8] mbuf: add function to dump ol flag list Olivier Matz
@ 2016-10-05  6:45   ` De Lara Guarch, Pablo
  2016-10-05 14:19     ` Olivier Matz
  2016-10-06  8:42   ` [dpdk-dev] [PATCH v3] " Olivier Matz
  1 sibling, 1 reply; 40+ messages in thread
From: De Lara Guarch, Pablo @ 2016-10-05  6:45 UTC (permalink / raw)
  To: Olivier Matz, dev

Hi Olivier,

> -----Original Message-----
> From: Olivier Matz [mailto:olivier.matz@6wind.com]
> Sent: Friday, September 09, 2016 12:55 AM
> To: dev@dpdk.org; De Lara Guarch, Pablo
> Subject: [PATCH v2 1/8] mbuf: add function to dump ol flag list
> 
> The functions rte_get_rx_ol_flag_name() and rte_get_tx_ol_flag_name()
> can dump one flag, or set of flag that are part of the same mask (ex:
> PKT_TX_UDP_CKSUM, part of PKT_TX_L4_MASK). But they are not designed
> to
> dump the list of flags contained in mbuf->ol_flags.
> 
> This commit introduce new functions to do that. Similarly to the packet
> type dump functions, the goal is to factorize the code that could be
> used in several applications and reduce the risk of desynchronization
> between the flags and the dump functions.
> 
> Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
> ---
>  doc/guides/rel_notes/release_16_11.rst |  5 ++
>  lib/librte_mbuf/rte_mbuf.c             | 91
> ++++++++++++++++++++++++++++++++++
>  lib/librte_mbuf/rte_mbuf.h             | 28 +++++++++++
>  lib/librte_mbuf/rte_mbuf_version.map   |  2 +
>  4 files changed, 126 insertions(+)
> 
> diff --git a/doc/guides/rel_notes/release_16_11.rst
> b/doc/guides/rel_notes/release_16_11.rst
> index 36111f3..a877e58 100644
> --- a/doc/guides/rel_notes/release_16_11.rst
> +++ b/doc/guides/rel_notes/release_16_11.rst
> @@ -50,6 +50,11 @@ New Features
> 
>    Added new functions ``rte_get_ptype_*()`` to dump a packet type as a
> string.
> 
> +* **Added functions to dump the offload flags as a string.**
> +
> +  Added two new functions ``rte_get_rx_ol_flag_list()`` and
> +  ``rte_get_tx_ol_flag_list()`` to dump offload flags as a string.
> +
>  Resolved Issues
>  ---------------
> 
> diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
> index fb2b962..56f37e6 100644
> --- a/lib/librte_mbuf/rte_mbuf.c
> +++ b/lib/librte_mbuf/rte_mbuf.c
> @@ -319,6 +319,53 @@ const char *rte_get_rx_ol_flag_name(uint64_t mask)
>  	}
>  }
> 
> +struct flag_mask {
> +	uint64_t flag;
> +	uint64_t mask;
> +	const char *default_name;
> +};
> +
> +/* write the list of rx ol flags in buffer buf */
> +int rte_get_rx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)

Return type should go in a separate line (same case in the other function).

Thanks,
Pablo

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

* Re: [dpdk-dev] [PATCH v2 4/8] app/testpmd: add option to enable lro
  2016-10-05  6:26   ` De Lara Guarch, Pablo
@ 2016-10-05 14:18     ` Olivier Matz
  0 siblings, 0 replies; 40+ messages in thread
From: Olivier Matz @ 2016-10-05 14:18 UTC (permalink / raw)
  To: De Lara Guarch, Pablo, dev

Hi Pablo,

On 10/05/2016 08:26 AM, De Lara Guarch, Pablo wrote:
> Hi Olivier,
> 
>> -----Original Message-----
>> From: Olivier Matz [mailto:olivier.matz@6wind.com]
>> Sent: Friday, September 09, 2016 12:56 AM
>> To: dev@dpdk.org; De Lara Guarch, Pablo
>> Subject: [PATCH v2 4/8] app/testpmd: add option to enable lro
>>
>> Introduce a new argument '--enable-lro' to ask testpmd to enable the LRO
>> feature on enabled ports, like it's done for '--enable-rx-cksum' for
>> instance.
>>
>> Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
>> ---
>>  app/test-pmd/parameters.c | 4 ++++
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
>> index 8792c2c..612ad37 100644
>> --- a/app/test-pmd/parameters.c
>> +++ b/app/test-pmd/parameters.c
>> @@ -150,6 +150,7 @@ usage(char* progname)
>>  	       "If the drop-queue doesn't exist, the packet is dropped. "
>>  	       "By default drop-queue=127.\n");
>>  	printf("  --crc-strip: enable CRC stripping by hardware.\n");
>> +	printf("  --enable-lro: enable large receive offload.\n");
>>  	printf("  --enable-rx-cksum: enable rx hardware checksum
>> offload.\n");
>>  	printf("  --disable-hw-vlan: disable hardware vlan.\n");
>>  	printf("  --disable-hw-vlan-filter: disable hardware vlan filter.\n");
>> @@ -525,6 +526,7 @@ launch_args_parse(int argc, char** argv)
>>  		{ "pkt-filter-size",            1, 0, 0 },
>>  		{ "pkt-filter-drop-queue",      1, 0, 0 },
>>  		{ "crc-strip",                  0, 0, 0 },
>> +		{ "enable-lro",                 0, 0, 0 },
>>  		{ "enable-rx-cksum",            0, 0, 0 },
>>  		{ "enable-scatter",             0, 0, 0 },
>>  		{ "disable-hw-vlan",            0, 0, 0 },
>> @@ -765,6 +767,8 @@ launch_args_parse(int argc, char** argv)
>>  			}
>>  			if (!strcmp(lgopts[opt_idx].name, "crc-strip"))
>>  				rx_mode.hw_strip_crc = 1;
>> +			if (!strcmp(lgopts[opt_idx].name, "enable-lro"))
>> +				rx_mode.enable_lro = 1;
>>  			if (!strcmp(lgopts[opt_idx].name, "enable-scatter"))
>>  				rx_mode.enable_scatter = 1;
>>  			if (!strcmp(lgopts[opt_idx].name, "enable-rx-cksum"))
>> --
>> 2.8.1
> 
> Could you add this new parameter in the testpmd documentation?

Yes, I'll do it.


Thanks,
Olivier

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

* Re: [dpdk-dev] [PATCH v2 1/8] mbuf: add function to dump ol flag list
  2016-10-05  6:45   ` De Lara Guarch, Pablo
@ 2016-10-05 14:19     ` Olivier Matz
  0 siblings, 0 replies; 40+ messages in thread
From: Olivier Matz @ 2016-10-05 14:19 UTC (permalink / raw)
  To: De Lara Guarch, Pablo, dev

Hi Pablo,

On 10/05/2016 08:45 AM, De Lara Guarch, Pablo wrote:
> Hi Olivier,
> 
>> -----Original Message-----
>> diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
>> index fb2b962..56f37e6 100644
>> --- a/lib/librte_mbuf/rte_mbuf.c
>> +++ b/lib/librte_mbuf/rte_mbuf.c
>> @@ -319,6 +319,53 @@ const char *rte_get_rx_ol_flag_name(uint64_t mask)
>>  	}
>>  }
>>
>> +struct flag_mask {
>> +	uint64_t flag;
>> +	uint64_t mask;
>> +	const char *default_name;
>> +};
>> +
>> +/* write the list of rx ol flags in buffer buf */
>> +int rte_get_rx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
> 
> Return type should go in a separate line (same case in the other function).

I'll fix that too, thanks for reviewing.

Olivier

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

* [dpdk-dev] [PATCH v3] mbuf: add function to dump ol flag list
  2016-09-09  7:55 ` [dpdk-dev] [PATCH v2 1/8] mbuf: add function to dump ol flag list Olivier Matz
  2016-10-05  6:45   ` De Lara Guarch, Pablo
@ 2016-10-06  8:42   ` Olivier Matz
  2016-10-07  3:51     ` De Lara Guarch, Pablo
  1 sibling, 1 reply; 40+ messages in thread
From: Olivier Matz @ 2016-10-06  8:42 UTC (permalink / raw)
  To: dev, pablo.de.lara.guarch

The functions rte_get_rx_ol_flag_name() and rte_get_tx_ol_flag_name()
can dump one flag, or set of flag that are part of the same mask (ex:
PKT_TX_UDP_CKSUM, part of PKT_TX_L4_MASK). But they are not designed to
dump the list of flags contained in mbuf->ol_flags.

This commit introduce new functions to do that. Similarly to the packet
type dump functions, the goal is to factorize the code that could be
used in several applications and reduce the risk of desynchronization
between the flags and the dump functions.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---

v2 -> v3:
- Move return type on a separate line in function definitions

 doc/guides/rel_notes/release_16_11.rst |  5 ++
 lib/librte_mbuf/rte_mbuf.c             | 93 ++++++++++++++++++++++++++++++++++
 lib/librte_mbuf/rte_mbuf.h             | 28 ++++++++++
 lib/librte_mbuf/rte_mbuf_version.map   |  2 +
 4 files changed, 128 insertions(+)

diff --git a/doc/guides/rel_notes/release_16_11.rst b/doc/guides/rel_notes/release_16_11.rst
index 40c09ca..3d3c417 100644
--- a/doc/guides/rel_notes/release_16_11.rst
+++ b/doc/guides/rel_notes/release_16_11.rst
@@ -50,6 +50,11 @@ New Features
 
   Added new functions ``rte_get_ptype_*()`` to dump a packet type as a string.
 
+* **Added functions to dump the offload flags as a string.**
+
+  Added two new functions ``rte_get_rx_ol_flag_list()`` and
+  ``rte_get_tx_ol_flag_list()`` to dump offload flags as a string.
+
 Resolved Issues
 ---------------
 
diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index 37fd72b..37691ca 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -317,6 +317,54 @@ const char *rte_get_rx_ol_flag_name(uint64_t mask)
 	}
 }
 
+struct flag_mask {
+	uint64_t flag;
+	uint64_t mask;
+	const char *default_name;
+};
+
+/* write the list of rx ol flags in buffer buf */
+int
+rte_get_rx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
+{
+	const struct flag_mask rx_flags[] = {
+		{ PKT_RX_VLAN_PKT, PKT_RX_VLAN_PKT, NULL },
+		{ PKT_RX_RSS_HASH, PKT_RX_RSS_HASH, NULL },
+		{ PKT_RX_FDIR, PKT_RX_FDIR, NULL },
+		{ PKT_RX_L4_CKSUM_BAD, PKT_RX_L4_CKSUM_BAD, NULL },
+		{ PKT_RX_IP_CKSUM_BAD, PKT_RX_IP_CKSUM_BAD, NULL },
+		{ PKT_RX_EIP_CKSUM_BAD, PKT_RX_EIP_CKSUM_BAD, NULL },
+		{ PKT_RX_VLAN_STRIPPED, PKT_RX_VLAN_STRIPPED, NULL },
+		{ PKT_RX_IEEE1588_PTP, PKT_RX_IEEE1588_PTP, NULL },
+		{ PKT_RX_IEEE1588_TMST, PKT_RX_IEEE1588_TMST, NULL },
+		{ PKT_RX_QINQ_STRIPPED, PKT_RX_QINQ_STRIPPED, NULL },
+	};
+	const char *name;
+	unsigned int i;
+	int ret;
+
+	if (buflen == 0)
+		return -1;
+
+	buf[0] = '\0';
+	for (i = 0; i < RTE_DIM(rx_flags); i++) {
+		if ((mask & rx_flags[i].mask) != rx_flags[i].flag)
+			continue;
+		name = rte_get_rx_ol_flag_name(rx_flags[i].flag);
+		if (name == NULL)
+			name = rx_flags[i].default_name;
+		ret = snprintf(buf, buflen, "%s ", name);
+		if (ret < 0)
+			return -1;
+		if ((size_t)ret >= buflen)
+			return -1;
+		buf += ret;
+		buflen -= ret;
+	}
+
+	return 0;
+}
+
 /*
  * Get the name of a TX offload flag. Must be kept synchronized with flag
  * definitions in rte_mbuf.h.
@@ -339,3 +387,48 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask)
 	default: return NULL;
 	}
 }
+
+/* write the list of tx ol flags in buffer buf */
+int
+rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
+{
+	const struct flag_mask tx_flags[] = {
+		{ PKT_TX_VLAN_PKT, PKT_TX_VLAN_PKT, NULL },
+		{ PKT_TX_IP_CKSUM, PKT_TX_IP_CKSUM, NULL },
+		{ PKT_TX_TCP_CKSUM, PKT_TX_L4_MASK, NULL },
+		{ PKT_TX_SCTP_CKSUM, PKT_TX_L4_MASK, NULL },
+		{ PKT_TX_UDP_CKSUM, PKT_TX_L4_MASK, NULL },
+		{ PKT_TX_L4_NO_CKSUM, PKT_TX_L4_MASK, "PKT_TX_L4_NO_CKSUM" },
+		{ PKT_TX_IEEE1588_TMST, PKT_TX_IEEE1588_TMST, NULL },
+		{ PKT_TX_TCP_SEG, PKT_TX_TCP_SEG, NULL },
+		{ PKT_TX_IPV4, PKT_TX_IPV4, NULL },
+		{ PKT_TX_IPV6, PKT_TX_IPV6, NULL },
+		{ PKT_TX_OUTER_IP_CKSUM, PKT_TX_OUTER_IP_CKSUM, NULL },
+		{ PKT_TX_OUTER_IPV4, PKT_TX_OUTER_IPV4, NULL },
+		{ PKT_TX_OUTER_IPV6, PKT_TX_OUTER_IPV6, NULL },
+	};
+	const char *name;
+	unsigned int i;
+	int ret;
+
+	if (buflen == 0)
+		return -1;
+
+	buf[0] = '\0';
+	for (i = 0; i < RTE_DIM(tx_flags); i++) {
+		if ((mask & tx_flags[i].mask) != tx_flags[i].flag)
+			continue;
+		name = rte_get_tx_ol_flag_name(tx_flags[i].flag);
+		if (name == NULL)
+			name = tx_flags[i].default_name;
+		ret = snprintf(buf, buflen, "%s ", name);
+		if (ret < 0)
+			return -1;
+		if ((size_t)ret >= buflen)
+			return -1;
+		buf += ret;
+		buflen -= ret;
+	}
+
+	return 0;
+}
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 1451ec3..5e349e7 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -240,6 +240,20 @@ extern "C" {
 const char *rte_get_rx_ol_flag_name(uint64_t mask);
 
 /**
+ * Dump the list of RX offload flags in a buffer
+ *
+ * @param mask
+ *   The mask describing the RX flags.
+ * @param buf
+ *   The ouput buffer.
+ * @param buflen
+ *   The length of the buffer.
+ * @return
+ *   0 on success, (-1) on error.
+ */
+int rte_get_rx_ol_flag_list(uint64_t mask, char *buf, size_t buflen);
+
+/**
  * Get the name of a TX offload flag
  *
  * @param mask
@@ -252,6 +266,20 @@ const char *rte_get_rx_ol_flag_name(uint64_t mask);
 const char *rte_get_tx_ol_flag_name(uint64_t mask);
 
 /**
+ * Dump the list of TX offload flags in a buffer
+ *
+ * @param mask
+ *   The mask describing the TX flags.
+ * @param buf
+ *   The ouput buffer.
+ * @param buflen
+ *   The length of the buffer.
+ * @return
+ *   0 on success, (-1) on error.
+ */
+int rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen);
+
+/**
  * Some NICs need at least 2KB buffer to RX standard Ethernet frame without
  * splitting it into multiple segments.
  * So, for mbufs that planned to be involved into RX/TX, the recommended
diff --git a/lib/librte_mbuf/rte_mbuf_version.map b/lib/librte_mbuf/rte_mbuf_version.map
index 5455ba6..6e2ea84 100644
--- a/lib/librte_mbuf/rte_mbuf_version.map
+++ b/lib/librte_mbuf/rte_mbuf_version.map
@@ -31,5 +31,7 @@ DPDK_16.11 {
 	rte_get_ptype_l4_name;
 	rte_get_ptype_name;
 	rte_get_ptype_tunnel_name;
+	rte_get_rx_ol_flag_list;
+	rte_get_tx_ol_flag_list;
 
 } DPDK_2.1;
-- 
2.8.1

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

* [dpdk-dev] [PATCH v3] app/testpmd: add option to enable lro
  2016-09-09  7:55 ` [dpdk-dev] [PATCH v2 4/8] app/testpmd: add option to enable lro Olivier Matz
  2016-10-05  6:26   ` De Lara Guarch, Pablo
@ 2016-10-06  8:44   ` Olivier Matz
  2016-10-06  8:47     ` [dpdk-dev] [PATCH v4] " Olivier Matz
  1 sibling, 1 reply; 40+ messages in thread
From: Olivier Matz @ 2016-10-06  8:44 UTC (permalink / raw)
  To: dev, pablo.de.lara.guarch

Introduce a new argument '--enable-lro' to ask testpmd to enable the LRO
feature on enabled ports, like it's done for '--enable-rx-cksum' for
instance.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---

v2 -> v3:
- add documentation for this new option

 app/test-pmd/parameters.c             | 4 ++++
 doc/guides/testpmd_app_ug/run_app.rst | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
index 6a6a07e..c45f78a 100644
--- a/app/test-pmd/parameters.c
+++ b/app/test-pmd/parameters.c
@@ -149,6 +149,7 @@ usage(char* progname)
 	       "If the drop-queue doesn't exist, the packet is dropped. "
 	       "By default drop-queue=127.\n");
 	printf("  --crc-strip: enable CRC stripping by hardware.\n");
+	printf("  --enable-lro: enable large receive offload.\n");
 	printf("  --enable-rx-cksum: enable rx hardware checksum offload.\n");
 	printf("  --disable-hw-vlan: disable hardware vlan.\n");
 	printf("  --disable-hw-vlan-filter: disable hardware vlan filter.\n");
@@ -524,6 +525,7 @@ launch_args_parse(int argc, char** argv)
 		{ "pkt-filter-size",            1, 0, 0 },
 		{ "pkt-filter-drop-queue",      1, 0, 0 },
 		{ "crc-strip",                  0, 0, 0 },
+		{ "enable-lro",                 0, 0, 0 },
 		{ "enable-rx-cksum",            0, 0, 0 },
 		{ "enable-scatter",             0, 0, 0 },
 		{ "disable-hw-vlan",            0, 0, 0 },
@@ -764,6 +766,8 @@ launch_args_parse(int argc, char** argv)
 			}
 			if (!strcmp(lgopts[opt_idx].name, "crc-strip"))
 				rx_mode.hw_strip_crc = 1;
+			if (!strcmp(lgopts[opt_idx].name, "enable-lro"))
+				rx_mode.enable_lro = 1;
 			if (!strcmp(lgopts[opt_idx].name, "enable-scatter"))
 				rx_mode.enable_scatter = 1;
 			if (!strcmp(lgopts[opt_idx].name, "enable-rx-cksum"))
diff --git a/doc/guides/testpmd_app_ug/run_app.rst b/doc/guides/testpmd_app_ug/run_app.rst
index 7712bd2..4060036 100644
--- a/doc/guides/testpmd_app_ug/run_app.rst
+++ b/doc/guides/testpmd_app_ug/run_app.rst
@@ -285,6 +285,10 @@ The commandline options are:
 
     Enable hardware CRC stripping.
 
+*   ``enable-lro``
+
+    Enable large receive offload.
+
 *   ``--enable-rx-cksum``
 
     Enable hardware RX checksum offload.
-- 
2.8.1

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

* [dpdk-dev] [PATCH v4] app/testpmd: add option to enable lro
  2016-10-06  8:44   ` [dpdk-dev] [PATCH v3] " Olivier Matz
@ 2016-10-06  8:47     ` Olivier Matz
  0 siblings, 0 replies; 40+ messages in thread
From: Olivier Matz @ 2016-10-06  8:47 UTC (permalink / raw)
  To: dev, pablo.de.lara.guarch

Introduce a new argument '--enable-lro' to ask testpmd to enable the LRO
feature on enabled ports, like it's done for '--enable-rx-cksum' for
instance.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---

v3 -> v4:
- fix typo in documentation

 app/test-pmd/parameters.c             | 4 ++++
 doc/guides/testpmd_app_ug/run_app.rst | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
index 6a6a07e..c45f78a 100644
--- a/app/test-pmd/parameters.c
+++ b/app/test-pmd/parameters.c
@@ -149,6 +149,7 @@ usage(char* progname)
 	       "If the drop-queue doesn't exist, the packet is dropped. "
 	       "By default drop-queue=127.\n");
 	printf("  --crc-strip: enable CRC stripping by hardware.\n");
+	printf("  --enable-lro: enable large receive offload.\n");
 	printf("  --enable-rx-cksum: enable rx hardware checksum offload.\n");
 	printf("  --disable-hw-vlan: disable hardware vlan.\n");
 	printf("  --disable-hw-vlan-filter: disable hardware vlan filter.\n");
@@ -524,6 +525,7 @@ launch_args_parse(int argc, char** argv)
 		{ "pkt-filter-size",            1, 0, 0 },
 		{ "pkt-filter-drop-queue",      1, 0, 0 },
 		{ "crc-strip",                  0, 0, 0 },
+		{ "enable-lro",                 0, 0, 0 },
 		{ "enable-rx-cksum",            0, 0, 0 },
 		{ "enable-scatter",             0, 0, 0 },
 		{ "disable-hw-vlan",            0, 0, 0 },
@@ -764,6 +766,8 @@ launch_args_parse(int argc, char** argv)
 			}
 			if (!strcmp(lgopts[opt_idx].name, "crc-strip"))
 				rx_mode.hw_strip_crc = 1;
+			if (!strcmp(lgopts[opt_idx].name, "enable-lro"))
+				rx_mode.enable_lro = 1;
 			if (!strcmp(lgopts[opt_idx].name, "enable-scatter"))
 				rx_mode.enable_scatter = 1;
 			if (!strcmp(lgopts[opt_idx].name, "enable-rx-cksum"))
diff --git a/doc/guides/testpmd_app_ug/run_app.rst b/doc/guides/testpmd_app_ug/run_app.rst
index 7712bd2..55c7ac0 100644
--- a/doc/guides/testpmd_app_ug/run_app.rst
+++ b/doc/guides/testpmd_app_ug/run_app.rst
@@ -285,6 +285,10 @@ The commandline options are:
 
     Enable hardware CRC stripping.
 
+*   ``--enable-lro``
+
+    Enable large receive offload.
+
 *   ``--enable-rx-cksum``
 
     Enable hardware RX checksum offload.
-- 
2.8.1

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

* Re: [dpdk-dev] [PATCH v3] mbuf: add function to dump ol flag list
  2016-10-06  8:42   ` [dpdk-dev] [PATCH v3] " Olivier Matz
@ 2016-10-07  3:51     ` De Lara Guarch, Pablo
  2016-10-07 15:39       ` Olivier Matz
  0 siblings, 1 reply; 40+ messages in thread
From: De Lara Guarch, Pablo @ 2016-10-07  3:51 UTC (permalink / raw)
  To: Olivier Matz, dev



> -----Original Message-----
> From: Olivier Matz [mailto:olivier.matz@6wind.com]
> Sent: Thursday, October 06, 2016 1:43 AM
> To: dev@dpdk.org; De Lara Guarch, Pablo
> Subject: [PATCH v3] mbuf: add function to dump ol flag list
> 
> The functions rte_get_rx_ol_flag_name() and rte_get_tx_ol_flag_name()
> can dump one flag, or set of flag that are part of the same mask (ex:
> PKT_TX_UDP_CKSUM, part of PKT_TX_L4_MASK). But they are not designed
> to
> dump the list of flags contained in mbuf->ol_flags.
> 
> This commit introduce new functions to do that. Similarly to the packet
> type dump functions, the goal is to factorize the code that could be
> used in several applications and reduce the risk of desynchronization
> between the flags and the dump functions.
> 
> Signed-off-by: Olivier Matz <olivier.matz@6wind.com>

Hi Olivier,

Sorry, I missed a typo in this patch: "ouput" -> "output".

Also, check-git-log.sh is complaining about two patches:

Wrong headline lowercase:
        app/testpmd: dump rx flags in csum engine
        app/testpmd: display rx port in csum engine

Lastly, could you send another version of the patchset (including patches without any modifications).
In my opinion, it is a bit difficult to apply the patchset, because Patchwork doesn't tell me
that this patch is the first patch of the patchset.

The rest of the patches look ok to me.

Thanks,
Pablo

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

* Re: [dpdk-dev] [PATCH v3] mbuf: add function to dump ol flag list
  2016-10-07  3:51     ` De Lara Guarch, Pablo
@ 2016-10-07 15:39       ` Olivier Matz
  0 siblings, 0 replies; 40+ messages in thread
From: Olivier Matz @ 2016-10-07 15:39 UTC (permalink / raw)
  To: De Lara Guarch, Pablo, dev

Hi Pablo,

On 10/07/2016 05:51 AM, De Lara Guarch, Pablo wrote:
> 
> 
>> -----Original Message-----
>> From: Olivier Matz [mailto:olivier.matz@6wind.com]
>> Sent: Thursday, October 06, 2016 1:43 AM
>> To: dev@dpdk.org; De Lara Guarch, Pablo
>> Subject: [PATCH v3] mbuf: add function to dump ol flag list
>>
>> The functions rte_get_rx_ol_flag_name() and rte_get_tx_ol_flag_name()
>> can dump one flag, or set of flag that are part of the same mask (ex:
>> PKT_TX_UDP_CKSUM, part of PKT_TX_L4_MASK). But they are not designed
>> to
>> dump the list of flags contained in mbuf->ol_flags.
>>
>> This commit introduce new functions to do that. Similarly to the packet
>> type dump functions, the goal is to factorize the code that could be
>> used in several applications and reduce the risk of desynchronization
>> between the flags and the dump functions.
>>
>> Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
> 
> Hi Olivier,
> 
> Sorry, I missed a typo in this patch: "ouput" -> "output".
> 
> Also, check-git-log.sh is complaining about two patches:
> 
> Wrong headline lowercase:
>         app/testpmd: dump rx flags in csum engine
>         app/testpmd: display rx port in csum engine
> 
> Lastly, could you send another version of the patchset (including patches without any modifications).
> In my opinion, it is a bit difficult to apply the patchset, because Patchwork doesn't tell me
> that this patch is the first patch of the patchset.

Thank you for the review. I'll fix all these issue and send the whole
patchset again (will be called v5 to avoid confusion with separate
patches). I didn't want to spam the list with the full patchset for
these minor fixes, but you're right it's not that clear.

Regards,
Olivier

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

* [dpdk-dev] [PATCH v5 0/8] Misc enhancements in testpmd
  2016-09-09  7:55 [dpdk-dev] [PATCH v2 0/8] Misc enhancements in testpmd Olivier Matz
                   ` (8 preceding siblings ...)
  2016-10-03  9:02 ` [dpdk-dev] [PATCH v2 0/8] Misc enhancements in testpmd Olivier Matz
@ 2016-10-07 16:05 ` Olivier Matz
  2016-10-07 16:05   ` [dpdk-dev] [PATCH v5 1/8] mbuf: add function to dump ol flag list Olivier Matz
                     ` (9 more replies)
  9 siblings, 10 replies; 40+ messages in thread
From: Olivier Matz @ 2016-10-07 16:05 UTC (permalink / raw)
  To: dev, pablo.de.lara.guarch

This patchset introduces several enhancements or minor fixes
in testpmd. It is targetted for v16.11, and applies on top of
software ptype v2 patchset [1].

These patches are useful to validate the virtio offload
patchset [2] (to be rebased).

[1] http://dpdk.org/ml/archives/dev/2016-August/045876.html
[2] http://dpdk.org/ml/archives/dev/2016-July/044404.html

v4 -> v5:
- fix headline lowercase for "Rx"
- fix typo in API comment: "ouput" -> "output"

v3 -> v4:
- fix typo in documentation

v2 -> v3:
- move return type on a separate line in function definitions
- add documentation for the new --enable-lro option

v1 -> v2:
- rebase on top of sw ptype v2 patch

Olivier Matz (8):
  mbuf: add function to dump ol flag list
  app/testpmd: use new function to dump offload flags
  app/testpmd: dump Rx flags in csum engine
  app/testpmd: add option to enable lro
  app/testpmd: do not change ip addrs in csum engine
  app/testpmd: display Rx port in csum engine
  app/testpmd: don't use tso if packet is too small
  app/testpmd: hide segsize when unrelevant in csum engine

 app/test-pmd/csumonly.c                | 96 ++++++++++++----------------------
 app/test-pmd/parameters.c              |  4 ++
 app/test-pmd/rxonly.c                  | 15 +-----
 doc/guides/rel_notes/release_16_11.rst |  5 ++
 doc/guides/testpmd_app_ug/run_app.rst  |  4 ++
 lib/librte_mbuf/rte_mbuf.c             | 93 ++++++++++++++++++++++++++++++++
 lib/librte_mbuf/rte_mbuf.h             | 28 ++++++++++
 lib/librte_mbuf/rte_mbuf_version.map   |  2 +
 8 files changed, 170 insertions(+), 77 deletions(-)

-- 
2.8.1

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

* [dpdk-dev] [PATCH v5 1/8] mbuf: add function to dump ol flag list
  2016-10-07 16:05 ` [dpdk-dev] [PATCH v5 " Olivier Matz
@ 2016-10-07 16:05   ` Olivier Matz
  2016-10-11 20:42     ` Thomas Monjalon
  2016-10-07 16:05   ` [dpdk-dev] [PATCH v5 2/8] app/testpmd: use new function to dump offload flags Olivier Matz
                     ` (8 subsequent siblings)
  9 siblings, 1 reply; 40+ messages in thread
From: Olivier Matz @ 2016-10-07 16:05 UTC (permalink / raw)
  To: dev, pablo.de.lara.guarch

The functions rte_get_rx_ol_flag_name() and rte_get_tx_ol_flag_name()
can dump one flag, or set of flag that are part of the same mask (ex:
PKT_TX_UDP_CKSUM, part of PKT_TX_L4_MASK). But they are not designed to
dump the list of flags contained in mbuf->ol_flags.

This commit introduce new functions to do that. Similarly to the packet
type dump functions, the goal is to factorize the code that could be
used in several applications and reduce the risk of desynchronization
between the flags and the dump functions.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 doc/guides/rel_notes/release_16_11.rst |  5 ++
 lib/librte_mbuf/rte_mbuf.c             | 93 ++++++++++++++++++++++++++++++++++
 lib/librte_mbuf/rte_mbuf.h             | 28 ++++++++++
 lib/librte_mbuf/rte_mbuf_version.map   |  2 +
 4 files changed, 128 insertions(+)

diff --git a/doc/guides/rel_notes/release_16_11.rst b/doc/guides/rel_notes/release_16_11.rst
index e9dc797..a0dc9d4 100644
--- a/doc/guides/rel_notes/release_16_11.rst
+++ b/doc/guides/rel_notes/release_16_11.rst
@@ -78,6 +78,11 @@ New Features
 
   Added new functions ``rte_get_ptype_*()`` to dump a packet type as a string.
 
+* **Added functions to dump the offload flags as a string.**
+
+  Added two new functions ``rte_get_rx_ol_flag_list()`` and
+  ``rte_get_tx_ol_flag_list()`` to dump offload flags as a string.
+
 Resolved Issues
 ---------------
 
diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index cd95e6f..d58a701 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -319,6 +319,54 @@ const char *rte_get_rx_ol_flag_name(uint64_t mask)
 	}
 }
 
+struct flag_mask {
+	uint64_t flag;
+	uint64_t mask;
+	const char *default_name;
+};
+
+/* write the list of rx ol flags in buffer buf */
+int
+rte_get_rx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
+{
+	const struct flag_mask rx_flags[] = {
+		{ PKT_RX_VLAN_PKT, PKT_RX_VLAN_PKT, NULL },
+		{ PKT_RX_RSS_HASH, PKT_RX_RSS_HASH, NULL },
+		{ PKT_RX_FDIR, PKT_RX_FDIR, NULL },
+		{ PKT_RX_L4_CKSUM_BAD, PKT_RX_L4_CKSUM_BAD, NULL },
+		{ PKT_RX_IP_CKSUM_BAD, PKT_RX_IP_CKSUM_BAD, NULL },
+		{ PKT_RX_EIP_CKSUM_BAD, PKT_RX_EIP_CKSUM_BAD, NULL },
+		{ PKT_RX_VLAN_STRIPPED, PKT_RX_VLAN_STRIPPED, NULL },
+		{ PKT_RX_IEEE1588_PTP, PKT_RX_IEEE1588_PTP, NULL },
+		{ PKT_RX_IEEE1588_TMST, PKT_RX_IEEE1588_TMST, NULL },
+		{ PKT_RX_QINQ_STRIPPED, PKT_RX_QINQ_STRIPPED, NULL },
+	};
+	const char *name;
+	unsigned int i;
+	int ret;
+
+	if (buflen == 0)
+		return -1;
+
+	buf[0] = '\0';
+	for (i = 0; i < RTE_DIM(rx_flags); i++) {
+		if ((mask & rx_flags[i].mask) != rx_flags[i].flag)
+			continue;
+		name = rte_get_rx_ol_flag_name(rx_flags[i].flag);
+		if (name == NULL)
+			name = rx_flags[i].default_name;
+		ret = snprintf(buf, buflen, "%s ", name);
+		if (ret < 0)
+			return -1;
+		if ((size_t)ret >= buflen)
+			return -1;
+		buf += ret;
+		buflen -= ret;
+	}
+
+	return 0;
+}
+
 /*
  * Get the name of a TX offload flag. Must be kept synchronized with flag
  * definitions in rte_mbuf.h.
@@ -341,3 +389,48 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask)
 	default: return NULL;
 	}
 }
+
+/* write the list of tx ol flags in buffer buf */
+int
+rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
+{
+	const struct flag_mask tx_flags[] = {
+		{ PKT_TX_VLAN_PKT, PKT_TX_VLAN_PKT, NULL },
+		{ PKT_TX_IP_CKSUM, PKT_TX_IP_CKSUM, NULL },
+		{ PKT_TX_TCP_CKSUM, PKT_TX_L4_MASK, NULL },
+		{ PKT_TX_SCTP_CKSUM, PKT_TX_L4_MASK, NULL },
+		{ PKT_TX_UDP_CKSUM, PKT_TX_L4_MASK, NULL },
+		{ PKT_TX_L4_NO_CKSUM, PKT_TX_L4_MASK, "PKT_TX_L4_NO_CKSUM" },
+		{ PKT_TX_IEEE1588_TMST, PKT_TX_IEEE1588_TMST, NULL },
+		{ PKT_TX_TCP_SEG, PKT_TX_TCP_SEG, NULL },
+		{ PKT_TX_IPV4, PKT_TX_IPV4, NULL },
+		{ PKT_TX_IPV6, PKT_TX_IPV6, NULL },
+		{ PKT_TX_OUTER_IP_CKSUM, PKT_TX_OUTER_IP_CKSUM, NULL },
+		{ PKT_TX_OUTER_IPV4, PKT_TX_OUTER_IPV4, NULL },
+		{ PKT_TX_OUTER_IPV6, PKT_TX_OUTER_IPV6, NULL },
+	};
+	const char *name;
+	unsigned int i;
+	int ret;
+
+	if (buflen == 0)
+		return -1;
+
+	buf[0] = '\0';
+	for (i = 0; i < RTE_DIM(tx_flags); i++) {
+		if ((mask & tx_flags[i].mask) != tx_flags[i].flag)
+			continue;
+		name = rte_get_tx_ol_flag_name(tx_flags[i].flag);
+		if (name == NULL)
+			name = tx_flags[i].default_name;
+		ret = snprintf(buf, buflen, "%s ", name);
+		if (ret < 0)
+			return -1;
+		if ((size_t)ret >= buflen)
+			return -1;
+		buf += ret;
+		buflen -= ret;
+	}
+
+	return 0;
+}
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 8c6bc2b..ead353c 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -240,6 +240,20 @@ extern "C" {
 const char *rte_get_rx_ol_flag_name(uint64_t mask);
 
 /**
+ * Dump the list of RX offload flags in a buffer
+ *
+ * @param mask
+ *   The mask describing the RX flags.
+ * @param buf
+ *   The output buffer.
+ * @param buflen
+ *   The length of the buffer.
+ * @return
+ *   0 on success, (-1) on error.
+ */
+int rte_get_rx_ol_flag_list(uint64_t mask, char *buf, size_t buflen);
+
+/**
  * Get the name of a TX offload flag
  *
  * @param mask
@@ -252,6 +266,20 @@ const char *rte_get_rx_ol_flag_name(uint64_t mask);
 const char *rte_get_tx_ol_flag_name(uint64_t mask);
 
 /**
+ * Dump the list of TX offload flags in a buffer
+ *
+ * @param mask
+ *   The mask describing the TX flags.
+ * @param buf
+ *   The output buffer.
+ * @param buflen
+ *   The length of the buffer.
+ * @return
+ *   0 on success, (-1) on error.
+ */
+int rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen);
+
+/**
  * Some NICs need at least 2KB buffer to RX standard Ethernet frame without
  * splitting it into multiple segments.
  * So, for mbufs that planned to be involved into RX/TX, the recommended
diff --git a/lib/librte_mbuf/rte_mbuf_version.map b/lib/librte_mbuf/rte_mbuf_version.map
index 5455ba6..6e2ea84 100644
--- a/lib/librte_mbuf/rte_mbuf_version.map
+++ b/lib/librte_mbuf/rte_mbuf_version.map
@@ -31,5 +31,7 @@ DPDK_16.11 {
 	rte_get_ptype_l4_name;
 	rte_get_ptype_name;
 	rte_get_ptype_tunnel_name;
+	rte_get_rx_ol_flag_list;
+	rte_get_tx_ol_flag_list;
 
 } DPDK_2.1;
-- 
2.8.1

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

* [dpdk-dev] [PATCH v5 2/8] app/testpmd: use new function to dump offload flags
  2016-10-07 16:05 ` [dpdk-dev] [PATCH v5 " Olivier Matz
  2016-10-07 16:05   ` [dpdk-dev] [PATCH v5 1/8] mbuf: add function to dump ol flag list Olivier Matz
@ 2016-10-07 16:05   ` Olivier Matz
  2016-10-07 16:05   ` [dpdk-dev] [PATCH v5 3/8] app/testpmd: dump Rx flags in csum engine Olivier Matz
                     ` (7 subsequent siblings)
  9 siblings, 0 replies; 40+ messages in thread
From: Olivier Matz @ 2016-10-07 16:05 UTC (permalink / raw)
  To: dev, pablo.de.lara.guarch

Use the functions introduced in the previous commit to dump the offload
flags.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 app/test-pmd/csumonly.c | 27 +++------------------------
 app/test-pmd/rxonly.c   | 15 ++-------------
 2 files changed, 5 insertions(+), 37 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index 21cb78f..5ca5702 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -791,23 +791,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 
 		/* if verbose mode is enabled, dump debug info */
 		if (verbose_level > 0) {
-			struct {
-				uint64_t flag;
-				uint64_t mask;
-			} tx_flags[] = {
-				{ PKT_TX_IP_CKSUM, PKT_TX_IP_CKSUM },
-				{ PKT_TX_UDP_CKSUM, PKT_TX_L4_MASK },
-				{ PKT_TX_TCP_CKSUM, PKT_TX_L4_MASK },
-				{ PKT_TX_SCTP_CKSUM, PKT_TX_L4_MASK },
-				{ PKT_TX_IPV4, PKT_TX_IPV4 },
-				{ PKT_TX_IPV6, PKT_TX_IPV6 },
-				{ PKT_TX_OUTER_IP_CKSUM, PKT_TX_OUTER_IP_CKSUM },
-				{ PKT_TX_OUTER_IPV4, PKT_TX_OUTER_IPV4 },
-				{ PKT_TX_OUTER_IPV6, PKT_TX_OUTER_IPV6 },
-				{ PKT_TX_TCP_SEG, PKT_TX_TCP_SEG },
-			};
-			unsigned j;
-			const char *name;
+			char buf[256];
 
 			printf("-----------------\n");
 			printf("mbuf=%p, pkt_len=%u, nb_segs=%hhu:\n",
@@ -837,13 +821,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 					m->outer_l2_len, m->outer_l3_len);
 			if (info.tso_segsz != 0)
 				printf("tx: m->tso_segsz=%d\n", m->tso_segsz);
-			printf("tx: flags=");
-			for (j = 0; j < sizeof(tx_flags)/sizeof(*tx_flags); j++) {
-				name = rte_get_tx_ol_flag_name(tx_flags[j].flag);
-				if ((m->ol_flags & tx_flags[j].mask) ==
-					tx_flags[j].flag)
-					printf("%s ", name);
-			}
+			rte_get_tx_ol_flag_list(m->ol_flags, buf, sizeof(buf));
+			printf("tx: flags=%s", buf);
 			printf("\n");
 		}
 	}
diff --git a/app/test-pmd/rxonly.c b/app/test-pmd/rxonly.c
index 9acc4c6..fff815c 100644
--- a/app/test-pmd/rxonly.c
+++ b/app/test-pmd/rxonly.c
@@ -229,19 +229,8 @@ pkt_burst_receive(struct fwd_stream *fs)
 		}
 		printf(" - Receive queue=0x%x", (unsigned) fs->rx_queue);
 		printf("\n");
-		if (ol_flags != 0) {
-			unsigned rxf;
-			const char *name;
-
-			for (rxf = 0; rxf < sizeof(mb->ol_flags) * 8; rxf++) {
-				if ((ol_flags & (1ULL << rxf)) == 0)
-					continue;
-				name = rte_get_rx_ol_flag_name(1ULL << rxf);
-				if (name == NULL)
-					continue;
-				printf("  %s\n", name);
-			}
-		}
+		rte_get_rx_ol_flag_list(mb->ol_flags, buf, sizeof(buf));
+		printf("  ol_flags: %s\n", buf);
 		rte_pktmbuf_free(mb);
 	}
 
-- 
2.8.1

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

* [dpdk-dev] [PATCH v5 3/8] app/testpmd: dump Rx flags in csum engine
  2016-10-07 16:05 ` [dpdk-dev] [PATCH v5 " Olivier Matz
  2016-10-07 16:05   ` [dpdk-dev] [PATCH v5 1/8] mbuf: add function to dump ol flag list Olivier Matz
  2016-10-07 16:05   ` [dpdk-dev] [PATCH v5 2/8] app/testpmd: use new function to dump offload flags Olivier Matz
@ 2016-10-07 16:05   ` Olivier Matz
  2016-10-07 16:05   ` [dpdk-dev] [PATCH v5 4/8] app/testpmd: add option to enable lro Olivier Matz
                     ` (6 subsequent siblings)
  9 siblings, 0 replies; 40+ messages in thread
From: Olivier Matz @ 2016-10-07 16:05 UTC (permalink / raw)
  To: dev, pablo.de.lara.guarch

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 app/test-pmd/csumonly.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index 5ca5702..e7ee0b3 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -640,7 +640,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 	uint16_t nb_rx;
 	uint16_t nb_tx;
 	uint16_t i;
-	uint64_t ol_flags;
+	uint64_t rx_ol_flags, tx_ol_flags;
 	uint16_t testpmd_ol_flags;
 	uint32_t retry;
 	uint32_t rx_bad_ip_csum;
@@ -680,13 +680,14 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 			rte_prefetch0(rte_pktmbuf_mtod(pkts_burst[i + 1],
 						       void *));
 
-		ol_flags = 0;
-		info.is_tunnel = 0;
 		m = pkts_burst[i];
+		info.is_tunnel = 0;
+		tx_ol_flags = 0;
+		rx_ol_flags = m->ol_flags;
 
 		/* Update the L3/L4 checksum error packet statistics */
-		rx_bad_ip_csum += ((m->ol_flags & PKT_RX_IP_CKSUM_BAD) != 0);
-		rx_bad_l4_csum += ((m->ol_flags & PKT_RX_L4_CKSUM_BAD) != 0);
+		rx_bad_ip_csum += ((rx_ol_flags & PKT_RX_IP_CKSUM_BAD) != 0);
+		rx_bad_l4_csum += ((rx_ol_flags & PKT_RX_L4_CKSUM_BAD) != 0);
 
 		/* step 1: dissect packet, parsing optional vlan, ip4/ip6, vxlan
 		 * and inner headers */
@@ -737,13 +738,13 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 		 * is configured, prepare the mbuf for TCP segmentation. */
 
 		/* process checksums of inner headers first */
-		ol_flags |= process_inner_cksums(l3_hdr, &info, testpmd_ol_flags);
+		tx_ol_flags |= process_inner_cksums(l3_hdr, &info, testpmd_ol_flags);
 
 		/* Then process outer headers if any. Note that the software
 		 * checksum will be wrong if one of the inner checksums is
 		 * processed in hardware. */
 		if (info.is_tunnel == 1) {
-			ol_flags |= process_outer_cksums(outer_l3_hdr, &info,
+			tx_ol_flags |= process_outer_cksums(outer_l3_hdr, &info,
 				testpmd_ol_flags);
 		}
 
@@ -777,7 +778,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 			m->l4_len = info.l4_len;
 		}
 		m->tso_segsz = info.tso_segsz;
-		m->ol_flags = ol_flags;
+		m->ol_flags = tx_ol_flags;
 
 		/* Do split & copy for the packet. */
 		if (tx_pkt_split != TX_PKT_SPLIT_OFF) {
@@ -797,10 +798,11 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 			printf("mbuf=%p, pkt_len=%u, nb_segs=%hhu:\n",
 				m, m->pkt_len, m->nb_segs);
 			/* dump rx parsed packet info */
+			rte_get_rx_ol_flag_list(rx_ol_flags, buf, sizeof(buf));
 			printf("rx: l2_len=%d ethertype=%x l3_len=%d "
-				"l4_proto=%d l4_len=%d\n",
+				"l4_proto=%d l4_len=%d flags=%s\n",
 				info.l2_len, rte_be_to_cpu_16(info.ethertype),
-				info.l3_len, info.l4_proto, info.l4_len);
+				info.l3_len, info.l4_proto, info.l4_len, buf);
 			if (info.is_tunnel == 1)
 				printf("rx: outer_l2_len=%d outer_ethertype=%x "
 					"outer_l3_len=%d\n", info.outer_l2_len,
-- 
2.8.1

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

* [dpdk-dev] [PATCH v5 4/8] app/testpmd: add option to enable lro
  2016-10-07 16:05 ` [dpdk-dev] [PATCH v5 " Olivier Matz
                     ` (2 preceding siblings ...)
  2016-10-07 16:05   ` [dpdk-dev] [PATCH v5 3/8] app/testpmd: dump Rx flags in csum engine Olivier Matz
@ 2016-10-07 16:05   ` Olivier Matz
  2016-10-07 16:05   ` [dpdk-dev] [PATCH v5 5/8] app/testpmd: do not change ip addrs in csum engine Olivier Matz
                     ` (5 subsequent siblings)
  9 siblings, 0 replies; 40+ messages in thread
From: Olivier Matz @ 2016-10-07 16:05 UTC (permalink / raw)
  To: dev, pablo.de.lara.guarch

Introduce a new argument '--enable-lro' to ask testpmd to enable the LRO
feature on enabled ports, like it's done for '--enable-rx-cksum' for
instance.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 app/test-pmd/parameters.c             | 4 ++++
 doc/guides/testpmd_app_ug/run_app.rst | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
index 6a6a07e..c45f78a 100644
--- a/app/test-pmd/parameters.c
+++ b/app/test-pmd/parameters.c
@@ -149,6 +149,7 @@ usage(char* progname)
 	       "If the drop-queue doesn't exist, the packet is dropped. "
 	       "By default drop-queue=127.\n");
 	printf("  --crc-strip: enable CRC stripping by hardware.\n");
+	printf("  --enable-lro: enable large receive offload.\n");
 	printf("  --enable-rx-cksum: enable rx hardware checksum offload.\n");
 	printf("  --disable-hw-vlan: disable hardware vlan.\n");
 	printf("  --disable-hw-vlan-filter: disable hardware vlan filter.\n");
@@ -524,6 +525,7 @@ launch_args_parse(int argc, char** argv)
 		{ "pkt-filter-size",            1, 0, 0 },
 		{ "pkt-filter-drop-queue",      1, 0, 0 },
 		{ "crc-strip",                  0, 0, 0 },
+		{ "enable-lro",                 0, 0, 0 },
 		{ "enable-rx-cksum",            0, 0, 0 },
 		{ "enable-scatter",             0, 0, 0 },
 		{ "disable-hw-vlan",            0, 0, 0 },
@@ -764,6 +766,8 @@ launch_args_parse(int argc, char** argv)
 			}
 			if (!strcmp(lgopts[opt_idx].name, "crc-strip"))
 				rx_mode.hw_strip_crc = 1;
+			if (!strcmp(lgopts[opt_idx].name, "enable-lro"))
+				rx_mode.enable_lro = 1;
 			if (!strcmp(lgopts[opt_idx].name, "enable-scatter"))
 				rx_mode.enable_scatter = 1;
 			if (!strcmp(lgopts[opt_idx].name, "enable-rx-cksum"))
diff --git a/doc/guides/testpmd_app_ug/run_app.rst b/doc/guides/testpmd_app_ug/run_app.rst
index 7712bd2..55c7ac0 100644
--- a/doc/guides/testpmd_app_ug/run_app.rst
+++ b/doc/guides/testpmd_app_ug/run_app.rst
@@ -285,6 +285,10 @@ The commandline options are:
 
     Enable hardware CRC stripping.
 
+*   ``--enable-lro``
+
+    Enable large receive offload.
+
 *   ``--enable-rx-cksum``
 
     Enable hardware RX checksum offload.
-- 
2.8.1

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

* [dpdk-dev] [PATCH v5 5/8] app/testpmd: do not change ip addrs in csum engine
  2016-10-07 16:05 ` [dpdk-dev] [PATCH v5 " Olivier Matz
                     ` (3 preceding siblings ...)
  2016-10-07 16:05   ` [dpdk-dev] [PATCH v5 4/8] app/testpmd: add option to enable lro Olivier Matz
@ 2016-10-07 16:05   ` Olivier Matz
  2016-10-07 16:05   ` [dpdk-dev] [PATCH v5 6/8] app/testpmd: display Rx port " Olivier Matz
                     ` (4 subsequent siblings)
  9 siblings, 0 replies; 40+ messages in thread
From: Olivier Matz @ 2016-10-07 16:05 UTC (permalink / raw)
  To: dev, pablo.de.lara.guarch

The csum forward engine was updated to change the IP addresses in the
packet data in
commit 51f694dd40f5 ("app/testpmd: rework checksum forward engine")

This was done to ensure that the checksum is correctly reprocessed when
using hardware checksum offload. But the functions
process_inner_cksums() and process_outer_cksums() already reset the
checksum field to 0, so this is not necessary.

Moreover, this makes the engine more complex than needed, and prevents
to easily use it to forward traffic (like iperf) as it modifies the
packets.

This patch drops this behavior.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 app/test-pmd/csumonly.c | 30 ++++--------------------------
 1 file changed, 4 insertions(+), 26 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index e7ee0b3..eeb67db 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -317,21 +317,6 @@ parse_encap_ip(void *encap_ip, struct testpmd_offload_info *info)
 	info->l2_len = 0;
 }
 
-/* modify the IPv4 or IPv4 source address of a packet */
-static void
-change_ip_addresses(void *l3_hdr, uint16_t ethertype)
-{
-	struct ipv4_hdr *ipv4_hdr = l3_hdr;
-	struct ipv6_hdr *ipv6_hdr = l3_hdr;
-
-	if (ethertype == _htons(ETHER_TYPE_IPv4)) {
-		ipv4_hdr->src_addr =
-			rte_cpu_to_be_32(rte_be_to_cpu_32(ipv4_hdr->src_addr) + 1);
-	} else if (ethertype == _htons(ETHER_TYPE_IPv6)) {
-		ipv6_hdr->src_addr[15] = ipv6_hdr->src_addr[15] + 1;
-	}
-}
-
 /* if possible, calculate the checksum of a packet in hw or sw,
  * depending on the testpmd command line configuration */
 static uint64_t
@@ -608,7 +593,6 @@ pkt_copy_split(const struct rte_mbuf *pkt)
  * Receive a burst of packets, and for each packet:
  *  - parse packet, and try to recognize a supported packet type (1)
  *  - if it's not a supported packet type, don't touch the packet, else:
- *  - modify the IPs in inner headers and in outer headers if any
  *  - reprocess the checksum of all supported layers. This is done in SW
  *    or HW, depending on testpmd command line configuration
  *  - if TSO is enabled in testpmd command line, also flag the mbuf for TCP
@@ -725,20 +709,14 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 			l3_hdr = (char *)l3_hdr + info.outer_l3_len + info.l2_len;
 		}
 
-		/* step 2: change all source IPs (v4 or v6) so we need
-		 * to recompute the chksums even if they were correct */
-
-		change_ip_addresses(l3_hdr, info.ethertype);
-		if (info.is_tunnel == 1)
-			change_ip_addresses(outer_l3_hdr, info.outer_ethertype);
-
-		/* step 3: depending on user command line configuration,
+		/* step 2: depending on user command line configuration,
 		 * recompute checksum either in software or flag the
 		 * mbuf to offload the calculation to the NIC. If TSO
 		 * is configured, prepare the mbuf for TCP segmentation. */
 
 		/* process checksums of inner headers first */
-		tx_ol_flags |= process_inner_cksums(l3_hdr, &info, testpmd_ol_flags);
+		tx_ol_flags |= process_inner_cksums(l3_hdr, &info,
+			testpmd_ol_flags);
 
 		/* Then process outer headers if any. Note that the software
 		 * checksum will be wrong if one of the inner checksums is
@@ -748,7 +726,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 				testpmd_ol_flags);
 		}
 
-		/* step 4: fill the mbuf meta data (flags and header lengths) */
+		/* step 3: fill the mbuf meta data (flags and header lengths) */
 
 		if (info.is_tunnel == 1) {
 			if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) {
-- 
2.8.1

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

* [dpdk-dev] [PATCH v5 6/8] app/testpmd: display Rx port in csum engine
  2016-10-07 16:05 ` [dpdk-dev] [PATCH v5 " Olivier Matz
                     ` (4 preceding siblings ...)
  2016-10-07 16:05   ` [dpdk-dev] [PATCH v5 5/8] app/testpmd: do not change ip addrs in csum engine Olivier Matz
@ 2016-10-07 16:05   ` Olivier Matz
  2016-10-07 16:05   ` [dpdk-dev] [PATCH v5 7/8] app/testpmd: don't use tso if packet is too small Olivier Matz
                     ` (3 subsequent siblings)
  9 siblings, 0 replies; 40+ messages in thread
From: Olivier Matz @ 2016-10-07 16:05 UTC (permalink / raw)
  To: dev, pablo.de.lara.guarch

This information is useful when debugging, especially with
bidirectional traffic.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 app/test-pmd/csumonly.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index eeb67db..19c8099 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -773,8 +773,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 			char buf[256];
 
 			printf("-----------------\n");
-			printf("mbuf=%p, pkt_len=%u, nb_segs=%hhu:\n",
-				m, m->pkt_len, m->nb_segs);
+			printf("port=%u, mbuf=%p, pkt_len=%u, nb_segs=%hhu:\n",
+				fs->rx_port, m, m->pkt_len, m->nb_segs);
 			/* dump rx parsed packet info */
 			rte_get_rx_ol_flag_list(rx_ol_flags, buf, sizeof(buf));
 			printf("rx: l2_len=%d ethertype=%x l3_len=%d "
-- 
2.8.1

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

* [dpdk-dev] [PATCH v5 7/8] app/testpmd: don't use tso if packet is too small
  2016-10-07 16:05 ` [dpdk-dev] [PATCH v5 " Olivier Matz
                     ` (5 preceding siblings ...)
  2016-10-07 16:05   ` [dpdk-dev] [PATCH v5 6/8] app/testpmd: display Rx port " Olivier Matz
@ 2016-10-07 16:05   ` Olivier Matz
  2016-10-07 16:05   ` [dpdk-dev] [PATCH v5 8/8] app/testpmd: hide segsize when unrelevant in csum engine Olivier Matz
                     ` (2 subsequent siblings)
  9 siblings, 0 replies; 40+ messages in thread
From: Olivier Matz @ 2016-10-07 16:05 UTC (permalink / raw)
  To: dev, pablo.de.lara.guarch

Asking for TSO (TCP Segmentation Offload) on packets that are already
smaller than (headers + MSS) does not work, for instance on ixgbe.

Fix the csumonly engine to only set the TSO flag when a segmentation
offload is really required, i.e. when packet is large enough.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 app/test-pmd/csumonly.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index 19c8099..2057633 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -101,6 +101,7 @@ struct testpmd_offload_info {
 	uint16_t outer_l3_len;
 	uint8_t outer_l4_proto;
 	uint16_t tso_segsz;
+	uint32_t pkt_len;
 };
 
 /* simplified GRE header */
@@ -328,13 +329,20 @@ process_inner_cksums(void *l3_hdr, const struct testpmd_offload_info *info,
 	struct tcp_hdr *tcp_hdr;
 	struct sctp_hdr *sctp_hdr;
 	uint64_t ol_flags = 0;
+	uint32_t max_pkt_len, tso_segsz = 0;
+
+	/* ensure packet is large enough to require tso */
+	max_pkt_len = info->l2_len + info->l3_len + info->l4_len +
+		info->tso_segsz;
+	if (info->tso_segsz != 0 && info->pkt_len > max_pkt_len)
+		tso_segsz = info->tso_segsz;
 
 	if (info->ethertype == _htons(ETHER_TYPE_IPv4)) {
 		ipv4_hdr = l3_hdr;
 		ipv4_hdr->hdr_checksum = 0;
 
 		ol_flags |= PKT_TX_IPV4;
-		if (info->tso_segsz != 0 && info->l4_proto == IPPROTO_TCP) {
+		if (tso_segsz != 0 && info->l4_proto == IPPROTO_TCP) {
 			ol_flags |= PKT_TX_IP_CKSUM;
 		} else {
 			if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM)
@@ -366,7 +374,7 @@ process_inner_cksums(void *l3_hdr, const struct testpmd_offload_info *info,
 	} else if (info->l4_proto == IPPROTO_TCP) {
 		tcp_hdr = (struct tcp_hdr *)((char *)l3_hdr + info->l3_len);
 		tcp_hdr->cksum = 0;
-		if (info->tso_segsz != 0) {
+		if (tso_segsz != 0) {
 			ol_flags |= PKT_TX_TCP_SEG;
 			tcp_hdr->cksum = get_psd_sum(l3_hdr, info->ethertype,
 				ol_flags);
@@ -666,6 +674,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 
 		m = pkts_burst[i];
 		info.is_tunnel = 0;
+		info.pkt_len = rte_pktmbuf_pkt_len(m);
 		tx_ol_flags = 0;
 		rx_ol_flags = m->ol_flags;
 
-- 
2.8.1

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

* [dpdk-dev] [PATCH v5 8/8] app/testpmd: hide segsize when unrelevant in csum engine
  2016-10-07 16:05 ` [dpdk-dev] [PATCH v5 " Olivier Matz
                     ` (6 preceding siblings ...)
  2016-10-07 16:05   ` [dpdk-dev] [PATCH v5 7/8] app/testpmd: don't use tso if packet is too small Olivier Matz
@ 2016-10-07 16:05   ` Olivier Matz
  2016-10-11 18:13   ` [dpdk-dev] [PATCH v5 0/8] Misc enhancements in testpmd De Lara Guarch, Pablo
  2016-10-12 15:39   ` [dpdk-dev] [PATCH v6 " Olivier Matz
  9 siblings, 0 replies; 40+ messages in thread
From: Olivier Matz @ 2016-10-07 16:05 UTC (permalink / raw)
  To: dev, pablo.de.lara.guarch

When TSO is not asked, hide the segment size.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 app/test-pmd/csumonly.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index 2057633..d5eb260 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -808,7 +808,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 				(testpmd_ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
 				printf("tx: m->outer_l2_len=%d m->outer_l3_len=%d\n",
 					m->outer_l2_len, m->outer_l3_len);
-			if (info.tso_segsz != 0)
+			if (info.tso_segsz != 0 && (m->ol_flags & PKT_TX_TCP_SEG))
 				printf("tx: m->tso_segsz=%d\n", m->tso_segsz);
 			rte_get_tx_ol_flag_list(m->ol_flags, buf, sizeof(buf));
 			printf("tx: flags=%s", buf);
-- 
2.8.1

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

* Re: [dpdk-dev] [PATCH v5 0/8] Misc enhancements in testpmd
  2016-10-07 16:05 ` [dpdk-dev] [PATCH v5 " Olivier Matz
                     ` (7 preceding siblings ...)
  2016-10-07 16:05   ` [dpdk-dev] [PATCH v5 8/8] app/testpmd: hide segsize when unrelevant in csum engine Olivier Matz
@ 2016-10-11 18:13   ` De Lara Guarch, Pablo
  2016-10-12 15:39   ` [dpdk-dev] [PATCH v6 " Olivier Matz
  9 siblings, 0 replies; 40+ messages in thread
From: De Lara Guarch, Pablo @ 2016-10-11 18:13 UTC (permalink / raw)
  To: Olivier Matz, dev



> -----Original Message-----
> From: Olivier Matz [mailto:olivier.matz@6wind.com]
> Sent: Friday, October 07, 2016 9:05 AM
> To: dev@dpdk.org; De Lara Guarch, Pablo
> Subject: [PATCH v5 0/8] Misc enhancements in testpmd
> 
> This patchset introduces several enhancements or minor fixes
> in testpmd. It is targetted for v16.11, and applies on top of
> software ptype v2 patchset [1].
> 
> These patches are useful to validate the virtio offload
> patchset [2] (to be rebased).
> 
> [1] http://dpdk.org/ml/archives/dev/2016-August/045876.html
> [2] http://dpdk.org/ml/archives/dev/2016-July/044404.html
> 
> v4 -> v5:
> - fix headline lowercase for "Rx"
> - fix typo in API comment: "ouput" -> "output"
> 
> v3 -> v4:
> - fix typo in documentation
> 
> v2 -> v3:
> - move return type on a separate line in function definitions
> - add documentation for the new --enable-lro option
> 
> v1 -> v2:
> - rebase on top of sw ptype v2 patch
> 
> Olivier Matz (8):
>   mbuf: add function to dump ol flag list
>   app/testpmd: use new function to dump offload flags
>   app/testpmd: dump Rx flags in csum engine
>   app/testpmd: add option to enable lro
>   app/testpmd: do not change ip addrs in csum engine
>   app/testpmd: display Rx port in csum engine
>   app/testpmd: don't use tso if packet is too small
>   app/testpmd: hide segsize when unrelevant in csum engine
> 
>  app/test-pmd/csumonly.c                | 96 ++++++++++++----------------------
>  app/test-pmd/parameters.c              |  4 ++
>  app/test-pmd/rxonly.c                  | 15 +-----
>  doc/guides/rel_notes/release_16_11.rst |  5 ++
>  doc/guides/testpmd_app_ug/run_app.rst  |  4 ++
>  lib/librte_mbuf/rte_mbuf.c             | 93
> ++++++++++++++++++++++++++++++++
>  lib/librte_mbuf/rte_mbuf.h             | 28 ++++++++++
>  lib/librte_mbuf/rte_mbuf_version.map   |  2 +
>  8 files changed, 170 insertions(+), 77 deletions(-)
> 
> --
> 2.8.1

Series-acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>

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

* Re: [dpdk-dev] [PATCH v5 1/8] mbuf: add function to dump ol flag list
  2016-10-07 16:05   ` [dpdk-dev] [PATCH v5 1/8] mbuf: add function to dump ol flag list Olivier Matz
@ 2016-10-11 20:42     ` Thomas Monjalon
  0 siblings, 0 replies; 40+ messages in thread
From: Thomas Monjalon @ 2016-10-11 20:42 UTC (permalink / raw)
  To: Olivier Matz; +Cc: dev, pablo.de.lara.guarch

2016-10-07 18:05, Olivier Matz:
> The functions rte_get_rx_ol_flag_name() and rte_get_tx_ol_flag_name()
> can dump one flag, or set of flag that are part of the same mask (ex:
> PKT_TX_UDP_CKSUM, part of PKT_TX_L4_MASK). But they are not designed to
> dump the list of flags contained in mbuf->ol_flags.
> 
> This commit introduce new functions to do that. Similarly to the packet
> type dump functions, the goal is to factorize the code that could be
> used in several applications and reduce the risk of desynchronization
> between the flags and the dump functions.
> 
> Signed-off-by: Olivier Matz <olivier.matz@6wind.com>

I think it must be rebased because of "mbuf: add Tx side tunneling type":
	http://dpdk.org/commit/63c0d74
Sorry for the late notification.

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

* [dpdk-dev] [PATCH v6 0/8] Misc enhancements in testpmd
  2016-10-07 16:05 ` [dpdk-dev] [PATCH v5 " Olivier Matz
                     ` (8 preceding siblings ...)
  2016-10-11 18:13   ` [dpdk-dev] [PATCH v5 0/8] Misc enhancements in testpmd De Lara Guarch, Pablo
@ 2016-10-12 15:39   ` Olivier Matz
  2016-10-12 15:39     ` [dpdk-dev] [PATCH v6 1/8] mbuf: add function to dump ol flag list Olivier Matz
                       ` (8 more replies)
  9 siblings, 9 replies; 40+ messages in thread
From: Olivier Matz @ 2016-10-12 15:39 UTC (permalink / raw)
  To: dev, pablo.de.lara.guarch; +Cc: thomas.monjalon

This patchset introduces several enhancements or minor fixes
in testpmd. It is targetted for v16.11, and applies on top of
software ptype v2 patchset [1].

These patches are useful to validate the virtio offload
patchset [2] (to be rebased).

[1] http://dpdk.org/ml/archives/dev/2016-August/045876.html
[2] http://dpdk.org/ml/archives/dev/2016-July/044404.html

v5 -> v6:
- rebase against head

v4 -> v5:
- fix headline lowercase for "Rx"
- fix typo in API comment: "ouput" -> "output"

v3 -> v4:
- fix typo in documentation

v2 -> v3:
- move return type on a separate line in function definitions
- add documentation for the new --enable-lro option

v1 -> v2:
- rebase on top of sw ptype v2 patch

Olivier Matz (8):
  mbuf: add function to dump ol flag list
  app/testpmd: use new function to dump offload flags
  app/testpmd: dump Rx flags in csum engine
  app/testpmd: add option to enable lro
  app/testpmd: do not change ip addrs in csum engine
  app/testpmd: display Rx port in csum engine
  app/testpmd: don't use tso if packet is too small
  app/testpmd: hide segsize when unrelevant in csum engine

 app/test-pmd/csumonly.c                | 119 +++++++++++++--------------------
 app/test-pmd/parameters.c              |   4 ++
 app/test-pmd/rxonly.c                  |  15 +----
 doc/guides/rel_notes/release_16_11.rst |   5 ++
 doc/guides/testpmd_app_ug/run_app.rst  |   4 ++
 lib/librte_mbuf/rte_mbuf.c             | 101 ++++++++++++++++++++++++++++
 lib/librte_mbuf/rte_mbuf.h             |  28 ++++++++
 lib/librte_mbuf/rte_mbuf_version.map   |   2 +
 8 files changed, 192 insertions(+), 86 deletions(-)

-- 
2.8.1

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

* [dpdk-dev] [PATCH v6 1/8] mbuf: add function to dump ol flag list
  2016-10-12 15:39   ` [dpdk-dev] [PATCH v6 " Olivier Matz
@ 2016-10-12 15:39     ` Olivier Matz
  2016-10-12 15:39     ` [dpdk-dev] [PATCH v6 2/8] app/testpmd: use new function to dump offload flags Olivier Matz
                       ` (7 subsequent siblings)
  8 siblings, 0 replies; 40+ messages in thread
From: Olivier Matz @ 2016-10-12 15:39 UTC (permalink / raw)
  To: dev, pablo.de.lara.guarch; +Cc: thomas.monjalon

The functions rte_get_rx_ol_flag_name() and rte_get_tx_ol_flag_name()
can dump one flag, or set of flag that are part of the same mask (ex:
PKT_TX_UDP_CKSUM, part of PKT_TX_L4_MASK). But they are not designed to
dump the list of flags contained in mbuf->ol_flags.

This commit introduce new functions to do that. Similarly to the packet
type dump functions, the goal is to factorize the code that could be
used in several applications and reduce the risk of desynchronization
between the flags and the dump functions.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 doc/guides/rel_notes/release_16_11.rst |   5 ++
 lib/librte_mbuf/rte_mbuf.c             | 101 +++++++++++++++++++++++++++++++++
 lib/librte_mbuf/rte_mbuf.h             |  28 +++++++++
 lib/librte_mbuf/rte_mbuf_version.map   |   2 +
 4 files changed, 136 insertions(+)

diff --git a/doc/guides/rel_notes/release_16_11.rst b/doc/guides/rel_notes/release_16_11.rst
index 25c447d..0f04a39 100644
--- a/doc/guides/rel_notes/release_16_11.rst
+++ b/doc/guides/rel_notes/release_16_11.rst
@@ -99,6 +99,11 @@ New Features
   * AES GCM/CTR mode
 
 
+* **Added functions to dump the offload flags as a string.**
+
+  Added two new functions ``rte_get_rx_ol_flag_list()`` and
+  ``rte_get_tx_ol_flag_list()`` to dump offload flags as a string.
+
 Resolved Issues
 ---------------
 
diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index 04f9ed3..4e1fdd1 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -319,6 +319,54 @@ const char *rte_get_rx_ol_flag_name(uint64_t mask)
 	}
 }
 
+struct flag_mask {
+	uint64_t flag;
+	uint64_t mask;
+	const char *default_name;
+};
+
+/* write the list of rx ol flags in buffer buf */
+int
+rte_get_rx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
+{
+	const struct flag_mask rx_flags[] = {
+		{ PKT_RX_VLAN_PKT, PKT_RX_VLAN_PKT, NULL },
+		{ PKT_RX_RSS_HASH, PKT_RX_RSS_HASH, NULL },
+		{ PKT_RX_FDIR, PKT_RX_FDIR, NULL },
+		{ PKT_RX_L4_CKSUM_BAD, PKT_RX_L4_CKSUM_BAD, NULL },
+		{ PKT_RX_IP_CKSUM_BAD, PKT_RX_IP_CKSUM_BAD, NULL },
+		{ PKT_RX_EIP_CKSUM_BAD, PKT_RX_EIP_CKSUM_BAD, NULL },
+		{ PKT_RX_VLAN_STRIPPED, PKT_RX_VLAN_STRIPPED, NULL },
+		{ PKT_RX_IEEE1588_PTP, PKT_RX_IEEE1588_PTP, NULL },
+		{ PKT_RX_IEEE1588_TMST, PKT_RX_IEEE1588_TMST, NULL },
+		{ PKT_RX_QINQ_STRIPPED, PKT_RX_QINQ_STRIPPED, NULL },
+	};
+	const char *name;
+	unsigned int i;
+	int ret;
+
+	if (buflen == 0)
+		return -1;
+
+	buf[0] = '\0';
+	for (i = 0; i < RTE_DIM(rx_flags); i++) {
+		if ((mask & rx_flags[i].mask) != rx_flags[i].flag)
+			continue;
+		name = rte_get_rx_ol_flag_name(rx_flags[i].flag);
+		if (name == NULL)
+			name = rx_flags[i].default_name;
+		ret = snprintf(buf, buflen, "%s ", name);
+		if (ret < 0)
+			return -1;
+		if ((size_t)ret >= buflen)
+			return -1;
+		buf += ret;
+		buflen -= ret;
+	}
+
+	return 0;
+}
+
 /*
  * Get the name of a TX offload flag. Must be kept synchronized with flag
  * definitions in rte_mbuf.h.
@@ -345,3 +393,56 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask)
 	default: return NULL;
 	}
 }
+
+/* write the list of tx ol flags in buffer buf */
+int
+rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
+{
+	const struct flag_mask tx_flags[] = {
+		{ PKT_TX_VLAN_PKT, PKT_TX_VLAN_PKT, NULL },
+		{ PKT_TX_IP_CKSUM, PKT_TX_IP_CKSUM, NULL },
+		{ PKT_TX_TCP_CKSUM, PKT_TX_L4_MASK, NULL },
+		{ PKT_TX_SCTP_CKSUM, PKT_TX_L4_MASK, NULL },
+		{ PKT_TX_UDP_CKSUM, PKT_TX_L4_MASK, NULL },
+		{ PKT_TX_L4_NO_CKSUM, PKT_TX_L4_MASK, "PKT_TX_L4_NO_CKSUM" },
+		{ PKT_TX_IEEE1588_TMST, PKT_TX_IEEE1588_TMST, NULL },
+		{ PKT_TX_TCP_SEG, PKT_TX_TCP_SEG, NULL },
+		{ PKT_TX_IPV4, PKT_TX_IPV4, NULL },
+		{ PKT_TX_IPV6, PKT_TX_IPV6, NULL },
+		{ PKT_TX_OUTER_IP_CKSUM, PKT_TX_OUTER_IP_CKSUM, NULL },
+		{ PKT_TX_OUTER_IPV4, PKT_TX_OUTER_IPV4, NULL },
+		{ PKT_TX_OUTER_IPV6, PKT_TX_OUTER_IPV6, NULL },
+		{ PKT_TX_TUNNEL_VXLAN, PKT_TX_TUNNEL_MASK,
+		  "PKT_TX_TUNNEL_NONE" },
+		{ PKT_TX_TUNNEL_GRE, PKT_TX_TUNNEL_MASK,
+		  "PKT_TX_TUNNEL_NONE" },
+		{ PKT_TX_TUNNEL_IPIP, PKT_TX_TUNNEL_MASK,
+		  "PKT_TX_TUNNEL_NONE" },
+		{ PKT_TX_TUNNEL_GENEVE, PKT_TX_TUNNEL_MASK,
+		  "PKT_TX_TUNNEL_NONE" },
+	};
+	const char *name;
+	unsigned int i;
+	int ret;
+
+	if (buflen == 0)
+		return -1;
+
+	buf[0] = '\0';
+	for (i = 0; i < RTE_DIM(tx_flags); i++) {
+		if ((mask & tx_flags[i].mask) != tx_flags[i].flag)
+			continue;
+		name = rte_get_tx_ol_flag_name(tx_flags[i].flag);
+		if (name == NULL)
+			name = tx_flags[i].default_name;
+		ret = snprintf(buf, buflen, "%s ", name);
+		if (ret < 0)
+			return -1;
+		if ((size_t)ret >= buflen)
+			return -1;
+		buf += ret;
+		buflen -= ret;
+	}
+
+	return 0;
+}
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 55bc389..7541070 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -252,6 +252,20 @@ extern "C" {
 const char *rte_get_rx_ol_flag_name(uint64_t mask);
 
 /**
+ * Dump the list of RX offload flags in a buffer
+ *
+ * @param mask
+ *   The mask describing the RX flags.
+ * @param buf
+ *   The output buffer.
+ * @param buflen
+ *   The length of the buffer.
+ * @return
+ *   0 on success, (-1) on error.
+ */
+int rte_get_rx_ol_flag_list(uint64_t mask, char *buf, size_t buflen);
+
+/**
  * Get the name of a TX offload flag
  *
  * @param mask
@@ -264,6 +278,20 @@ const char *rte_get_rx_ol_flag_name(uint64_t mask);
 const char *rte_get_tx_ol_flag_name(uint64_t mask);
 
 /**
+ * Dump the list of TX offload flags in a buffer
+ *
+ * @param mask
+ *   The mask describing the TX flags.
+ * @param buf
+ *   The output buffer.
+ * @param buflen
+ *   The length of the buffer.
+ * @return
+ *   0 on success, (-1) on error.
+ */
+int rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen);
+
+/**
  * Some NICs need at least 2KB buffer to RX standard Ethernet frame without
  * splitting it into multiple segments.
  * So, for mbufs that planned to be involved into RX/TX, the recommended
diff --git a/lib/librte_mbuf/rte_mbuf_version.map b/lib/librte_mbuf/rte_mbuf_version.map
index 5455ba6..6e2ea84 100644
--- a/lib/librte_mbuf/rte_mbuf_version.map
+++ b/lib/librte_mbuf/rte_mbuf_version.map
@@ -31,5 +31,7 @@ DPDK_16.11 {
 	rte_get_ptype_l4_name;
 	rte_get_ptype_name;
 	rte_get_ptype_tunnel_name;
+	rte_get_rx_ol_flag_list;
+	rte_get_tx_ol_flag_list;
 
 } DPDK_2.1;
-- 
2.8.1

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

* [dpdk-dev] [PATCH v6 2/8] app/testpmd: use new function to dump offload flags
  2016-10-12 15:39   ` [dpdk-dev] [PATCH v6 " Olivier Matz
  2016-10-12 15:39     ` [dpdk-dev] [PATCH v6 1/8] mbuf: add function to dump ol flag list Olivier Matz
@ 2016-10-12 15:39     ` Olivier Matz
  2016-10-12 15:39     ` [dpdk-dev] [PATCH v6 3/8] app/testpmd: dump Rx flags in csum engine Olivier Matz
                       ` (6 subsequent siblings)
  8 siblings, 0 replies; 40+ messages in thread
From: Olivier Matz @ 2016-10-12 15:39 UTC (permalink / raw)
  To: dev, pablo.de.lara.guarch; +Cc: thomas.monjalon

Use the functions introduced in the previous commit to dump the offload
flags.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 app/test-pmd/csumonly.c | 31 +++----------------------------
 app/test-pmd/rxonly.c   | 15 ++-------------
 2 files changed, 5 insertions(+), 41 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index 4fe038d..2ecd6b8 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -816,27 +816,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 
 		/* if verbose mode is enabled, dump debug info */
 		if (verbose_level > 0) {
-			struct {
-				uint64_t flag;
-				uint64_t mask;
-			} tx_flags[] = {
-				{ PKT_TX_IP_CKSUM, PKT_TX_IP_CKSUM },
-				{ PKT_TX_UDP_CKSUM, PKT_TX_L4_MASK },
-				{ PKT_TX_TCP_CKSUM, PKT_TX_L4_MASK },
-				{ PKT_TX_SCTP_CKSUM, PKT_TX_L4_MASK },
-				{ PKT_TX_IPV4, PKT_TX_IPV4 },
-				{ PKT_TX_IPV6, PKT_TX_IPV6 },
-				{ PKT_TX_OUTER_IP_CKSUM, PKT_TX_OUTER_IP_CKSUM },
-				{ PKT_TX_OUTER_IPV4, PKT_TX_OUTER_IPV4 },
-				{ PKT_TX_OUTER_IPV6, PKT_TX_OUTER_IPV6 },
-				{ PKT_TX_TCP_SEG, PKT_TX_TCP_SEG },
-				{ PKT_TX_TUNNEL_VXLAN, PKT_TX_TUNNEL_MASK },
-				{ PKT_TX_TUNNEL_GRE, PKT_TX_TUNNEL_MASK },
-				{ PKT_TX_TUNNEL_IPIP, PKT_TX_TUNNEL_MASK },
-				{ PKT_TX_TUNNEL_GENEVE, PKT_TX_TUNNEL_MASK },
-			};
-			unsigned j;
-			const char *name;
+			char buf[256];
 
 			printf("-----------------\n");
 			printf("mbuf=%p, pkt_len=%u, nb_segs=%hhu:\n",
@@ -872,13 +852,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 						m->tso_segsz);
 			} else if (info.tso_segsz != 0)
 				printf("tx: m->tso_segsz=%d\n", m->tso_segsz);
-			printf("tx: flags=");
-			for (j = 0; j < sizeof(tx_flags)/sizeof(*tx_flags); j++) {
-				name = rte_get_tx_ol_flag_name(tx_flags[j].flag);
-				if ((m->ol_flags & tx_flags[j].mask) ==
-					tx_flags[j].flag)
-					printf("%s ", name);
-			}
+			rte_get_tx_ol_flag_list(m->ol_flags, buf, sizeof(buf));
+			printf("tx: flags=%s", buf);
 			printf("\n");
 		}
 	}
diff --git a/app/test-pmd/rxonly.c b/app/test-pmd/rxonly.c
index 9acc4c6..fff815c 100644
--- a/app/test-pmd/rxonly.c
+++ b/app/test-pmd/rxonly.c
@@ -229,19 +229,8 @@ pkt_burst_receive(struct fwd_stream *fs)
 		}
 		printf(" - Receive queue=0x%x", (unsigned) fs->rx_queue);
 		printf("\n");
-		if (ol_flags != 0) {
-			unsigned rxf;
-			const char *name;
-
-			for (rxf = 0; rxf < sizeof(mb->ol_flags) * 8; rxf++) {
-				if ((ol_flags & (1ULL << rxf)) == 0)
-					continue;
-				name = rte_get_rx_ol_flag_name(1ULL << rxf);
-				if (name == NULL)
-					continue;
-				printf("  %s\n", name);
-			}
-		}
+		rte_get_rx_ol_flag_list(mb->ol_flags, buf, sizeof(buf));
+		printf("  ol_flags: %s\n", buf);
 		rte_pktmbuf_free(mb);
 	}
 
-- 
2.8.1

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

* [dpdk-dev] [PATCH v6 3/8] app/testpmd: dump Rx flags in csum engine
  2016-10-12 15:39   ` [dpdk-dev] [PATCH v6 " Olivier Matz
  2016-10-12 15:39     ` [dpdk-dev] [PATCH v6 1/8] mbuf: add function to dump ol flag list Olivier Matz
  2016-10-12 15:39     ` [dpdk-dev] [PATCH v6 2/8] app/testpmd: use new function to dump offload flags Olivier Matz
@ 2016-10-12 15:39     ` Olivier Matz
  2016-10-12 15:39     ` [dpdk-dev] [PATCH v6 4/8] app/testpmd: add option to enable lro Olivier Matz
                       ` (5 subsequent siblings)
  8 siblings, 0 replies; 40+ messages in thread
From: Olivier Matz @ 2016-10-12 15:39 UTC (permalink / raw)
  To: dev, pablo.de.lara.guarch; +Cc: thomas.monjalon

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 app/test-pmd/csumonly.c | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index 2ecd6b8..42974d5 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -652,7 +652,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 	uint16_t nb_rx;
 	uint16_t nb_tx;
 	uint16_t i;
-	uint64_t ol_flags;
+	uint64_t rx_ol_flags, tx_ol_flags;
 	uint16_t testpmd_ol_flags;
 	uint32_t retry;
 	uint32_t rx_bad_ip_csum;
@@ -693,13 +693,14 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 			rte_prefetch0(rte_pktmbuf_mtod(pkts_burst[i + 1],
 						       void *));
 
-		ol_flags = 0;
-		info.is_tunnel = 0;
 		m = pkts_burst[i];
+		info.is_tunnel = 0;
+		tx_ol_flags = 0;
+		rx_ol_flags = m->ol_flags;
 
 		/* Update the L3/L4 checksum error packet statistics */
-		rx_bad_ip_csum += ((m->ol_flags & PKT_RX_IP_CKSUM_BAD) != 0);
-		rx_bad_l4_csum += ((m->ol_flags & PKT_RX_L4_CKSUM_BAD) != 0);
+		rx_bad_ip_csum += ((rx_ol_flags & PKT_RX_IP_CKSUM_BAD) != 0);
+		rx_bad_l4_csum += ((rx_ol_flags & PKT_RX_L4_CKSUM_BAD) != 0);
 
 		/* step 1: dissect packet, parsing optional vlan, ip4/ip6, vxlan
 		 * and inner headers */
@@ -721,7 +722,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 					info.l3_len);
 				parse_vxlan(udp_hdr, &info, m->packet_type);
 				if (info.is_tunnel)
-					ol_flags |= PKT_TX_TUNNEL_VXLAN;
+					tx_ol_flags |= PKT_TX_TUNNEL_VXLAN;
 			} else if (info.l4_proto == IPPROTO_GRE) {
 				struct simple_gre_hdr *gre_hdr;
 
@@ -729,14 +730,14 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 					((char *)l3_hdr + info.l3_len);
 				parse_gre(gre_hdr, &info);
 				if (info.is_tunnel)
-					ol_flags |= PKT_TX_TUNNEL_GRE;
+					tx_ol_flags |= PKT_TX_TUNNEL_GRE;
 			} else if (info.l4_proto == IPPROTO_IPIP) {
 				void *encap_ip_hdr;
 
 				encap_ip_hdr = (char *)l3_hdr + info.l3_len;
 				parse_encap_ip(encap_ip_hdr, &info);
 				if (info.is_tunnel)
-					ol_flags |= PKT_TX_TUNNEL_IPIP;
+					tx_ol_flags |= PKT_TX_TUNNEL_IPIP;
 			}
 		}
 
@@ -759,15 +760,16 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 		 * is configured, prepare the mbuf for TCP segmentation. */
 
 		/* process checksums of inner headers first */
-		ol_flags |= process_inner_cksums(l3_hdr, &info, testpmd_ol_flags);
+		tx_ol_flags |= process_inner_cksums(l3_hdr, &info,
+			testpmd_ol_flags);
 
 		/* Then process outer headers if any. Note that the software
 		 * checksum will be wrong if one of the inner checksums is
 		 * processed in hardware. */
 		if (info.is_tunnel == 1) {
-			ol_flags |= process_outer_cksums(outer_l3_hdr, &info,
+			tx_ol_flags |= process_outer_cksums(outer_l3_hdr, &info,
 					testpmd_ol_flags,
-					!!(ol_flags & PKT_TX_TCP_SEG));
+					!!(tx_ol_flags & PKT_TX_TCP_SEG));
 		}
 
 		/* step 4: fill the mbuf meta data (flags and header lengths) */
@@ -802,7 +804,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 			m->l4_len = info.l4_len;
 			m->tso_segsz = info.tso_segsz;
 		}
-		m->ol_flags = ol_flags;
+		m->ol_flags = tx_ol_flags;
 
 		/* Do split & copy for the packet. */
 		if (tx_pkt_split != TX_PKT_SPLIT_OFF) {
@@ -822,10 +824,11 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 			printf("mbuf=%p, pkt_len=%u, nb_segs=%hhu:\n",
 				m, m->pkt_len, m->nb_segs);
 			/* dump rx parsed packet info */
+			rte_get_rx_ol_flag_list(rx_ol_flags, buf, sizeof(buf));
 			printf("rx: l2_len=%d ethertype=%x l3_len=%d "
-				"l4_proto=%d l4_len=%d\n",
+				"l4_proto=%d l4_len=%d flags=%s\n",
 				info.l2_len, rte_be_to_cpu_16(info.ethertype),
-				info.l3_len, info.l4_proto, info.l4_len);
+				info.l3_len, info.l4_proto, info.l4_len, buf);
 			if (info.is_tunnel == 1)
 				printf("rx: outer_l2_len=%d outer_ethertype=%x "
 					"outer_l3_len=%d\n", info.outer_l2_len,
-- 
2.8.1

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

* [dpdk-dev] [PATCH v6 4/8] app/testpmd: add option to enable lro
  2016-10-12 15:39   ` [dpdk-dev] [PATCH v6 " Olivier Matz
                       ` (2 preceding siblings ...)
  2016-10-12 15:39     ` [dpdk-dev] [PATCH v6 3/8] app/testpmd: dump Rx flags in csum engine Olivier Matz
@ 2016-10-12 15:39     ` Olivier Matz
  2016-10-12 15:39     ` [dpdk-dev] [PATCH v6 5/8] app/testpmd: do not change ip addrs in csum engine Olivier Matz
                       ` (4 subsequent siblings)
  8 siblings, 0 replies; 40+ messages in thread
From: Olivier Matz @ 2016-10-12 15:39 UTC (permalink / raw)
  To: dev, pablo.de.lara.guarch; +Cc: thomas.monjalon

Introduce a new argument '--enable-lro' to ask testpmd to enable the LRO
feature on enabled ports, like it's done for '--enable-rx-cksum' for
instance.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 app/test-pmd/parameters.c             | 4 ++++
 doc/guides/testpmd_app_ug/run_app.rst | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
index 6a6a07e..c45f78a 100644
--- a/app/test-pmd/parameters.c
+++ b/app/test-pmd/parameters.c
@@ -149,6 +149,7 @@ usage(char* progname)
 	       "If the drop-queue doesn't exist, the packet is dropped. "
 	       "By default drop-queue=127.\n");
 	printf("  --crc-strip: enable CRC stripping by hardware.\n");
+	printf("  --enable-lro: enable large receive offload.\n");
 	printf("  --enable-rx-cksum: enable rx hardware checksum offload.\n");
 	printf("  --disable-hw-vlan: disable hardware vlan.\n");
 	printf("  --disable-hw-vlan-filter: disable hardware vlan filter.\n");
@@ -524,6 +525,7 @@ launch_args_parse(int argc, char** argv)
 		{ "pkt-filter-size",            1, 0, 0 },
 		{ "pkt-filter-drop-queue",      1, 0, 0 },
 		{ "crc-strip",                  0, 0, 0 },
+		{ "enable-lro",                 0, 0, 0 },
 		{ "enable-rx-cksum",            0, 0, 0 },
 		{ "enable-scatter",             0, 0, 0 },
 		{ "disable-hw-vlan",            0, 0, 0 },
@@ -764,6 +766,8 @@ launch_args_parse(int argc, char** argv)
 			}
 			if (!strcmp(lgopts[opt_idx].name, "crc-strip"))
 				rx_mode.hw_strip_crc = 1;
+			if (!strcmp(lgopts[opt_idx].name, "enable-lro"))
+				rx_mode.enable_lro = 1;
 			if (!strcmp(lgopts[opt_idx].name, "enable-scatter"))
 				rx_mode.enable_scatter = 1;
 			if (!strcmp(lgopts[opt_idx].name, "enable-rx-cksum"))
diff --git a/doc/guides/testpmd_app_ug/run_app.rst b/doc/guides/testpmd_app_ug/run_app.rst
index 7712bd2..55c7ac0 100644
--- a/doc/guides/testpmd_app_ug/run_app.rst
+++ b/doc/guides/testpmd_app_ug/run_app.rst
@@ -285,6 +285,10 @@ The commandline options are:
 
     Enable hardware CRC stripping.
 
+*   ``--enable-lro``
+
+    Enable large receive offload.
+
 *   ``--enable-rx-cksum``
 
     Enable hardware RX checksum offload.
-- 
2.8.1

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

* [dpdk-dev] [PATCH v6 5/8] app/testpmd: do not change ip addrs in csum engine
  2016-10-12 15:39   ` [dpdk-dev] [PATCH v6 " Olivier Matz
                       ` (3 preceding siblings ...)
  2016-10-12 15:39     ` [dpdk-dev] [PATCH v6 4/8] app/testpmd: add option to enable lro Olivier Matz
@ 2016-10-12 15:39     ` Olivier Matz
  2016-10-12 15:39     ` [dpdk-dev] [PATCH v6 6/8] app/testpmd: display Rx port " Olivier Matz
                       ` (3 subsequent siblings)
  8 siblings, 0 replies; 40+ messages in thread
From: Olivier Matz @ 2016-10-12 15:39 UTC (permalink / raw)
  To: dev, pablo.de.lara.guarch; +Cc: thomas.monjalon

The csum forward engine was updated to change the IP addresses in the
packet data in
commit 51f694dd40f5 ("app/testpmd: rework checksum forward engine")

This was done to ensure that the checksum is correctly reprocessed when
using hardware checksum offload. But the functions
process_inner_cksums() and process_outer_cksums() already reset the
checksum field to 0, so this is not necessary.

Moreover, this makes the engine more complex than needed, and prevents
to easily use it to forward traffic (like iperf) as it modifies the
packets.

This patch drops this behavior.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 app/test-pmd/csumonly.c | 27 ++-------------------------
 1 file changed, 2 insertions(+), 25 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index 42974d5..34d4b11 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -318,21 +318,6 @@ parse_encap_ip(void *encap_ip, struct testpmd_offload_info *info)
 	info->l2_len = 0;
 }
 
-/* modify the IPv4 or IPv4 source address of a packet */
-static void
-change_ip_addresses(void *l3_hdr, uint16_t ethertype)
-{
-	struct ipv4_hdr *ipv4_hdr = l3_hdr;
-	struct ipv6_hdr *ipv6_hdr = l3_hdr;
-
-	if (ethertype == _htons(ETHER_TYPE_IPv4)) {
-		ipv4_hdr->src_addr =
-			rte_cpu_to_be_32(rte_be_to_cpu_32(ipv4_hdr->src_addr) + 1);
-	} else if (ethertype == _htons(ETHER_TYPE_IPv6)) {
-		ipv6_hdr->src_addr[15] = ipv6_hdr->src_addr[15] + 1;
-	}
-}
-
 /* if possible, calculate the checksum of a packet in hw or sw,
  * depending on the testpmd command line configuration */
 static uint64_t
@@ -620,7 +605,6 @@ pkt_copy_split(const struct rte_mbuf *pkt)
  * Receive a burst of packets, and for each packet:
  *  - parse packet, and try to recognize a supported packet type (1)
  *  - if it's not a supported packet type, don't touch the packet, else:
- *  - modify the IPs in inner headers and in outer headers if any
  *  - reprocess the checksum of all supported layers. This is done in SW
  *    or HW, depending on testpmd command line configuration
  *  - if TSO is enabled in testpmd command line, also flag the mbuf for TCP
@@ -747,14 +731,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 			l3_hdr = (char *)l3_hdr + info.outer_l3_len + info.l2_len;
 		}
 
-		/* step 2: change all source IPs (v4 or v6) so we need
-		 * to recompute the chksums even if they were correct */
-
-		change_ip_addresses(l3_hdr, info.ethertype);
-		if (info.is_tunnel == 1)
-			change_ip_addresses(outer_l3_hdr, info.outer_ethertype);
-
-		/* step 3: depending on user command line configuration,
+		/* step 2: depending on user command line configuration,
 		 * recompute checksum either in software or flag the
 		 * mbuf to offload the calculation to the NIC. If TSO
 		 * is configured, prepare the mbuf for TCP segmentation. */
@@ -772,7 +749,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 					!!(tx_ol_flags & PKT_TX_TCP_SEG));
 		}
 
-		/* step 4: fill the mbuf meta data (flags and header lengths) */
+		/* step 3: fill the mbuf meta data (flags and header lengths) */
 
 		if (info.is_tunnel == 1) {
 			if (info.tunnel_tso_segsz ||
-- 
2.8.1

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

* [dpdk-dev] [PATCH v6 6/8] app/testpmd: display Rx port in csum engine
  2016-10-12 15:39   ` [dpdk-dev] [PATCH v6 " Olivier Matz
                       ` (4 preceding siblings ...)
  2016-10-12 15:39     ` [dpdk-dev] [PATCH v6 5/8] app/testpmd: do not change ip addrs in csum engine Olivier Matz
@ 2016-10-12 15:39     ` Olivier Matz
  2016-10-12 15:39     ` [dpdk-dev] [PATCH v6 7/8] app/testpmd: don't use tso if packet is too small Olivier Matz
                       ` (2 subsequent siblings)
  8 siblings, 0 replies; 40+ messages in thread
From: Olivier Matz @ 2016-10-12 15:39 UTC (permalink / raw)
  To: dev, pablo.de.lara.guarch; +Cc: thomas.monjalon

This information is useful when debugging, especially with
bidirectional traffic.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 app/test-pmd/csumonly.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index 34d4b11..dbd8dc4 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -798,8 +798,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 			char buf[256];
 
 			printf("-----------------\n");
-			printf("mbuf=%p, pkt_len=%u, nb_segs=%hhu:\n",
-				m, m->pkt_len, m->nb_segs);
+			printf("port=%u, mbuf=%p, pkt_len=%u, nb_segs=%hhu:\n",
+				fs->rx_port, m, m->pkt_len, m->nb_segs);
 			/* dump rx parsed packet info */
 			rte_get_rx_ol_flag_list(rx_ol_flags, buf, sizeof(buf));
 			printf("rx: l2_len=%d ethertype=%x l3_len=%d "
-- 
2.8.1

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

* [dpdk-dev] [PATCH v6 7/8] app/testpmd: don't use tso if packet is too small
  2016-10-12 15:39   ` [dpdk-dev] [PATCH v6 " Olivier Matz
                       ` (5 preceding siblings ...)
  2016-10-12 15:39     ` [dpdk-dev] [PATCH v6 6/8] app/testpmd: display Rx port " Olivier Matz
@ 2016-10-12 15:39     ` Olivier Matz
  2016-10-12 15:39     ` [dpdk-dev] [PATCH v6 8/8] app/testpmd: hide segsize when unrelevant in csum engine Olivier Matz
  2016-10-12 16:41     ` [dpdk-dev] [PATCH v6 0/8] Misc enhancements in testpmd Thomas Monjalon
  8 siblings, 0 replies; 40+ messages in thread
From: Olivier Matz @ 2016-10-12 15:39 UTC (permalink / raw)
  To: dev, pablo.de.lara.guarch; +Cc: thomas.monjalon

Asking for TSO (TCP Segmentation Offload) on packets that are already
smaller than (headers + MSS) does not work, for instance on ixgbe.

Fix the csumonly engine to only set the TSO flag when a segmentation
offload is really required, i.e. when packet is large enough.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 app/test-pmd/csumonly.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index dbd8dc4..d51d85a 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -102,6 +102,7 @@ struct testpmd_offload_info {
 	uint8_t outer_l4_proto;
 	uint16_t tso_segsz;
 	uint16_t tunnel_tso_segsz;
+	uint32_t pkt_len;
 };
 
 /* simplified GRE header */
@@ -329,6 +330,21 @@ process_inner_cksums(void *l3_hdr, const struct testpmd_offload_info *info,
 	struct tcp_hdr *tcp_hdr;
 	struct sctp_hdr *sctp_hdr;
 	uint64_t ol_flags = 0;
+	uint32_t max_pkt_len, tso_segsz = 0;
+
+	/* ensure packet is large enough to require tso */
+	if (!info->is_tunnel) {
+		max_pkt_len = info->l2_len + info->l3_len + info->l4_len +
+			info->tso_segsz;
+		if (info->tunnel_tso_segsz != 0 && info->pkt_len > max_pkt_len)
+			tso_segsz = info->tso_segsz;
+	} else {
+		max_pkt_len = info->outer_l2_len + info->outer_l3_len +
+			info->l2_len + info->l3_len + info->l4_len +
+			info->tunnel_tso_segsz;
+		if (info->tunnel_tso_segsz != 0 && info->pkt_len > max_pkt_len)
+			tso_segsz = info->tunnel_tso_segsz;
+	}
 
 	if (info->ethertype == _htons(ETHER_TYPE_IPv4)) {
 		ipv4_hdr = l3_hdr;
@@ -369,8 +385,7 @@ process_inner_cksums(void *l3_hdr, const struct testpmd_offload_info *info,
 	} else if (info->l4_proto == IPPROTO_TCP) {
 		tcp_hdr = (struct tcp_hdr *)((char *)l3_hdr + info->l3_len);
 		tcp_hdr->cksum = 0;
-		if ((info->is_tunnel && info->tunnel_tso_segsz != 0) ||
-		    (!info->is_tunnel && info->tso_segsz != 0)) {
+		if (tso_segsz) {
 			ol_flags |= PKT_TX_TCP_SEG;
 			tcp_hdr->cksum = get_psd_sum(l3_hdr, info->ethertype,
 				ol_flags);
@@ -679,6 +694,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 
 		m = pkts_burst[i];
 		info.is_tunnel = 0;
+		info.pkt_len = rte_pktmbuf_pkt_len(m);
 		tx_ol_flags = 0;
 		rx_ol_flags = m->ol_flags;
 
-- 
2.8.1

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

* [dpdk-dev] [PATCH v6 8/8] app/testpmd: hide segsize when unrelevant in csum engine
  2016-10-12 15:39   ` [dpdk-dev] [PATCH v6 " Olivier Matz
                       ` (6 preceding siblings ...)
  2016-10-12 15:39     ` [dpdk-dev] [PATCH v6 7/8] app/testpmd: don't use tso if packet is too small Olivier Matz
@ 2016-10-12 15:39     ` Olivier Matz
  2016-10-12 16:41     ` [dpdk-dev] [PATCH v6 0/8] Misc enhancements in testpmd Thomas Monjalon
  8 siblings, 0 replies; 40+ messages in thread
From: Olivier Matz @ 2016-10-12 15:39 UTC (permalink / raw)
  To: dev, pablo.de.lara.guarch; +Cc: thomas.monjalon

When TSO is not asked, hide the segment size.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 app/test-pmd/csumonly.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index d51d85a..f9e65b6 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -843,10 +843,12 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 						"m->outer_l3_len=%d\n",
 						m->outer_l2_len,
 						m->outer_l3_len);
-				if (info.tunnel_tso_segsz != 0)
+				if (info.tunnel_tso_segsz != 0 &&
+						(m->ol_flags & PKT_TX_TCP_SEG))
 					printf("tx: m->tso_segsz=%d\n",
 						m->tso_segsz);
-			} else if (info.tso_segsz != 0)
+			} else if (info.tso_segsz != 0 &&
+					(m->ol_flags & PKT_TX_TCP_SEG))
 				printf("tx: m->tso_segsz=%d\n", m->tso_segsz);
 			rte_get_tx_ol_flag_list(m->ol_flags, buf, sizeof(buf));
 			printf("tx: flags=%s", buf);
-- 
2.8.1

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

* Re: [dpdk-dev] [PATCH v6 0/8] Misc enhancements in testpmd
  2016-10-12 15:39   ` [dpdk-dev] [PATCH v6 " Olivier Matz
                       ` (7 preceding siblings ...)
  2016-10-12 15:39     ` [dpdk-dev] [PATCH v6 8/8] app/testpmd: hide segsize when unrelevant in csum engine Olivier Matz
@ 2016-10-12 16:41     ` Thomas Monjalon
  8 siblings, 0 replies; 40+ messages in thread
From: Thomas Monjalon @ 2016-10-12 16:41 UTC (permalink / raw)
  To: Olivier Matz; +Cc: dev, pablo.de.lara.guarch

2016-10-12 17:39, Olivier Matz:
> This patchset introduces several enhancements or minor fixes
> in testpmd. It is targetted for v16.11, and applies on top of
> software ptype v2 patchset [1].
> 
> These patches are useful to validate the virtio offload
> patchset [2] (to be rebased).

Applied, thanks

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

end of thread, other threads:[~2016-10-12 16:41 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-09  7:55 [dpdk-dev] [PATCH v2 0/8] Misc enhancements in testpmd Olivier Matz
2016-09-09  7:55 ` [dpdk-dev] [PATCH v2 1/8] mbuf: add function to dump ol flag list Olivier Matz
2016-10-05  6:45   ` De Lara Guarch, Pablo
2016-10-05 14:19     ` Olivier Matz
2016-10-06  8:42   ` [dpdk-dev] [PATCH v3] " Olivier Matz
2016-10-07  3:51     ` De Lara Guarch, Pablo
2016-10-07 15:39       ` Olivier Matz
2016-09-09  7:55 ` [dpdk-dev] [PATCH v2 2/8] app/testpmd: use new function to dump offload flags Olivier Matz
2016-09-09  7:55 ` [dpdk-dev] [PATCH v2 3/8] app/testpmd: dump rx flags in csum engine Olivier Matz
2016-09-09  7:55 ` [dpdk-dev] [PATCH v2 4/8] app/testpmd: add option to enable lro Olivier Matz
2016-10-05  6:26   ` De Lara Guarch, Pablo
2016-10-05 14:18     ` Olivier Matz
2016-10-06  8:44   ` [dpdk-dev] [PATCH v3] " Olivier Matz
2016-10-06  8:47     ` [dpdk-dev] [PATCH v4] " Olivier Matz
2016-09-09  7:55 ` [dpdk-dev] [PATCH v2 5/8] app/testpmd: do not change ip addrs in csum engine Olivier Matz
2016-09-09  7:55 ` [dpdk-dev] [PATCH v2 6/8] app/testpmd: display rx port " Olivier Matz
2016-09-09  7:55 ` [dpdk-dev] [PATCH v2 7/8] app/testpmd: don't use tso if packet is too small Olivier Matz
2016-09-09  7:55 ` [dpdk-dev] [PATCH v2 8/8] app/testpmd: hide segsize when unrelevant in csum engine Olivier Matz
2016-10-03  9:02 ` [dpdk-dev] [PATCH v2 0/8] Misc enhancements in testpmd Olivier Matz
2016-10-07 16:05 ` [dpdk-dev] [PATCH v5 " Olivier Matz
2016-10-07 16:05   ` [dpdk-dev] [PATCH v5 1/8] mbuf: add function to dump ol flag list Olivier Matz
2016-10-11 20:42     ` Thomas Monjalon
2016-10-07 16:05   ` [dpdk-dev] [PATCH v5 2/8] app/testpmd: use new function to dump offload flags Olivier Matz
2016-10-07 16:05   ` [dpdk-dev] [PATCH v5 3/8] app/testpmd: dump Rx flags in csum engine Olivier Matz
2016-10-07 16:05   ` [dpdk-dev] [PATCH v5 4/8] app/testpmd: add option to enable lro Olivier Matz
2016-10-07 16:05   ` [dpdk-dev] [PATCH v5 5/8] app/testpmd: do not change ip addrs in csum engine Olivier Matz
2016-10-07 16:05   ` [dpdk-dev] [PATCH v5 6/8] app/testpmd: display Rx port " Olivier Matz
2016-10-07 16:05   ` [dpdk-dev] [PATCH v5 7/8] app/testpmd: don't use tso if packet is too small Olivier Matz
2016-10-07 16:05   ` [dpdk-dev] [PATCH v5 8/8] app/testpmd: hide segsize when unrelevant in csum engine Olivier Matz
2016-10-11 18:13   ` [dpdk-dev] [PATCH v5 0/8] Misc enhancements in testpmd De Lara Guarch, Pablo
2016-10-12 15:39   ` [dpdk-dev] [PATCH v6 " Olivier Matz
2016-10-12 15:39     ` [dpdk-dev] [PATCH v6 1/8] mbuf: add function to dump ol flag list Olivier Matz
2016-10-12 15:39     ` [dpdk-dev] [PATCH v6 2/8] app/testpmd: use new function to dump offload flags Olivier Matz
2016-10-12 15:39     ` [dpdk-dev] [PATCH v6 3/8] app/testpmd: dump Rx flags in csum engine Olivier Matz
2016-10-12 15:39     ` [dpdk-dev] [PATCH v6 4/8] app/testpmd: add option to enable lro Olivier Matz
2016-10-12 15:39     ` [dpdk-dev] [PATCH v6 5/8] app/testpmd: do not change ip addrs in csum engine Olivier Matz
2016-10-12 15:39     ` [dpdk-dev] [PATCH v6 6/8] app/testpmd: display Rx port " Olivier Matz
2016-10-12 15:39     ` [dpdk-dev] [PATCH v6 7/8] app/testpmd: don't use tso if packet is too small Olivier Matz
2016-10-12 15:39     ` [dpdk-dev] [PATCH v6 8/8] app/testpmd: hide segsize when unrelevant in csum engine Olivier Matz
2016-10-12 16:41     ` [dpdk-dev] [PATCH v6 0/8] Misc enhancements in testpmd 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).