[dpdk-stable] patch 'net/enic: fix flow director SCTP matching' has been queued to LTS release 17.11.7

Yongseok Koh yskoh at mellanox.com
Tue Jul 23 02:59:49 CEST 2019


Hi,

FYI, your patch has been queued to LTS release 17.11.7

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objection by 07/27/19. So please
shout if anyone has objection.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Thanks.

Yongseok

---
>From c6b1b6f30009928ddd521cb626e160b59eba6e1c Mon Sep 17 00:00:00 2001
From: Hyong Youb Kim <hyonkim at cisco.com>
Date: Sat, 2 Mar 2019 02:42:40 -0800
Subject: [PATCH] net/enic: fix flow director SCTP matching

[ upstream commit 4182ee7f0239563916b1f730d5a58f534769ee5e ]

The firmware filter API does not have flags indicating "match SCTP
packet". Instead, the driver needs to explicitly add an IP match and
set the protocol number (132 for SCTP) in the IP header.

The existing code (copy_fltr_v2) has two bugs.

1. It sets the protocol number (132) in the match value, but not the
mask. The mask remains 0, so the match becomes a wildcard match. The
NIC ends up matching all protocol numbers (i.e. thinks non-SCTP
packets are SCTP).

2. It modifies the input argument (rte_eth_fdir_input). The driver
tracks filters using rte_hash_{add,del}_key(input). So, addding
(RTE_ETH_FILTER_ADD) and deleting (RTE_ETH_FILTER_DELETE) must use the
same input argument for the same filter. But, overwriting the protocol
number while adding the filter breaks this assumption, and causes
delete operation to fail.

So, set the mask as well as protocol value. Do not modify the input
argument, and use const in function signatures to make the intention
clear. Also move a couple function declarations to enic_clsf.c from
enic.h as they are strictly local.

Fixes: dfbd6a9cb504 ("net/enic: extend flow director support for 1300 series")

Signed-off-by: Hyong Youb Kim <hyonkim at cisco.com>
Reviewed-by: John Daley <johndale at cisco.com>
---
 drivers/net/enic/enic.h      |  8 ++------
 drivers/net/enic/enic_clsf.c | 38 ++++++++++++++++++++++++------------
 2 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/drivers/net/enic/enic.h b/drivers/net/enic/enic.h
index 8bbff18c0a..d8c1dfefbc 100644
--- a/drivers/net/enic/enic.h
+++ b/drivers/net/enic/enic.h
@@ -91,8 +91,8 @@ struct enic_fdir {
 	u32 modes;
 	u32 types_mask;
 	void (*copy_fltr_fn)(struct filter_v2 *filt,
-			     struct rte_eth_fdir_input *input,
-			     struct rte_eth_fdir_masks *masks);
+			     const struct rte_eth_fdir_input *input,
+			     const struct rte_eth_fdir_masks *masks);
 };
 
 struct enic_soft_stats {
@@ -303,9 +303,5 @@ int enic_set_mtu(struct enic *enic, uint16_t new_mtu);
 int enic_link_update(struct enic *enic);
 void enic_fdir_info(struct enic *enic);
 void enic_fdir_info_get(struct enic *enic, struct rte_eth_fdir_info *stats);
-void copy_fltr_v1(struct filter_v2 *fltr, struct rte_eth_fdir_input *input,
-		  struct rte_eth_fdir_masks *masks);
-void copy_fltr_v2(struct filter_v2 *fltr, struct rte_eth_fdir_input *input,
-		  struct rte_eth_fdir_masks *masks);
 extern const struct rte_flow_ops enic_flow_ops;
 #endif /* _ENIC_H_ */
diff --git a/drivers/net/enic/enic_clsf.c b/drivers/net/enic/enic_clsf.c
index c76af0d10c..e507399099 100644
--- a/drivers/net/enic/enic_clsf.c
+++ b/drivers/net/enic/enic_clsf.c
@@ -65,6 +65,13 @@
 
 #define ENICPMD_CLSF_HASH_ENTRIES       ENICPMD_FDIR_MAX
 
+static void copy_fltr_v1(struct filter_v2 *fltr,
+		const struct rte_eth_fdir_input *input,
+		const struct rte_eth_fdir_masks *masks);
+static void copy_fltr_v2(struct filter_v2 *fltr,
+		const struct rte_eth_fdir_input *input,
+		const struct rte_eth_fdir_masks *masks);
+
 void enic_fdir_stats_get(struct enic *enic, struct rte_eth_fdir_stats *stats)
 {
 	*stats = enic->fdir.stats;
@@ -108,9 +115,9 @@ enic_set_layer(struct filter_generic_1 *gp, unsigned int flag,
 /* Copy Flow Director filter to a VIC ipv4 filter (for Cisco VICs
  * without advanced filter support.
  */
-void
-copy_fltr_v1(struct filter_v2 *fltr, struct rte_eth_fdir_input *input,
-	     __rte_unused struct rte_eth_fdir_masks *masks)
+static void
+copy_fltr_v1(struct filter_v2 *fltr, const struct rte_eth_fdir_input *input,
+	     __rte_unused const struct rte_eth_fdir_masks *masks)
 {
 	fltr->type = FILTER_IPV4_5TUPLE;
 	fltr->u.ipv4.src_addr = rte_be_to_cpu_32(
@@ -133,9 +140,9 @@ copy_fltr_v1(struct filter_v2 *fltr, struct rte_eth_fdir_input *input,
 /* Copy Flow Director filter to a VIC generic filter (requires advanced
  * filter support.
  */
-void
-copy_fltr_v2(struct filter_v2 *fltr, struct rte_eth_fdir_input *input,
-	     struct rte_eth_fdir_masks *masks)
+static void
+copy_fltr_v2(struct filter_v2 *fltr, const struct rte_eth_fdir_input *input,
+	     const struct rte_eth_fdir_masks *masks)
 {
 	struct filter_generic_1 *gp = &fltr->u.generic_1;
 	int i;
@@ -193,9 +200,11 @@ copy_fltr_v2(struct filter_v2 *fltr, struct rte_eth_fdir_input *input,
 			sctp_val.tag = input->flow.sctp4_flow.verify_tag;
 		}
 
-		/* v4 proto should be 132, override ip4_flow.proto */
-		input->flow.ip4_flow.proto = 132;
-
+		/*
+		 * Unlike UDP/TCP (FILTER_GENERIC_1_{UDP,TCP}), the firmware
+		 * has no "packet is SCTP" flag. Use flag=0 (generic L4) and
+		 * manually set proto_id=sctp below.
+		 */
 		enic_set_layer(gp, 0, FILTER_GENERIC_1_L4, &sctp_mask,
 			       &sctp_val, sizeof(struct sctp_hdr));
 	}
@@ -219,6 +228,10 @@ copy_fltr_v2(struct filter_v2 *fltr, struct rte_eth_fdir_input *input,
 		if (input->flow.ip4_flow.proto) {
 			ip4_mask.next_proto_id = masks->ipv4_mask.proto;
 			ip4_val.next_proto_id = input->flow.ip4_flow.proto;
+		} else if (input->flow_type == RTE_ETH_FLOW_NONFRAG_IPV4_SCTP) {
+			/* Explicitly match the SCTP protocol number */
+			ip4_mask.next_proto_id = 0xff;
+			ip4_val.next_proto_id = IPPROTO_SCTP;
 		}
 		if (input->flow.ip4_flow.src_ip) {
 			ip4_mask.src_addr =  masks->ipv4_mask.src_ip;
@@ -281,9 +294,6 @@ copy_fltr_v2(struct filter_v2 *fltr, struct rte_eth_fdir_input *input,
 			sctp_val.tag = input->flow.sctp6_flow.verify_tag;
 		}
 
-		/* v4 proto should be 132, override ipv6_flow.proto */
-		input->flow.ipv6_flow.proto = 132;
-
 		enic_set_layer(gp, 0, FILTER_GENERIC_1_L4, &sctp_mask,
 			       &sctp_val, sizeof(struct sctp_hdr));
 	}
@@ -299,6 +309,10 @@ copy_fltr_v2(struct filter_v2 *fltr, struct rte_eth_fdir_input *input,
 		if (input->flow.ipv6_flow.proto) {
 			ipv6_mask.proto = masks->ipv6_mask.proto;
 			ipv6_val.proto = input->flow.ipv6_flow.proto;
+		} else if (input->flow_type == RTE_ETH_FLOW_NONFRAG_IPV6_SCTP) {
+			/* See comments for IPv4 SCTP above. */
+			ipv6_mask.proto = 0xff;
+			ipv6_val.proto = IPPROTO_SCTP;
 		}
 		for (i = 0; i < 4; i++) {
 			*(uint32_t *)&ipv6_mask.src_addr[i * 4] =
-- 
2.21.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2019-07-22 17:55:07.697516555 -0700
+++ 0022-net-enic-fix-flow-director-SCTP-matching.patch	2019-07-22 17:55:05.878471000 -0700
@@ -1,8 +1,10 @@
-From 4182ee7f0239563916b1f730d5a58f534769ee5e Mon Sep 17 00:00:00 2001
+From c6b1b6f30009928ddd521cb626e160b59eba6e1c Mon Sep 17 00:00:00 2001
 From: Hyong Youb Kim <hyonkim at cisco.com>
 Date: Sat, 2 Mar 2019 02:42:40 -0800
 Subject: [PATCH] net/enic: fix flow director SCTP matching
 
+[ upstream commit 4182ee7f0239563916b1f730d5a58f534769ee5e ]
+
 The firmware filter API does not have flags indicating "match SCTP
 packet". Instead, the driver needs to explicitly add an IP match and
 set the protocol number (132 for SCTP) in the IP header.
@@ -27,7 +29,6 @@
 enic.h as they are strictly local.
 
 Fixes: dfbd6a9cb504 ("net/enic: extend flow director support for 1300 series")
-Cc: stable at dpdk.org
 
 Signed-off-by: Hyong Youb Kim <hyonkim at cisco.com>
 Reviewed-by: John Daley <johndale at cisco.com>
@@ -37,10 +38,10 @@
  2 files changed, 28 insertions(+), 18 deletions(-)
 
 diff --git a/drivers/net/enic/enic.h b/drivers/net/enic/enic.h
-index 6c497e9a29..fa4d5590e4 100644
+index 8bbff18c0a..d8c1dfefbc 100644
 --- a/drivers/net/enic/enic.h
 +++ b/drivers/net/enic/enic.h
-@@ -76,8 +76,8 @@ struct enic_fdir {
+@@ -91,8 +91,8 @@ struct enic_fdir {
  	u32 modes;
  	u32 types_mask;
  	void (*copy_fltr_fn)(struct filter_v2 *filt,
@@ -51,8 +52,8 @@
  };
  
  struct enic_soft_stats {
-@@ -342,9 +342,5 @@ int enic_link_update(struct enic *enic);
- bool enic_use_vector_rx_handler(struct enic *enic);
+@@ -303,9 +303,5 @@ int enic_set_mtu(struct enic *enic, uint16_t new_mtu);
+ int enic_link_update(struct enic *enic);
  void enic_fdir_info(struct enic *enic);
  void enic_fdir_info_get(struct enic *enic, struct rte_eth_fdir_info *stats);
 -void copy_fltr_v1(struct filter_v2 *fltr, struct rte_eth_fdir_input *input,
@@ -62,10 +63,10 @@
  extern const struct rte_flow_ops enic_flow_ops;
  #endif /* _ENIC_H_ */
 diff --git a/drivers/net/enic/enic_clsf.c b/drivers/net/enic/enic_clsf.c
-index 9e9e548c23..48c8e62643 100644
+index c76af0d10c..e507399099 100644
 --- a/drivers/net/enic/enic_clsf.c
 +++ b/drivers/net/enic/enic_clsf.c
-@@ -36,6 +36,13 @@
+@@ -65,6 +65,13 @@
  
  #define ENICPMD_CLSF_HASH_ENTRIES       ENICPMD_FDIR_MAX
  
@@ -79,7 +80,7 @@
  void enic_fdir_stats_get(struct enic *enic, struct rte_eth_fdir_stats *stats)
  {
  	*stats = enic->fdir.stats;
-@@ -79,9 +86,9 @@ enic_set_layer(struct filter_generic_1 *gp, unsigned int flag,
+@@ -108,9 +115,9 @@ enic_set_layer(struct filter_generic_1 *gp, unsigned int flag,
  /* Copy Flow Director filter to a VIC ipv4 filter (for Cisco VICs
   * without advanced filter support.
   */
@@ -92,7 +93,7 @@
  {
  	fltr->type = FILTER_IPV4_5TUPLE;
  	fltr->u.ipv4.src_addr = rte_be_to_cpu_32(
-@@ -104,9 +111,9 @@ copy_fltr_v1(struct filter_v2 *fltr, struct rte_eth_fdir_input *input,
+@@ -133,9 +140,9 @@ copy_fltr_v1(struct filter_v2 *fltr, struct rte_eth_fdir_input *input,
  /* Copy Flow Director filter to a VIC generic filter (requires advanced
   * filter support.
   */
@@ -104,8 +105,8 @@
 +	     const struct rte_eth_fdir_masks *masks)
  {
  	struct filter_generic_1 *gp = &fltr->u.generic_1;
- 
-@@ -163,9 +170,11 @@ copy_fltr_v2(struct filter_v2 *fltr, struct rte_eth_fdir_input *input,
+ 	int i;
+@@ -193,9 +200,11 @@ copy_fltr_v2(struct filter_v2 *fltr, struct rte_eth_fdir_input *input,
  			sctp_val.tag = input->flow.sctp4_flow.verify_tag;
  		}
  
@@ -120,7 +121,7 @@
  		enic_set_layer(gp, 0, FILTER_GENERIC_1_L4, &sctp_mask,
  			       &sctp_val, sizeof(struct sctp_hdr));
  	}
-@@ -189,6 +198,10 @@ copy_fltr_v2(struct filter_v2 *fltr, struct rte_eth_fdir_input *input,
+@@ -219,6 +228,10 @@ copy_fltr_v2(struct filter_v2 *fltr, struct rte_eth_fdir_input *input,
  		if (input->flow.ip4_flow.proto) {
  			ip4_mask.next_proto_id = masks->ipv4_mask.proto;
  			ip4_val.next_proto_id = input->flow.ip4_flow.proto;
@@ -131,7 +132,7 @@
  		}
  		if (input->flow.ip4_flow.src_ip) {
  			ip4_mask.src_addr =  masks->ipv4_mask.src_ip;
-@@ -251,9 +264,6 @@ copy_fltr_v2(struct filter_v2 *fltr, struct rte_eth_fdir_input *input,
+@@ -281,9 +294,6 @@ copy_fltr_v2(struct filter_v2 *fltr, struct rte_eth_fdir_input *input,
  			sctp_val.tag = input->flow.sctp6_flow.verify_tag;
  		}
  
@@ -141,7 +142,7 @@
  		enic_set_layer(gp, 0, FILTER_GENERIC_1_L4, &sctp_mask,
  			       &sctp_val, sizeof(struct sctp_hdr));
  	}
-@@ -269,6 +279,10 @@ copy_fltr_v2(struct filter_v2 *fltr, struct rte_eth_fdir_input *input,
+@@ -299,6 +309,10 @@ copy_fltr_v2(struct filter_v2 *fltr, struct rte_eth_fdir_input *input,
  		if (input->flow.ipv6_flow.proto) {
  			ipv6_mask.proto = masks->ipv6_mask.proto;
  			ipv6_val.proto = input->flow.ipv6_flow.proto;
@@ -150,8 +151,8 @@
 +			ipv6_mask.proto = 0xff;
 +			ipv6_val.proto = IPPROTO_SCTP;
  		}
- 		memcpy(ipv6_mask.src_addr, masks->ipv6_mask.src_ip,
- 		       sizeof(ipv6_mask.src_addr));
+ 		for (i = 0; i < 4; i++) {
+ 			*(uint32_t *)&ipv6_mask.src_addr[i * 4] =
 -- 
 2.21.0
 


More information about the stable mailing list