patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Yuanhan Liu <yliu@fridaylinux.org>
To: Harish Patil <harish.patil@cavium.com>
Cc: dpdk stable <stable@dpdk.org>
Subject: [dpdk-stable] patch 'net/qede: check tunnel L3 header' has been queued to LTS release 17.11.1
Date: Thu,  1 Feb 2018 17:47:46 +0800	[thread overview]
Message-ID: <1517478479-12417-32-git-send-email-yliu@fridaylinux.org> (raw)
In-Reply-To: <1517478479-12417-1-git-send-email-yliu@fridaylinux.org>

Hi,

FYI, your patch has been queued to LTS release 17.11.1

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 02/03/18. So please
shout if anyone has objections.

Thanks.

	--yliu

---
>From c55f999d4b7ac6a1a8dbaf11507357311d06ea89 Mon Sep 17 00:00:00 2001
From: Harish Patil <harish.patil@cavium.com>
Date: Sat, 27 Jan 2018 13:15:27 -0800
Subject: [PATCH] net/qede: check tunnel L3 header

[ upstream commit 3f72dd780e1078191305e6ed4268f82ff3cf1e02 ]

- Add a check to verify tunnel IP header checksum is valid and mark MBUF
flag as appropriate.
- Bit of refactoring so that inner frame handling for tunneled packets can
be made common as regular (non-tunneled) packets.
- make qede_tunn_exist() as inline.
- remove RTE_PTYPE_L2_ETHER as default L2 pkt_type.

Fixes: 3d4bb4411683 ("net/qede: add fastpath support for VXLAN tunneling")

Signed-off-by: Harish Patil <harish.patil@cavium.com>
---
 drivers/net/qede/qede_rxtx.c | 143 +++++++++++++++++++++++++++----------------
 1 file changed, 91 insertions(+), 52 deletions(-)

diff --git a/drivers/net/qede/qede_rxtx.c b/drivers/net/qede/qede_rxtx.c
index 01a24e5..d210b06 100644
--- a/drivers/net/qede/qede_rxtx.c
+++ b/drivers/net/qede/qede_rxtx.c
@@ -812,12 +812,18 @@ void qede_stop_queues(struct rte_eth_dev *eth_dev)
 	}
 }
 
-static bool qede_tunn_exist(uint16_t flag)
+static inline bool qede_tunn_exist(uint16_t flag)
 {
 	return !!((PARSING_AND_ERR_FLAGS_TUNNELEXIST_MASK <<
 		    PARSING_AND_ERR_FLAGS_TUNNELEXIST_SHIFT) & flag);
 }
 
+static inline uint8_t qede_check_tunn_csum_l3(uint16_t flag)
+{
+	return !!((PARSING_AND_ERR_FLAGS_TUNNELIPHDRERROR_MASK <<
+		PARSING_AND_ERR_FLAGS_TUNNELIPHDRERROR_SHIFT) & flag);
+}
+
 /*
  * qede_check_tunn_csum_l4:
  * Returns:
@@ -844,33 +850,51 @@ static inline uint8_t qede_check_notunn_csum_l4(uint16_t flag)
 	return 0;
 }
 
-/* Returns outer L3 and L4 packet_type for tunneled packets */
+/* Returns outer L2, L3 and L4 packet_type for tunneled packets */
 static inline uint32_t qede_rx_cqe_to_pkt_type_outer(struct rte_mbuf *m)
 {
 	uint32_t packet_type = RTE_PTYPE_UNKNOWN;
 	struct ether_hdr *eth_hdr;
 	struct ipv4_hdr *ipv4_hdr;
 	struct ipv6_hdr *ipv6_hdr;
+	struct vlan_hdr *vlan_hdr;
+	uint16_t ethertype;
+	bool vlan_tagged = 0;
+	uint16_t len;
 
 	eth_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *);
-	if (eth_hdr->ether_type == rte_cpu_to_be_16(ETHER_TYPE_IPv4)) {
+	len = sizeof(struct ether_hdr);
+	ethertype = rte_cpu_to_be_16(eth_hdr->ether_type);
+
+	 /* Note: Valid only if VLAN stripping is disabled */
+	if (ethertype == ETHER_TYPE_VLAN) {
+		vlan_tagged = 1;
+		vlan_hdr = (struct vlan_hdr *)(eth_hdr + 1);
+		len += sizeof(struct vlan_hdr);
+		ethertype = rte_cpu_to_be_16(vlan_hdr->eth_proto);
+	}
+
+	if (ethertype == ETHER_TYPE_IPv4) {
 		packet_type |= RTE_PTYPE_L3_IPV4;
-		ipv4_hdr = rte_pktmbuf_mtod_offset(m, struct ipv4_hdr *,
-						   sizeof(struct ether_hdr));
+		ipv4_hdr = rte_pktmbuf_mtod_offset(m, struct ipv4_hdr *, len);
 		if (ipv4_hdr->next_proto_id == IPPROTO_TCP)
 			packet_type |= RTE_PTYPE_L4_TCP;
 		else if (ipv4_hdr->next_proto_id == IPPROTO_UDP)
 			packet_type |= RTE_PTYPE_L4_UDP;
-	} else if (eth_hdr->ether_type == rte_cpu_to_be_16(ETHER_TYPE_IPv6)) {
+	} else if (ethertype == ETHER_TYPE_IPv6) {
 		packet_type |= RTE_PTYPE_L3_IPV6;
-		ipv6_hdr = rte_pktmbuf_mtod_offset(m, struct ipv6_hdr *,
-						   sizeof(struct ether_hdr));
+		ipv6_hdr = rte_pktmbuf_mtod_offset(m, struct ipv6_hdr *, len);
 		if (ipv6_hdr->proto == IPPROTO_TCP)
 			packet_type |= RTE_PTYPE_L4_TCP;
 		else if (ipv6_hdr->proto == IPPROTO_UDP)
 			packet_type |= RTE_PTYPE_L4_UDP;
 	}
 
+	if (vlan_tagged)
+		packet_type |= RTE_PTYPE_L2_ETHER_VLAN;
+	else
+		packet_type |= RTE_PTYPE_L2_ETHER;
+
 	return packet_type;
 }
 
@@ -1163,17 +1187,17 @@ static inline uint32_t qede_rx_cqe_to_tunn_pkt_type(uint16_t flags)
 		[QEDE_PKT_TYPE_TUNN_GRE] = RTE_PTYPE_TUNNEL_GRE,
 		[QEDE_PKT_TYPE_TUNN_VXLAN] = RTE_PTYPE_TUNNEL_VXLAN,
 		[QEDE_PKT_TYPE_TUNN_L2_TENID_NOEXIST_GENEVE] =
-				RTE_PTYPE_TUNNEL_GENEVE | RTE_PTYPE_L2_ETHER,
+				RTE_PTYPE_TUNNEL_GENEVE,
 		[QEDE_PKT_TYPE_TUNN_L2_TENID_NOEXIST_GRE] =
-				RTE_PTYPE_TUNNEL_GRE | RTE_PTYPE_L2_ETHER,
+				RTE_PTYPE_TUNNEL_GRE,
 		[QEDE_PKT_TYPE_TUNN_L2_TENID_NOEXIST_VXLAN] =
-				RTE_PTYPE_TUNNEL_VXLAN | RTE_PTYPE_L2_ETHER,
+				RTE_PTYPE_TUNNEL_VXLAN,
 		[QEDE_PKT_TYPE_TUNN_L2_TENID_EXIST_GENEVE] =
-				RTE_PTYPE_TUNNEL_GENEVE | RTE_PTYPE_L2_ETHER,
+				RTE_PTYPE_TUNNEL_GENEVE,
 		[QEDE_PKT_TYPE_TUNN_L2_TENID_EXIST_GRE] =
-				RTE_PTYPE_TUNNEL_GRE | RTE_PTYPE_L2_ETHER,
+				RTE_PTYPE_TUNNEL_GRE,
 		[QEDE_PKT_TYPE_TUNN_L2_TENID_EXIST_VXLAN] =
-				RTE_PTYPE_TUNNEL_VXLAN | RTE_PTYPE_L2_ETHER,
+				RTE_PTYPE_TUNNEL_VXLAN,
 		[QEDE_PKT_TYPE_TUNN_IPV4_TENID_NOEXIST_GENEVE] =
 				RTE_PTYPE_TUNNEL_GENEVE | RTE_PTYPE_L3_IPV4,
 		[QEDE_PKT_TYPE_TUNN_IPV4_TENID_NOEXIST_GRE] =
@@ -1253,7 +1277,7 @@ print_rx_bd_info(struct rte_mbuf *m, struct qede_rx_queue *rxq,
 		 uint8_t bitfield)
 {
 	PMD_RX_LOG(INFO, rxq,
-		"len 0x%x bf 0x%x hash_val 0x%x"
+		"len 0x%04x bf 0x%04x hash_val 0x%x"
 		" ol_flags 0x%04lx l2=%s l3=%s l4=%s tunn=%s"
 		" inner_l2=%s inner_l3=%s inner_l4=%s\n",
 		m->data_len, bitfield, m->hash.rss,
@@ -1404,47 +1428,62 @@ qede_recv_pkts(void *p_rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 				ol_flags |= PKT_RX_L4_CKSUM_BAD;
 			} else {
 				ol_flags |= PKT_RX_L4_CKSUM_GOOD;
-				if (tpa_start_flg)
-					flags =
-					 cqe_start_tpa->tunnel_pars_flags.flags;
-				else
-					flags = fp_cqe->tunnel_pars_flags.flags;
-				tunn_parse_flag = flags;
-				/* Tunnel_type */
-				packet_type =
-				qede_rx_cqe_to_tunn_pkt_type(tunn_parse_flag);
-
-				/* Inner header */
-				packet_type |=
-				      qede_rx_cqe_to_pkt_type_inner(parse_flag);
-
-				/* Outer L3/L4 types is not available in CQE */
-				packet_type |=
-				      qede_rx_cqe_to_pkt_type_outer(rx_mb);
 			}
-		} else {
-			PMD_RX_LOG(INFO, rxq, "Rx non-tunneled packet\n");
-			if (unlikely(qede_check_notunn_csum_l4(parse_flag))) {
-				PMD_RX_LOG(ERR, rxq,
-					    "L4 csum failed, flags = 0x%x\n",
-					    parse_flag);
-				rxq->rx_hw_errors++;
-				ol_flags |= PKT_RX_L4_CKSUM_BAD;
-			} else {
-				ol_flags |= PKT_RX_L4_CKSUM_GOOD;
-			}
-			if (unlikely(qede_check_notunn_csum_l3(rx_mb,
-							parse_flag))) {
+
+			if (unlikely(qede_check_tunn_csum_l3(parse_flag))) {
 				PMD_RX_LOG(ERR, rxq,
-					   "IP csum failed, flags = 0x%x\n",
-					   parse_flag);
-				rxq->rx_hw_errors++;
-				ol_flags |= PKT_RX_IP_CKSUM_BAD;
+					"Outer L3 csum failed, flags = 0x%x\n",
+					parse_flag);
+				  rxq->rx_hw_errors++;
+				  ol_flags |= PKT_RX_EIP_CKSUM_BAD;
 			} else {
-				ol_flags |= PKT_RX_IP_CKSUM_GOOD;
-				packet_type =
-					qede_rx_cqe_to_pkt_type(parse_flag);
+				  ol_flags |= PKT_RX_IP_CKSUM_GOOD;
 			}
+
+			if (tpa_start_flg)
+				flags = cqe_start_tpa->tunnel_pars_flags.flags;
+			else
+				flags = fp_cqe->tunnel_pars_flags.flags;
+			tunn_parse_flag = flags;
+
+			/* Tunnel_type */
+			packet_type =
+				qede_rx_cqe_to_tunn_pkt_type(tunn_parse_flag);
+
+			/* Inner header */
+			packet_type |=
+			      qede_rx_cqe_to_pkt_type_inner(parse_flag);
+
+			/* Outer L3/L4 types is not available in CQE */
+			packet_type |= qede_rx_cqe_to_pkt_type_outer(rx_mb);
+
+			/* Outer L3/L4 types is not available in CQE.
+			 * Need to add offset to parse correctly,
+			 */
+			rx_mb->data_off = offset + RTE_PKTMBUF_HEADROOM;
+			packet_type |= qede_rx_cqe_to_pkt_type_outer(rx_mb);
+		}
+
+		/* Common handling for non-tunnel packets and for inner
+		 * headers in the case of tunnel.
+		 */
+		if (unlikely(qede_check_notunn_csum_l4(parse_flag))) {
+			PMD_RX_LOG(ERR, rxq,
+				    "L4 csum failed, flags = 0x%x\n",
+				    parse_flag);
+			rxq->rx_hw_errors++;
+			ol_flags |= PKT_RX_L4_CKSUM_BAD;
+		} else {
+			ol_flags |= PKT_RX_L4_CKSUM_GOOD;
+		}
+		if (unlikely(qede_check_notunn_csum_l3(rx_mb, parse_flag))) {
+			PMD_RX_LOG(ERR, rxq, "IP csum failed, flags = 0x%x\n",
+				   parse_flag);
+			rxq->rx_hw_errors++;
+			ol_flags |= PKT_RX_IP_CKSUM_BAD;
+		} else {
+			ol_flags |= PKT_RX_IP_CKSUM_GOOD;
+			packet_type |= qede_rx_cqe_to_pkt_type(parse_flag);
 		}
 
 		if (CQE_HAS_VLAN(parse_flag) ||
-- 
2.7.4

  parent reply	other threads:[~2018-02-01  9:49 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-01  9:47 [dpdk-stable] patch 'event/sw: fix debug logging config option' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'service: fix possible mem leak on initialize' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'cmdline: fix dynamic tokens parsing' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'cmdline: avoid garbage in unused fields of parsed result' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'keepalive: fix state alignment' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'log: fix memory leak in regexp level set' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'eal/arm64: remove the braces in memory barrier macros' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'mbuf: fix NULL freeing when debug enabled' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'crypto/qat: fix out-of-bounds access' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'crypto/qat: fix parameter type' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'cryptodev: fix session pointer cast' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'crypto/qat: fix null auth algo overwrite' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/mlx5: fix return value of start operation' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/enic: fix crash due to static max number of queues' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/e1000: fix null pointer check' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/i40e: fix memory leak' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/mlx5: fix missing RSS capability' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/mlx5: fix flow item validation' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/mlx5: fix memory region cache lookup' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/mlx5: fix memory region cache last index' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/mlx5: fix memory region boundary checks' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/ena: do not set Tx L4 offloads in Rx path' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/virtio-user: fix crash as features change' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/virtio: fix Rx and Tx handler selection for ARM32' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/virtio: fix queue flushing with vector Rx enabled' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/virtio: fix memory leak when reinitializing device' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/i40e: fix VF Rx interrupt enabling' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/ixgbe: " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/e1000: " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/bnxt: fix size of Tx ring in HW' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/bnxt: fix number of pools for RSS' " Yuanhan Liu
2018-02-01  9:47 ` Yuanhan Liu [this message]
2018-02-01  9:47 ` [dpdk-stable] patch 'net/qede: fix tunnel header size in Tx BD configuration' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/qede: fix MTU set and max Rx length' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'eal/ppc: remove the braces in memory barrier macros' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'crypto/dpaa2_sec: fix enum conversion for GCM' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'mk: support renamed Makefile in external project' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'crypto/scheduler: fix strncpy' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'ethdev: fix port data reset timing' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'ethdev: fix port id allocation' " Yuanhan Liu
2018-02-11  2:46   ` Yuanhan Liu
2018-02-11  6:40     ` Matan Azrad
2018-02-11  6:54       ` Yuanhan Liu
2018-02-11  7:15         ` Matan Azrad
2018-02-01  9:47 ` [dpdk-stable] patch 'app/testpmd: fix port validation' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/ixgbe: fix reset error handling' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'examples/bond: fix vdev name' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'crypto/qat: fix allocation check and leak' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'examples/bond: check mbuf allocation' " Yuanhan Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1517478479-12417-32-git-send-email-yliu@fridaylinux.org \
    --to=yliu@fridaylinux.org \
    --cc=harish.patil@cavium.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).