From patchwork Mon Nov 1 08:45:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yu, DapengX" X-Patchwork-Id: 103307 X-Patchwork-Delegate: qi.z.zhang@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 339A7A0C57; Mon, 1 Nov 2021 09:45:27 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F262D40E28; Mon, 1 Nov 2021 09:45:26 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 0D6D440DF6; Mon, 1 Nov 2021 09:45:24 +0100 (CET) X-IronPort-AV: E=McAfee;i="6200,9189,10154"; a="228426804" X-IronPort-AV: E=Sophos;i="5.87,198,1631602800"; d="scan'208";a="228426804" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2021 01:45:24 -0700 X-IronPort-AV: E=Sophos;i="5.87,198,1631602800"; d="scan'208";a="499956365" Received: from unknown (HELO localhost.localdomain) ([10.240.183.93]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2021 01:45:21 -0700 From: dapengx.yu@intel.com To: Qiming Yang , Qi Zhang Cc: dev@dpdk.org, haiyue.wang@intel.com, Dapeng Yu , stable@dpdk.org Date: Mon, 1 Nov 2021 16:45:05 +0800 Message-Id: <20211101084506.513407-1-dapengx.yu@intel.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 1/2] net/ice: save meta on switch filter creation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Dapeng Yu The meta is abandoned when switch filter is created in original implementation. This patch saved the meta in RTE flow for future use. Fixes: 47d460d63233 ("net/ice: rework switch filter") Cc: stable@dpdk.org Signed-off-by: Dapeng Yu Acked-by: Qi Zhang --- drivers/net/ice/ice_switch_filter.c | 69 ++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 20 deletions(-) diff --git a/drivers/net/ice/ice_switch_filter.c b/drivers/net/ice/ice_switch_filter.c index 6b0c1bff1e..804cf9b812 100644 --- a/drivers/net/ice/ice_switch_filter.c +++ b/drivers/net/ice/ice_switch_filter.c @@ -180,6 +180,21 @@ struct sw_meta { struct ice_adv_rule_info rule_info; }; +struct ice_switch_filter_conf { + bool added; + + /* Only when added flag is true, the query data is valid */ + struct ice_rule_query_data sw_query_data; + + /* + * The lookup elements and rule info are saved here when filter creation + * succeeds. + */ + 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 +374,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 +396,24 @@ 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->lkups = list; + filter_conf_ptr->lkups_num = lkups_cnt; + filter_conf_ptr->rule_info = *rule_info; + + filter_conf_ptr->added = true; + + flow->rule = filter_conf_ptr; } else { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_HANDLE, NULL, @@ -400,7 +421,6 @@ ice_switch_create(struct ice_adapter *ad, goto error; } - rte_free(list); rte_free(meta); return 0; @@ -411,6 +431,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 +450,23 @@ 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->added) { 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 +474,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, From patchwork Mon Nov 1 08:45:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yu, DapengX" X-Patchwork-Id: 103308 X-Patchwork-Delegate: qi.z.zhang@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 45099A0C57; Mon, 1 Nov 2021 09:45:48 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2D023410FF; Mon, 1 Nov 2021 09:45:48 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 07D6E40DF6; Mon, 1 Nov 2021 09:45:45 +0100 (CET) X-IronPort-AV: E=McAfee;i="6200,9189,10154"; a="254578798" X-IronPort-AV: E=Sophos;i="5.87,198,1631602800"; d="scan'208";a="254578798" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2021 01:45:32 -0700 X-IronPort-AV: E=Sophos;i="5.87,198,1631602800"; d="scan'208";a="499956407" Received: from unknown (HELO localhost.localdomain) ([10.240.183.93]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2021 01:45:29 -0700 From: dapengx.yu@intel.com To: Qiming Yang , Qi Zhang Cc: dev@dpdk.org, haiyue.wang@intel.com, Dapeng Yu , stable@dpdk.org Date: Mon, 1 Nov 2021 16:45:06 +0800 Message-Id: <20211101084506.513407-2-dapengx.yu@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211101084506.513407-1-dapengx.yu@intel.com> References: <20211101084506.513407-1-dapengx.yu@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 2/2] net/ice: fix flow redirect failure X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Dapeng Yu When the switch flow rules are redirected, if rule is removed but not added successfully, the rule addition in the next time will not succeed because the rule's meta cannot be found. This patch uses the saved flow rule's meta when the flow rule is added again to make the addition succeed. Fixes: 397b4b3c5095 ("net/ice: enable flow redirect on switch") Cc: stable@dpdk.org Signed-off-by: Dapeng Yu --- drivers/net/ice/ice_switch_filter.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/drivers/net/ice/ice_switch_filter.c b/drivers/net/ice/ice_switch_filter.c index 804cf9b812..0994ea00ae 100644 --- a/drivers/net/ice/ice_switch_filter.c +++ b/drivers/net/ice/ice_switch_filter.c @@ -1917,7 +1917,10 @@ ice_switch_redirect(struct ice_adapter *ad, struct rte_flow *flow, struct ice_flow_redirect *rd) { - struct ice_rule_query_data *rdata = flow->rule; + struct ice_rule_query_data *rdata; + struct ice_switch_filter_conf *filter_conf_ptr = + (struct ice_switch_filter_conf *)flow->rule; + struct ice_rule_query_data added_rdata = { 0 }; struct ice_adv_fltr_mgmt_list_entry *list_itr; struct ice_adv_lkup_elem *lkups_dp = NULL; struct LIST_HEAD_TYPE *list_head; @@ -1927,6 +1930,8 @@ ice_switch_redirect(struct ice_adapter *ad, uint16_t lkups_cnt; int ret; + rdata = &filter_conf_ptr->sw_query_data; + if (rdata->vsi_handle != rd->vsi_handle) return 0; @@ -1937,6 +1942,22 @@ ice_switch_redirect(struct ice_adapter *ad, if (rd->type != ICE_FLOW_REDIRECT_VSI) return -ENOTSUP; + if (!filter_conf_ptr->added) { + ret = ice_add_adv_rule(hw, filter_conf_ptr->lkups, + filter_conf_ptr->lkups_num, + &filter_conf_ptr->rule_info, + &added_rdata); + + if (ret) { + PMD_DRV_LOG(ERR, "Failed to replay the rule again"); + return -EINVAL; + } + + filter_conf_ptr->sw_query_data = added_rdata; + filter_conf_ptr->added = true; + return 0; + } + list_head = &sw->recp_list[rdata->rid].filt_rules; LIST_FOR_EACH_ENTRY(list_itr, list_head, ice_adv_fltr_mgmt_list_entry, list_entry) { @@ -1983,10 +2004,14 @@ ice_switch_redirect(struct ice_adapter *ad, /* Replay the rule */ ret = ice_add_adv_rule(hw, lkups_dp, lkups_cnt, - &rinfo, rdata); + &rinfo, &added_rdata); if (ret) { PMD_DRV_LOG(ERR, "Failed to replay the rule"); + filter_conf_ptr->added = false; ret = -EINVAL; + } else { + filter_conf_ptr->sw_query_data = added_rdata; + filter_conf_ptr->added = true; } out: