From patchwork Tue Nov 12 03:50:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shougang Wang X-Patchwork-Id: 62880 X-Patchwork-Delegate: xiaolong.ye@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 14F14A04AB; Tue, 12 Nov 2019 11:09:22 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 23E732BAE; Tue, 12 Nov 2019 11:09:19 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id C22E12BA2 for ; Tue, 12 Nov 2019 11:09:16 +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; 12 Nov 2019 02:09:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,295,1569308400"; d="scan'208";a="214048328" Received: from intel.sh.intel.com ([10.239.255.146]) by fmsmga001.fm.intel.com with ESMTP; 12 Nov 2019 02:09:14 -0800 From: Wang ShougangX To: dev@dpdk.org Cc: qiming.yang@intel.com, qi.z.zhang@intel.com, Wang ShougangX Date: Tue, 12 Nov 2019 03:50:08 +0000 Message-Id: <20191112035011.67537-2-shougangx.wang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191112035011.67537-1-shougangx.wang@intel.com> References: <20191105033806.2878-1-shougangx.wang@intel.com> <20191112035011.67537-1-shougangx.wang@intel.com> Subject: [dpdk-dev] [PATCH v4 1/4] net/ice: fix memzone reserve and release in FDIR 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" To avoid memzone reserve failure and memory leak, following resources management should be added. - Check if the FDIR Memzone already exists before reserving. - Free FDIR memzone when teardown and other failure scenarios. Fixes: 84dc7a95a2d3 ("net/ice: enable flow director engine") Signed-off-by: Wang ShougangX Acked-by: Qi Zhang --- drivers/net/ice/ice_ethdev.h | 1 + drivers/net/ice/ice_fdir_filter.c | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h index c55713cc1..d4ab18436 100644 --- a/drivers/net/ice/ice_ethdev.h +++ b/drivers/net/ice/ice_ethdev.h @@ -334,6 +334,7 @@ struct ice_fdir_info { struct ice_rx_queue *rxq; void *prg_pkt; /* memory for fdir program packet */ uint64_t dma_addr; /* physic address of packet memory*/ + const struct rte_memzone *mz; struct ice_fdir_filter_conf conf; struct ice_fdir_filter_conf **hash_map; diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c index afab5af7f..a89c506c0 100644 --- a/drivers/net/ice/ice_fdir_filter.c +++ b/drivers/net/ice/ice_fdir_filter.c @@ -127,6 +127,12 @@ static struct ice_flow_parser ice_fdir_parser_comms; static const struct rte_memzone * ice_memzone_reserve(const char *name, uint32_t len, int socket_id) { + const struct rte_memzone *mz; + + mz = rte_memzone_lookup(name); + if (mz) + return mz; + return rte_memzone_reserve_aligned(name, len, socket_id, RTE_MEMZONE_IOVA_CONTIG, ICE_RING_BASE_ALIGN); @@ -481,19 +487,23 @@ ice_fdir_setup(struct ice_pf *pf) } pf->fdir.prg_pkt = mz->addr; pf->fdir.dma_addr = mz->iova; + pf->fdir.mz = mz; err = ice_fdir_prof_alloc(hw); if (err) { PMD_DRV_LOG(ERR, "Cannot allocate memory for " "flow director profile."); err = -ENOMEM; - goto fail_mem; + goto fail_prof; } PMD_DRV_LOG(INFO, "FDIR setup successfully, with programming queue %u.", vsi->base_queue); return ICE_SUCCESS; +fail_prof: + rte_memzone_free(pf->fdir.mz); + pf->fdir.mz = NULL; fail_mem: ice_rx_queue_release(pf->fdir.rxq); pf->fdir.rxq = NULL; @@ -607,6 +617,13 @@ ice_fdir_teardown(struct ice_pf *pf) ice_fdir_prof_free(hw); ice_release_vsi(vsi); pf->fdir.fdir_vsi = NULL; + + if (pf->fdir.mz) { + err = rte_memzone_free(pf->fdir.mz); + pf->fdir.mz = NULL; + if (err) + PMD_DRV_LOG(ERR, "Failed to free FDIR memezone."); + } } static int From patchwork Tue Nov 12 03:50:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shougang Wang X-Patchwork-Id: 62881 X-Patchwork-Delegate: xiaolong.ye@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 19424A04AB; Tue, 12 Nov 2019 11:09:30 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CF2E92BCE; Tue, 12 Nov 2019 11:09:21 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id DD6762BA2 for ; Tue, 12 Nov 2019 11:09:18 +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; 12 Nov 2019 02:09:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,295,1569308400"; d="scan'208";a="214048335" Received: from intel.sh.intel.com ([10.239.255.146]) by fmsmga001.fm.intel.com with ESMTP; 12 Nov 2019 02:09:17 -0800 From: Wang ShougangX To: dev@dpdk.org Cc: qiming.yang@intel.com, qi.z.zhang@intel.com, Wang ShougangX Date: Tue, 12 Nov 2019 03:50:09 +0000 Message-Id: <20191112035011.67537-3-shougangx.wang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191112035011.67537-1-shougangx.wang@intel.com> References: <20191105033806.2878-1-shougangx.wang@intel.com> <20191112035011.67537-1-shougangx.wang@intel.com> Subject: [dpdk-dev] [PATCH v4 2/4] net/ice: fix removal of FDIR profile 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" The removal of FDIR profile should start from the next of ICE_FLTR_PTYPE_NONF_NONE. Fixes: 109e8e06249e ("net/ice: configure HW flow director rule") Signed-off-by: Wang ShougangX --- drivers/net/ice/ice_fdir_filter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c index a89c506c0..039e00a28 100644 --- a/drivers/net/ice/ice_fdir_filter.c +++ b/drivers/net/ice/ice_fdir_filter.c @@ -571,7 +571,7 @@ ice_fdir_prof_rm_all(struct ice_pf *pf) { enum ice_fltr_ptype ptype; - for (ptype = ICE_FLTR_PTYPE_NONF_NONE; + for (ptype = ICE_FLTR_PTYPE_NONF_NONE + 1; ptype < ICE_FLTR_PTYPE_MAX; ptype++) { ice_fdir_prof_rm(pf, ptype, false); From patchwork Tue Nov 12 03:50:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shougang Wang X-Patchwork-Id: 62882 X-Patchwork-Delegate: xiaolong.ye@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id D7E4BA04AB; Tue, 12 Nov 2019 11:09:37 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 753AA2BEA; Tue, 12 Nov 2019 11:09:24 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 21E60374 for ; Tue, 12 Nov 2019 11:09:20 +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; 12 Nov 2019 02:09:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,295,1569308400"; d="scan'208";a="214048343" Received: from intel.sh.intel.com ([10.239.255.146]) by fmsmga001.fm.intel.com with ESMTP; 12 Nov 2019 02:09:19 -0800 From: Wang ShougangX To: dev@dpdk.org Cc: qiming.yang@intel.com, qi.z.zhang@intel.com, Wang ShougangX Date: Tue, 12 Nov 2019 03:50:10 +0000 Message-Id: <20191112035011.67537-4-shougangx.wang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191112035011.67537-1-shougangx.wang@intel.com> References: <20191105033806.2878-1-shougangx.wang@intel.com> <20191112035011.67537-1-shougangx.wang@intel.com> Subject: [dpdk-dev] [PATCH v4 3/4] net/ice: fix FDIR counter resource release 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" All the counter resources should be cleaned up when teardown. Fixes: 0f880c3df192 ("net/ice: add flow director counter resource init/release") Signed-off-by: Wang ShougangX Acked-by: Qi Zhang --- drivers/net/ice/ice_fdir_filter.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c index 039e00a28..82dd283f7 100644 --- a/drivers/net/ice/ice_fdir_filter.c +++ b/drivers/net/ice/ice_fdir_filter.c @@ -252,6 +252,9 @@ ice_fdir_counter_release(struct ice_pf *pf) for (i = 0; i < container->index_free; i++) rte_free(container->pools[i]); + TAILQ_INIT(&container->pool_list); + container->index_free = 0; + return 0; } From patchwork Tue Nov 12 03:50:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shougang Wang X-Patchwork-Id: 62883 X-Patchwork-Delegate: xiaolong.ye@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3195CA04AB; Tue, 12 Nov 2019 11:09:44 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A770D2C12; Tue, 12 Nov 2019 11:09:26 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 294062BEA for ; Tue, 12 Nov 2019 11:09:23 +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; 12 Nov 2019 02:09:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,295,1569308400"; d="scan'208";a="214048348" Received: from intel.sh.intel.com ([10.239.255.146]) by fmsmga001.fm.intel.com with ESMTP; 12 Nov 2019 02:09:21 -0800 From: Wang ShougangX To: dev@dpdk.org Cc: qiming.yang@intel.com, qi.z.zhang@intel.com, Wang ShougangX Date: Tue, 12 Nov 2019 03:50:11 +0000 Message-Id: <20191112035011.67537-5-shougangx.wang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191112035011.67537-1-shougangx.wang@intel.com> References: <20191105033806.2878-1-shougangx.wang@intel.com> <20191112035011.67537-1-shougangx.wang@intel.com> Subject: [dpdk-dev] [PATCH v4 4/4] net/ice: fix wild pointer 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" To avoid wild pointer, pointers should be set to NULL after free them. Fixes: 1a2fc1799f09 ("net/ice: reject duplicated flow for flow director") Fixes: 84dc7a95a2d3 ("net/ice: enable flow director engine") Fixes: 0f880c3df192 ("net/ice: add flow director counter resource init/release") Signed-off-by: Wang ShougangX --- drivers/net/ice/ice_fdir_filter.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c index 82dd283f7..ac03819ed 100644 --- a/drivers/net/ice/ice_fdir_filter.c +++ b/drivers/net/ice/ice_fdir_filter.c @@ -152,6 +152,7 @@ ice_fdir_prof_alloc(struct ice_hw *hw) if (!hw->fdir_prof) return -ENOMEM; } + for (ptype = ICE_FLTR_PTYPE_NONF_IPV4_UDP; ptype < ICE_FLTR_PTYPE_MAX; ptype++) { @@ -167,9 +168,13 @@ ice_fdir_prof_alloc(struct ice_hw *hw) fail_mem: for (fltr_ptype = ICE_FLTR_PTYPE_NONF_IPV4_UDP; fltr_ptype < ptype; - fltr_ptype++) + fltr_ptype++) { rte_free(hw->fdir_prof[fltr_ptype]); + hw->fdir_prof[fltr_ptype] = NULL; + } + rte_free(hw->fdir_prof); + hw->fdir_prof = NULL; return -ENOMEM; } @@ -249,8 +254,10 @@ ice_fdir_counter_release(struct ice_pf *pf) &fdir_info->counter; uint8_t i; - for (i = 0; i < container->index_free; i++) + for (i = 0; i < container->index_free; i++) { rte_free(container->pools[i]); + container->pools[i] = NULL; + } TAILQ_INIT(&container->pool_list); container->index_free = 0; @@ -400,6 +407,9 @@ ice_fdir_release_filter_list(struct ice_pf *pf) rte_free(fdir_info->hash_map); if (fdir_info->hash_table) rte_hash_free(fdir_info->hash_table); + + fdir_info->hash_map = NULL; + fdir_info->hash_table = NULL; } /* @@ -526,10 +536,13 @@ ice_fdir_prof_free(struct ice_hw *hw) for (ptype = ICE_FLTR_PTYPE_NONF_IPV4_UDP; ptype < ICE_FLTR_PTYPE_MAX; - ptype++) + ptype++) { rte_free(hw->fdir_prof[ptype]); + hw->fdir_prof[ptype] = NULL; + } rte_free(hw->fdir_prof); + hw->fdir_prof = NULL; } /* Remove a profile for some filter type */