From patchwork Tue Jun 4 05:42:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leyi Rong X-Patchwork-Id: 54312 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 B296F1BC15; Tue, 4 Jun 2019 07:45:20 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 0A4741BA5E for ; Tue, 4 Jun 2019 07:44:33 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Jun 2019 22:44:33 -0700 X-ExtLoop1: 1 Received: from lrong-srv-03.sh.intel.com ([10.67.119.177]) by fmsmga008.fm.intel.com with ESMTP; 03 Jun 2019 22:44:32 -0700 From: Leyi Rong To: qi.z.zhang@intel.com Cc: dev@dpdk.org, Leyi Rong , Dan Nowlin , Paul M Stillwell Jr Date: Tue, 4 Jun 2019 13:42:35 +0800 Message-Id: <20190604054248.68510-37-leyi.rong@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190604054248.68510-1-leyi.rong@intel.com> References: <20190604054248.68510-1-leyi.rong@intel.com> Subject: [dpdk-dev] [PATCH 36/49] net/ice/base: add lock around profile map list 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" Add locking mechanism around profile map list. Signed-off-by: Dan Nowlin Signed-off-by: Paul M Stillwell Jr Signed-off-by: Leyi Rong --- drivers/net/ice/base/ice_flex_pipe.c | 31 +++++++++++++++++----------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/drivers/net/ice/base/ice_flex_pipe.c b/drivers/net/ice/base/ice_flex_pipe.c index fdbf893a8..5864cbf3e 100644 --- a/drivers/net/ice/base/ice_flex_pipe.c +++ b/drivers/net/ice/base/ice_flex_pipe.c @@ -3973,6 +3973,8 @@ ice_add_prof(struct ice_hw *hw, enum ice_block blk, u64 id, u8 ptypes[], u32 byte = 0; u8 prof_id; + ice_acquire_lock(&hw->blk[blk].es.prof_map_lock); + /* search for existing profile */ status = ice_find_prof_id(hw, blk, es, &prof_id); if (status) { @@ -4044,11 +4046,12 @@ ice_add_prof(struct ice_hw *hw, enum ice_block blk, u64 id, u8 ptypes[], bytes--; byte++; } - LIST_ADD(&prof->list, &hw->blk[blk].es.prof_map); - return ICE_SUCCESS; + LIST_ADD(&prof->list, &hw->blk[blk].es.prof_map); + status = ICE_SUCCESS; err_ice_add_prof: + ice_release_lock(&hw->blk[blk].es.prof_map_lock); return status; } @@ -4350,29 +4353,33 @@ ice_rem_flow_all(struct ice_hw *hw, enum ice_block blk, u64 id) */ enum ice_status ice_rem_prof(struct ice_hw *hw, enum ice_block blk, u64 id) { - enum ice_status status; struct ice_prof_map *pmap; + enum ice_status status; - pmap = ice_search_prof_id(hw, blk, id); - if (!pmap) - return ICE_ERR_DOES_NOT_EXIST; + ice_acquire_lock(&hw->blk[blk].es.prof_map_lock); + + pmap = ice_search_prof_id_low(hw, blk, id); + if (!pmap) { + status = ICE_ERR_DOES_NOT_EXIST; + goto err_ice_rem_prof; + } /* remove all flows with this profile */ status = ice_rem_flow_all(hw, blk, pmap->profile_cookie); if (status) - return status; + goto err_ice_rem_prof; - /* remove profile */ - status = ice_free_prof_id(hw, blk, pmap->prof_id); - if (status) - return status; /* dereference profile, and possibly remove */ ice_prof_dec_ref(hw, blk, pmap->prof_id); LIST_DEL(&pmap->list); ice_free(hw, pmap); - return ICE_SUCCESS; + status = ICE_SUCCESS; + +err_ice_rem_prof: + ice_release_lock(&hw->blk[blk].es.prof_map_lock); + return status; } /**