From patchwork Thu Mar 7 12:58:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zhang X-Patchwork-Id: 50956 X-Patchwork-Delegate: qi.z.zhang@intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E52EE1B3FD; Thu, 7 Mar 2019 13:57:42 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 069D11B3B8 for ; Thu, 7 Mar 2019 13:57:39 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Mar 2019 04:57:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,451,1544515200"; d="scan'208";a="152884478" Received: from dpdk51.sh.intel.com ([10.67.110.160]) by fmsmga001.fm.intel.com with ESMTP; 07 Mar 2019 04:57:38 -0800 From: Qi Zhang To: wenzhuo.lu@intel.com, qiming.yang@intel.com Cc: dev@dpdk.org, paul.m.stillwell.jr@intel.com, ferruh.yigit@intel.com, Qi Zhang , Vignesh Sridhar Date: Thu, 7 Mar 2019 20:58:38 +0800 Message-Id: <20190307125841.14247-35-qi.z.zhang@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190307125841.14247-1-qi.z.zhang@intel.com> References: <20190228055650.25237-1-qi.z.zhang@intel.com> <20190307125841.14247-1-qi.z.zhang@intel.com> Subject: [dpdk-dev] [PATCH v2 34/37] net/ice/base: fix duplicate resource allocations X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" This patch ensure that TCAM allocations made by a newly added VSIG that has the same characteristic list of an existing VSIG are removed. Fixes: 51d04e4933e3 ("net/ice/base: add flexible pipeline module") Signed-off-by: Vignesh Sridhar Signed-off-by: Paul M Stillwell Jr Signed-off-by: Qi Zhang --- drivers/net/ice/base/ice_flex_pipe.c | 85 +++++++++++++++++------------------- 1 file changed, 41 insertions(+), 44 deletions(-) diff --git a/drivers/net/ice/base/ice_flex_pipe.c b/drivers/net/ice/base/ice_flex_pipe.c index 37bb4cbb5..c9d8730d2 100644 --- a/drivers/net/ice/base/ice_flex_pipe.c +++ b/drivers/net/ice/base/ice_flex_pipe.c @@ -2302,21 +2302,23 @@ ice_vsig_free(struct ice_hw *hw, enum ice_block blk, u16 vsig) hw->blk[blk].xlt2.vsig_tbl[idx].in_use = false; vsi_cur = hw->blk[blk].xlt2.vsig_tbl[idx].first_vsi; - if (!vsi_cur) - return ICE_ERR_CFG; - - /* remove all vsis associated with this VSIG XLT2 entry */ - do { - struct ice_vsig_vsi *tmp = vsi_cur->next_vsi; - - vsi_cur->vsig = ICE_DEFAULT_VSIG; - vsi_cur->changed = 1; - vsi_cur->next_vsi = NULL; - vsi_cur = tmp; - } while (vsi_cur); - - /* NULL terminate head of vsi list */ - hw->blk[blk].xlt2.vsig_tbl[idx].first_vsi = NULL; + /* If the VSIG has at least 1 VSI then iterate through the + * list and remove the VSIs before deleting the group. + */ + if (vsi_cur) { + /* remove all vsis associated with this VSIG XLT2 entry */ + do { + struct ice_vsig_vsi *tmp = vsi_cur->next_vsi; + + vsi_cur->vsig = ICE_DEFAULT_VSIG; + vsi_cur->changed = 1; + vsi_cur->next_vsi = NULL; + vsi_cur = tmp; + } while (vsi_cur); + + /* NULL terminate head of VSI list */ + hw->blk[blk].xlt2.vsig_tbl[idx].first_vsi = NULL; + } /* free characteristic list */ LIST_FOR_EACH_ENTRY_SAFE(del, dtmp, @@ -4267,36 +4269,32 @@ ice_rem_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsig, /* Move all VSIS associated with this VSIG to the default VSIG */ vsi_cur = hw->blk[blk].xlt2.vsig_tbl[idx].first_vsi; - if (!vsi_cur) - return ICE_ERR_CFG; - - do { - struct ice_vsig_vsi *tmp = vsi_cur->next_vsi; - struct ice_chs_chg *p; - - p = (struct ice_chs_chg *)ice_malloc(hw, sizeof(*p)); - if (!p) - goto err_ice_rem_vsig; + /* If the VSIG has at least 1 VSI then iterate through the list + * and remove the VSIs before deleting the group. + */ + if (vsi_cur) { + do { + struct ice_vsig_vsi *tmp = vsi_cur->next_vsi; + struct ice_chs_chg *p; - p->type = ICE_VSIG_REM; - p->orig_vsig = vsig; - p->vsig = ICE_DEFAULT_VSIG; - p->vsi = vsi_cur - hw->blk[blk].xlt2.vsis; + p = (struct ice_chs_chg *)ice_malloc(hw, sizeof(*p)); + if (!p) + return ICE_ERR_NO_MEMORY; - LIST_ADD(&p->list_entry, chg); + p->type = ICE_VSIG_REM; + p->orig_vsig = vsig; + p->vsig = ICE_DEFAULT_VSIG; + p->vsi = vsi_cur - hw->blk[blk].xlt2.vsis; - status = ice_vsig_free(hw, blk, vsig); - if (status) - return status; + LIST_ADD(&p->list_entry, chg); - vsi_cur = tmp; - } while (vsi_cur); + vsi_cur = tmp; + } while (vsi_cur); + } - return ICE_SUCCESS; + status = ice_vsig_free(hw, blk, vsig); -err_ice_rem_vsig: - /* the caller will free up the change list */ - return ICE_ERR_NO_MEMORY; + return status; } /** @@ -4493,7 +4491,7 @@ ice_get_profs_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsig, ice_memcpy(p, ent1, sizeof(*p), ICE_NONDMA_TO_NONDMA); - LIST_ADD(&p->list, lst); + LIST_ADD_TAIL(&p->list, lst); } return ICE_SUCCESS; @@ -5000,14 +4998,13 @@ ice_add_prof_id_flow(struct ice_hw *hw, enum ice_block blk, u16 vsi, u64 hdl) /* search for an existing VSIG with an exact charc match */ status = ice_find_dup_props_vsig(hw, blk, &union_lst, &vsig); if (!status) { - /* found an exact match */ - /* move vsi to the VSIG that matches */ + /* move VSI to the VSIG that matches */ status = ice_move_vsi(hw, blk, vsi, vsig, &chg); if (status) goto err_ice_add_prof_id_flow; - /* remove original VSIG if we just moved the only VSI - * from it + /* VSI has been moved out of or_vsig. If the or_vsig had + * only that VSI it is now empty and can be removed. */ if (only_vsi) { status = ice_rem_vsig(hw, blk, or_vsig, &chg);