DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 0/6] Support generic tunnel TX csum and TSO
@ 2018-01-09 14:11 Xueming Li
  2018-01-09 14:11 ` [dpdk-dev] [PATCH 1/6] net/mlx5: support tx swp tunnel offloading Xueming Li
                   ` (5 more replies)
  0 siblings, 6 replies; 80+ messages in thread
From: Xueming Li @ 2018-01-09 14:11 UTC (permalink / raw)
  To: Olivier MATZ, Thomas Monjalon, Jingjing Wu, Yongseok Koh
  Cc: Xueming Li, Shahaf Shuler, dev

This patchset add new HW TX capability of generic tunnel checksum and TSO
offloads, HW supporting generic tunnel offloading could handle new tunnel 
type offloading w/o upgrading HW. 

This is achieved by informing HW offsets and types of headers, HW would 
do calculation and TSO segments based on packet inner and outer headers offset
regardless of tunnel type.

Xueming Li (6):
  net/mlx5: support tx swp tunnel offloading
  net/mlx5: allow max 192B WQE TSO inline header length
  net/mlx5: add SWP PCI parameter for TX common tunnel offloads
  ethdev: introduce TX common tunnel offloads
  net/mlx5: support TX common tunnel offloads
  app/testpmd: testpmd support TX common tunnel offloads

 app/test-pmd/cmdline.c         |   9 ++-
 app/test-pmd/config.c          |   9 +++
 drivers/net/mlx5/mlx5.c        |   7 ++
 drivers/net/mlx5/mlx5.h        |   1 +
 drivers/net/mlx5/mlx5_defs.h   |   2 +-
 drivers/net/mlx5/mlx5_ethdev.c |   3 +-
 drivers/net/mlx5/mlx5_prm.h    |  12 +++
 drivers/net/mlx5/mlx5_rxtx.c   | 163 ++++++++++++++++++++++++++---------------
 drivers/net/mlx5/mlx5_rxtx.h   |  94 +++++++++++++++++++-----
 drivers/net/mlx5/mlx5_txq.c    |   4 +
 lib/librte_ether/rte_ethdev.h  |   9 +++
 11 files changed, 234 insertions(+), 79 deletions(-)

-- 
2.13.3

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

* [dpdk-dev] [PATCH 1/6] net/mlx5: support tx swp tunnel offloading
  2018-01-09 14:11 [dpdk-dev] [PATCH 0/6] Support generic tunnel TX csum and TSO Xueming Li
@ 2018-01-09 14:11 ` Xueming Li
  2018-01-29 15:08   ` [dpdk-dev] [PATCH v2 1/5] ethdev: introduce Tx generic tunnel offloads Xueming Li
                     ` (17 more replies)
  2018-01-09 14:11 ` [dpdk-dev] [PATCH 2/6] net/mlx5: allow max 192B WQE TSO inline header length Xueming Li
                   ` (4 subsequent siblings)
  5 siblings, 18 replies; 80+ messages in thread
From: Xueming Li @ 2018-01-09 14:11 UTC (permalink / raw)
  To: Olivier MATZ, Thomas Monjalon, Jingjing Wu, Yongseok Koh
  Cc: Xueming Li, Shahaf Shuler, dev

This commit adds support for generic tunnel TSO and checksum offloads.
The PMD will compute the inner/outer headers offset according to the
mbuf fields. The Hardware will do calculation according to offsets and types.
Such capability is supported only for PFs.

Signed-off-by: Xueming Li <xuemingl@mellanox.com>

---
 drivers/net/mlx5/mlx5_prm.h  |  12 ++++
 drivers/net/mlx5/mlx5_rxtx.c | 163 ++++++++++++++++++++++++++++---------------
 drivers/net/mlx5/mlx5_rxtx.h |  94 ++++++++++++++++++++-----
 drivers/net/mlx5/mlx5_txq.c  |   1 +
 4 files changed, 195 insertions(+), 75 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_prm.h b/drivers/net/mlx5/mlx5_prm.h
index 2de310bcb..edf39c249 100644
--- a/drivers/net/mlx5/mlx5_prm.h
+++ b/drivers/net/mlx5/mlx5_prm.h
@@ -135,6 +135,18 @@
 /* Inner L4 checksum offload (Tunneled packets only). */
 #define MLX5_ETH_WQE_L4_INNER_CSUM (1u << 5)
 
+/* Outer L4 type is UDP. */
+#define MLX5_ETH_OUTER_L4_UDP  (1u << 5)
+
+/* Outer L3 type is IPV6. */
+#define MLX5_ETH_OUTER_L3_IPV6 (1u << 4)
+
+/* Inner L4 type is UDP. */
+#define MLX5_ETH_INNER_L4_UDP (1u << 1)
+
+/* Inner L3 type is IPV6. */
+#define MLX5_ETH_INNER_L3_IPV6 (1u << 0)
+
 /* Is flow mark valid. */
 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
 #define MLX5_FLOW_MARK_IS_VALID(val) ((val) & 0xffffff00)
diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c
index 3b8f71c28..d79f9fc0e 100644
--- a/drivers/net/mlx5/mlx5_rxtx.c
+++ b/drivers/net/mlx5/mlx5_rxtx.c
@@ -247,6 +247,80 @@ mlx5_copy_to_wq(void *dst, const void *src, size_t n,
 }
 
 /**
+ * Inline TSO headers into WQE and set checksums fields.
+ *
+ * @param txq
+ *   Pointer to TX queue structure.
+ * @param buf
+ *   Pointer to packet mbuf structure.
+ * @param raw
+ *   Double pointer to WQE current write offset.
+ * @param cs_flags
+ *   Pointer to checksums flags.
+ * @swp_offsets
+ *   Pointer to header offsets when using software parser.
+ * @swp_types
+ *   Pointer to header types when using software parser.
+ * @param max_wqe
+ *   Pointer to the available number of wqes.
+ *
+ * @return
+ *   Headers size which were copied into wqe upon success,
+ *   negative errno value otherwise, the following erros
+ *   are defined:
+ *
+ *   -EINVAL: invalid arugments for TSO. packet headers are too large
+ *   or not enough WQEs. cannot execute the TSO.
+ *
+ *   -ENOMEM: reached the end of WQ ring. the TSO WQE can be executed
+ *   only after the WQ ring wraparound.
+ */
+static int
+process_tso(struct mlx5_txq_data *txq, struct rte_mbuf *buf, uint8_t **raw,
+	    uint16_t *max_wqe)
+{
+	uintptr_t addr = rte_pktmbuf_mtod(buf, uintptr_t);
+	volatile struct mlx5_wqe *wqe = (volatile struct mlx5_wqe *)
+					 tx_mlx5_wqe(txq, txq->wqe_ci);
+	uint8_t *curr = *raw;
+	const uint8_t tunneled = txq->tunnel_en &&
+			       (buf->ol_flags & PKT_TX_TUNNEL_MASK);
+	uint16_t pkt_inline_sz = (uintptr_t)curr - (uintptr_t)wqe -
+				 (MLX5_WQE_DWORD_SIZE * 2 - 2);
+	uint8_t vlan_sz = (buf->ol_flags & PKT_TX_VLAN_PKT) ? 4 : 0;
+	uintptr_t end = (uintptr_t)(((uintptr_t)txq->wqes) +
+				    (1 << txq->wqe_n) * MLX5_WQE_SIZE);
+	unsigned int copy_b;
+	uint16_t tso_header_sz;
+
+	if (vlan_sz)
+		addr += 2 * ETHER_ADDR_LEN + 2;
+	else
+		addr += pkt_inline_sz;
+	tso_header_sz = buf->l2_len + vlan_sz +	buf->l3_len + buf->l4_len;
+	if (tunneled)
+		tso_header_sz += buf->outer_l2_len + buf->outer_l3_len;
+	if (unlikely(tso_header_sz > MLX5_MAX_TSO_HEADER)) {
+		txq->stats.oerrors++;
+		return -EINVAL;
+	}
+	copy_b = tso_header_sz - pkt_inline_sz;
+	if (copy_b && ((end - (uintptr_t)curr) > copy_b)) {
+		uint16_t n = (MLX5_WQE_DS(copy_b) - 1 + 3) / 4;
+
+		if (unlikely(*max_wqe < n))
+			return -EINVAL;
+		*max_wqe -= n;
+		rte_memcpy((void *)curr, (void *)addr, copy_b);
+		/* Another DWORD will be added in the inline part. */
+		*raw = curr + MLX5_WQE_DS(copy_b) * MLX5_WQE_DWORD_SIZE;
+	} else {
+		return -ENOMEM;
+	}
+	return copy_b;
+}
+
+/**
  * DPDK callback to check the status of a tx descriptor.
  *
  * @param tx_queue
@@ -376,6 +450,8 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
 		uint16_t ehdr;
 		uint8_t cs_flags;
 		uint64_t tso = 0;
+		uint32_t swp_offsets = 0;
+		uint8_t swp_types = 0;
 		uint16_t tso_segsz = 0;
 #ifdef MLX5_PMD_SOFT_COUNTERS
 		uint32_t total_length = 0;
@@ -417,7 +493,9 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
 		if (pkts_n - i > 1)
 			rte_prefetch0(
 			    rte_pktmbuf_mtod(*(pkts + 1), volatile void *));
-		cs_flags = txq_ol_cksum_to_cs(txq, buf);
+		cs_flags = txq_ol_flags_to_verbs(txq, buf,
+						 (uint8_t *)&swp_offsets,
+						 &swp_types);
 		raw = ((uint8_t *)(uintptr_t)wqe) + 2 * MLX5_WQE_DWORD_SIZE;
 		/* Replace the Ethernet type by the VLAN if necessary. */
 		if (buf->ol_flags & PKT_TX_VLAN_PKT) {
@@ -445,69 +523,37 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
 		raw += MLX5_WQE_DWORD_SIZE;
 		tso = txq->tso_en && (buf->ol_flags & PKT_TX_TCP_SEG);
 		if (tso) {
-			uintptr_t end =
-				(uintptr_t)(((uintptr_t)txq->wqes) +
-					    (1 << txq->wqe_n) * MLX5_WQE_SIZE);
-			unsigned int copy_b;
-			uint8_t vlan_sz =
-				(buf->ol_flags & PKT_TX_VLAN_PKT) ? 4 : 0;
-			const uint64_t is_tunneled =
-				buf->ol_flags & (PKT_TX_TUNNEL_GRE |
-						 PKT_TX_TUNNEL_VXLAN);
-
-			tso_header_sz = buf->l2_len + vlan_sz +
-					buf->l3_len + buf->l4_len;
-			tso_segsz = buf->tso_segsz;
-			if (unlikely(tso_segsz == 0)) {
-				txq->stats.oerrors++;
-				break;
-			}
-			if (is_tunneled	&& txq->tunnel_en) {
-				tso_header_sz += buf->outer_l2_len +
-						 buf->outer_l3_len;
-				cs_flags |= MLX5_ETH_WQE_L4_INNER_CSUM;
-			} else {
-				cs_flags |= MLX5_ETH_WQE_L4_CSUM;
-			}
-			if (unlikely(tso_header_sz > MLX5_MAX_TSO_HEADER)) {
-				txq->stats.oerrors++;
-				break;
-			}
-			copy_b = tso_header_sz - pkt_inline_sz;
-			/* First seg must contain all headers. */
-			assert(copy_b <= length);
-			if (copy_b && ((end - (uintptr_t)raw) > copy_b)) {
-				uint16_t n = (MLX5_WQE_DS(copy_b) - 1 + 3) / 4;
+			int ret;
 
-				if (unlikely(max_wqe < n))
-					break;
-				max_wqe -= n;
-				rte_memcpy((void *)raw, (void *)addr, copy_b);
-				addr += copy_b;
-				length -= copy_b;
-				/* Include padding for TSO header. */
-				copy_b = MLX5_WQE_DS(copy_b) *
-					 MLX5_WQE_DWORD_SIZE;
-				pkt_inline_sz += copy_b;
-				raw += copy_b;
-			} else {
+			ret = process_tso(txq, buf, &raw, &max_wqe);
+			if (ret == -EINVAL) {
+				break;
+			} else if (ret == -ENOMEM) {
 				/* NOP WQE. */
 				wqe->ctrl = (rte_v128u32_t){
-					rte_cpu_to_be_32(txq->wqe_ci << 8),
-					rte_cpu_to_be_32(txq->qp_num_8s | 1),
-					0,
-					0,
+						rte_cpu_to_be_32(txq->wqe_ci << 8),
+						rte_cpu_to_be_32(txq->qp_num_8s | 1),
+						0,
+						0,
 				};
 				ds = 1;
-#ifdef MLX5_PMD_SOFT_COUNTERS
 				total_length = 0;
-#endif
 				k++;
 				goto next_wqe;
+			} else {
+				tso_segsz = buf->tso_segsz;
+				if (unlikely(tso_segsz == 0)) {
+					txq->stats.oerrors++;
+					break;
+				}
+				addr += ret;
+				length -= ret;
+				pkt_inline_sz += ret;
+				tso_header_sz = pkt_inline_sz;
 			}
 		}
 		/* Inline if enough room. */
-		if (max_inline || tso) {
+		if (max_inline || unlikely(tso)) {
 			uint32_t inl = 0;
 			uintptr_t end = (uintptr_t)
 				(((uintptr_t)txq->wqes) +
@@ -652,7 +698,7 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
 		++i;
 		j += sg;
 		/* Initialize known and common part of the WQE structure. */
-		if (tso) {
+		if (unlikely(tso)) {
 			wqe->ctrl = (rte_v128u32_t){
 				rte_cpu_to_be_32((txq->wqe_ci << 8) |
 						 MLX5_OPCODE_TSO),
@@ -661,8 +707,9 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
 				0,
 			};
 			wqe->eseg = (rte_v128u32_t){
-				0,
-				cs_flags | (rte_cpu_to_be_16(tso_segsz) << 16),
+				swp_offsets,
+				cs_flags | (swp_types << 8) |
+					(rte_cpu_to_be_16(tso_segsz) << 16),
 				0,
 				(ehdr << 16) | rte_cpu_to_be_16(tso_header_sz),
 			};
@@ -675,8 +722,8 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
 				0,
 			};
 			wqe->eseg = (rte_v128u32_t){
-				0,
-				cs_flags,
+				swp_offsets,
+				cs_flags | (swp_types << 8),
 				0,
 				(ehdr << 16) | rte_cpu_to_be_16(pkt_inline_sz),
 			};
diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h
index 4ade8bee1..852594708 100644
--- a/drivers/net/mlx5/mlx5_rxtx.h
+++ b/drivers/net/mlx5/mlx5_rxtx.h
@@ -196,6 +196,7 @@ struct mlx5_txq_data {
 	uint16_t tso_en:1; /* When set hardware TSO is enabled. */
 	uint16_t tunnel_en:1;
 	/* When set TX offload for tunneled packets are supported. */
+	uint16_t swp_en:1; /* When set software parser is supported. */
 	uint16_t mpw_hdr_dseg:1; /* Enable DSEGs in the title WQEBB. */
 	uint16_t max_inline; /* Multiple of RTE_CACHE_LINE_SIZE to inline. */
 	uint16_t inline_max_packet_sz; /* Max packet size for inlining. */
@@ -623,40 +624,99 @@ mlx5_tx_dbrec(struct mlx5_txq_data *txq, volatile struct mlx5_wqe *wqe)
 }
 
 /**
- * Convert the Checksum offloads to Verbs.
+ * Convert mbuf tx offloads info to Verbs.
  *
  * @param txq_data
  *   Pointer to the Tx queue.
  * @param buf
  *   Pointer to the mbuf.
+ * @param offsets
+ *   Pointer to the header offsets.
+ * @param swp_types
+ *   Pointer to the swp types.
  *
  * @return
  *   the converted cs_flags.
  */
 static __rte_always_inline uint8_t
-txq_ol_cksum_to_cs(struct mlx5_txq_data *txq_data, struct rte_mbuf *buf)
+txq_ol_flags_to_verbs(struct mlx5_txq_data *txq_data, struct rte_mbuf *buf,
+		   uint8_t *offsets, uint8_t *swp_types)
 {
 	uint8_t cs_flags = 0;
-
-	/* Should we enable HW CKSUM offload */
-	if (buf->ol_flags &
-	    (PKT_TX_IP_CKSUM | PKT_TX_TCP_CKSUM | PKT_TX_UDP_CKSUM)) {
-		if (txq_data->tunnel_en &&
-		    (buf->ol_flags &
-		     (PKT_TX_TUNNEL_GRE | PKT_TX_TUNNEL_VXLAN))) {
-			cs_flags = MLX5_ETH_WQE_L3_INNER_CSUM |
-				   MLX5_ETH_WQE_L4_INNER_CSUM;
-			if (buf->ol_flags & PKT_TX_OUTER_IP_CKSUM)
-				cs_flags |= MLX5_ETH_WQE_L3_CSUM;
-		} else {
-			cs_flags = MLX5_ETH_WQE_L3_CSUM |
-				   MLX5_ETH_WQE_L4_CSUM;
-		}
+	uint8_t vlan_sz = (buf->ol_flags & PKT_TX_VLAN_PKT) ? 4 : 0;
+	const uint8_t tunnel = txq_data->tunnel_en &&
+			       (buf->ol_flags & PKT_TX_TUNNEL_MASK);
+	const uint8_t tso = txq_data->tso_en &&
+			    (buf->ol_flags & PKT_TX_TCP_SEG);
+	uint16_t off = buf->outer_l2_len + vlan_sz;
+
+	if (likely(!tso && !(buf->ol_flags &
+	    (PKT_TX_IP_CKSUM | PKT_TX_TCP_CKSUM | PKT_TX_UDP_CKSUM |
+	     PKT_TX_OUTER_IP_CKSUM))))
+		return cs_flags;
+	if (likely(!tunnel)) {
+		if (buf->ol_flags & PKT_TX_IP_CKSUM)
+			cs_flags = MLX5_ETH_WQE_L3_CSUM;
+		if (tso || (buf->ol_flags & PKT_TX_L4_MASK))
+			cs_flags |= MLX5_ETH_WQE_L4_CSUM;
+		return cs_flags;
+	}
+	/* Tunneled packets */
+	if (buf->ol_flags & PKT_TX_OUTER_IP_CKSUM)
+		cs_flags = MLX5_ETH_WQE_L3_CSUM;
+	if (buf->ol_flags & PKT_TX_IP_CKSUM)
+		cs_flags |= MLX5_ETH_WQE_L3_INNER_CSUM;
+	if (tso || (buf->ol_flags & PKT_TX_L4_MASK))
+		cs_flags |= MLX5_ETH_WQE_L4_INNER_CSUM;
+	if (!txq_data->swp_en) /* HW offloading, only set csum flags*/
+		return cs_flags;
+	/* SW Parer enabled */
+	if (tso || (buf->ol_flags & PKT_TX_OUTER_IP_CKSUM)) {
+		offsets[1] = off >> 1; /* Outer L3 offset */
+		if (buf->ol_flags & PKT_TX_OUTER_IPV6)
+			*swp_types |= MLX5_ETH_OUTER_L3_IPV6;
+	}
+	off += buf->outer_l3_len;
+	/* TODO is outer L4 required? */
+	if (tso && (buf->ol_flags & PKT_TX_TUNNEL_VXLAN)) {
+		offsets[0] = off >> 1; /* Outer L4 offset */
+		*swp_types |= MLX5_ETH_OUTER_L4_UDP;
+	}
+	off += buf->l2_len;
+	if (tso || (buf->ol_flags & PKT_TX_IP_CKSUM)) {
+		offsets[3] = off >> 1; /* Inner L3 offset */
+		if (buf->ol_flags & PKT_TX_IPV6)
+			*swp_types |= MLX5_ETH_INNER_L3_IPV6;
+	}
+	if (tso || (buf->ol_flags & PKT_TX_L4_MASK)) {
+		off += buf->l3_len;
+		offsets[2] = off >> 1; /* Inner L4 offset */
+		if ((buf->ol_flags & PKT_TX_L4_MASK) == PKT_TX_UDP_CKSUM)
+			*swp_types |= MLX5_ETH_INNER_L4_UDP;
 	}
 	return cs_flags;
 }
 
 /**
+ * Convert the Checksum offloads to Verbs.
+ *
+ * @param txq_data
+ *   Pointer to the Tx queue.
+ * @param buf
+ *   Pointer to the mbuf.
+ *
+ * @return
+ *   the converted cs_flags.
+ */
+static __rte_always_inline uint8_t
+txq_ol_cksum_to_cs(struct mlx5_txq_data *txq_data, struct rte_mbuf *buf)
+{
+	uint32_t offsets;
+	uint8_t swp_types;
+	return txq_ol_flags_to_verbs(txq_data, buf, (uint8_t *)&offsets, &swp_types);
+}
+
+/**
  * Count the number of contiguous single segment packets.
  *
  * @param pkts
diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c
index b81c85fed..bd7ba0834 100644
--- a/drivers/net/mlx5/mlx5_txq.c
+++ b/drivers/net/mlx5/mlx5_txq.c
@@ -729,6 +729,7 @@ txq_set_params(struct mlx5_txq_ctrl *txq_ctrl)
 		txq_ctrl->txq.tso_en = 1;
 	}
 	txq_ctrl->txq.tunnel_en = config->tunnel_en;
+	txq_ctrl->txq.swp_en = 1;
 }
 
 /**
-- 
2.13.3

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

* [dpdk-dev] [PATCH 2/6] net/mlx5: allow max 192B WQE TSO inline header length
  2018-01-09 14:11 [dpdk-dev] [PATCH 0/6] Support generic tunnel TX csum and TSO Xueming Li
  2018-01-09 14:11 ` [dpdk-dev] [PATCH 1/6] net/mlx5: support tx swp tunnel offloading Xueming Li
@ 2018-01-09 14:11 ` Xueming Li
  2018-01-09 14:11 ` [dpdk-dev] [PATCH 3/6] net/mlx5: add SWP PCI parameter for TX common tunnel offloads Xueming Li
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 80+ messages in thread
From: Xueming Li @ 2018-01-09 14:11 UTC (permalink / raw)
  To: Olivier MATZ, Thomas Monjalon, Jingjing Wu, Yongseok Koh
  Cc: Xueming Li, Shahaf Shuler, dev

IPv6 VXLAN TSO and header options demands more than 128B inline header
length.

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
---
 drivers/net/mlx5/mlx5_defs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/mlx5/mlx5_defs.h b/drivers/net/mlx5/mlx5_defs.h
index 3a7706cfd..c4eea145b 100644
--- a/drivers/net/mlx5/mlx5_defs.h
+++ b/drivers/net/mlx5/mlx5_defs.h
@@ -84,7 +84,7 @@
 #define MLX5_MAX_XSTATS 32
 
 /* Maximum Packet headers size (L2+L3+L4) for TSO. */
-#define MLX5_MAX_TSO_HEADER 128
+#define MLX5_MAX_TSO_HEADER 192
 
 /* Default minimum number of Tx queues for vectorized Tx. */
 #define MLX5_VPMD_MIN_TXQS 4
-- 
2.13.3

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

* [dpdk-dev] [PATCH 3/6] net/mlx5: add SWP PCI parameter for TX common tunnel offloads
  2018-01-09 14:11 [dpdk-dev] [PATCH 0/6] Support generic tunnel TX csum and TSO Xueming Li
  2018-01-09 14:11 ` [dpdk-dev] [PATCH 1/6] net/mlx5: support tx swp tunnel offloading Xueming Li
  2018-01-09 14:11 ` [dpdk-dev] [PATCH 2/6] net/mlx5: allow max 192B WQE TSO inline header length Xueming Li
@ 2018-01-09 14:11 ` Xueming Li
  2018-01-09 14:11 ` [dpdk-dev] [PATCH 4/6] ethdev: introduce " Xueming Li
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 80+ messages in thread
From: Xueming Li @ 2018-01-09 14:11 UTC (permalink / raw)
  To: Olivier MATZ, Thomas Monjalon, Jingjing Wu, Yongseok Koh
  Cc: Xueming Li, Shahaf Shuler, dev

Add PCI parameter 'swp' to control TX SWP feature, enabled by default.

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
---
 drivers/net/mlx5/mlx5.c     | 7 +++++++
 drivers/net/mlx5/mlx5.h     | 1 +
 drivers/net/mlx5/mlx5_txq.c | 2 +-
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 1c95f3520..c124465fd 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -91,6 +91,9 @@
 /* Device parameter to enable hardware Rx vector. */
 #define MLX5_RX_VEC_EN "rx_vec_en"
 
+/* Device parameter to enable TX SW parser. */
+#define MLX5_TX_SWP "swp"
+
 #ifndef HAVE_IBV_MLX5_MOD_MPW
 #define MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED (1 << 2)
 #define MLX5DV_CONTEXT_FLAGS_ENHANCED_MPW (1 << 3)
@@ -407,6 +410,8 @@ mlx5_args_check(const char *key, const char *val, void *opaque)
 		config->tx_vec_en = !!tmp;
 	} else if (strcmp(MLX5_RX_VEC_EN, key) == 0) {
 		config->rx_vec_en = !!tmp;
+	} else if (strcmp(MLX5_TX_SWP, key) == 0) {
+		config->swp = !!tmp;
 	} else {
 		WARN("%s: unknown parameter", key);
 		return -EINVAL;
@@ -437,6 +442,7 @@ mlx5_args(struct mlx5_dev_config *config, struct rte_devargs *devargs)
 		MLX5_TXQ_MAX_INLINE_LEN,
 		MLX5_TX_VEC_EN,
 		MLX5_RX_VEC_EN,
+		MLX5_TX_SWP,
 		NULL,
 	};
 	struct rte_kvargs *kvlist;
@@ -629,6 +635,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
 			.txq_inline = MLX5_ARG_UNSET,
 			.txqs_inline = MLX5_ARG_UNSET,
 			.inline_max_packet_sz = MLX5_ARG_UNSET,
+			.swp = 1,
 		};
 
 		mlx5_dev[idx].ports |= test;
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 8ee522069..4d5d12326 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -116,6 +116,7 @@ struct mlx5_dev_config {
 	unsigned int tx_vec_en:1; /* Tx vector is enabled. */
 	unsigned int rx_vec_en:1; /* Rx vector is enabled. */
 	unsigned int mpw_hdr_dseg:1; /* Enable DSEGs in the title WQEBB. */
+	unsigned int swp:1; /* TX common tunnel csum and tso offloads. */
 	unsigned int tso_max_payload_sz; /* Maximum TCP payload for TSO. */
 	unsigned int ind_table_max_size; /* Maximum indirection table size. */
 	int txq_inline; /* Maximum packet size for inlining. */
diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c
index bd7ba0834..0e8498161 100644
--- a/drivers/net/mlx5/mlx5_txq.c
+++ b/drivers/net/mlx5/mlx5_txq.c
@@ -729,7 +729,7 @@ txq_set_params(struct mlx5_txq_ctrl *txq_ctrl)
 		txq_ctrl->txq.tso_en = 1;
 	}
 	txq_ctrl->txq.tunnel_en = config->tunnel_en;
-	txq_ctrl->txq.swp_en = 1;
+	txq_ctrl->txq.swp_en = config->swp;
 }
 
 /**
-- 
2.13.3

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

* [dpdk-dev] [PATCH 4/6] ethdev: introduce TX common tunnel offloads
  2018-01-09 14:11 [dpdk-dev] [PATCH 0/6] Support generic tunnel TX csum and TSO Xueming Li
                   ` (2 preceding siblings ...)
  2018-01-09 14:11 ` [dpdk-dev] [PATCH 3/6] net/mlx5: add SWP PCI parameter for TX common tunnel offloads Xueming Li
@ 2018-01-09 14:11 ` Xueming Li
  2018-01-11 18:38   ` Ferruh Yigit
                     ` (2 more replies)
  2018-01-09 14:11 ` [dpdk-dev] [PATCH 5/6] net/mlx5: support " Xueming Li
  2018-01-09 14:11 ` [dpdk-dev] [PATCH 6/6] app/testpmd: testpmd " Xueming Li
  5 siblings, 3 replies; 80+ messages in thread
From: Xueming Li @ 2018-01-09 14:11 UTC (permalink / raw)
  To: Olivier MATZ, Thomas Monjalon, Jingjing Wu, Yongseok Koh
  Cc: Xueming Li, Shahaf Shuler, dev

This patch introduce new DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO flag for
devices that support tunnel agnostic TX checksum and tso offloading.

Checksum offset and TSO header length are calculated based on mbuf
inner length l*_len, outer_l*_len and tx offload flags PKT_TX_*, tunnel
header length is part of inner l2_len, so device HW do cheksum and TSO
calculation w/o knowledge of perticular tunnel type.

When set application must guarantee that correct header types and
lengths for each inner and outer headers in mbuf header, no need to
specify tunnel type.

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
---
 lib/librte_ether/rte_ethdev.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 57b61ed41..8457d01be 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1003,6 +1003,15 @@ struct rte_eth_conf {
  *   the same mempool and has refcnt = 1.
  */
 #define DEV_TX_OFFLOAD_SECURITY         0x00020000
+/**< Device supports arbitrary tunnel chksum and tso offloading w/o knowing
+ *   tunnel detail. Checksum and TSO are calculated based on mbuf fields:
+ *     l*_len, outer_l*_len
+ *     PKT_TX_OUTER_IPV6, PKT_TX_IPV6
+ *     PKT_TX_IP_CKSUM, PKT_TX_TCP_CKSUM, PKT_TX_UDP_CKSUM
+ *   When set application must guarantee correct header fields, no need to
+ *   specify tunnel type PKT_TX_TUNNEL_* for HW.
+ */
+#define DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO	0x00040000
 
 struct rte_pci_device;
 
-- 
2.13.3

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

* [dpdk-dev] [PATCH 5/6] net/mlx5: support TX common tunnel offloads
  2018-01-09 14:11 [dpdk-dev] [PATCH 0/6] Support generic tunnel TX csum and TSO Xueming Li
                   ` (3 preceding siblings ...)
  2018-01-09 14:11 ` [dpdk-dev] [PATCH 4/6] ethdev: introduce " Xueming Li
@ 2018-01-09 14:11 ` Xueming Li
  2018-01-09 14:11 ` [dpdk-dev] [PATCH 6/6] app/testpmd: testpmd " Xueming Li
  5 siblings, 0 replies; 80+ messages in thread
From: Xueming Li @ 2018-01-09 14:11 UTC (permalink / raw)
  To: Olivier MATZ, Thomas Monjalon, Jingjing Wu, Yongseok Koh
  Cc: Xueming Li, Shahaf Shuler, dev

Support new TX common offloads DEV_TX_OFFLOAD_COMMON_TNL including
common tunnel chksum and common tunnel tso.

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
---
 drivers/net/mlx5/mlx5_ethdev.c | 3 ++-
 drivers/net/mlx5/mlx5_txq.c    | 5 ++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index adaa34fff..80d984312 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -1400,7 +1400,8 @@ priv_select_tx_function(struct priv *priv, struct rte_eth_dev *dev)
 	uint64_t tx_offloads = dev->data->dev_conf.txmode.offloads;
 	int tso = !!(tx_offloads & (DEV_TX_OFFLOAD_TCP_TSO |
 				    DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
-				    DEV_TX_OFFLOAD_GRE_TNL_TSO));
+				    DEV_TX_OFFLOAD_GRE_TNL_TSO |
+				    DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO));
 	int vlan_insert = !!(tx_offloads & DEV_TX_OFFLOAD_VLAN_INSERT);
 
 	assert(priv != NULL);
diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c
index 0e8498161..f4a75b41c 100644
--- a/drivers/net/mlx5/mlx5_txq.c
+++ b/drivers/net/mlx5/mlx5_txq.c
@@ -143,6 +143,8 @@ mlx5_priv_get_tx_port_offloads(struct priv *priv)
 		if (config->tso)
 			offloads |= (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
 				     DEV_TX_OFFLOAD_GRE_TNL_TSO);
+		if (config->swp)
+			offloads |= DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO;
 	}
 	return offloads;
 }
@@ -729,7 +731,8 @@ txq_set_params(struct mlx5_txq_ctrl *txq_ctrl)
 		txq_ctrl->txq.tso_en = 1;
 	}
 	txq_ctrl->txq.tunnel_en = config->tunnel_en;
-	txq_ctrl->txq.swp_en = config->swp;
+	txq_ctrl->txq.swp_en = (DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO &
+				txq_ctrl->txq.offloads) && config->swp;
 }
 
 /**
-- 
2.13.3

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

* [dpdk-dev] [PATCH 6/6] app/testpmd: testpmd support TX common tunnel offloads
  2018-01-09 14:11 [dpdk-dev] [PATCH 0/6] Support generic tunnel TX csum and TSO Xueming Li
                   ` (4 preceding siblings ...)
  2018-01-09 14:11 ` [dpdk-dev] [PATCH 5/6] net/mlx5: support " Xueming Li
@ 2018-01-09 14:11 ` Xueming Li
  2018-01-16  3:09   ` Lu, Wenzhuo
  5 siblings, 1 reply; 80+ messages in thread
From: Xueming Li @ 2018-01-09 14:11 UTC (permalink / raw)
  To: Olivier MATZ, Thomas Monjalon, Jingjing Wu, Yongseok Koh
  Cc: Xueming Li, Shahaf Shuler, dev

"show port cap" and "csum parse tunnel" command support TX common tunnel
offloads

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
---
 app/test-pmd/cmdline.c | 9 +++++++--
 app/test-pmd/config.c  | 9 +++++++++
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 00a229a41..63bc493b3 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -3949,6 +3949,9 @@ check_tunnel_tso_nic_support(portid_t port_id)
 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
 		printf("Warning: GENEVE TUNNEL TSO not supported therefore "
 		       "not enabled for port %d\n", port_id);
+	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO))
+		printf("Warning: COMMON TUNNEL TSO not supported therefore "
+		       "not enabled for port %d\n", port_id);
 	return dev_info;
 }
 
@@ -3976,13 +3979,15 @@ cmd_tunnel_tso_set_parsed(void *parsed_result,
 			~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
 			  DEV_TX_OFFLOAD_GRE_TNL_TSO |
 			  DEV_TX_OFFLOAD_IPIP_TNL_TSO |
-			  DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
+			  DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
+			  DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO);
 		printf("TSO for tunneled packets is disabled\n");
 	} else {
 		uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
 					 DEV_TX_OFFLOAD_GRE_TNL_TSO |
 					 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
-					 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
+					 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
+					 DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO);
 
 		ports[res->port_id].dev_conf.txmode.offloads |=
 			(tso_offloads & dev_info.tx_offload_capa);
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index da968cb64..486667bf4 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -739,6 +739,15 @@ port_offload_cap_display(portid_t port_id)
 			printf("off\n");
 	}
 
+	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO) {
+		printf("TX common tunnel TSO and checksum:  ");
+		if (ports[port_id].dev_conf.txmode.offloads &
+		       DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO)
+			printf("on\n");
+		else
+			printf("off\n");
+	}
+
 }
 
 int
-- 
2.13.3

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

* Re: [dpdk-dev] [PATCH 4/6] ethdev: introduce TX common tunnel offloads
  2018-01-09 14:11 ` [dpdk-dev] [PATCH 4/6] ethdev: introduce " Xueming Li
@ 2018-01-11 18:38   ` Ferruh Yigit
  2018-01-16 17:10   ` Olivier Matz
  2018-01-17  0:50   ` Yongseok Koh
  2 siblings, 0 replies; 80+ messages in thread
From: Ferruh Yigit @ 2018-01-11 18:38 UTC (permalink / raw)
  To: Xueming Li, Olivier MATZ, Thomas Monjalon, Jingjing Wu, Yongseok Koh
  Cc: Shahaf Shuler, dev

On 1/9/2018 2:11 PM, Xueming Li wrote:
> This patch introduce new DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO flag for
> devices that support tunnel agnostic TX checksum and tso offloading.
> 
> Checksum offset and TSO header length are calculated based on mbuf
> inner length l*_len, outer_l*_len and tx offload flags PKT_TX_*, tunnel
> header length is part of inner l2_len, so device HW do cheksum and TSO
> calculation w/o knowledge of perticular tunnel type.
> 
> When set application must guarantee that correct header types and
> lengths for each inner and outer headers in mbuf header, no need to
> specify tunnel type.
> 
> Signed-off-by: Xueming Li <xuemingl@mellanox.com>

Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>

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

* Re: [dpdk-dev] [PATCH 6/6] app/testpmd: testpmd support TX common tunnel offloads
  2018-01-09 14:11 ` [dpdk-dev] [PATCH 6/6] app/testpmd: testpmd " Xueming Li
@ 2018-01-16  3:09   ` Lu, Wenzhuo
  0 siblings, 0 replies; 80+ messages in thread
From: Lu, Wenzhuo @ 2018-01-16  3:09 UTC (permalink / raw)
  To: Xueming Li, Olivier MATZ, Thomas Monjalon, Wu, Jingjing, Yongseok Koh
  Cc: Shahaf Shuler, dev

Hi,


> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Xueming Li
> Sent: Tuesday, January 9, 2018 10:11 PM
> To: Olivier MATZ <olivier.matz@6wind.com>; Thomas Monjalon
> <thomas@monjalon.net>; Wu, Jingjing <jingjing.wu@intel.com>; Yongseok
> Koh <yskoh@mellanox.com>
> Cc: Xueming Li <xuemingl@mellanox.com>; Shahaf Shuler
> <shahafs@mellanox.com>; dev@dpdk.org
> Subject: [dpdk-dev] [PATCH 6/6] app/testpmd: testpmd support TX common
> tunnel offloads
> 
> "show port cap" and "csum parse tunnel" command support TX common
> tunnel offloads
> 
> Signed-off-by: Xueming Li <xuemingl@mellanox.com>
Acked-by: Wenzhuo Lu <wenzhuo.lu@intel.com>

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

* Re: [dpdk-dev] [PATCH 4/6] ethdev: introduce TX common tunnel offloads
  2018-01-09 14:11 ` [dpdk-dev] [PATCH 4/6] ethdev: introduce " Xueming Li
  2018-01-11 18:38   ` Ferruh Yigit
@ 2018-01-16 17:10   ` Olivier Matz
  2018-01-16 17:28     ` Xueming(Steven) Li
  2018-01-17  0:50   ` Yongseok Koh
  2 siblings, 1 reply; 80+ messages in thread
From: Olivier Matz @ 2018-01-16 17:10 UTC (permalink / raw)
  To: Xueming Li; +Cc: Thomas Monjalon, Jingjing Wu, Yongseok Koh, Shahaf Shuler, dev

Hi Xueming,

On Tue, Jan 09, 2018 at 10:11:08PM +0800, Xueming Li wrote:
> This patch introduce new DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO flag for
> devices that support tunnel agnostic TX checksum and tso offloading.
> 
> Checksum offset and TSO header length are calculated based on mbuf
> inner length l*_len, outer_l*_len and tx offload flags PKT_TX_*, tunnel
> header length is part of inner l2_len, so device HW do cheksum and TSO
> calculation w/o knowledge of perticular tunnel type.
> 
> When set application must guarantee that correct header types and
> lengths for each inner and outer headers in mbuf header, no need to
> specify tunnel type.
> 
> Signed-off-by: Xueming Li <xuemingl@mellanox.com>
> ---
>  lib/librte_ether/rte_ethdev.h | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
> index 57b61ed41..8457d01be 100644
> --- a/lib/librte_ether/rte_ethdev.h
> +++ b/lib/librte_ether/rte_ethdev.h
> @@ -1003,6 +1003,15 @@ struct rte_eth_conf {
>   *   the same mempool and has refcnt = 1.
>   */
>  #define DEV_TX_OFFLOAD_SECURITY         0x00020000
> +/**< Device supports arbitrary tunnel chksum and tso offloading w/o knowing
> + *   tunnel detail. Checksum and TSO are calculated based on mbuf fields:
> + *     l*_len, outer_l*_len
> + *     PKT_TX_OUTER_IPV6, PKT_TX_IPV6
> + *     PKT_TX_IP_CKSUM, PKT_TX_TCP_CKSUM, PKT_TX_UDP_CKSUM
> + *   When set application must guarantee correct header fields, no need to
> + *   specify tunnel type PKT_TX_TUNNEL_* for HW.
> + */
> +#define DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO	0x00040000
>  
>  struct rte_pci_device;
>  

I'd like to have more details about this flag and its meaning.

Let's say we want to do TSO on the following vxlan packet:
  Ether / IP1 / UDP / VXLAN / Ether / IP2 / TCP / Data

With the current API, we need to pass the tunnel type to the hardware
with the flag PKT_TX_TUNNEL_VXLAN. Thanks to that, the driver can
forward this information to the hardware so it knows that the
ip1->length, udp->length and optionally the udp->chksum have to be
updated for each generated segment.

With your proposal, if I understand properly, it is not expected to pass
the tunnel type in the mbuf. So how can the hardware know if some fields
have to be updated in the outer header?

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

* Re: [dpdk-dev] [PATCH 4/6] ethdev: introduce TX common tunnel offloads
  2018-01-16 17:10   ` Olivier Matz
@ 2018-01-16 17:28     ` Xueming(Steven) Li
  2018-01-16 19:06       ` Shahaf Shuler
  0 siblings, 1 reply; 80+ messages in thread
From: Xueming(Steven) Li @ 2018-01-16 17:28 UTC (permalink / raw)
  To: Olivier Matz
  Cc: Thomas Monjalon, Jingjing Wu, Yongseok Koh, Shahaf Shuler, dev

Hi Olivier,

Thanks for looking into this.

> -----Original Message-----
> From: Olivier Matz [mailto:olivier.matz@6wind.com]
> Sent: Wednesday, January 17, 2018 1:10 AM
> To: Xueming(Steven) Li <xuemingl@mellanox.com>
> Cc: Thomas Monjalon <thomas@monjalon.net>; Jingjing Wu
> <jingjing.wu@intel.com>; Yongseok Koh <yskoh@mellanox.com>; Shahaf Shuler
> <shahafs@mellanox.com>; dev@dpdk.org
> Subject: Re: [PATCH 4/6] ethdev: introduce TX common tunnel offloads
> 
> Hi Xueming,
> 
> On Tue, Jan 09, 2018 at 10:11:08PM +0800, Xueming Li wrote:
> > This patch introduce new DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO flag for
> > devices that support tunnel agnostic TX checksum and tso offloading.
> >
> > Checksum offset and TSO header length are calculated based on mbuf
> > inner length l*_len, outer_l*_len and tx offload flags PKT_TX_*,
> > tunnel header length is part of inner l2_len, so device HW do cheksum
> > and TSO calculation w/o knowledge of perticular tunnel type.
> >
> > When set application must guarantee that correct header types and
> > lengths for each inner and outer headers in mbuf header, no need to
> > specify tunnel type.
> >
> > Signed-off-by: Xueming Li <xuemingl@mellanox.com>
> > ---
> >  lib/librte_ether/rte_ethdev.h | 9 +++++++++
> >  1 file changed, 9 insertions(+)
> >
> > diff --git a/lib/librte_ether/rte_ethdev.h
> > b/lib/librte_ether/rte_ethdev.h index 57b61ed41..8457d01be 100644
> > --- a/lib/librte_ether/rte_ethdev.h
> > +++ b/lib/librte_ether/rte_ethdev.h
> > @@ -1003,6 +1003,15 @@ struct rte_eth_conf {
> >   *   the same mempool and has refcnt = 1.
> >   */
> >  #define DEV_TX_OFFLOAD_SECURITY         0x00020000
> > +/**< Device supports arbitrary tunnel chksum and tso offloading w/o
> knowing
> > + *   tunnel detail. Checksum and TSO are calculated based on mbuf
> fields:
> > + *     l*_len, outer_l*_len
> > + *     PKT_TX_OUTER_IPV6, PKT_TX_IPV6
> > + *     PKT_TX_IP_CKSUM, PKT_TX_TCP_CKSUM, PKT_TX_UDP_CKSUM
> > + *   When set application must guarantee correct header fields, no need
> to
> > + *   specify tunnel type PKT_TX_TUNNEL_* for HW.
> > + */
> > +#define DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO	0x00040000
> >
> >  struct rte_pci_device;
> >
> 
> I'd like to have more details about this flag and its meaning.
> 
> Let's say we want to do TSO on the following vxlan packet:
>   Ether / IP1 / UDP / VXLAN / Ether / IP2 / TCP / Data
> 
> With the current API, we need to pass the tunnel type to the hardware with
> the flag PKT_TX_TUNNEL_VXLAN. Thanks to that, the driver can forward this
> information to the hardware so it knows that the
> ip1->length, udp->length and optionally the udp->chksum have to be
> updated for each generated segment.
> 
> With your proposal, if I understand properly, it is not expected to pass
> the tunnel type in the mbuf. So how can the hardware know if some fields
> have to be updated in the outer header?

I'm not expert on hardware, the driver has to supply outer and inner 
L3/L4 offsets, types and which field(s) to fill checksum, no length update
as far as I know.

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

* Re: [dpdk-dev] [PATCH 4/6] ethdev: introduce TX common tunnel offloads
  2018-01-16 17:28     ` Xueming(Steven) Li
@ 2018-01-16 19:06       ` Shahaf Shuler
  2018-01-22 12:46         ` Olivier Matz
  0 siblings, 1 reply; 80+ messages in thread
From: Shahaf Shuler @ 2018-01-16 19:06 UTC (permalink / raw)
  To: Xueming(Steven) Li, Olivier Matz
  Cc: Thomas Monjalon, Jingjing Wu, Yongseok Koh, dev

Hi Oliver, Xueming,

Tuesday, January 16, 2018 7:29 PM, Xueming(Steven) Li:
> > Hi Xueming,
> >
> > On Tue, Jan 09, 2018 at 10:11:08PM +0800, Xueming Li wrote:
> > >   */
> > >  #define DEV_TX_OFFLOAD_SECURITY         0x00020000
> > > +/**< Device supports arbitrary tunnel chksum and tso offloading w/o
> > knowing
> > > + *   tunnel detail. Checksum and TSO are calculated based on mbuf
> > fields:
> > > + *     l*_len, outer_l*_len
> > > + *     PKT_TX_OUTER_IPV6, PKT_TX_IPV6
> > > + *     PKT_TX_IP_CKSUM, PKT_TX_TCP_CKSUM, PKT_TX_UDP_CKSUM
> > > + *   When set application must guarantee correct header fields, no need
> > to
> > > + *   specify tunnel type PKT_TX_TUNNEL_* for HW.
> > > + */

I think some documentation is missing here.
What the NIC needs to know to support the generic tunnel TSO and checksum offloads is:
1. the length of each header
2. the type of the outer/inner l3/l4. Meaning is it IPv4/IPv6 and whether it is UDP/TCP.

The outer IPv6 seems covered. The inner L4 seems missing. 

More details about this offload below.

> > > +#define DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO	0x00040000
> > >
> > >  struct rte_pci_device;
> > >
> >
> > I'd like to have more details about this flag and its meaning.
> >
> > Let's say we want to do TSO on the following vxlan packet:
> >   Ether / IP1 / UDP / VXLAN / Ether / IP2 / TCP / Data
> >
> > With the current API, we need to pass the tunnel type to the hardware
> > with the flag PKT_TX_TUNNEL_VXLAN. Thanks to that, the driver can
> > forward this information to the hardware so it knows that the
> > ip1->length, udp->length and optionally the udp->chksum have to be
> > updated for each generated segment.
> >
> > With your proposal, if I understand properly, it is not expected to
> > pass the tunnel type in the mbuf. So how can the hardware know if some
> > fields have to be updated in the outer header?
> 
> I'm not expert on hardware, the driver has to supply outer and inner
> L3/L4 offsets, types and which field(s) to fill checksum, no length update as
> far as I know.

Mellanox HW is capable to parse the packet according to hints from the driver.

If you think about it, to calculate the IP checksum all you need to do is know the inner/outer IP offset, and the fact it is an IPv4.
To calculate the inner TCP/UDP checksum it is the same. all that after the L4 is counted as payload and the pseudo header can be done with the information about the IP.

About TSO - just need to get the offset till the inner header so that the NIC can append the full headers to every segment and update the inner/outer L3 and L4 fields accordingly (which their location is known). 

All of this can be done by the mbuf fields. Given those fields the driver can calculate the:
Outer_l3_offset = outer_l2_len
Outer_l4_offlset = outer_l3_offset +  outer_l3_len
Inner_l3_offset = outer_l4_offset + l2_len 
Inner_l4_offset = inner_l4_offset + l3_len

And pass to the device. Theoretically multiple encapsulating are supported by enlarging the l2_len. 
 
Hope it explains more about this generic offload. 




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

* Re: [dpdk-dev] [PATCH 4/6] ethdev: introduce TX common tunnel offloads
  2018-01-09 14:11 ` [dpdk-dev] [PATCH 4/6] ethdev: introduce " Xueming Li
  2018-01-11 18:38   ` Ferruh Yigit
  2018-01-16 17:10   ` Olivier Matz
@ 2018-01-17  0:50   ` Yongseok Koh
  2 siblings, 0 replies; 80+ messages in thread
From: Yongseok Koh @ 2018-01-17  0:50 UTC (permalink / raw)
  To: Xueming(Steven) Li
  Cc: Olivier MATZ, Thomas Monjalon, Jingjing Wu, Shahaf Shuler, dev


> On Jan 9, 2018, at 6:11 AM, Xueming Li <xuemingl@mellanox.com> wrote:
> 
> This patch introduce new DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO flag for
> devices that support tunnel agnostic TX checksum and tso offloading.
> 
> Checksum offset and TSO header length are calculated based on mbuf
> inner length l*_len, outer_l*_len and tx offload flags PKT_TX_*, tunnel
> header length is part of inner l2_len, so device HW do cheksum and TSO
> calculation w/o knowledge of perticular tunnel type.
> 
> When set application must guarantee that correct header types and
> lengths for each inner and outer headers in mbuf header, no need to
> specify tunnel type.
> 
> Signed-off-by: Xueming Li <xuemingl@mellanox.com>
> ---
> lib/librte_ether/rte_ethdev.h | 9 +++++++++
> 1 file changed, 9 insertions(+)
> 
> diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
> index 57b61ed41..8457d01be 100644
> --- a/lib/librte_ether/rte_ethdev.h
> +++ b/lib/librte_ether/rte_ethdev.h
> @@ -1003,6 +1003,15 @@ struct rte_eth_conf {
>  *   the same mempool and has refcnt = 1.
>  */
> #define DEV_TX_OFFLOAD_SECURITY         0x00020000
> +/**< Device supports arbitrary tunnel chksum and tso offloading w/o knowing
> + *   tunnel detail. Checksum and TSO are calculated based on mbuf fields:
> + *     l*_len, outer_l*_len
> + *     PKT_TX_OUTER_IPV6, PKT_TX_IPV6
> + *     PKT_TX_IP_CKSUM, PKT_TX_TCP_CKSUM, PKT_TX_UDP_CKSUM
> + *   When set application must guarantee correct header fields, no need to
> + *   specify tunnel type PKT_TX_TUNNEL_* for HW.
> + */
> +#define DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO	0x00040000
> 
> struct rte_pci_device;

I'm wondering why generic tunnel offload has to support checksum and TSO
together. Those two are orthogonal, aren't they? App can request HW checksum
offload even for non-TSO packets. Does DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO mean
HW can support checksum and TSO for generic tunnel? Then shouldn't it be two
flags instead? E.g.
DEV_TX_OFFLOAD_GENERIC_TNL_TSO
DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM

Thanks
Yongseok

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

* Re: [dpdk-dev] [PATCH 4/6] ethdev: introduce TX common tunnel offloads
  2018-01-16 19:06       ` Shahaf Shuler
@ 2018-01-22 12:46         ` Olivier Matz
  2018-01-22 20:06           ` Shahaf Shuler
  0 siblings, 1 reply; 80+ messages in thread
From: Olivier Matz @ 2018-01-22 12:46 UTC (permalink / raw)
  To: Shahaf Shuler
  Cc: Xueming(Steven) Li, Thomas Monjalon, Jingjing Wu, Yongseok Koh, dev

Hi,

On Tue, Jan 16, 2018 at 07:06:15PM +0000, Shahaf Shuler wrote:
> Hi Oliver, Xueming,
> 
> Tuesday, January 16, 2018 7:29 PM, Xueming(Steven) Li:
> > > Hi Xueming,
> > >
> > > On Tue, Jan 09, 2018 at 10:11:08PM +0800, Xueming Li wrote:
> > > >   */
> > > >  #define DEV_TX_OFFLOAD_SECURITY         0x00020000
> > > > +/**< Device supports arbitrary tunnel chksum and tso offloading w/o
> > > knowing
> > > > + *   tunnel detail. Checksum and TSO are calculated based on mbuf
> > > fields:
> > > > + *     l*_len, outer_l*_len
> > > > + *     PKT_TX_OUTER_IPV6, PKT_TX_IPV6
> > > > + *     PKT_TX_IP_CKSUM, PKT_TX_TCP_CKSUM, PKT_TX_UDP_CKSUM
> > > > + *   When set application must guarantee correct header fields, no need
> > > to
> > > > + *   specify tunnel type PKT_TX_TUNNEL_* for HW.
> > > > + */
> 
> I think some documentation is missing here.
> What the NIC needs to know to support the generic tunnel TSO and checksum offloads is:
> 1. the length of each header
> 2. the type of the outer/inner l3/l4. Meaning is it IPv4/IPv6 and whether it is UDP/TCP.
> 
> The outer IPv6 seems covered. The inner L4 seems missing. 
> 
> More details about this offload below.
> 
> > > > +#define DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO	0x00040000
> > > >
> > > >  struct rte_pci_device;
> > > >
> > >
> > > I'd like to have more details about this flag and its meaning.
> > >
> > > Let's say we want to do TSO on the following vxlan packet:
> > >   Ether / IP1 / UDP / VXLAN / Ether / IP2 / TCP / Data
> > >
> > > With the current API, we need to pass the tunnel type to the hardware
> > > with the flag PKT_TX_TUNNEL_VXLAN. Thanks to that, the driver can
> > > forward this information to the hardware so it knows that the
> > > ip1->length, udp->length and optionally the udp->chksum have to be
> > > updated for each generated segment.
> > >
> > > With your proposal, if I understand properly, it is not expected to
> > > pass the tunnel type in the mbuf. So how can the hardware know if some
> > > fields have to be updated in the outer header?
> > 
> > I'm not expert on hardware, the driver has to supply outer and inner
> > L3/L4 offsets, types and which field(s) to fill checksum, no length update as
> > far as I know.
> 
> Mellanox HW is capable to parse the packet according to hints from the driver.
> 
> If you think about it, to calculate the IP checksum all you need to do is know the inner/outer IP offset, and the fact it is an IPv4.
> To calculate the inner TCP/UDP checksum it is the same. all that after the L4 is counted as payload and the pseudo header can be done with the information about the IP.
> 
> About TSO - just need to get the offset till the inner header so that the NIC can append the full headers to every segment and update the inner/outer L3 and L4 fields accordingly (which their location is known). 

I think that's partially true. Let me try to clarify:

- in case of VXLAN (my previous example), the hw needs to update the
  outer L3 (ip length) and L4 (udp length and optionnally checksum)
- in case of GRE, an update of the checksum is required if present. The
  sequence number may also be increased (I don't know how widely it is
  used).
- in case of a proprietary or unsupported tunnel, the hardware cannot
  know which fields to update in the outer header. So I'm not sure
  a "generic" flag is possible.

How can the application know which tunnels types are supported by the
hardware and which should be done in software?


Olivier

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

* Re: [dpdk-dev] [PATCH 4/6] ethdev: introduce TX common tunnel offloads
  2018-01-22 12:46         ` Olivier Matz
@ 2018-01-22 20:06           ` Shahaf Shuler
  0 siblings, 0 replies; 80+ messages in thread
From: Shahaf Shuler @ 2018-01-22 20:06 UTC (permalink / raw)
  To: Olivier Matz
  Cc: Xueming(Steven) Li, Thomas Monjalon, Jingjing Wu, Yongseok Koh, dev

Monday, January 22, 2018 2:47 PM, Olivier Matz:
> Hi,
> 
> On Tue, Jan 16, 2018 at 07:06:15PM +0000, Shahaf Shuler wrote:
> > Hi Oliver, Xueming,
> >
> > Tuesday, January 16, 2018 7:29 PM, Xueming(Steven) Li:
> > > > Hi Xueming,
> > > >
> > > > On Tue, Jan 09, 2018 at 10:11:08PM +0800, Xueming Li wrote:
> > > > >   */
> > > > >  #define DEV_TX_OFFLOAD_SECURITY         0x00020000
> > > > > +/**< Device supports arbitrary tunnel chksum and tso offloading
> > > > > +w/o
> > > > knowing
> > > > > + *   tunnel detail. Checksum and TSO are calculated based on mbuf
> > > > fields:
> > > > > + *     l*_len, outer_l*_len
> > > > > + *     PKT_TX_OUTER_IPV6, PKT_TX_IPV6
> > > > > + *     PKT_TX_IP_CKSUM, PKT_TX_TCP_CKSUM,
> PKT_TX_UDP_CKSUM
> > > > > + *   When set application must guarantee correct header fields, no
> need
> > > > to
> > > > > + *   specify tunnel type PKT_TX_TUNNEL_* for HW.
> > > > > + */
> >
> > I think some documentation is missing here.
> > What the NIC needs to know to support the generic tunnel TSO and
> checksum offloads is:
> > 1. the length of each header
> > 2. the type of the outer/inner l3/l4. Meaning is it IPv4/IPv6 and whether it
> is UDP/TCP.
> >
> > The outer IPv6 seems covered. The inner L4 seems missing.
> >
> > More details about this offload below.
> >
> > > > > +#define DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO
> 	0x00040000
> > > > >
> > > > >  struct rte_pci_device;
> > > > >
> > > >
> > > > I'd like to have more details about this flag and its meaning.
> > > >
> > > > Let's say we want to do TSO on the following vxlan packet:
> > > >   Ether / IP1 / UDP / VXLAN / Ether / IP2 / TCP / Data
> > > >
> > > > With the current API, we need to pass the tunnel type to the
> > > > hardware with the flag PKT_TX_TUNNEL_VXLAN. Thanks to that, the
> > > > driver can forward this information to the hardware so it knows
> > > > that the
> > > > ip1->length, udp->length and optionally the udp->chksum have to be
> > > > updated for each generated segment.
> > > >
> > > > With your proposal, if I understand properly, it is not expected
> > > > to pass the tunnel type in the mbuf. So how can the hardware know
> > > > if some fields have to be updated in the outer header?
> > >
> > > I'm not expert on hardware, the driver has to supply outer and inner
> > > L3/L4 offsets, types and which field(s) to fill checksum, no length
> > > update as far as I know.
> >
> > Mellanox HW is capable to parse the packet according to hints from the
> driver.
> >
> > If you think about it, to calculate the IP checksum all you need to do is know
> the inner/outer IP offset, and the fact it is an IPv4.
> > To calculate the inner TCP/UDP checksum it is the same. all that after the L4
> is counted as payload and the pseudo header can be done with the
> information about the IP.
> >
> > About TSO - just need to get the offset till the inner header so that the NIC
> can append the full headers to every segment and update the inner/outer L3
> and L4 fields accordingly (which their location is known).
> 
> I think that's partially true. Let me try to clarify:
> 
> - in case of VXLAN (my previous example), the hw needs to update the
>   outer L3 (ip length) and L4 (udp length and optionnally checksum)
> - in case of GRE, an update of the checksum is required if present. The
>   sequence number may also be increased (I don't know how widely it is
>   used).
> - in case of a proprietary or unsupported tunnel, the hardware cannot
>   know which fields to update in the outer header. So I'm not sure
>   a "generic" flag is possible.
> 
> How can the application know which tunnels types are supported by the
> hardware and which should be done in software?

Yes I understand your point. maybe we should rephrase and change the name of the feature. 

The support from the device is for inner and outer checksums on IPV4/TCP/UDP and TSO for *any packet with the following format*:

< some headers > / [optional IPv4/IPv6] / [optional TCP/UDP] / <some headers> / [optional inner IPv4/IPv6] / [optional TCP/UDP]

 For example the following packets can use this feature:

1. eth / ipv4 / udp / VXLAN / ip / tcp
2. eth / ipv4 / GRE / MPLS / ipv4 / udp 


> 
> 
> Olivier

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

* [dpdk-dev] [PATCH v2 1/5] ethdev: introduce Tx generic tunnel offloads
  2018-01-09 14:11 ` [dpdk-dev] [PATCH 1/6] net/mlx5: support tx swp tunnel offloading Xueming Li
@ 2018-01-29 15:08   ` Xueming Li
  2018-01-29 16:49     ` Ananyev, Konstantin
  2018-01-29 15:08   ` [dpdk-dev] [PATCH v2 2/5] app/testpmd: testpmd support " Xueming Li
                     ` (16 subsequent siblings)
  17 siblings, 1 reply; 80+ messages in thread
From: Xueming Li @ 2018-01-29 15:08 UTC (permalink / raw)
  To: Olivier MATZ
  Cc: Xueming Li, dev, Jingjing Wu, Shahaf Shuler, Yongseok Koh,
	Thomas Monjalon, Ferruh Yigit

This patch introduce new TX offloads flag for devices that support
tunnel agnostic checksum and TSO offloads.

The support from the device is for inner and outer checksums on
IPV4/TCP/UDP and TSO for *any packet with the following format*:

< some headers > / [optional IPv4/IPv6] / [optional TCP/UDP] / <some
headers> / [optional inner IPv4/IPv6] / [optional TCP/UDP]

For example the following packets can use this feature:

1. eth / ipv4 / udp / VXLAN / ip / tcp
2. eth / ipv4 / GRE / MPLS / ipv4 / udp

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
---
 lib/librte_ether/rte_ethdev.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 1a5b4cdc5..d8d08ccb2 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -979,6 +979,16 @@ struct rte_eth_conf {
  *   the same mempool and has refcnt = 1.
  */
 #define DEV_TX_OFFLOAD_SECURITY         0x00020000
+/**< Device supports generic tunnel checksum and TSO offloading.
+ * Checksum and TSO are done based on following mbuf fields:
+ *   - Length of each header
+ *   - Type of outer/inner L3 type, IPv4 or IPv6
+ *   - Type of outer/inner L4 type, TCP or UDP.
+ *	- PKT_TX_TUNNEL_VXLAN implies outer UDP type.
+ *	- PKT_TX_TCP_SEG implies inner TCP type.
+ * Tunnel type is optional except PKT_TX_TUNNEL_VXLAN to hint outer UDP.
+ */
+#define DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO	0x00040000
 
 /*
  * If new Tx offload capabilities are defined, they also must be
-- 
2.13.3

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

* [dpdk-dev] [PATCH v2 2/5] app/testpmd: testpmd support Tx generic tunnel offloads
  2018-01-09 14:11 ` [dpdk-dev] [PATCH 1/6] net/mlx5: support tx swp tunnel offloading Xueming Li
  2018-01-29 15:08   ` [dpdk-dev] [PATCH v2 1/5] ethdev: introduce Tx generic tunnel offloads Xueming Li
@ 2018-01-29 15:08   ` Xueming Li
  2018-01-29 15:08   ` [dpdk-dev] [PATCH v2 3/5] net/mlx5: separate TSO function in Tx data path Xueming Li
                     ` (15 subsequent siblings)
  17 siblings, 0 replies; 80+ messages in thread
From: Xueming Li @ 2018-01-29 15:08 UTC (permalink / raw)
  To: Olivier MATZ
  Cc: Xueming Li, dev, Jingjing Wu, Shahaf Shuler, Yongseok Koh,
	Thomas Monjalon, Ferruh Yigit

"show port cap" and "csum parse tunnel" command support TX generic
tunnel offloads

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
---
 app/test-pmd/cmdline.c | 9 +++++++--
 app/test-pmd/config.c  | 9 +++++++++
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 9f12c0fd2..b43ce5b2f 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -3990,6 +3990,9 @@ check_tunnel_tso_nic_support(portid_t port_id)
 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
 		printf("Warning: GENEVE TUNNEL TSO not supported therefore "
 		       "not enabled for port %d\n", port_id);
+	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO))
+		printf("Warning: Generic TUNNEL TSO not supported therefore "
+		       "not enabled for port %d\n", port_id);
 	return dev_info;
 }
 
@@ -4017,13 +4020,15 @@ cmd_tunnel_tso_set_parsed(void *parsed_result,
 			~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
 			  DEV_TX_OFFLOAD_GRE_TNL_TSO |
 			  DEV_TX_OFFLOAD_IPIP_TNL_TSO |
-			  DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
+			  DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
+			  DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO);
 		printf("TSO for tunneled packets is disabled\n");
 	} else {
 		uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
 					 DEV_TX_OFFLOAD_GRE_TNL_TSO |
 					 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
-					 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
+					 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
+					 DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO);
 
 		ports[res->port_id].dev_conf.txmode.offloads |=
 			(tso_offloads & dev_info.tx_offload_capa);
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 957b82098..3bf20ee11 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -751,6 +751,15 @@ port_offload_cap_display(portid_t port_id)
 			printf("off\n");
 	}
 
+	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO) {
+		printf("TX Generic tunnel TSO and checksum:  ");
+		if (ports[port_id].dev_conf.txmode.offloads &
+		       DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO)
+			printf("on\n");
+		else
+			printf("off\n");
+	}
+
 }
 
 int
-- 
2.13.3

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

* [dpdk-dev] [PATCH v2 3/5] net/mlx5: separate TSO function in Tx data path
  2018-01-09 14:11 ` [dpdk-dev] [PATCH 1/6] net/mlx5: support tx swp tunnel offloading Xueming Li
  2018-01-29 15:08   ` [dpdk-dev] [PATCH v2 1/5] ethdev: introduce Tx generic tunnel offloads Xueming Li
  2018-01-29 15:08   ` [dpdk-dev] [PATCH v2 2/5] app/testpmd: testpmd support " Xueming Li
@ 2018-01-29 15:08   ` Xueming Li
  2018-01-29 15:08   ` [dpdk-dev] [PATCH v2 4/5] net/mlx5: support generic tunnel offloading Xueming Li
                     ` (14 subsequent siblings)
  17 siblings, 0 replies; 80+ messages in thread
From: Xueming Li @ 2018-01-29 15:08 UTC (permalink / raw)
  To: Olivier MATZ
  Cc: Xueming Li, dev, Jingjing Wu, Shahaf Shuler, Yongseok Koh,
	Thomas Monjalon, Ferruh Yigit

Separate TSO function to make logic of mlx5_tx_burst clear.

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
---
 drivers/net/mlx5/mlx5_rxtx.c | 112 ++++++++++++++++++++++++++-----------------
 1 file changed, 67 insertions(+), 45 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c
index 3b8f71c28..dc6691d1c 100644
--- a/drivers/net/mlx5/mlx5_rxtx.c
+++ b/drivers/net/mlx5/mlx5_rxtx.c
@@ -247,6 +247,66 @@ mlx5_copy_to_wq(void *dst, const void *src, size_t n,
 }
 
 /**
+ * Inline TSO headers into WQE.
+ *
+ * @return
+ *   0 on success, negative errno value on failure.
+ */
+static int
+inline_tso(struct mlx5_txq_data *txq, struct rte_mbuf *buf,
+	   uint32_t *length,
+	   uint8_t *cs_flags,
+	   uintptr_t *addr,
+	   uint16_t *pkt_inline_sz,
+	   uint8_t **raw,
+	   uint16_t *max_wqe,
+	   uint16_t *tso_segsz,
+	   uint16_t *tso_header_sz)
+{
+	uintptr_t end = (uintptr_t)(((uintptr_t)txq->wqes) +
+				    (1 << txq->wqe_n) * MLX5_WQE_SIZE);
+	unsigned int copy_b;
+	uint8_t vlan_sz = (buf->ol_flags & PKT_TX_VLAN_PKT) ? 4 : 0;
+	const uint8_t tunneled = txq->tunnel_en &&
+				 (buf->ol_flags & (PKT_TX_TUNNEL_GRE |
+						   PKT_TX_TUNNEL_VXLAN));
+	uint16_t n_wqe;
+
+	*tso_segsz = buf->tso_segsz;
+	*tso_header_sz = buf->l2_len + vlan_sz + buf->l3_len + buf->l4_len;
+	if (unlikely(*tso_segsz == 0 || *tso_header_sz == 0)) {
+		txq->stats.oerrors++;
+		return -EINVAL;
+	}
+	if (tunneled) {
+		*tso_header_sz += buf->outer_l2_len + buf->outer_l3_len;
+		*cs_flags |= MLX5_ETH_WQE_L4_INNER_CSUM;
+	} else {
+		*cs_flags |= MLX5_ETH_WQE_L4_CSUM;
+	}
+	if (unlikely(*tso_header_sz > MLX5_MAX_TSO_HEADER)) {
+		txq->stats.oerrors++;
+		return -EINVAL;
+	}
+	copy_b = *tso_header_sz - *pkt_inline_sz;
+	/* First seg must contain all TSO headers. */
+	assert(copy_b <= *length);
+	if (!copy_b || ((end - (uintptr_t)*raw) < copy_b))
+		return -EAGAIN;
+	n_wqe = (MLX5_WQE_DS(copy_b) - 1 + 3) / 4;
+	if (unlikely(*max_wqe < n_wqe))
+		return -EINVAL;
+	*max_wqe -= n_wqe;
+	rte_memcpy((void *)*raw, (void *)*addr, copy_b);
+	*length -= copy_b;
+	*addr += copy_b;
+	copy_b = MLX5_WQE_DS(copy_b) * MLX5_WQE_DWORD_SIZE;
+	*pkt_inline_sz += copy_b;
+	*raw += copy_b;
+	return 0;
+}
+
+/**
  * DPDK callback to check the status of a tx descriptor.
  *
  * @param tx_queue
@@ -380,6 +440,7 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
 #ifdef MLX5_PMD_SOFT_COUNTERS
 		uint32_t total_length = 0;
 #endif
+		int ret;
 
 		/* first_seg */
 		buf = *pkts;
@@ -445,52 +506,13 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
 		raw += MLX5_WQE_DWORD_SIZE;
 		tso = txq->tso_en && (buf->ol_flags & PKT_TX_TCP_SEG);
 		if (tso) {
-			uintptr_t end =
-				(uintptr_t)(((uintptr_t)txq->wqes) +
-					    (1 << txq->wqe_n) * MLX5_WQE_SIZE);
-			unsigned int copy_b;
-			uint8_t vlan_sz =
-				(buf->ol_flags & PKT_TX_VLAN_PKT) ? 4 : 0;
-			const uint64_t is_tunneled =
-				buf->ol_flags & (PKT_TX_TUNNEL_GRE |
-						 PKT_TX_TUNNEL_VXLAN);
-
-			tso_header_sz = buf->l2_len + vlan_sz +
-					buf->l3_len + buf->l4_len;
-			tso_segsz = buf->tso_segsz;
-			if (unlikely(tso_segsz == 0)) {
-				txq->stats.oerrors++;
+			ret = inline_tso(txq, buf, &length, &cs_flags,
+					 &addr, &pkt_inline_sz,
+					 &raw, &max_wqe,
+					 &tso_segsz, &tso_header_sz);
+			if (ret == -EINVAL) {
 				break;
-			}
-			if (is_tunneled	&& txq->tunnel_en) {
-				tso_header_sz += buf->outer_l2_len +
-						 buf->outer_l3_len;
-				cs_flags |= MLX5_ETH_WQE_L4_INNER_CSUM;
-			} else {
-				cs_flags |= MLX5_ETH_WQE_L4_CSUM;
-			}
-			if (unlikely(tso_header_sz > MLX5_MAX_TSO_HEADER)) {
-				txq->stats.oerrors++;
-				break;
-			}
-			copy_b = tso_header_sz - pkt_inline_sz;
-			/* First seg must contain all headers. */
-			assert(copy_b <= length);
-			if (copy_b && ((end - (uintptr_t)raw) > copy_b)) {
-				uint16_t n = (MLX5_WQE_DS(copy_b) - 1 + 3) / 4;
-
-				if (unlikely(max_wqe < n))
-					break;
-				max_wqe -= n;
-				rte_memcpy((void *)raw, (void *)addr, copy_b);
-				addr += copy_b;
-				length -= copy_b;
-				/* Include padding for TSO header. */
-				copy_b = MLX5_WQE_DS(copy_b) *
-					 MLX5_WQE_DWORD_SIZE;
-				pkt_inline_sz += copy_b;
-				raw += copy_b;
-			} else {
+			} else if (ret == -EAGAIN) {
 				/* NOP WQE. */
 				wqe->ctrl = (rte_v128u32_t){
 					rte_cpu_to_be_32(txq->wqe_ci << 8),
-- 
2.13.3

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

* [dpdk-dev] [PATCH v2 4/5] net/mlx5: support generic tunnel offloading
  2018-01-09 14:11 ` [dpdk-dev] [PATCH 1/6] net/mlx5: support tx swp tunnel offloading Xueming Li
                     ` (2 preceding siblings ...)
  2018-01-29 15:08   ` [dpdk-dev] [PATCH v2 3/5] net/mlx5: separate TSO function in Tx data path Xueming Li
@ 2018-01-29 15:08   ` Xueming Li
  2018-01-29 15:08   ` [dpdk-dev] [PATCH v2 5/5] net/mlx5: allow max 192B TSO inline header length Xueming Li
                     ` (13 subsequent siblings)
  17 siblings, 0 replies; 80+ messages in thread
From: Xueming Li @ 2018-01-29 15:08 UTC (permalink / raw)
  To: Olivier MATZ
  Cc: Xueming Li, dev, Jingjing Wu, Shahaf Shuler, Yongseok Koh,
	Thomas Monjalon, Ferruh Yigit

This commit adds support for generic tunnel TSO and checksum offload.
PMD will compute the inner/outer headers offset according to the
mbuf fields. Hardware will do calculation based on offsets and types.

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
---
 doc/guides/nics/mlx5.rst              |   8 +++
 drivers/net/mlx5/Makefile             |   5 ++
 drivers/net/mlx5/mlx5.c               |  30 +++++++--
 drivers/net/mlx5/mlx5.h               |   1 +
 drivers/net/mlx5/mlx5_ethdev.c        |   3 +-
 drivers/net/mlx5/mlx5_prm.h           |  24 +++++++
 drivers/net/mlx5/mlx5_rxtx.c          | 117 +++++++++++++++++++++++++++-------
 drivers/net/mlx5/mlx5_rxtx.h          | 104 +++++++++++++++++++++++-------
 drivers/net/mlx5/mlx5_rxtx_vec.c      |   9 +--
 drivers/net/mlx5/mlx5_rxtx_vec_neon.h |   2 +-
 drivers/net/mlx5/mlx5_rxtx_vec_sse.h  |   2 +-
 drivers/net/mlx5/mlx5_txq.c           |   4 ++
 12 files changed, 248 insertions(+), 61 deletions(-)

diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst
index 2e6d1e45a..184302ee5 100644
--- a/doc/guides/nics/mlx5.rst
+++ b/doc/guides/nics/mlx5.rst
@@ -307,6 +307,14 @@ Run-time configuration
 
   Enabled by default.
 
+- ``swp`` parameter [int]
+
+  A nonzero value enables TX SW parser to support genenric tunnel TSO and
+  checksum offloading. Please refer to ``DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO``
+  for detail information.
+
+  Disabled by default.
+
 Prerequisites
 -------------
 
diff --git a/drivers/net/mlx5/Makefile b/drivers/net/mlx5/Makefile
index a3984eb9f..254cb93c8 100644
--- a/drivers/net/mlx5/Makefile
+++ b/drivers/net/mlx5/Makefile
@@ -118,6 +118,11 @@ mlx5_autoconf.h.new: $(RTE_SDK)/buildtools/auto-config-h.sh
 		enum IBV_WQ_FLAG_RX_END_PADDING \
 		$(AUTOCONF_OUTPUT)
 	$Q sh -- '$<' '$@' \
+		HAVE_IBV_MLX5_MOD_SWP \
+		infiniband/mlx5dv.h \
+		enum MLX5DV_CONTEXT_MASK_SWP \
+		$(AUTOCONF_OUTPUT)
+	$Q sh -- '$<' '$@' \
 		HAVE_IBV_MLX5_MOD_MPW \
 		infiniband/mlx5dv.h \
 		enum MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED \
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 5a959f7c5..3b126d45a 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -93,6 +93,9 @@
 /* Device parameter to enable hardware Rx vector. */
 #define MLX5_RX_VEC_EN "rx_vec_en"
 
+/* Device parameter to control Tx SW parser. */
+#define MLX5_TX_SWP "swp"
+
 #ifndef HAVE_IBV_MLX5_MOD_MPW
 #define MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED (1 << 2)
 #define MLX5DV_CONTEXT_FLAGS_ENHANCED_MPW (1 << 3)
@@ -421,6 +424,8 @@ mlx5_args_check(const char *key, const char *val, void *opaque)
 		config->tx_vec_en = !!tmp;
 	} else if (strcmp(MLX5_RX_VEC_EN, key) == 0) {
 		config->rx_vec_en = !!tmp;
+	} else if (strcmp(MLX5_TX_SWP, key) == 0) {
+		config->swp = !!tmp;
 	} else {
 		WARN("%s: unknown parameter", key);
 		return -EINVAL;
@@ -451,6 +456,7 @@ mlx5_args(struct mlx5_dev_config *config, struct rte_devargs *devargs)
 		MLX5_TXQ_MAX_INLINE_LEN,
 		MLX5_TX_VEC_EN,
 		MLX5_RX_VEC_EN,
+		MLX5_TX_SWP,
 		NULL,
 	};
 	struct rte_kvargs *kvlist;
@@ -606,9 +612,10 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
 	unsigned int mps;
 	unsigned int cqe_comp;
 	unsigned int tunnel_en = 0;
+	unsigned int swp = 0;
 	int idx;
 	int i;
-	struct mlx5dv_context attrs_out;
+	struct mlx5dv_context attrs_out = {0};
 #ifdef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT
 	struct ibv_counter_set_description cs_desc;
 #endif
@@ -695,10 +702,9 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
 	ibv_dev = list[i];
 
 	DEBUG("device opened");
-	/*
-	 * Multi-packet send is supported by ConnectX-4 Lx PF as well
-	 * as all ConnectX-5 devices.
-	 */
+#ifdef HAVE_IBV_MLX5_MOD_SWP
+	attrs_out.comp_mask |= MLX5DV_CONTEXT_MASK_SWP;
+#endif
 	mlx5dv_query_device(attr_ctx, &attrs_out);
 	if (attrs_out.flags & MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED) {
 		if (attrs_out.flags & MLX5DV_CONTEXT_FLAGS_ENHANCED_MPW) {
@@ -712,6 +718,11 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
 		DEBUG("MPW isn't supported");
 		mps = MLX5_MPW_DISABLED;
 	}
+#ifdef HAVE_IBV_MLX5_MOD_SWP
+	if (attrs_out.comp_mask | MLX5DV_CONTEXT_MASK_SWP)
+		swp = attrs_out.sw_parsing_caps.sw_parsing_offloads;
+	DEBUG("SWP support: %u", swp);
+#endif
 	if (RTE_CACHE_LINE_SIZE == 128 &&
 	    !(attrs_out.flags & MLX5DV_CONTEXT_FLAGS_CQE_128B_COMP))
 		cqe_comp = 0;
@@ -928,6 +939,11 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
 		err = priv_uar_init_primary(priv);
 		if (err)
 			goto port_error;
+		if (config.swp && !swp) {
+			WARN("Tx SWP isn't supported");
+			config.swp = 0;
+		}
+		INFO("SWP is %s", config.swp ? "enabled" : "disabled");
 		/* Configure the first MAC address by default. */
 		if (priv_get_mac(priv, &mac.addr_bytes)) {
 			ERROR("cannot get MAC address, is mlx5_en loaded?"
@@ -1080,8 +1096,10 @@ RTE_INIT(rte_mlx5_pmd_init);
 static void
 rte_mlx5_pmd_init(void)
 {
-	/* Build the static table for ptype conversion. */
+	/* Build the static tables for verbs conversion. */
 	mlx5_set_ptype_table();
+	mlx5_set_cksum_table();
+	mlx5_set_swp_types_table();
 	/*
 	 * RDMAV_HUGEPAGES_SAFE tells ibv_fork_init() we intend to use
 	 * huge pages. Calling ibv_fork_init() during init allows
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 7851cac96..db88ee840 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -116,6 +116,7 @@ struct mlx5_dev_config {
 	unsigned int tx_vec_en:1; /* Tx vector is enabled. */
 	unsigned int rx_vec_en:1; /* Rx vector is enabled. */
 	unsigned int mpw_hdr_dseg:1; /* Enable DSEGs in the title WQEBB. */
+	unsigned int swp:1; /* Tx generic tunnel checksum and TSO offload. */
 	unsigned int tso_max_payload_sz; /* Maximum TCP payload for TSO. */
 	unsigned int ind_table_max_size; /* Maximum indirection table size. */
 	int txq_inline; /* Maximum packet size for inlining. */
diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index 83657f509..bef54c562 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -1492,7 +1492,8 @@ priv_select_tx_function(struct priv *priv, struct rte_eth_dev *dev)
 	uint64_t tx_offloads = dev->data->dev_conf.txmode.offloads;
 	int tso = !!(tx_offloads & (DEV_TX_OFFLOAD_TCP_TSO |
 				    DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
-				    DEV_TX_OFFLOAD_GRE_TNL_TSO));
+				    DEV_TX_OFFLOAD_GRE_TNL_TSO |
+				    DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO));
 	int vlan_insert = !!(tx_offloads & DEV_TX_OFFLOAD_VLAN_INSERT);
 
 	assert(priv != NULL);
diff --git a/drivers/net/mlx5/mlx5_prm.h b/drivers/net/mlx5/mlx5_prm.h
index 2de310bcb..ba62699f9 100644
--- a/drivers/net/mlx5/mlx5_prm.h
+++ b/drivers/net/mlx5/mlx5_prm.h
@@ -135,6 +135,30 @@
 /* Inner L4 checksum offload (Tunneled packets only). */
 #define MLX5_ETH_WQE_L4_INNER_CSUM (1u << 5)
 
+/* Outer L4 type is TCP. */
+#define MLX5_ETH_WQE_L4_OUTER_TCP  (0u << 5)
+
+/* Outer L4 type is UDP. */
+#define MLX5_ETH_WQE_L4_OUTER_UDP  (1u << 5)
+
+/* Outer L3 type is IPV4. */
+#define MLX5_ETH_WQE_L3_OUTER_IPV4 (0u << 4)
+
+/* Outer L3 type is IPV6. */
+#define MLX5_ETH_WQE_L3_OUTER_IPV6 (1u << 4)
+
+/* Inner L4 type is TCP. */
+#define MLX5_ETH_WQE_L4_INNER_TCP (0u << 1)
+
+/* Inner L4 type is UDP. */
+#define MLX5_ETH_WQE_L4_INNER_UDP (1u << 1)
+
+/* Inner L3 type is IPV4. */
+#define MLX5_ETH_WQE_L3_INNER_IPV4 (0u << 0)
+
+/* Inner L3 type is IPV6. */
+#define MLX5_ETH_WQE_L3_INNER_IPV6 (1u << 0)
+
 /* Is flow mark valid. */
 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
 #define MLX5_FLOW_MARK_IS_VALID(val) ((val) & 0xffffff00)
diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c
index dc6691d1c..3d2462a67 100644
--- a/drivers/net/mlx5/mlx5_rxtx.c
+++ b/drivers/net/mlx5/mlx5_rxtx.c
@@ -75,6 +75,9 @@ uint32_t mlx5_ptype_table[] __rte_cache_aligned = {
 	[0xff] = RTE_PTYPE_ALL_MASK, /* Last entry for errored packet. */
 };
 
+uint8_t mlx5_cksum_table[1 << 10] __rte_cache_aligned;
+uint8_t mlx5_swp_types_table[1 << 10] __rte_cache_aligned;
+
 /**
  * Build a table to translate Rx completion flags to packet type.
  *
@@ -191,6 +194,74 @@ mlx5_set_ptype_table(void)
 }
 
 /**
+ * Build a table to translate packet to checksum type of Verbs.
+ */
+void
+mlx5_set_cksum_table(void)
+{
+	unsigned int i;
+	uint8_t v;
+
+	/*
+	 * The index should have:
+	 * bit[0] = PKT_TX_TCP_SEG
+	 * bit[2:3] = PKT_TX_UDP_CKSUM, PKT_TX_TCP_CKSUM
+	 * bit[4] = PKT_TX_IP_CKSUM
+	 * bit[8] = PKT_TX_OUTER_IP_CKSUM
+	 * bit[9] = tunnel
+	 */
+	for (i = 0; i < RTE_DIM(mlx5_cksum_table); ++i) {
+		v = 0;
+		if (i & (1 << 9)) {
+			/* Tunneled packet. */
+			if (i & (1 << 8)) /* Outer IP. */
+				v |= MLX5_ETH_WQE_L3_CSUM;
+			if (i & (1 << 4)) /* Inner IP. */
+				v |= MLX5_ETH_WQE_L3_INNER_CSUM;
+			if (i & (3 << 2 | 1 << 0)) /* L4 or TSO. */
+				v |= MLX5_ETH_WQE_L4_INNER_CSUM;
+		} else {
+			/* No tunnel. */
+			if (i & (1 << 4)) /* IP. */
+				v |= MLX5_ETH_WQE_L3_CSUM;
+			if (i & (3 << 2 | 1 << 0)) /* L4 or TSO. */
+				v |= MLX5_ETH_WQE_L4_CSUM;
+		}
+		mlx5_cksum_table[i] = v;
+	}
+}
+
+/**
+ * Build a table to translate packet type of mbuf to SWP type of Verbs.
+ */
+void
+mlx5_set_swp_types_table(void)
+{
+	unsigned int i;
+	uint8_t v;
+
+	/*
+	 * The index should have:
+	 * bit[0:1] = PKT_TX_UDP_CKSUM
+	 * bit[4] = PKT_TX_IPV6
+	 * bit[8] = PKT_TX_OUTER_IPV6
+	 * bit[9] = Outer UDP
+	 */
+	for (i = 0; i < RTE_DIM(mlx5_swp_types_table); ++i) {
+		v = 0;
+		if (i & (1 << 8)) /* Outer IPv6. */
+			v |= MLX5_ETH_WQE_L3_OUTER_IPV6;
+		if (i & (1 << 9)) /* Outer UDP. */
+			v |= MLX5_ETH_WQE_L4_OUTER_UDP;
+		if (i & (1 << 4)) /* Inner IPv6. */
+			v |= MLX5_ETH_WQE_L3_INNER_IPV6;
+		if ((i & 3) == (PKT_TX_UDP_CKSUM >> 52)) /* Inner UDP. */
+			v |= MLX5_ETH_WQE_L4_INNER_UDP;
+		mlx5_swp_types_table[i] = v;
+	}
+}
+
+/**
  * Return the size of tailroom of WQ.
  *
  * @param txq
@@ -255,7 +326,6 @@ mlx5_copy_to_wq(void *dst, const void *src, size_t n,
 static int
 inline_tso(struct mlx5_txq_data *txq, struct rte_mbuf *buf,
 	   uint32_t *length,
-	   uint8_t *cs_flags,
 	   uintptr_t *addr,
 	   uint16_t *pkt_inline_sz,
 	   uint8_t **raw,
@@ -278,19 +348,15 @@ inline_tso(struct mlx5_txq_data *txq, struct rte_mbuf *buf,
 		txq->stats.oerrors++;
 		return -EINVAL;
 	}
-	if (tunneled) {
+	if (tunneled)
 		*tso_header_sz += buf->outer_l2_len + buf->outer_l3_len;
-		*cs_flags |= MLX5_ETH_WQE_L4_INNER_CSUM;
-	} else {
-		*cs_flags |= MLX5_ETH_WQE_L4_CSUM;
-	}
-	if (unlikely(*tso_header_sz > MLX5_MAX_TSO_HEADER)) {
+	/* First seg must contain all TSO headers. */
+	if (unlikely(*tso_header_sz > MLX5_MAX_TSO_HEADER) ||
+		     *tso_header_sz > DATA_LEN(buf)) {
 		txq->stats.oerrors++;
 		return -EINVAL;
 	}
 	copy_b = *tso_header_sz - *pkt_inline_sz;
-	/* First seg must contain all TSO headers. */
-	assert(copy_b <= *length);
 	if (!copy_b || ((end - (uintptr_t)*raw) < copy_b))
 		return -EAGAIN;
 	n_wqe = (MLX5_WQE_DS(copy_b) - 1 + 3) / 4;
@@ -423,7 +489,7 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
 	if (unlikely(!max_wqe))
 		return 0;
 	do {
-		struct rte_mbuf *buf = NULL;
+		struct rte_mbuf *buf = *pkts; /* First_seg. */
 		uint8_t *raw;
 		volatile struct mlx5_wqe_v *wqe = NULL;
 		volatile rte_v128u32_t *dseg = NULL;
@@ -435,15 +501,16 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
 		uint16_t tso_header_sz = 0;
 		uint16_t ehdr;
 		uint8_t cs_flags;
-		uint64_t tso = 0;
+		uint8_t tso = txq->tso_en && (buf->ol_flags & PKT_TX_TCP_SEG);
+		uint8_t is_vlan = buf->ol_flags & PKT_TX_VLAN_PKT;
+		uint32_t swp_offsets = 0;
+		uint8_t swp_types = 0;
 		uint16_t tso_segsz = 0;
 #ifdef MLX5_PMD_SOFT_COUNTERS
 		uint32_t total_length = 0;
 #endif
 		int ret;
 
-		/* first_seg */
-		buf = *pkts;
 		segs_n = buf->nb_segs;
 		/*
 		 * Make sure there is enough room to store this packet and
@@ -478,10 +545,12 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
 		if (pkts_n - i > 1)
 			rte_prefetch0(
 			    rte_pktmbuf_mtod(*(pkts + 1), volatile void *));
-		cs_flags = txq_ol_cksum_to_cs(txq, buf);
+		cs_flags = txq_ol_cksum_to_cs(buf);
+		txq_mbuf_to_swp(txq, buf, tso, is_vlan,
+				(uint8_t *)&swp_offsets, &swp_types);
 		raw = ((uint8_t *)(uintptr_t)wqe) + 2 * MLX5_WQE_DWORD_SIZE;
 		/* Replace the Ethernet type by the VLAN if necessary. */
-		if (buf->ol_flags & PKT_TX_VLAN_PKT) {
+		if (is_vlan) {
 			uint32_t vlan = rte_cpu_to_be_32(0x81000000 |
 							 buf->vlan_tci);
 			unsigned int len = 2 * ETHER_ADDR_LEN - 2;
@@ -504,9 +573,8 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
 			addr += pkt_inline_sz;
 		}
 		raw += MLX5_WQE_DWORD_SIZE;
-		tso = txq->tso_en && (buf->ol_flags & PKT_TX_TCP_SEG);
 		if (tso) {
-			ret = inline_tso(txq, buf, &length, &cs_flags,
+			ret = inline_tso(txq, buf, &length,
 					 &addr, &pkt_inline_sz,
 					 &raw, &max_wqe,
 					 &tso_segsz, &tso_header_sz);
@@ -683,8 +751,9 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
 				0,
 			};
 			wqe->eseg = (rte_v128u32_t){
-				0,
-				cs_flags | (rte_cpu_to_be_16(tso_segsz) << 16),
+				swp_offsets,
+				cs_flags | (swp_types << 8) |
+				(rte_cpu_to_be_16(tso_segsz) << 16),
 				0,
 				(ehdr << 16) | rte_cpu_to_be_16(tso_header_sz),
 			};
@@ -697,8 +766,8 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
 				0,
 			};
 			wqe->eseg = (rte_v128u32_t){
-				0,
-				cs_flags,
+				swp_offsets,
+				cs_flags | (swp_types << 8),
 				0,
 				(ehdr << 16) | rte_cpu_to_be_16(pkt_inline_sz),
 			};
@@ -870,7 +939,7 @@ mlx5_tx_burst_mpw(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
 		}
 		max_elts -= segs_n;
 		--pkts_n;
-		cs_flags = txq_ol_cksum_to_cs(txq, buf);
+		cs_flags = txq_ol_cksum_to_cs(buf);
 		/* Retrieve packet information. */
 		length = PKT_LEN(buf);
 		assert(length);
@@ -1102,7 +1171,7 @@ mlx5_tx_burst_mpw_inline(void *dpdk_txq, struct rte_mbuf **pkts,
 		 * iteration.
 		 */
 		max_wqe = (1u << txq->wqe_n) - (txq->wqe_ci - txq->wqe_pi);
-		cs_flags = txq_ol_cksum_to_cs(txq, buf);
+		cs_flags = txq_ol_cksum_to_cs(buf);
 		/* Retrieve packet information. */
 		length = PKT_LEN(buf);
 		/* Start new session if packet differs. */
@@ -1380,7 +1449,7 @@ txq_burst_empw(struct mlx5_txq_data *txq, struct rte_mbuf **pkts,
 		/* Make sure there is enough room to store this packet. */
 		if (max_elts - j == 0)
 			break;
-		cs_flags = txq_ol_cksum_to_cs(txq, buf);
+		cs_flags = txq_ol_cksum_to_cs(buf);
 		/* Retrieve packet information. */
 		length = PKT_LEN(buf);
 		/* Start new session if:
diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h
index d4738b14c..7040c9ec8 100644
--- a/drivers/net/mlx5/mlx5_rxtx.h
+++ b/drivers/net/mlx5/mlx5_rxtx.h
@@ -195,6 +195,7 @@ struct mlx5_txq_data {
 	uint16_t tso_en:1; /* When set hardware TSO is enabled. */
 	uint16_t tunnel_en:1;
 	/* When set TX offload for tunneled packets are supported. */
+	uint16_t swp_en:1; /* Whether SW parser is enabled. */
 	uint16_t mpw_hdr_dseg:1; /* Enable DSEGs in the title WQEBB. */
 	uint16_t max_inline; /* Multiple of RTE_CACHE_LINE_SIZE to inline. */
 	uint16_t inline_max_packet_sz; /* Max packet size for inlining. */
@@ -301,8 +302,12 @@ uint64_t mlx5_priv_get_tx_port_offloads(struct priv *);
 /* mlx5_rxtx.c */
 
 extern uint32_t mlx5_ptype_table[];
+extern uint8_t mlx5_cksum_table[];
+extern uint8_t mlx5_swp_types_table[];
 
 void mlx5_set_ptype_table(void);
+void mlx5_set_cksum_table(void);
+void mlx5_set_swp_types_table(void);
 uint16_t mlx5_tx_burst(void *, struct rte_mbuf **, uint16_t);
 uint16_t mlx5_tx_burst_mpw(void *, struct rte_mbuf **, uint16_t);
 uint16_t mlx5_tx_burst_mpw_inline(void *, struct rte_mbuf **, uint16_t);
@@ -627,38 +632,93 @@ mlx5_tx_dbrec(struct mlx5_txq_data *txq, volatile struct mlx5_wqe *wqe)
 }
 
 /**
- * Convert the Checksum offloads to Verbs.
+ * Convert mbuf to Verb SWP.
  *
  * @param txq_data
  *   Pointer to the Tx queue.
  * @param buf
  *   Pointer to the mbuf.
+ * @param tso
+ *   TSO offloads enabled.
+ * @param vlan
+ *   VLAN offloads enabled
+ * @param offsets
+ *   Pointer to the SWP header offsets.
+ * @param swp_types
+ *   Pointer to the SWP header types.
+ */
+static __rte_always_inline void
+txq_mbuf_to_swp(struct mlx5_txq_data *txq, struct rte_mbuf *buf,
+		 uint8_t tso, uint64_t vlan,
+		 uint8_t *offsets, uint8_t *swp_types)
+{
+	uint8_t tunnel = (buf->ol_flags & PKT_TX_TUNNEL_MASK) ||
+			  buf->outer_l2_len;
+	uint16_t idx;
+	uint16_t off;
+	int outer_udp;
+	const uint64_t ol_flags_mask = PKT_TX_UDP_CKSUM | PKT_TX_IPV6 |
+				       PKT_TX_OUTER_IPV6;
+
+	if (!txq->swp_en || !tunnel)
+		return;
+	outer_udp = (buf->ol_flags & PKT_TX_TUNNEL_MASK) == PKT_TX_TUNNEL_VXLAN;
+	/*
+	 * The index should have:
+	 * bit[0:1] = PKT_TX_UDP_CKSUM
+	 * bit[4] = PKT_TX_IPV6
+	 * bit[8] = PKT_TX_OUTER_IPV6
+	 * bit[9] = Outer UDP
+	 */
+	idx = ((buf->ol_flags & ol_flags_mask) >> 52) |
+	      (outer_udp << 9);
+	*swp_types = mlx5_swp_types_table[idx];
+	/* swp offsets. */
+	off = buf->outer_l2_len + (vlan ? 4 : 0); /* Outer L3 offset. */
+	if (tso || (buf->ol_flags & PKT_TX_OUTER_IP_CKSUM))
+		offsets[1] = off >> 1;
+	off += buf->outer_l3_len; /* Outer L4 offset. */
+	if (outer_udp)
+		offsets[0] = off >> 1;
+	off += buf->l2_len; /* Inner L3 offset. */
+	if (tso || (buf->ol_flags & PKT_TX_IP_CKSUM))
+		offsets[3] = off >> 1;
+	off += buf->l3_len; /* Inner L4 offset. */
+	if (tso || ((buf->ol_flags & PKT_TX_L4_MASK) == PKT_TX_TCP_CKSUM) ||
+	    ((buf->ol_flags & PKT_TX_L4_MASK) == PKT_TX_UDP_CKSUM))
+		offsets[2] = off >> 1;
+}
+
+/**
+ * Convert the Checksum offloads to Verbs.
+ *
+ * @param buf
+ *   Pointer to the mbuf.
  *
  * @return
- *   the converted cs_flags.
+ *   Converted checksum flags.
  */
 static __rte_always_inline uint8_t
-txq_ol_cksum_to_cs(struct mlx5_txq_data *txq_data, struct rte_mbuf *buf)
+txq_ol_cksum_to_cs(struct rte_mbuf *buf)
 {
-	uint8_t cs_flags = 0;
-
-	/* Should we enable HW CKSUM offload */
-	if (buf->ol_flags &
-	    (PKT_TX_IP_CKSUM | PKT_TX_TCP_CKSUM | PKT_TX_UDP_CKSUM |
-	     PKT_TX_OUTER_IP_CKSUM)) {
-		if (txq_data->tunnel_en &&
-		    (buf->ol_flags &
-		     (PKT_TX_TUNNEL_GRE | PKT_TX_TUNNEL_VXLAN))) {
-			cs_flags = MLX5_ETH_WQE_L3_INNER_CSUM |
-				   MLX5_ETH_WQE_L4_INNER_CSUM;
-			if (buf->ol_flags & PKT_TX_OUTER_IP_CKSUM)
-				cs_flags |= MLX5_ETH_WQE_L3_CSUM;
-		} else {
-			cs_flags = MLX5_ETH_WQE_L3_CSUM |
-				   MLX5_ETH_WQE_L4_CSUM;
-		}
-	}
-	return cs_flags;
+	uint32_t idx;
+	uint32_t is_tunnel;
+	const uint64_t ol_flags_mask = PKT_TX_TCP_SEG | PKT_TX_L4_MASK |
+				       PKT_TX_IP_CKSUM | PKT_TX_OUTER_IP_CKSUM;
+
+	is_tunnel = (buf->ol_flags & (PKT_TX_TUNNEL_MASK |
+		     PKT_TX_OUTER_IP_CKSUM)) || buf->outer_l2_len;
+	/*
+	 * The index should have:
+	 * bit[0] = PKT_TX_TCP_SEG
+	 * bit[2:3] = PKT_TX_UDP_CKSUM, PKT_TX_TCP_CKSUM
+	 * bit[4] = PKT_TX_IP_CKSUM
+	 * bit[8] = PKT_TX_OUTER_IP_CKSUM
+	 * bit[9] = tunnel
+	 */
+	idx = ((buf->ol_flags & ol_flags_mask) >> 50) |
+	      (is_tunnel << 9);
+	return mlx5_cksum_table[idx];
 }
 
 /**
diff --git a/drivers/net/mlx5/mlx5_rxtx_vec.c b/drivers/net/mlx5/mlx5_rxtx_vec.c
index 142c786d5..a1f3d662a 100644
--- a/drivers/net/mlx5/mlx5_rxtx_vec.c
+++ b/drivers/net/mlx5/mlx5_rxtx_vec.c
@@ -70,8 +70,6 @@
 /**
  * Count the number of packets having same ol_flags and calculate cs_flags.
  *
- * @param txq
- *   Pointer to TX queue structure.
  * @param pkts
  *   Pointer to array of packets.
  * @param pkts_n
@@ -83,8 +81,7 @@
  *   Number of packets having same ol_flags.
  */
 static inline unsigned int
-txq_calc_offload(struct mlx5_txq_data *txq, struct rte_mbuf **pkts,
-		 uint16_t pkts_n, uint8_t *cs_flags)
+txq_calc_offload(struct rte_mbuf **pkts, uint16_t pkts_n, uint8_t *cs_flags)
 {
 	unsigned int pos;
 	const uint64_t ol_mask =
@@ -98,7 +95,7 @@ txq_calc_offload(struct mlx5_txq_data *txq, struct rte_mbuf **pkts,
 	for (pos = 1; pos < pkts_n; ++pos)
 		if ((pkts[pos]->ol_flags ^ pkts[0]->ol_flags) & ol_mask)
 			break;
-	*cs_flags = txq_ol_cksum_to_cs(txq, pkts[0]);
+	*cs_flags = txq_ol_cksum_to_cs(pkts[0]);
 	return pos;
 }
 
@@ -169,7 +166,7 @@ mlx5_tx_burst_vec(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
 		if (txq->offloads & DEV_TX_OFFLOAD_MULTI_SEGS)
 			n = txq_count_contig_single_seg(&pkts[nb_tx], n);
 		if (txq->offloads & MLX5_VEC_TX_CKSUM_OFFLOAD_CAP)
-			n = txq_calc_offload(txq, &pkts[nb_tx], n, &cs_flags);
+			n = txq_calc_offload(&pkts[nb_tx], n, &cs_flags);
 		ret = txq_burst_v(txq, &pkts[nb_tx], n, cs_flags);
 		nb_tx += ret;
 		if (!ret)
diff --git a/drivers/net/mlx5/mlx5_rxtx_vec_neon.h b/drivers/net/mlx5/mlx5_rxtx_vec_neon.h
index e11565f69..261da11a6 100644
--- a/drivers/net/mlx5/mlx5_rxtx_vec_neon.h
+++ b/drivers/net/mlx5/mlx5_rxtx_vec_neon.h
@@ -170,7 +170,7 @@ txq_scatter_v(struct mlx5_txq_data *txq, struct rte_mbuf **pkts,
 			break;
 		wqe = &((volatile struct mlx5_wqe64 *)
 			 txq->wqes)[wqe_ci & wq_mask].hdr;
-		cs_flags = txq_ol_cksum_to_cs(txq, buf);
+		cs_flags = txq_ol_cksum_to_cs(buf);
 		/* Title WQEBB pointer. */
 		t_wqe = (uint8x16_t *)wqe;
 		dseg = (uint8_t *)(wqe + 1);
diff --git a/drivers/net/mlx5/mlx5_rxtx_vec_sse.h b/drivers/net/mlx5/mlx5_rxtx_vec_sse.h
index 559b0237e..c55f5e36a 100644
--- a/drivers/net/mlx5/mlx5_rxtx_vec_sse.h
+++ b/drivers/net/mlx5/mlx5_rxtx_vec_sse.h
@@ -172,7 +172,7 @@ txq_scatter_v(struct mlx5_txq_data *txq, struct rte_mbuf **pkts,
 		}
 		wqe = &((volatile struct mlx5_wqe64 *)
 			 txq->wqes)[wqe_ci & wq_mask].hdr;
-		cs_flags = txq_ol_cksum_to_cs(txq, buf);
+		cs_flags = txq_ol_cksum_to_cs(buf);
 		/* Title WQEBB pointer. */
 		t_wqe = (__m128i *)wqe;
 		dseg = (__m128i *)(wqe + 1);
diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c
index 65086d36f..c4cd61aa6 100644
--- a/drivers/net/mlx5/mlx5_txq.c
+++ b/drivers/net/mlx5/mlx5_txq.c
@@ -143,6 +143,8 @@ mlx5_priv_get_tx_port_offloads(struct priv *priv)
 		if (config->tso)
 			offloads |= (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
 				     DEV_TX_OFFLOAD_GRE_TNL_TSO);
+		if (config->swp)
+			offloads |= DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO;
 	}
 	return offloads;
 }
@@ -754,6 +756,8 @@ txq_set_params(struct mlx5_txq_ctrl *txq_ctrl)
 		txq_ctrl->txq.tso_en = 1;
 	}
 	txq_ctrl->txq.tunnel_en = config->tunnel_en;
+	txq_ctrl->txq.swp_en = (DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO &
+				txq_ctrl->txq.offloads) && config->swp;
 }
 
 /**
-- 
2.13.3

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

* [dpdk-dev] [PATCH v2 5/5] net/mlx5: allow max 192B TSO inline header length
  2018-01-09 14:11 ` [dpdk-dev] [PATCH 1/6] net/mlx5: support tx swp tunnel offloading Xueming Li
                     ` (3 preceding siblings ...)
  2018-01-29 15:08   ` [dpdk-dev] [PATCH v2 4/5] net/mlx5: support generic tunnel offloading Xueming Li
@ 2018-01-29 15:08   ` Xueming Li
  2018-03-05 14:51   ` [dpdk-dev] [PATCH v3 0/7] support generic tunnel Tx checksum and TSO Xueming Li
                     ` (12 subsequent siblings)
  17 siblings, 0 replies; 80+ messages in thread
From: Xueming Li @ 2018-01-29 15:08 UTC (permalink / raw)
  To: Olivier MATZ
  Cc: Xueming Li, dev, Jingjing Wu, Shahaf Shuler, Yongseok Koh,
	Thomas Monjalon, Ferruh Yigit

Change max inline header length to 192B to allow IPv6 VXLAN TSO headers
and header with options that more than 128B.

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
---
 drivers/net/mlx5/mlx5_defs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/mlx5/mlx5_defs.h b/drivers/net/mlx5/mlx5_defs.h
index a925921eb..948de73f7 100644
--- a/drivers/net/mlx5/mlx5_defs.h
+++ b/drivers/net/mlx5/mlx5_defs.h
@@ -86,7 +86,7 @@
 #define MLX5_MAX_XSTATS 32
 
 /* Maximum Packet headers size (L2+L3+L4) for TSO. */
-#define MLX5_MAX_TSO_HEADER 128
+#define MLX5_MAX_TSO_HEADER 192
 
 /* Default minimum number of Tx queues for vectorized Tx. */
 #define MLX5_VPMD_MIN_TXQS 4
-- 
2.13.3

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

* Re: [dpdk-dev] [PATCH v2 1/5] ethdev: introduce Tx generic tunnel offloads
  2018-01-29 15:08   ` [dpdk-dev] [PATCH v2 1/5] ethdev: introduce Tx generic tunnel offloads Xueming Li
@ 2018-01-29 16:49     ` Ananyev, Konstantin
  2018-01-30  3:01       ` Xueming(Steven) Li
  0 siblings, 1 reply; 80+ messages in thread
From: Ananyev, Konstantin @ 2018-01-29 16:49 UTC (permalink / raw)
  To: Xueming Li, Olivier MATZ
  Cc: dev, Wu, Jingjing, Shahaf Shuler, Yongseok Koh, Thomas Monjalon,
	Yigit, Ferruh

Hi Xueming,

> 
> This patch introduce new TX offloads flag for devices that support
> tunnel agnostic checksum and TSO offloads.
> 
> The support from the device is for inner and outer checksums on
> IPV4/TCP/UDP and TSO for *any packet with the following format*:
> 
> < some headers > / [optional IPv4/IPv6] / [optional TCP/UDP] / <some
> headers> / [optional inner IPv4/IPv6] / [optional TCP/UDP]
> 
> For example the following packets can use this feature:
> 
> 1. eth / ipv4 / udp / VXLAN / ip / tcp
> 2. eth / ipv4 / GRE / MPLS / ipv4 / udp

So in terms of usage - what is the difference with current TSO types?
Konstantin

> 
> Signed-off-by: Xueming Li <xuemingl@mellanox.com>
> ---
>  lib/librte_ether/rte_ethdev.h | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
> index 1a5b4cdc5..d8d08ccb2 100644
> --- a/lib/librte_ether/rte_ethdev.h
> +++ b/lib/librte_ether/rte_ethdev.h
> @@ -979,6 +979,16 @@ struct rte_eth_conf {
>   *   the same mempool and has refcnt = 1.
>   */
>  #define DEV_TX_OFFLOAD_SECURITY         0x00020000
> +/**< Device supports generic tunnel checksum and TSO offloading.
> + * Checksum and TSO are done based on following mbuf fields:
> + *   - Length of each header
> + *   - Type of outer/inner L3 type, IPv4 or IPv6
> + *   - Type of outer/inner L4 type, TCP or UDP.
> + *	- PKT_TX_TUNNEL_VXLAN implies outer UDP type.
> + *	- PKT_TX_TCP_SEG implies inner TCP type.
> + * Tunnel type is optional except PKT_TX_TUNNEL_VXLAN to hint outer UDP.
> + */
> +#define DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO	0x00040000
> 
>  /*
>   * If new Tx offload capabilities are defined, they also must be
> --
> 2.13.3

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

* Re: [dpdk-dev] [PATCH v2 1/5] ethdev: introduce Tx generic tunnel offloads
  2018-01-29 16:49     ` Ananyev, Konstantin
@ 2018-01-30  3:01       ` Xueming(Steven) Li
  2018-01-30 13:28         ` Ananyev, Konstantin
  0 siblings, 1 reply; 80+ messages in thread
From: Xueming(Steven) Li @ 2018-01-30  3:01 UTC (permalink / raw)
  To: Ananyev, Konstantin, Olivier MATZ
  Cc: dev, Wu, Jingjing, Shahaf Shuler, Yongseok Koh, Thomas Monjalon,
	Yigit, Ferruh

Hi Konstantin,

> -----Original Message-----
> From: Ananyev, Konstantin [mailto:konstantin.ananyev@intel.com]
> Sent: Tuesday, January 30, 2018 12:49 AM
> To: Xueming(Steven) Li <xuemingl@mellanox.com>; Olivier MATZ
> <olivier.matz@6wind.com>
> Cc: dev@dpdk.org; Wu, Jingjing <jingjing.wu@intel.com>; Shahaf Shuler
> <shahafs@mellanox.com>; Yongseok Koh <yskoh@mellanox.com>; Thomas Monjalon
> <thomas@monjalon.net>; Yigit, Ferruh <ferruh.yigit@intel.com>
> Subject: RE: [dpdk-dev] [PATCH v2 1/5] ethdev: introduce Tx generic tunnel
> offloads
> 
> Hi Xueming,
> 
> >
> > This patch introduce new TX offloads flag for devices that support
> > tunnel agnostic checksum and TSO offloads.
> >
> > The support from the device is for inner and outer checksums on
> > IPV4/TCP/UDP and TSO for *any packet with the following format*:
> >
> > < some headers > / [optional IPv4/IPv6] / [optional TCP/UDP] / <some
> > headers> / [optional inner IPv4/IPv6] / [optional TCP/UDP]
> >
> > For example the following packets can use this feature:
> >
> > 1. eth / ipv4 / udp / VXLAN / ip / tcp 2. eth / ipv4 / GRE / MPLS /
> > ipv4 / udp
> 
> So in terms of usage - what is the difference with current TSO types?
> Konstantin
> 

Traditionally, HW only recognize "known" tunnel type, do TSO calculation
based on L3/L4 headers known to tunnel type. For example, it must be 
L2 header after VXLAN, then L3. While this Generic offloading provides
inner/outer L3/L4 header info(len and offset) to HW, and thus tunnel 
info become less important. Please note the MPLS over GRE tunnel in last
example above.

> >
> > Signed-off-by: Xueming Li <xuemingl@mellanox.com>
> > ---
> >  lib/librte_ether/rte_ethdev.h | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> >
> > diff --git a/lib/librte_ether/rte_ethdev.h
> > b/lib/librte_ether/rte_ethdev.h index 1a5b4cdc5..d8d08ccb2 100644
> > --- a/lib/librte_ether/rte_ethdev.h
> > +++ b/lib/librte_ether/rte_ethdev.h
> > @@ -979,6 +979,16 @@ struct rte_eth_conf {
> >   *   the same mempool and has refcnt = 1.
> >   */
> >  #define DEV_TX_OFFLOAD_SECURITY         0x00020000
> > +/**< Device supports generic tunnel checksum and TSO offloading.
> > + * Checksum and TSO are done based on following mbuf fields:
> > + *   - Length of each header
> > + *   - Type of outer/inner L3 type, IPv4 or IPv6
> > + *   - Type of outer/inner L4 type, TCP or UDP.
> > + *	- PKT_TX_TUNNEL_VXLAN implies outer UDP type.
> > + *	- PKT_TX_TCP_SEG implies inner TCP type.
> > + * Tunnel type is optional except PKT_TX_TUNNEL_VXLAN to hint outer UDP.
> > + */
> > +#define DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO	0x00040000
> >
> >  /*
> >   * If new Tx offload capabilities are defined, they also must be
> > --
> > 2.13.3


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

* Re: [dpdk-dev] [PATCH v2 1/5] ethdev: introduce Tx generic tunnel offloads
  2018-01-30  3:01       ` Xueming(Steven) Li
@ 2018-01-30 13:28         ` Ananyev, Konstantin
  2018-01-30 15:27           ` Xueming(Steven) Li
  0 siblings, 1 reply; 80+ messages in thread
From: Ananyev, Konstantin @ 2018-01-30 13:28 UTC (permalink / raw)
  To: Xueming(Steven) Li, Olivier MATZ
  Cc: dev, Wu, Jingjing, Shahaf Shuler, Yongseok Koh, Thomas Monjalon,
	Yigit, Ferruh


Hi Xueming,

> > > This patch introduce new TX offloads flag for devices that support
> > > tunnel agnostic checksum and TSO offloads.
> > >
> > > The support from the device is for inner and outer checksums on
> > > IPV4/TCP/UDP and TSO for *any packet with the following format*:
> > >
> > > < some headers > / [optional IPv4/IPv6] / [optional TCP/UDP] / <some
> > > headers> / [optional inner IPv4/IPv6] / [optional TCP/UDP]
> > >
> > > For example the following packets can use this feature:
> > >
> > > 1. eth / ipv4 / udp / VXLAN / ip / tcp 2. eth / ipv4 / GRE / MPLS /
> > > ipv4 / udp
> >
> > So in terms of usage - what is the difference with current TSO types?
> > Konstantin
> >
> 
> Traditionally, HW only recognize "known" tunnel type, do TSO calculation
> based on L3/L4 headers known to tunnel type. For example, it must be
> L2 header after VXLAN, then L3. While this Generic offloading provides
> inner/outer L3/L4 header info(len and offset) to HW, and thus tunnel
> info become less important. Please note the MPLS over GRE tunnel in last
> example above.

Ok, but I wonder when the user would like to do TSO on tunnel packet, for this offload -
would he need to do something differently from what he has to do now:
raise PKT_TX_TCP_SEG and related flags, raise appropriate PKT_TX_TUNNEL_* flag,
fill l2_len, l3_len, l4_len,tso_segsz,outer_l2_len,outer_l3_len? 

Konstantin

> 
> > >
> > > Signed-off-by: Xueming Li <xuemingl@mellanox.com>
> > > ---
> > >  lib/librte_ether/rte_ethdev.h | 10 ++++++++++
> > >  1 file changed, 10 insertions(+)
> > >
> > > diff --git a/lib/librte_ether/rte_ethdev.h
> > > b/lib/librte_ether/rte_ethdev.h index 1a5b4cdc5..d8d08ccb2 100644
> > > --- a/lib/librte_ether/rte_ethdev.h
> > > +++ b/lib/librte_ether/rte_ethdev.h
> > > @@ -979,6 +979,16 @@ struct rte_eth_conf {
> > >   *   the same mempool and has refcnt = 1.
> > >   */
> > >  #define DEV_TX_OFFLOAD_SECURITY         0x00020000
> > > +/**< Device supports generic tunnel checksum and TSO offloading.
> > > + * Checksum and TSO are done based on following mbuf fields:
> > > + *   - Length of each header
> > > + *   - Type of outer/inner L3 type, IPv4 or IPv6
> > > + *   - Type of outer/inner L4 type, TCP or UDP.
> > > + *	- PKT_TX_TUNNEL_VXLAN implies outer UDP type.
> > > + *	- PKT_TX_TCP_SEG implies inner TCP type.
> > > + * Tunnel type is optional except PKT_TX_TUNNEL_VXLAN to hint outer UDP.
> > > + */
> > > +#define DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO	0x00040000
> > >
> > >  /*
> > >   * If new Tx offload capabilities are defined, they also must be
> > > --
> > > 2.13.3


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

* Re: [dpdk-dev] [PATCH v2 1/5] ethdev: introduce Tx generic tunnel offloads
  2018-01-30 13:28         ` Ananyev, Konstantin
@ 2018-01-30 15:27           ` Xueming(Steven) Li
  2018-01-30 15:33             ` Ananyev, Konstantin
  0 siblings, 1 reply; 80+ messages in thread
From: Xueming(Steven) Li @ 2018-01-30 15:27 UTC (permalink / raw)
  To: Ananyev, Konstantin, Olivier MATZ
  Cc: dev, Wu, Jingjing, Shahaf Shuler, Yongseok Koh, Thomas Monjalon,
	Yigit, Ferruh

Hi Ananyev,

> -----Original Message-----
> From: Ananyev, Konstantin [mailto:konstantin.ananyev@intel.com]
> Sent: Tuesday, January 30, 2018 9:28 PM
> To: Xueming(Steven) Li <xuemingl@mellanox.com>; Olivier MATZ
> <olivier.matz@6wind.com>
> Cc: dev@dpdk.org; Wu, Jingjing <jingjing.wu@intel.com>; Shahaf Shuler
> <shahafs@mellanox.com>; Yongseok Koh <yskoh@mellanox.com>; Thomas Monjalon
> <thomas@monjalon.net>; Yigit, Ferruh <ferruh.yigit@intel.com>
> Subject: RE: [dpdk-dev] [PATCH v2 1/5] ethdev: introduce Tx generic tunnel
> offloads
> 
> 
> Hi Xueming,
> 
> > > > This patch introduce new TX offloads flag for devices that support
> > > > tunnel agnostic checksum and TSO offloads.
> > > >
> > > > The support from the device is for inner and outer checksums on
> > > > IPV4/TCP/UDP and TSO for *any packet with the following format*:
> > > >
> > > > < some headers > / [optional IPv4/IPv6] / [optional TCP/UDP] /
> > > > <some
> > > > headers> / [optional inner IPv4/IPv6] / [optional TCP/UDP]
> > > >
> > > > For example the following packets can use this feature:
> > > >
> > > > 1. eth / ipv4 / udp / VXLAN / ip / tcp 2. eth / ipv4 / GRE / MPLS
> > > > /
> > > > ipv4 / udp
> > >
> > > So in terms of usage - what is the difference with current TSO types?
> > > Konstantin
> > >
> >
> > Traditionally, HW only recognize "known" tunnel type, do TSO
> > calculation based on L3/L4 headers known to tunnel type. For example,
> > it must be
> > L2 header after VXLAN, then L3. While this Generic offloading provides
> > inner/outer L3/L4 header info(len and offset) to HW, and thus tunnel
> > info become less important. Please note the MPLS over GRE tunnel in
> > last example above.
> 
> Ok, but I wonder when the user would like to do TSO on tunnel packet, for
> this offload - would he need to do something differently from what he has
> to do now:
> raise PKT_TX_TCP_SEG and related flags, raise appropriate PKT_TX_TUNNEL_*
> flag, fill l2_len, l3_len, l4_len,tso_segsz,outer_l2_len,outer_l3_len?
> 

Yes, these fields are sufficient except PKT_TX_TUNNEL_*, major target of this 
new feature is to support "unknown" tunnel offloading, it supports "known" 
tunnel type as well. 

PKT_TX_TUNNEL_VXLAN has to be used as a hint if outer UDP expected.
 
> Konstantin
> 
> >
> > > >
> > > > Signed-off-by: Xueming Li <xuemingl@mellanox.com>
> > > > ---
> > > >  lib/librte_ether/rte_ethdev.h | 10 ++++++++++
> > > >  1 file changed, 10 insertions(+)
> > > >
> > > > diff --git a/lib/librte_ether/rte_ethdev.h
> > > > b/lib/librte_ether/rte_ethdev.h index 1a5b4cdc5..d8d08ccb2 100644
> > > > --- a/lib/librte_ether/rte_ethdev.h
> > > > +++ b/lib/librte_ether/rte_ethdev.h
> > > > @@ -979,6 +979,16 @@ struct rte_eth_conf {
> > > >   *   the same mempool and has refcnt = 1.
> > > >   */
> > > >  #define DEV_TX_OFFLOAD_SECURITY         0x00020000
> > > > +/**< Device supports generic tunnel checksum and TSO offloading.
> > > > + * Checksum and TSO are done based on following mbuf fields:
> > > > + *   - Length of each header
> > > > + *   - Type of outer/inner L3 type, IPv4 or IPv6
> > > > + *   - Type of outer/inner L4 type, TCP or UDP.
> > > > + *	- PKT_TX_TUNNEL_VXLAN implies outer UDP type.
> > > > + *	- PKT_TX_TCP_SEG implies inner TCP type.
> > > > + * Tunnel type is optional except PKT_TX_TUNNEL_VXLAN to hint outer
> UDP.
> > > > + */
> > > > +#define DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO	0x00040000
> > > >
> > > >  /*
> > > >   * If new Tx offload capabilities are defined, they also must be
> > > > --
> > > > 2.13.3


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

* Re: [dpdk-dev] [PATCH v2 1/5] ethdev: introduce Tx generic tunnel offloads
  2018-01-30 15:27           ` Xueming(Steven) Li
@ 2018-01-30 15:33             ` Ananyev, Konstantin
  2018-01-30 15:47               ` Xueming(Steven) Li
  0 siblings, 1 reply; 80+ messages in thread
From: Ananyev, Konstantin @ 2018-01-30 15:33 UTC (permalink / raw)
  To: Xueming(Steven) Li, Olivier MATZ
  Cc: dev, Wu, Jingjing, Shahaf Shuler, Yongseok Koh, Thomas Monjalon,
	Yigit, Ferruh



> -----Original Message-----
> From: Xueming(Steven) Li [mailto:xuemingl@mellanox.com]
> Sent: Tuesday, January 30, 2018 3:27 PM
> To: Ananyev, Konstantin <konstantin.ananyev@intel.com>; Olivier MATZ <olivier.matz@6wind.com>
> Cc: dev@dpdk.org; Wu, Jingjing <jingjing.wu@intel.com>; Shahaf Shuler <shahafs@mellanox.com>; Yongseok Koh
> <yskoh@mellanox.com>; Thomas Monjalon <thomas@monjalon.net>; Yigit, Ferruh <ferruh.yigit@intel.com>
> Subject: RE: [dpdk-dev] [PATCH v2 1/5] ethdev: introduce Tx generic tunnel offloads
> 
> Hi Ananyev,
> 
> > -----Original Message-----
> > From: Ananyev, Konstantin [mailto:konstantin.ananyev@intel.com]
> > Sent: Tuesday, January 30, 2018 9:28 PM
> > To: Xueming(Steven) Li <xuemingl@mellanox.com>; Olivier MATZ
> > <olivier.matz@6wind.com>
> > Cc: dev@dpdk.org; Wu, Jingjing <jingjing.wu@intel.com>; Shahaf Shuler
> > <shahafs@mellanox.com>; Yongseok Koh <yskoh@mellanox.com>; Thomas Monjalon
> > <thomas@monjalon.net>; Yigit, Ferruh <ferruh.yigit@intel.com>
> > Subject: RE: [dpdk-dev] [PATCH v2 1/5] ethdev: introduce Tx generic tunnel
> > offloads
> >
> >
> > Hi Xueming,
> >
> > > > > This patch introduce new TX offloads flag for devices that support
> > > > > tunnel agnostic checksum and TSO offloads.
> > > > >
> > > > > The support from the device is for inner and outer checksums on
> > > > > IPV4/TCP/UDP and TSO for *any packet with the following format*:
> > > > >
> > > > > < some headers > / [optional IPv4/IPv6] / [optional TCP/UDP] /
> > > > > <some
> > > > > headers> / [optional inner IPv4/IPv6] / [optional TCP/UDP]
> > > > >
> > > > > For example the following packets can use this feature:
> > > > >
> > > > > 1. eth / ipv4 / udp / VXLAN / ip / tcp 2. eth / ipv4 / GRE / MPLS
> > > > > /
> > > > > ipv4 / udp
> > > >
> > > > So in terms of usage - what is the difference with current TSO types?
> > > > Konstantin
> > > >
> > >
> > > Traditionally, HW only recognize "known" tunnel type, do TSO
> > > calculation based on L3/L4 headers known to tunnel type. For example,
> > > it must be
> > > L2 header after VXLAN, then L3. While this Generic offloading provides
> > > inner/outer L3/L4 header info(len and offset) to HW, and thus tunnel
> > > info become less important. Please note the MPLS over GRE tunnel in
> > > last example above.
> >
> > Ok, but I wonder when the user would like to do TSO on tunnel packet, for
> > this offload - would he need to do something differently from what he has
> > to do now:
> > raise PKT_TX_TCP_SEG and related flags, raise appropriate PKT_TX_TUNNEL_*
> > flag, fill l2_len, l3_len, l4_len,tso_segsz,outer_l2_len,outer_l3_len?
> >
> 
> Yes, these fields are sufficient except PKT_TX_TUNNEL_*, major target of this
> new feature is to support "unknown" tunnel offloading, it supports "known"
> tunnel type as well.

Ok, but user would still need to set some flag to indicate that this is a tunnel packet,
and he wants TSO over it, right?
For pre-defined tunnel types it can be one of PKT_TX_TUNNEL_*
(which actually means that user still have to know tunnel type anyway?)
But for some not defined tunnel type - what it would be?
Konstantin

> 
> PKT_TX_TUNNEL_VXLAN has to be used as a hint if outer UDP expected.
> 
> > Konstantin
> >
> > >
> > > > >
> > > > > Signed-off-by: Xueming Li <xuemingl@mellanox.com>
> > > > > ---
> > > > >  lib/librte_ether/rte_ethdev.h | 10 ++++++++++
> > > > >  1 file changed, 10 insertions(+)
> > > > >
> > > > > diff --git a/lib/librte_ether/rte_ethdev.h
> > > > > b/lib/librte_ether/rte_ethdev.h index 1a5b4cdc5..d8d08ccb2 100644
> > > > > --- a/lib/librte_ether/rte_ethdev.h
> > > > > +++ b/lib/librte_ether/rte_ethdev.h
> > > > > @@ -979,6 +979,16 @@ struct rte_eth_conf {
> > > > >   *   the same mempool and has refcnt = 1.
> > > > >   */
> > > > >  #define DEV_TX_OFFLOAD_SECURITY         0x00020000
> > > > > +/**< Device supports generic tunnel checksum and TSO offloading.
> > > > > + * Checksum and TSO are done based on following mbuf fields:
> > > > > + *   - Length of each header
> > > > > + *   - Type of outer/inner L3 type, IPv4 or IPv6
> > > > > + *   - Type of outer/inner L4 type, TCP or UDP.
> > > > > + *	- PKT_TX_TUNNEL_VXLAN implies outer UDP type.
> > > > > + *	- PKT_TX_TCP_SEG implies inner TCP type.
> > > > > + * Tunnel type is optional except PKT_TX_TUNNEL_VXLAN to hint outer
> > UDP.
> > > > > + */
> > > > > +#define DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO	0x00040000
> > > > >
> > > > >  /*
> > > > >   * If new Tx offload capabilities are defined, they also must be
> > > > > --
> > > > > 2.13.3


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

* Re: [dpdk-dev] [PATCH v2 1/5] ethdev: introduce Tx generic tunnel offloads
  2018-01-30 15:33             ` Ananyev, Konstantin
@ 2018-01-30 15:47               ` Xueming(Steven) Li
  2018-01-30 16:02                 ` Ananyev, Konstantin
  0 siblings, 1 reply; 80+ messages in thread
From: Xueming(Steven) Li @ 2018-01-30 15:47 UTC (permalink / raw)
  To: Ananyev, Konstantin, Olivier MATZ
  Cc: dev, Wu, Jingjing, Shahaf Shuler, Yongseok Koh, Thomas Monjalon,
	Yigit, Ferruh



> -----Original Message-----
> From: Ananyev, Konstantin [mailto:konstantin.ananyev@intel.com]
> Sent: Tuesday, January 30, 2018 11:34 PM
> To: Xueming(Steven) Li <xuemingl@mellanox.com>; Olivier MATZ
> <olivier.matz@6wind.com>
> Cc: dev@dpdk.org; Wu, Jingjing <jingjing.wu@intel.com>; Shahaf Shuler
> <shahafs@mellanox.com>; Yongseok Koh <yskoh@mellanox.com>; Thomas Monjalon
> <thomas@monjalon.net>; Yigit, Ferruh <ferruh.yigit@intel.com>
> Subject: RE: [dpdk-dev] [PATCH v2 1/5] ethdev: introduce Tx generic tunnel
> offloads
> 
> 
> 
> > -----Original Message-----
> > From: Xueming(Steven) Li [mailto:xuemingl@mellanox.com]
> > Sent: Tuesday, January 30, 2018 3:27 PM
> > To: Ananyev, Konstantin <konstantin.ananyev@intel.com>; Olivier MATZ
> > <olivier.matz@6wind.com>
> > Cc: dev@dpdk.org; Wu, Jingjing <jingjing.wu@intel.com>; Shahaf Shuler
> > <shahafs@mellanox.com>; Yongseok Koh <yskoh@mellanox.com>; Thomas
> > Monjalon <thomas@monjalon.net>; Yigit, Ferruh <ferruh.yigit@intel.com>
> > Subject: RE: [dpdk-dev] [PATCH v2 1/5] ethdev: introduce Tx generic
> > tunnel offloads
> >
> > Hi Ananyev,
> >
> > > -----Original Message-----
> > > From: Ananyev, Konstantin [mailto:konstantin.ananyev@intel.com]
> > > Sent: Tuesday, January 30, 2018 9:28 PM
> > > To: Xueming(Steven) Li <xuemingl@mellanox.com>; Olivier MATZ
> > > <olivier.matz@6wind.com>
> > > Cc: dev@dpdk.org; Wu, Jingjing <jingjing.wu@intel.com>; Shahaf
> > > Shuler <shahafs@mellanox.com>; Yongseok Koh <yskoh@mellanox.com>;
> > > Thomas Monjalon <thomas@monjalon.net>; Yigit, Ferruh
> > > <ferruh.yigit@intel.com>
> > > Subject: RE: [dpdk-dev] [PATCH v2 1/5] ethdev: introduce Tx generic
> > > tunnel offloads
> > >
> > >
> > > Hi Xueming,
> > >
> > > > > > This patch introduce new TX offloads flag for devices that
> > > > > > support tunnel agnostic checksum and TSO offloads.
> > > > > >
> > > > > > The support from the device is for inner and outer checksums
> > > > > > on IPV4/TCP/UDP and TSO for *any packet with the following
> format*:
> > > > > >
> > > > > > < some headers > / [optional IPv4/IPv6] / [optional TCP/UDP] /
> > > > > > <some
> > > > > > headers> / [optional inner IPv4/IPv6] / [optional TCP/UDP]
> > > > > >
> > > > > > For example the following packets can use this feature:
> > > > > >
> > > > > > 1. eth / ipv4 / udp / VXLAN / ip / tcp 2. eth / ipv4 / GRE /
> > > > > > MPLS /
> > > > > > ipv4 / udp
> > > > >
> > > > > So in terms of usage - what is the difference with current TSO
> types?
> > > > > Konstantin
> > > > >
> > > >
> > > > Traditionally, HW only recognize "known" tunnel type, do TSO
> > > > calculation based on L3/L4 headers known to tunnel type. For
> > > > example, it must be
> > > > L2 header after VXLAN, then L3. While this Generic offloading
> > > > provides inner/outer L3/L4 header info(len and offset) to HW, and
> > > > thus tunnel info become less important. Please note the MPLS over
> > > > GRE tunnel in last example above.
> > >
> > > Ok, but I wonder when the user would like to do TSO on tunnel
> > > packet, for this offload - would he need to do something differently
> > > from what he has to do now:
> > > raise PKT_TX_TCP_SEG and related flags, raise appropriate
> > > PKT_TX_TUNNEL_* flag, fill l2_len, l3_len,
> l4_len,tso_segsz,outer_l2_len,outer_l3_len?
> > >
> >
> > Yes, these fields are sufficient except PKT_TX_TUNNEL_*, major target
> > of this new feature is to support "unknown" tunnel offloading, it
> supports "known"
> > tunnel type as well.
> 
> Ok, but user would still need to set some flag to indicate that this is a
> tunnel packet, and he wants TSO over it, right?
> For pre-defined tunnel types it can be one of PKT_TX_TUNNEL_* (which
> actually means that user still have to know tunnel type anyway?) But for
> some not defined tunnel type - what it would be?
> Konstantin
>

As this feature target to TX path, Outer length as tunnel indication,
leave it empty if tunnel not defined. 

But I think it good to define something like:
 	PKT_TX_TUNNEL_GENERIC = PKT_TX_TUNNEL_MASK
And a new flag PKT_TX_OUTER_UDP, how do you think?
 
> >
> > PKT_TX_TUNNEL_VXLAN has to be used as a hint if outer UDP expected.
> >
> > > Konstantin
> > >
> > > >
> > > > > >
> > > > > > Signed-off-by: Xueming Li <xuemingl@mellanox.com>
> > > > > > ---
> > > > > >  lib/librte_ether/rte_ethdev.h | 10 ++++++++++
> > > > > >  1 file changed, 10 insertions(+)
> > > > > >
> > > > > > diff --git a/lib/librte_ether/rte_ethdev.h
> > > > > > b/lib/librte_ether/rte_ethdev.h index 1a5b4cdc5..d8d08ccb2
> > > > > > 100644
> > > > > > --- a/lib/librte_ether/rte_ethdev.h
> > > > > > +++ b/lib/librte_ether/rte_ethdev.h
> > > > > > @@ -979,6 +979,16 @@ struct rte_eth_conf {
> > > > > >   *   the same mempool and has refcnt = 1.
> > > > > >   */
> > > > > >  #define DEV_TX_OFFLOAD_SECURITY         0x00020000
> > > > > > +/**< Device supports generic tunnel checksum and TSO offloading.
> > > > > > + * Checksum and TSO are done based on following mbuf fields:
> > > > > > + *   - Length of each header
> > > > > > + *   - Type of outer/inner L3 type, IPv4 or IPv6
> > > > > > + *   - Type of outer/inner L4 type, TCP or UDP.
> > > > > > + *	- PKT_TX_TUNNEL_VXLAN implies outer UDP type.
> > > > > > + *	- PKT_TX_TCP_SEG implies inner TCP type.
> > > > > > + * Tunnel type is optional except PKT_TX_TUNNEL_VXLAN to hint
> > > > > > +outer
> > > UDP.
> > > > > > + */
> > > > > > +#define DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO	0x00040000
> > > > > >
> > > > > >  /*
> > > > > >   * If new Tx offload capabilities are defined, they also must
> > > > > > be
> > > > > > --
> > > > > > 2.13.3


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

* Re: [dpdk-dev] [PATCH v2 1/5] ethdev: introduce Tx generic tunnel offloads
  2018-01-30 15:47               ` Xueming(Steven) Li
@ 2018-01-30 16:02                 ` Ananyev, Konstantin
  2018-01-30 16:10                   ` Xueming(Steven) Li
  0 siblings, 1 reply; 80+ messages in thread
From: Ananyev, Konstantin @ 2018-01-30 16:02 UTC (permalink / raw)
  To: Xueming(Steven) Li, Olivier MATZ
  Cc: dev, Wu, Jingjing, Shahaf Shuler, Yongseok Koh, Thomas Monjalon,
	Yigit, Ferruh



> > > >
> > > > > > > This patch introduce new TX offloads flag for devices that
> > > > > > > support tunnel agnostic checksum and TSO offloads.
> > > > > > >
> > > > > > > The support from the device is for inner and outer checksums
> > > > > > > on IPV4/TCP/UDP and TSO for *any packet with the following
> > format*:
> > > > > > >
> > > > > > > < some headers > / [optional IPv4/IPv6] / [optional TCP/UDP] /
> > > > > > > <some
> > > > > > > headers> / [optional inner IPv4/IPv6] / [optional TCP/UDP]
> > > > > > >
> > > > > > > For example the following packets can use this feature:
> > > > > > >
> > > > > > > 1. eth / ipv4 / udp / VXLAN / ip / tcp 2. eth / ipv4 / GRE /
> > > > > > > MPLS /
> > > > > > > ipv4 / udp
> > > > > >
> > > > > > So in terms of usage - what is the difference with current TSO
> > types?
> > > > > > Konstantin
> > > > > >
> > > > >
> > > > > Traditionally, HW only recognize "known" tunnel type, do TSO
> > > > > calculation based on L3/L4 headers known to tunnel type. For
> > > > > example, it must be
> > > > > L2 header after VXLAN, then L3. While this Generic offloading
> > > > > provides inner/outer L3/L4 header info(len and offset) to HW, and
> > > > > thus tunnel info become less important. Please note the MPLS over
> > > > > GRE tunnel in last example above.
> > > >
> > > > Ok, but I wonder when the user would like to do TSO on tunnel
> > > > packet, for this offload - would he need to do something differently
> > > > from what he has to do now:
> > > > raise PKT_TX_TCP_SEG and related flags, raise appropriate
> > > > PKT_TX_TUNNEL_* flag, fill l2_len, l3_len,
> > l4_len,tso_segsz,outer_l2_len,outer_l3_len?
> > > >
> > >
> > > Yes, these fields are sufficient except PKT_TX_TUNNEL_*, major target
> > > of this new feature is to support "unknown" tunnel offloading, it
> > supports "known"
> > > tunnel type as well.
> >
> > Ok, but user would still need to set some flag to indicate that this is a
> > tunnel packet, and he wants TSO over it, right?
> > For pre-defined tunnel types it can be one of PKT_TX_TUNNEL_* (which
> > actually means that user still have to know tunnel type anyway?) But for
> > some not defined tunnel type - what it would be?
> > Konstantin
> >
> 
> As this feature target to TX path, Outer length as tunnel indication,
> leave it empty if tunnel not defined.

Sorry, I didn't get it.
We need to let PMD know that it is a tunnel packet, right?
So we do need to raise PKT_TX_TUNNEL_* flag.

> 
> But I think it good to define something like:
>  	PKT_TX_TUNNEL_GENERIC = PKT_TX_TUNNEL_MASK

Yes, that's an option, I would probably name it PKT_TX_TUNNEL_UNKNOWN.

> And a new flag PKT_TX_OUTER_UDP, how do you think?

Not sure why do we need it?
HW still needs to know outer_l4_type to be able to work correctly?
Konstantin

> 
> > >
> > > PKT_TX_TUNNEL_VXLAN has to be used as a hint if outer UDP expected.
> > >
> > > > Konstantin
> > > >
> > > > >
> > > > > > >
> > > > > > > Signed-off-by: Xueming Li <xuemingl@mellanox.com>
> > > > > > > ---
> > > > > > >  lib/librte_ether/rte_ethdev.h | 10 ++++++++++
> > > > > > >  1 file changed, 10 insertions(+)
> > > > > > >
> > > > > > > diff --git a/lib/librte_ether/rte_ethdev.h
> > > > > > > b/lib/librte_ether/rte_ethdev.h index 1a5b4cdc5..d8d08ccb2
> > > > > > > 100644
> > > > > > > --- a/lib/librte_ether/rte_ethdev.h
> > > > > > > +++ b/lib/librte_ether/rte_ethdev.h
> > > > > > > @@ -979,6 +979,16 @@ struct rte_eth_conf {
> > > > > > >   *   the same mempool and has refcnt = 1.
> > > > > > >   */
> > > > > > >  #define DEV_TX_OFFLOAD_SECURITY         0x00020000
> > > > > > > +/**< Device supports generic tunnel checksum and TSO offloading.
> > > > > > > + * Checksum and TSO are done based on following mbuf fields:
> > > > > > > + *   - Length of each header
> > > > > > > + *   - Type of outer/inner L3 type, IPv4 or IPv6
> > > > > > > + *   - Type of outer/inner L4 type, TCP or UDP.
> > > > > > > + *	- PKT_TX_TUNNEL_VXLAN implies outer UDP type.
> > > > > > > + *	- PKT_TX_TCP_SEG implies inner TCP type.
> > > > > > > + * Tunnel type is optional except PKT_TX_TUNNEL_VXLAN to hint
> > > > > > > +outer
> > > > UDP.
> > > > > > > + */
> > > > > > > +#define DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO	0x00040000
> > > > > > >
> > > > > > >  /*
> > > > > > >   * If new Tx offload capabilities are defined, they also must
> > > > > > > be
> > > > > > > --
> > > > > > > 2.13.3


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

* Re: [dpdk-dev] [PATCH v2 1/5] ethdev: introduce Tx generic tunnel offloads
  2018-01-30 16:02                 ` Ananyev, Konstantin
@ 2018-01-30 16:10                   ` Xueming(Steven) Li
  2018-01-30 17:04                     ` Ananyev, Konstantin
  0 siblings, 1 reply; 80+ messages in thread
From: Xueming(Steven) Li @ 2018-01-30 16:10 UTC (permalink / raw)
  To: Ananyev, Konstantin, Olivier MATZ
  Cc: dev, Wu, Jingjing, Shahaf Shuler, Yongseok Koh, Thomas Monjalon,
	Yigit, Ferruh



> -----Original Message-----
> From: Ananyev, Konstantin [mailto:konstantin.ananyev@intel.com]
> Sent: Wednesday, January 31, 2018 12:03 AM
> To: Xueming(Steven) Li <xuemingl@mellanox.com>; Olivier MATZ
> <olivier.matz@6wind.com>
> Cc: dev@dpdk.org; Wu, Jingjing <jingjing.wu@intel.com>; Shahaf Shuler
> <shahafs@mellanox.com>; Yongseok Koh <yskoh@mellanox.com>; Thomas Monjalon
> <thomas@monjalon.net>; Yigit, Ferruh <ferruh.yigit@intel.com>
> Subject: RE: [dpdk-dev] [PATCH v2 1/5] ethdev: introduce Tx generic tunnel
> offloads
> 
> 
> 
> > > > >
> > > > > > > > This patch introduce new TX offloads flag for devices that
> > > > > > > > support tunnel agnostic checksum and TSO offloads.
> > > > > > > >
> > > > > > > > The support from the device is for inner and outer
> > > > > > > > checksums on IPV4/TCP/UDP and TSO for *any packet with the
> > > > > > > > following
> > > format*:
> > > > > > > >
> > > > > > > > < some headers > / [optional IPv4/IPv6] / [optional
> > > > > > > > TCP/UDP] / <some
> > > > > > > > headers> / [optional inner IPv4/IPv6] / [optional TCP/UDP]
> > > > > > > >
> > > > > > > > For example the following packets can use this feature:
> > > > > > > >
> > > > > > > > 1. eth / ipv4 / udp / VXLAN / ip / tcp 2. eth / ipv4 / GRE
> > > > > > > > / MPLS /
> > > > > > > > ipv4 / udp
> > > > > > >
> > > > > > > So in terms of usage - what is the difference with current
> > > > > > > TSO
> > > types?
> > > > > > > Konstantin
> > > > > > >
> > > > > >
> > > > > > Traditionally, HW only recognize "known" tunnel type, do TSO
> > > > > > calculation based on L3/L4 headers known to tunnel type. For
> > > > > > example, it must be
> > > > > > L2 header after VXLAN, then L3. While this Generic offloading
> > > > > > provides inner/outer L3/L4 header info(len and offset) to HW,
> > > > > > and thus tunnel info become less important. Please note the
> > > > > > MPLS over GRE tunnel in last example above.
> > > > >
> > > > > Ok, but I wonder when the user would like to do TSO on tunnel
> > > > > packet, for this offload - would he need to do something
> > > > > differently from what he has to do now:
> > > > > raise PKT_TX_TCP_SEG and related flags, raise appropriate
> > > > > PKT_TX_TUNNEL_* flag, fill l2_len, l3_len,
> > > l4_len,tso_segsz,outer_l2_len,outer_l3_len?
> > > > >
> > > >
> > > > Yes, these fields are sufficient except PKT_TX_TUNNEL_*, major
> > > > target of this new feature is to support "unknown" tunnel
> > > > offloading, it
> > > supports "known"
> > > > tunnel type as well.
> > >
> > > Ok, but user would still need to set some flag to indicate that this
> > > is a tunnel packet, and he wants TSO over it, right?
> > > For pre-defined tunnel types it can be one of PKT_TX_TUNNEL_* (which
> > > actually means that user still have to know tunnel type anyway?) But
> > > for some not defined tunnel type - what it would be?
> > > Konstantin
> > >
> >
> > As this feature target to TX path, Outer length as tunnel indication,
> > leave it empty if tunnel not defined.
> 
> Sorry, I didn't get it.
> We need to let PMD know that it is a tunnel packet, right?
> So we do need to raise PKT_TX_TUNNEL_* flag.
> 

In my current code, mbuf.outer_l2_len is used to test tunnel packet. 
Agree a new tunnel flag would be better. 

> >
> > But I think it good to define something like:
> >  	PKT_TX_TUNNEL_GENERIC = PKT_TX_TUNNEL_MASK
> 
> Yes, that's an option, I would probably name it PKT_TX_TUNNEL_UNKNOWN.
> 
> > And a new flag PKT_TX_OUTER_UDP, how do you think?
> 
> Not sure why do we need it?
> HW still needs to know outer_l4_type to be able to work correctly?

For tunnel type like vxlan, if outer UDP present, hw has to update UDP
length field for each TSO packet segment.

> Konstantin
> 
> >
> > > >
> > > > PKT_TX_TUNNEL_VXLAN has to be used as a hint if outer UDP expected.
> > > >
> > > > > Konstantin
> > > > >
> > > > > >
> > > > > > > >
> > > > > > > > Signed-off-by: Xueming Li <xuemingl@mellanox.com>
> > > > > > > > ---
> > > > > > > >  lib/librte_ether/rte_ethdev.h | 10 ++++++++++
> > > > > > > >  1 file changed, 10 insertions(+)
> > > > > > > >
> > > > > > > > diff --git a/lib/librte_ether/rte_ethdev.h
> > > > > > > > b/lib/librte_ether/rte_ethdev.h index 1a5b4cdc5..d8d08ccb2
> > > > > > > > 100644
> > > > > > > > --- a/lib/librte_ether/rte_ethdev.h
> > > > > > > > +++ b/lib/librte_ether/rte_ethdev.h
> > > > > > > > @@ -979,6 +979,16 @@ struct rte_eth_conf {
> > > > > > > >   *   the same mempool and has refcnt = 1.
> > > > > > > >   */
> > > > > > > >  #define DEV_TX_OFFLOAD_SECURITY         0x00020000
> > > > > > > > +/**< Device supports generic tunnel checksum and TSO
> offloading.
> > > > > > > > + * Checksum and TSO are done based on following mbuf fields:
> > > > > > > > + *   - Length of each header
> > > > > > > > + *   - Type of outer/inner L3 type, IPv4 or IPv6
> > > > > > > > + *   - Type of outer/inner L4 type, TCP or UDP.
> > > > > > > > + *	- PKT_TX_TUNNEL_VXLAN implies outer UDP type.
> > > > > > > > + *	- PKT_TX_TCP_SEG implies inner TCP type.
> > > > > > > > + * Tunnel type is optional except PKT_TX_TUNNEL_VXLAN to
> > > > > > > > +hint outer
> > > > > UDP.
> > > > > > > > + */
> > > > > > > > +#define DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO	0x00040000
> > > > > > > >
> > > > > > > >  /*
> > > > > > > >   * If new Tx offload capabilities are defined, they also
> > > > > > > > must be
> > > > > > > > --
> > > > > > > > 2.13.3


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

* Re: [dpdk-dev] [PATCH v2 1/5] ethdev: introduce Tx generic tunnel offloads
  2018-01-30 16:10                   ` Xueming(Steven) Li
@ 2018-01-30 17:04                     ` Ananyev, Konstantin
  2018-01-30 17:54                       ` Xueming(Steven) Li
  0 siblings, 1 reply; 80+ messages in thread
From: Ananyev, Konstantin @ 2018-01-30 17:04 UTC (permalink / raw)
  To: Xueming(Steven) Li, Olivier MATZ
  Cc: dev, Wu, Jingjing, Shahaf Shuler, Yongseok Koh, Thomas Monjalon,
	Yigit, Ferruh



> -----Original Message-----
> From: Xueming(Steven) Li [mailto:xuemingl@mellanox.com]
> Sent: Tuesday, January 30, 2018 4:10 PM
> To: Ananyev, Konstantin <konstantin.ananyev@intel.com>; Olivier MATZ <olivier.matz@6wind.com>
> Cc: dev@dpdk.org; Wu, Jingjing <jingjing.wu@intel.com>; Shahaf Shuler <shahafs@mellanox.com>; Yongseok Koh
> <yskoh@mellanox.com>; Thomas Monjalon <thomas@monjalon.net>; Yigit, Ferruh <ferruh.yigit@intel.com>
> Subject: RE: [dpdk-dev] [PATCH v2 1/5] ethdev: introduce Tx generic tunnel offloads
> 
> 
> 
> > -----Original Message-----
> > From: Ananyev, Konstantin [mailto:konstantin.ananyev@intel.com]
> > Sent: Wednesday, January 31, 2018 12:03 AM
> > To: Xueming(Steven) Li <xuemingl@mellanox.com>; Olivier MATZ
> > <olivier.matz@6wind.com>
> > Cc: dev@dpdk.org; Wu, Jingjing <jingjing.wu@intel.com>; Shahaf Shuler
> > <shahafs@mellanox.com>; Yongseok Koh <yskoh@mellanox.com>; Thomas Monjalon
> > <thomas@monjalon.net>; Yigit, Ferruh <ferruh.yigit@intel.com>
> > Subject: RE: [dpdk-dev] [PATCH v2 1/5] ethdev: introduce Tx generic tunnel
> > offloads
> >
> >
> >
> > > > > >
> > > > > > > > > This patch introduce new TX offloads flag for devices that
> > > > > > > > > support tunnel agnostic checksum and TSO offloads.
> > > > > > > > >
> > > > > > > > > The support from the device is for inner and outer
> > > > > > > > > checksums on IPV4/TCP/UDP and TSO for *any packet with the
> > > > > > > > > following
> > > > format*:
> > > > > > > > >
> > > > > > > > > < some headers > / [optional IPv4/IPv6] / [optional
> > > > > > > > > TCP/UDP] / <some
> > > > > > > > > headers> / [optional inner IPv4/IPv6] / [optional TCP/UDP]
> > > > > > > > >
> > > > > > > > > For example the following packets can use this feature:
> > > > > > > > >
> > > > > > > > > 1. eth / ipv4 / udp / VXLAN / ip / tcp 2. eth / ipv4 / GRE
> > > > > > > > > / MPLS /
> > > > > > > > > ipv4 / udp
> > > > > > > >
> > > > > > > > So in terms of usage - what is the difference with current
> > > > > > > > TSO
> > > > types?
> > > > > > > > Konstantin
> > > > > > > >
> > > > > > >
> > > > > > > Traditionally, HW only recognize "known" tunnel type, do TSO
> > > > > > > calculation based on L3/L4 headers known to tunnel type. For
> > > > > > > example, it must be
> > > > > > > L2 header after VXLAN, then L3. While this Generic offloading
> > > > > > > provides inner/outer L3/L4 header info(len and offset) to HW,
> > > > > > > and thus tunnel info become less important. Please note the
> > > > > > > MPLS over GRE tunnel in last example above.
> > > > > >
> > > > > > Ok, but I wonder when the user would like to do TSO on tunnel
> > > > > > packet, for this offload - would he need to do something
> > > > > > differently from what he has to do now:
> > > > > > raise PKT_TX_TCP_SEG and related flags, raise appropriate
> > > > > > PKT_TX_TUNNEL_* flag, fill l2_len, l3_len,
> > > > l4_len,tso_segsz,outer_l2_len,outer_l3_len?
> > > > > >
> > > > >
> > > > > Yes, these fields are sufficient except PKT_TX_TUNNEL_*, major
> > > > > target of this new feature is to support "unknown" tunnel
> > > > > offloading, it
> > > > supports "known"
> > > > > tunnel type as well.
> > > >
> > > > Ok, but user would still need to set some flag to indicate that this
> > > > is a tunnel packet, and he wants TSO over it, right?
> > > > For pre-defined tunnel types it can be one of PKT_TX_TUNNEL_* (which
> > > > actually means that user still have to know tunnel type anyway?) But
> > > > for some not defined tunnel type - what it would be?
> > > > Konstantin
> > > >
> > >
> > > As this feature target to TX path, Outer length as tunnel indication,
> > > leave it empty if tunnel not defined.
> >
> > Sorry, I didn't get it.
> > We need to let PMD know that it is a tunnel packet, right?
> > So we do need to raise PKT_TX_TUNNEL_* flag.
> >
> 
> In my current code, mbuf.outer_l2_len is used to test tunnel packet.
> Agree a new tunnel flag would be better.
> 
> > >
> > > But I think it good to define something like:
> > >  	PKT_TX_TUNNEL_GENERIC = PKT_TX_TUNNEL_MASK
> >
> > Yes, that's an option, I would probably name it PKT_TX_TUNNEL_UNKNOWN.
> >
> > > And a new flag PKT_TX_OUTER_UDP, how do you think?
> >
> > Not sure why do we need it?
> > HW still needs to know outer_l4_type to be able to work correctly?
> 
> For tunnel type like vxlan, if outer UDP present, hw has to update UDP
> length field for each TSO packet segment.

I understand that, but I thought that HW is smart enough to parse the header
and recognize outer L3/L4 type  - as it is a 'generic' tunneling 
(sorry I am not familiar with MLX HW at all).
From what you saying - that assumption was wrong and user still  need
to provide some packet-type info at  least about outer headers, right?
So what else need to be set?  
Probably PKT_TX_OUTER_IPV*, might be something else?
Konstantin

> Konstantin
> >
> > >
> > > > >
> > > > > PKT_TX_TUNNEL_VXLAN has to be used as a hint if outer UDP expected.
> > > > >
> > > > > > Konstantin
> > > > > >
> > > > > > >
> > > > > > > > >
> > > > > > > > > Signed-off-by: Xueming Li <xuemingl@mellanox.com>
> > > > > > > > > ---
> > > > > > > > >  lib/librte_ether/rte_ethdev.h | 10 ++++++++++
> > > > > > > > >  1 file changed, 10 insertions(+)
> > > > > > > > >
> > > > > > > > > diff --git a/lib/librte_ether/rte_ethdev.h
> > > > > > > > > b/lib/librte_ether/rte_ethdev.h index 1a5b4cdc5..d8d08ccb2
> > > > > > > > > 100644
> > > > > > > > > --- a/lib/librte_ether/rte_ethdev.h
> > > > > > > > > +++ b/lib/librte_ether/rte_ethdev.h
> > > > > > > > > @@ -979,6 +979,16 @@ struct rte_eth_conf {
> > > > > > > > >   *   the same mempool and has refcnt = 1.
> > > > > > > > >   */
> > > > > > > > >  #define DEV_TX_OFFLOAD_SECURITY         0x00020000
> > > > > > > > > +/**< Device supports generic tunnel checksum and TSO
> > offloading.
> > > > > > > > > + * Checksum and TSO are done based on following mbuf fields:
> > > > > > > > > + *   - Length of each header
> > > > > > > > > + *   - Type of outer/inner L3 type, IPv4 or IPv6
> > > > > > > > > + *   - Type of outer/inner L4 type, TCP or UDP.
> > > > > > > > > + *	- PKT_TX_TUNNEL_VXLAN implies outer UDP type.
> > > > > > > > > + *	- PKT_TX_TCP_SEG implies inner TCP type.
> > > > > > > > > + * Tunnel type is optional except PKT_TX_TUNNEL_VXLAN to
> > > > > > > > > +hint outer
> > > > > > UDP.
> > > > > > > > > + */
> > > > > > > > > +#define DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO	0x00040000
> > > > > > > > >
> > > > > > > > >  /*
> > > > > > > > >   * If new Tx offload capabilities are defined, they also
> > > > > > > > > must be
> > > > > > > > > --
> > > > > > > > > 2.13.3


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

* Re: [dpdk-dev] [PATCH v2 1/5] ethdev: introduce Tx generic tunnel offloads
  2018-01-30 17:04                     ` Ananyev, Konstantin
@ 2018-01-30 17:54                       ` Xueming(Steven) Li
  2018-01-30 20:21                         ` Thomas Monjalon
  2018-01-31 15:17                         ` Xueming(Steven) Li
  0 siblings, 2 replies; 80+ messages in thread
From: Xueming(Steven) Li @ 2018-01-30 17:54 UTC (permalink / raw)
  To: Ananyev, Konstantin, Olivier MATZ
  Cc: dev, Wu, Jingjing, Shahaf Shuler, Yongseok Koh, Thomas Monjalon,
	Yigit, Ferruh



> -----Original Message-----
> From: Ananyev, Konstantin [mailto:konstantin.ananyev@intel.com]
> Sent: Wednesday, January 31, 2018 1:05 AM
> To: Xueming(Steven) Li <xuemingl@mellanox.com>; Olivier MATZ
> <olivier.matz@6wind.com>
> Cc: dev@dpdk.org; Wu, Jingjing <jingjing.wu@intel.com>; Shahaf Shuler
> <shahafs@mellanox.com>; Yongseok Koh <yskoh@mellanox.com>; Thomas Monjalon
> <thomas@monjalon.net>; Yigit, Ferruh <ferruh.yigit@intel.com>
> Subject: RE: [dpdk-dev] [PATCH v2 1/5] ethdev: introduce Tx generic tunnel
> offloads
> 
> 
> 
> > -----Original Message-----
> > From: Xueming(Steven) Li [mailto:xuemingl@mellanox.com]
> > Sent: Tuesday, January 30, 2018 4:10 PM
> > To: Ananyev, Konstantin <konstantin.ananyev@intel.com>; Olivier MATZ
> > <olivier.matz@6wind.com>
> > Cc: dev@dpdk.org; Wu, Jingjing <jingjing.wu@intel.com>; Shahaf Shuler
> > <shahafs@mellanox.com>; Yongseok Koh <yskoh@mellanox.com>; Thomas
> > Monjalon <thomas@monjalon.net>; Yigit, Ferruh <ferruh.yigit@intel.com>
> > Subject: RE: [dpdk-dev] [PATCH v2 1/5] ethdev: introduce Tx generic
> > tunnel offloads
> >
> >
> >
> > > -----Original Message-----
> > > From: Ananyev, Konstantin [mailto:konstantin.ananyev@intel.com]
> > > Sent: Wednesday, January 31, 2018 12:03 AM
> > > To: Xueming(Steven) Li <xuemingl@mellanox.com>; Olivier MATZ
> > > <olivier.matz@6wind.com>
> > > Cc: dev@dpdk.org; Wu, Jingjing <jingjing.wu@intel.com>; Shahaf
> > > Shuler <shahafs@mellanox.com>; Yongseok Koh <yskoh@mellanox.com>;
> > > Thomas Monjalon <thomas@monjalon.net>; Yigit, Ferruh
> > > <ferruh.yigit@intel.com>
> > > Subject: RE: [dpdk-dev] [PATCH v2 1/5] ethdev: introduce Tx generic
> > > tunnel offloads
> > >
> > >
> > >
> > > > > > >
> > > > > > > > > > This patch introduce new TX offloads flag for devices
> > > > > > > > > > that support tunnel agnostic checksum and TSO offloads.
> > > > > > > > > >
> > > > > > > > > > The support from the device is for inner and outer
> > > > > > > > > > checksums on IPV4/TCP/UDP and TSO for *any packet with
> > > > > > > > > > the following
> > > > > format*:
> > > > > > > > > >
> > > > > > > > > > < some headers > / [optional IPv4/IPv6] / [optional
> > > > > > > > > > TCP/UDP] / <some
> > > > > > > > > > headers> / [optional inner IPv4/IPv6] / [optional
> > > > > > > > > > headers> TCP/UDP]
> > > > > > > > > >
> > > > > > > > > > For example the following packets can use this feature:
> > > > > > > > > >
> > > > > > > > > > 1. eth / ipv4 / udp / VXLAN / ip / tcp 2. eth / ipv4 /
> > > > > > > > > > GRE / MPLS /
> > > > > > > > > > ipv4 / udp
> > > > > > > > >
> > > > > > > > > So in terms of usage - what is the difference with
> > > > > > > > > current TSO
> > > > > types?
> > > > > > > > > Konstantin
> > > > > > > > >
> > > > > > > >
> > > > > > > > Traditionally, HW only recognize "known" tunnel type, do
> > > > > > > > TSO calculation based on L3/L4 headers known to tunnel
> > > > > > > > type. For example, it must be
> > > > > > > > L2 header after VXLAN, then L3. While this Generic
> > > > > > > > offloading provides inner/outer L3/L4 header info(len and
> > > > > > > > offset) to HW, and thus tunnel info become less important.
> > > > > > > > Please note the MPLS over GRE tunnel in last example above.
> > > > > > >
> > > > > > > Ok, but I wonder when the user would like to do TSO on
> > > > > > > tunnel packet, for this offload - would he need to do
> > > > > > > something differently from what he has to do now:
> > > > > > > raise PKT_TX_TCP_SEG and related flags, raise appropriate
> > > > > > > PKT_TX_TUNNEL_* flag, fill l2_len, l3_len,
> > > > > l4_len,tso_segsz,outer_l2_len,outer_l3_len?
> > > > > > >
> > > > > >
> > > > > > Yes, these fields are sufficient except PKT_TX_TUNNEL_*, major
> > > > > > target of this new feature is to support "unknown" tunnel
> > > > > > offloading, it
> > > > > supports "known"
> > > > > > tunnel type as well.
> > > > >
> > > > > Ok, but user would still need to set some flag to indicate that
> > > > > this is a tunnel packet, and he wants TSO over it, right?
> > > > > For pre-defined tunnel types it can be one of PKT_TX_TUNNEL_*
> > > > > (which actually means that user still have to know tunnel type
> > > > > anyway?) But for some not defined tunnel type - what it would be?
> > > > > Konstantin
> > > > >
> > > >
> > > > As this feature target to TX path, Outer length as tunnel
> > > > indication, leave it empty if tunnel not defined.
> > >
> > > Sorry, I didn't get it.
> > > We need to let PMD know that it is a tunnel packet, right?
> > > So we do need to raise PKT_TX_TUNNEL_* flag.
> > >
> >
> > In my current code, mbuf.outer_l2_len is used to test tunnel packet.
> > Agree a new tunnel flag would be better.
> >
> > > >
> > > > But I think it good to define something like:
> > > >  	PKT_TX_TUNNEL_GENERIC = PKT_TX_TUNNEL_MASK
> > >
> > > Yes, that's an option, I would probably name it PKT_TX_TUNNEL_UNKNOWN.
> > >
> > > > And a new flag PKT_TX_OUTER_UDP, how do you think?
> > >
> > > Not sure why do we need it?
> > > HW still needs to know outer_l4_type to be able to work correctly?
> >
> > For tunnel type like vxlan, if outer UDP present, hw has to update UDP
> > length field for each TSO packet segment.
> 
> I understand that, but I thought that HW is smart enough to parse the
> header and recognize outer L3/L4 type  - as it is a 'generic' tunneling
> (sorry I am not familiar with MLX HW at all).

It might be useful if the outer encapsulation not regular, for example MPLS.

> From what you saying - that assumption was wrong and user still  need to
> provide some packet-type info at  least about outer headers, right?
> So what else need to be set?
> Probably PKT_TX_OUTER_IPV*, might be something else?

Sorry for the confusion, besides optional outer UDP type, still need PKT_TX_IPV4/6 and PKT_TX_OUTER_IPV4/6 


> Konstantin
> 
> > Konstantin
> > >
> > > >
> > > > > >
> > > > > > PKT_TX_TUNNEL_VXLAN has to be used as a hint if outer UDP
> expected.
> > > > > >
> > > > > > > Konstantin
> > > > > > >
> > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Signed-off-by: Xueming Li <xuemingl@mellanox.com>
> > > > > > > > > > ---
> > > > > > > > > >  lib/librte_ether/rte_ethdev.h | 10 ++++++++++
> > > > > > > > > >  1 file changed, 10 insertions(+)
> > > > > > > > > >
> > > > > > > > > > diff --git a/lib/librte_ether/rte_ethdev.h
> > > > > > > > > > b/lib/librte_ether/rte_ethdev.h index
> > > > > > > > > > 1a5b4cdc5..d8d08ccb2
> > > > > > > > > > 100644
> > > > > > > > > > --- a/lib/librte_ether/rte_ethdev.h
> > > > > > > > > > +++ b/lib/librte_ether/rte_ethdev.h
> > > > > > > > > > @@ -979,6 +979,16 @@ struct rte_eth_conf {
> > > > > > > > > >   *   the same mempool and has refcnt = 1.
> > > > > > > > > >   */
> > > > > > > > > >  #define DEV_TX_OFFLOAD_SECURITY         0x00020000
> > > > > > > > > > +/**< Device supports generic tunnel checksum and TSO
> > > offloading.
> > > > > > > > > > + * Checksum and TSO are done based on following mbuf
> fields:
> > > > > > > > > > + *   - Length of each header
> > > > > > > > > > + *   - Type of outer/inner L3 type, IPv4 or IPv6
> > > > > > > > > > + *   - Type of outer/inner L4 type, TCP or UDP.
> > > > > > > > > > + *	- PKT_TX_TUNNEL_VXLAN implies outer UDP type.
> > > > > > > > > > + *	- PKT_TX_TCP_SEG implies inner TCP type.
> > > > > > > > > > + * Tunnel type is optional except PKT_TX_TUNNEL_VXLAN
> > > > > > > > > > +to hint outer
> > > > > > > UDP.
> > > > > > > > > > + */
> > > > > > > > > > +#define DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO
> 	0x00040000
> > > > > > > > > >
> > > > > > > > > >  /*
> > > > > > > > > >   * If new Tx offload capabilities are defined, they
> > > > > > > > > > also must be
> > > > > > > > > > --
> > > > > > > > > > 2.13.3


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

* Re: [dpdk-dev] [PATCH v2 1/5] ethdev: introduce Tx generic tunnel offloads
  2018-01-30 17:54                       ` Xueming(Steven) Li
@ 2018-01-30 20:21                         ` Thomas Monjalon
  2018-01-31 15:20                           ` Xueming(Steven) Li
  2018-01-31 15:17                         ` Xueming(Steven) Li
  1 sibling, 1 reply; 80+ messages in thread
From: Thomas Monjalon @ 2018-01-30 20:21 UTC (permalink / raw)
  To: Xueming(Steven) Li
  Cc: Ananyev, Konstantin, Olivier MATZ, dev, Wu, Jingjing,
	Shahaf Shuler, Yongseok Koh, Yigit, Ferruh

Xueming,

We already discussed privately some time ago about this API.
You got some questions from me, from Olivier and from Konstantin.
The next version should answer the questions asked.

When defining an API, the doxygen documentation must explain precisely
what must be set, when and why.
The documentation must be sufficient to allow users using it,
and to allow PMD writers to implement it.

I think it cannot be properly reviewed until we clearly understand
the API and the HW requirements/expectations.

Hope this helps to understand what is expected for integrating such API.


30/01/2018 18:54, Xueming(Steven) Li:

> > > > > > > > > > > This patch introduce new TX offloads flag for devices
> > > > > > > > > > > that support tunnel agnostic checksum and TSO offloads.
> > > > > > > > > > >
> > > > > > > > > > > The support from the device is for inner and outer
> > > > > > > > > > > checksums on IPV4/TCP/UDP and TSO for *any packet with
> > > > > > > > > > > the following
> > > > > > format*:
> > > > > > > > > > >
> > > > > > > > > > > < some headers > / [optional IPv4/IPv6] / [optional
> > > > > > > > > > > TCP/UDP] / <some
> > > > > > > > > > > headers> / [optional inner IPv4/IPv6] / [optional
> > > > > > > > > > > headers> TCP/UDP]
> > > > > > > > > > >
> > > > > > > > > > > For example the following packets can use this feature:
> > > > > > > > > > >
> > > > > > > > > > > 1. eth / ipv4 / udp / VXLAN / ip / tcp 2. eth / ipv4 /
> > > > > > > > > > > GRE / MPLS /
> > > > > > > > > > > ipv4 / udp
> > > > > > > > > >
> > > > > > > > > > So in terms of usage - what is the difference with
> > > > > > > > > > current TSO
> > > > > > types?
> > > > > > > > > > Konstantin
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > > Traditionally, HW only recognize "known" tunnel type, do
> > > > > > > > > TSO calculation based on L3/L4 headers known to tunnel
> > > > > > > > > type. For example, it must be
> > > > > > > > > L2 header after VXLAN, then L3. While this Generic
> > > > > > > > > offloading provides inner/outer L3/L4 header info(len and
> > > > > > > > > offset) to HW, and thus tunnel info become less important.
> > > > > > > > > Please note the MPLS over GRE tunnel in last example above.
> > > > > > > >
> > > > > > > > Ok, but I wonder when the user would like to do TSO on
> > > > > > > > tunnel packet, for this offload - would he need to do
> > > > > > > > something differently from what he has to do now:
> > > > > > > > raise PKT_TX_TCP_SEG and related flags, raise appropriate
> > > > > > > > PKT_TX_TUNNEL_* flag, fill l2_len, l3_len,
> > > > > > l4_len,tso_segsz,outer_l2_len,outer_l3_len?
> > > > > > > >
> > > > > > >
> > > > > > > Yes, these fields are sufficient except PKT_TX_TUNNEL_*, major
> > > > > > > target of this new feature is to support "unknown" tunnel
> > > > > > > offloading, it
> > > > > > supports "known"
> > > > > > > tunnel type as well.
> > > > > >
> > > > > > Ok, but user would still need to set some flag to indicate that
> > > > > > this is a tunnel packet, and he wants TSO over it, right?
> > > > > > For pre-defined tunnel types it can be one of PKT_TX_TUNNEL_*
> > > > > > (which actually means that user still have to know tunnel type
> > > > > > anyway?) But for some not defined tunnel type - what it would be?
> > > > > > Konstantin
> > > > > >
> > > > >
> > > > > As this feature target to TX path, Outer length as tunnel
> > > > > indication, leave it empty if tunnel not defined.
> > > >
> > > > Sorry, I didn't get it.
> > > > We need to let PMD know that it is a tunnel packet, right?
> > > > So we do need to raise PKT_TX_TUNNEL_* flag.
> > > >
> > >
> > > In my current code, mbuf.outer_l2_len is used to test tunnel packet.
> > > Agree a new tunnel flag would be better.
> > >
> > > > >
> > > > > But I think it good to define something like:
> > > > >  	PKT_TX_TUNNEL_GENERIC = PKT_TX_TUNNEL_MASK
> > > >
> > > > Yes, that's an option, I would probably name it PKT_TX_TUNNEL_UNKNOWN.
> > > >
> > > > > And a new flag PKT_TX_OUTER_UDP, how do you think?
> > > >
> > > > Not sure why do we need it?
> > > > HW still needs to know outer_l4_type to be able to work correctly?
> > >
> > > For tunnel type like vxlan, if outer UDP present, hw has to update UDP
> > > length field for each TSO packet segment.
> > 
> > I understand that, but I thought that HW is smart enough to parse the
> > header and recognize outer L3/L4 type  - as it is a 'generic' tunneling
> > (sorry I am not familiar with MLX HW at all).
> 
> It might be useful if the outer encapsulation not regular, for example MPLS.
> 
> > From what you saying - that assumption was wrong and user still  need to
> > provide some packet-type info at  least about outer headers, right?
> > So what else need to be set?
> > Probably PKT_TX_OUTER_IPV*, might be something else?
> 
> Sorry for the confusion, besides optional outer UDP type, still need PKT_TX_IPV4/6 and PKT_TX_OUTER_IPV4/6 

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

* Re: [dpdk-dev] [PATCH v2 1/5] ethdev: introduce Tx generic tunnel offloads
  2018-01-30 17:54                       ` Xueming(Steven) Li
  2018-01-30 20:21                         ` Thomas Monjalon
@ 2018-01-31 15:17                         ` Xueming(Steven) Li
  1 sibling, 0 replies; 80+ messages in thread
From: Xueming(Steven) Li @ 2018-01-31 15:17 UTC (permalink / raw)
  To: Xueming(Steven) Li, Ananyev, Konstantin, Olivier MATZ
  Cc: dev, Wu, Jingjing, Shahaf Shuler, Yongseok Koh, Thomas Monjalon,
	Yigit, Ferruh



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Xueming(Steven) Li
> Sent: Wednesday, January 31, 2018 1:54 AM
> To: Ananyev, Konstantin <konstantin.ananyev@intel.com>; Olivier MATZ
> <olivier.matz@6wind.com>
> Cc: dev@dpdk.org; Wu, Jingjing <jingjing.wu@intel.com>; Shahaf Shuler
> <shahafs@mellanox.com>; Yongseok Koh <yskoh@mellanox.com>; Thomas Monjalon
> <thomas@monjalon.net>; Yigit, Ferruh <ferruh.yigit@intel.com>
> Subject: Re: [dpdk-dev] [PATCH v2 1/5] ethdev: introduce Tx generic tunnel
> offloads
> 
> 
> 
> > -----Original Message-----
> > From: Ananyev, Konstantin [mailto:konstantin.ananyev@intel.com]
> > Sent: Wednesday, January 31, 2018 1:05 AM
> > To: Xueming(Steven) Li <xuemingl@mellanox.com>; Olivier MATZ
> > <olivier.matz@6wind.com>
> > Cc: dev@dpdk.org; Wu, Jingjing <jingjing.wu@intel.com>; Shahaf Shuler
> > <shahafs@mellanox.com>; Yongseok Koh <yskoh@mellanox.com>; Thomas
> > Monjalon <thomas@monjalon.net>; Yigit, Ferruh <ferruh.yigit@intel.com>
> > Subject: RE: [dpdk-dev] [PATCH v2 1/5] ethdev: introduce Tx generic
> > tunnel offloads
> >
> >
> >
> > > -----Original Message-----
> > > From: Xueming(Steven) Li [mailto:xuemingl@mellanox.com]
> > > Sent: Tuesday, January 30, 2018 4:10 PM
> > > To: Ananyev, Konstantin <konstantin.ananyev@intel.com>; Olivier MATZ
> > > <olivier.matz@6wind.com>
> > > Cc: dev@dpdk.org; Wu, Jingjing <jingjing.wu@intel.com>; Shahaf
> > > Shuler <shahafs@mellanox.com>; Yongseok Koh <yskoh@mellanox.com>;
> > > Thomas Monjalon <thomas@monjalon.net>; Yigit, Ferruh
> > > <ferruh.yigit@intel.com>
> > > Subject: RE: [dpdk-dev] [PATCH v2 1/5] ethdev: introduce Tx generic
> > > tunnel offloads
> > >
> > >
> > >
> > > > -----Original Message-----
> > > > From: Ananyev, Konstantin [mailto:konstantin.ananyev@intel.com]
> > > > Sent: Wednesday, January 31, 2018 12:03 AM
> > > > To: Xueming(Steven) Li <xuemingl@mellanox.com>; Olivier MATZ
> > > > <olivier.matz@6wind.com>
> > > > Cc: dev@dpdk.org; Wu, Jingjing <jingjing.wu@intel.com>; Shahaf
> > > > Shuler <shahafs@mellanox.com>; Yongseok Koh <yskoh@mellanox.com>;
> > > > Thomas Monjalon <thomas@monjalon.net>; Yigit, Ferruh
> > > > <ferruh.yigit@intel.com>
> > > > Subject: RE: [dpdk-dev] [PATCH v2 1/5] ethdev: introduce Tx
> > > > generic tunnel offloads
> > > >
> > > >
> > > >
> > > > > > > >
> > > > > > > > > > > This patch introduce new TX offloads flag for
> > > > > > > > > > > devices that support tunnel agnostic checksum and TSO
> offloads.
> > > > > > > > > > >
> > > > > > > > > > > The support from the device is for inner and outer
> > > > > > > > > > > checksums on IPV4/TCP/UDP and TSO for *any packet
> > > > > > > > > > > with the following
> > > > > > format*:
> > > > > > > > > > >
> > > > > > > > > > > < some headers > / [optional IPv4/IPv6] / [optional
> > > > > > > > > > > TCP/UDP] / <some
> > > > > > > > > > > headers> / [optional inner IPv4/IPv6] / [optional
> > > > > > > > > > > headers> TCP/UDP]
> > > > > > > > > > >
> > > > > > > > > > > For example the following packets can use this feature:
> > > > > > > > > > >
> > > > > > > > > > > 1. eth / ipv4 / udp / VXLAN / ip / tcp 2. eth / ipv4
> > > > > > > > > > > / GRE / MPLS /
> > > > > > > > > > > ipv4 / udp
> > > > > > > > > >
> > > > > > > > > > So in terms of usage - what is the difference with
> > > > > > > > > > current TSO
> > > > > > types?
> > > > > > > > > > Konstantin
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > > Traditionally, HW only recognize "known" tunnel type, do
> > > > > > > > > TSO calculation based on L3/L4 headers known to tunnel
> > > > > > > > > type. For example, it must be
> > > > > > > > > L2 header after VXLAN, then L3. While this Generic
> > > > > > > > > offloading provides inner/outer L3/L4 header info(len
> > > > > > > > > and
> > > > > > > > > offset) to HW, and thus tunnel info become less important.
> > > > > > > > > Please note the MPLS over GRE tunnel in last example above.
> > > > > > > >
> > > > > > > > Ok, but I wonder when the user would like to do TSO on
> > > > > > > > tunnel packet, for this offload - would he need to do
> > > > > > > > something differently from what he has to do now:
> > > > > > > > raise PKT_TX_TCP_SEG and related flags, raise appropriate
> > > > > > > > PKT_TX_TUNNEL_* flag, fill l2_len, l3_len,
> > > > > > l4_len,tso_segsz,outer_l2_len,outer_l3_len?
> > > > > > > >
> > > > > > >
> > > > > > > Yes, these fields are sufficient except PKT_TX_TUNNEL_*,
> > > > > > > major target of this new feature is to support "unknown"
> > > > > > > tunnel offloading, it
> > > > > > supports "known"
> > > > > > > tunnel type as well.
> > > > > >
> > > > > > Ok, but user would still need to set some flag to indicate
> > > > > > that this is a tunnel packet, and he wants TSO over it, right?
> > > > > > For pre-defined tunnel types it can be one of PKT_TX_TUNNEL_*
> > > > > > (which actually means that user still have to know tunnel type
> > > > > > anyway?) But for some not defined tunnel type - what it would be?
> > > > > > Konstantin
> > > > > >
> > > > >
> > > > > As this feature target to TX path, Outer length as tunnel
> > > > > indication, leave it empty if tunnel not defined.
> > > >
> > > > Sorry, I didn't get it.
> > > > We need to let PMD know that it is a tunnel packet, right?
> > > > So we do need to raise PKT_TX_TUNNEL_* flag.
> > > >
> > >
> > > In my current code, mbuf.outer_l2_len is used to test tunnel packet.
> > > Agree a new tunnel flag would be better.
> > >
> > > > >
> > > > > But I think it good to define something like:
> > > > >  	PKT_TX_TUNNEL_GENERIC = PKT_TX_TUNNEL_MASK
> > > >
> > > > Yes, that's an option, I would probably name it
> PKT_TX_TUNNEL_UNKNOWN.
> > > >
> > > > > And a new flag PKT_TX_OUTER_UDP, how do you think?
> > > >
> > > > Not sure why do we need it?
> > > > HW still needs to know outer_l4_type to be able to work correctly?
> > >
> > > For tunnel type like vxlan, if outer UDP present, hw has to update
> > > UDP length field for each TSO packet segment.
> >
> > I understand that, but I thought that HW is smart enough to parse the
> > header and recognize outer L3/L4 type  - as it is a 'generic'
> > tunneling (sorry I am not familiar with MLX HW at all).
> 
> It might be useful if the outer encapsulation not regular, for example
> MPLS.
> 
> > From what you saying - that assumption was wrong and user still  need
> > to provide some packet-type info at  least about outer headers, right?
> > So what else need to be set?
> > Probably PKT_TX_OUTER_IPV*, might be something else?
> 
> Sorry for the confusion, besides optional outer UDP type, still need
> PKT_TX_IPV4/6 and PKT_TX_OUTER_IPV4/6

About introducing PKT_TX_OUTER_UDP, mbuf has defined packet_type which
has all inner/outer and tunnel types, not sure whether it good to
request user set packet_type field, normally it used on RX path.

> 
> 
> > Konstantin
> >
> > > Konstantin
> > > >
> > > > >
> > > > > > >
> > > > > > > PKT_TX_TUNNEL_VXLAN has to be used as a hint if outer UDP
> > expected.
> > > > > > >
> > > > > > > > Konstantin
> > > > > > > >
> > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Signed-off-by: Xueming Li <xuemingl@mellanox.com>
> > > > > > > > > > > ---
> > > > > > > > > > >  lib/librte_ether/rte_ethdev.h | 10 ++++++++++
> > > > > > > > > > >  1 file changed, 10 insertions(+)
> > > > > > > > > > >
> > > > > > > > > > > diff --git a/lib/librte_ether/rte_ethdev.h
> > > > > > > > > > > b/lib/librte_ether/rte_ethdev.h index
> > > > > > > > > > > 1a5b4cdc5..d8d08ccb2
> > > > > > > > > > > 100644
> > > > > > > > > > > --- a/lib/librte_ether/rte_ethdev.h
> > > > > > > > > > > +++ b/lib/librte_ether/rte_ethdev.h
> > > > > > > > > > > @@ -979,6 +979,16 @@ struct rte_eth_conf {
> > > > > > > > > > >   *   the same mempool and has refcnt = 1.
> > > > > > > > > > >   */
> > > > > > > > > > >  #define DEV_TX_OFFLOAD_SECURITY         0x00020000
> > > > > > > > > > > +/**< Device supports generic tunnel checksum and
> > > > > > > > > > > +TSO
> > > > offloading.
> > > > > > > > > > > + * Checksum and TSO are done based on following
> > > > > > > > > > > + mbuf
> > fields:
> > > > > > > > > > > + *   - Length of each header
> > > > > > > > > > > + *   - Type of outer/inner L3 type, IPv4 or IPv6
> > > > > > > > > > > + *   - Type of outer/inner L4 type, TCP or UDP.
> > > > > > > > > > > + *	- PKT_TX_TUNNEL_VXLAN implies outer UDP type.
> > > > > > > > > > > + *	- PKT_TX_TCP_SEG implies inner TCP type.
> > > > > > > > > > > + * Tunnel type is optional except
> > > > > > > > > > > +PKT_TX_TUNNEL_VXLAN to hint outer
> > > > > > > > UDP.
> > > > > > > > > > > + */
> > > > > > > > > > > +#define DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO
> > 	0x00040000
> > > > > > > > > > >
> > > > > > > > > > >  /*
> > > > > > > > > > >   * If new Tx offload capabilities are defined, they
> > > > > > > > > > > also must be
> > > > > > > > > > > --
> > > > > > > > > > > 2.13.3


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

* Re: [dpdk-dev] [PATCH v2 1/5] ethdev: introduce Tx generic tunnel offloads
  2018-01-30 20:21                         ` Thomas Monjalon
@ 2018-01-31 15:20                           ` Xueming(Steven) Li
  0 siblings, 0 replies; 80+ messages in thread
From: Xueming(Steven) Li @ 2018-01-31 15:20 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: Ananyev, Konstantin, Olivier MATZ, dev, Wu, Jingjing,
	Shahaf Shuler, Yongseok Koh, Yigit, Ferruh

Hi Thomas,

Yes, would update in next version, thanks for reminding.

Regards,
Xueming

> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas@monjalon.net]
> Sent: Wednesday, January 31, 2018 4:21 AM
> To: Xueming(Steven) Li <xuemingl@mellanox.com>
> Cc: Ananyev, Konstantin <konstantin.ananyev@intel.com>; Olivier MATZ
> <olivier.matz@6wind.com>; dev@dpdk.org; Wu, Jingjing
> <jingjing.wu@intel.com>; Shahaf Shuler <shahafs@mellanox.com>; Yongseok
> Koh <yskoh@mellanox.com>; Yigit, Ferruh <ferruh.yigit@intel.com>
> Subject: Re: [dpdk-dev] [PATCH v2 1/5] ethdev: introduce Tx generic tunnel
> offloads
> 
> Xueming,
> 
> We already discussed privately some time ago about this API.
> You got some questions from me, from Olivier and from Konstantin.
> The next version should answer the questions asked.
> 
> When defining an API, the doxygen documentation must explain precisely
> what must be set, when and why.
> The documentation must be sufficient to allow users using it, and to allow
> PMD writers to implement it.
> 
> I think it cannot be properly reviewed until we clearly understand the API
> and the HW requirements/expectations.
> 
> Hope this helps to understand what is expected for integrating such API.
> 
> 
> 30/01/2018 18:54, Xueming(Steven) Li:
> 
> > > > > > > > > > > > This patch introduce new TX offloads flag for
> > > > > > > > > > > > devices that support tunnel agnostic checksum and
> TSO offloads.
> > > > > > > > > > > >
> > > > > > > > > > > > The support from the device is for inner and outer
> > > > > > > > > > > > checksums on IPV4/TCP/UDP and TSO for *any packet
> > > > > > > > > > > > with the following
> > > > > > > format*:
> > > > > > > > > > > >
> > > > > > > > > > > > < some headers > / [optional IPv4/IPv6] /
> > > > > > > > > > > > [optional TCP/UDP] / <some
> > > > > > > > > > > > headers> / [optional inner IPv4/IPv6] / [optional
> > > > > > > > > > > > headers> TCP/UDP]
> > > > > > > > > > > >
> > > > > > > > > > > > For example the following packets can use this
> feature:
> > > > > > > > > > > >
> > > > > > > > > > > > 1. eth / ipv4 / udp / VXLAN / ip / tcp 2. eth /
> > > > > > > > > > > > ipv4 / GRE / MPLS /
> > > > > > > > > > > > ipv4 / udp
> > > > > > > > > > >
> > > > > > > > > > > So in terms of usage - what is the difference with
> > > > > > > > > > > current TSO
> > > > > > > types?
> > > > > > > > > > > Konstantin
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Traditionally, HW only recognize "known" tunnel type,
> > > > > > > > > > do TSO calculation based on L3/L4 headers known to
> > > > > > > > > > tunnel type. For example, it must be
> > > > > > > > > > L2 header after VXLAN, then L3. While this Generic
> > > > > > > > > > offloading provides inner/outer L3/L4 header info(len
> > > > > > > > > > and
> > > > > > > > > > offset) to HW, and thus tunnel info become less
> important.
> > > > > > > > > > Please note the MPLS over GRE tunnel in last example
> above.
> > > > > > > > >
> > > > > > > > > Ok, but I wonder when the user would like to do TSO on
> > > > > > > > > tunnel packet, for this offload - would he need to do
> > > > > > > > > something differently from what he has to do now:
> > > > > > > > > raise PKT_TX_TCP_SEG and related flags, raise
> > > > > > > > > appropriate
> > > > > > > > > PKT_TX_TUNNEL_* flag, fill l2_len, l3_len,
> > > > > > > l4_len,tso_segsz,outer_l2_len,outer_l3_len?
> > > > > > > > >
> > > > > > > >
> > > > > > > > Yes, these fields are sufficient except PKT_TX_TUNNEL_*,
> > > > > > > > major target of this new feature is to support "unknown"
> > > > > > > > tunnel offloading, it
> > > > > > > supports "known"
> > > > > > > > tunnel type as well.
> > > > > > >
> > > > > > > Ok, but user would still need to set some flag to indicate
> > > > > > > that this is a tunnel packet, and he wants TSO over it, right?
> > > > > > > For pre-defined tunnel types it can be one of
> > > > > > > PKT_TX_TUNNEL_* (which actually means that user still have
> > > > > > > to know tunnel type
> > > > > > > anyway?) But for some not defined tunnel type - what it would
> be?
> > > > > > > Konstantin
> > > > > > >
> > > > > >
> > > > > > As this feature target to TX path, Outer length as tunnel
> > > > > > indication, leave it empty if tunnel not defined.
> > > > >
> > > > > Sorry, I didn't get it.
> > > > > We need to let PMD know that it is a tunnel packet, right?
> > > > > So we do need to raise PKT_TX_TUNNEL_* flag.
> > > > >
> > > >
> > > > In my current code, mbuf.outer_l2_len is used to test tunnel packet.
> > > > Agree a new tunnel flag would be better.
> > > >
> > > > > >
> > > > > > But I think it good to define something like:
> > > > > >  	PKT_TX_TUNNEL_GENERIC = PKT_TX_TUNNEL_MASK
> > > > >
> > > > > Yes, that's an option, I would probably name it
> PKT_TX_TUNNEL_UNKNOWN.
> > > > >
> > > > > > And a new flag PKT_TX_OUTER_UDP, how do you think?
> > > > >
> > > > > Not sure why do we need it?
> > > > > HW still needs to know outer_l4_type to be able to work correctly?
> > > >
> > > > For tunnel type like vxlan, if outer UDP present, hw has to update
> > > > UDP length field for each TSO packet segment.
> > >
> > > I understand that, but I thought that HW is smart enough to parse
> > > the header and recognize outer L3/L4 type  - as it is a 'generic'
> > > tunneling (sorry I am not familiar with MLX HW at all).
> >
> > It might be useful if the outer encapsulation not regular, for example
> MPLS.
> >
> > > From what you saying - that assumption was wrong and user still
> > > need to provide some packet-type info at  least about outer headers,
> right?
> > > So what else need to be set?
> > > Probably PKT_TX_OUTER_IPV*, might be something else?
> >
> > Sorry for the confusion, besides optional outer UDP type, still need
> > PKT_TX_IPV4/6 and PKT_TX_OUTER_IPV4/6


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

* [dpdk-dev] [PATCH v3 0/7] support generic tunnel Tx checksum and TSO
  2018-01-09 14:11 ` [dpdk-dev] [PATCH 1/6] net/mlx5: support tx swp tunnel offloading Xueming Li
                     ` (4 preceding siblings ...)
  2018-01-29 15:08   ` [dpdk-dev] [PATCH v2 5/5] net/mlx5: allow max 192B TSO inline header length Xueming Li
@ 2018-03-05 14:51   ` Xueming Li
  2018-03-05 14:51   ` [dpdk-dev] [PATCH v3 1/7] ethdev: introduce Tx generic tunnel L3/L4 offload Xueming Li
                     ` (11 subsequent siblings)
  17 siblings, 0 replies; 80+ messages in thread
From: Xueming Li @ 2018-03-05 14:51 UTC (permalink / raw)
  To: Wenzhuo Lu, Jingjing Wu, Thomas Monjalon, Yongseok Koh,
	Olivier MATZ, Shahaf Shuler
  Cc: Xueming Li, Ferruh Yigit, dev

- Add VXLAN-GPE and GRE extention support to testpmd csum forwarding enginee
- Split DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO into DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM
  and DEV_TX_OFFLOAD_GENERIC_TNL_TSO
- Add PKT_TX_TUNNEL_UNKNOWN and PKT_TX_OUTER_UDP

  http://www.dpdk.org/dev/patchwork/patch/34655/


This patchset add new HW TX capability of generic tunnel checksum and TSO
offloads, HW supporting generic tunnel offloading could handle new tunnel 
type offloading w/o upgrading HW. 

This is achieved by informing HW offsets and types of headers, HW would 
do calculation and TSO segments based on packet inner and outer headers offset
regardless of tunnel type.

Xueming Li (7):
  ethdev: introduce Tx generic tunnel L3/L4 offload
  app/testpmd: testpmd support Tx generic tunnel offloads
  app/testpmd: add more GRE extension to csum engine
  app/testpmd: introduce VXLAN GPE to csum forwarding engine
  net/mlx5: separate TSO function in Tx data path
  net/mlx5: support generic tunnel offloading
  net/mlx5: allow max 192B TSO inline header length

 app/test-pmd/cmdline.c                |   9 +-
 app/test-pmd/config.c                 |  18 +++
 app/test-pmd/csumonly.c               | 117 +++++++++++++++++--
 app/test-pmd/parameters.c             |  12 +-
 app/test-pmd/testpmd.h                |   2 +
 doc/guides/nics/mlx5.rst              |   8 ++
 doc/guides/testpmd_app_ug/run_app.rst |   5 +
 drivers/net/mlx5/Makefile             |   5 +
 drivers/net/mlx5/mlx5.c               |  28 ++++-
 drivers/net/mlx5/mlx5.h               |   1 +
 drivers/net/mlx5/mlx5_defs.h          |   2 +-
 drivers/net/mlx5/mlx5_ethdev.c        |   4 +-
 drivers/net/mlx5/mlx5_prm.h           |  24 ++++
 drivers/net/mlx5/mlx5_rxtx.c          | 208 ++++++++++++++++++++++++----------
 drivers/net/mlx5/mlx5_rxtx.h          |  98 ++++++++++++----
 drivers/net/mlx5/mlx5_rxtx_vec.c      |   9 +-
 drivers/net/mlx5/mlx5_rxtx_vec_neon.h |   2 +-
 drivers/net/mlx5/mlx5_rxtx_vec_sse.h  |   2 +-
 drivers/net/mlx5/mlx5_txq.c           |  12 +-
 lib/librte_ether/rte_ethdev.h         |  24 ++++
 lib/librte_mbuf/rte_mbuf.c            |   5 +
 lib/librte_mbuf/rte_mbuf.h            |  18 ++-
 22 files changed, 500 insertions(+), 113 deletions(-)

-- 
2.13.3

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

* [dpdk-dev] [PATCH v3 1/7] ethdev: introduce Tx generic tunnel L3/L4 offload
  2018-01-09 14:11 ` [dpdk-dev] [PATCH 1/6] net/mlx5: support tx swp tunnel offloading Xueming Li
                     ` (5 preceding siblings ...)
  2018-03-05 14:51   ` [dpdk-dev] [PATCH v3 0/7] support generic tunnel Tx checksum and TSO Xueming Li
@ 2018-03-05 14:51   ` Xueming Li
  2018-03-21  1:40     ` Yongseok Koh
  2018-03-05 14:51   ` [dpdk-dev] [PATCH v3 2/7] app/testpmd: testpmd support Tx generic tunnel offloads Xueming Li
                     ` (10 subsequent siblings)
  17 siblings, 1 reply; 80+ messages in thread
From: Xueming Li @ 2018-03-05 14:51 UTC (permalink / raw)
  To: Wenzhuo Lu, Jingjing Wu, Thomas Monjalon, Yongseok Koh,
	Olivier MATZ, Shahaf Shuler
  Cc: Xueming Li, Ferruh Yigit, dev

This patch introduce new TX offload flags for device that supports
tunnel agnostic L3/L4 checksum and TSO offload.

The support from the device is for inner and outer checksums on
IPV4/TCP/UDP and TSO for *any packet with the following format*:

< some headers > / [optional IPv4/IPv6] / [optional TCP/UDP] / <some
headers> / [optional inner IPv4/IPv6] / [optional TCP/UDP]

For example the following packets can use this feature:

1. eth / ipv4 / udp / VXLAN / ip / tcp
2. eth / ipv4 / GRE / MPLS / ipv4 / udp

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
---
 lib/librte_ether/rte_ethdev.h | 24 ++++++++++++++++++++++++
 lib/librte_mbuf/rte_mbuf.c    |  5 +++++
 lib/librte_mbuf/rte_mbuf.h    | 18 ++++++++++++++++--
 3 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 036153306..66d12d3e0 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -980,6 +980,30 @@ struct rte_eth_conf {
  *   the same mempool and has refcnt = 1.
  */
 #define DEV_TX_OFFLOAD_SECURITY         0x00020000
+/**< Generic tunnel L3/L4 checksum offload. To enable this offload feature
+ * for a packet to be transmitted on hardware supporting generic tunnel L3/L4
+ * checksum offload:
+ *  - fill outer_l2_len and outer_l3_len in mbuf
+ *  - fill l2_len and l3_len in mbuf
+ *  - set the flags PKT_TX_TUNNEL_xxx (use PKT_TX_TUNNEL_UNKNOWN if undefined)
+ *  - set the flags PKT_TX_OUTER_IP_CKSUM
+ *  - set the flags PKT_TX_IP_CKSUM
+ *  - set the flags PKT_TX_TCP_CKSUM, PKT_TX_SCTP_CKSUM or PKT_TX_UDP_CKSUM
+ */
+#define DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM	0x00040000
+/**< Generic tunnel segmentation offload. To enable it, the user needs to:
+ *  - fill outer_l2_len and outer_l3_len in mbuf
+ *  - fill l2_len and l3_len in mbuf
+ *  - set the flags PKT_TX_TUNNEL_xxx (use PKT_TX_TUNNEL_UNKNOWN if undefined)
+ *  - set the flags PKT_TX_OUTER_IPV4 or PKT_TX_OUTER_IPV6
+ *  - if it's UDP tunnel, set the flags PKT_TX_OUTER_UDP
+ *  - set the flags PKT_TX_IPV4 or PKT_TX_IPV6
+ *  - set the PKT_TX_TCP_SEG flag in mbuf->ol_flags (this flag implies
+ *    PKT_TX_OUTER_IP_CKSUM, PKT_TX_IP_CKSUM and PKT_TX_TCP_CKSUM)
+ * Hardware that supports generic tunnel TSO offload only update outer/inner
+ * L3/L4 fields, tunnel fields are not touched.
+ */
+#define DEV_TX_OFFLOAD_GENERIC_TNL_TSO		0x00080000
 
 /*
  * If new Tx offload capabilities are defined, they also must be
diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index 091d388d3..c139d5b30 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -400,11 +400,13 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask)
 	case PKT_TX_OUTER_IP_CKSUM: return "PKT_TX_OUTER_IP_CKSUM";
 	case PKT_TX_OUTER_IPV4: return "PKT_TX_OUTER_IPV4";
 	case PKT_TX_OUTER_IPV6: return "PKT_TX_OUTER_IPV6";
+	case PKT_TX_OUTER_UDP: return "PKT_TX_OUTER_UDP";
 	case PKT_TX_TUNNEL_VXLAN: return "PKT_TX_TUNNEL_VXLAN";
 	case PKT_TX_TUNNEL_GRE: return "PKT_TX_TUNNEL_GRE";
 	case PKT_TX_TUNNEL_IPIP: return "PKT_TX_TUNNEL_IPIP";
 	case PKT_TX_TUNNEL_GENEVE: return "PKT_TX_TUNNEL_GENEVE";
 	case PKT_TX_TUNNEL_MPLSINUDP: return "PKT_TX_TUNNEL_MPLSINUDP";
+	case PKT_TX_TUNNEL_UNKNOWN: return "PKT_TX_TUNNEL_UNKNOWN";
 	case PKT_TX_MACSEC: return "PKT_TX_MACSEC";
 	case PKT_TX_SEC_OFFLOAD: return "PKT_TX_SEC_OFFLOAD";
 	default: return NULL;
@@ -429,6 +431,7 @@ rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
 		{ 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_OUTER_UDP, PKT_TX_OUTER_UDP, NULL },
 		{ PKT_TX_TUNNEL_VXLAN, PKT_TX_TUNNEL_MASK,
 		  "PKT_TX_TUNNEL_NONE" },
 		{ PKT_TX_TUNNEL_GRE, PKT_TX_TUNNEL_MASK,
@@ -439,6 +442,8 @@ rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
 		  "PKT_TX_TUNNEL_NONE" },
 		{ PKT_TX_TUNNEL_MPLSINUDP, PKT_TX_TUNNEL_MASK,
 		  "PKT_TX_TUNNEL_NONE" },
+		{ PKT_TX_TUNNEL_UNKNOWN, PKT_TX_TUNNEL_MASK,
+		  "PKT_TX_TUNNEL_NONE" },
 		{ PKT_TX_MACSEC, PKT_TX_MACSEC, NULL },
 		{ PKT_TX_SEC_OFFLOAD, PKT_TX_SEC_OFFLOAD, NULL },
 	};
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 62740254d..53cc1b713 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -210,6 +210,13 @@ extern "C" {
 #define PKT_TX_TUNNEL_GENEVE  (0x4ULL << 45)
 /**< TX packet with MPLS-in-UDP RFC 7510 header. */
 #define PKT_TX_TUNNEL_MPLSINUDP (0x5ULL << 45)
+/**
+ * Used by generic tunnel checksum and TSO. Please refer to document of below
+ * fields to enable this feature on hardware support Generic tunnel offload:
+ *  - DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM
+ *  - DEV_TX_OFFLOAD_GENERIC_TNL_TSO
+ */
+#define PKT_TX_TUNNEL_UNKNOWN (0xFULL << 45)
 /* add new TX TUNNEL type here */
 #define PKT_TX_TUNNEL_MASK    (0xFULL << 45)
 
@@ -232,6 +239,8 @@ extern "C" {
  *  - calculate the pseudo header checksum without taking ip_len in account,
  *    and set it in the TCP header. Refer to rte_ipv4_phdr_cksum() and
  *    rte_ipv6_phdr_cksum() that can be used as helpers.
+ *  PLease refer to DEV_TX_OFFLOAD_GENERIC_TNL_TSO to enable Generic tunnel
+ *  TSO.
  */
 #define PKT_TX_TCP_SEG       (1ULL << 50)
 
@@ -311,6 +320,13 @@ extern "C" {
 #define PKT_TX_OUTER_IPV6    (1ULL << 60)
 
 /**
+ * Packet outer header is UDP. Set when using generic tunnel TSO offload
+ * (DEV_TX_OFFLOAD_GENERIC_TNL_TSO) to tell the NIC that the outer L4
+ * header is UDP.
+ */
+#define PKT_TX_OUTER_UDP     (1ULL << 61) /**< Outer L4 header is UDP. */
+
+/**
  * Bitmask of all supported packet Tx offload features flags,
  * which can be set for packet.
  */
@@ -326,8 +342,6 @@ extern "C" {
 		PKT_TX_MACSEC |		 \
 		PKT_TX_SEC_OFFLOAD)
 
-#define __RESERVED           (1ULL << 61) /**< reserved for future mbuf use */
-
 #define IND_ATTACHED_MBUF    (1ULL << 62) /**< Indirect attached mbuf */
 
 /* Use final bit of flags to indicate a control mbuf */
-- 
2.13.3

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

* [dpdk-dev] [PATCH v3 2/7] app/testpmd: testpmd support Tx generic tunnel offloads
  2018-01-09 14:11 ` [dpdk-dev] [PATCH 1/6] net/mlx5: support tx swp tunnel offloading Xueming Li
                     ` (6 preceding siblings ...)
  2018-03-05 14:51   ` [dpdk-dev] [PATCH v3 1/7] ethdev: introduce Tx generic tunnel L3/L4 offload Xueming Li
@ 2018-03-05 14:51   ` Xueming Li
  2018-03-05 14:51   ` [dpdk-dev] [PATCH v3 3/7] app/testpmd: add more GRE extension to csum engine Xueming Li
                     ` (9 subsequent siblings)
  17 siblings, 0 replies; 80+ messages in thread
From: Xueming Li @ 2018-03-05 14:51 UTC (permalink / raw)
  To: Wenzhuo Lu, Jingjing Wu, Thomas Monjalon, Yongseok Koh,
	Olivier MATZ, Shahaf Shuler
  Cc: Xueming Li, Ferruh Yigit, dev

"show port cap" and "csum parse tunnel" command support TX generic
tunnel offloads

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
---
 app/test-pmd/cmdline.c  |  9 +++++++--
 app/test-pmd/config.c   | 18 ++++++++++++++++++
 app/test-pmd/csumonly.c |  3 ++-
 3 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index d1dc1de6c..4f2b31357 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -4013,6 +4013,9 @@ check_tunnel_tso_nic_support(portid_t port_id)
 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
 		printf("Warning: GENEVE TUNNEL TSO not supported therefore "
 		       "not enabled for port %d\n", port_id);
+	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENERIC_TNL_TSO))
+		printf("Warning: Generic TUNNEL TSO not supported therefore "
+		       "not enabled for port %d\n", port_id);
 	return dev_info;
 }
 
@@ -4040,13 +4043,15 @@ cmd_tunnel_tso_set_parsed(void *parsed_result,
 			~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
 			  DEV_TX_OFFLOAD_GRE_TNL_TSO |
 			  DEV_TX_OFFLOAD_IPIP_TNL_TSO |
-			  DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
+			  DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
+			  DEV_TX_OFFLOAD_GENERIC_TNL_TSO);
 		printf("TSO for tunneled packets is disabled\n");
 	} else {
 		uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
 					 DEV_TX_OFFLOAD_GRE_TNL_TSO |
 					 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
-					 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
+					 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
+					 DEV_TX_OFFLOAD_GENERIC_TNL_TSO);
 
 		ports[res->port_id].dev_conf.txmode.offloads |=
 			(tso_offloads & dev_info.tx_offload_capa);
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 4bb255c62..0e5d1b5f5 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -668,6 +668,15 @@ port_offload_cap_display(portid_t port_id)
 			printf("off\n");
 	}
 
+	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM) {
+		printf("Generic tunnel checksum:  ");
+		if (ports[port_id].dev_conf.txmode.offloads &
+		    DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM)
+			printf("on\n");
+		else
+			printf("off\n");
+	}
+
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) {
 		printf("TX TCP segmentation:           ");
 		if (ports[port_id].dev_conf.txmode.offloads &
@@ -722,6 +731,15 @@ port_offload_cap_display(portid_t port_id)
 			printf("off\n");
 	}
 
+	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENERIC_TNL_TSO) {
+		printf("Generic tunnel TSO:  ");
+		if (ports[port_id].dev_conf.txmode.offloads &
+		    DEV_TX_OFFLOAD_GENERIC_TNL_TSO)
+			printf("on\n");
+		else
+			printf("off\n");
+	}
+
 }
 
 int
diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index 5f5ab64aa..7b2309372 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -693,7 +693,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 					info.l3_len);
 				parse_vxlan(udp_hdr, &info, m->packet_type);
 				if (info.is_tunnel)
-					tx_ol_flags |= PKT_TX_TUNNEL_VXLAN;
+					tx_ol_flags |= (PKT_TX_TUNNEL_VXLAN |
+							PKT_TX_OUTER_UDP);
 			} else if (info.l4_proto == IPPROTO_GRE) {
 				struct simple_gre_hdr *gre_hdr;
 
-- 
2.13.3

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

* [dpdk-dev] [PATCH v3 3/7] app/testpmd: add more GRE extension to csum engine
  2018-01-09 14:11 ` [dpdk-dev] [PATCH 1/6] net/mlx5: support tx swp tunnel offloading Xueming Li
                     ` (7 preceding siblings ...)
  2018-03-05 14:51   ` [dpdk-dev] [PATCH v3 2/7] app/testpmd: testpmd support Tx generic tunnel offloads Xueming Li
@ 2018-03-05 14:51   ` Xueming Li
  2018-03-05 14:51   ` [dpdk-dev] [PATCH v3 4/7] app/testpmd: introduce VXLAN GPE to csum forwarding engine Xueming Li
                     ` (8 subsequent siblings)
  17 siblings, 0 replies; 80+ messages in thread
From: Xueming Li @ 2018-03-05 14:51 UTC (permalink / raw)
  To: Wenzhuo Lu, Jingjing Wu, Thomas Monjalon, Yongseok Koh,
	Olivier MATZ, Shahaf Shuler
  Cc: Xueming Li, Ferruh Yigit, dev

This patch adds GRE checksum and sequence extension supports in addtion
to key extension to csum forwarding engine.

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
---
 app/test-pmd/csumonly.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index 7b2309372..00ec40d58 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -49,9 +49,12 @@
 #define IP_HDRLEN  0x05 /* default IP header length == five 32-bits words. */
 #define IP_VHL_DEF (IP_VERSION | IP_HDRLEN)
 
-#define GRE_KEY_PRESENT 0x2000
-#define GRE_KEY_LEN     4
-#define GRE_SUPPORTED_FIELDS GRE_KEY_PRESENT
+#define GRE_CHECKSUM_PRESENT	0x8000
+#define GRE_KEY_PRESENT		0x2000
+#define GRE_SEQUENCE_PRESENT	0x1000
+#define GRE_EXT_LEN		4
+#define GRE_SUPPORTED_FIELDS	(GRE_CHECKSUM_PRESENT | GRE_KEY_PRESENT |\
+				 GRE_SEQUENCE_PRESENT)
 
 /* We cannot use rte_cpu_to_be_16() on a constant in a switch/case */
 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
@@ -203,14 +206,14 @@ parse_gre(struct simple_gre_hdr *gre_hdr, struct testpmd_offload_info *info)
 	struct ipv6_hdr *ipv6_hdr;
 	uint8_t gre_len = 0;
 
-	/* check which fields are supported */
-	if ((gre_hdr->flags & _htons(~GRE_SUPPORTED_FIELDS)) != 0)
-		return;
-
 	gre_len += sizeof(struct simple_gre_hdr);
 
 	if (gre_hdr->flags & _htons(GRE_KEY_PRESENT))
-		gre_len += GRE_KEY_LEN;
+		gre_len += GRE_EXT_LEN;
+	if (gre_hdr->flags & _htons(GRE_SEQUENCE_PRESENT))
+		gre_len += GRE_EXT_LEN;
+	if (gre_hdr->flags & _htons(GRE_CHECKSUM_PRESENT))
+		gre_len += GRE_EXT_LEN;
 
 	if (gre_hdr->proto == _htons(ETHER_TYPE_IPv4)) {
 		info->is_tunnel = 1;
@@ -739,6 +742,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 
 		/* step 3: fill the mbuf meta data (flags and header lengths) */
 
+		m->tx_offload = 0;
 		if (info.is_tunnel == 1) {
 			if (info.tunnel_tso_segsz ||
 			    (tx_offloads &
-- 
2.13.3

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

* [dpdk-dev] [PATCH v3 4/7] app/testpmd: introduce VXLAN GPE to csum forwarding engine
  2018-01-09 14:11 ` [dpdk-dev] [PATCH 1/6] net/mlx5: support tx swp tunnel offloading Xueming Li
                     ` (8 preceding siblings ...)
  2018-03-05 14:51   ` [dpdk-dev] [PATCH v3 3/7] app/testpmd: add more GRE extension to csum engine Xueming Li
@ 2018-03-05 14:51   ` Xueming Li
  2018-03-05 14:51   ` [dpdk-dev] [PATCH v3 5/7] net/mlx5: separate TSO function in Tx data path Xueming Li
                     ` (7 subsequent siblings)
  17 siblings, 0 replies; 80+ messages in thread
From: Xueming Li @ 2018-03-05 14:51 UTC (permalink / raw)
  To: Wenzhuo Lu, Jingjing Wu, Thomas Monjalon, Yongseok Koh,
	Olivier MATZ, Shahaf Shuler
  Cc: Xueming Li, Ferruh Yigit, dev

This patch introduced VXLAN-GPE support to csum forwarding engine by
recognizing VXLAN-GPE UDP port and parsing tunnel payload according to
next-protocol type.

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
---
 app/test-pmd/csumonly.c               | 96 +++++++++++++++++++++++++++++++++--
 app/test-pmd/parameters.c             | 12 ++++-
 app/test-pmd/testpmd.h                |  2 +
 doc/guides/testpmd_app_ug/run_app.rst |  5 ++
 4 files changed, 111 insertions(+), 4 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index 00ec40d58..526d28e74 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -56,6 +56,10 @@
 #define GRE_SUPPORTED_FIELDS	(GRE_CHECKSUM_PRESENT | GRE_KEY_PRESENT |\
 				 GRE_SEQUENCE_PRESENT)
 
+#define VXLAN_GPE_TYPE_IPv4 1
+#define VXLAN_GPE_TYPE_IPv6 2
+#define VXLAN_GPE_TYPE_ETH 3
+
 /* We cannot use rte_cpu_to_be_16() on a constant in a switch/case */
 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
 #define _htons(x) ((uint16_t)((((x) & 0x00ffU) << 8) | (((x) & 0xff00U) >> 8)))
@@ -63,6 +67,8 @@
 #define _htons(x) (x)
 #endif
 
+uint16_t vxlan_gpe_udp_port = 4790;
+
 /* structure that caches offload info for the current packet */
 struct testpmd_offload_info {
 	uint16_t ethertype;
@@ -87,6 +93,14 @@ struct simple_gre_hdr {
 	uint16_t proto;
 } __attribute__((__packed__));
 
+/* simplified VXLAN-GPE header */
+struct vxlan_gpe_hdr {
+	uint8_t vx_flags; /**< flag (8). */
+	uint8_t reserved[2]; /**< Reserved (16). */
+	uint8_t proto; /**< next-protocol (8). */
+	uint32_t vx_vni;   /**< VNI (24) + Reserved (8). */
+} __attribute__((__packed__));
+
 static uint16_t
 get_udptcp_checksum(void *l3_hdr, void *l4_hdr, uint16_t ethertype)
 {
@@ -197,6 +211,70 @@ parse_vxlan(struct udp_hdr *udp_hdr,
 	info->l2_len += ETHER_VXLAN_HLEN; /* add udp + vxlan */
 }
 
+/* Parse a vxlan-gpe header */
+static void
+parse_vxlan_gpe(struct udp_hdr *udp_hdr,
+	    struct testpmd_offload_info *info)
+{
+	struct ether_hdr *eth_hdr;
+	struct ipv4_hdr *ipv4_hdr;
+	struct ipv6_hdr *ipv6_hdr;
+	struct vxlan_gpe_hdr *vxlan_gpe_hdr;
+	uint8_t vxlan_gpe_len = sizeof(*vxlan_gpe_hdr);
+
+	/* check udp destination port, 4790 is the default vxlan-gpe port */
+	if (udp_hdr->dst_port != _htons(vxlan_gpe_udp_port))
+		return;
+
+	vxlan_gpe_hdr = (struct vxlan_gpe_hdr *)((char *)udp_hdr +
+				sizeof(struct udp_hdr));
+
+	if (!vxlan_gpe_hdr->proto || vxlan_gpe_hdr->proto ==
+	    VXLAN_GPE_TYPE_IPv4) {
+		info->is_tunnel = 1;
+		info->outer_ethertype = info->ethertype;
+		info->outer_l2_len = info->l2_len;
+		info->outer_l3_len = info->l3_len;
+		info->outer_l4_proto = info->l4_proto;
+
+		ipv4_hdr = (struct ipv4_hdr *)((char *)vxlan_gpe_hdr +
+			   vxlan_gpe_len);
+
+		parse_ipv4(ipv4_hdr, info);
+		info->ethertype = _htons(ETHER_TYPE_IPv4);
+		info->l2_len = 0;
+
+	} else if (vxlan_gpe_hdr->proto == VXLAN_GPE_TYPE_IPv6) {
+		info->is_tunnel = 1;
+		info->outer_ethertype = info->ethertype;
+		info->outer_l2_len = info->l2_len;
+		info->outer_l3_len = info->l3_len;
+		info->outer_l4_proto = info->l4_proto;
+
+		ipv6_hdr = (struct ipv6_hdr *)((char *)vxlan_gpe_hdr +
+			   vxlan_gpe_len);
+
+		info->ethertype = _htons(ETHER_TYPE_IPv6);
+		parse_ipv6(ipv6_hdr, info);
+		info->l2_len = 0;
+
+	} else if (vxlan_gpe_hdr->proto == VXLAN_GPE_TYPE_ETH) {
+		info->is_tunnel = 1;
+		info->outer_ethertype = info->ethertype;
+		info->outer_l2_len = info->l2_len;
+		info->outer_l3_len = info->l3_len;
+		info->outer_l4_proto = info->l4_proto;
+
+		eth_hdr = (struct ether_hdr *)((char *)vxlan_gpe_hdr +
+			  vxlan_gpe_len);
+
+		parse_ethernet(eth_hdr, info);
+	} else
+		return;
+
+	info->l2_len += ETHER_VXLAN_HLEN;
+}
+
 /* Parse a gre header */
 static void
 parse_gre(struct simple_gre_hdr *gre_hdr, struct testpmd_offload_info *info)
@@ -591,6 +669,10 @@ pkt_copy_split(const struct rte_mbuf *pkt)
  *   Ether / (vlan) / IP|IP6 / UDP|TCP|SCTP .
  *   Ether / (vlan) / outer IP|IP6 / outer UDP / VxLAN / Ether / IP|IP6 /
  *           UDP|TCP|SCTP
+ *   Ether / (vlan) / outer IP|IP6 / outer UDP / VXLAN-GPE / Ether / IP|IP6 /
+ *           UDP|TCP|SCTP
+ *   Ether / (vlan) / outer IP|IP6 / outer UDP / VXLAN-GPE / IP|IP6 /
+ *           UDP|TCP|SCTP
  *   Ether / (vlan) / outer IP|IP6 / GRE / Ether / IP|IP6 / UDP|TCP|SCTP
  *   Ether / (vlan) / outer IP|IP6 / GRE / IP|IP6 / UDP|TCP|SCTP
  *   Ether / (vlan) / outer IP|IP6 / IP|IP6 / UDP|TCP|SCTP
@@ -694,10 +776,18 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 
 				udp_hdr = (struct udp_hdr *)((char *)l3_hdr +
 					info.l3_len);
-				parse_vxlan(udp_hdr, &info, m->packet_type);
-				if (info.is_tunnel)
-					tx_ol_flags |= (PKT_TX_TUNNEL_VXLAN |
+				parse_vxlan_gpe(udp_hdr, &info);
+				if (info.is_tunnel) {
+					tx_ol_flags |= (PKT_TX_TUNNEL_UNKNOWN |
 							PKT_TX_OUTER_UDP);
+				} else {
+					parse_vxlan(udp_hdr, &info,
+						    m->packet_type);
+					if (info.is_tunnel)
+						tx_ol_flags |=
+							(PKT_TX_TUNNEL_VXLAN |
+							 PKT_TX_OUTER_UDP);
+				}
 			} else if (info.l4_proto == IPPROTO_GRE) {
 				struct simple_gre_hdr *gre_hdr;
 
diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
index 97d22b860..d7489bcec 100644
--- a/app/test-pmd/parameters.c
+++ b/app/test-pmd/parameters.c
@@ -70,7 +70,7 @@ usage(char* progname)
 	       "--rss-ip | --rss-udp | "
 	       "--rxpt= | --rxht= | --rxwt= | --rxfreet= | "
 	       "--txpt= | --txht= | --txwt= | --txfreet= | "
-	       "--txrst= | --tx-offloads ]\n",
+	       "--txrst= | --tx-offloads= | --vxlan-gpe-port= ]\n",
 	       progname);
 #ifdef RTE_LIBRTE_CMDLINE
 	printf("  --interactive: run in interactive mode.\n");
@@ -186,6 +186,7 @@ usage(char* progname)
 	printf("  --flow-isolate-all: "
 	       "requests flow API isolated mode on all ports at initialization time.\n");
 	printf("  --tx-offloads=0xXXXXXXXX: hexadecimal bitmask of TX queue offloads\n");
+	printf("  --vxlan-gpe-port=N: UPD port of tunnel VXLAN-GPE\n");
 }
 
 #ifdef RTE_LIBRTE_CMDLINE
@@ -621,6 +622,7 @@ launch_args_parse(int argc, char** argv)
 		{ "print-event",		1, 0, 0 },
 		{ "mask-event",			1, 0, 0 },
 		{ "tx-offloads",		1, 0, 0 },
+		{ "vxlan-gpe-port",		1, 0, 0 },
 		{ 0, 0, 0, 0 },
 	};
 
@@ -1092,6 +1094,14 @@ launch_args_parse(int argc, char** argv)
 					rte_exit(EXIT_FAILURE,
 						 "tx-offloads must be >= 0\n");
 			}
+			if (!strcmp(lgopts[opt_idx].name, "vxlan-gpe-port")) {
+				n = atoi(optarg);
+				if (n >= 0)
+					vxlan_gpe_udp_port = (uint16_t)n;
+				else
+					rte_exit(EXIT_FAILURE,
+						 "vxlan-gpe-port must be >= 0\n");
+			}
 			if (!strcmp(lgopts[opt_idx].name, "print-event"))
 				if (parse_event_printing_config(optarg, 1)) {
 					rte_exit(EXIT_FAILURE,
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 153abea05..4cec239fe 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -433,6 +433,8 @@ extern uint32_t retry_enabled;
 extern struct fwd_lcore  **fwd_lcores;
 extern struct fwd_stream **fwd_streams;
 
+extern uint16_t vxlan_gpe_udp_port; /**< UDP port of tunnel VXLAN-GPE. */
+
 extern portid_t nb_peer_eth_addrs; /**< Number of peer ethernet addresses. */
 extern struct ether_addr peer_eth_addrs[RTE_MAX_ETHPORTS];
 
diff --git a/doc/guides/testpmd_app_ug/run_app.rst b/doc/guides/testpmd_app_ug/run_app.rst
index 1fd53958a..2e8690f41 100644
--- a/doc/guides/testpmd_app_ug/run_app.rst
+++ b/doc/guides/testpmd_app_ug/run_app.rst
@@ -479,3 +479,8 @@ The commandline options are:
 
     Set the hexadecimal bitmask of TX queue offloads.
     The default value is 0.
+
+*   ``--vxlan-gpe-port=N``
+
+    Set the UDP port number of tunnel VXLAN-GPE to N.
+    The default value is 4790.
-- 
2.13.3

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

* [dpdk-dev] [PATCH v3 5/7] net/mlx5: separate TSO function in Tx data path
  2018-01-09 14:11 ` [dpdk-dev] [PATCH 1/6] net/mlx5: support tx swp tunnel offloading Xueming Li
                     ` (9 preceding siblings ...)
  2018-03-05 14:51   ` [dpdk-dev] [PATCH v3 4/7] app/testpmd: introduce VXLAN GPE to csum forwarding engine Xueming Li
@ 2018-03-05 14:51   ` Xueming Li
  2018-03-05 14:51   ` [dpdk-dev] [PATCH v3 6/7] net/mlx5: support generic tunnel offloading Xueming Li
                     ` (6 subsequent siblings)
  17 siblings, 0 replies; 80+ messages in thread
From: Xueming Li @ 2018-03-05 14:51 UTC (permalink / raw)
  To: Wenzhuo Lu, Jingjing Wu, Thomas Monjalon, Yongseok Koh,
	Olivier MATZ, Shahaf Shuler
  Cc: Xueming Li, Ferruh Yigit, dev

Separate TSO function to make logic of mlx5_tx_burst clear.

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
---
 drivers/net/mlx5/mlx5_rxtx.c | 112 ++++++++++++++++++++++++++-----------------
 1 file changed, 67 insertions(+), 45 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c
index 049f7e6c1..6d273841b 100644
--- a/drivers/net/mlx5/mlx5_rxtx.c
+++ b/drivers/net/mlx5/mlx5_rxtx.c
@@ -219,6 +219,66 @@ mlx5_copy_to_wq(void *dst, const void *src, size_t n,
 }
 
 /**
+ * Inline TSO headers into WQE.
+ *
+ * @return
+ *   0 on success, negative errno value on failure.
+ */
+static int
+inline_tso(struct mlx5_txq_data *txq, struct rte_mbuf *buf,
+	   uint32_t *length,
+	   uint8_t *cs_flags,
+	   uintptr_t *addr,
+	   uint16_t *pkt_inline_sz,
+	   uint8_t **raw,
+	   uint16_t *max_wqe,
+	   uint16_t *tso_segsz,
+	   uint16_t *tso_header_sz)
+{
+	uintptr_t end = (uintptr_t)(((uintptr_t)txq->wqes) +
+				    (1 << txq->wqe_n) * MLX5_WQE_SIZE);
+	unsigned int copy_b;
+	uint8_t vlan_sz = (buf->ol_flags & PKT_TX_VLAN_PKT) ? 4 : 0;
+	const uint8_t tunneled = txq->tunnel_en &&
+				 (buf->ol_flags & (PKT_TX_TUNNEL_GRE |
+						   PKT_TX_TUNNEL_VXLAN));
+	uint16_t n_wqe;
+
+	*tso_segsz = buf->tso_segsz;
+	*tso_header_sz = buf->l2_len + vlan_sz + buf->l3_len + buf->l4_len;
+	if (unlikely(*tso_segsz == 0 || *tso_header_sz == 0)) {
+		txq->stats.oerrors++;
+		return -EINVAL;
+	}
+	if (tunneled) {
+		*tso_header_sz += buf->outer_l2_len + buf->outer_l3_len;
+		*cs_flags |= MLX5_ETH_WQE_L4_INNER_CSUM;
+	} else {
+		*cs_flags |= MLX5_ETH_WQE_L4_CSUM;
+	}
+	if (unlikely(*tso_header_sz > MLX5_MAX_TSO_HEADER)) {
+		txq->stats.oerrors++;
+		return -EINVAL;
+	}
+	copy_b = *tso_header_sz - *pkt_inline_sz;
+	/* First seg must contain all TSO headers. */
+	assert(copy_b <= *length);
+	if (!copy_b || ((end - (uintptr_t)*raw) < copy_b))
+		return -EAGAIN;
+	n_wqe = (MLX5_WQE_DS(copy_b) - 1 + 3) / 4;
+	if (unlikely(*max_wqe < n_wqe))
+		return -EINVAL;
+	*max_wqe -= n_wqe;
+	rte_memcpy((void *)*raw, (void *)*addr, copy_b);
+	*length -= copy_b;
+	*addr += copy_b;
+	copy_b = MLX5_WQE_DS(copy_b) * MLX5_WQE_DWORD_SIZE;
+	*pkt_inline_sz += copy_b;
+	*raw += copy_b;
+	return 0;
+}
+
+/**
  * DPDK callback to check the status of a tx descriptor.
  *
  * @param tx_queue
@@ -352,6 +412,7 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
 #ifdef MLX5_PMD_SOFT_COUNTERS
 		uint32_t total_length = 0;
 #endif
+		int ret;
 
 		/* first_seg */
 		buf = *pkts;
@@ -417,52 +478,13 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
 		raw += MLX5_WQE_DWORD_SIZE;
 		tso = txq->tso_en && (buf->ol_flags & PKT_TX_TCP_SEG);
 		if (tso) {
-			uintptr_t end =
-				(uintptr_t)(((uintptr_t)txq->wqes) +
-					    (1 << txq->wqe_n) * MLX5_WQE_SIZE);
-			unsigned int copy_b;
-			uint8_t vlan_sz =
-				(buf->ol_flags & PKT_TX_VLAN_PKT) ? 4 : 0;
-			const uint64_t is_tunneled =
-				buf->ol_flags & (PKT_TX_TUNNEL_GRE |
-						 PKT_TX_TUNNEL_VXLAN);
-
-			tso_header_sz = buf->l2_len + vlan_sz +
-					buf->l3_len + buf->l4_len;
-			tso_segsz = buf->tso_segsz;
-			if (unlikely(tso_segsz == 0)) {
-				txq->stats.oerrors++;
+			ret = inline_tso(txq, buf, &length, &cs_flags,
+					 &addr, &pkt_inline_sz,
+					 &raw, &max_wqe,
+					 &tso_segsz, &tso_header_sz);
+			if (ret == -EINVAL) {
 				break;
-			}
-			if (is_tunneled	&& txq->tunnel_en) {
-				tso_header_sz += buf->outer_l2_len +
-						 buf->outer_l3_len;
-				cs_flags |= MLX5_ETH_WQE_L4_INNER_CSUM;
-			} else {
-				cs_flags |= MLX5_ETH_WQE_L4_CSUM;
-			}
-			if (unlikely(tso_header_sz > MLX5_MAX_TSO_HEADER)) {
-				txq->stats.oerrors++;
-				break;
-			}
-			copy_b = tso_header_sz - pkt_inline_sz;
-			/* First seg must contain all headers. */
-			assert(copy_b <= length);
-			if (copy_b && ((end - (uintptr_t)raw) > copy_b)) {
-				uint16_t n = (MLX5_WQE_DS(copy_b) - 1 + 3) / 4;
-
-				if (unlikely(max_wqe < n))
-					break;
-				max_wqe -= n;
-				rte_memcpy((void *)raw, (void *)addr, copy_b);
-				addr += copy_b;
-				length -= copy_b;
-				/* Include padding for TSO header. */
-				copy_b = MLX5_WQE_DS(copy_b) *
-					 MLX5_WQE_DWORD_SIZE;
-				pkt_inline_sz += copy_b;
-				raw += copy_b;
-			} else {
+			} else if (ret == -EAGAIN) {
 				/* NOP WQE. */
 				wqe->ctrl = (rte_v128u32_t){
 					rte_cpu_to_be_32(txq->wqe_ci << 8),
-- 
2.13.3

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

* [dpdk-dev] [PATCH v3 6/7] net/mlx5: support generic tunnel offloading
  2018-01-09 14:11 ` [dpdk-dev] [PATCH 1/6] net/mlx5: support tx swp tunnel offloading Xueming Li
                     ` (10 preceding siblings ...)
  2018-03-05 14:51   ` [dpdk-dev] [PATCH v3 5/7] net/mlx5: separate TSO function in Tx data path Xueming Li
@ 2018-03-05 14:51   ` Xueming Li
  2018-03-05 14:51   ` [dpdk-dev] [PATCH v3 7/7] net/mlx5: allow max 192B TSO inline header length Xueming Li
                     ` (5 subsequent siblings)
  17 siblings, 0 replies; 80+ messages in thread
From: Xueming Li @ 2018-03-05 14:51 UTC (permalink / raw)
  To: Wenzhuo Lu, Jingjing Wu, Thomas Monjalon, Yongseok Koh,
	Olivier MATZ, Shahaf Shuler
  Cc: Xueming Li, Ferruh Yigit, dev

This commit adds support for generic tunnel TSO and checksum offload.
PMD will compute the inner/outer headers offset according to the
mbuf fields. Hardware will do calculation based on offsets and types.

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
---
 doc/guides/nics/mlx5.rst              |   8 +++
 drivers/net/mlx5/Makefile             |   5 ++
 drivers/net/mlx5/mlx5.c               |  28 ++++++--
 drivers/net/mlx5/mlx5.h               |   1 +
 drivers/net/mlx5/mlx5_ethdev.c        |   4 +-
 drivers/net/mlx5/mlx5_prm.h           |  24 +++++++
 drivers/net/mlx5/mlx5_rxtx.c          | 122 ++++++++++++++++++++++++++--------
 drivers/net/mlx5/mlx5_rxtx.h          |  98 +++++++++++++++++++++------
 drivers/net/mlx5/mlx5_rxtx_vec.c      |   9 +--
 drivers/net/mlx5/mlx5_rxtx_vec_neon.h |   2 +-
 drivers/net/mlx5/mlx5_rxtx_vec_sse.h  |   2 +-
 drivers/net/mlx5/mlx5_txq.c           |  12 +++-
 12 files changed, 251 insertions(+), 64 deletions(-)

diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst
index 0e6e525c9..c47a7b2a9 100644
--- a/doc/guides/nics/mlx5.rst
+++ b/doc/guides/nics/mlx5.rst
@@ -334,6 +334,14 @@ Run-time configuration
 
   Enabled by default.
 
+- ``swp`` parameter [int]
+
+  A nonzero value enables TX SW parser to support genenric tunnel TSO and
+  checksum offloading. Please refer to ``DEV_TX_OFFLOAD_GENERIC_TNL_TSO``
+  and ``DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM`` for detail information.
+
+  Disabled by default.
+
 Prerequisites
 -------------
 
diff --git a/drivers/net/mlx5/Makefile b/drivers/net/mlx5/Makefile
index afda4118f..c61fc3b0e 100644
--- a/drivers/net/mlx5/Makefile
+++ b/drivers/net/mlx5/Makefile
@@ -135,6 +135,11 @@ mlx5_autoconf.h.new: $(RTE_SDK)/buildtools/auto-config-h.sh
 		enum IBV_WQ_FLAG_RX_END_PADDING \
 		$(AUTOCONF_OUTPUT)
 	$Q sh -- '$<' '$@' \
+		HAVE_IBV_MLX5_MOD_SWP \
+		infiniband/mlx5dv.h \
+		enum MLX5DV_CONTEXT_MASK_SWP \
+		$(AUTOCONF_OUTPUT)
+	$Q sh -- '$<' '$@' \
 		HAVE_IBV_MLX5_MOD_MPW \
 		infiniband/mlx5dv.h \
 		enum MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED \
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 61cb93101..d7f699b94 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -68,6 +68,9 @@
 /* Device parameter to enable hardware Rx vector. */
 #define MLX5_RX_VEC_EN "rx_vec_en"
 
+/* Device parameter to control Tx SW parser. */
+#define MLX5_TX_SWP "swp"
+
 #ifndef HAVE_IBV_MLX5_MOD_MPW
 #define MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED (1 << 2)
 #define MLX5DV_CONTEXT_FLAGS_ENHANCED_MPW (1 << 3)
@@ -397,6 +400,8 @@ mlx5_args_check(const char *key, const char *val, void *opaque)
 		config->tx_vec_en = !!tmp;
 	} else if (strcmp(MLX5_RX_VEC_EN, key) == 0) {
 		config->rx_vec_en = !!tmp;
+	} else if (strcmp(MLX5_TX_SWP, key) == 0) {
+		config->swp = !!tmp;
 	} else {
 		WARN("%s: unknown parameter", key);
 		return -EINVAL;
@@ -427,6 +432,7 @@ mlx5_args(struct mlx5_dev_config *config, struct rte_devargs *devargs)
 		MLX5_TXQ_MAX_INLINE_LEN,
 		MLX5_TX_VEC_EN,
 		MLX5_RX_VEC_EN,
+		MLX5_TX_SWP,
 		NULL,
 	};
 	struct rte_kvargs *kvlist;
@@ -582,6 +588,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
 	unsigned int mps;
 	unsigned int cqe_comp;
 	unsigned int tunnel_en = 0;
+	unsigned int swp = 0;
 	int idx;
 	int i;
 	struct mlx5dv_context attrs_out = {0};
@@ -657,10 +664,9 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
 	ibv_dev = list[i];
 
 	DEBUG("device opened");
-	/*
-	 * Multi-packet send is supported by ConnectX-4 Lx PF as well
-	 * as all ConnectX-5 devices.
-	 */
+#ifdef HAVE_IBV_MLX5_MOD_SWP
+	attrs_out.comp_mask |= MLX5DV_CONTEXT_MASK_SWP;
+#endif
 #ifdef HAVE_IBV_DEVICE_TUNNEL_SUPPORT
 	attrs_out.comp_mask |= MLX5DV_CONTEXT_MASK_TUNNEL_OFFLOADS;
 #endif
@@ -677,6 +683,11 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
 		DEBUG("MPW isn't supported");
 		mps = MLX5_MPW_DISABLED;
 	}
+#ifdef HAVE_IBV_MLX5_MOD_SWP
+	if (attrs_out.comp_mask | MLX5DV_CONTEXT_MASK_SWP)
+		swp = attrs_out.sw_parsing_caps.sw_parsing_offloads;
+	DEBUG("SWP support: %u", swp);
+#endif
 	if (RTE_CACHE_LINE_SIZE == 128 &&
 	    !(attrs_out.flags & MLX5DV_CONTEXT_FLAGS_CQE_128B_COMP))
 		cqe_comp = 0;
@@ -894,6 +905,11 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
 		err = priv_uar_init_primary(priv);
 		if (err)
 			goto port_error;
+		if (config.swp && !swp) {
+			WARN("Tx SWP isn't supported");
+			config.swp = 0;
+		}
+		INFO("SWP is %s", config.swp ? "enabled" : "disabled");
 		/* Configure the first MAC address by default. */
 		if (priv_get_mac(priv, &mac.addr_bytes)) {
 			ERROR("cannot get MAC address, is mlx5_en loaded?"
@@ -1129,8 +1145,10 @@ RTE_INIT(rte_mlx5_pmd_init);
 static void
 rte_mlx5_pmd_init(void)
 {
-	/* Build the static table for ptype conversion. */
+	/* Build the static tables for verbs conversion. */
 	mlx5_set_ptype_table();
+	mlx5_set_cksum_table();
+	mlx5_set_swp_types_table();
 	/*
 	 * RDMAV_HUGEPAGES_SAFE tells ibv_fork_init() we intend to use
 	 * huge pages. Calling ibv_fork_init() during init allows
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 9ad0533fc..bcef4a79f 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -88,6 +88,7 @@ struct mlx5_dev_config {
 	unsigned int tx_vec_en:1; /* Tx vector is enabled. */
 	unsigned int rx_vec_en:1; /* Rx vector is enabled. */
 	unsigned int mpw_hdr_dseg:1; /* Enable DSEGs in the title WQEBB. */
+	unsigned int swp:1; /* Tx generic tunnel checksum and TSO offload. */
 	unsigned int tso_max_payload_sz; /* Maximum TCP payload for TSO. */
 	unsigned int ind_table_max_size; /* Maximum indirection table size. */
 	int txq_inline; /* Maximum packet size for inlining. */
diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index b73cb53df..1ee92d211 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -1269,11 +1269,13 @@ priv_select_tx_function(struct priv *priv, struct rte_eth_dev *dev)
 	int tso = !!(tx_offloads & (DEV_TX_OFFLOAD_TCP_TSO |
 				    DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
 				    DEV_TX_OFFLOAD_GRE_TNL_TSO));
+	int swp = !!(tx_offloads & (DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM |
+				    DEV_TX_OFFLOAD_GENERIC_TNL_TSO));
 	int vlan_insert = !!(tx_offloads & DEV_TX_OFFLOAD_VLAN_INSERT);
 
 	assert(priv != NULL);
 	/* Select appropriate TX function. */
-	if (vlan_insert || tso)
+	if (vlan_insert || tso || swp)
 		return tx_pkt_burst;
 	if (config->mps == MLX5_MPW_ENHANCED) {
 		if (priv_check_vec_tx_support(priv, dev) > 0) {
diff --git a/drivers/net/mlx5/mlx5_prm.h b/drivers/net/mlx5/mlx5_prm.h
index 9eb9c15e1..2129d74a3 100644
--- a/drivers/net/mlx5/mlx5_prm.h
+++ b/drivers/net/mlx5/mlx5_prm.h
@@ -107,6 +107,30 @@
 /* Inner L4 checksum offload (Tunneled packets only). */
 #define MLX5_ETH_WQE_L4_INNER_CSUM (1u << 5)
 
+/* Outer L4 type is TCP. */
+#define MLX5_ETH_WQE_L4_OUTER_TCP  (0u << 5)
+
+/* Outer L4 type is UDP. */
+#define MLX5_ETH_WQE_L4_OUTER_UDP  (1u << 5)
+
+/* Outer L3 type is IPV4. */
+#define MLX5_ETH_WQE_L3_OUTER_IPV4 (0u << 4)
+
+/* Outer L3 type is IPV6. */
+#define MLX5_ETH_WQE_L3_OUTER_IPV6 (1u << 4)
+
+/* Inner L4 type is TCP. */
+#define MLX5_ETH_WQE_L4_INNER_TCP (0u << 1)
+
+/* Inner L4 type is UDP. */
+#define MLX5_ETH_WQE_L4_INNER_UDP (1u << 1)
+
+/* Inner L3 type is IPV4. */
+#define MLX5_ETH_WQE_L3_INNER_IPV4 (0u << 0)
+
+/* Inner L3 type is IPV6. */
+#define MLX5_ETH_WQE_L3_INNER_IPV6 (1u << 0)
+
 /* Is flow mark valid. */
 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
 #define MLX5_FLOW_MARK_IS_VALID(val) ((val) & 0xffffff00)
diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c
index 6d273841b..53d5a06fb 100644
--- a/drivers/net/mlx5/mlx5_rxtx.c
+++ b/drivers/net/mlx5/mlx5_rxtx.c
@@ -47,6 +47,9 @@ uint32_t mlx5_ptype_table[] __rte_cache_aligned = {
 	[0xff] = RTE_PTYPE_ALL_MASK, /* Last entry for errored packet. */
 };
 
+uint8_t mlx5_cksum_table[1 << 10] __rte_cache_aligned;
+uint8_t mlx5_swp_types_table[1 << 10] __rte_cache_aligned;
+
 /**
  * Build a table to translate Rx completion flags to packet type.
  *
@@ -163,6 +166,74 @@ mlx5_set_ptype_table(void)
 }
 
 /**
+ * Build a table to translate packet to checksum type of Verbs.
+ */
+void
+mlx5_set_cksum_table(void)
+{
+	unsigned int i;
+	uint8_t v;
+
+	/*
+	 * The index should have:
+	 * bit[0] = PKT_TX_TCP_SEG
+	 * bit[2:3] = PKT_TX_UDP_CKSUM, PKT_TX_TCP_CKSUM
+	 * bit[4] = PKT_TX_IP_CKSUM
+	 * bit[8] = PKT_TX_OUTER_IP_CKSUM
+	 * bit[9] = tunnel
+	 */
+	for (i = 0; i < RTE_DIM(mlx5_cksum_table); ++i) {
+		v = 0;
+		if (i & (1 << 9)) {
+			/* Tunneled packet. */
+			if (i & (1 << 8)) /* Outer IP. */
+				v |= MLX5_ETH_WQE_L3_CSUM;
+			if (i & (1 << 4)) /* Inner IP. */
+				v |= MLX5_ETH_WQE_L3_INNER_CSUM;
+			if (i & (3 << 2 | 1 << 0)) /* L4 or TSO. */
+				v |= MLX5_ETH_WQE_L4_INNER_CSUM;
+		} else {
+			/* No tunnel. */
+			if (i & (1 << 4)) /* IP. */
+				v |= MLX5_ETH_WQE_L3_CSUM;
+			if (i & (3 << 2 | 1 << 0)) /* L4 or TSO. */
+				v |= MLX5_ETH_WQE_L4_CSUM;
+		}
+		mlx5_cksum_table[i] = v;
+	}
+}
+
+/**
+ * Build a table to translate packet type of mbuf to SWP type of Verbs.
+ */
+void
+mlx5_set_swp_types_table(void)
+{
+	unsigned int i;
+	uint8_t v;
+
+	/*
+	 * The index should have:
+	 * bit[0:1] = PKT_TX_L4_MASK
+	 * bit[4] = PKT_TX_IPV6
+	 * bit[8] = PKT_TX_OUTER_IPV6
+	 * bit[9] = PKT_TX_OUTER_UDP
+	 */
+	for (i = 0; i < RTE_DIM(mlx5_swp_types_table); ++i) {
+		v = 0;
+		if (i & (1 << 8))
+			v |= MLX5_ETH_WQE_L3_OUTER_IPV6;
+		if (i & (1 << 9))
+			v |= MLX5_ETH_WQE_L4_OUTER_UDP;
+		if (i & (1 << 4))
+			v |= MLX5_ETH_WQE_L3_INNER_IPV6;
+		if ((i & 3) == (PKT_TX_UDP_CKSUM >> 52))
+			v |= MLX5_ETH_WQE_L4_INNER_UDP;
+		mlx5_swp_types_table[i] = v;
+	}
+}
+
+/**
  * Return the size of tailroom of WQ.
  *
  * @param txq
@@ -227,7 +298,6 @@ mlx5_copy_to_wq(void *dst, const void *src, size_t n,
 static int
 inline_tso(struct mlx5_txq_data *txq, struct rte_mbuf *buf,
 	   uint32_t *length,
-	   uint8_t *cs_flags,
 	   uintptr_t *addr,
 	   uint16_t *pkt_inline_sz,
 	   uint8_t **raw,
@@ -239,9 +309,8 @@ inline_tso(struct mlx5_txq_data *txq, struct rte_mbuf *buf,
 				    (1 << txq->wqe_n) * MLX5_WQE_SIZE);
 	unsigned int copy_b;
 	uint8_t vlan_sz = (buf->ol_flags & PKT_TX_VLAN_PKT) ? 4 : 0;
-	const uint8_t tunneled = txq->tunnel_en &&
-				 (buf->ol_flags & (PKT_TX_TUNNEL_GRE |
-						   PKT_TX_TUNNEL_VXLAN));
+	const uint8_t tunneled = txq->tunnel_en && (buf->ol_flags &
+				 PKT_TX_TUNNEL_MASK);
 	uint16_t n_wqe;
 
 	*tso_segsz = buf->tso_segsz;
@@ -250,19 +319,15 @@ inline_tso(struct mlx5_txq_data *txq, struct rte_mbuf *buf,
 		txq->stats.oerrors++;
 		return -EINVAL;
 	}
-	if (tunneled) {
+	if (tunneled)
 		*tso_header_sz += buf->outer_l2_len + buf->outer_l3_len;
-		*cs_flags |= MLX5_ETH_WQE_L4_INNER_CSUM;
-	} else {
-		*cs_flags |= MLX5_ETH_WQE_L4_CSUM;
-	}
-	if (unlikely(*tso_header_sz > MLX5_MAX_TSO_HEADER)) {
+	/* First seg must contain all TSO headers. */
+	if (unlikely(*tso_header_sz > MLX5_MAX_TSO_HEADER) ||
+		     *tso_header_sz > DATA_LEN(buf)) {
 		txq->stats.oerrors++;
 		return -EINVAL;
 	}
 	copy_b = *tso_header_sz - *pkt_inline_sz;
-	/* First seg must contain all TSO headers. */
-	assert(copy_b <= *length);
 	if (!copy_b || ((end - (uintptr_t)*raw) < copy_b))
 		return -EAGAIN;
 	n_wqe = (MLX5_WQE_DS(copy_b) - 1 + 3) / 4;
@@ -395,7 +460,7 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
 	if (unlikely(!max_wqe))
 		return 0;
 	do {
-		struct rte_mbuf *buf = NULL;
+		struct rte_mbuf *buf = *pkts; /* First_seg. */
 		uint8_t *raw;
 		volatile struct mlx5_wqe_v *wqe = NULL;
 		volatile rte_v128u32_t *dseg = NULL;
@@ -407,15 +472,16 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
 		uint16_t tso_header_sz = 0;
 		uint16_t ehdr;
 		uint8_t cs_flags;
-		uint64_t tso = 0;
+		uint8_t tso = txq->tso_en && (buf->ol_flags & PKT_TX_TCP_SEG);
+		uint8_t is_vlan = !!(buf->ol_flags & PKT_TX_VLAN_PKT);
+		uint32_t swp_offsets = 0;
+		uint8_t swp_types = 0;
 		uint16_t tso_segsz = 0;
 #ifdef MLX5_PMD_SOFT_COUNTERS
 		uint32_t total_length = 0;
 #endif
 		int ret;
 
-		/* first_seg */
-		buf = *pkts;
 		segs_n = buf->nb_segs;
 		/*
 		 * Make sure there is enough room to store this packet and
@@ -450,10 +516,12 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
 		if (pkts_n - i > 1)
 			rte_prefetch0(
 			    rte_pktmbuf_mtod(*(pkts + 1), volatile void *));
-		cs_flags = txq_ol_cksum_to_cs(txq, buf);
+		cs_flags = txq_ol_cksum_to_cs(buf);
+		txq_mbuf_to_swp(txq, buf, tso, is_vlan,
+				(uint8_t *)&swp_offsets, &swp_types);
 		raw = ((uint8_t *)(uintptr_t)wqe) + 2 * MLX5_WQE_DWORD_SIZE;
 		/* Replace the Ethernet type by the VLAN if necessary. */
-		if (buf->ol_flags & PKT_TX_VLAN_PKT) {
+		if (is_vlan) {
 			uint32_t vlan = rte_cpu_to_be_32(0x81000000 |
 							 buf->vlan_tci);
 			unsigned int len = 2 * ETHER_ADDR_LEN - 2;
@@ -476,9 +544,8 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
 			addr += pkt_inline_sz;
 		}
 		raw += MLX5_WQE_DWORD_SIZE;
-		tso = txq->tso_en && (buf->ol_flags & PKT_TX_TCP_SEG);
 		if (tso) {
-			ret = inline_tso(txq, buf, &length, &cs_flags,
+			ret = inline_tso(txq, buf, &length,
 					 &addr, &pkt_inline_sz,
 					 &raw, &max_wqe,
 					 &tso_segsz, &tso_header_sz);
@@ -655,8 +722,9 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
 				0,
 			};
 			wqe->eseg = (rte_v128u32_t){
-				0,
-				cs_flags | (rte_cpu_to_be_16(tso_segsz) << 16),
+				swp_offsets,
+				cs_flags | (swp_types << 8) |
+				(rte_cpu_to_be_16(tso_segsz) << 16),
 				0,
 				(ehdr << 16) | rte_cpu_to_be_16(tso_header_sz),
 			};
@@ -669,8 +737,8 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
 				0,
 			};
 			wqe->eseg = (rte_v128u32_t){
-				0,
-				cs_flags,
+				swp_offsets,
+				cs_flags | (swp_types << 8),
 				0,
 				(ehdr << 16) | rte_cpu_to_be_16(pkt_inline_sz),
 			};
@@ -842,7 +910,7 @@ mlx5_tx_burst_mpw(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
 		}
 		max_elts -= segs_n;
 		--pkts_n;
-		cs_flags = txq_ol_cksum_to_cs(txq, buf);
+		cs_flags = txq_ol_cksum_to_cs(buf);
 		/* Retrieve packet information. */
 		length = PKT_LEN(buf);
 		assert(length);
@@ -1074,7 +1142,7 @@ mlx5_tx_burst_mpw_inline(void *dpdk_txq, struct rte_mbuf **pkts,
 		 * iteration.
 		 */
 		max_wqe = (1u << txq->wqe_n) - (txq->wqe_ci - txq->wqe_pi);
-		cs_flags = txq_ol_cksum_to_cs(txq, buf);
+		cs_flags = txq_ol_cksum_to_cs(buf);
 		/* Retrieve packet information. */
 		length = PKT_LEN(buf);
 		/* Start new session if packet differs. */
@@ -1352,7 +1420,7 @@ txq_burst_empw(struct mlx5_txq_data *txq, struct rte_mbuf **pkts,
 		/* Make sure there is enough room to store this packet. */
 		if (max_elts - j == 0)
 			break;
-		cs_flags = txq_ol_cksum_to_cs(txq, buf);
+		cs_flags = txq_ol_cksum_to_cs(buf);
 		/* Retrieve packet information. */
 		length = PKT_LEN(buf);
 		/* Start new session if:
diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h
index d7e890558..b7cb30e9a 100644
--- a/drivers/net/mlx5/mlx5_rxtx.h
+++ b/drivers/net/mlx5/mlx5_rxtx.h
@@ -167,6 +167,7 @@ struct mlx5_txq_data {
 	uint16_t tso_en:1; /* When set hardware TSO is enabled. */
 	uint16_t tunnel_en:1;
 	/* When set TX offload for tunneled packets are supported. */
+	uint16_t swp_en:1; /* Whether SW parser is enabled. */
 	uint16_t mpw_hdr_dseg:1; /* Enable DSEGs in the title WQEBB. */
 	uint16_t max_inline; /* Multiple of RTE_CACHE_LINE_SIZE to inline. */
 	uint16_t inline_max_packet_sz; /* Max packet size for inlining. */
@@ -273,8 +274,12 @@ uint64_t mlx5_priv_get_tx_port_offloads(struct priv *);
 /* mlx5_rxtx.c */
 
 extern uint32_t mlx5_ptype_table[];
+extern uint8_t mlx5_cksum_table[];
+extern uint8_t mlx5_swp_types_table[];
 
 void mlx5_set_ptype_table(void);
+void mlx5_set_cksum_table(void);
+void mlx5_set_swp_types_table(void);
 uint16_t mlx5_tx_burst(void *, struct rte_mbuf **, uint16_t);
 uint16_t mlx5_tx_burst_mpw(void *, struct rte_mbuf **, uint16_t);
 uint16_t mlx5_tx_burst_mpw_inline(void *, struct rte_mbuf **, uint16_t);
@@ -599,38 +604,87 @@ mlx5_tx_dbrec(struct mlx5_txq_data *txq, volatile struct mlx5_wqe *wqe)
 }
 
 /**
- * Convert the Checksum offloads to Verbs.
+ * Convert mbuf to Verb SWP.
  *
  * @param txq_data
  *   Pointer to the Tx queue.
  * @param buf
  *   Pointer to the mbuf.
+ * @param tso
+ *   TSO offloads enabled.
+ * @param vlan
+ *   VLAN offloads enabled
+ * @param offsets
+ *   Pointer to the SWP header offsets.
+ * @param swp_types
+ *   Pointer to the SWP header types.
+ */
+static __rte_always_inline void
+txq_mbuf_to_swp(struct mlx5_txq_data *txq, struct rte_mbuf *buf,
+		 uint8_t tso, uint64_t vlan,
+		 uint8_t *offsets, uint8_t *swp_types)
+{
+	uint64_t tunnel = buf->ol_flags & PKT_TX_TUNNEL_MASK;
+	uint16_t idx;
+	uint16_t off;
+	const uint64_t ol_flags_mask = PKT_TX_L4_MASK | PKT_TX_IPV6 |
+				       PKT_TX_OUTER_IPV6 | PKT_TX_OUTER_UDP;
+
+	if (likely(!tunnel || !txq->swp_en))
+		return;
+	/*
+	 * The index should have:
+	 * bit[0:1] = PKT_TX_L4_MASK
+	 * bit[4] = PKT_TX_IPV6
+	 * bit[8] = PKT_TX_OUTER_IPV6
+	 * bit[9] = PKT_TX_OUTER_UDP
+	 */
+	idx = (buf->ol_flags & ol_flags_mask) >> 52;
+	*swp_types = mlx5_swp_types_table[idx];
+	/* swp offsets. */
+	off = buf->outer_l2_len + (vlan ? 4 : 0); /* Outer L3 offset. */
+	if (tso || (buf->ol_flags & PKT_TX_OUTER_IP_CKSUM))
+		offsets[1] = off >> 1;
+	off += buf->outer_l3_len; /* Outer L4 offset. */
+	if ((buf->ol_flags & PKT_TX_OUTER_UDP) ||
+	    tunnel == PKT_TX_TUNNEL_VXLAN || tunnel == PKT_TX_TUNNEL_MPLSINUDP)
+		offsets[0] = off >> 1;
+	off += buf->l2_len; /* Inner L3 offset. */
+	if (tso || (buf->ol_flags & PKT_TX_IP_CKSUM))
+		offsets[3] = off >> 1;
+	off += buf->l3_len; /* Inner L4 offset. */
+	if (tso || ((buf->ol_flags & PKT_TX_L4_MASK) == PKT_TX_TCP_CKSUM) ||
+	    ((buf->ol_flags & PKT_TX_L4_MASK) == PKT_TX_UDP_CKSUM))
+		offsets[2] = off >> 1;
+}
+
+/**
+ * Convert the Checksum offloads to Verbs.
+ *
+ * @param buf
+ *   Pointer to the mbuf.
  *
  * @return
- *   the converted cs_flags.
+ *   Converted checksum flags.
  */
 static __rte_always_inline uint8_t
-txq_ol_cksum_to_cs(struct mlx5_txq_data *txq_data, struct rte_mbuf *buf)
+txq_ol_cksum_to_cs(struct rte_mbuf *buf)
 {
-	uint8_t cs_flags = 0;
-
-	/* Should we enable HW CKSUM offload */
-	if (buf->ol_flags &
-	    (PKT_TX_IP_CKSUM | PKT_TX_TCP_CKSUM | PKT_TX_UDP_CKSUM |
-	     PKT_TX_OUTER_IP_CKSUM)) {
-		if (txq_data->tunnel_en &&
-		    (buf->ol_flags &
-		     (PKT_TX_TUNNEL_GRE | PKT_TX_TUNNEL_VXLAN))) {
-			cs_flags = MLX5_ETH_WQE_L3_INNER_CSUM |
-				   MLX5_ETH_WQE_L4_INNER_CSUM;
-			if (buf->ol_flags & PKT_TX_OUTER_IP_CKSUM)
-				cs_flags |= MLX5_ETH_WQE_L3_CSUM;
-		} else {
-			cs_flags = MLX5_ETH_WQE_L3_CSUM |
-				   MLX5_ETH_WQE_L4_CSUM;
-		}
-	}
-	return cs_flags;
+	uint32_t idx;
+	uint8_t is_tunnel = !!(buf->ol_flags & PKT_TX_TUNNEL_MASK);
+	const uint64_t ol_flags_mask = PKT_TX_TCP_SEG | PKT_TX_L4_MASK |
+				       PKT_TX_IP_CKSUM | PKT_TX_OUTER_IP_CKSUM;
+
+	/*
+	 * The index should have:
+	 * bit[0] = PKT_TX_TCP_SEG
+	 * bit[2:3] = PKT_TX_UDP_CKSUM, PKT_TX_TCP_CKSUM
+	 * bit[4] = PKT_TX_IP_CKSUM
+	 * bit[8] = PKT_TX_OUTER_IP_CKSUM
+	 * bit[9] = tunnel
+	 */
+	idx = ((buf->ol_flags & ol_flags_mask) >> 50) | (!!is_tunnel << 9);
+	return mlx5_cksum_table[idx];
 }
 
 /**
diff --git a/drivers/net/mlx5/mlx5_rxtx_vec.c b/drivers/net/mlx5/mlx5_rxtx_vec.c
index b66c2916f..c5204ac47 100644
--- a/drivers/net/mlx5/mlx5_rxtx_vec.c
+++ b/drivers/net/mlx5/mlx5_rxtx_vec.c
@@ -42,8 +42,6 @@
 /**
  * Count the number of packets having same ol_flags and calculate cs_flags.
  *
- * @param txq
- *   Pointer to TX queue structure.
  * @param pkts
  *   Pointer to array of packets.
  * @param pkts_n
@@ -55,8 +53,7 @@
  *   Number of packets having same ol_flags.
  */
 static inline unsigned int
-txq_calc_offload(struct mlx5_txq_data *txq, struct rte_mbuf **pkts,
-		 uint16_t pkts_n, uint8_t *cs_flags)
+txq_calc_offload(struct rte_mbuf **pkts, uint16_t pkts_n, uint8_t *cs_flags)
 {
 	unsigned int pos;
 	const uint64_t ol_mask =
@@ -70,7 +67,7 @@ txq_calc_offload(struct mlx5_txq_data *txq, struct rte_mbuf **pkts,
 	for (pos = 1; pos < pkts_n; ++pos)
 		if ((pkts[pos]->ol_flags ^ pkts[0]->ol_flags) & ol_mask)
 			break;
-	*cs_flags = txq_ol_cksum_to_cs(txq, pkts[0]);
+	*cs_flags = txq_ol_cksum_to_cs(pkts[0]);
 	return pos;
 }
 
@@ -141,7 +138,7 @@ mlx5_tx_burst_vec(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
 		if (txq->offloads & DEV_TX_OFFLOAD_MULTI_SEGS)
 			n = txq_count_contig_single_seg(&pkts[nb_tx], n);
 		if (txq->offloads & MLX5_VEC_TX_CKSUM_OFFLOAD_CAP)
-			n = txq_calc_offload(txq, &pkts[nb_tx], n, &cs_flags);
+			n = txq_calc_offload(&pkts[nb_tx], n, &cs_flags);
 		ret = txq_burst_v(txq, &pkts[nb_tx], n, cs_flags);
 		nb_tx += ret;
 		if (!ret)
diff --git a/drivers/net/mlx5/mlx5_rxtx_vec_neon.h b/drivers/net/mlx5/mlx5_rxtx_vec_neon.h
index bbe1818ef..37ad768e5 100644
--- a/drivers/net/mlx5/mlx5_rxtx_vec_neon.h
+++ b/drivers/net/mlx5/mlx5_rxtx_vec_neon.h
@@ -142,7 +142,7 @@ txq_scatter_v(struct mlx5_txq_data *txq, struct rte_mbuf **pkts,
 			break;
 		wqe = &((volatile struct mlx5_wqe64 *)
 			 txq->wqes)[wqe_ci & wq_mask].hdr;
-		cs_flags = txq_ol_cksum_to_cs(txq, buf);
+		cs_flags = txq_ol_cksum_to_cs(buf);
 		/* Title WQEBB pointer. */
 		t_wqe = (uint8x16_t *)wqe;
 		dseg = (uint8_t *)(wqe + 1);
diff --git a/drivers/net/mlx5/mlx5_rxtx_vec_sse.h b/drivers/net/mlx5/mlx5_rxtx_vec_sse.h
index c088bcb51..d531d2b10 100644
--- a/drivers/net/mlx5/mlx5_rxtx_vec_sse.h
+++ b/drivers/net/mlx5/mlx5_rxtx_vec_sse.h
@@ -144,7 +144,7 @@ txq_scatter_v(struct mlx5_txq_data *txq, struct rte_mbuf **pkts,
 		}
 		wqe = &((volatile struct mlx5_wqe64 *)
 			 txq->wqes)[wqe_ci & wq_mask].hdr;
-		cs_flags = txq_ol_cksum_to_cs(txq, buf);
+		cs_flags = txq_ol_cksum_to_cs(buf);
 		/* Title WQEBB pointer. */
 		t_wqe = (__m128i *)wqe;
 		dseg = (__m128i *)(wqe + 1);
diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c
index ed1c713ea..ac09282ad 100644
--- a/drivers/net/mlx5/mlx5_txq.c
+++ b/drivers/net/mlx5/mlx5_txq.c
@@ -116,6 +116,9 @@ mlx5_priv_get_tx_port_offloads(struct priv *priv)
 		if (config->tso)
 			offloads |= (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
 				     DEV_TX_OFFLOAD_GRE_TNL_TSO);
+		if (config->swp)
+			offloads |= (DEV_TX_OFFLOAD_GENERIC_TNL_TSO |
+				     DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM);
 	}
 	return offloads;
 }
@@ -651,7 +654,11 @@ txq_set_params(struct mlx5_txq_ctrl *txq_ctrl)
 	unsigned int inline_max_packet_sz;
 	eth_tx_burst_t tx_pkt_burst = priv_select_tx_function(priv, priv->dev);
 	int is_empw_func = is_empw_burst_func(tx_pkt_burst);
-	int tso = !!(txq_ctrl->txq.offloads & DEV_TX_OFFLOAD_TCP_TSO);
+	int tso = !!(txq_ctrl->txq.offloads &
+		     (DEV_TX_OFFLOAD_TCP_TSO |
+		      DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
+		      DEV_TX_OFFLOAD_GRE_TNL_TSO |
+		      DEV_TX_OFFLOAD_GENERIC_TNL_TSO));
 
 	txq_inline = (config->txq_inline == MLX5_ARG_UNSET) ?
 		0 : config->txq_inline;
@@ -730,6 +737,9 @@ txq_set_params(struct mlx5_txq_ctrl *txq_ctrl)
 		txq_ctrl->txq.tso_en = 1;
 	}
 	txq_ctrl->txq.tunnel_en = config->tunnel_en;
+	txq_ctrl->txq.swp_en = ((DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM |
+				 DEV_TX_OFFLOAD_GENERIC_TNL_TSO) &
+				txq_ctrl->txq.offloads) && config->swp;
 }
 
 /**
-- 
2.13.3

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

* [dpdk-dev] [PATCH v3 7/7] net/mlx5: allow max 192B TSO inline header length
  2018-01-09 14:11 ` [dpdk-dev] [PATCH 1/6] net/mlx5: support tx swp tunnel offloading Xueming Li
                     ` (11 preceding siblings ...)
  2018-03-05 14:51   ` [dpdk-dev] [PATCH v3 6/7] net/mlx5: support generic tunnel offloading Xueming Li
@ 2018-03-05 14:51   ` Xueming Li
  2018-04-08 12:32   ` [dpdk-dev] [PATCH v4 0/4] support Tx generic tunnel checksum and TSO Xueming Li
                     ` (4 subsequent siblings)
  17 siblings, 0 replies; 80+ messages in thread
From: Xueming Li @ 2018-03-05 14:51 UTC (permalink / raw)
  To: Wenzhuo Lu, Jingjing Wu, Thomas Monjalon, Yongseok Koh,
	Olivier MATZ, Shahaf Shuler
  Cc: Xueming Li, Ferruh Yigit, dev

Change max inline header length to 192B to allow IPv6 VXLAN TSO headers
and header with options that more than 128B.

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
---
 drivers/net/mlx5/mlx5_defs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/mlx5/mlx5_defs.h b/drivers/net/mlx5/mlx5_defs.h
index c3334ca30..1fbd9d3c5 100644
--- a/drivers/net/mlx5/mlx5_defs.h
+++ b/drivers/net/mlx5/mlx5_defs.h
@@ -58,7 +58,7 @@
 #define MLX5_MAX_XSTATS 32
 
 /* Maximum Packet headers size (L2+L3+L4) for TSO. */
-#define MLX5_MAX_TSO_HEADER 128
+#define MLX5_MAX_TSO_HEADER 192
 
 /* Default minimum number of Tx queues for vectorized Tx. */
 #define MLX5_VPMD_MIN_TXQS 4
-- 
2.13.3

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

* Re: [dpdk-dev] [PATCH v3 1/7] ethdev: introduce Tx generic tunnel L3/L4 offload
  2018-03-05 14:51   ` [dpdk-dev] [PATCH v3 1/7] ethdev: introduce Tx generic tunnel L3/L4 offload Xueming Li
@ 2018-03-21  1:40     ` Yongseok Koh
  2018-03-22 13:55       ` Xueming(Steven) Li
  0 siblings, 1 reply; 80+ messages in thread
From: Yongseok Koh @ 2018-03-21  1:40 UTC (permalink / raw)
  To: Xueming Li
  Cc: Wenzhuo Lu, Jingjing Wu, Thomas Monjalon, Olivier MATZ,
	Shahaf Shuler, Ferruh Yigit, dev

On Mon, Mar 05, 2018 at 10:51:15PM +0800, Xueming Li wrote:
> This patch introduce new TX offload flags for device that supports
> tunnel agnostic L3/L4 checksum and TSO offload.
> 
> The support from the device is for inner and outer checksums on
> IPV4/TCP/UDP and TSO for *any packet with the following format*:
> 
> < some headers > / [optional IPv4/IPv6] / [optional TCP/UDP] / <some
> headers> / [optional inner IPv4/IPv6] / [optional TCP/UDP]
> 
> For example the following packets can use this feature:
> 
> 1. eth / ipv4 / udp / VXLAN / ip / tcp
> 2. eth / ipv4 / GRE / MPLS / ipv4 / udp
> 
> Signed-off-by: Xueming Li <xuemingl@mellanox.com>
> ---
>  lib/librte_ether/rte_ethdev.h | 24 ++++++++++++++++++++++++
>  lib/librte_mbuf/rte_mbuf.c    |  5 +++++
>  lib/librte_mbuf/rte_mbuf.h    | 18 ++++++++++++++++--
>  3 files changed, 45 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
> index 036153306..66d12d3e0 100644
> --- a/lib/librte_ether/rte_ethdev.h
> +++ b/lib/librte_ether/rte_ethdev.h
> @@ -980,6 +980,30 @@ struct rte_eth_conf {
>   *   the same mempool and has refcnt = 1.
>   */
>  #define DEV_TX_OFFLOAD_SECURITY         0x00020000
> +/**< Generic tunnel L3/L4 checksum offload. To enable this offload feature
> + * for a packet to be transmitted on hardware supporting generic tunnel L3/L4
> + * checksum offload:
> + *  - fill outer_l2_len and outer_l3_len in mbuf
> + *  - fill l2_len and l3_len in mbuf
> + *  - set the flags PKT_TX_TUNNEL_xxx (use PKT_TX_TUNNEL_UNKNOWN if undefined)
> + *  - set the flags PKT_TX_OUTER_IP_CKSUM
> + *  - set the flags PKT_TX_IP_CKSUM
> + *  - set the flags PKT_TX_TCP_CKSUM, PKT_TX_SCTP_CKSUM or PKT_TX_UDP_CKSUM
> + */
> +#define DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM	0x00040000

It looks redundant to me. Isn't it same as having DEV_TX_OFFLOAD_*_CKSUM?
According to the API document, when PKT_TX_*_CKSUM is set, all the necessary
length fields should be filled in (e.g. mbuf->outer_l?_len and mbuf->l?_len). It
doesn't need to specify any tunnel type for checksum. For example, in order to
request checksum offload for an unknown tunnel type which is similar to VxLAN,
what should app do? Even without defining this new offload flag, it is currently
possible by setting
	(PKT_TX_OUTER_IP_CKSUM | PKT_TX_OUTER_IPV4 | PKT_TX_IP_CKSUM |
	 PKT_TX_IPV4 | PKT_TX_UDP_CKSUM)
along with various length fields.

> +/**< Generic tunnel segmentation offload. To enable it, the user needs to:
> + *  - fill outer_l2_len and outer_l3_len in mbuf
> + *  - fill l2_len and l3_len in mbuf
> + *  - set the flags PKT_TX_TUNNEL_xxx (use PKT_TX_TUNNEL_UNKNOWN if undefined)
> + *  - set the flags PKT_TX_OUTER_IPV4 or PKT_TX_OUTER_IPV6
> + *  - if it's UDP tunnel, set the flags PKT_TX_OUTER_UDP
> + *  - set the flags PKT_TX_IPV4 or PKT_TX_IPV6
> + *  - set the PKT_TX_TCP_SEG flag in mbuf->ol_flags (this flag implies
> + *    PKT_TX_OUTER_IP_CKSUM, PKT_TX_IP_CKSUM and PKT_TX_TCP_CKSUM)
> + * Hardware that supports generic tunnel TSO offload only update outer/inner
> + * L3/L4 fields, tunnel fields are not touched.
> + */
> +#define DEV_TX_OFFLOAD_GENERIC_TNL_TSO		0x00080000

Practically, for the existing TSO offloads for tunneled packets, tunnel type
(PKT_TX_TUNNEL_*) is needed for knowing if transport is UDP-based or IP-based
because the length field of UDP header should be updated for TSO. AFAIK, there's
no TCP-based tunnel. For PKT_TX_TUNNEL_UNKNOWN, the only thing _unknown_ seems
to be the type of transport and by defining PKT_TX_OUTER_UDP, you seem to
recognize the type of transport between UDP and IP (it's not non-UDP). Given
that, the new flags still look redundant and ambiguous. If PKT_TX_TUNNEL_VXLAN
is set, there's no need to set PKT_TX_OUTER_UDP redundantly.

Instead, I think defining PKT_TX_TUNNEL_UDP_UNKNOWN and PKT_TX_TUNNEL_IP_UNKNOWN
could be a good alternative. It is only my humble two cents and I'd like to hear
from more people regarding this.


Thanks,
Yongseok

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

* Re: [dpdk-dev] [PATCH v3 1/7] ethdev: introduce Tx generic tunnel L3/L4 offload
  2018-03-21  1:40     ` Yongseok Koh
@ 2018-03-22 13:55       ` Xueming(Steven) Li
  2018-03-28 12:52         ` Olivier Matz
  0 siblings, 1 reply; 80+ messages in thread
From: Xueming(Steven) Li @ 2018-03-22 13:55 UTC (permalink / raw)
  To: Yongseok Koh
  Cc: Wenzhuo Lu, Jingjing Wu, Thomas Monjalon, Olivier MATZ,
	Shahaf Shuler, Ferruh Yigit, dev



> -----Original Message-----
> From: Yongseok Koh
> Sent: Wednesday, March 21, 2018 9:41 AM
> To: Xueming(Steven) Li <xuemingl@mellanox.com>
> Cc: Wenzhuo Lu <wenzhuo.lu@intel.com>; Jingjing Wu <jingjing.wu@intel.com>;
> Thomas Monjalon <thomas@monjalon.net>; Olivier MATZ
> <olivier.matz@6wind.com>; Shahaf Shuler <shahafs@mellanox.com>; Ferruh
> Yigit <ferruh.yigit@intel.com>; dev@dpdk.org
> Subject: Re: [PATCH v3 1/7] ethdev: introduce Tx generic tunnel L3/L4
> offload
> 
> On Mon, Mar 05, 2018 at 10:51:15PM +0800, Xueming Li wrote:
> > This patch introduce new TX offload flags for device that supports
> > tunnel agnostic L3/L4 checksum and TSO offload.
> >
> > The support from the device is for inner and outer checksums on
> > IPV4/TCP/UDP and TSO for *any packet with the following format*:
> >
> > < some headers > / [optional IPv4/IPv6] / [optional TCP/UDP] / <some
> > headers> / [optional inner IPv4/IPv6] / [optional TCP/UDP]
> >
> > For example the following packets can use this feature:
> >
> > 1. eth / ipv4 / udp / VXLAN / ip / tcp 2. eth / ipv4 / GRE / MPLS /
> > ipv4 / udp
> >
> > Signed-off-by: Xueming Li <xuemingl@mellanox.com>
> > ---
> >  lib/librte_ether/rte_ethdev.h | 24 ++++++++++++++++++++++++
> >  lib/librte_mbuf/rte_mbuf.c    |  5 +++++
> >  lib/librte_mbuf/rte_mbuf.h    | 18 ++++++++++++++++--
> >  3 files changed, 45 insertions(+), 2 deletions(-)
> >
> > diff --git a/lib/librte_ether/rte_ethdev.h
> > b/lib/librte_ether/rte_ethdev.h index 036153306..66d12d3e0 100644
> > --- a/lib/librte_ether/rte_ethdev.h
> > +++ b/lib/librte_ether/rte_ethdev.h
> > @@ -980,6 +980,30 @@ struct rte_eth_conf {
> >   *   the same mempool and has refcnt = 1.
> >   */
> >  #define DEV_TX_OFFLOAD_SECURITY         0x00020000
> > +/**< Generic tunnel L3/L4 checksum offload. To enable this offload
> > +feature
> > + * for a packet to be transmitted on hardware supporting generic
> > +tunnel L3/L4
> > + * checksum offload:
> > + *  - fill outer_l2_len and outer_l3_len in mbuf
> > + *  - fill l2_len and l3_len in mbuf
> > + *  - set the flags PKT_TX_TUNNEL_xxx (use PKT_TX_TUNNEL_UNKNOWN if
> > +undefined)
> > + *  - set the flags PKT_TX_OUTER_IP_CKSUM
> > + *  - set the flags PKT_TX_IP_CKSUM
> > + *  - set the flags PKT_TX_TCP_CKSUM, PKT_TX_SCTP_CKSUM or
> > +PKT_TX_UDP_CKSUM  */
> > +#define DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM	0x00040000
> 
> It looks redundant to me. Isn't it same as having DEV_TX_OFFLOAD_*_CKSUM?
> According to the API document, when PKT_TX_*_CKSUM is set, all the
> necessary length fields should be filled in (e.g. mbuf->outer_l?_len and
> mbuf->l?_len). It doesn't need to specify any tunnel type for checksum.
> For example, in order to request checksum offload for an unknown tunnel
> type which is similar to VxLAN, what should app do? Even without defining
> this new offload flag, it is currently possible by setting
> 	(PKT_TX_OUTER_IP_CKSUM | PKT_TX_OUTER_IPV4 | PKT_TX_IP_CKSUM |
> 	 PKT_TX_IPV4 | PKT_TX_UDP_CKSUM)
> along with various length fields.

Agree it almost same as existing checksum offloading requirement, besides:
1. it does not demand pseudo checksum
2. no need to clear IP checksum
I guess the requirement on API doc is a super set and differences could be 
documented on PMD doc.

For mlx5 original chksum offloading, hw will parse everything w/o demanding
mbuf headers, a little better performance than SWP. The question is how to 
choose between SWP and HW checksum offloading - assuming PKT_TX_TUNNEL_UNKNOWN
is the key. Take L3 VXLAN(no inner L2 header) as example, only SWP could 
offload it correctly and PKT_TX_TUNNEL_UNKOWN should be used here, not 
PKT_TX_TUNNEL_VXLAN, make sense?

Another question, how does user app know the NIC capability of generic tunnel 
checksum offload?

> 
> > +/**< Generic tunnel segmentation offload. To enable it, the user needs
> to:
> > + *  - fill outer_l2_len and outer_l3_len in mbuf
> > + *  - fill l2_len and l3_len in mbuf
> > + *  - set the flags PKT_TX_TUNNEL_xxx (use PKT_TX_TUNNEL_UNKNOWN if
> > +undefined)
> > + *  - set the flags PKT_TX_OUTER_IPV4 or PKT_TX_OUTER_IPV6
> > + *  - if it's UDP tunnel, set the flags PKT_TX_OUTER_UDP
> > + *  - set the flags PKT_TX_IPV4 or PKT_TX_IPV6
> > + *  - set the PKT_TX_TCP_SEG flag in mbuf->ol_flags (this flag implies
> > + *    PKT_TX_OUTER_IP_CKSUM, PKT_TX_IP_CKSUM and PKT_TX_TCP_CKSUM)
> > + * Hardware that supports generic tunnel TSO offload only update
> > +outer/inner
> > + * L3/L4 fields, tunnel fields are not touched.
> > + */
> > +#define DEV_TX_OFFLOAD_GENERIC_TNL_TSO		0x00080000
> 
> Practically, for the existing TSO offloads for tunneled packets, tunnel
> type
> (PKT_TX_TUNNEL_*) is needed for knowing if transport is UDP-based or IP-
> based because the length field of UDP header should be updated for TSO.
> AFAIK, there's no TCP-based tunnel. For PKT_TX_TUNNEL_UNKNOWN, the only
> thing _unknown_ seems to be the type of transport and by defining
> PKT_TX_OUTER_UDP, you seem to recognize the type of transport between UDP
> and IP (it's not non-UDP). Given that, the new flags still look redundant
> and ambiguous. If PKT_TX_TUNNEL_VXLAN is set, there's no need to set
> PKT_TX_OUTER_UDP redundantly.
> 
> Instead, I think defining PKT_TX_TUNNEL_UDP_UNKNOWN and
> PKT_TX_TUNNEL_IP_UNKNOWN could be a good alternative. It is only my humble
> two cents and I'd like to hear from more people regarding this.
> 

This flag looks more like a feature notification. Current tunnel offloading 
capability like "DEV_TX_OFFLOAD_VXLAN_TNL_TSO" ties to VXLAN tunnel type,
DEV_TX_OFFLOAD_GENERIC_TNL_TSO should be able to let users know that NIC's
capability of offloading generic tunnel type like MPLS-in-UDP that not defined
yet. PKT_TX_OUTER_UDP is something must to have to flag an exists of outer UDP
in such case.

> 
> Thanks,
> Yongseok

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

* Re: [dpdk-dev] [PATCH v3 1/7] ethdev: introduce Tx generic tunnel L3/L4 offload
  2018-03-22 13:55       ` Xueming(Steven) Li
@ 2018-03-28 12:52         ` Olivier Matz
  2018-04-04  8:20           ` Xueming(Steven) Li
  0 siblings, 1 reply; 80+ messages in thread
From: Olivier Matz @ 2018-03-28 12:52 UTC (permalink / raw)
  To: Xueming(Steven) Li
  Cc: Yongseok Koh, Wenzhuo Lu, Jingjing Wu, Thomas Monjalon,
	Shahaf Shuler, Ferruh Yigit, dev

Hi Xueming, Yongseok,

On Thu, Mar 22, 2018 at 01:55:05PM +0000, Xueming(Steven) Li wrote:
> 
> 
> > -----Original Message-----
> > From: Yongseok Koh
> > Sent: Wednesday, March 21, 2018 9:41 AM
> > To: Xueming(Steven) Li <xuemingl@mellanox.com>
> > Cc: Wenzhuo Lu <wenzhuo.lu@intel.com>; Jingjing Wu <jingjing.wu@intel.com>;
> > Thomas Monjalon <thomas@monjalon.net>; Olivier MATZ
> > <olivier.matz@6wind.com>; Shahaf Shuler <shahafs@mellanox.com>; Ferruh
> > Yigit <ferruh.yigit@intel.com>; dev@dpdk.org
> > Subject: Re: [PATCH v3 1/7] ethdev: introduce Tx generic tunnel L3/L4
> > offload
> > 
> > On Mon, Mar 05, 2018 at 10:51:15PM +0800, Xueming Li wrote:
> > > This patch introduce new TX offload flags for device that supports
> > > tunnel agnostic L3/L4 checksum and TSO offload.
> > >
> > > The support from the device is for inner and outer checksums on
> > > IPV4/TCP/UDP and TSO for *any packet with the following format*:
> > >
> > > < some headers > / [optional IPv4/IPv6] / [optional TCP/UDP] / <some
> > > headers> / [optional inner IPv4/IPv6] / [optional TCP/UDP]
> > >
> > > For example the following packets can use this feature:
> > >
> > > 1. eth / ipv4 / udp / VXLAN / ip / tcp 2. eth / ipv4 / GRE / MPLS /
> > > ipv4 / udp
> > >
> > > Signed-off-by: Xueming Li <xuemingl@mellanox.com>
> > > ---
> > >  lib/librte_ether/rte_ethdev.h | 24 ++++++++++++++++++++++++
> > >  lib/librte_mbuf/rte_mbuf.c    |  5 +++++
> > >  lib/librte_mbuf/rte_mbuf.h    | 18 ++++++++++++++++--
> > >  3 files changed, 45 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/lib/librte_ether/rte_ethdev.h
> > > b/lib/librte_ether/rte_ethdev.h index 036153306..66d12d3e0 100644
> > > --- a/lib/librte_ether/rte_ethdev.h
> > > +++ b/lib/librte_ether/rte_ethdev.h
> > > @@ -980,6 +980,30 @@ struct rte_eth_conf {
> > >   *   the same mempool and has refcnt = 1.
> > >   */
> > >  #define DEV_TX_OFFLOAD_SECURITY         0x00020000
> > > +/**< Generic tunnel L3/L4 checksum offload. To enable this offload
> > > +feature
> > > + * for a packet to be transmitted on hardware supporting generic
> > > +tunnel L3/L4
> > > + * checksum offload:
> > > + *  - fill outer_l2_len and outer_l3_len in mbuf
> > > + *  - fill l2_len and l3_len in mbuf
> > > + *  - set the flags PKT_TX_TUNNEL_xxx (use PKT_TX_TUNNEL_UNKNOWN if
> > > +undefined)
> > > + *  - set the flags PKT_TX_OUTER_IP_CKSUM
> > > + *  - set the flags PKT_TX_IP_CKSUM
> > > + *  - set the flags PKT_TX_TCP_CKSUM, PKT_TX_SCTP_CKSUM or
> > > +PKT_TX_UDP_CKSUM  */
> > > +#define DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM	0x00040000
> > 
> > It looks redundant to me. Isn't it same as having DEV_TX_OFFLOAD_*_CKSUM?
> > According to the API document, when PKT_TX_*_CKSUM is set, all the
> > necessary length fields should be filled in (e.g. mbuf->outer_l?_len and
> > mbuf->l?_len). It doesn't need to specify any tunnel type for checksum.
> > For example, in order to request checksum offload for an unknown tunnel
> > type which is similar to VxLAN, what should app do? Even without defining
> > this new offload flag, it is currently possible by setting
> > 	(PKT_TX_OUTER_IP_CKSUM | PKT_TX_OUTER_IPV4 | PKT_TX_IP_CKSUM |
> > 	 PKT_TX_IPV4 | PKT_TX_UDP_CKSUM)
> > along with various length fields.
> 
> Agree it almost same as existing checksum offloading requirement, besides:
> 1. it does not demand pseudo checksum
> 2. no need to clear IP checksum
> I guess the requirement on API doc is a super set and differences could be 
> documented on PMD doc.

Since commit 4fb7e803eb1a ("ethdev: add Tx preparation"), setting the
IP checksum to 0 and the pseudo header checksum in TCP is not required.
The user just need to set the flags, then before transmitting the packet,
call tx_prepare() which will do the proper work, according to the hw
requirements.

It looks that the API documentation of PKT_TX_TCP_SEG should be updated.
I'll submit a patch for this.


> For mlx5 original chksum offloading, hw will parse everything w/o demanding
> mbuf headers, a little better performance than SWP. The question is how to 
> choose between SWP and HW checksum offloading - assuming PKT_TX_TUNNEL_UNKNOWN
> is the key. Take L3 VXLAN(no inner L2 header) as example, only SWP could 
> offload it correctly and PKT_TX_TUNNEL_UNKOWN should be used here, not 
> PKT_TX_TUNNEL_VXLAN, make sense?
> 
> Another question, how does user app know the NIC capability of generic tunnel 
> checksum offload?

After reading the patchset, I still don't see what you want to achieve.
In patch 1, we talk about these 2 packets:

1. eth / ipv4 / udp / VXLAN / ip / tcp     (L3 VXLAN as you said above)
2. eth / ipv4 / GRE / MPLS / ipv4 / udp

What is not doable with current API?

I didn't try, but I think the following would work currently
with tx_prepare() + tx_burst().

- inner TSO on 1.

  flags = PKT_TX_TUNNEL_VXLAN | PKT_TX_IPV4 | PKT_TX_IP_CKSUM |
          PKT_TX_TCP_CKSUM | PKT_TX_TCP_SEG
  outer_l2_len = size(eth)
  outer_l3_len = size(ipv4)
  l2_len = size(udp + vxlan)
  l3_len = size(ip)

- inner TCP checksum on 1.

  flags = PKT_TX_TUNNEL_VXLAN | PKT_TX_IPV4 | PKT_TX_IP_CKSUM |
          PKT_TX_TCP_CKSUM
  outer_l2_len = size(eth)
  outer_l3_len = size(ipv4)
  l2_len = size(udp + vxlan)
  l3_len = size(ip)

- inner UDP checksum on 2.

  flags = PKT_TX_TUNNEL_GRE | PKT_TX_IPV4 | PKT_TX_IP_CKSUM |
          PKT_TX_UDP_CKSUM
  outer_l2_len = size(eth)
  outer_l3_len = size(ipv4)
  l2_len = size(gre + mpls)
  l3_len = size(ipv4)

Yes, writing the tunnel len in l2_len is a bit strange, but it
should do the trick.

It's still unclear for me why you need to add a "generic" flag.
Is there something you can't do today with the current API?


> 
> > 
> > > +/**< Generic tunnel segmentation offload. To enable it, the user needs
> > to:
> > > + *  - fill outer_l2_len and outer_l3_len in mbuf
> > > + *  - fill l2_len and l3_len in mbuf
> > > + *  - set the flags PKT_TX_TUNNEL_xxx (use PKT_TX_TUNNEL_UNKNOWN if
> > > +undefined)
> > > + *  - set the flags PKT_TX_OUTER_IPV4 or PKT_TX_OUTER_IPV6
> > > + *  - if it's UDP tunnel, set the flags PKT_TX_OUTER_UDP
> > > + *  - set the flags PKT_TX_IPV4 or PKT_TX_IPV6
> > > + *  - set the PKT_TX_TCP_SEG flag in mbuf->ol_flags (this flag implies
> > > + *    PKT_TX_OUTER_IP_CKSUM, PKT_TX_IP_CKSUM and PKT_TX_TCP_CKSUM)
> > > + * Hardware that supports generic tunnel TSO offload only update
> > > +outer/inner
> > > + * L3/L4 fields, tunnel fields are not touched.
> > > + */
> > > +#define DEV_TX_OFFLOAD_GENERIC_TNL_TSO		0x00080000
> > 
> > Practically, for the existing TSO offloads for tunneled packets, tunnel
> > type
> > (PKT_TX_TUNNEL_*) is needed for knowing if transport is UDP-based or IP-
> > based because the length field of UDP header should be updated for TSO.
> > AFAIK, there's no TCP-based tunnel. For PKT_TX_TUNNEL_UNKNOWN, the only
> > thing _unknown_ seems to be the type of transport and by defining
> > PKT_TX_OUTER_UDP, you seem to recognize the type of transport between UDP
> > and IP (it's not non-UDP). Given that, the new flags still look redundant
> > and ambiguous. If PKT_TX_TUNNEL_VXLAN is set, there's no need to set
> > PKT_TX_OUTER_UDP redundantly.
> > 
> > Instead, I think defining PKT_TX_TUNNEL_UDP_UNKNOWN and
> > PKT_TX_TUNNEL_IP_UNKNOWN could be a good alternative. It is only my humble
> > two cents and I'd like to hear from more people regarding this.
> > 
> 

I agree with Yongseok here. The flag PKT_TX_TUNNEL_VXLAN implies that
the protocol is UDP. Having a flag PKT_TX_TUNNEL_UDP or PKT_TX_TUNNEL_IP
could make sense if we find a use case that cannot be done currently with
the existing API (for instance, another tunnel type over UDP).

> This flag looks more like a feature notification. Current tunnel offloading 
> capability like "DEV_TX_OFFLOAD_VXLAN_TNL_TSO" ties to VXLAN tunnel type,
> DEV_TX_OFFLOAD_GENERIC_TNL_TSO should be able to let users know that NIC's
> capability of offloading generic tunnel type like MPLS-in-UDP that not defined
> yet. PKT_TX_OUTER_UDP is something must to have to flag an exists of outer UDP
> in such case.

So, maybe, instead of DEV_TX_OFFLOAD_GENERIC_TNL_TSO it could be
DEV_TX_OFFLOAD_UDP_TUNNEL_TSO. Because it is not possible for a hardware
to support TSO on top of any kind of tunnel type.

For instance, if the tunnel header has a checksum or a sequence id, the
hardware must be aware of it.

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

* Re: [dpdk-dev] [PATCH v3 1/7] ethdev: introduce Tx generic tunnel L3/L4 offload
  2018-03-28 12:52         ` Olivier Matz
@ 2018-04-04  8:20           ` Xueming(Steven) Li
  0 siblings, 0 replies; 80+ messages in thread
From: Xueming(Steven) Li @ 2018-04-04  8:20 UTC (permalink / raw)
  To: Olivier Matz
  Cc: Yongseok Koh, Wenzhuo Lu, Jingjing Wu, Thomas Monjalon,
	Shahaf Shuler, Ferruh Yigit, dev

Hi Olivier, 

> -----Original Message-----
> From: Olivier Matz <olivier.matz@6wind.com>
> Sent: Wednesday, March 28, 2018 8:53 PM
> To: Xueming(Steven) Li <xuemingl@mellanox.com>
> Cc: Yongseok Koh <yskoh@mellanox.com>; Wenzhuo Lu <wenzhuo.lu@intel.com>;
> Jingjing Wu <jingjing.wu@intel.com>; Thomas Monjalon <thomas@monjalon.net>;
> Shahaf Shuler <shahafs@mellanox.com>; Ferruh Yigit
> <ferruh.yigit@intel.com>; dev@dpdk.org
> Subject: Re: [PATCH v3 1/7] ethdev: introduce Tx generic tunnel L3/L4
> offload
> 
> Hi Xueming, Yongseok,
> 
> On Thu, Mar 22, 2018 at 01:55:05PM +0000, Xueming(Steven) Li wrote:
> >
> >
> > > -----Original Message-----
> > > From: Yongseok Koh
> > > Sent: Wednesday, March 21, 2018 9:41 AM
> > > To: Xueming(Steven) Li <xuemingl@mellanox.com>
> > > Cc: Wenzhuo Lu <wenzhuo.lu@intel.com>; Jingjing Wu
> > > <jingjing.wu@intel.com>; Thomas Monjalon <thomas@monjalon.net>;
> > > Olivier MATZ <olivier.matz@6wind.com>; Shahaf Shuler
> > > <shahafs@mellanox.com>; Ferruh Yigit <ferruh.yigit@intel.com>;
> > > dev@dpdk.org
> > > Subject: Re: [PATCH v3 1/7] ethdev: introduce Tx generic tunnel
> > > L3/L4 offload
> > >
> > > On Mon, Mar 05, 2018 at 10:51:15PM +0800, Xueming Li wrote:
> > > > This patch introduce new TX offload flags for device that supports
> > > > tunnel agnostic L3/L4 checksum and TSO offload.
> > > >
> > > > The support from the device is for inner and outer checksums on
> > > > IPV4/TCP/UDP and TSO for *any packet with the following format*:
> > > >
> > > > < some headers > / [optional IPv4/IPv6] / [optional TCP/UDP] /
> > > > <some
> > > > headers> / [optional inner IPv4/IPv6] / [optional TCP/UDP]
> > > >
> > > > For example the following packets can use this feature:
> > > >
> > > > 1. eth / ipv4 / udp / VXLAN / ip / tcp 2. eth / ipv4 / GRE / MPLS
> > > > /
> > > > ipv4 / udp
> > > >
> > > > Signed-off-by: Xueming Li <xuemingl@mellanox.com>
> > > > ---
> > > >  lib/librte_ether/rte_ethdev.h | 24 ++++++++++++++++++++++++
> > > >  lib/librte_mbuf/rte_mbuf.c    |  5 +++++
> > > >  lib/librte_mbuf/rte_mbuf.h    | 18 ++++++++++++++++--
> > > >  3 files changed, 45 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/lib/librte_ether/rte_ethdev.h
> > > > b/lib/librte_ether/rte_ethdev.h index 036153306..66d12d3e0 100644
> > > > --- a/lib/librte_ether/rte_ethdev.h
> > > > +++ b/lib/librte_ether/rte_ethdev.h
> > > > @@ -980,6 +980,30 @@ struct rte_eth_conf {
> > > >   *   the same mempool and has refcnt = 1.
> > > >   */
> > > >  #define DEV_TX_OFFLOAD_SECURITY         0x00020000
> > > > +/**< Generic tunnel L3/L4 checksum offload. To enable this
> > > > +offload feature
> > > > + * for a packet to be transmitted on hardware supporting generic
> > > > +tunnel L3/L4
> > > > + * checksum offload:
> > > > + *  - fill outer_l2_len and outer_l3_len in mbuf
> > > > + *  - fill l2_len and l3_len in mbuf
> > > > + *  - set the flags PKT_TX_TUNNEL_xxx (use PKT_TX_TUNNEL_UNKNOWN
> > > > +if
> > > > +undefined)
> > > > + *  - set the flags PKT_TX_OUTER_IP_CKSUM
> > > > + *  - set the flags PKT_TX_IP_CKSUM
> > > > + *  - set the flags PKT_TX_TCP_CKSUM, PKT_TX_SCTP_CKSUM or
> > > > +PKT_TX_UDP_CKSUM  */
> > > > +#define DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM	0x00040000
> > >
> > > It looks redundant to me. Isn't it same as having
> DEV_TX_OFFLOAD_*_CKSUM?
> > > According to the API document, when PKT_TX_*_CKSUM is set, all the
> > > necessary length fields should be filled in (e.g. mbuf->outer_l?_len
> > > and
> > > mbuf->l?_len). It doesn't need to specify any tunnel type for checksum.
> > > For example, in order to request checksum offload for an unknown
> > > tunnel type which is similar to VxLAN, what should app do? Even
> > > without defining this new offload flag, it is currently possible by
> setting
> > > 	(PKT_TX_OUTER_IP_CKSUM | PKT_TX_OUTER_IPV4 | PKT_TX_IP_CKSUM |
> > > 	 PKT_TX_IPV4 | PKT_TX_UDP_CKSUM)
> > > along with various length fields.
> >
> > Agree it almost same as existing checksum offloading requirement,
> besides:
> > 1. it does not demand pseudo checksum
> > 2. no need to clear IP checksum
> > I guess the requirement on API doc is a super set and differences
> > could be documented on PMD doc.
> 
> Since commit 4fb7e803eb1a ("ethdev: add Tx preparation"), setting the IP
> checksum to 0 and the pseudo header checksum in TCP is not required.
> The user just need to set the flags, then before transmitting the packet,
> call tx_prepare() which will do the proper work, according to the hw
> requirements.
> 
> It looks that the API documentation of PKT_TX_TCP_SEG should be updated.
> I'll submit a patch for this.
> 

Nice to hide intel specific requirement and now it's much clear, thanks.

> 
> > For mlx5 original chksum offloading, hw will parse everything w/o
> > demanding mbuf headers, a little better performance than SWP. The
> > question is how to choose between SWP and HW checksum offloading -
> > assuming PKT_TX_TUNNEL_UNKNOWN is the key. Take L3 VXLAN(no inner L2
> > header) as example, only SWP could offload it correctly and
> > PKT_TX_TUNNEL_UNKOWN should be used here, not PKT_TX_TUNNEL_VXLAN, make
> sense?
> >
> > Another question, how does user app know the NIC capability of generic
> > tunnel checksum offload?
> 
> After reading the patchset, I still don't see what you want to achieve.
> In patch 1, we talk about these 2 packets:
> 
> 1. eth / ipv4 / udp / VXLAN / ip / tcp     (L3 VXLAN as you said above)
> 2. eth / ipv4 / GRE / MPLS / ipv4 / udp
> 
> What is not doable with current API?
> 
> I didn't try, but I think the following would work currently with
> tx_prepare() + tx_burst().
> 
> - inner TSO on 1.
> 
>   flags = PKT_TX_TUNNEL_VXLAN | PKT_TX_IPV4 | PKT_TX_IP_CKSUM |
>           PKT_TX_TCP_CKSUM | PKT_TX_TCP_SEG
>   outer_l2_len = size(eth)
>   outer_l3_len = size(ipv4)
>   l2_len = size(udp + vxlan)
>   l3_len = size(ip)
> 
> - inner TCP checksum on 1.
> 
>   flags = PKT_TX_TUNNEL_VXLAN | PKT_TX_IPV4 | PKT_TX_IP_CKSUM |
>           PKT_TX_TCP_CKSUM
>   outer_l2_len = size(eth)
>   outer_l3_len = size(ipv4)
>   l2_len = size(udp + vxlan)
>   l3_len = size(ip)
> 
> - inner UDP checksum on 2.
> 
>   flags = PKT_TX_TUNNEL_GRE | PKT_TX_IPV4 | PKT_TX_IP_CKSUM |
>           PKT_TX_UDP_CKSUM
>   outer_l2_len = size(eth)
>   outer_l3_len = size(ipv4)
>   l2_len = size(gre + mpls)
>   l3_len = size(ipv4)
> 
> Yes, writing the tunnel len in l2_len is a bit strange, but it should do
> the trick.
> 
> It's still unclear for me why you need to add a "generic" flag.
> Is there something you can't do today with the current API?
> 

I think the problem is mlx5 current hw so smart that not generic enough, 
that's why this patchset tried to introduce new hw feature and new generic flag.
Since current checksum API already covered, no reason to add new, thanks.

> 
> >
> > >
> > > > +/**< Generic tunnel segmentation offload. To enable it, the user
> > > > +needs
> > > to:
> > > > + *  - fill outer_l2_len and outer_l3_len in mbuf
> > > > + *  - fill l2_len and l3_len in mbuf
> > > > + *  - set the flags PKT_TX_TUNNEL_xxx (use PKT_TX_TUNNEL_UNKNOWN
> > > > +if
> > > > +undefined)
> > > > + *  - set the flags PKT_TX_OUTER_IPV4 or PKT_TX_OUTER_IPV6
> > > > + *  - if it's UDP tunnel, set the flags PKT_TX_OUTER_UDP
> > > > + *  - set the flags PKT_TX_IPV4 or PKT_TX_IPV6
> > > > + *  - set the PKT_TX_TCP_SEG flag in mbuf->ol_flags (this flag
> implies
> > > > + *    PKT_TX_OUTER_IP_CKSUM, PKT_TX_IP_CKSUM and PKT_TX_TCP_CKSUM)
> > > > + * Hardware that supports generic tunnel TSO offload only update
> > > > +outer/inner
> > > > + * L3/L4 fields, tunnel fields are not touched.
> > > > + */
> > > > +#define DEV_TX_OFFLOAD_GENERIC_TNL_TSO		0x00080000
> > >
> > > Practically, for the existing TSO offloads for tunneled packets,
> > > tunnel type
> > > (PKT_TX_TUNNEL_*) is needed for knowing if transport is UDP-based or
> > > IP- based because the length field of UDP header should be updated for
> TSO.
> > > AFAIK, there's no TCP-based tunnel. For PKT_TX_TUNNEL_UNKNOWN, the
> > > only thing _unknown_ seems to be the type of transport and by
> > > defining PKT_TX_OUTER_UDP, you seem to recognize the type of
> > > transport between UDP and IP (it's not non-UDP). Given that, the new
> > > flags still look redundant and ambiguous. If PKT_TX_TUNNEL_VXLAN is
> > > set, there's no need to set PKT_TX_OUTER_UDP redundantly.
> > >
> > > Instead, I think defining PKT_TX_TUNNEL_UDP_UNKNOWN and
> > > PKT_TX_TUNNEL_IP_UNKNOWN could be a good alternative. It is only my
> > > humble two cents and I'd like to hear from more people regarding this.
> > >
> >
> 
> I agree with Yongseok here. The flag PKT_TX_TUNNEL_VXLAN implies that the
> protocol is UDP. Having a flag PKT_TX_TUNNEL_UDP or PKT_TX_TUNNEL_IP could
> make sense if we find a use case that cannot be done currently with the
> existing API (for instance, another tunnel type over UDP).

PKT_TX_TUNNEL_UDP + PKT_TX_TUNNEL_IP looks similar to PKT_TX_TUNNEL_UNKOWN + 
PKT_TX_OUTER_UDP, I'm fine with this proposal.

> 
> > This flag looks more like a feature notification. Current tunnel
> > offloading capability like "DEV_TX_OFFLOAD_VXLAN_TNL_TSO" ties to
> > VXLAN tunnel type, DEV_TX_OFFLOAD_GENERIC_TNL_TSO should be able to
> > let users know that NIC's capability of offloading generic tunnel type
> > like MPLS-in-UDP that not defined yet. PKT_TX_OUTER_UDP is something
> > must to have to flag an exists of outer UDP in such case.
> 
> So, maybe, instead of DEV_TX_OFFLOAD_GENERIC_TNL_TSO it could be
> DEV_TX_OFFLOAD_UDP_TUNNEL_TSO. Because it is not possible for a hardware
> to support TSO on top of any kind of tunnel type.
> 
> For instance, if the tunnel header has a checksum or a sequence id, the
> hardware must be aware of it.

Similarly, I'll split DEV_TX_OFFLOAD_GENERIC_TNL_TSO into DEV_TX_OFFLOAD_UDP_TNL_TSO
and DEV_TX_OFFLOAD_IP_TNL_TSO to cover tunnel types that no checksum and seq id.

Overall speaking, existing app using tunnel offloading should work w/o any change.
I'm working on a new version to reflect this change, and split this patch set into 
public and mlx5.

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

* [dpdk-dev] [PATCH v4 0/4] support Tx generic tunnel checksum and TSO
  2018-01-09 14:11 ` [dpdk-dev] [PATCH 1/6] net/mlx5: support tx swp tunnel offloading Xueming Li
                     ` (12 preceding siblings ...)
  2018-03-05 14:51   ` [dpdk-dev] [PATCH v3 7/7] net/mlx5: allow max 192B TSO inline header length Xueming Li
@ 2018-04-08 12:32   ` Xueming Li
  2018-04-17 14:43     ` [dpdk-dev] [PATCH v5 0/2] " Xueming Li
                       ` (5 more replies)
  2018-04-08 12:32   ` [dpdk-dev] [PATCH v4 1/4] ethdev: introduce generic IP/UDP tunnel checksum and TSO Xueming Li
                     ` (3 subsequent siblings)
  17 siblings, 6 replies; 80+ messages in thread
From: Xueming Li @ 2018-04-08 12:32 UTC (permalink / raw)
  To: Wenzhuo Lu, Jingjing Wu, Thomas Monjalon, Yongseok Koh,
	Olivier MATZ, Shahaf Shuler
  Cc: Xueming Li, Ferruh Yigit, dev

V4: 
- Removed DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM and DEV_TX_OFFLOAD_GENERIC_TNL_TSO
- Replaced with DEV_TX_OFFLOAD_IP_TNL_TSO
- Removed PKT_TX_OUTER_UDP
- Splited PKT_TX_TUNNEL_UNKNOWN into PKT_TX_TUNNEL_IP and PKT_TX_TUNNEL_UDP

V3:
- Add VXLAN-GPE and GRE extention support to testpmd csum forwarding enginee
- Split DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO into DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM
  and DEV_TX_OFFLOAD_GENERIC_TNL_TSO
- Add PKT_TX_TUNNEL_UNKNOWN and PKT_TX_OUTER_UDP

  http://www.dpdk.org/dev/patchwork/patch/34655/


This patchset introduces new HW capability of generic tunnel cheksum and TSO offloads, HW supporting generic tunnel checksum and TSO could handle new tunnel type offloading w/o upgrading HW. 
New Generic tunnel checksum and TSO offload support IP tunnel and UDP tunnel. Please note that tunnel type that has length, sequence id or checksum are not considered as generic tunnel type.

Xueming Li (4):
  ethdev: introduce Tx generic tunnel L3/L4 offload
  app/testpmd: testpmd support Tx generic tunnel offloads
  app/testpmd: add more GRE extension to csum engine
  app/testpmd: introduce VXLAN GPE to csum forwarding engine

 app/test-pmd/cmdline.c                |  14 ++++-
 app/test-pmd/config.c                 |  17 +++++
 app/test-pmd/csumonly.c               | 115 ++++++++++++++++++++++++++++++----
 app/test-pmd/parameters.c             |  12 +++-
 app/test-pmd/testpmd.h                |   2 +
 doc/guides/testpmd_app_ug/run_app.rst |   5 ++
 lib/librte_ether/rte_ethdev.h         |   4 ++
 lib/librte_mbuf/rte_mbuf.c            |   6 ++
 lib/librte_mbuf/rte_mbuf.h            |   2 +
 9 files changed, 163 insertions(+), 14 deletions(-)

-- 
2.13.3

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

* [dpdk-dev] [PATCH v4 1/4] ethdev: introduce generic IP/UDP tunnel checksum and TSO
  2018-01-09 14:11 ` [dpdk-dev] [PATCH 1/6] net/mlx5: support tx swp tunnel offloading Xueming Li
                     ` (13 preceding siblings ...)
  2018-04-08 12:32   ` [dpdk-dev] [PATCH v4 0/4] support Tx generic tunnel checksum and TSO Xueming Li
@ 2018-04-08 12:32   ` Xueming Li
  2018-04-16 22:42     ` Thomas Monjalon
  2018-04-08 12:32   ` [dpdk-dev] [PATCH v4 2/4] app/testpmd: testpmd support Tx generic tunnel offloads Xueming Li
                     ` (2 subsequent siblings)
  17 siblings, 1 reply; 80+ messages in thread
From: Xueming Li @ 2018-04-08 12:32 UTC (permalink / raw)
  To: Wenzhuo Lu, Jingjing Wu, Thomas Monjalon, Yongseok Koh,
	Olivier MATZ, Shahaf Shuler
  Cc: Xueming Li, Ferruh Yigit, dev

This patch introduce new TX offload flags for device that supports
IP or UDP tunneled packet L3/L4 checksum and TSO offload.

The support from the device is for inner and outer checksums on
IPV4/TCP/UDP and TSO for *any packet with the following format*:

<some headers> / [optional IPv4/IPv6] / [optional TCP/UDP] / <some
headers> / [optional inner IPv4/IPv6] / [optional TCP/UDP]

For example the following packets can use this feature:

1. eth / ipv4 / udp / VXLAN / ip / tcp
2. eth / ipv4 / GRE / MPLS / ipv4 / udp

Please note that tunnel headers that contain payload length, sequence id
or checksum will not be updated.

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
---
 lib/librte_ether/rte_ethdev.h | 4 ++++
 lib/librte_mbuf/rte_mbuf.c    | 6 ++++++
 lib/librte_mbuf/rte_mbuf.h    | 2 ++
 3 files changed, 12 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 5c8af16f5..a3ae43cdc 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -980,6 +980,10 @@ struct rte_eth_conf {
  *   the same mempool and has refcnt = 1.
  */
 #define DEV_TX_OFFLOAD_SECURITY         0x00020000
+/**< Device supports UDP tunneled packet TSO */
+#define DEV_TX_OFFLOAD_UDP_TNL_TSO      0x00040000
+/**< Device supports IP based tunnel packet TSO */
+#define DEV_TX_OFFLOAD_IP_TNL_TSO       0x00080000
 
 /*
  * If new Tx offload capabilities are defined, they also must be
diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index 091d388d3..41e1bc953 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -405,6 +405,8 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask)
 	case PKT_TX_TUNNEL_IPIP: return "PKT_TX_TUNNEL_IPIP";
 	case PKT_TX_TUNNEL_GENEVE: return "PKT_TX_TUNNEL_GENEVE";
 	case PKT_TX_TUNNEL_MPLSINUDP: return "PKT_TX_TUNNEL_MPLSINUDP";
+	case PKT_TX_TUNNEL_IP: return "PKT_TX_TUNNEL_IP";
+	case PKT_TX_TUNNEL_UDP: return "PKT_TX_TUNNEL_UDP";
 	case PKT_TX_MACSEC: return "PKT_TX_MACSEC";
 	case PKT_TX_SEC_OFFLOAD: return "PKT_TX_SEC_OFFLOAD";
 	default: return NULL;
@@ -439,6 +441,10 @@ rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
 		  "PKT_TX_TUNNEL_NONE" },
 		{ PKT_TX_TUNNEL_MPLSINUDP, PKT_TX_TUNNEL_MASK,
 		  "PKT_TX_TUNNEL_NONE" },
+		{ PKT_TX_TUNNEL_IP, PKT_TX_TUNNEL_MASK,
+		  "PKT_TX_TUNNEL_NONE" },
+		{ PKT_TX_TUNNEL_UDP, PKT_TX_TUNNEL_MASK,
+		  "PKT_TX_TUNNEL_NONE" },
 		{ PKT_TX_MACSEC, PKT_TX_MACSEC, NULL },
 		{ PKT_TX_SEC_OFFLOAD, PKT_TX_SEC_OFFLOAD, NULL },
 	};
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 62740254d..6a8031c7a 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -210,6 +210,8 @@ extern "C" {
 #define PKT_TX_TUNNEL_GENEVE  (0x4ULL << 45)
 /**< TX packet with MPLS-in-UDP RFC 7510 header. */
 #define PKT_TX_TUNNEL_MPLSINUDP (0x5ULL << 45)
+#define PKT_TX_TUNNEL_IP (0xDULL << 45) /**< Tx IP tunneled packet. */
+#define PKT_TX_TUNNEL_UDP (0xEULL << 45) /**< Tx UDP tunneled packet. */
 /* add new TX TUNNEL type here */
 #define PKT_TX_TUNNEL_MASK    (0xFULL << 45)
 
-- 
2.13.3

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

* [dpdk-dev] [PATCH v4 2/4] app/testpmd: testpmd support Tx generic tunnel offloads
  2018-01-09 14:11 ` [dpdk-dev] [PATCH 1/6] net/mlx5: support tx swp tunnel offloading Xueming Li
                     ` (14 preceding siblings ...)
  2018-04-08 12:32   ` [dpdk-dev] [PATCH v4 1/4] ethdev: introduce generic IP/UDP tunnel checksum and TSO Xueming Li
@ 2018-04-08 12:32   ` Xueming Li
  2018-04-17 14:24     ` Iremonger, Bernard
  2018-04-08 12:32   ` [dpdk-dev] [PATCH v4 3/4] app/testpmd: add more GRE extension to csum engine Xueming Li
  2018-04-08 12:32   ` [dpdk-dev] [PATCH v4 4/4] app/testpmd: introduce VXLAN GPE to csum forwarding engine Xueming Li
  17 siblings, 1 reply; 80+ messages in thread
From: Xueming Li @ 2018-04-08 12:32 UTC (permalink / raw)
  To: Wenzhuo Lu, Jingjing Wu, Thomas Monjalon, Yongseok Koh,
	Olivier MATZ, Shahaf Shuler
  Cc: Xueming Li, Ferruh Yigit, dev

"show port cap" and "csum parse tunnel" command support TX generic
tunnel offloads

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
---
 app/test-pmd/cmdline.c  | 14 ++++++++++++--
 app/test-pmd/config.c   | 17 +++++++++++++++++
 app/test-pmd/csumonly.c |  3 ++-
 3 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 40b31ad7e..a81112220 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -4013,6 +4013,12 @@ check_tunnel_tso_nic_support(portid_t port_id)
 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
 		printf("Warning: GENEVE TUNNEL TSO not supported therefore "
 		       "not enabled for port %d\n", port_id);
+	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
+		printf("Warning: IP TUNNEL TSO not supported therefore "
+		       "not enabled for port %d\n", port_id);
+	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
+		printf("Warning: UDP TUNNEL TSO not supported therefore "
+		       "not enabled for port %d\n", port_id);
 	return dev_info;
 }
 
@@ -4040,13 +4046,17 @@ cmd_tunnel_tso_set_parsed(void *parsed_result,
 			~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
 			  DEV_TX_OFFLOAD_GRE_TNL_TSO |
 			  DEV_TX_OFFLOAD_IPIP_TNL_TSO |
-			  DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
+			  DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
+			  DEV_TX_OFFLOAD_IP_TNL_TSO |
+			  DEV_TX_OFFLOAD_UDP_TNL_TSO);
 		printf("TSO for tunneled packets is disabled\n");
 	} else {
 		uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
 					 DEV_TX_OFFLOAD_GRE_TNL_TSO |
 					 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
-					 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
+					 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
+					 DEV_TX_OFFLOAD_IP_TNL_TSO |
+					 DEV_TX_OFFLOAD_UDP_TNL_TSO);
 
 		ports[res->port_id].dev_conf.txmode.offloads |=
 			(tso_offloads & dev_info.tx_offload_capa);
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 4bb255c62..481d2b62d 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -722,6 +722,23 @@ port_offload_cap_display(portid_t port_id)
 			printf("off\n");
 	}
 
+	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO) {
+		printf("IP tunnel TSO:  ");
+		if (ports[port_id].dev_conf.txmode.offloads &
+		    DEV_TX_OFFLOAD_IP_TNL_TSO)
+			printf("on\n");
+		else
+			printf("off\n");
+	}
+
+	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO) {
+		printf("UDP tunnel TSO:  ");
+		if (ports[port_id].dev_conf.txmode.offloads &
+		    DEV_TX_OFFLOAD_UDP_TNL_TSO)
+			printf("on\n");
+		else
+			printf("off\n");
+	}
 }
 
 int
diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index 5f5ab64aa..7b2309372 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -693,7 +693,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 					info.l3_len);
 				parse_vxlan(udp_hdr, &info, m->packet_type);
 				if (info.is_tunnel)
-					tx_ol_flags |= PKT_TX_TUNNEL_VXLAN;
+					tx_ol_flags |= (PKT_TX_TUNNEL_VXLAN |
+							PKT_TX_OUTER_UDP);
 			} else if (info.l4_proto == IPPROTO_GRE) {
 				struct simple_gre_hdr *gre_hdr;
 
-- 
2.13.3

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

* [dpdk-dev] [PATCH v4 3/4] app/testpmd: add more GRE extension to csum engine
  2018-01-09 14:11 ` [dpdk-dev] [PATCH 1/6] net/mlx5: support tx swp tunnel offloading Xueming Li
                     ` (15 preceding siblings ...)
  2018-04-08 12:32   ` [dpdk-dev] [PATCH v4 2/4] app/testpmd: testpmd support Tx generic tunnel offloads Xueming Li
@ 2018-04-08 12:32   ` Xueming Li
  2018-04-16 22:45     ` Thomas Monjalon
  2018-04-08 12:32   ` [dpdk-dev] [PATCH v4 4/4] app/testpmd: introduce VXLAN GPE to csum forwarding engine Xueming Li
  17 siblings, 1 reply; 80+ messages in thread
From: Xueming Li @ 2018-04-08 12:32 UTC (permalink / raw)
  To: Wenzhuo Lu, Jingjing Wu, Thomas Monjalon, Yongseok Koh,
	Olivier MATZ, Shahaf Shuler
  Cc: Xueming Li, Ferruh Yigit, dev

This patch adds GRE checksum and sequence extension supports in addtion
to key extension to csum forwarding engine.

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
---
 app/test-pmd/csumonly.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index 7b2309372..00ec40d58 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -49,9 +49,12 @@
 #define IP_HDRLEN  0x05 /* default IP header length == five 32-bits words. */
 #define IP_VHL_DEF (IP_VERSION | IP_HDRLEN)
 
-#define GRE_KEY_PRESENT 0x2000
-#define GRE_KEY_LEN     4
-#define GRE_SUPPORTED_FIELDS GRE_KEY_PRESENT
+#define GRE_CHECKSUM_PRESENT	0x8000
+#define GRE_KEY_PRESENT		0x2000
+#define GRE_SEQUENCE_PRESENT	0x1000
+#define GRE_EXT_LEN		4
+#define GRE_SUPPORTED_FIELDS	(GRE_CHECKSUM_PRESENT | GRE_KEY_PRESENT |\
+				 GRE_SEQUENCE_PRESENT)
 
 /* We cannot use rte_cpu_to_be_16() on a constant in a switch/case */
 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
@@ -203,14 +206,14 @@ parse_gre(struct simple_gre_hdr *gre_hdr, struct testpmd_offload_info *info)
 	struct ipv6_hdr *ipv6_hdr;
 	uint8_t gre_len = 0;
 
-	/* check which fields are supported */
-	if ((gre_hdr->flags & _htons(~GRE_SUPPORTED_FIELDS)) != 0)
-		return;
-
 	gre_len += sizeof(struct simple_gre_hdr);
 
 	if (gre_hdr->flags & _htons(GRE_KEY_PRESENT))
-		gre_len += GRE_KEY_LEN;
+		gre_len += GRE_EXT_LEN;
+	if (gre_hdr->flags & _htons(GRE_SEQUENCE_PRESENT))
+		gre_len += GRE_EXT_LEN;
+	if (gre_hdr->flags & _htons(GRE_CHECKSUM_PRESENT))
+		gre_len += GRE_EXT_LEN;
 
 	if (gre_hdr->proto == _htons(ETHER_TYPE_IPv4)) {
 		info->is_tunnel = 1;
@@ -739,6 +742,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 
 		/* step 3: fill the mbuf meta data (flags and header lengths) */
 
+		m->tx_offload = 0;
 		if (info.is_tunnel == 1) {
 			if (info.tunnel_tso_segsz ||
 			    (tx_offloads &
-- 
2.13.3

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

* [dpdk-dev] [PATCH v4 4/4] app/testpmd: introduce VXLAN GPE to csum forwarding engine
  2018-01-09 14:11 ` [dpdk-dev] [PATCH 1/6] net/mlx5: support tx swp tunnel offloading Xueming Li
                     ` (16 preceding siblings ...)
  2018-04-08 12:32   ` [dpdk-dev] [PATCH v4 3/4] app/testpmd: add more GRE extension to csum engine Xueming Li
@ 2018-04-08 12:32   ` Xueming Li
  2018-04-16 22:46     ` Thomas Monjalon
  17 siblings, 1 reply; 80+ messages in thread
From: Xueming Li @ 2018-04-08 12:32 UTC (permalink / raw)
  To: Wenzhuo Lu, Jingjing Wu, Thomas Monjalon, Yongseok Koh,
	Olivier MATZ, Shahaf Shuler
  Cc: Xueming Li, Ferruh Yigit, dev

This patch introduced VXLAN-GPE support to csum forwarding engine by
recognizing VXLAN-GPE UDP port and parsing tunnel payload according to
next-protocol type.

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
---
 app/test-pmd/csumonly.c               | 96 +++++++++++++++++++++++++++++++++--
 app/test-pmd/parameters.c             | 12 ++++-
 app/test-pmd/testpmd.h                |  2 +
 doc/guides/testpmd_app_ug/run_app.rst |  5 ++
 4 files changed, 110 insertions(+), 5 deletions(-)

diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index 00ec40d58..d8b214e6d 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -56,6 +56,10 @@
 #define GRE_SUPPORTED_FIELDS	(GRE_CHECKSUM_PRESENT | GRE_KEY_PRESENT |\
 				 GRE_SEQUENCE_PRESENT)
 
+#define VXLAN_GPE_TYPE_IPv4 1
+#define VXLAN_GPE_TYPE_IPv6 2
+#define VXLAN_GPE_TYPE_ETH 3
+
 /* We cannot use rte_cpu_to_be_16() on a constant in a switch/case */
 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
 #define _htons(x) ((uint16_t)((((x) & 0x00ffU) << 8) | (((x) & 0xff00U) >> 8)))
@@ -63,6 +67,8 @@
 #define _htons(x) (x)
 #endif
 
+uint16_t vxlan_gpe_udp_port = 4790;
+
 /* structure that caches offload info for the current packet */
 struct testpmd_offload_info {
 	uint16_t ethertype;
@@ -87,6 +93,14 @@ struct simple_gre_hdr {
 	uint16_t proto;
 } __attribute__((__packed__));
 
+/* simplified VXLAN-GPE header */
+struct vxlan_gpe_hdr {
+	uint8_t vx_flags; /**< flag (8). */
+	uint8_t reserved[2]; /**< Reserved (16). */
+	uint8_t proto; /**< next-protocol (8). */
+	uint32_t vx_vni;   /**< VNI (24) + Reserved (8). */
+} __attribute__((__packed__));
+
 static uint16_t
 get_udptcp_checksum(void *l3_hdr, void *l4_hdr, uint16_t ethertype)
 {
@@ -197,6 +211,70 @@ parse_vxlan(struct udp_hdr *udp_hdr,
 	info->l2_len += ETHER_VXLAN_HLEN; /* add udp + vxlan */
 }
 
+/* Parse a vxlan-gpe header */
+static void
+parse_vxlan_gpe(struct udp_hdr *udp_hdr,
+	    struct testpmd_offload_info *info)
+{
+	struct ether_hdr *eth_hdr;
+	struct ipv4_hdr *ipv4_hdr;
+	struct ipv6_hdr *ipv6_hdr;
+	struct vxlan_gpe_hdr *vxlan_gpe_hdr;
+	uint8_t vxlan_gpe_len = sizeof(*vxlan_gpe_hdr);
+
+	/* check udp destination port, 4790 is the default vxlan-gpe port */
+	if (udp_hdr->dst_port != _htons(vxlan_gpe_udp_port))
+		return;
+
+	vxlan_gpe_hdr = (struct vxlan_gpe_hdr *)((char *)udp_hdr +
+				sizeof(struct udp_hdr));
+
+	if (!vxlan_gpe_hdr->proto || vxlan_gpe_hdr->proto ==
+	    VXLAN_GPE_TYPE_IPv4) {
+		info->is_tunnel = 1;
+		info->outer_ethertype = info->ethertype;
+		info->outer_l2_len = info->l2_len;
+		info->outer_l3_len = info->l3_len;
+		info->outer_l4_proto = info->l4_proto;
+
+		ipv4_hdr = (struct ipv4_hdr *)((char *)vxlan_gpe_hdr +
+			   vxlan_gpe_len);
+
+		parse_ipv4(ipv4_hdr, info);
+		info->ethertype = _htons(ETHER_TYPE_IPv4);
+		info->l2_len = 0;
+
+	} else if (vxlan_gpe_hdr->proto == VXLAN_GPE_TYPE_IPv6) {
+		info->is_tunnel = 1;
+		info->outer_ethertype = info->ethertype;
+		info->outer_l2_len = info->l2_len;
+		info->outer_l3_len = info->l3_len;
+		info->outer_l4_proto = info->l4_proto;
+
+		ipv6_hdr = (struct ipv6_hdr *)((char *)vxlan_gpe_hdr +
+			   vxlan_gpe_len);
+
+		info->ethertype = _htons(ETHER_TYPE_IPv6);
+		parse_ipv6(ipv6_hdr, info);
+		info->l2_len = 0;
+
+	} else if (vxlan_gpe_hdr->proto == VXLAN_GPE_TYPE_ETH) {
+		info->is_tunnel = 1;
+		info->outer_ethertype = info->ethertype;
+		info->outer_l2_len = info->l2_len;
+		info->outer_l3_len = info->l3_len;
+		info->outer_l4_proto = info->l4_proto;
+
+		eth_hdr = (struct ether_hdr *)((char *)vxlan_gpe_hdr +
+			  vxlan_gpe_len);
+
+		parse_ethernet(eth_hdr, info);
+	} else
+		return;
+
+	info->l2_len += ETHER_VXLAN_HLEN;
+}
+
 /* Parse a gre header */
 static void
 parse_gre(struct simple_gre_hdr *gre_hdr, struct testpmd_offload_info *info)
@@ -591,6 +669,10 @@ pkt_copy_split(const struct rte_mbuf *pkt)
  *   Ether / (vlan) / IP|IP6 / UDP|TCP|SCTP .
  *   Ether / (vlan) / outer IP|IP6 / outer UDP / VxLAN / Ether / IP|IP6 /
  *           UDP|TCP|SCTP
+ *   Ether / (vlan) / outer IP|IP6 / outer UDP / VXLAN-GPE / Ether / IP|IP6 /
+ *           UDP|TCP|SCTP
+ *   Ether / (vlan) / outer IP|IP6 / outer UDP / VXLAN-GPE / IP|IP6 /
+ *           UDP|TCP|SCTP
  *   Ether / (vlan) / outer IP|IP6 / GRE / Ether / IP|IP6 / UDP|TCP|SCTP
  *   Ether / (vlan) / outer IP|IP6 / GRE / IP|IP6 / UDP|TCP|SCTP
  *   Ether / (vlan) / outer IP|IP6 / IP|IP6 / UDP|TCP|SCTP
@@ -694,10 +776,16 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 
 				udp_hdr = (struct udp_hdr *)((char *)l3_hdr +
 					info.l3_len);
-				parse_vxlan(udp_hdr, &info, m->packet_type);
-				if (info.is_tunnel)
-					tx_ol_flags |= (PKT_TX_TUNNEL_VXLAN |
-							PKT_TX_OUTER_UDP);
+				parse_vxlan_gpe(udp_hdr, &info);
+				if (info.is_tunnel) {
+					tx_ol_flags |= PKT_TX_TUNNEL_UDP;
+				} else {
+					parse_vxlan(udp_hdr, &info,
+						    m->packet_type);
+					if (info.is_tunnel)
+						tx_ol_flags |=
+							PKT_TX_TUNNEL_VXLAN;
+				}
 			} else if (info.l4_proto == IPPROTO_GRE) {
 				struct simple_gre_hdr *gre_hdr;
 
diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
index 97d22b860..d7489bcec 100644
--- a/app/test-pmd/parameters.c
+++ b/app/test-pmd/parameters.c
@@ -70,7 +70,7 @@ usage(char* progname)
 	       "--rss-ip | --rss-udp | "
 	       "--rxpt= | --rxht= | --rxwt= | --rxfreet= | "
 	       "--txpt= | --txht= | --txwt= | --txfreet= | "
-	       "--txrst= | --tx-offloads ]\n",
+	       "--txrst= | --tx-offloads= | --vxlan-gpe-port= ]\n",
 	       progname);
 #ifdef RTE_LIBRTE_CMDLINE
 	printf("  --interactive: run in interactive mode.\n");
@@ -186,6 +186,7 @@ usage(char* progname)
 	printf("  --flow-isolate-all: "
 	       "requests flow API isolated mode on all ports at initialization time.\n");
 	printf("  --tx-offloads=0xXXXXXXXX: hexadecimal bitmask of TX queue offloads\n");
+	printf("  --vxlan-gpe-port=N: UPD port of tunnel VXLAN-GPE\n");
 }
 
 #ifdef RTE_LIBRTE_CMDLINE
@@ -621,6 +622,7 @@ launch_args_parse(int argc, char** argv)
 		{ "print-event",		1, 0, 0 },
 		{ "mask-event",			1, 0, 0 },
 		{ "tx-offloads",		1, 0, 0 },
+		{ "vxlan-gpe-port",		1, 0, 0 },
 		{ 0, 0, 0, 0 },
 	};
 
@@ -1092,6 +1094,14 @@ launch_args_parse(int argc, char** argv)
 					rte_exit(EXIT_FAILURE,
 						 "tx-offloads must be >= 0\n");
 			}
+			if (!strcmp(lgopts[opt_idx].name, "vxlan-gpe-port")) {
+				n = atoi(optarg);
+				if (n >= 0)
+					vxlan_gpe_udp_port = (uint16_t)n;
+				else
+					rte_exit(EXIT_FAILURE,
+						 "vxlan-gpe-port must be >= 0\n");
+			}
 			if (!strcmp(lgopts[opt_idx].name, "print-event"))
 				if (parse_event_printing_config(optarg, 1)) {
 					rte_exit(EXIT_FAILURE,
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 153abea05..4cec239fe 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -433,6 +433,8 @@ extern uint32_t retry_enabled;
 extern struct fwd_lcore  **fwd_lcores;
 extern struct fwd_stream **fwd_streams;
 
+extern uint16_t vxlan_gpe_udp_port; /**< UDP port of tunnel VXLAN-GPE. */
+
 extern portid_t nb_peer_eth_addrs; /**< Number of peer ethernet addresses. */
 extern struct ether_addr peer_eth_addrs[RTE_MAX_ETHPORTS];
 
diff --git a/doc/guides/testpmd_app_ug/run_app.rst b/doc/guides/testpmd_app_ug/run_app.rst
index 1fd53958a..2e8690f41 100644
--- a/doc/guides/testpmd_app_ug/run_app.rst
+++ b/doc/guides/testpmd_app_ug/run_app.rst
@@ -479,3 +479,8 @@ The commandline options are:
 
     Set the hexadecimal bitmask of TX queue offloads.
     The default value is 0.
+
+*   ``--vxlan-gpe-port=N``
+
+    Set the UDP port number of tunnel VXLAN-GPE to N.
+    The default value is 4790.
-- 
2.13.3

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

* Re: [dpdk-dev] [PATCH v4 1/4] ethdev: introduce generic IP/UDP tunnel checksum and TSO
  2018-04-08 12:32   ` [dpdk-dev] [PATCH v4 1/4] ethdev: introduce generic IP/UDP tunnel checksum and TSO Xueming Li
@ 2018-04-16 22:42     ` Thomas Monjalon
  2018-04-17  7:53       ` Xueming(Steven) Li
  0 siblings, 1 reply; 80+ messages in thread
From: Thomas Monjalon @ 2018-04-16 22:42 UTC (permalink / raw)
  To: Xueming Li
  Cc: dev, Wenzhuo Lu, Jingjing Wu, Yongseok Koh, Olivier MATZ,
	Shahaf Shuler, Ferruh Yigit

08/04/2018 14:32, Xueming Li:
> --- a/lib/librte_mbuf/rte_mbuf.h
> +++ b/lib/librte_mbuf/rte_mbuf.h
> @@ -210,6 +210,8 @@ extern "C" {
>  #define PKT_TX_TUNNEL_GENEVE  (0x4ULL << 45)
>  /**< TX packet with MPLS-in-UDP RFC 7510 header. */
>  #define PKT_TX_TUNNEL_MPLSINUDP (0x5ULL << 45)
> +#define PKT_TX_TUNNEL_IP (0xDULL << 45) /**< Tx IP tunneled packet. */
> +#define PKT_TX_TUNNEL_UDP (0xEULL << 45) /**< Tx UDP tunneled packet. */

I think you need to explain in details, in the comments,
what we can expect when using these flags.
Please write the doxygen comment on the lines before the flag.

Any reason for using 0xD and 0xE values?
Because they are more generic than the first ones?

>  /* add new TX TUNNEL type here */
>  #define PKT_TX_TUNNEL_MASK    (0xFULL << 45)

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

* Re: [dpdk-dev] [PATCH v4 3/4] app/testpmd: add more GRE extension to csum engine
  2018-04-08 12:32   ` [dpdk-dev] [PATCH v4 3/4] app/testpmd: add more GRE extension to csum engine Xueming Li
@ 2018-04-16 22:45     ` Thomas Monjalon
  2018-04-17  5:19       ` Xueming(Steven) Li
  0 siblings, 1 reply; 80+ messages in thread
From: Thomas Monjalon @ 2018-04-16 22:45 UTC (permalink / raw)
  To: Xueming Li
  Cc: dev, Wenzhuo Lu, Jingjing Wu, Yongseok Koh, Olivier MATZ,
	Shahaf Shuler, Ferruh Yigit

08/04/2018 14:32, Xueming Li:
> This patch adds GRE checksum and sequence extension supports in addtion
> to key extension to csum forwarding engine.
> 
> Signed-off-by: Xueming Li <xuemingl@mellanox.com>

This patch is also part of another series, isn't it?
("introduce new tunnel types")

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

* Re: [dpdk-dev] [PATCH v4 4/4] app/testpmd: introduce VXLAN GPE to csum forwarding engine
  2018-04-08 12:32   ` [dpdk-dev] [PATCH v4 4/4] app/testpmd: introduce VXLAN GPE to csum forwarding engine Xueming Li
@ 2018-04-16 22:46     ` Thomas Monjalon
  2018-04-17 13:56       ` Iremonger, Bernard
  0 siblings, 1 reply; 80+ messages in thread
From: Thomas Monjalon @ 2018-04-16 22:46 UTC (permalink / raw)
  To: Xueming Li
  Cc: dev, Wenzhuo Lu, Jingjing Wu, Yongseok Koh, Olivier MATZ,
	Shahaf Shuler, Ferruh Yigit

08/04/2018 14:32, Xueming Li:
> This patch introduced VXLAN-GPE support to csum forwarding engine by
> recognizing VXLAN-GPE UDP port and parsing tunnel payload according to
> next-protocol type.
> 
> Signed-off-by: Xueming Li <xuemingl@mellanox.com>

This is not the right series for this patch.
It is already in the "new tunnel types" patchset.

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

* Re: [dpdk-dev] [PATCH v4 3/4] app/testpmd: add more GRE extension to csum engine
  2018-04-16 22:45     ` Thomas Monjalon
@ 2018-04-17  5:19       ` Xueming(Steven) Li
  0 siblings, 0 replies; 80+ messages in thread
From: Xueming(Steven) Li @ 2018-04-17  5:19 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: dev, Wenzhuo Lu, Jingjing Wu, Yongseok Koh, Olivier MATZ,
	Shahaf Shuler, Ferruh Yigit



> -----Original Message-----
> From: Thomas Monjalon <thomas@monjalon.net>
> Sent: Tuesday, April 17, 2018 6:45 AM
> To: Xueming(Steven) Li <xuemingl@mellanox.com>
> Cc: dev@dpdk.org; Wenzhuo Lu <wenzhuo.lu@intel.com>; Jingjing Wu <jingjing.wu@intel.com>; Yongseok Koh
> <yskoh@mellanox.com>; Olivier MATZ <olivier.matz@6wind.com>; Shahaf Shuler <shahafs@mellanox.com>;
> Ferruh Yigit <ferruh.yigit@intel.com>
> Subject: Re: [dpdk-dev] [PATCH v4 3/4] app/testpmd: add more GRE extension to csum engine
> 
> 08/04/2018 14:32, Xueming Li:
> > This patch adds GRE checksum and sequence extension supports in
> > addtion to key extension to csum forwarding engine.
> >
> > Signed-off-by: Xueming Li <xuemingl@mellanox.com>
> 
> This patch is also part of another series, isn't it?
> ("introduce new tunnel types")
> 

Good catch, it was there for test purpose, I'll remove this one and the next.

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

* Re: [dpdk-dev] [PATCH v4 1/4] ethdev: introduce generic IP/UDP tunnel checksum and TSO
  2018-04-16 22:42     ` Thomas Monjalon
@ 2018-04-17  7:53       ` Xueming(Steven) Li
  2018-04-17  8:10         ` Thomas Monjalon
  0 siblings, 1 reply; 80+ messages in thread
From: Xueming(Steven) Li @ 2018-04-17  7:53 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: dev, Wenzhuo Lu, Jingjing Wu, Yongseok Koh, Olivier MATZ,
	Shahaf Shuler, Ferruh Yigit



> -----Original Message-----
> From: Thomas Monjalon <thomas@monjalon.net>
> Sent: Tuesday, April 17, 2018 6:43 AM
> To: Xueming(Steven) Li <xuemingl@mellanox.com>
> Cc: dev@dpdk.org; Wenzhuo Lu <wenzhuo.lu@intel.com>; Jingjing Wu <jingjing.wu@intel.com>; Yongseok Koh
> <yskoh@mellanox.com>; Olivier MATZ <olivier.matz@6wind.com>; Shahaf Shuler <shahafs@mellanox.com>;
> Ferruh Yigit <ferruh.yigit@intel.com>
> Subject: Re: [dpdk-dev] [PATCH v4 1/4] ethdev: introduce generic IP/UDP tunnel checksum and TSO
> 
> 08/04/2018 14:32, Xueming Li:
> > --- a/lib/librte_mbuf/rte_mbuf.h
> > +++ b/lib/librte_mbuf/rte_mbuf.h
> > @@ -210,6 +210,8 @@ extern "C" {
> >  #define PKT_TX_TUNNEL_GENEVE  (0x4ULL << 45)  /**< TX packet with
> > MPLS-in-UDP RFC 7510 header. */  #define PKT_TX_TUNNEL_MPLSINUDP
> > (0x5ULL << 45)
> > +#define PKT_TX_TUNNEL_IP (0xDULL << 45) /**< Tx IP tunneled packet.
> > +*/ #define PKT_TX_TUNNEL_UDP (0xEULL << 45) /**< Tx UDP tunneled
> > +packet. */
> 
> I think you need to explain in details, in the comments, what we can expect when using these flags.
> Please write the doxygen comment on the lines before the flag.

Got it.

> 
> Any reason for using 0xD and 0xE values?
> Because they are more generic than the first ones?

Yes, do you think it better to continue with previous ones?

> 
> >  /* add new TX TUNNEL type here */
> >  #define PKT_TX_TUNNEL_MASK    (0xFULL << 45)
> 
> 


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

* Re: [dpdk-dev] [PATCH v4 1/4] ethdev: introduce generic IP/UDP tunnel checksum and TSO
  2018-04-17  7:53       ` Xueming(Steven) Li
@ 2018-04-17  8:10         ` Thomas Monjalon
  0 siblings, 0 replies; 80+ messages in thread
From: Thomas Monjalon @ 2018-04-17  8:10 UTC (permalink / raw)
  To: Xueming(Steven) Li, Olivier MATZ
  Cc: dev, Wenzhuo Lu, Jingjing Wu, Yongseok Koh, Shahaf Shuler, Ferruh Yigit

17/04/2018 09:53, Xueming(Steven) Li:
> From: Thomas Monjalon <thomas@monjalon.net>
> > 08/04/2018 14:32, Xueming Li:
> > > --- a/lib/librte_mbuf/rte_mbuf.h
> > > +++ b/lib/librte_mbuf/rte_mbuf.h
> > > @@ -210,6 +210,8 @@ extern "C" {
> > >  #define PKT_TX_TUNNEL_GENEVE  (0x4ULL << 45)  /**< TX packet with
> > > MPLS-in-UDP RFC 7510 header. */  #define PKT_TX_TUNNEL_MPLSINUDP
> > > (0x5ULL << 45)
> > > +#define PKT_TX_TUNNEL_IP (0xDULL << 45) /**< Tx IP tunneled packet.
> > > +*/ #define PKT_TX_TUNNEL_UDP (0xEULL << 45) /**< Tx UDP tunneled
> > > +packet. */
> > 
> > I think you need to explain in details, in the comments, what we can expect when using these flags.
> > Please write the doxygen comment on the lines before the flag.
> 
> Got it.
> 
> > 
> > Any reason for using 0xD and 0xE values?
> > Because they are more generic than the first ones?
> 
> Yes, do you think it better to continue with previous ones?

No strong opinion.
Olivier?

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

* Re: [dpdk-dev] [PATCH v4 4/4] app/testpmd: introduce VXLAN GPE to csum forwarding engine
  2018-04-16 22:46     ` Thomas Monjalon
@ 2018-04-17 13:56       ` Iremonger, Bernard
  2018-04-17 14:12         ` Xueming(Steven) Li
  0 siblings, 1 reply; 80+ messages in thread
From: Iremonger, Bernard @ 2018-04-17 13:56 UTC (permalink / raw)
  To: Thomas Monjalon, Xueming Li
  Cc: dev, Lu, Wenzhuo, Wu,  Jingjing, Yongseok Koh, Olivier MATZ,
	Shahaf Shuler, Yigit, Ferruh

Hi Li,

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Thomas Monjalon
> Sent: Monday, April 16, 2018 11:46 PM
> To: Xueming Li <xuemingl@mellanox.com>
> Cc: dev@dpdk.org; Lu, Wenzhuo <wenzhuo.lu@intel.com>; Wu, Jingjing
> <jingjing.wu@intel.com>; Yongseok Koh <yskoh@mellanox.com>; Olivier MATZ
> <olivier.matz@6wind.com>; Shahaf Shuler <shahafs@mellanox.com>; Yigit,
> Ferruh <ferruh.yigit@intel.com>
> Subject: Re: [dpdk-dev] [PATCH v4 4/4] app/testpmd: introduce VXLAN GPE to
> csum forwarding engine
> 
> 08/04/2018 14:32, Xueming Li:
> > This patch introduced VXLAN-GPE support to csum forwarding engine by
> > recognizing VXLAN-GPE UDP port and parsing tunnel payload according to
> > next-protocol type.
> >
> > Signed-off-by: Xueming Li <xuemingl@mellanox.com>
> 
> This is not the right series for this patch.
> It is already in the "new tunnel types" patchset.
> 
> 
This patch fails to apply to the current master branch.

Regards,

Bernard.

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

* Re: [dpdk-dev] [PATCH v4 4/4] app/testpmd: introduce VXLAN GPE to csum forwarding engine
  2018-04-17 13:56       ` Iremonger, Bernard
@ 2018-04-17 14:12         ` Xueming(Steven) Li
  0 siblings, 0 replies; 80+ messages in thread
From: Xueming(Steven) Li @ 2018-04-17 14:12 UTC (permalink / raw)
  To: Iremonger, Bernard, Thomas Monjalon
  Cc: dev, Lu, Wenzhuo, Wu,  Jingjing, Yongseok Koh, Olivier MATZ,
	Shahaf Shuler, Yigit, Ferruh


> -----Original Message-----
> From: Iremonger, Bernard <bernard.iremonger@intel.com>
> Sent: Tuesday, April 17, 2018 9:56 PM
> To: Thomas Monjalon <thomas@monjalon.net>; Xueming(Steven) Li <xuemingl@mellanox.com>
> Cc: dev@dpdk.org; Lu, Wenzhuo <wenzhuo.lu@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>; Yongseok
> Koh <yskoh@mellanox.com>; Olivier MATZ <olivier.matz@6wind.com>; Shahaf Shuler <shahafs@mellanox.com>;
> Yigit, Ferruh <ferruh.yigit@intel.com>
> Subject: RE: [dpdk-dev] [PATCH v4 4/4] app/testpmd: introduce VXLAN GPE to csum forwarding engine
> 
> Hi Li,
> 
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Thomas Monjalon
> > Sent: Monday, April 16, 2018 11:46 PM
> > To: Xueming Li <xuemingl@mellanox.com>
> > Cc: dev@dpdk.org; Lu, Wenzhuo <wenzhuo.lu@intel.com>; Wu, Jingjing
> > <jingjing.wu@intel.com>; Yongseok Koh <yskoh@mellanox.com>; Olivier
> > MATZ <olivier.matz@6wind.com>; Shahaf Shuler <shahafs@mellanox.com>;
> > Yigit, Ferruh <ferruh.yigit@intel.com>
> > Subject: Re: [dpdk-dev] [PATCH v4 4/4] app/testpmd: introduce VXLAN
> > GPE to csum forwarding engine
> >
> > 08/04/2018 14:32, Xueming Li:
> > > This patch introduced VXLAN-GPE support to csum forwarding engine by
> > > recognizing VXLAN-GPE UDP port and parsing tunnel payload according
> > > to next-protocol type.
> > >
> > > Signed-off-by: Xueming Li <xuemingl@mellanox.com>
> >
> > This is not the right series for this patch.
> > It is already in the "new tunnel types" patchset.
> >
> >
> This patch fails to apply to the current master branch.


I'll send out a new version today, thanks.

> 
> Regards,
> 
> Bernard.
> 


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

* Re: [dpdk-dev] [PATCH v4 2/4] app/testpmd: testpmd support Tx generic tunnel offloads
  2018-04-08 12:32   ` [dpdk-dev] [PATCH v4 2/4] app/testpmd: testpmd support Tx generic tunnel offloads Xueming Li
@ 2018-04-17 14:24     ` Iremonger, Bernard
  2018-04-17 15:44       ` Xueming(Steven) Li
  0 siblings, 1 reply; 80+ messages in thread
From: Iremonger, Bernard @ 2018-04-17 14:24 UTC (permalink / raw)
  To: Xueming Li, Lu, Wenzhuo, Wu, Jingjing, Thomas Monjalon,
	Yongseok Koh, Olivier MATZ, Shahaf Shuler
  Cc: Yigit, Ferruh, dev

Hi Lu,

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Xueming Li
> Sent: Sunday, April 8, 2018 1:33 PM
> To: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Wu, Jingjing
> <jingjing.wu@intel.com>; Thomas Monjalon <thomas@monjalon.net>;
> Yongseok Koh <yskoh@mellanox.com>; Olivier MATZ
> <olivier.matz@6wind.com>; Shahaf Shuler <shahafs@mellanox.com>
> Cc: Xueming Li <xuemingl@mellanox.com>; Yigit, Ferruh
> <ferruh.yigit@intel.com>; dev@dpdk.org
> Subject: [dpdk-dev] [PATCH v4 2/4] app/testpmd: testpmd support Tx generic
> tunnel offloads
> 
> "show port cap" and "csum parse tunnel" command support TX generic tunnel
> offloads
> 
> Signed-off-by: Xueming Li <xuemingl@mellanox.com>
> ---
>  app/test-pmd/cmdline.c  | 14 ++++++++++++--
>  app/test-pmd/config.c   | 17 +++++++++++++++++
>  app/test-pmd/csumonly.c |  3 ++-
>  3 files changed, 31 insertions(+), 3 deletions(-)
> 
> diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index
> 40b31ad7e..a81112220 100644
> --- a/app/test-pmd/cmdline.c
> +++ b/app/test-pmd/cmdline.c
> @@ -4013,6 +4013,12 @@ check_tunnel_tso_nic_support(portid_t port_id)
>  	if (!(dev_info.tx_offload_capa &
> DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
>  		printf("Warning: GENEVE TUNNEL TSO not supported therefore
> "
>  		       "not enabled for port %d\n", port_id);
> +	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
> +		printf("Warning: IP TUNNEL TSO not supported therefore "
> +		       "not enabled for port %d\n", port_id);
> +	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
> +		printf("Warning: UDP TUNNEL TSO not supported therefore "
> +		       "not enabled for port %d\n", port_id);
>  	return dev_info;
>  }
> 
> @@ -4040,13 +4046,17 @@ cmd_tunnel_tso_set_parsed(void *parsed_result,
>  			~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
>  			  DEV_TX_OFFLOAD_GRE_TNL_TSO |
>  			  DEV_TX_OFFLOAD_IPIP_TNL_TSO |
> -			  DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
> +			  DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
> +			  DEV_TX_OFFLOAD_IP_TNL_TSO |
> +			  DEV_TX_OFFLOAD_UDP_TNL_TSO);
>  		printf("TSO for tunneled packets is disabled\n");
>  	} else {
>  		uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
>  					 DEV_TX_OFFLOAD_GRE_TNL_TSO |
>  					 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
> -
> DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
> +					 DEV_TX_OFFLOAD_GENEVE_TNL_TSO
> |
> +					 DEV_TX_OFFLOAD_IP_TNL_TSO |
> +					 DEV_TX_OFFLOAD_UDP_TNL_TSO);
> 
>  		ports[res->port_id].dev_conf.txmode.offloads |=
>  			(tso_offloads & dev_info.tx_offload_capa); diff --git
> a/app/test-pmd/config.c b/app/test-pmd/config.c index 4bb255c62..481d2b62d
> 100644
> --- a/app/test-pmd/config.c
> +++ b/app/test-pmd/config.c
> @@ -722,6 +722,23 @@ port_offload_cap_display(portid_t port_id)
>  			printf("off\n");
>  	}
> 
> +	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO) {
> +		printf("IP tunnel TSO:  ");
> +		if (ports[port_id].dev_conf.txmode.offloads &
> +		    DEV_TX_OFFLOAD_IP_TNL_TSO)
> +			printf("on\n");
> +		else
> +			printf("off\n");
> +	}
> +
> +	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO) {
> +		printf("UDP tunnel TSO:  ");
> +		if (ports[port_id].dev_conf.txmode.offloads &
> +		    DEV_TX_OFFLOAD_UDP_TNL_TSO)
> +			printf("on\n");
> +		else
> +			printf("off\n");
> +	}
>  }
> 
>  int
> diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index
> 5f5ab64aa..7b2309372 100644
> --- a/app/test-pmd/csumonly.c
> +++ b/app/test-pmd/csumonly.c
> @@ -693,7 +693,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
>  					info.l3_len);
>  				parse_vxlan(udp_hdr, &info, m->packet_type);
>  				if (info.is_tunnel)
> -					tx_ol_flags |=
> PKT_TX_TUNNEL_VXLAN;
> +					tx_ol_flags |=
> (PKT_TX_TUNNEL_VXLAN |
> +							PKT_TX_OUTER_UDP);
>  			} else if (info.l4_proto == IPPROTO_GRE) {
>  				struct simple_gre_hdr *gre_hdr;
> 
> --
> 2.13.3

This patch fails to compile on latest master branch.

/root/dpdk_sforge_2/app/test-pmd/csumonly.c: In function 'pkt_burst_checksum_forward':
/root/dpdk_sforge_2/app/test-pmd/csumonly.c:700:8: error: 'PKT_TX_OUTER_UDP' undeclared (first use in this function)
        PKT_TX_OUTER_UDP);
        ^
/root/dpdk_sforge_2/app/test-pmd/csumonly.c:700:8: note: each undeclared identifier is reported only once for each function it appears in
make[5]: *** [csumonly.o] Error 1
make[4]: *** [test-pmd] Error 2
make[3]: *** [app] Error 2
make[2]: *** [all] Error 2
make[1]: *** [pre_install] Error 2
make: *** [install] Error 2

Regards,

Bernard.

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

* [dpdk-dev] [PATCH v5 0/2] support Tx generic tunnel checksum and TSO
  2018-04-08 12:32   ` [dpdk-dev] [PATCH v4 0/4] support Tx generic tunnel checksum and TSO Xueming Li
@ 2018-04-17 14:43     ` Xueming Li
  2018-04-17 14:47     ` [dpdk-dev] [PATCH v5 1/2] ethdev: introduce generic IP/UDP " Xueming Li
                       ` (4 subsequent siblings)
  5 siblings, 0 replies; 80+ messages in thread
From: Xueming Li @ 2018-04-17 14:43 UTC (permalink / raw)
  To: Wenzhuo Lu, Jingjing Wu, Thomas Monjalon, Yongseok Koh,
	Olivier MATZ, Shahaf Shuler, Iremonger, Bernard
  Cc: Xueming Li, Ferruh Yigit, dev

V5:
- Removed duplicated testpmd patch in other pathset.
- More comments on PKT_TX_TUNNEL_IP and PKT_TX_TUNNEL_UDP

V4:
- Removed DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM and DEV_TX_OFFLOAD_GENERIC_TNL_TSO
- Replaced with DEV_TX_OFFLOAD_IP_TNL_TSO
- Removed PKT_TX_OUTER_UDP
- Splited PKT_TX_TUNNEL_UNKNOWN into PKT_TX_TUNNEL_IP and PKT_TX_TUNNEL_UDP

V3:
- Add VXLAN-GPE and GRE extention support to testpmd csum forwarding enginee
- Split DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO into DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM
  and DEV_TX_OFFLOAD_GENERIC_TNL_TSO
- Add PKT_TX_TUNNEL_UNKNOWN and PKT_TX_OUTER_UDP

  http://www.dpdk.org/dev/patchwork/patch/34655/


This patchset introduces new HW capability of generic tunnel cheksum and TSO offloads, HW supporting generic tunnel checksum and TSO could handle new tunnel type offloading w/o
 upgrading HW.
New Generic tunnel checksum and TSO offload support IP tunnel and UDP tunnel. Please note that tunnel type that has length, sequence id or checksum are not considered as generi
c tunnel type.


Xueming Li (2):
  ethdev: introduce generic IP/UDP tunnel checksum and TSO
  app/testpmd: testpmd support Tx generic tunnel offloads

 app/test-pmd/cmdline.c        | 14 ++++++++++++--
 app/test-pmd/config.c         | 17 +++++++++++++++++
 lib/librte_ether/rte_ethdev.h |  4 ++++
 lib/librte_mbuf/rte_mbuf.c    |  6 ++++++
 lib/librte_mbuf/rte_mbuf.h    | 16 ++++++++++++++++
 5 files changed, 55 insertions(+), 2 deletions(-)

-- 
2.13.3

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

* [dpdk-dev] [PATCH v5 1/2] ethdev: introduce generic IP/UDP tunnel checksum and TSO
  2018-04-08 12:32   ` [dpdk-dev] [PATCH v4 0/4] support Tx generic tunnel checksum and TSO Xueming Li
  2018-04-17 14:43     ` [dpdk-dev] [PATCH v5 0/2] " Xueming Li
@ 2018-04-17 14:47     ` Xueming Li
  2018-04-17 21:21       ` Thomas Monjalon
  2018-04-17 14:49     ` [dpdk-dev] [PATCH v5 2/2] app/testpmd: testpmd support Tx generic tunnel offloads Xueming Li
                       ` (3 subsequent siblings)
  5 siblings, 1 reply; 80+ messages in thread
From: Xueming Li @ 2018-04-17 14:47 UTC (permalink / raw)
  To: Wenzhuo Lu, Jingjing Wu, Thomas Monjalon, Yongseok Koh,
	Olivier MATZ, Shahaf Shuler, Iremonger, Bernard
  Cc: Xueming Li, Ferruh Yigit, dev

This patch introduce new TX offload flags for device that supports
IP or UDP tunneled packet L3/L4 checksum and TSO offload.

The support from the device is for inner and outer checksums on
IPV4/TCP/UDP and TSO for *any packet with the following format*:

<some headers> / [optional IPv4/IPv6] / [optional TCP/UDP] / <some
headers> / [optional inner IPv4/IPv6] / [optional TCP/UDP]

For example the following packets can use this feature:

1. eth / ipv4 / udp / VXLAN / ip / tcp
2. eth / ipv4 / GRE / MPLS / ipv4 / udp

Please note that tunnel headers that contain payload length, sequence id
or checksum will not be updated.

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
---
 lib/librte_ether/rte_ethdev.h |  4 ++++
 lib/librte_mbuf/rte_mbuf.c    |  6 ++++++
 lib/librte_mbuf/rte_mbuf.h    | 16 ++++++++++++++++
 3 files changed, 26 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 4f417f573..51db97a6a 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -980,6 +980,10 @@ struct rte_eth_conf {
  *   the same mempool and has refcnt = 1.
  */
 #define DEV_TX_OFFLOAD_SECURITY         0x00020000
+/**< Device supports UDP tunneled packet TSO */
+#define DEV_TX_OFFLOAD_UDP_TNL_TSO      0x00040000
+/**< Device supports IP based tunnel packet TSO */
+#define DEV_TX_OFFLOAD_IP_TNL_TSO       0x00080000
 
 /*
  * If new Tx offload capabilities are defined, they also must be
diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index 3f4c83305..64e960d4c 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -390,6 +390,8 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask)
 	case PKT_TX_TUNNEL_IPIP: return "PKT_TX_TUNNEL_IPIP";
 	case PKT_TX_TUNNEL_GENEVE: return "PKT_TX_TUNNEL_GENEVE";
 	case PKT_TX_TUNNEL_MPLSINUDP: return "PKT_TX_TUNNEL_MPLSINUDP";
+	case PKT_TX_TUNNEL_IP: return "PKT_TX_TUNNEL_IP";
+	case PKT_TX_TUNNEL_UDP: return "PKT_TX_TUNNEL_UDP";
 	case PKT_TX_MACSEC: return "PKT_TX_MACSEC";
 	case PKT_TX_SEC_OFFLOAD: return "PKT_TX_SEC_OFFLOAD";
 	default: return NULL;
@@ -424,6 +426,10 @@ rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
 		  "PKT_TX_TUNNEL_NONE" },
 		{ PKT_TX_TUNNEL_MPLSINUDP, PKT_TX_TUNNEL_MASK,
 		  "PKT_TX_TUNNEL_NONE" },
+		{ PKT_TX_TUNNEL_IP, PKT_TX_TUNNEL_MASK,
+		  "PKT_TX_TUNNEL_NONE" },
+		{ PKT_TX_TUNNEL_UDP, PKT_TX_TUNNEL_MASK,
+		  "PKT_TX_TUNNEL_NONE" },
 		{ PKT_TX_MACSEC, PKT_TX_MACSEC, NULL },
 		{ PKT_TX_SEC_OFFLOAD, PKT_TX_SEC_OFFLOAD, NULL },
 	};
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 06eceba37..639e18f7c 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -210,6 +210,22 @@ extern "C" {
 #define PKT_TX_TUNNEL_GENEVE  (0x4ULL << 45)
 /**< TX packet with MPLS-in-UDP RFC 7510 header. */
 #define PKT_TX_TUNNEL_MPLSINUDP (0x5ULL << 45)
+/**
+ * Generic IP encapsulated tunnel type, used for TSO offload instead
+ * of defining new tunnel types. This feature relies on offloading
+ * DEV_TX_OFFLOAD_IP_TNL_TSO present.
+ * Tunnel header that contains payload length, sequence id or checksum
+ * is not expected to be updated.
+ */
+#define PKT_TX_TUNNEL_IP (0xDULL << 45)
+/**
+ * Generic UDP encapsulated tunnel type, used for TSO offload instead
+ * of defining new tunnel types. This feature relies on offloading
+ * DEV_TX_OFFLOAD_UDP_TNL_TSO present.
+ * Tunnel header that contains payload length, sequence id or checksum
+ * is not expected to be updated.
+ */
+#define PKT_TX_TUNNEL_UDP (0xEULL << 45)
 /* add new TX TUNNEL type here */
 #define PKT_TX_TUNNEL_MASK    (0xFULL << 45)
 
-- 
2.13.3

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

* [dpdk-dev] [PATCH v5 2/2] app/testpmd: testpmd support Tx generic tunnel offloads
  2018-04-08 12:32   ` [dpdk-dev] [PATCH v4 0/4] support Tx generic tunnel checksum and TSO Xueming Li
  2018-04-17 14:43     ` [dpdk-dev] [PATCH v5 0/2] " Xueming Li
  2018-04-17 14:47     ` [dpdk-dev] [PATCH v5 1/2] ethdev: introduce generic IP/UDP " Xueming Li
@ 2018-04-17 14:49     ` Xueming Li
  2018-04-18 13:38     ` [dpdk-dev] [PATCH v6 0/2] support Tx generic tunnel checksum and TSO Xueming Li
                       ` (2 subsequent siblings)
  5 siblings, 0 replies; 80+ messages in thread
From: Xueming Li @ 2018-04-17 14:49 UTC (permalink / raw)
  To: Wenzhuo Lu, Jingjing Wu, Thomas Monjalon, Yongseok Koh,
	Olivier MATZ, Shahaf Shuler, Iremonger, Bernard
  Cc: Xueming Li, Ferruh Yigit, dev

"show port cap" and "csum parse tunnel" command support TX generic
tunnel offloads

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
---
 app/test-pmd/cmdline.c | 14 ++++++++++++--
 app/test-pmd/config.c  | 17 +++++++++++++++++
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 512e3b55e..4ec3dab56 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -4157,6 +4157,12 @@ check_tunnel_tso_nic_support(portid_t port_id)
 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
 		printf("Warning: GENEVE TUNNEL TSO not supported therefore "
 		       "not enabled for port %d\n", port_id);
+	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
+		printf("Warning: IP TUNNEL TSO not supported therefore "
+		       "not enabled for port %d\n", port_id);
+	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
+		printf("Warning: UDP TUNNEL TSO not supported therefore "
+		       "not enabled for port %d\n", port_id);
 	return dev_info;
 }
 
@@ -4184,13 +4190,17 @@ cmd_tunnel_tso_set_parsed(void *parsed_result,
 			~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
 			  DEV_TX_OFFLOAD_GRE_TNL_TSO |
 			  DEV_TX_OFFLOAD_IPIP_TNL_TSO |
-			  DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
+			  DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
+			  DEV_TX_OFFLOAD_IP_TNL_TSO |
+			  DEV_TX_OFFLOAD_UDP_TNL_TSO);
 		printf("TSO for tunneled packets is disabled\n");
 	} else {
 		uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
 					 DEV_TX_OFFLOAD_GRE_TNL_TSO |
 					 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
-					 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
+					 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
+					 DEV_TX_OFFLOAD_IP_TNL_TSO |
+					 DEV_TX_OFFLOAD_UDP_TNL_TSO);
 
 		ports[res->port_id].dev_conf.txmode.offloads |=
 			(tso_offloads & dev_info.tx_offload_capa);
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index dd051f5ca..f329a8810 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -722,6 +722,23 @@ port_offload_cap_display(portid_t port_id)
 			printf("off\n");
 	}
 
+	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO) {
+		printf("IP tunnel TSO:  ");
+		if (ports[port_id].dev_conf.txmode.offloads &
+		    DEV_TX_OFFLOAD_IP_TNL_TSO)
+			printf("on\n");
+		else
+			printf("off\n");
+	}
+
+	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO) {
+		printf("UDP tunnel TSO:  ");
+		if (ports[port_id].dev_conf.txmode.offloads &
+		    DEV_TX_OFFLOAD_UDP_TNL_TSO)
+			printf("on\n");
+		else
+			printf("off\n");
+	}
 }
 
 int
-- 
2.13.3

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

* Re: [dpdk-dev] [PATCH v4 2/4] app/testpmd: testpmd support Tx generic tunnel offloads
  2018-04-17 14:24     ` Iremonger, Bernard
@ 2018-04-17 15:44       ` Xueming(Steven) Li
  0 siblings, 0 replies; 80+ messages in thread
From: Xueming(Steven) Li @ 2018-04-17 15:44 UTC (permalink / raw)
  To: Iremonger, Bernard, Lu, Wenzhuo, Wu, Jingjing, Thomas Monjalon,
	Yongseok Koh, Olivier MATZ, Shahaf Shuler
  Cc: Yigit, Ferruh, dev

Hi Bernard,

> -----Original Message-----
> From: Iremonger, Bernard <bernard.iremonger@intel.com>
> Sent: Tuesday, April 17, 2018 10:25 PM
> To: Xueming(Steven) Li <xuemingl@mellanox.com>; Lu, Wenzhuo <wenzhuo.lu@intel.com>; Wu, Jingjing
> <jingjing.wu@intel.com>; Thomas Monjalon <thomas@monjalon.net>; Yongseok Koh <yskoh@mellanox.com>;
> Olivier MATZ <olivier.matz@6wind.com>; Shahaf Shuler <shahafs@mellanox.com>
> Cc: Yigit, Ferruh <ferruh.yigit@intel.com>; dev@dpdk.org
> Subject: RE: [dpdk-dev] [PATCH v4 2/4] app/testpmd: testpmd support Tx generic tunnel offloads
> 
> Hi Lu,
> 
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Xueming Li
> > Sent: Sunday, April 8, 2018 1:33 PM
> > To: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Wu, Jingjing
> > <jingjing.wu@intel.com>; Thomas Monjalon <thomas@monjalon.net>;
> > Yongseok Koh <yskoh@mellanox.com>; Olivier MATZ
> > <olivier.matz@6wind.com>; Shahaf Shuler <shahafs@mellanox.com>
> > Cc: Xueming Li <xuemingl@mellanox.com>; Yigit, Ferruh
> > <ferruh.yigit@intel.com>; dev@dpdk.org
> > Subject: [dpdk-dev] [PATCH v4 2/4] app/testpmd: testpmd support Tx
> > generic tunnel offloads
> >
> > "show port cap" and "csum parse tunnel" command support TX generic
> > tunnel offloads
> >
> > Signed-off-by: Xueming Li <xuemingl@mellanox.com>
> > ---
> >  app/test-pmd/cmdline.c  | 14 ++++++++++++--
> >  app/test-pmd/config.c   | 17 +++++++++++++++++
> >  app/test-pmd/csumonly.c |  3 ++-
> >  3 files changed, 31 insertions(+), 3 deletions(-)
> >
> > diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index
> > 40b31ad7e..a81112220 100644
> > --- a/app/test-pmd/cmdline.c
> > +++ b/app/test-pmd/cmdline.c
> > @@ -4013,6 +4013,12 @@ check_tunnel_tso_nic_support(portid_t port_id)
> >  	if (!(dev_info.tx_offload_capa &
> > DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
> >  		printf("Warning: GENEVE TUNNEL TSO not supported therefore "
> >  		       "not enabled for port %d\n", port_id);
> > +	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
> > +		printf("Warning: IP TUNNEL TSO not supported therefore "
> > +		       "not enabled for port %d\n", port_id);
> > +	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
> > +		printf("Warning: UDP TUNNEL TSO not supported therefore "
> > +		       "not enabled for port %d\n", port_id);
> >  	return dev_info;
> >  }
> >
> > @@ -4040,13 +4046,17 @@ cmd_tunnel_tso_set_parsed(void *parsed_result,
> >  			~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
> >  			  DEV_TX_OFFLOAD_GRE_TNL_TSO |
> >  			  DEV_TX_OFFLOAD_IPIP_TNL_TSO |
> > -			  DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
> > +			  DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
> > +			  DEV_TX_OFFLOAD_IP_TNL_TSO |
> > +			  DEV_TX_OFFLOAD_UDP_TNL_TSO);
> >  		printf("TSO for tunneled packets is disabled\n");
> >  	} else {
> >  		uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
> >  					 DEV_TX_OFFLOAD_GRE_TNL_TSO |
> >  					 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
> > -
> > DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
> > +					 DEV_TX_OFFLOAD_GENEVE_TNL_TSO
> > |
> > +					 DEV_TX_OFFLOAD_IP_TNL_TSO |
> > +					 DEV_TX_OFFLOAD_UDP_TNL_TSO);
> >
> >  		ports[res->port_id].dev_conf.txmode.offloads |=
> >  			(tso_offloads & dev_info.tx_offload_capa); diff --git
> > a/app/test-pmd/config.c b/app/test-pmd/config.c index
> > 4bb255c62..481d2b62d
> > 100644
> > --- a/app/test-pmd/config.c
> > +++ b/app/test-pmd/config.c
> > @@ -722,6 +722,23 @@ port_offload_cap_display(portid_t port_id)
> >  			printf("off\n");
> >  	}
> >
> > +	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO) {
> > +		printf("IP tunnel TSO:  ");
> > +		if (ports[port_id].dev_conf.txmode.offloads &
> > +		    DEV_TX_OFFLOAD_IP_TNL_TSO)
> > +			printf("on\n");
> > +		else
> > +			printf("off\n");
> > +	}
> > +
> > +	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO) {
> > +		printf("UDP tunnel TSO:  ");
> > +		if (ports[port_id].dev_conf.txmode.offloads &
> > +		    DEV_TX_OFFLOAD_UDP_TNL_TSO)
> > +			printf("on\n");
> > +		else
> > +			printf("off\n");
> > +	}
> >  }
> >
> >  int
> > diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index
> > 5f5ab64aa..7b2309372 100644
> > --- a/app/test-pmd/csumonly.c
> > +++ b/app/test-pmd/csumonly.c
> > @@ -693,7 +693,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
> >  					info.l3_len);
> >  				parse_vxlan(udp_hdr, &info, m->packet_type);
> >  				if (info.is_tunnel)
> > -					tx_ol_flags |=
> > PKT_TX_TUNNEL_VXLAN;
> > +					tx_ol_flags |=
> > (PKT_TX_TUNNEL_VXLAN |
> > +							PKT_TX_OUTER_UDP);
> >  			} else if (info.l4_proto == IPPROTO_GRE) {
> >  				struct simple_gre_hdr *gre_hdr;
> >
> > --
> > 2.13.3
> 
> This patch fails to compile on latest master branch.
> 
> /root/dpdk_sforge_2/app/test-pmd/csumonly.c: In function 'pkt_burst_checksum_forward':
> /root/dpdk_sforge_2/app/test-pmd/csumonly.c:700:8: error: 'PKT_TX_OUTER_UDP' undeclared (first use in
> this function)
>         PKT_TX_OUTER_UDP);
>         ^
> /root/dpdk_sforge_2/app/test-pmd/csumonly.c:700:8: note: each undeclared identifier is reported only
> once for each function it appears in
> make[5]: *** [csumonly.o] Error 1
> make[4]: *** [test-pmd] Error 2
> make[3]: *** [app] Error 2
> make[2]: *** [all] Error 2
> make[1]: *** [pre_install] Error 2
> make: *** [install] Error 2
> 
> Regards,
> 
> Bernard.

Please give a try on V5 version:
http://www.dpdk.org/ml/archives/dev/2018-April/097656.html


Best Regards,
Xueming Li

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

* Re: [dpdk-dev] [PATCH v5 1/2] ethdev: introduce generic IP/UDP tunnel checksum and TSO
  2018-04-17 14:47     ` [dpdk-dev] [PATCH v5 1/2] ethdev: introduce generic IP/UDP " Xueming Li
@ 2018-04-17 21:21       ` Thomas Monjalon
  0 siblings, 0 replies; 80+ messages in thread
From: Thomas Monjalon @ 2018-04-17 21:21 UTC (permalink / raw)
  To: Xueming Li
  Cc: dev, Wenzhuo Lu, Jingjing Wu, Yongseok Koh, Olivier MATZ,
	Shahaf Shuler, Bernard, Ferruh Yigit

17/04/2018 16:47, Xueming Li:
> This patch introduce new TX offload flags for device that supports
> IP or UDP tunneled packet L3/L4 checksum and TSO offload.
> 
> The support from the device is for inner and outer checksums on
> IPV4/TCP/UDP and TSO for *any packet with the following format*:
> 
> <some headers> / [optional IPv4/IPv6] / [optional TCP/UDP] / <some
> headers> / [optional inner IPv4/IPv6] / [optional TCP/UDP]
> 
> For example the following packets can use this feature:
> 
> 1. eth / ipv4 / udp / VXLAN / ip / tcp
> 2. eth / ipv4 / GRE / MPLS / ipv4 / udp
> 
> Please note that tunnel headers that contain payload length, sequence id
> or checksum will not be updated.
[...]
> +/**< Device supports UDP tunneled packet TSO */
> +#define DEV_TX_OFFLOAD_UDP_TNL_TSO      0x00040000
> +/**< Device supports IP based tunnel packet TSO */
> +#define DEV_TX_OFFLOAD_IP_TNL_TSO       0x00080000

These doxygen comments are related to the constants on the next line.
So the syntax is /** not /**<

[...]

General comment: API description is required for application writers
and PMD developers. You need to provide details about what the offload
is expected to do.

> +/**
> + * Generic IP encapsulated tunnel type, used for TSO offload instead
> + * of defining new tunnel types.

The words "instead of defining new tunnel types" are justifications for
the commit message, not for the code itself.

> This feature relies on offloading
> + * DEV_TX_OFFLOAD_IP_TNL_TSO present.

I think you want to say that DEV_TX_OFFLOAD_IP_TNL_TSO must be enabled.

> + * Tunnel header that contains payload length, sequence id or checksum
> + * is not expected to be updated.

OK
So what is updated by this offload exactly?
inner and outer checksums on IPV4/TCP/UDP? What else?
No IPv6? No SCTP?

> + */
> +#define PKT_TX_TUNNEL_IP (0xDULL << 45)
> +/**
> + * Generic UDP encapsulated tunnel type, used for TSO offload instead
> + * of defining new tunnel types. This feature relies on offloading
> + * DEV_TX_OFFLOAD_UDP_TNL_TSO present.
> + * Tunnel header that contains payload length, sequence id or checksum
> + * is not expected to be updated.
> + */

Same comments as for PKT_TX_TUNNEL_IP.

> +#define PKT_TX_TUNNEL_UDP (0xEULL << 45)

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

* [dpdk-dev] [PATCH v6 0/2] support Tx generic tunnel checksum and TSO
  2018-04-08 12:32   ` [dpdk-dev] [PATCH v4 0/4] support Tx generic tunnel checksum and TSO Xueming Li
                       ` (2 preceding siblings ...)
  2018-04-17 14:49     ` [dpdk-dev] [PATCH v5 2/2] app/testpmd: testpmd support Tx generic tunnel offloads Xueming Li
@ 2018-04-18 13:38     ` Xueming Li
  2018-04-18 13:58     ` [dpdk-dev] [PATCH v6 1/2] ethdev: introduce generic IP/UDP " Xueming Li
  2018-04-18 13:59     ` [dpdk-dev] [PATCH v6 " Xueming Li
  5 siblings, 0 replies; 80+ messages in thread
From: Xueming Li @ 2018-04-18 13:38 UTC (permalink / raw)
  To: Wenzhuo Lu, Jingjing Wu, Thomas Monjalon, Yongseok Koh,
	Olivier MATZ, Shahaf Shuler, Iremonger, Bernard
  Cc: Xueming Li, Ferruh Yigit, dev

V6:
- Comments update according to maillist discussion.

V5:
- Removed duplicated testpmd patch in other pathset.
- More comments on PKT_TX_TUNNEL_IP and PKT_TX_TUNNEL_UDP

V4:
- Removed DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM and DEV_TX_OFFLOAD_GENERIC_TNL_TSO
- Replaced with DEV_TX_OFFLOAD_IP_TNL_TSO
- Removed PKT_TX_OUTER_UDP
- Splited PKT_TX_TUNNEL_UNKNOWN into PKT_TX_TUNNEL_IP and PKT_TX_TUNNEL_UDP

V3:
- Add VXLAN-GPE and GRE extention support to testpmd csum forwarding enginee
- Split DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO into DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM
  and DEV_TX_OFFLOAD_GENERIC_TNL_TSO
- Add PKT_TX_TUNNEL_UNKNOWN and PKT_TX_OUTER_UDP

  http://www.dpdk.org/dev/patchwork/patch/34655/


This patchset introduces new HW capability of generic tunnel cheksum and TSO offloads, HW supporting generic tunnel checksum and TSO could handle new tunnel type offloading w/o
 upgrading HW.
New Generic tunnel checksum and TSO offload support IP tunnel and UDP tunnel. Please note that tunnel type that has length, sequence id or checksum are not considered as generi
c tunnel type.

Xueming Li (2):
  ethdev: introduce generic IP/UDP tunnel checksum and TSO
  app/testpmd: testpmd support Tx generic tunnel offloads

 app/test-pmd/cmdline.c        | 14 ++++++++++++--
 app/test-pmd/config.c         | 17 +++++++++++++++++
 lib/librte_ether/rte_ethdev.h | 12 ++++++++++++
 lib/librte_mbuf/rte_mbuf.c    |  6 ++++++
 lib/librte_mbuf/rte_mbuf.h    | 25 +++++++++++++++++++++++++
 5 files changed, 72 insertions(+), 2 deletions(-)

-- 
2.13.3

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

* [dpdk-dev] [PATCH v6 1/2] ethdev: introduce generic IP/UDP tunnel checksum and TSO
  2018-04-08 12:32   ` [dpdk-dev] [PATCH v4 0/4] support Tx generic tunnel checksum and TSO Xueming Li
                       ` (3 preceding siblings ...)
  2018-04-18 13:38     ` [dpdk-dev] [PATCH v6 0/2] support Tx generic tunnel checksum and TSO Xueming Li
@ 2018-04-18 13:58     ` Xueming Li
  2018-04-18 14:28       ` Thomas Monjalon
                         ` (3 more replies)
  2018-04-18 13:59     ` [dpdk-dev] [PATCH v6 " Xueming Li
  5 siblings, 4 replies; 80+ messages in thread
From: Xueming Li @ 2018-04-18 13:58 UTC (permalink / raw)
  To: Wenzhuo Lu, Jingjing Wu, Thomas Monjalon, Yongseok Koh,
	Olivier MATZ, Shahaf Shuler, Iremonger, Bernard
  Cc: Xueming Li, Ferruh Yigit, dev

This patch introduce new TX offload flags for device that supports
IP or UDP tunneled packet L3/L4 checksum and TSO offload.
It will be used for non-standard tunnels.

The support from the device is for inner and outer checksums on
IPV4/TCP/UDP and TSO for *any packet with the following format*:

<some headers> / [optional IPv4/IPv6] / [optional TCP/UDP] / <some
headers> / [optional inner IPv4/IPv6] / [optional TCP/UDP]

For example the following packets can use this feature:

1. eth / ipv4 / udp / VXLAN / ip / tcp
2. eth / ipv4 / GRE / MPLS / ipv4 / udp

Please note that specific tunnel headers that contain payload length,
sequence id or checksum will not be updated.

The new flag PKT_TX_TUNNEL_IP is redundant with PKT_TX_OUTER_IP_CKSUM.
The old flag PKT_TX_OUTER_IP_CKSUM can be deprecated and removed in
later release.

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
---
 lib/librte_ether/rte_ethdev.h | 12 ++++++++++++
 lib/librte_mbuf/rte_mbuf.c    |  6 ++++++
 lib/librte_mbuf/rte_mbuf.h    | 25 +++++++++++++++++++++++++
 3 files changed, 43 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 4f417f573..ef152dec6 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -980,6 +980,18 @@ struct rte_eth_conf {
  *   the same mempool and has refcnt = 1.
  */
 #define DEV_TX_OFFLOAD_SECURITY         0x00020000
+/**
+ * Device supports generic UDP tunneled packet TSO.
+ * Application must set PKT_TX_TUNNEL_UDP and other mbuf fields required
+ * for tunnel TSO.
+ */
+#define DEV_TX_OFFLOAD_UDP_TNL_TSO      0x00040000
+/**
+ * Device supports generic IP tunneled packet TSO.
+ * Application must set PKT_TX_TUNNEL_IP and other mbuf fields required
+ * for tunnel TSO.
+ */
+#define DEV_TX_OFFLOAD_IP_TNL_TSO       0x00080000
 
 /*
  * If new Tx offload capabilities are defined, they also must be
diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index 3f4c83305..64e960d4c 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -390,6 +390,8 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask)
 	case PKT_TX_TUNNEL_IPIP: return "PKT_TX_TUNNEL_IPIP";
 	case PKT_TX_TUNNEL_GENEVE: return "PKT_TX_TUNNEL_GENEVE";
 	case PKT_TX_TUNNEL_MPLSINUDP: return "PKT_TX_TUNNEL_MPLSINUDP";
+	case PKT_TX_TUNNEL_IP: return "PKT_TX_TUNNEL_IP";
+	case PKT_TX_TUNNEL_UDP: return "PKT_TX_TUNNEL_UDP";
 	case PKT_TX_MACSEC: return "PKT_TX_MACSEC";
 	case PKT_TX_SEC_OFFLOAD: return "PKT_TX_SEC_OFFLOAD";
 	default: return NULL;
@@ -424,6 +426,10 @@ rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
 		  "PKT_TX_TUNNEL_NONE" },
 		{ PKT_TX_TUNNEL_MPLSINUDP, PKT_TX_TUNNEL_MASK,
 		  "PKT_TX_TUNNEL_NONE" },
+		{ PKT_TX_TUNNEL_IP, PKT_TX_TUNNEL_MASK,
+		  "PKT_TX_TUNNEL_NONE" },
+		{ PKT_TX_TUNNEL_UDP, PKT_TX_TUNNEL_MASK,
+		  "PKT_TX_TUNNEL_NONE" },
 		{ PKT_TX_MACSEC, PKT_TX_MACSEC, NULL },
 		{ PKT_TX_SEC_OFFLOAD, PKT_TX_SEC_OFFLOAD, NULL },
 	};
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 06eceba37..a1ee1c3a7 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -210,6 +210,31 @@ extern "C" {
 #define PKT_TX_TUNNEL_GENEVE  (0x4ULL << 45)
 /**< TX packet with MPLS-in-UDP RFC 7510 header. */
 #define PKT_TX_TUNNEL_MPLSINUDP (0x5ULL << 45)
+/**
+ * Generic IP encapsulated tunnel type, used for TSO and checksum offload.
+ * It can be used for tunnels which are not standards or listed above.
+ * It is preferred to use specific tunnel flags like PKT_TX_TUNNEL_VXLAN
+ * if possible.
+ * The ethdev must be configured with DEV_TX_OFFLOAD_IP_TNL_TSO.
+ * Outer and inner checksums are done according to the existing flags like
+ * PKT_TX_xxx_CKSUM.
+ * Specific tunnel headers that contain payload length, sequence id
+ * or checksum are not expected to be updated.
+ */
+#define PKT_TX_TUNNEL_IP (0xDULL << 45)
+/**
+ * Generic UDP encapsulated tunnel type, used for TSO and checksum offload.
+ * UDP tunnel type implies outer IP layer.
+ * It can be used for tunnels which are not standards or listed above.
+ * It is preferred to use specific tunnel flags like PKT_TX_TUNNEL_VXLAN
+ * if possible.
+ * The ethdev must be configured with DEV_TX_OFFLOAD_UDP_TNL_TSO.
+ * Outer and inner checksums are done according to the existing flags like
+ * PKT_TX_xxx_CKSUM.
+ * Specific tunnel headers that contain payload length, sequence id
+ * or checksum are not expected to be updated.
+ */
+#define PKT_TX_TUNNEL_UDP (0xEULL << 45)
 /* add new TX TUNNEL type here */
 #define PKT_TX_TUNNEL_MASK    (0xFULL << 45)
 
-- 
2.13.3

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

* [dpdk-dev] [PATCH v6 2/2] app/testpmd: testpmd support Tx generic tunnel offloads
  2018-04-08 12:32   ` [dpdk-dev] [PATCH v4 0/4] support Tx generic tunnel checksum and TSO Xueming Li
                       ` (4 preceding siblings ...)
  2018-04-18 13:58     ` [dpdk-dev] [PATCH v6 1/2] ethdev: introduce generic IP/UDP " Xueming Li
@ 2018-04-18 13:59     ` Xueming Li
  5 siblings, 0 replies; 80+ messages in thread
From: Xueming Li @ 2018-04-18 13:59 UTC (permalink / raw)
  To: Wenzhuo Lu, Jingjing Wu, Thomas Monjalon, Yongseok Koh,
	Olivier MATZ, Shahaf Shuler, Iremonger, Bernard
  Cc: Xueming Li, Ferruh Yigit, dev

"show port cap" and "csum parse tunnel" command support TX generic
tunnel offloads

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
---
 app/test-pmd/cmdline.c | 14 ++++++++++++--
 app/test-pmd/config.c  | 17 +++++++++++++++++
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 512e3b55e..4ec3dab56 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -4157,6 +4157,12 @@ check_tunnel_tso_nic_support(portid_t port_id)
 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
 		printf("Warning: GENEVE TUNNEL TSO not supported therefore "
 		       "not enabled for port %d\n", port_id);
+	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
+		printf("Warning: IP TUNNEL TSO not supported therefore "
+		       "not enabled for port %d\n", port_id);
+	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
+		printf("Warning: UDP TUNNEL TSO not supported therefore "
+		       "not enabled for port %d\n", port_id);
 	return dev_info;
 }
 
@@ -4184,13 +4190,17 @@ cmd_tunnel_tso_set_parsed(void *parsed_result,
 			~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
 			  DEV_TX_OFFLOAD_GRE_TNL_TSO |
 			  DEV_TX_OFFLOAD_IPIP_TNL_TSO |
-			  DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
+			  DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
+			  DEV_TX_OFFLOAD_IP_TNL_TSO |
+			  DEV_TX_OFFLOAD_UDP_TNL_TSO);
 		printf("TSO for tunneled packets is disabled\n");
 	} else {
 		uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
 					 DEV_TX_OFFLOAD_GRE_TNL_TSO |
 					 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
-					 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
+					 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
+					 DEV_TX_OFFLOAD_IP_TNL_TSO |
+					 DEV_TX_OFFLOAD_UDP_TNL_TSO);
 
 		ports[res->port_id].dev_conf.txmode.offloads |=
 			(tso_offloads & dev_info.tx_offload_capa);
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index dd051f5ca..f329a8810 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -722,6 +722,23 @@ port_offload_cap_display(portid_t port_id)
 			printf("off\n");
 	}
 
+	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO) {
+		printf("IP tunnel TSO:  ");
+		if (ports[port_id].dev_conf.txmode.offloads &
+		    DEV_TX_OFFLOAD_IP_TNL_TSO)
+			printf("on\n");
+		else
+			printf("off\n");
+	}
+
+	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO) {
+		printf("UDP tunnel TSO:  ");
+		if (ports[port_id].dev_conf.txmode.offloads &
+		    DEV_TX_OFFLOAD_UDP_TNL_TSO)
+			printf("on\n");
+		else
+			printf("off\n");
+	}
 }
 
 int
-- 
2.13.3

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

* Re: [dpdk-dev] [PATCH v6 1/2] ethdev: introduce generic IP/UDP tunnel checksum and TSO
  2018-04-18 13:58     ` [dpdk-dev] [PATCH v6 1/2] ethdev: introduce generic IP/UDP " Xueming Li
@ 2018-04-18 14:28       ` Thomas Monjalon
  2018-04-18 16:45         ` Ananyev, Konstantin
  2018-04-20 12:48       ` [dpdk-dev] [PATCH v7 0/2] support Tx generic " Xueming Li
                         ` (2 subsequent siblings)
  3 siblings, 1 reply; 80+ messages in thread
From: Thomas Monjalon @ 2018-04-18 14:28 UTC (permalink / raw)
  To: Xueming Li
  Cc: Wenzhuo Lu, Jingjing Wu, Yongseok Koh, Olivier MATZ,
	Shahaf Shuler, Bernard, Ferruh Yigit, dev

18/04/2018 15:58, Xueming Li:
> This patch introduce new TX offload flags for device that supports
> IP or UDP tunneled packet L3/L4 checksum and TSO offload.
> It will be used for non-standard tunnels.
> 
> The support from the device is for inner and outer checksums on
> IPV4/TCP/UDP and TSO for *any packet with the following format*:
> 
> <some headers> / [optional IPv4/IPv6] / [optional TCP/UDP] / <some
> headers> / [optional inner IPv4/IPv6] / [optional TCP/UDP]
> 
> For example the following packets can use this feature:
> 
> 1. eth / ipv4 / udp / VXLAN / ip / tcp
> 2. eth / ipv4 / GRE / MPLS / ipv4 / udp
> 
> Please note that specific tunnel headers that contain payload length,
> sequence id or checksum will not be updated.
> 
> The new flag PKT_TX_TUNNEL_IP is redundant with PKT_TX_OUTER_IP_CKSUM.
> The old flag PKT_TX_OUTER_IP_CKSUM can be deprecated and removed in
> later release.
> 
> Signed-off-by: Xueming Li <xuemingl@mellanox.com>

Except a small comment below, it looks OK.

Acked-by: Thomas Monjalon <thomas@monjalon.net>

Please send a deprecation notice for PKT_TX_OUTER_IP_CKSUM.


> --- a/lib/librte_mbuf/rte_mbuf.h
> +++ b/lib/librte_mbuf/rte_mbuf.h
> +/**
> + * Generic IP encapsulated tunnel type, used for TSO and checksum offload.
> + * It can be used for tunnels which are not standards or listed above.
> + * It is preferred to use specific tunnel flags like PKT_TX_TUNNEL_VXLAN
> + * if possible.

PKT_TX_TUNNEL_GRE or PKT_TX_TUNNEL_IPIP may be a better example than
PKT_TX_TUNNEL_VXLAN in IP tunnel case.

> + * The ethdev must be configured with DEV_TX_OFFLOAD_IP_TNL_TSO.
> + * Outer and inner checksums are done according to the existing flags like
> + * PKT_TX_xxx_CKSUM.
> + * Specific tunnel headers that contain payload length, sequence id
> + * or checksum are not expected to be updated.
> + */
> +#define PKT_TX_TUNNEL_IP (0xDULL << 45)
> +/**
> + * Generic UDP encapsulated tunnel type, used for TSO and checksum offload.
> + * UDP tunnel type implies outer IP layer.
> + * It can be used for tunnels which are not standards or listed above.
> + * It is preferred to use specific tunnel flags like PKT_TX_TUNNEL_VXLAN
> + * if possible.
> + * The ethdev must be configured with DEV_TX_OFFLOAD_UDP_TNL_TSO.
> + * Outer and inner checksums are done according to the existing flags like
> + * PKT_TX_xxx_CKSUM.
> + * Specific tunnel headers that contain payload length, sequence id
> + * or checksum are not expected to be updated.
> + */
> +#define PKT_TX_TUNNEL_UDP (0xEULL << 45)

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

* Re: [dpdk-dev] [PATCH v6 1/2] ethdev: introduce generic IP/UDP tunnel checksum and TSO
  2018-04-18 14:28       ` Thomas Monjalon
@ 2018-04-18 16:45         ` Ananyev, Konstantin
  2018-04-18 18:02           ` Thomas Monjalon
  0 siblings, 1 reply; 80+ messages in thread
From: Ananyev, Konstantin @ 2018-04-18 16:45 UTC (permalink / raw)
  To: Thomas Monjalon, Xueming Li
  Cc: Lu, Wenzhuo, Wu, Jingjing, Yongseok Koh, Olivier MATZ,
	Shahaf Shuler, Iremonger, Bernard, Yigit, Ferruh, dev



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Thomas Monjalon
> Sent: Wednesday, April 18, 2018 3:28 PM
> To: Xueming Li <xuemingl@mellanox.com>
> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>; Yongseok Koh <yskoh@mellanox.com>; Olivier MATZ
> <olivier.matz@6wind.com>; Shahaf Shuler <shahafs@mellanox.com>; Iremonger, Bernard <bernard.iremonger@intel.com>; Yigit, Ferruh
> <ferruh.yigit@intel.com>; dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v6 1/2] ethdev: introduce generic IP/UDP tunnel checksum and TSO
> 
> 18/04/2018 15:58, Xueming Li:
> > This patch introduce new TX offload flags for device that supports
> > IP or UDP tunneled packet L3/L4 checksum and TSO offload.
> > It will be used for non-standard tunnels.
> >
> > The support from the device is for inner and outer checksums on
> > IPV4/TCP/UDP and TSO for *any packet with the following format*:
> >
> > <some headers> / [optional IPv4/IPv6] / [optional TCP/UDP] / <some
> > headers> / [optional inner IPv4/IPv6] / [optional TCP/UDP]
> >
> > For example the following packets can use this feature:
> >
> > 1. eth / ipv4 / udp / VXLAN / ip / tcp
> > 2. eth / ipv4 / GRE / MPLS / ipv4 / udp
> >
> > Please note that specific tunnel headers that contain payload length,
> > sequence id or checksum will not be updated.
> >
> > The new flag PKT_TX_TUNNEL_IP is redundant with PKT_TX_OUTER_IP_CKSUM.
> > The old flag PKT_TX_OUTER_IP_CKSUM can be deprecated and removed in
> > later release.
> >
> > Signed-off-by: Xueming Li <xuemingl@mellanox.com>
> 
> Except a small comment below, it looks OK.
> 
> Acked-by: Thomas Monjalon <thomas@monjalon.net>
> 
> Please send a deprecation notice for PKT_TX_OUTER_IP_CKSUM.

I probably missed something, but why PKT_TX_OUTER_IP_CKSUM
is supposed to be deprecated?
Konstantin

> 
> 
> > --- a/lib/librte_mbuf/rte_mbuf.h
> > +++ b/lib/librte_mbuf/rte_mbuf.h
> > +/**
> > + * Generic IP encapsulated tunnel type, used for TSO and checksum offload.
> > + * It can be used for tunnels which are not standards or listed above.
> > + * It is preferred to use specific tunnel flags like PKT_TX_TUNNEL_VXLAN
> > + * if possible.
> 
> PKT_TX_TUNNEL_GRE or PKT_TX_TUNNEL_IPIP may be a better example than
> PKT_TX_TUNNEL_VXLAN in IP tunnel case.
> 
> > + * The ethdev must be configured with DEV_TX_OFFLOAD_IP_TNL_TSO.
> > + * Outer and inner checksums are done according to the existing flags like
> > + * PKT_TX_xxx_CKSUM.
> > + * Specific tunnel headers that contain payload length, sequence id
> > + * or checksum are not expected to be updated.
> > + */
> > +#define PKT_TX_TUNNEL_IP (0xDULL << 45)
> > +/**
> > + * Generic UDP encapsulated tunnel type, used for TSO and checksum offload.
> > + * UDP tunnel type implies outer IP layer.
> > + * It can be used for tunnels which are not standards or listed above.
> > + * It is preferred to use specific tunnel flags like PKT_TX_TUNNEL_VXLAN
> > + * if possible.
> > + * The ethdev must be configured with DEV_TX_OFFLOAD_UDP_TNL_TSO.
> > + * Outer and inner checksums are done according to the existing flags like
> > + * PKT_TX_xxx_CKSUM.
> > + * Specific tunnel headers that contain payload length, sequence id
> > + * or checksum are not expected to be updated.
> > + */
> > +#define PKT_TX_TUNNEL_UDP (0xEULL << 45)
> 
> 

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

* Re: [dpdk-dev] [PATCH v6 1/2] ethdev: introduce generic IP/UDP tunnel checksum and TSO
  2018-04-18 16:45         ` Ananyev, Konstantin
@ 2018-04-18 18:02           ` Thomas Monjalon
  2018-04-23  9:55             ` Olivier Matz
  0 siblings, 1 reply; 80+ messages in thread
From: Thomas Monjalon @ 2018-04-18 18:02 UTC (permalink / raw)
  To: Ananyev, Konstantin
  Cc: Xueming Li, Lu, Wenzhuo, Wu, Jingjing, Yongseok Koh,
	Olivier MATZ, Shahaf Shuler, Iremonger, Bernard, Yigit, Ferruh,
	dev

18/04/2018 18:45, Ananyev, Konstantin:
> From: Thomas Monjalon
> > 18/04/2018 15:58, Xueming Li:
> > > The new flag PKT_TX_TUNNEL_IP is redundant with PKT_TX_OUTER_IP_CKSUM.
> > > The old flag PKT_TX_OUTER_IP_CKSUM can be deprecated and removed in
> > > later release.
> > >
> > > Signed-off-by: Xueming Li <xuemingl@mellanox.com>
> > 
> > Except a small comment below, it looks OK.
> > 
> > Acked-by: Thomas Monjalon <thomas@monjalon.net>
> > 
> > Please send a deprecation notice for PKT_TX_OUTER_IP_CKSUM.
> 
> I probably missed something, but why PKT_TX_OUTER_IP_CKSUM
> is supposed to be deprecated?

Because PKT_TX_TUNNEL_* flags sepersede it. I think we need to discuss it.

We use the offload flags PKT_TX_TUNNEL_* when we request some offloads
in the outer and the inner headers at the same time.
When setting a tunnel flag PKT_TX_TUNNEL_*, it can be expected that
the outer checksums will be offloaded, otherwise it is almost
impossible to request an offload in the inner header.
In the case of an UDP tunnel, any change in the inner packet will
require an UDP checksum update.
In the case of an IP tunnel, a change of the inner packet size
(like TSO) will require an IP checksum update.

If we really require PKT_TX_OUTER_IP_CKSUM to be set in addition to
PKT_TX_TUNNEL_* flags, then we should add more PKT_TX_OUTER_*_CKSUM,
like PKT_TX_OUTER_UDP_CKSUM which is missing.

Opinions?

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

* [dpdk-dev] [PATCH v7 0/2] support Tx generic tunnel checksum and TSO
  2018-04-18 13:58     ` [dpdk-dev] [PATCH v6 1/2] ethdev: introduce generic IP/UDP " Xueming Li
  2018-04-18 14:28       ` Thomas Monjalon
@ 2018-04-20 12:48       ` Xueming Li
  2018-04-23 11:36         ` [dpdk-dev] [PATCH v8 " Xueming Li
                           ` (2 more replies)
  2018-04-20 12:48       ` [dpdk-dev] [PATCH v7 1/2] ethdev: introduce generic IP/UDP tunnel checksum and TSO Xueming Li
  2018-04-20 12:48       ` [dpdk-dev] [PATCH v7 2/2] app/testpmd: testpmd support Tx generic tunnel offloads Xueming Li
  3 siblings, 3 replies; 80+ messages in thread
From: Xueming Li @ 2018-04-20 12:48 UTC (permalink / raw)
  To: Wenzhuo Lu, Jingjing Wu, Thomas Monjalon, Yongseok Koh,
	Olivier MATZ, Shahaf Shuler
  Cc: Xueming Li, Ferruh Yigit, dev, AnanyevKonstantinkonstantin.ananyev

V7:
- Removed PKT_TX_OUTER_IP_CKSUM deprecation suggestion from commit log

V6:
- Comments update according to maillist discussion.

V5:
- Removed duplicated testpmd patch in other pathset.
- More comments on PKT_TX_TUNNEL_IP and PKT_TX_TUNNEL_UDP

V4:
- Removed DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM and DEV_TX_OFFLOAD_GENERIC_TNL_TSO
- Replaced with DEV_TX_OFFLOAD_IP_TNL_TSO
- Removed PKT_TX_OUTER_UDP
- Splited PKT_TX_TUNNEL_UNKNOWN into PKT_TX_TUNNEL_IP and PKT_TX_TUNNEL_UDP

V3:
- Add VXLAN-GPE and GRE extention support to testpmd csum forwarding enginee
- Split DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO into DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM
  and DEV_TX_OFFLOAD_GENERIC_TNL_TSO
- Add PKT_TX_TUNNEL_UNKNOWN and PKT_TX_OUTER_UDP

  http://www.dpdk.org/dev/patchwork/patch/34655/

Xueming Li (2):
  ethdev: introduce generic IP/UDP tunnel checksum and TSO
  app/testpmd: testpmd support Tx generic tunnel offloads

 app/test-pmd/cmdline.c        | 14 ++++++++++++--
 app/test-pmd/config.c         | 17 +++++++++++++++++
 lib/librte_ether/rte_ethdev.h | 12 ++++++++++++
 lib/librte_mbuf/rte_mbuf.c    |  6 ++++++
 lib/librte_mbuf/rte_mbuf.h    | 25 +++++++++++++++++++++++++
 5 files changed, 72 insertions(+), 2 deletions(-)

-- 
2.13.3

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

* [dpdk-dev] [PATCH v7 1/2] ethdev: introduce generic IP/UDP tunnel checksum and TSO
  2018-04-18 13:58     ` [dpdk-dev] [PATCH v6 1/2] ethdev: introduce generic IP/UDP " Xueming Li
  2018-04-18 14:28       ` Thomas Monjalon
  2018-04-20 12:48       ` [dpdk-dev] [PATCH v7 0/2] support Tx generic " Xueming Li
@ 2018-04-20 12:48       ` Xueming Li
  2018-04-23  9:59         ` Olivier Matz
  2018-04-20 12:48       ` [dpdk-dev] [PATCH v7 2/2] app/testpmd: testpmd support Tx generic tunnel offloads Xueming Li
  3 siblings, 1 reply; 80+ messages in thread
From: Xueming Li @ 2018-04-20 12:48 UTC (permalink / raw)
  To: Wenzhuo Lu, Jingjing Wu, Thomas Monjalon, Yongseok Koh,
	Olivier MATZ, Shahaf Shuler
  Cc: Xueming Li, Ferruh Yigit, dev, AnanyevKonstantinkonstantin.ananyev

This patch introduce new TX offload flags for device that supports
IP or UDP tunneled packet L3/L4 checksum and TSO offload.
It will be used for non-standard tunnels.

The support from the device is for inner and outer checksums on
IPV4/TCP/UDP and TSO for *any packet with the following format*:

<some headers> / [optional IPv4/IPv6] / [optional TCP/UDP] / <some
headers> / [optional inner IPv4/IPv6] / [optional TCP/UDP]

For example the following packets can use this feature:

1. eth / ipv4 / udp / VXLAN / ip / tcp
2. eth / ipv4 / GRE / MPLS / ipv4 / udp

Please note that specific tunnel headers that contain payload length,
sequence id or checksum will not be updated.

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
Acked-by: Thomas Monjalon <thomas@monjalon.net>
---
 lib/librte_ether/rte_ethdev.h | 12 ++++++++++++
 lib/librte_mbuf/rte_mbuf.c    |  6 ++++++
 lib/librte_mbuf/rte_mbuf.h    | 25 +++++++++++++++++++++++++
 3 files changed, 43 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 4f417f573..ef152dec6 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -980,6 +980,18 @@ struct rte_eth_conf {
  *   the same mempool and has refcnt = 1.
  */
 #define DEV_TX_OFFLOAD_SECURITY         0x00020000
+/**
+ * Device supports generic UDP tunneled packet TSO.
+ * Application must set PKT_TX_TUNNEL_UDP and other mbuf fields required
+ * for tunnel TSO.
+ */
+#define DEV_TX_OFFLOAD_UDP_TNL_TSO      0x00040000
+/**
+ * Device supports generic IP tunneled packet TSO.
+ * Application must set PKT_TX_TUNNEL_IP and other mbuf fields required
+ * for tunnel TSO.
+ */
+#define DEV_TX_OFFLOAD_IP_TNL_TSO       0x00080000
 
 /*
  * If new Tx offload capabilities are defined, they also must be
diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index 3f4c83305..64e960d4c 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -390,6 +390,8 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask)
 	case PKT_TX_TUNNEL_IPIP: return "PKT_TX_TUNNEL_IPIP";
 	case PKT_TX_TUNNEL_GENEVE: return "PKT_TX_TUNNEL_GENEVE";
 	case PKT_TX_TUNNEL_MPLSINUDP: return "PKT_TX_TUNNEL_MPLSINUDP";
+	case PKT_TX_TUNNEL_IP: return "PKT_TX_TUNNEL_IP";
+	case PKT_TX_TUNNEL_UDP: return "PKT_TX_TUNNEL_UDP";
 	case PKT_TX_MACSEC: return "PKT_TX_MACSEC";
 	case PKT_TX_SEC_OFFLOAD: return "PKT_TX_SEC_OFFLOAD";
 	default: return NULL;
@@ -424,6 +426,10 @@ rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
 		  "PKT_TX_TUNNEL_NONE" },
 		{ PKT_TX_TUNNEL_MPLSINUDP, PKT_TX_TUNNEL_MASK,
 		  "PKT_TX_TUNNEL_NONE" },
+		{ PKT_TX_TUNNEL_IP, PKT_TX_TUNNEL_MASK,
+		  "PKT_TX_TUNNEL_NONE" },
+		{ PKT_TX_TUNNEL_UDP, PKT_TX_TUNNEL_MASK,
+		  "PKT_TX_TUNNEL_NONE" },
 		{ PKT_TX_MACSEC, PKT_TX_MACSEC, NULL },
 		{ PKT_TX_SEC_OFFLOAD, PKT_TX_SEC_OFFLOAD, NULL },
 	};
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 06eceba37..80595e6e2 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -210,6 +210,31 @@ extern "C" {
 #define PKT_TX_TUNNEL_GENEVE  (0x4ULL << 45)
 /**< TX packet with MPLS-in-UDP RFC 7510 header. */
 #define PKT_TX_TUNNEL_MPLSINUDP (0x5ULL << 45)
+/**
+ * Generic IP encapsulated tunnel type, used for TSO and checksum offload.
+ * It can be used for tunnels which are not standards or listed above.
+ * It is preferred to use specific tunnel flags like PKT_TX_TUNNEL_GRE
+ * or PKT_TX_TUNNEL_IPIP if possible.
+ * The ethdev must be configured with DEV_TX_OFFLOAD_IP_TNL_TSO.
+ * Outer and inner checksums are done according to the existing flags like
+ * PKT_TX_xxx_CKSUM.
+ * Specific tunnel headers that contain payload length, sequence id
+ * or checksum are not expected to be updated.
+ */
+#define PKT_TX_TUNNEL_IP (0xDULL << 45)
+/**
+ * Generic UDP encapsulated tunnel type, used for TSO and checksum offload.
+ * UDP tunnel type implies outer IP layer.
+ * It can be used for tunnels which are not standards or listed above.
+ * It is preferred to use specific tunnel flags like PKT_TX_TUNNEL_GRE
+ * or PKT_TX_TUNNEL_IPIP if possible.
+ * The ethdev must be configured with DEV_TX_OFFLOAD_UDP_TNL_TSO.
+ * Outer and inner checksums are done according to the existing flags like
+ * PKT_TX_xxx_CKSUM.
+ * Specific tunnel headers that contain payload length, sequence id
+ * or checksum are not expected to be updated.
+ */
+#define PKT_TX_TUNNEL_UDP (0xEULL << 45)
 /* add new TX TUNNEL type here */
 #define PKT_TX_TUNNEL_MASK    (0xFULL << 45)
 
-- 
2.13.3

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

* [dpdk-dev] [PATCH v7 2/2] app/testpmd: testpmd support Tx generic tunnel offloads
  2018-04-18 13:58     ` [dpdk-dev] [PATCH v6 1/2] ethdev: introduce generic IP/UDP " Xueming Li
                         ` (2 preceding siblings ...)
  2018-04-20 12:48       ` [dpdk-dev] [PATCH v7 1/2] ethdev: introduce generic IP/UDP tunnel checksum and TSO Xueming Li
@ 2018-04-20 12:48       ` Xueming Li
  3 siblings, 0 replies; 80+ messages in thread
From: Xueming Li @ 2018-04-20 12:48 UTC (permalink / raw)
  To: Wenzhuo Lu, Jingjing Wu, Thomas Monjalon, Yongseok Koh,
	Olivier MATZ, Shahaf Shuler
  Cc: Xueming Li, Ferruh Yigit, dev, AnanyevKonstantinkonstantin.ananyev

"show port cap" and "csum parse tunnel" command support TX generic
tunnel offloads

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
---
 app/test-pmd/cmdline.c | 14 ++++++++++++--
 app/test-pmd/config.c  | 17 +++++++++++++++++
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 512e3b55e..4ec3dab56 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -4157,6 +4157,12 @@ check_tunnel_tso_nic_support(portid_t port_id)
 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
 		printf("Warning: GENEVE TUNNEL TSO not supported therefore "
 		       "not enabled for port %d\n", port_id);
+	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
+		printf("Warning: IP TUNNEL TSO not supported therefore "
+		       "not enabled for port %d\n", port_id);
+	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
+		printf("Warning: UDP TUNNEL TSO not supported therefore "
+		       "not enabled for port %d\n", port_id);
 	return dev_info;
 }
 
@@ -4184,13 +4190,17 @@ cmd_tunnel_tso_set_parsed(void *parsed_result,
 			~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
 			  DEV_TX_OFFLOAD_GRE_TNL_TSO |
 			  DEV_TX_OFFLOAD_IPIP_TNL_TSO |
-			  DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
+			  DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
+			  DEV_TX_OFFLOAD_IP_TNL_TSO |
+			  DEV_TX_OFFLOAD_UDP_TNL_TSO);
 		printf("TSO for tunneled packets is disabled\n");
 	} else {
 		uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
 					 DEV_TX_OFFLOAD_GRE_TNL_TSO |
 					 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
-					 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
+					 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
+					 DEV_TX_OFFLOAD_IP_TNL_TSO |
+					 DEV_TX_OFFLOAD_UDP_TNL_TSO);
 
 		ports[res->port_id].dev_conf.txmode.offloads |=
 			(tso_offloads & dev_info.tx_offload_capa);
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index dd051f5ca..f329a8810 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -722,6 +722,23 @@ port_offload_cap_display(portid_t port_id)
 			printf("off\n");
 	}
 
+	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO) {
+		printf("IP tunnel TSO:  ");
+		if (ports[port_id].dev_conf.txmode.offloads &
+		    DEV_TX_OFFLOAD_IP_TNL_TSO)
+			printf("on\n");
+		else
+			printf("off\n");
+	}
+
+	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO) {
+		printf("UDP tunnel TSO:  ");
+		if (ports[port_id].dev_conf.txmode.offloads &
+		    DEV_TX_OFFLOAD_UDP_TNL_TSO)
+			printf("on\n");
+		else
+			printf("off\n");
+	}
 }
 
 int
-- 
2.13.3

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

* Re: [dpdk-dev] [PATCH v6 1/2] ethdev: introduce generic IP/UDP tunnel checksum and TSO
  2018-04-18 18:02           ` Thomas Monjalon
@ 2018-04-23  9:55             ` Olivier Matz
  0 siblings, 0 replies; 80+ messages in thread
From: Olivier Matz @ 2018-04-23  9:55 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: Ananyev, Konstantin, Xueming Li, Lu, Wenzhuo, Wu, Jingjing,
	Yongseok Koh, Shahaf Shuler, Iremonger, Bernard, Yigit, Ferruh,
	dev

On Wed, Apr 18, 2018 at 08:02:35PM +0200, Thomas Monjalon wrote:
> 18/04/2018 18:45, Ananyev, Konstantin:
> > From: Thomas Monjalon
> > > 18/04/2018 15:58, Xueming Li:
> > > > The new flag PKT_TX_TUNNEL_IP is redundant with PKT_TX_OUTER_IP_CKSUM.
> > > > The old flag PKT_TX_OUTER_IP_CKSUM can be deprecated and removed in
> > > > later release.
> > > >
> > > > Signed-off-by: Xueming Li <xuemingl@mellanox.com>
> > > 
> > > Except a small comment below, it looks OK.
> > > 
> > > Acked-by: Thomas Monjalon <thomas@monjalon.net>
> > > 
> > > Please send a deprecation notice for PKT_TX_OUTER_IP_CKSUM.
> > 
> > I probably missed something, but why PKT_TX_OUTER_IP_CKSUM
> > is supposed to be deprecated?
> 
> Because PKT_TX_TUNNEL_* flags sepersede it. I think we need to discuss it.
> 
> We use the offload flags PKT_TX_TUNNEL_* when we request some offloads
> in the outer and the inner headers at the same time.
> When setting a tunnel flag PKT_TX_TUNNEL_*, it can be expected that
> the outer checksums will be offloaded, otherwise it is almost
> impossible to request an offload in the inner header.
> In the case of an UDP tunnel, any change in the inner packet will
> require an UDP checksum update.
> In the case of an IP tunnel, a change of the inner packet size
> (like TSO) will require an IP checksum update.
> 
> If we really require PKT_TX_OUTER_IP_CKSUM to be set in addition to
> PKT_TX_TUNNEL_* flags, then we should add more PKT_TX_OUTER_*_CKSUM,
> like PKT_TX_OUTER_UDP_CKSUM which is missing.

I agree, I think PKT_TX_TUNNEL_* implies PKT_TX_OUTER_IP_CKSUM.
And I don't see use-case where we only need PKT_TX_OUTER_IP_CKSUM,
because in that case we can use PKT_TX_IP_CKSUM.

But this can be discussed in a second step, for now I think it's safer
to keep it as is.

Olivier

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

* Re: [dpdk-dev] [PATCH v7 1/2] ethdev: introduce generic IP/UDP tunnel checksum and TSO
  2018-04-20 12:48       ` [dpdk-dev] [PATCH v7 1/2] ethdev: introduce generic IP/UDP tunnel checksum and TSO Xueming Li
@ 2018-04-23  9:59         ` Olivier Matz
  0 siblings, 0 replies; 80+ messages in thread
From: Olivier Matz @ 2018-04-23  9:59 UTC (permalink / raw)
  To: Xueming Li
  Cc: Wenzhuo Lu, Jingjing Wu, Thomas Monjalon, Yongseok Koh,
	Shahaf Shuler, Ferruh Yigit, dev,
	AnanyevKonstantinkonstantin.ananyev

Hi Xueming,

First, sorry for the lack of quick feedback on this series.

On Fri, Apr 20, 2018 at 08:48:58PM +0800, Xueming Li wrote:
> This patch introduce new TX offload flags for device that supports
> IP or UDP tunneled packet L3/L4 checksum and TSO offload.
> It will be used for non-standard tunnels.
> 
> The support from the device is for inner and outer checksums on
> IPV4/TCP/UDP and TSO for *any packet with the following format*:
> 
> <some headers> / [optional IPv4/IPv6] / [optional TCP/UDP] / <some
> headers> / [optional inner IPv4/IPv6] / [optional TCP/UDP]
> 
> For example the following packets can use this feature:
> 
> 1. eth / ipv4 / udp / VXLAN / ip / tcp
> 2. eth / ipv4 / GRE / MPLS / ipv4 / udp
> 
> Please note that specific tunnel headers that contain payload length,
> sequence id or checksum will not be updated.
> 
> Signed-off-by: Xueming Li <xuemingl@mellanox.com>
> Acked-by: Thomas Monjalon <thomas@monjalon.net>

[...]

> --- a/lib/librte_mbuf/rte_mbuf.h
> +++ b/lib/librte_mbuf/rte_mbuf.h
> @@ -210,6 +210,31 @@ extern "C" {
>  #define PKT_TX_TUNNEL_GENEVE  (0x4ULL << 45)
>  /**< TX packet with MPLS-in-UDP RFC 7510 header. */
>  #define PKT_TX_TUNNEL_MPLSINUDP (0x5ULL << 45)
> +/**
> + * Generic IP encapsulated tunnel type, used for TSO and checksum offload.
> + * It can be used for tunnels which are not standards or listed above.
> + * It is preferred to use specific tunnel flags like PKT_TX_TUNNEL_GRE
> + * or PKT_TX_TUNNEL_IPIP if possible.
> + * The ethdev must be configured with DEV_TX_OFFLOAD_IP_TNL_TSO.
> + * Outer and inner checksums are done according to the existing flags like
> + * PKT_TX_xxx_CKSUM.
> + * Specific tunnel headers that contain payload length, sequence id
> + * or checksum are not expected to be updated.
> + */
> +#define PKT_TX_TUNNEL_IP (0xDULL << 45)
> +/**
> + * Generic UDP encapsulated tunnel type, used for TSO and checksum offload.
> + * UDP tunnel type implies outer IP layer.
> + * It can be used for tunnels which are not standards or listed above.
> + * It is preferred to use specific tunnel flags like PKT_TX_TUNNEL_GRE
> + * or PKT_TX_TUNNEL_IPIP if possible.

Minor comment:
A better example here, instead of GRE and IPIP, could be VXLAN because
it is UDP-based.

Then,
Acked-by: Olivier Matz <olivier.matz@6wind.com>

Thanks

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

* [dpdk-dev] [PATCH v8 0/2] support Tx generic tunnel checksum and TSO
  2018-04-20 12:48       ` [dpdk-dev] [PATCH v7 0/2] support Tx generic " Xueming Li
@ 2018-04-23 11:36         ` Xueming Li
  2018-04-23 16:17           ` Ferruh Yigit
  2018-04-23 11:36         ` [dpdk-dev] [PATCH v8 1/2] ethdev: introduce generic IP/UDP " Xueming Li
  2018-04-23 11:36         ` [dpdk-dev] [PATCH v8 2/2] app/testpmd: testpmd support Tx generic tunnel offloads Xueming Li
  2 siblings, 1 reply; 80+ messages in thread
From: Xueming Li @ 2018-04-23 11:36 UTC (permalink / raw)
  To: Wenzhuo Lu, Jingjing Wu, Thomas Monjalon, Yongseok Koh,
	Olivier MATZ, Shahaf Shuler
  Cc: Xueming Li, Ferruh Yigit, dev

V8:
- Fixed comment of PKT_TX_TUNNEL_UDP
V7:
- Removed PKT_TX_OUTER_IP_CKSUM deprecation suggestion from commit log

V6:
- Comments update according to maillist discussion.

V5:
- Removed duplicated testpmd patch in other pathset.
- More comments on PKT_TX_TUNNEL_IP and PKT_TX_TUNNEL_UDP

V4:
- Removed DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM and DEV_TX_OFFLOAD_GENERIC_TNL_TSO
- Replaced with DEV_TX_OFFLOAD_IP_TNL_TSO
- Removed PKT_TX_OUTER_UDP
- Splited PKT_TX_TUNNEL_UNKNOWN into PKT_TX_TUNNEL_IP and PKT_TX_TUNNEL_UDP

V3:
- Add VXLAN-GPE and GRE extention support to testpmd csum forwarding enginee
- Split DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO into DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM
  and DEV_TX_OFFLOAD_GENERIC_TNL_TSO
- Add PKT_TX_TUNNEL_UNKNOWN and PKT_TX_OUTER_UDP

  http://www.dpdk.org/dev/patchwork/patch/34655/



Xueming Li (2):
  ethdev: introduce generic IP/UDP tunnel checksum and TSO
  app/testpmd: testpmd support Tx generic tunnel offloads

 app/test-pmd/cmdline.c        | 14 ++++++++++++--
 app/test-pmd/config.c         | 17 +++++++++++++++++
 lib/librte_ether/rte_ethdev.h | 12 ++++++++++++
 lib/librte_mbuf/rte_mbuf.c    |  6 ++++++
 lib/librte_mbuf/rte_mbuf.h    | 25 +++++++++++++++++++++++++
 5 files changed, 72 insertions(+), 2 deletions(-)

-- 
2.13.3

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

* [dpdk-dev] [PATCH v8 1/2] ethdev: introduce generic IP/UDP tunnel checksum and TSO
  2018-04-20 12:48       ` [dpdk-dev] [PATCH v7 0/2] support Tx generic " Xueming Li
  2018-04-23 11:36         ` [dpdk-dev] [PATCH v8 " Xueming Li
@ 2018-04-23 11:36         ` Xueming Li
  2018-04-23 11:49           ` Xueming Li
  2018-04-23 11:36         ` [dpdk-dev] [PATCH v8 2/2] app/testpmd: testpmd support Tx generic tunnel offloads Xueming Li
  2 siblings, 1 reply; 80+ messages in thread
From: Xueming Li @ 2018-04-23 11:36 UTC (permalink / raw)
  To: Wenzhuo Lu, Jingjing Wu, Thomas Monjalon, Yongseok Koh,
	Olivier MATZ, Shahaf Shuler
  Cc: Xueming Li, Ferruh Yigit, dev

This patch introduce new TX offload flags for device that supports
IP or UDP tunneled packet L3/L4 checksum and TSO offload.
It will be used for non-standard tunnels.

The support from the device is for inner and outer checksums on
IPV4/TCP/UDP and TSO for *any packet with the following format*:

<some headers> / [optional IPv4/IPv6] / [optional TCP/UDP] / <some
headers> / [optional inner IPv4/IPv6] / [optional TCP/UDP]

For example the following packets can use this feature:

1. eth / ipv4 / udp / VXLAN / ip / tcp
2. eth / ipv4 / GRE / MPLS / ipv4 / udp

Please note that specific tunnel headers that contain payload length,
sequence id or checksum will not be updated.

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
Acked-by: Thomas Monjalon <thomas@monjalon.net>
---
 lib/librte_ether/rte_ethdev.h | 12 ++++++++++++
 lib/librte_mbuf/rte_mbuf.c    |  6 ++++++
 lib/librte_mbuf/rte_mbuf.h    | 25 +++++++++++++++++++++++++
 3 files changed, 43 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 4f417f573..ef152dec6 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -980,6 +980,18 @@ struct rte_eth_conf {
  *   the same mempool and has refcnt = 1.
  */
 #define DEV_TX_OFFLOAD_SECURITY         0x00020000
+/**
+ * Device supports generic UDP tunneled packet TSO.
+ * Application must set PKT_TX_TUNNEL_UDP and other mbuf fields required
+ * for tunnel TSO.
+ */
+#define DEV_TX_OFFLOAD_UDP_TNL_TSO      0x00040000
+/**
+ * Device supports generic IP tunneled packet TSO.
+ * Application must set PKT_TX_TUNNEL_IP and other mbuf fields required
+ * for tunnel TSO.
+ */
+#define DEV_TX_OFFLOAD_IP_TNL_TSO       0x00080000
 
 /*
  * If new Tx offload capabilities are defined, they also must be
diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index 3f4c83305..64e960d4c 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -390,6 +390,8 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask)
 	case PKT_TX_TUNNEL_IPIP: return "PKT_TX_TUNNEL_IPIP";
 	case PKT_TX_TUNNEL_GENEVE: return "PKT_TX_TUNNEL_GENEVE";
 	case PKT_TX_TUNNEL_MPLSINUDP: return "PKT_TX_TUNNEL_MPLSINUDP";
+	case PKT_TX_TUNNEL_IP: return "PKT_TX_TUNNEL_IP";
+	case PKT_TX_TUNNEL_UDP: return "PKT_TX_TUNNEL_UDP";
 	case PKT_TX_MACSEC: return "PKT_TX_MACSEC";
 	case PKT_TX_SEC_OFFLOAD: return "PKT_TX_SEC_OFFLOAD";
 	default: return NULL;
@@ -424,6 +426,10 @@ rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
 		  "PKT_TX_TUNNEL_NONE" },
 		{ PKT_TX_TUNNEL_MPLSINUDP, PKT_TX_TUNNEL_MASK,
 		  "PKT_TX_TUNNEL_NONE" },
+		{ PKT_TX_TUNNEL_IP, PKT_TX_TUNNEL_MASK,
+		  "PKT_TX_TUNNEL_NONE" },
+		{ PKT_TX_TUNNEL_UDP, PKT_TX_TUNNEL_MASK,
+		  "PKT_TX_TUNNEL_NONE" },
 		{ PKT_TX_MACSEC, PKT_TX_MACSEC, NULL },
 		{ PKT_TX_SEC_OFFLOAD, PKT_TX_SEC_OFFLOAD, NULL },
 	};
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 06eceba37..9be1361e8 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -210,6 +210,31 @@ extern "C" {
 #define PKT_TX_TUNNEL_GENEVE  (0x4ULL << 45)
 /**< TX packet with MPLS-in-UDP RFC 7510 header. */
 #define PKT_TX_TUNNEL_MPLSINUDP (0x5ULL << 45)
+/**
+ * Generic IP encapsulated tunnel type, used for TSO and checksum offload.
+ * It can be used for tunnels which are not standards or listed above.
+ * It is preferred to use specific tunnel flags like PKT_TX_TUNNEL_GRE
+ * or PKT_TX_TUNNEL_IPIP if possible.
+ * The ethdev must be configured with DEV_TX_OFFLOAD_IP_TNL_TSO.
+ * Outer and inner checksums are done according to the existing flags like
+ * PKT_TX_xxx_CKSUM.
+ * Specific tunnel headers that contain payload length, sequence id
+ * or checksum are not expected to be updated.
+ */
+#define PKT_TX_TUNNEL_IP (0xDULL << 45)
+/**
+ * Generic UDP encapsulated tunnel type, used for TSO and checksum offload.
+ * UDP tunnel type implies outer IP layer.
+ * It can be used for tunnels which are not standards or listed above.
+ * It is preferred to use specific tunnel flags like PKT_TX_TUNNEL_VXLAN
+ * if possible.
+ * The ethdev must be configured with DEV_TX_OFFLOAD_UDP_TNL_TSO.
+ * Outer and inner checksums are done according to the existing flags like
+ * PKT_TX_xxx_CKSUM.
+ * Specific tunnel headers that contain payload length, sequence id
+ * or checksum are not expected to be updated.
+ */
+#define PKT_TX_TUNNEL_UDP (0xEULL << 45)
 /* add new TX TUNNEL type here */
 #define PKT_TX_TUNNEL_MASK    (0xFULL << 45)
 
-- 
2.13.3

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

* [dpdk-dev] [PATCH v8 2/2] app/testpmd: testpmd support Tx generic tunnel offloads
  2018-04-20 12:48       ` [dpdk-dev] [PATCH v7 0/2] support Tx generic " Xueming Li
  2018-04-23 11:36         ` [dpdk-dev] [PATCH v8 " Xueming Li
  2018-04-23 11:36         ` [dpdk-dev] [PATCH v8 1/2] ethdev: introduce generic IP/UDP " Xueming Li
@ 2018-04-23 11:36         ` Xueming Li
  2 siblings, 0 replies; 80+ messages in thread
From: Xueming Li @ 2018-04-23 11:36 UTC (permalink / raw)
  To: Wenzhuo Lu, Jingjing Wu, Thomas Monjalon, Yongseok Koh,
	Olivier MATZ, Shahaf Shuler
  Cc: Xueming Li, Ferruh Yigit, dev

"show port cap" and "csum parse tunnel" command support TX generic
tunnel offloads

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
---
 app/test-pmd/cmdline.c | 14 ++++++++++++--
 app/test-pmd/config.c  | 17 +++++++++++++++++
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 512e3b55e..4ec3dab56 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -4157,6 +4157,12 @@ check_tunnel_tso_nic_support(portid_t port_id)
 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
 		printf("Warning: GENEVE TUNNEL TSO not supported therefore "
 		       "not enabled for port %d\n", port_id);
+	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
+		printf("Warning: IP TUNNEL TSO not supported therefore "
+		       "not enabled for port %d\n", port_id);
+	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
+		printf("Warning: UDP TUNNEL TSO not supported therefore "
+		       "not enabled for port %d\n", port_id);
 	return dev_info;
 }
 
@@ -4184,13 +4190,17 @@ cmd_tunnel_tso_set_parsed(void *parsed_result,
 			~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
 			  DEV_TX_OFFLOAD_GRE_TNL_TSO |
 			  DEV_TX_OFFLOAD_IPIP_TNL_TSO |
-			  DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
+			  DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
+			  DEV_TX_OFFLOAD_IP_TNL_TSO |
+			  DEV_TX_OFFLOAD_UDP_TNL_TSO);
 		printf("TSO for tunneled packets is disabled\n");
 	} else {
 		uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
 					 DEV_TX_OFFLOAD_GRE_TNL_TSO |
 					 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
-					 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
+					 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
+					 DEV_TX_OFFLOAD_IP_TNL_TSO |
+					 DEV_TX_OFFLOAD_UDP_TNL_TSO);
 
 		ports[res->port_id].dev_conf.txmode.offloads |=
 			(tso_offloads & dev_info.tx_offload_capa);
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index dd051f5ca..f329a8810 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -722,6 +722,23 @@ port_offload_cap_display(portid_t port_id)
 			printf("off\n");
 	}
 
+	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO) {
+		printf("IP tunnel TSO:  ");
+		if (ports[port_id].dev_conf.txmode.offloads &
+		    DEV_TX_OFFLOAD_IP_TNL_TSO)
+			printf("on\n");
+		else
+			printf("off\n");
+	}
+
+	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO) {
+		printf("UDP tunnel TSO:  ");
+		if (ports[port_id].dev_conf.txmode.offloads &
+		    DEV_TX_OFFLOAD_UDP_TNL_TSO)
+			printf("on\n");
+		else
+			printf("off\n");
+	}
 }
 
 int
-- 
2.13.3

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

* [dpdk-dev] [PATCH v8 1/2] ethdev: introduce generic IP/UDP tunnel checksum and TSO
  2018-04-23 11:36         ` [dpdk-dev] [PATCH v8 1/2] ethdev: introduce generic IP/UDP " Xueming Li
@ 2018-04-23 11:49           ` Xueming Li
  0 siblings, 0 replies; 80+ messages in thread
From: Xueming Li @ 2018-04-23 11:49 UTC (permalink / raw)
  To: Wenzhuo Lu, Jingjing Wu, Thomas Monjalon, Yongseok Koh,
	Olivier MATZ, Shahaf Shuler
  Cc: Xueming Li, Ferruh Yigit, dev

This patch introduce new TX offload flags for device that supports
IP or UDP tunneled packet L3/L4 checksum and TSO offload.
It will be used for non-standard tunnels.

The support from the device is for inner and outer checksums on
IPV4/TCP/UDP and TSO for *any packet with the following format*:

<some headers> / [optional IPv4/IPv6] / [optional TCP/UDP] / <some
headers> / [optional inner IPv4/IPv6] / [optional TCP/UDP]

For example the following packets can use this feature:

1. eth / ipv4 / udp / VXLAN / ip / tcp
2. eth / ipv4 / GRE / MPLS / ipv4 / udp

Please note that specific tunnel headers that contain payload length,
sequence id or checksum will not be updated.

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
Acked-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
---
 lib/librte_ether/rte_ethdev.h | 12 ++++++++++++
 lib/librte_mbuf/rte_mbuf.c    |  6 ++++++
 lib/librte_mbuf/rte_mbuf.h    | 25 +++++++++++++++++++++++++
 3 files changed, 43 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 4f417f573..ef152dec6 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -980,6 +980,18 @@ struct rte_eth_conf {
  *   the same mempool and has refcnt = 1.
  */
 #define DEV_TX_OFFLOAD_SECURITY         0x00020000
+/**
+ * Device supports generic UDP tunneled packet TSO.
+ * Application must set PKT_TX_TUNNEL_UDP and other mbuf fields required
+ * for tunnel TSO.
+ */
+#define DEV_TX_OFFLOAD_UDP_TNL_TSO      0x00040000
+/**
+ * Device supports generic IP tunneled packet TSO.
+ * Application must set PKT_TX_TUNNEL_IP and other mbuf fields required
+ * for tunnel TSO.
+ */
+#define DEV_TX_OFFLOAD_IP_TNL_TSO       0x00080000
 
 /*
  * If new Tx offload capabilities are defined, they also must be
diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index 3f4c83305..64e960d4c 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -390,6 +390,8 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask)
 	case PKT_TX_TUNNEL_IPIP: return "PKT_TX_TUNNEL_IPIP";
 	case PKT_TX_TUNNEL_GENEVE: return "PKT_TX_TUNNEL_GENEVE";
 	case PKT_TX_TUNNEL_MPLSINUDP: return "PKT_TX_TUNNEL_MPLSINUDP";
+	case PKT_TX_TUNNEL_IP: return "PKT_TX_TUNNEL_IP";
+	case PKT_TX_TUNNEL_UDP: return "PKT_TX_TUNNEL_UDP";
 	case PKT_TX_MACSEC: return "PKT_TX_MACSEC";
 	case PKT_TX_SEC_OFFLOAD: return "PKT_TX_SEC_OFFLOAD";
 	default: return NULL;
@@ -424,6 +426,10 @@ rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
 		  "PKT_TX_TUNNEL_NONE" },
 		{ PKT_TX_TUNNEL_MPLSINUDP, PKT_TX_TUNNEL_MASK,
 		  "PKT_TX_TUNNEL_NONE" },
+		{ PKT_TX_TUNNEL_IP, PKT_TX_TUNNEL_MASK,
+		  "PKT_TX_TUNNEL_NONE" },
+		{ PKT_TX_TUNNEL_UDP, PKT_TX_TUNNEL_MASK,
+		  "PKT_TX_TUNNEL_NONE" },
 		{ PKT_TX_MACSEC, PKT_TX_MACSEC, NULL },
 		{ PKT_TX_SEC_OFFLOAD, PKT_TX_SEC_OFFLOAD, NULL },
 	};
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 06eceba37..9be1361e8 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -210,6 +210,31 @@ extern "C" {
 #define PKT_TX_TUNNEL_GENEVE  (0x4ULL << 45)
 /**< TX packet with MPLS-in-UDP RFC 7510 header. */
 #define PKT_TX_TUNNEL_MPLSINUDP (0x5ULL << 45)
+/**
+ * Generic IP encapsulated tunnel type, used for TSO and checksum offload.
+ * It can be used for tunnels which are not standards or listed above.
+ * It is preferred to use specific tunnel flags like PKT_TX_TUNNEL_GRE
+ * or PKT_TX_TUNNEL_IPIP if possible.
+ * The ethdev must be configured with DEV_TX_OFFLOAD_IP_TNL_TSO.
+ * Outer and inner checksums are done according to the existing flags like
+ * PKT_TX_xxx_CKSUM.
+ * Specific tunnel headers that contain payload length, sequence id
+ * or checksum are not expected to be updated.
+ */
+#define PKT_TX_TUNNEL_IP (0xDULL << 45)
+/**
+ * Generic UDP encapsulated tunnel type, used for TSO and checksum offload.
+ * UDP tunnel type implies outer IP layer.
+ * It can be used for tunnels which are not standards or listed above.
+ * It is preferred to use specific tunnel flags like PKT_TX_TUNNEL_VXLAN
+ * if possible.
+ * The ethdev must be configured with DEV_TX_OFFLOAD_UDP_TNL_TSO.
+ * Outer and inner checksums are done according to the existing flags like
+ * PKT_TX_xxx_CKSUM.
+ * Specific tunnel headers that contain payload length, sequence id
+ * or checksum are not expected to be updated.
+ */
+#define PKT_TX_TUNNEL_UDP (0xEULL << 45)
 /* add new TX TUNNEL type here */
 #define PKT_TX_TUNNEL_MASK    (0xFULL << 45)
 
-- 
2.13.3

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

* Re: [dpdk-dev] [PATCH v8 0/2] support Tx generic tunnel checksum and TSO
  2018-04-23 11:36         ` [dpdk-dev] [PATCH v8 " Xueming Li
@ 2018-04-23 16:17           ` Ferruh Yigit
  0 siblings, 0 replies; 80+ messages in thread
From: Ferruh Yigit @ 2018-04-23 16:17 UTC (permalink / raw)
  To: Xueming Li, Wenzhuo Lu, Jingjing Wu, Thomas Monjalon,
	Yongseok Koh, Olivier MATZ, Shahaf Shuler
  Cc: dev

On 4/23/2018 12:36 PM, Xueming Li wrote:
> V8:
> - Fixed comment of PKT_TX_TUNNEL_UDP
> V7:
> - Removed PKT_TX_OUTER_IP_CKSUM deprecation suggestion from commit log
> 
> V6:
> - Comments update according to maillist discussion.
> 
> V5:
> - Removed duplicated testpmd patch in other pathset.
> - More comments on PKT_TX_TUNNEL_IP and PKT_TX_TUNNEL_UDP
> 
> V4:
> - Removed DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM and DEV_TX_OFFLOAD_GENERIC_TNL_TSO
> - Replaced with DEV_TX_OFFLOAD_IP_TNL_TSO
> - Removed PKT_TX_OUTER_UDP
> - Splited PKT_TX_TUNNEL_UNKNOWN into PKT_TX_TUNNEL_IP and PKT_TX_TUNNEL_UDP
> 
> V3:
> - Add VXLAN-GPE and GRE extention support to testpmd csum forwarding enginee
> - Split DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM_TSO into DEV_TX_OFFLOAD_GENERIC_TNL_CKSUM
>   and DEV_TX_OFFLOAD_GENERIC_TNL_TSO
> - Add PKT_TX_TUNNEL_UNKNOWN and PKT_TX_OUTER_UDP
> 
>   http://www.dpdk.org/dev/patchwork/patch/34655/
> 
> 
> 
> Xueming Li (2):
>   ethdev: introduce generic IP/UDP tunnel checksum and TSO
>   app/testpmd: testpmd support Tx generic tunnel offloads

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

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

end of thread, other threads:[~2018-04-23 16:17 UTC | newest]

Thread overview: 80+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-09 14:11 [dpdk-dev] [PATCH 0/6] Support generic tunnel TX csum and TSO Xueming Li
2018-01-09 14:11 ` [dpdk-dev] [PATCH 1/6] net/mlx5: support tx swp tunnel offloading Xueming Li
2018-01-29 15:08   ` [dpdk-dev] [PATCH v2 1/5] ethdev: introduce Tx generic tunnel offloads Xueming Li
2018-01-29 16:49     ` Ananyev, Konstantin
2018-01-30  3:01       ` Xueming(Steven) Li
2018-01-30 13:28         ` Ananyev, Konstantin
2018-01-30 15:27           ` Xueming(Steven) Li
2018-01-30 15:33             ` Ananyev, Konstantin
2018-01-30 15:47               ` Xueming(Steven) Li
2018-01-30 16:02                 ` Ananyev, Konstantin
2018-01-30 16:10                   ` Xueming(Steven) Li
2018-01-30 17:04                     ` Ananyev, Konstantin
2018-01-30 17:54                       ` Xueming(Steven) Li
2018-01-30 20:21                         ` Thomas Monjalon
2018-01-31 15:20                           ` Xueming(Steven) Li
2018-01-31 15:17                         ` Xueming(Steven) Li
2018-01-29 15:08   ` [dpdk-dev] [PATCH v2 2/5] app/testpmd: testpmd support " Xueming Li
2018-01-29 15:08   ` [dpdk-dev] [PATCH v2 3/5] net/mlx5: separate TSO function in Tx data path Xueming Li
2018-01-29 15:08   ` [dpdk-dev] [PATCH v2 4/5] net/mlx5: support generic tunnel offloading Xueming Li
2018-01-29 15:08   ` [dpdk-dev] [PATCH v2 5/5] net/mlx5: allow max 192B TSO inline header length Xueming Li
2018-03-05 14:51   ` [dpdk-dev] [PATCH v3 0/7] support generic tunnel Tx checksum and TSO Xueming Li
2018-03-05 14:51   ` [dpdk-dev] [PATCH v3 1/7] ethdev: introduce Tx generic tunnel L3/L4 offload Xueming Li
2018-03-21  1:40     ` Yongseok Koh
2018-03-22 13:55       ` Xueming(Steven) Li
2018-03-28 12:52         ` Olivier Matz
2018-04-04  8:20           ` Xueming(Steven) Li
2018-03-05 14:51   ` [dpdk-dev] [PATCH v3 2/7] app/testpmd: testpmd support Tx generic tunnel offloads Xueming Li
2018-03-05 14:51   ` [dpdk-dev] [PATCH v3 3/7] app/testpmd: add more GRE extension to csum engine Xueming Li
2018-03-05 14:51   ` [dpdk-dev] [PATCH v3 4/7] app/testpmd: introduce VXLAN GPE to csum forwarding engine Xueming Li
2018-03-05 14:51   ` [dpdk-dev] [PATCH v3 5/7] net/mlx5: separate TSO function in Tx data path Xueming Li
2018-03-05 14:51   ` [dpdk-dev] [PATCH v3 6/7] net/mlx5: support generic tunnel offloading Xueming Li
2018-03-05 14:51   ` [dpdk-dev] [PATCH v3 7/7] net/mlx5: allow max 192B TSO inline header length Xueming Li
2018-04-08 12:32   ` [dpdk-dev] [PATCH v4 0/4] support Tx generic tunnel checksum and TSO Xueming Li
2018-04-17 14:43     ` [dpdk-dev] [PATCH v5 0/2] " Xueming Li
2018-04-17 14:47     ` [dpdk-dev] [PATCH v5 1/2] ethdev: introduce generic IP/UDP " Xueming Li
2018-04-17 21:21       ` Thomas Monjalon
2018-04-17 14:49     ` [dpdk-dev] [PATCH v5 2/2] app/testpmd: testpmd support Tx generic tunnel offloads Xueming Li
2018-04-18 13:38     ` [dpdk-dev] [PATCH v6 0/2] support Tx generic tunnel checksum and TSO Xueming Li
2018-04-18 13:58     ` [dpdk-dev] [PATCH v6 1/2] ethdev: introduce generic IP/UDP " Xueming Li
2018-04-18 14:28       ` Thomas Monjalon
2018-04-18 16:45         ` Ananyev, Konstantin
2018-04-18 18:02           ` Thomas Monjalon
2018-04-23  9:55             ` Olivier Matz
2018-04-20 12:48       ` [dpdk-dev] [PATCH v7 0/2] support Tx generic " Xueming Li
2018-04-23 11:36         ` [dpdk-dev] [PATCH v8 " Xueming Li
2018-04-23 16:17           ` Ferruh Yigit
2018-04-23 11:36         ` [dpdk-dev] [PATCH v8 1/2] ethdev: introduce generic IP/UDP " Xueming Li
2018-04-23 11:49           ` Xueming Li
2018-04-23 11:36         ` [dpdk-dev] [PATCH v8 2/2] app/testpmd: testpmd support Tx generic tunnel offloads Xueming Li
2018-04-20 12:48       ` [dpdk-dev] [PATCH v7 1/2] ethdev: introduce generic IP/UDP tunnel checksum and TSO Xueming Li
2018-04-23  9:59         ` Olivier Matz
2018-04-20 12:48       ` [dpdk-dev] [PATCH v7 2/2] app/testpmd: testpmd support Tx generic tunnel offloads Xueming Li
2018-04-18 13:59     ` [dpdk-dev] [PATCH v6 " Xueming Li
2018-04-08 12:32   ` [dpdk-dev] [PATCH v4 1/4] ethdev: introduce generic IP/UDP tunnel checksum and TSO Xueming Li
2018-04-16 22:42     ` Thomas Monjalon
2018-04-17  7:53       ` Xueming(Steven) Li
2018-04-17  8:10         ` Thomas Monjalon
2018-04-08 12:32   ` [dpdk-dev] [PATCH v4 2/4] app/testpmd: testpmd support Tx generic tunnel offloads Xueming Li
2018-04-17 14:24     ` Iremonger, Bernard
2018-04-17 15:44       ` Xueming(Steven) Li
2018-04-08 12:32   ` [dpdk-dev] [PATCH v4 3/4] app/testpmd: add more GRE extension to csum engine Xueming Li
2018-04-16 22:45     ` Thomas Monjalon
2018-04-17  5:19       ` Xueming(Steven) Li
2018-04-08 12:32   ` [dpdk-dev] [PATCH v4 4/4] app/testpmd: introduce VXLAN GPE to csum forwarding engine Xueming Li
2018-04-16 22:46     ` Thomas Monjalon
2018-04-17 13:56       ` Iremonger, Bernard
2018-04-17 14:12         ` Xueming(Steven) Li
2018-01-09 14:11 ` [dpdk-dev] [PATCH 2/6] net/mlx5: allow max 192B WQE TSO inline header length Xueming Li
2018-01-09 14:11 ` [dpdk-dev] [PATCH 3/6] net/mlx5: add SWP PCI parameter for TX common tunnel offloads Xueming Li
2018-01-09 14:11 ` [dpdk-dev] [PATCH 4/6] ethdev: introduce " Xueming Li
2018-01-11 18:38   ` Ferruh Yigit
2018-01-16 17:10   ` Olivier Matz
2018-01-16 17:28     ` Xueming(Steven) Li
2018-01-16 19:06       ` Shahaf Shuler
2018-01-22 12:46         ` Olivier Matz
2018-01-22 20:06           ` Shahaf Shuler
2018-01-17  0:50   ` Yongseok Koh
2018-01-09 14:11 ` [dpdk-dev] [PATCH 5/6] net/mlx5: support " Xueming Li
2018-01-09 14:11 ` [dpdk-dev] [PATCH 6/6] app/testpmd: testpmd " Xueming Li
2018-01-16  3:09   ` Lu, Wenzhuo

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