[21/22] net/ice: support flow priority for DCF switch filter

Message ID 20210803083817.1243796-22-wenjun1.wu@intel.com (mailing list archive)
State Not Applicable, archived
Delegated to: Qi Zhang
Headers
Series backport feature support to DPDK 20.11 |

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Wenjun Wu Aug. 3, 2021, 8:38 a.m. UTC
  From: Yuying Zhang <yuying.zhang@intel.com>

[ upstream commit 2321e34c23b386c46e4a644682e40214cf59ee4f ]

This patch is not for LTS upstream, just for customer to cherry-pick.

Support rte flow priority attribute for DCF switch filter.
When a packet is matched by two rules, the behavior of it
is not defined. This patch supports flow priority to create
different recipes for this situation. Only priority 0 and 1
are supported and higher value denotes higher priority.

for example:
1. flow create 0 priority 0 ingress pattern eth / vlan tci is 2 / vlan
   tci is 2 / end actions vf id 2 / end
2. flow create 0 priority 1 ingress pattern eth / vlan / vlan / ipv4 dst
   is 192.168.0.1 / end actions vf id 1 / end

These two rules can be created at the same time in DCF switch
filter and priority of rule 2 is higher. Packet hits rule 2
when two conditions of rules are satisfied.

Signed-off-by: Yuying Zhang <yuying.zhang@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
---
 drivers/net/ice/ice_acl_filter.c    |  1 +
 drivers/net/ice/ice_fdir_filter.c   |  1 +
 drivers/net/ice/ice_generic_flow.c  | 18 ++++++++++--------
 drivers/net/ice/ice_generic_flow.h  |  1 +
 drivers/net/ice/ice_hash.c          |  2 ++
 drivers/net/ice/ice_switch_filter.c | 14 +++++++++-----
 6 files changed, 24 insertions(+), 13 deletions(-)
  

Patch

diff --git a/drivers/net/ice/ice_acl_filter.c b/drivers/net/ice/ice_acl_filter.c
index f7dbe53574..14e36aa9f6 100644
--- a/drivers/net/ice/ice_acl_filter.c
+++ b/drivers/net/ice/ice_acl_filter.c
@@ -904,6 +904,7 @@  ice_acl_parse(struct ice_adapter *ad,
 	       uint32_t array_len,
 	       const struct rte_flow_item pattern[],
 	       const struct rte_flow_action actions[],
+	       uint32_t priority __rte_unused,
 	       void **meta,
 	       struct rte_flow_error *error)
 {
diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c
index 4a071254ce..d2bc882720 100644
--- a/drivers/net/ice/ice_fdir_filter.c
+++ b/drivers/net/ice/ice_fdir_filter.c
@@ -2029,6 +2029,7 @@  ice_fdir_parse(struct ice_adapter *ad,
 	       uint32_t array_len,
 	       const struct rte_flow_item pattern[],
 	       const struct rte_flow_action actions[],
+	       uint32_t priority __rte_unused,
 	       void **meta,
 	       struct rte_flow_error *error)
 {
diff --git a/drivers/net/ice/ice_generic_flow.c b/drivers/net/ice/ice_generic_flow.c
index c9910a65d1..ec141e8fa0 100644
--- a/drivers/net/ice/ice_generic_flow.c
+++ b/drivers/net/ice/ice_generic_flow.c
@@ -1799,6 +1799,7 @@  enum rte_flow_item_type pattern_eth_ipv6_pfcp[] = {
 typedef struct ice_flow_engine * (*parse_engine_t)(struct ice_adapter *ad,
 		struct rte_flow *flow,
 		struct ice_parser_list *parser_list,
+		uint32_t priority,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
 		struct rte_flow_error *error);
@@ -1990,11 +1991,10 @@  ice_flow_valid_attr(struct ice_adapter *ad,
 	} else {
 		*ice_pipeline_stage =
 			ICE_FLOW_CLASSIFY_STAGE_DISTRIBUTOR_ONLY;
-		/* Not supported */
-		if (attr->priority) {
+		if (attr->priority > 1) {
 			rte_flow_error_set(error, EINVAL,
 					RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY,
-					attr, "Not support priority.");
+					attr, "Only support priority 0 and 1.");
 			return -rte_errno;
 		}
 	}
@@ -2139,6 +2139,7 @@  static struct ice_flow_engine *
 ice_parse_engine_create(struct ice_adapter *ad,
 		struct rte_flow *flow,
 		struct ice_parser_list *parser_list,
+		uint32_t priority,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
 		struct rte_flow_error *error)
@@ -2154,7 +2155,7 @@  ice_parse_engine_create(struct ice_adapter *ad,
 		if (parser_node->parser->parse_pattern_action(ad,
 				parser_node->parser->array,
 				parser_node->parser->array_len,
-				pattern, actions, &meta, error) < 0)
+				pattern, actions, priority, &meta, error) < 0)
 			continue;
 
 		engine = parser_node->parser->engine;
@@ -2172,6 +2173,7 @@  static struct ice_flow_engine *
 ice_parse_engine_validate(struct ice_adapter *ad,
 		struct rte_flow *flow __rte_unused,
 		struct ice_parser_list *parser_list,
+		uint32_t priority,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
 		struct rte_flow_error *error)
@@ -2184,7 +2186,7 @@  ice_parse_engine_validate(struct ice_adapter *ad,
 		if (parser_node->parser->parse_pattern_action(ad,
 				parser_node->parser->array,
 				parser_node->parser->array_len,
-				pattern, actions, NULL, error) < 0)
+				pattern, actions, priority, NULL, error) < 0)
 			continue;
 
 		engine = parser_node->parser->engine;
@@ -2234,7 +2236,7 @@  ice_flow_process_filter(struct rte_eth_dev *dev,
 		return ret;
 
 	*engine = ice_parse_engine(ad, flow, &pf->rss_parser_list,
-			pattern, actions, error);
+			attr->priority, pattern, actions, error);
 	if (*engine != NULL)
 		return 0;
 
@@ -2242,11 +2244,11 @@  ice_flow_process_filter(struct rte_eth_dev *dev,
 	case ICE_FLOW_CLASSIFY_STAGE_DISTRIBUTOR_ONLY:
 	case ICE_FLOW_CLASSIFY_STAGE_DISTRIBUTOR:
 		*engine = ice_parse_engine(ad, flow, &pf->dist_parser_list,
-				pattern, actions, error);
+				attr->priority, pattern, actions, error);
 		break;
 	case ICE_FLOW_CLASSIFY_STAGE_PERMISSION:
 		*engine = ice_parse_engine(ad, flow, &pf->perm_parser_list,
-				pattern, actions, error);
+				attr->priority, pattern, actions, error);
 		break;
 	default:
 		return -EINVAL;
diff --git a/drivers/net/ice/ice_generic_flow.h b/drivers/net/ice/ice_generic_flow.h
index 1b2cdf7e4c..6bfe3f6dd6 100644
--- a/drivers/net/ice/ice_generic_flow.h
+++ b/drivers/net/ice/ice_generic_flow.h
@@ -555,6 +555,7 @@  typedef int (*parse_pattern_action_t)(struct ice_adapter *ad,
 		uint32_t array_len,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
+		uint32_t priority,
 		void **meta,
 		struct rte_flow_error *error);
 
diff --git a/drivers/net/ice/ice_hash.c b/drivers/net/ice/ice_hash.c
index 2b0a479c7e..ae095eb3cf 100644
--- a/drivers/net/ice/ice_hash.c
+++ b/drivers/net/ice/ice_hash.c
@@ -75,6 +75,7 @@  ice_hash_parse_pattern_action(struct ice_adapter *ad,
 			uint32_t array_len,
 			const struct rte_flow_item pattern[],
 			const struct rte_flow_action actions[],
+			uint32_t priority,
 			void **meta,
 			struct rte_flow_error *error);
 
@@ -1237,6 +1238,7 @@  ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad,
 			uint32_t array_len,
 			const struct rte_flow_item pattern[],
 			const struct rte_flow_action actions[],
+			uint32_t priority __rte_unused,
 			void **meta,
 			struct rte_flow_error *error)
 {
diff --git a/drivers/net/ice/ice_switch_filter.c b/drivers/net/ice/ice_switch_filter.c
index 455123ee06..48726dc967 100644
--- a/drivers/net/ice/ice_switch_filter.c
+++ b/drivers/net/ice/ice_switch_filter.c
@@ -1512,6 +1512,7 @@  ice_switch_inset_get(const struct rte_flow_item pattern[],
 static int
 ice_switch_parse_dcf_action(struct ice_dcf_adapter *ad,
 			    const struct rte_flow_action *actions,
+			    uint32_t priority,
 			    struct rte_flow_error *error,
 			    struct ice_adv_rule_info *rule_info)
 {
@@ -1559,7 +1560,7 @@  ice_switch_parse_dcf_action(struct ice_dcf_adapter *ad,
 	rule_info->sw_act.src = rule_info->sw_act.vsi_handle;
 	rule_info->sw_act.flag = ICE_FLTR_RX;
 	rule_info->rx = 1;
-	rule_info->priority = 5;
+	rule_info->priority = priority + 5;
 
 	return 0;
 }
@@ -1567,6 +1568,7 @@  ice_switch_parse_dcf_action(struct ice_dcf_adapter *ad,
 static int
 ice_switch_parse_action(struct ice_pf *pf,
 		const struct rte_flow_action *actions,
+		uint32_t priority,
 		struct rte_flow_error *error,
 		struct ice_adv_rule_info *rule_info)
 {
@@ -1637,7 +1639,7 @@  ice_switch_parse_action(struct ice_pf *pf,
 	rule_info->sw_act.vsi_handle = vsi->idx;
 	rule_info->rx = 1;
 	rule_info->sw_act.src = vsi->idx;
-	rule_info->priority = 5;
+	rule_info->priority = priority + 5;
 
 	return 0;
 
@@ -1729,6 +1731,7 @@  ice_switch_parse_pattern_action(struct ice_adapter *ad,
 		uint32_t array_len,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
+		uint32_t priority,
 		void **meta,
 		struct rte_flow_error *error)
 {
@@ -1818,10 +1821,11 @@  ice_switch_parse_pattern_action(struct ice_adapter *ad,
 		goto error;
 
 	if (ad->hw.dcf_enabled)
-		ret = ice_switch_parse_dcf_action((void *)ad, actions, error,
-						  &rule_info);
+		ret = ice_switch_parse_dcf_action((void *)ad, actions, priority,
+						  error, &rule_info);
 	else
-		ret = ice_switch_parse_action(pf, actions, error, &rule_info);
+		ret = ice_switch_parse_action(pf, actions, priority, error,
+					      &rule_info);
 
 	if (ret)
 		goto error;