patches for DPDK stable branches
 help / color / mirror / Atom feed
From: dapengx.yu@intel.com
To: Qiming Yang <qiming.yang@intel.com>, Qi Zhang <qi.z.zhang@intel.com>
Cc: dev@dpdk.org, haiyue.wang@intel.com,
	Dapeng Yu <dapengx.yu@intel.com>,
	stable@dpdk.org
Subject: [dpdk-stable] [PATCH v3 1/2] net/ice: save rule on switch filter creation
Date: Thu,  4 Nov 2021 16:17:38 +0800	[thread overview]
Message-ID: <20211104081739.1540725-1-dapengx.yu@intel.com> (raw)
In-Reply-To: <20211103100527.1175159-1-dapengx.yu@intel.com>

From: Dapeng Yu <dapengx.yu@intel.com>

The VSI number, lookup elements and rule information for creating switch
filter are abandoned when switch filter is created in original
implementation.

This patch saved the abandoned data in RTE flow, it is for future
use on replay when handling exception at flow redirect.

Cc: stable@dpdk.org

Signed-off-by: Dapeng Yu <dapengx.yu@intel.com>
---
V2:
* Add more filter status and VSI number
V3:
* Use switch statement to make code clear
---
 drivers/net/ice/ice_switch_filter.c | 78 +++++++++++++++++++++--------
 1 file changed, 58 insertions(+), 20 deletions(-)

diff --git a/drivers/net/ice/ice_switch_filter.c b/drivers/net/ice/ice_switch_filter.c
index 6b0c1bff1e..d5add64c53 100644
--- a/drivers/net/ice/ice_switch_filter.c
+++ b/drivers/net/ice/ice_switch_filter.c
@@ -180,6 +180,27 @@ struct sw_meta {
 	struct ice_adv_rule_info rule_info;
 };
 
+enum ice_sw_fltr_status {
+	ICE_SW_FLTR_ADDED,
+	ICE_SW_FLTR_RMV_FAILED_ON_RIDRECT,
+	ICE_SW_FLTR_ADD_FAILED_ON_RIDRECT,
+};
+
+struct ice_switch_filter_conf {
+	enum ice_sw_fltr_status fltr_status;
+
+	struct ice_rule_query_data sw_query_data;
+
+	/*
+	 * The lookup elements and rule info are saved here when filter creation
+	 * succeeds.
+	 */
+	uint16_t vsi_num;
+	uint16_t lkups_num;
+	struct ice_adv_lkup_elem *lkups;
+	struct ice_adv_rule_info rule_info;
+};
+
 static struct ice_flow_parser ice_switch_dist_parser;
 static struct ice_flow_parser ice_switch_perm_parser;
 
@@ -359,7 +380,7 @@ ice_switch_create(struct ice_adapter *ad,
 	struct ice_pf *pf = &ad->pf;
 	struct ice_hw *hw = ICE_PF_TO_HW(pf);
 	struct ice_rule_query_data rule_added = {0};
-	struct ice_rule_query_data *filter_ptr;
+	struct ice_switch_filter_conf *filter_conf_ptr;
 	struct ice_adv_lkup_elem *list =
 		((struct sw_meta *)meta)->list;
 	uint16_t lkups_cnt =
@@ -381,18 +402,26 @@ ice_switch_create(struct ice_adapter *ad,
 	}
 	ret = ice_add_adv_rule(hw, list, lkups_cnt, rule_info, &rule_added);
 	if (!ret) {
-		filter_ptr = rte_zmalloc("ice_switch_filter",
-			sizeof(struct ice_rule_query_data), 0);
-		if (!filter_ptr) {
+		filter_conf_ptr = rte_zmalloc("ice_switch_filter",
+			sizeof(struct ice_switch_filter_conf), 0);
+		if (!filter_conf_ptr) {
 			rte_flow_error_set(error, EINVAL,
 				   RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
 				   "No memory for ice_switch_filter");
 			goto error;
 		}
-		flow->rule = filter_ptr;
-		rte_memcpy(filter_ptr,
-			&rule_added,
-			sizeof(struct ice_rule_query_data));
+
+		filter_conf_ptr->sw_query_data = rule_added;
+
+		filter_conf_ptr->vsi_num =
+			ice_get_hw_vsi_num(hw, rule_info->sw_act.vsi_handle);
+		filter_conf_ptr->lkups = list;
+		filter_conf_ptr->lkups_num = lkups_cnt;
+		filter_conf_ptr->rule_info = *rule_info;
+
+		filter_conf_ptr->fltr_status = ICE_SW_FLTR_ADDED;
+
+		flow->rule = filter_conf_ptr;
 	} else {
 		rte_flow_error_set(error, EINVAL,
 			RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
@@ -400,7 +429,6 @@ ice_switch_create(struct ice_adapter *ad,
 		goto error;
 	}
 
-	rte_free(list);
 	rte_free(meta);
 	return 0;
 
@@ -411,6 +439,18 @@ ice_switch_create(struct ice_adapter *ad,
 	return -rte_errno;
 }
 
+static inline void
+ice_switch_filter_rule_free(struct rte_flow *flow)
+{
+	struct ice_switch_filter_conf *filter_conf_ptr =
+		(struct ice_switch_filter_conf *)flow->rule;
+
+	if (filter_conf_ptr)
+		rte_free(filter_conf_ptr->lkups);
+
+	rte_free(filter_conf_ptr);
+}
+
 static int
 ice_switch_destroy(struct ice_adapter *ad,
 		struct rte_flow *flow,
@@ -418,20 +458,24 @@ ice_switch_destroy(struct ice_adapter *ad,
 {
 	struct ice_hw *hw = &ad->hw;
 	int ret;
-	struct ice_rule_query_data *filter_ptr;
+	struct ice_switch_filter_conf *filter_conf_ptr;
 
-	filter_ptr = (struct ice_rule_query_data *)
+	filter_conf_ptr = (struct ice_switch_filter_conf *)
 		flow->rule;
 
-	if (!filter_ptr) {
+	if (!filter_conf_ptr ||
+	    filter_conf_ptr->fltr_status == ICE_SW_FLTR_ADD_FAILED_ON_RIDRECT) {
 		rte_flow_error_set(error, EINVAL,
 			RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
 			"no such flow"
 			" create by switch filter");
+
+		ice_switch_filter_rule_free(flow);
+
 		return -rte_errno;
 	}
 
-	ret = ice_rem_adv_rule_by_id(hw, filter_ptr);
+	ret = ice_rem_adv_rule_by_id(hw, &filter_conf_ptr->sw_query_data);
 	if (ret) {
 		rte_flow_error_set(error, EINVAL,
 			RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
@@ -439,16 +483,10 @@ ice_switch_destroy(struct ice_adapter *ad,
 		return -rte_errno;
 	}
 
-	rte_free(filter_ptr);
+	ice_switch_filter_rule_free(flow);
 	return ret;
 }
 
-static void
-ice_switch_filter_rule_free(struct rte_flow *flow)
-{
-	rte_free(flow->rule);
-}
-
 static bool
 ice_switch_parse_pattern(const struct rte_flow_item pattern[],
 		struct rte_flow_error *error,
-- 
2.27.0


  parent reply	other threads:[~2021-11-04  8:18 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-01  8:45 [dpdk-stable] [PATCH 1/2] net/ice: save meta " dapengx.yu
2021-11-01  8:45 ` [dpdk-stable] [PATCH 2/2] net/ice: fix flow redirect failure dapengx.yu
2021-11-02  0:06 ` [dpdk-stable] [PATCH 1/2] net/ice: save meta on switch filter creation Zhang, Qi Z
2021-11-02  0:08   ` Zhang, Qi Z
2021-11-02 16:11 ` Ferruh Yigit
2021-11-03  3:25   ` Yu, DapengX
2021-11-03 10:05 ` [dpdk-stable] [PATCH v2 1/2] net/ice: save rule " dapengx.yu
2021-11-03 10:05   ` [dpdk-stable] [PATCH v2 2/2] net/ice: fix flow redirect failure dapengx.yu
2021-11-04  8:17   ` dapengx.yu [this message]
2021-11-04  8:17     ` [dpdk-stable] [PATCH v3 " dapengx.yu
2021-11-04  8:45     ` [dpdk-stable] [PATCH v4 1/2] net/ice: save rule on switch filter creation dapengx.yu
2021-11-04  8:45       ` [dpdk-stable] [PATCH v4 2/2] net/ice: fix flow redirect failure dapengx.yu
2021-11-04 11:12         ` Zhang, Qi Z
2021-11-04 11:10       ` [dpdk-stable] [PATCH v4 1/2] net/ice: save rule on switch filter creation Zhang, Qi Z

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=20211104081739.1540725-1-dapengx.yu@intel.com \
    --to=dapengx.yu@intel.com \
    --cc=dev@dpdk.org \
    --cc=haiyue.wang@intel.com \
    --cc=qi.z.zhang@intel.com \
    --cc=qiming.yang@intel.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).