DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 0/8] Misc enhancements in testpmd
@ 2016-07-11 18:39 Olivier Matz
  2016-07-11 18:39 ` [dpdk-dev] [PATCH 1/8] mbuf: add function to dump ol flag list Olivier Matz
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Olivier Matz @ 2016-07-11 18:39 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 patchset [1].

These patches will be useful to test another patchset (coming
soon !) that brings support for offload in virtio pmd.

[1] http://dpdk.org/ml/archives/dev/2016-July/043333.html

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] 9+ messages in thread

* [dpdk-dev] [PATCH 1/8] mbuf: add function to dump ol flag list
  2016-07-11 18:39 [dpdk-dev] [PATCH 0/8] Misc enhancements in testpmd Olivier Matz
@ 2016-07-11 18:39 ` Olivier Matz
  2016-07-11 18:39 ` [dpdk-dev] [PATCH 2/8] app/testpmd: use new function to dump offload flags Olivier Matz
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Olivier Matz @ 2016-07-11 18:39 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 7ce201b..6a591e2 100644
--- a/doc/guides/rel_notes/release_16_11.rst
+++ b/doc/guides/rel_notes/release_16_11.rst
@@ -48,6 +48,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 a515ece..f959bf2 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -316,6 +316,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.
@@ -338,3 +385,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 ad6f660..3c21c71 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 0f04b02..6f83745 100644
--- a/lib/librte_mbuf/rte_mbuf_version.map
+++ b/lib/librte_mbuf/rte_mbuf_version.map
@@ -31,6 +31,8 @@ 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;
 	rte_pktmbuf_get_ptype;
 
 } DPDK_2.1;
-- 
2.8.1

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

* [dpdk-dev] [PATCH 2/8] app/testpmd: use new function to dump offload flags
  2016-07-11 18:39 [dpdk-dev] [PATCH 0/8] Misc enhancements in testpmd Olivier Matz
  2016-07-11 18:39 ` [dpdk-dev] [PATCH 1/8] mbuf: add function to dump ol flag list Olivier Matz
@ 2016-07-11 18:39 ` Olivier Matz
  2016-07-11 18:39 ` [dpdk-dev] [PATCH 3/8] app/testpmd: dump rx flags in csum engine Olivier Matz
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Olivier Matz @ 2016-07-11 18:39 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 00da1a2..98da7e5 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] 9+ messages in thread

* [dpdk-dev] [PATCH 3/8] app/testpmd: dump rx flags in csum engine
  2016-07-11 18:39 [dpdk-dev] [PATCH 0/8] Misc enhancements in testpmd Olivier Matz
  2016-07-11 18:39 ` [dpdk-dev] [PATCH 1/8] mbuf: add function to dump ol flag list Olivier Matz
  2016-07-11 18:39 ` [dpdk-dev] [PATCH 2/8] app/testpmd: use new function to dump offload flags Olivier Matz
@ 2016-07-11 18:39 ` Olivier Matz
  2016-07-11 18:39 ` [dpdk-dev] [PATCH 4/8] app/testpmd: add option to enable lro Olivier Matz
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Olivier Matz @ 2016-07-11 18:39 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] 9+ messages in thread

* [dpdk-dev] [PATCH 4/8] app/testpmd: add option to enable lro
  2016-07-11 18:39 [dpdk-dev] [PATCH 0/8] Misc enhancements in testpmd Olivier Matz
                   ` (2 preceding siblings ...)
  2016-07-11 18:39 ` [dpdk-dev] [PATCH 3/8] app/testpmd: dump rx flags in csum engine Olivier Matz
@ 2016-07-11 18:39 ` Olivier Matz
  2016-07-11 18:39 ` [dpdk-dev] [PATCH 5/8] app/testpmd: do not change ip addrs in csum engine Olivier Matz
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Olivier Matz @ 2016-07-11 18:39 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] 9+ messages in thread

* [dpdk-dev] [PATCH 5/8] app/testpmd: do not change ip addrs in csum engine
  2016-07-11 18:39 [dpdk-dev] [PATCH 0/8] Misc enhancements in testpmd Olivier Matz
                   ` (3 preceding siblings ...)
  2016-07-11 18:39 ` [dpdk-dev] [PATCH 4/8] app/testpmd: add option to enable lro Olivier Matz
@ 2016-07-11 18:39 ` Olivier Matz
  2016-07-11 18:39 ` [dpdk-dev] [PATCH 6/8] app/testpmd: display rx port " Olivier Matz
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Olivier Matz @ 2016-07-11 18:39 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] 9+ messages in thread

* [dpdk-dev] [PATCH 6/8] app/testpmd: display rx port in csum engine
  2016-07-11 18:39 [dpdk-dev] [PATCH 0/8] Misc enhancements in testpmd Olivier Matz
                   ` (4 preceding siblings ...)
  2016-07-11 18:39 ` [dpdk-dev] [PATCH 5/8] app/testpmd: do not change ip addrs in csum engine Olivier Matz
@ 2016-07-11 18:39 ` Olivier Matz
  2016-07-11 18:39 ` [dpdk-dev] [PATCH 7/8] app/testpmd: don't use tso if packet is too small Olivier Matz
  2016-07-11 18:39 ` [dpdk-dev] [PATCH 8/8] app/testpmd: hide segsize when unrelevant in csum engine Olivier Matz
  7 siblings, 0 replies; 9+ messages in thread
From: Olivier Matz @ 2016-07-11 18:39 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] 9+ messages in thread

* [dpdk-dev] [PATCH 7/8] app/testpmd: don't use tso if packet is too small
  2016-07-11 18:39 [dpdk-dev] [PATCH 0/8] Misc enhancements in testpmd Olivier Matz
                   ` (5 preceding siblings ...)
  2016-07-11 18:39 ` [dpdk-dev] [PATCH 6/8] app/testpmd: display rx port " Olivier Matz
@ 2016-07-11 18:39 ` Olivier Matz
  2016-07-11 18:39 ` [dpdk-dev] [PATCH 8/8] app/testpmd: hide segsize when unrelevant in csum engine Olivier Matz
  7 siblings, 0 replies; 9+ messages in thread
From: Olivier Matz @ 2016-07-11 18:39 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] 9+ messages in thread

* [dpdk-dev] [PATCH 8/8] app/testpmd: hide segsize when unrelevant in csum engine
  2016-07-11 18:39 [dpdk-dev] [PATCH 0/8] Misc enhancements in testpmd Olivier Matz
                   ` (6 preceding siblings ...)
  2016-07-11 18:39 ` [dpdk-dev] [PATCH 7/8] app/testpmd: don't use tso if packet is too small Olivier Matz
@ 2016-07-11 18:39 ` Olivier Matz
  7 siblings, 0 replies; 9+ messages in thread
From: Olivier Matz @ 2016-07-11 18:39 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] 9+ messages in thread

end of thread, other threads:[~2016-07-11 18:39 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-11 18:39 [dpdk-dev] [PATCH 0/8] Misc enhancements in testpmd Olivier Matz
2016-07-11 18:39 ` [dpdk-dev] [PATCH 1/8] mbuf: add function to dump ol flag list Olivier Matz
2016-07-11 18:39 ` [dpdk-dev] [PATCH 2/8] app/testpmd: use new function to dump offload flags Olivier Matz
2016-07-11 18:39 ` [dpdk-dev] [PATCH 3/8] app/testpmd: dump rx flags in csum engine Olivier Matz
2016-07-11 18:39 ` [dpdk-dev] [PATCH 4/8] app/testpmd: add option to enable lro Olivier Matz
2016-07-11 18:39 ` [dpdk-dev] [PATCH 5/8] app/testpmd: do not change ip addrs in csum engine Olivier Matz
2016-07-11 18:39 ` [dpdk-dev] [PATCH 6/8] app/testpmd: display rx port " Olivier Matz
2016-07-11 18:39 ` [dpdk-dev] [PATCH 7/8] app/testpmd: don't use tso if packet is too small Olivier Matz
2016-07-11 18:39 ` [dpdk-dev] [PATCH 8/8] app/testpmd: hide segsize when unrelevant in csum engine Olivier Matz

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