[v2] net/i40e: enable MAC address as FDIR input set

Message ID 20200318031506.79773-1-lunyuanx.cui@intel.com (mailing list archive)
State Superseded, archived
Delegated to: xiaolong ye
Headers
Series [v2] net/i40e: enable MAC address as FDIR input set |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS
ci/travis-robot warning Travis build: failed
ci/Intel-compilation success Compilation OK

Commit Message

Cui, LunyuanX March 18, 2020, 3:15 a.m. UTC
  FVL enable both src MAC address and dst MAC address as FDIR's input
set for ipv4-other. And FVL enable only dst MAC address as FDIR's
input set for ipv4-other. When OVS-DPDK is working as a pure L2 switch,
Both two ways match offload with Mark+RSS action would help the
performance speed up. And FVL FDIR supports to change input set as
both two ways.

Signed-off-by: Lunyuan Cui <lunyuanx.cui@intel.com>

---
v2:
 - Enable src MAC address as FDIR's input set
---
 doc/guides/rel_notes/release_20_05.rst |  7 +++
 drivers/net/i40e/i40e_ethdev.c         |  1 +
 drivers/net/i40e/i40e_ethdev.h         | 18 +++++++-
 drivers/net/i40e/i40e_fdir.c           | 22 +++++++--
 drivers/net/i40e/i40e_flow.c           | 63 +++++++++++++++++++-------
 5 files changed, 89 insertions(+), 22 deletions(-)
  

Comments

Xing, Beilei March 27, 2020, 12:18 p.m. UTC | #1
> -----Original Message-----
> From: Cui, LunyuanX <lunyuanx.cui@intel.com>
> Sent: Wednesday, March 18, 2020 11:15 AM
> To: dev@dpdk.org
> Cc: Xing, Beilei <beilei.xing@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>;
> Wu, Jingjing <jingjing.wu@intel.com>; Cui, LunyuanX
> <lunyuanx.cui@intel.com>
> Subject: [PATCH v2] net/i40e: enable MAC address as FDIR input set
> 
> FVL enable both src MAC address and dst MAC address as FDIR's input set
> for ipv4-other. And FVL enable only dst MAC address as FDIR's input set for
> ipv4-other. 

Why emphasize input set 'src MAC address and dst MAC address' and ' dst MAC address ' as input set?
Can't we support src MAC only?

When OVS-DPDK is working as a pure L2 switch, Both two ways
> match offload with Mark+RSS action would help the performance speed up.
> And FVL FDIR supports to change input set as both two ways.
> 
> Signed-off-by: Lunyuan Cui <lunyuanx.cui@intel.com>
> 
> ---
> v2:
>  - Enable src MAC address as FDIR's input set
> ---
>  doc/guides/rel_notes/release_20_05.rst |  7 +++
>  drivers/net/i40e/i40e_ethdev.c         |  1 +
>  drivers/net/i40e/i40e_ethdev.h         | 18 +++++++-
>  drivers/net/i40e/i40e_fdir.c           | 22 +++++++--
>  drivers/net/i40e/i40e_flow.c           | 63 +++++++++++++++++++-------
>  5 files changed, 89 insertions(+), 22 deletions(-)
> 
> diff --git a/doc/guides/rel_notes/release_20_05.rst
> b/doc/guides/rel_notes/release_20_05.rst
> index 2190eaf85..f0efc5295 100644
> --- a/doc/guides/rel_notes/release_20_05.rst
> +++ b/doc/guides/rel_notes/release_20_05.rst
> @@ -56,6 +56,13 @@ New Features
>       Also, make sure to start the actual text at the margin.
>       =========================================================
> 
> +* **Updated Intel i40e driver.**
> +
> +  Updated i40e PMD with new features and improvements, including:
> +
> +  * enable only dst MAC address as FDIR input set for ipv4-other
> +  * enable both src MAC address and dst MAC address as FDIR input set
> + for ipv4-other
> +
> 
Same here.

>  Removed Items
>  -------------
> diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
> index 9fbda1c34..d11df8d83 100644
> --- a/drivers/net/i40e/i40e_ethdev.c
> +++ b/drivers/net/i40e/i40e_ethdev.c
> @@ -9373,6 +9373,7 @@ i40e_get_valid_input_set(enum i40e_filter_pctype
> pctype,
>  		I40E_INSET_SRC_PORT | I40E_INSET_DST_PORT |
>  		I40E_INSET_SCTP_VT,
>  		[I40E_FILTER_PCTYPE_NONF_IPV4_OTHER] =
> +		I40E_INSET_DMAC | I40E_INSET_SMAC |
>  		I40E_INSET_VLAN_OUTER | I40E_INSET_VLAN_INNER |
>  		I40E_INSET_IPV4_SRC | I40E_INSET_IPV4_DST |
>  		I40E_INSET_IPV4_TOS | I40E_INSET_IPV4_PROTO | diff --git
> a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h index
> aac89de91..e8b98b67e 100644
> --- a/drivers/net/i40e/i40e_ethdev.h
> +++ b/drivers/net/i40e/i40e_ethdev.h
> @@ -544,12 +544,19 @@ struct i40e_ipv6_l2tpv3oip_flow {
>  	uint32_t session_id; /* Session ID in big endian. */  };
> 
> +/* A structure used to define the input for l2 dst type flow */ struct

l2 dst type flow?

> +i40e_eth_l2_flow {

Flow other names, use i40e_l2_flow here.

> +	struct rte_ether_addr dst;
> +	struct rte_ether_addr src;
> +	uint16_t ether_type;          /**< Ether type in big endian */
> +};
> +
>  /*
>   * A union contains the inputs for all types of flow
>   * items in flows need to be in big endian
>   */
>  union i40e_fdir_flow {
> -	struct rte_eth_l2_flow          l2_flow;
> +	struct i40e_eth_l2_flow		l2_flow;
>  	struct rte_eth_udpv4_flow       udp4_flow;
>  	struct rte_eth_tcpv4_flow       tcp4_flow;
>  	struct rte_eth_sctpv4_flow      sctp4_flow;
> @@ -628,6 +635,13 @@ struct i40e_fdir_action {
>  	uint8_t flex_off;
>  };
> 
> +/* Ether input set kinds */
> +enum i40e_fdir_eth_inset {
> +	I40E_ETH_INSET_NULL = 0,
> +	I40E_ETH_INSET_DMAC,
> +	I40E_ETH_INSET_SMAC_DMAC,
> +};

What's the enumeration's purpose?
Could you follow the original code for input set configuration and packet construct?
  

Patch

diff --git a/doc/guides/rel_notes/release_20_05.rst b/doc/guides/rel_notes/release_20_05.rst
index 2190eaf85..f0efc5295 100644
--- a/doc/guides/rel_notes/release_20_05.rst
+++ b/doc/guides/rel_notes/release_20_05.rst
@@ -56,6 +56,13 @@  New Features
      Also, make sure to start the actual text at the margin.
      =========================================================
 
+* **Updated Intel i40e driver.**
+
+  Updated i40e PMD with new features and improvements, including:
+
+  * enable only dst MAC address as FDIR input set for ipv4-other
+  * enable both src MAC address and dst MAC address as FDIR input set for ipv4-other
+
 
 Removed Items
 -------------
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 9fbda1c34..d11df8d83 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -9373,6 +9373,7 @@  i40e_get_valid_input_set(enum i40e_filter_pctype pctype,
 		I40E_INSET_SRC_PORT | I40E_INSET_DST_PORT |
 		I40E_INSET_SCTP_VT,
 		[I40E_FILTER_PCTYPE_NONF_IPV4_OTHER] =
+		I40E_INSET_DMAC | I40E_INSET_SMAC |
 		I40E_INSET_VLAN_OUTER | I40E_INSET_VLAN_INNER |
 		I40E_INSET_IPV4_SRC | I40E_INSET_IPV4_DST |
 		I40E_INSET_IPV4_TOS | I40E_INSET_IPV4_PROTO |
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index aac89de91..e8b98b67e 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -544,12 +544,19 @@  struct i40e_ipv6_l2tpv3oip_flow {
 	uint32_t session_id; /* Session ID in big endian. */
 };
 
+/* A structure used to define the input for l2 dst type flow */
+struct i40e_eth_l2_flow {
+	struct rte_ether_addr dst;
+	struct rte_ether_addr src;
+	uint16_t ether_type;          /**< Ether type in big endian */
+};
+
 /*
  * A union contains the inputs for all types of flow
  * items in flows need to be in big endian
  */
 union i40e_fdir_flow {
-	struct rte_eth_l2_flow          l2_flow;
+	struct i40e_eth_l2_flow		l2_flow;
 	struct rte_eth_udpv4_flow       udp4_flow;
 	struct rte_eth_tcpv4_flow       tcp4_flow;
 	struct rte_eth_sctpv4_flow      sctp4_flow;
@@ -628,6 +635,13 @@  struct i40e_fdir_action {
 	uint8_t flex_off;
 };
 
+/* Ether input set kinds */
+enum i40e_fdir_eth_inset {
+	I40E_ETH_INSET_NULL = 0,
+	I40E_ETH_INSET_DMAC,
+	I40E_ETH_INSET_SMAC_DMAC,
+};
+
 /* A structure used to define the flow director filter entry by filter_ctrl API
  * It supports RTE_ETH_FILTER_FDIR with RTE_ETH_FILTER_ADD and
  * RTE_ETH_FILTER_DELETE operations.
@@ -637,6 +651,8 @@  struct i40e_fdir_filter_conf {
 	/* ID, an unique value is required when deal with FDIR entry */
 	struct i40e_fdir_input input;    /* Input set */
 	struct i40e_fdir_action action;  /* Action taken when match */
+	/* rule which only includes dst mac pattern */
+	enum i40e_fdir_eth_inset fdir_dst_mac_rule;
 };
 
 /*
diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c
index 931f25976..a14f14e75 100644
--- a/drivers/net/i40e/i40e_fdir.c
+++ b/drivers/net/i40e/i40e_fdir.c
@@ -1041,7 +1041,8 @@  static inline int
 i40e_flow_fdir_fill_eth_ip_head(struct i40e_pf *pf,
 				const struct i40e_fdir_input *fdir_input,
 				unsigned char *raw_pkt,
-				bool vlan)
+				bool vlan,
+				enum i40e_fdir_eth_inset fdir_dst_mac_input)
 {
 	struct i40e_customized_pctype *cus_pctype = NULL;
 	static uint8_t vlan_frame[] = {0x81, 0, 0, 0};
@@ -1062,7 +1063,18 @@  i40e_flow_fdir_fill_eth_ip_head(struct i40e_pf *pf,
 		[I40E_FILTER_PCTYPE_NONF_IPV6_OTHER] = IPPROTO_NONE,
 	};
 
+	if (fdir_dst_mac_input == I40E_ETH_INSET_DMAC) {
+		rte_memcpy(raw_pkt, &fdir_input->flow.l2_flow.dst,
+			sizeof(struct rte_ether_addr));
+	} else if (fdir_dst_mac_input == I40E_ETH_INSET_SMAC_DMAC) {
+		rte_memcpy(raw_pkt, &fdir_input->flow.l2_flow.dst,
+			sizeof(struct rte_ether_addr));
+		rte_memcpy(raw_pkt + sizeof(struct rte_ether_addr),
+			&fdir_input->flow.l2_flow.src,
+			sizeof(struct rte_ether_addr));
+	}
 	raw_pkt += 2 * sizeof(struct rte_ether_addr);
+
 	if (vlan && fdir_input->flow_ext.vlan_tci) {
 		rte_memcpy(raw_pkt, vlan_frame, sizeof(vlan_frame));
 		rte_memcpy(raw_pkt + sizeof(uint16_t),
@@ -1156,7 +1168,8 @@  i40e_flow_fdir_fill_eth_ip_head(struct i40e_pf *pf,
 static int
 i40e_flow_fdir_construct_pkt(struct i40e_pf *pf,
 			     const struct i40e_fdir_input *fdir_input,
-			     unsigned char *raw_pkt)
+			     unsigned char *raw_pkt,
+			     enum i40e_fdir_eth_inset fdir_dst_mac_input)
 {
 	unsigned char *payload = NULL;
 	unsigned char *ptr;
@@ -1186,7 +1199,7 @@  i40e_flow_fdir_construct_pkt(struct i40e_pf *pf,
 
 	/* fill the ethernet and IP head */
 	len = i40e_flow_fdir_fill_eth_ip_head(pf, fdir_input, raw_pkt,
-					      !!fdir_input->flow_ext.vlan_tci);
+			!!fdir_input->flow_ext.vlan_tci, fdir_dst_mac_input);
 	if (len < 0)
 		return -EINVAL;
 
@@ -1733,7 +1746,8 @@  i40e_flow_add_del_fdir_filter(struct rte_eth_dev *dev,
 
 	memset(pkt, 0, I40E_FDIR_PKT_LEN);
 
-	ret = i40e_flow_fdir_construct_pkt(pf, &filter->input, pkt);
+	ret = i40e_flow_fdir_construct_pkt(pf, &filter->input, pkt,
+			filter->fdir_dst_mac_rule);
 	if (ret < 0) {
 		PMD_DRV_LOG(ERR, "construct packet for fdir fails.");
 		return ret;
diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
index d877ac250..3d33fc276 100644
--- a/drivers/net/i40e/i40e_flow.c
+++ b/drivers/net/i40e/i40e_flow.c
@@ -2626,7 +2626,23 @@  i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev,
 			}
 
 			if (eth_spec && eth_mask) {
-				if (!rte_is_zero_ether_addr(&eth_mask->src) ||
+				if (rte_is_broadcast_ether_addr(&eth_mask->dst) &&
+					rte_is_zero_ether_addr(&eth_mask->src)) {
+					cons_filter.fdir_filter.fdir_dst_mac_rule =
+						I40E_ETH_INSET_DMAC;
+					filter->input.flow.l2_flow.dst =
+						eth_spec->dst;
+					input_set |= I40E_INSET_DMAC;
+				} else if (rte_is_broadcast_ether_addr(&eth_mask->dst) &&
+					rte_is_broadcast_ether_addr(&eth_mask->src)) {
+					cons_filter.fdir_filter.fdir_dst_mac_rule =
+						I40E_ETH_INSET_SMAC_DMAC;
+					filter->input.flow.l2_flow.dst =
+						eth_spec->dst;
+					filter->input.flow.l2_flow.src =
+						eth_spec->src;
+					input_set |= (I40E_INSET_DMAC | I40E_INSET_SMAC);
+				} else if (!rte_is_zero_ether_addr(&eth_mask->src) ||
 				    !rte_is_zero_ether_addr(&eth_mask->dst)) {
 					rte_flow_error_set(error, EINVAL,
 						      RTE_FLOW_ERROR_TYPE_ITEM,
@@ -2635,7 +2651,8 @@  i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev,
 					return -rte_errno;
 				}
 			}
-			if (eth_spec && eth_mask && eth_mask->type) {
+			if (eth_spec && eth_mask &&
+			next_type == RTE_FLOW_ITEM_TYPE_END) {
 				if (eth_mask->type != RTE_BE16(0xffff)) {
 					rte_flow_error_set(error, EINVAL,
 						      RTE_FLOW_ERROR_TYPE_ITEM,
@@ -2750,21 +2767,33 @@  i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev,
 				    frag_off & RTE_IPV4_HDR_MF_FLAG)
 					pctype = I40E_FILTER_PCTYPE_FRAG_IPV4;
 
-				/* Get the filter info */
-				filter->input.flow.ip4_flow.proto =
-					ipv4_spec->hdr.next_proto_id;
-				filter->input.flow.ip4_flow.tos =
-					ipv4_spec->hdr.type_of_service;
-				filter->input.flow.ip4_flow.ttl =
-					ipv4_spec->hdr.time_to_live;
-				filter->input.flow.ip4_flow.src_ip =
-					ipv4_spec->hdr.src_addr;
-				filter->input.flow.ip4_flow.dst_ip =
-					ipv4_spec->hdr.dst_addr;
-
-				filter->input.flow_ext.inner_ip = false;
-				filter->input.flow_ext.oip_type =
-					I40E_FDIR_IPTYPE_IPV4;
+				if (cons_filter.fdir_filter.fdir_dst_mac_rule) {
+					if (input_set & (I40E_INSET_IPV4_SRC |
+					I40E_INSET_IPV4_DST | I40E_INSET_IPV4_TOS |
+					I40E_INSET_IPV4_TTL | I40E_INSET_IPV4_PROTO)) {
+						rte_flow_error_set(error, EINVAL,
+						      RTE_FLOW_ERROR_TYPE_ITEM,
+						      item,
+						      "Invalid MAC_addr mask.");
+						return -rte_errno;
+					}
+				} else {
+					/* Get the filter info */
+					filter->input.flow.ip4_flow.proto =
+						ipv4_spec->hdr.next_proto_id;
+					filter->input.flow.ip4_flow.tos =
+						ipv4_spec->hdr.type_of_service;
+					filter->input.flow.ip4_flow.ttl =
+						ipv4_spec->hdr.time_to_live;
+					filter->input.flow.ip4_flow.src_ip =
+						ipv4_spec->hdr.src_addr;
+					filter->input.flow.ip4_flow.dst_ip =
+						ipv4_spec->hdr.dst_addr;
+
+					filter->input.flow_ext.inner_ip = false;
+					filter->input.flow_ext.oip_type =
+						I40E_FDIR_IPTYPE_IPV4;
+				}
 			} else if (!ipv4_spec && !ipv4_mask && !outer_ip) {
 				filter->input.flow_ext.inner_ip = true;
 				filter->input.flow_ext.iip_type =