From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 32486A0563; Mon, 23 Mar 2020 08:16:35 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 705E61C0CD; Mon, 23 Mar 2020 08:15:11 +0100 (CET) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 2F2641C068 for ; Mon, 23 Mar 2020 08:14:59 +0100 (CET) IronPort-SDR: xU7KRVaAqErtz1Mx3CAJsxSijNn/7wLF7/BF/09NuqkxRWgyXUQQg/RDAaWBWEQNsT3qVh3t9Q x6xbzCzeQ0kQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2020 00:14:58 -0700 IronPort-SDR: hcPqoQZUVnmsIacVslNgNm+IDL2PgAs0/w/zPenQgqcBwkneqebRwZ1ET67TIAxijjvq5NBSPh 0XdJ61klyjCw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,295,1580803200"; d="scan'208";a="246111540" Received: from dpdk51.sh.intel.com ([10.67.110.245]) by orsmga003.jf.intel.com with ESMTP; 23 Mar 2020 00:14:55 -0700 From: Qi Zhang To: qiming.yang@intel.com Cc: dev@dpdk.org, xiaolong.ye@intel.com, Qi Zhang , Tony Nguyen , Paul M Stillwell Jr Date: Mon, 23 Mar 2020 15:17:34 +0800 Message-Id: <20200323071759.13075-12-qi.z.zhang@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20200323071759.13075-1-qi.z.zhang@intel.com> References: <20200309114357.31800-1-qi.z.zhang@intel.com> <20200323071759.13075-1-qi.z.zhang@intel.com> Subject: [dpdk-dev] [PATCH v2 11/36] net/ice/base: minor fixes 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 is a collection of minor fixes that were found during code review. Changes are: - Call ice_hweight8() instead of calculating it ourselves in ice_bits_max_set(). - Call ice_test_and_clear_bit() over calling ice_is_bit_set() then ice_clear_bit() in ice_rem_vsi_rss_list(). - Remove 'chrs' variable in ice_add_prof_id_flow() as it's not being used for anything. - Return result directly instead of assigning to variable then returning the variable in ice_rem_vsig(). - Reduce scope, and don't initialize, 'or_vsig' in ice_add_prof_id_flow(). - Return error immediately in ice_add_prof_id_vsig(). Since the memory wasn't allocated, there is no need to goto and attempt to free memory. - Show that values 37-38 are reserved in ice_flow_avf_hdr_field as the other reserved values are shown. - Fix RCT ordering - Remove initialization of values that aren't needed - Fix function headers to match function names - Use offsetof instead of calculating ourselves in ice_pkg_buf_alloc() - In ice_rem_prof(), do not set status to ICE_SUCCESS as, due to code flow, this will always be ICE_SUCCESS. - Remove unnecessary semicolon in ice_prof_gen_key() - Remove unnecessary initializations - correct bw_alloc type in ice_sched_add_root_node Signed-off-by: Tony Nguyen Signed-off-by: Paul M Stillwell Jr Signed-off-by: Qi Zhang --- drivers/net/ice/base/ice_flex_pipe.c | 52 +++++++++++++++--------------------- drivers/net/ice/base/ice_flex_pipe.h | 2 +- drivers/net/ice/base/ice_flow.c | 7 ++--- drivers/net/ice/base/ice_flow.h | 1 + drivers/net/ice/base/ice_sched.c | 2 +- drivers/net/ice/base/ice_switch.c | 2 +- 6 files changed, 27 insertions(+), 39 deletions(-) diff --git a/drivers/net/ice/base/ice_flex_pipe.c b/drivers/net/ice/base/ice_flex_pipe.c index 5dd7a0d38..0cbd15f92 100644 --- a/drivers/net/ice/base/ice_flex_pipe.c +++ b/drivers/net/ice/base/ice_flex_pipe.c @@ -610,7 +610,7 @@ ice_gen_key_word(u8 val, u8 valid, u8 dont_care, u8 nvr_mtch, u8 *key, static bool ice_bits_max_set(const u8 *mask, u16 size, u16 max) { u16 count = 0; - u16 i, j; + u16 i; /* check each byte */ for (i = 0; i < size; i++) { @@ -626,11 +626,9 @@ static bool ice_bits_max_set(const u8 *mask, u16 size, u16 max) return false; /* count the bits in this byte, checking threshold */ - for (j = 0; j < BITS_PER_BYTE; j++) { - count += (mask[i] & (0x1 << j)) ? 1 : 0; - if (count > max) - return false; - } + count += ice_hweight8(mask[i]); + if (count > max) + return false; } return true; @@ -914,9 +912,8 @@ ice_update_pkg(struct ice_hw *hw, struct ice_buf *bufs, u32 count) return status; for (i = 0; i < count; i++) { - bool last = ((i + 1) == count); - struct ice_buf_hdr *bh = (struct ice_buf_hdr *)(bufs + i); + bool last = ((i + 1) == count); status = ice_aq_update_pkg(hw, bh, LE16_TO_CPU(bh->data_end), last, &offset, &info, NULL); @@ -1565,7 +1562,7 @@ ice_get_sw_fv_bitmap(struct ice_hw *hw, enum ice_prof_type req_profs, * allocated for every list entry. */ enum ice_status -ice_get_sw_fv_list(struct ice_hw *hw, u16 *prot_ids, u8 ids_cnt, +ice_get_sw_fv_list(struct ice_hw *hw, u16 *prot_ids, u16 ids_cnt, ice_bitmap_t *bm, struct LIST_HEAD_TYPE *fv_list) { struct ice_sw_fv_list_entry *fvl; @@ -1582,7 +1579,7 @@ ice_get_sw_fv_list(struct ice_hw *hw, u16 *prot_ids, u8 ids_cnt, ice_seg = hw->seg; do { - u8 i; + u16 i; fv = (struct ice_fv *) ice_pkg_enum_entry(ice_seg, &state, ICE_SID_FLD_VEC_SW, @@ -1806,7 +1803,7 @@ static u16 ice_pkg_buf_get_active_sections(struct ice_buf_build *bld) } /** - * ice_pkg_buf_header + * ice_pkg_buf * @bld: pointer to pkg build (allocated by ice_pkg_buf_alloc()) * * Return a pointer to the buffer's header @@ -1915,9 +1912,11 @@ ice_get_open_tunnel_port(struct ice_hw *hw, enum ice_tunnel_type type, * ice_create_tunnel * @hw: pointer to the HW structure * @type: type of tunnel - * @port: port to use for vxlan tunnel + * @port: port of tunnel to create * - * Creates a tunnel + * Create a tunnel by updating the parse graph in the parser. We do that by + * creating a package buffer with the tunnel info and issuing an update package + * command. */ enum ice_status ice_create_tunnel(struct ice_hw *hw, enum ice_tunnel_type type, u16 port) @@ -3887,6 +3886,7 @@ ice_vsig_get_ref(struct ice_hw *hw, enum ice_block blk, u16 vsig, u16 *refs) { u16 idx = vsig & ICE_VSIG_IDX_M; struct ice_vsig_vsi *ptr; + *refs = 0; if (!hw->blk[blk].xlt2.vsig_tbl[idx].in_use) @@ -4090,12 +4090,12 @@ ice_upd_prof_hw(struct ice_hw *hw, enum ice_block blk, struct ice_buf_build *b; struct ice_chs_chg *tmp; enum ice_status status; - u16 pkg_sects = 0; - u16 sects = 0; + u16 pkg_sects; u16 xlt1 = 0; u16 xlt2 = 0; u16 tcam = 0; u16 es = 0; + u16 sects; /* count number of sections we need */ LIST_FOR_EACH_ENTRY(tmp, chgs, ice_chs_chg, list_entry) { @@ -4194,8 +4194,6 @@ static void ice_update_fd_mask(struct ice_hw *hw, u16 prof_id, u32 mask_sel) GLQF_FDMASK_SEL(prof_id), mask_sel); } -#define ICE_SRC_DST_MAX_COUNT 8 - struct ice_fd_src_dst_pair { u8 prot_id; u8 count; @@ -4754,9 +4752,7 @@ ice_rem_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsig, } while (vsi_cur); } - status = ice_vsig_free(hw, blk, vsig); - - return status; + return ice_vsig_free(hw, blk, vsig); } /** @@ -4974,8 +4970,8 @@ static enum ice_status ice_add_prof_to_lst(struct ice_hw *hw, enum ice_block blk, struct LIST_HEAD_TYPE *lst, u64 hdl) { - struct ice_vsig_prof *p; struct ice_prof_map *map; + struct ice_vsig_prof *p; u16 i; map = ice_search_prof_id(hw, blk, hdl); @@ -5252,7 +5248,7 @@ ice_add_prof_id_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsig, u64 hdl, /* new VSIG profile structure */ t = (struct ice_vsig_prof *)ice_malloc(hw, sizeof(*t)); if (!t) - goto err_ice_add_prof_id_vsig; + return ICE_ERR_NO_MEMORY; t->profile_cookie = map->profile_cookie; t->prof_id = map->prof_id; @@ -5371,7 +5367,7 @@ ice_create_prof_id_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsi, u64 hdl, } /** - * ice_create_vsig_from_list - create a new VSIG with a list of profiles + * ice_create_vsig_from_lst - create a new VSIG with a list of profiles * @hw: pointer to the HW struct * @blk: hardware block * @vsi: the initial VSI that will be in VSIG @@ -5498,13 +5494,11 @@ ice_add_prof_id_flow(struct ice_hw *hw, enum ice_block blk, u16 vsi, u64 hdl) struct ice_vsig_prof *tmp1, *del1; struct LIST_HEAD_TYPE union_lst; struct ice_chs_chg *tmp, *del; - struct LIST_HEAD_TYPE chrs; struct LIST_HEAD_TYPE chg; enum ice_status status; - u16 vsig, or_vsig = 0; + u16 vsig; INIT_LIST_HEAD(&union_lst); - INIT_LIST_HEAD(&chrs); INIT_LIST_HEAD(&chg); /* Get profile */ @@ -5516,6 +5510,7 @@ ice_add_prof_id_flow(struct ice_hw *hw, enum ice_block blk, u16 vsi, u64 hdl) status = ice_vsig_find_vsi(hw, blk, vsi, &vsig); if (!status && vsig) { bool only_vsi; + u16 or_vsig; u16 ref; /* found in vsig */ @@ -5625,11 +5620,6 @@ ice_add_prof_id_flow(struct ice_hw *hw, enum ice_block blk, u16 vsi, u64 hdl) ice_free(hw, del1); } - LIST_FOR_EACH_ENTRY_SAFE(del1, tmp1, &chrs, ice_vsig_prof, list) { - LIST_DEL(&del1->list); - ice_free(hw, del1); - } - return status; } diff --git a/drivers/net/ice/base/ice_flex_pipe.h b/drivers/net/ice/base/ice_flex_pipe.h index fa72e386d..e3ee882da 100644 --- a/drivers/net/ice/base/ice_flex_pipe.h +++ b/drivers/net/ice/base/ice_flex_pipe.h @@ -36,7 +36,7 @@ ice_get_sw_fv_bitmap(struct ice_hw *hw, enum ice_prof_type type, void ice_init_prof_result_bm(struct ice_hw *hw); enum ice_status -ice_get_sw_fv_list(struct ice_hw *hw, u16 *prot_ids, u8 ids_cnt, +ice_get_sw_fv_list(struct ice_hw *hw, u16 *prot_ids, u16 ids_cnt, ice_bitmap_t *bm, struct LIST_HEAD_TYPE *fv_list); bool ice_get_open_tunnel_port(struct ice_hw *hw, enum ice_tunnel_type type, diff --git a/drivers/net/ice/base/ice_flow.c b/drivers/net/ice/base/ice_flow.c index d52bce1ce..0838b3bd2 100644 --- a/drivers/net/ice/base/ice_flow.c +++ b/drivers/net/ice/base/ice_flow.c @@ -1152,7 +1152,7 @@ ice_flow_add_prof_sync(struct ice_hw *hw, enum ice_block blk, struct ice_flow_prof **prof) { struct ice_flow_prof_params params; - enum ice_status status = ICE_SUCCESS; + enum ice_status status; u8 i; if (!prof || (acts_cnt && !acts)) @@ -1825,14 +1825,11 @@ void ice_rem_vsi_rss_list(struct ice_hw *hw, u16 vsi_handle) ice_acquire_lock(&hw->rss_locks); LIST_FOR_EACH_ENTRY_SAFE(r, tmp, &hw->rss_list_head, ice_rss_cfg, l_entry) { - if (ice_is_bit_set(r->vsis, vsi_handle)) { - ice_clear_bit(vsi_handle, r->vsis); - + if (ice_test_and_clear_bit(vsi_handle, r->vsis)) if (!ice_is_any_bit_set(r->vsis, ICE_MAX_VSI)) { LIST_DEL(&r->l_entry); ice_free(hw, r); } - } } ice_release_lock(&hw->rss_locks); } diff --git a/drivers/net/ice/base/ice_flow.h b/drivers/net/ice/base/ice_flow.h index d7b10ccc3..4c2067f0c 100644 --- a/drivers/net/ice/base/ice_flow.h +++ b/drivers/net/ice/base/ice_flow.h @@ -187,6 +187,7 @@ enum ice_flow_avf_hdr_field { ICE_AVF_FLOW_FIELD_IPV4_SCTP, ICE_AVF_FLOW_FIELD_IPV4_OTHER, ICE_AVF_FLOW_FIELD_FRAG_IPV4, + /* Values 37-38 are reserved */ ICE_AVF_FLOW_FIELD_UNICAST_IPV6_UDP = 39, ICE_AVF_FLOW_FIELD_MULTICAST_IPV6_UDP, ICE_AVF_FLOW_FIELD_IPV6_UDP, diff --git a/drivers/net/ice/base/ice_sched.c b/drivers/net/ice/base/ice_sched.c index 03885d027..575c2ab58 100644 --- a/drivers/net/ice/base/ice_sched.c +++ b/drivers/net/ice/base/ice_sched.c @@ -2907,7 +2907,7 @@ ice_sched_update_elem(struct ice_hw *hw, struct ice_sched_node *node, */ static enum ice_status ice_sched_cfg_node_bw_alloc(struct ice_hw *hw, struct ice_sched_node *node, - enum ice_rl_type rl_type, u8 bw_alloc) + enum ice_rl_type rl_type, u16 bw_alloc) { struct ice_aqc_txsched_elem_data buf; struct ice_aqc_txsched_elem *data; diff --git a/drivers/net/ice/base/ice_switch.c b/drivers/net/ice/base/ice_switch.c index adcda9645..796390e93 100644 --- a/drivers/net/ice/base/ice_switch.c +++ b/drivers/net/ice/base/ice_switch.c @@ -743,7 +743,7 @@ ice_get_recp_frm_fw(struct ice_hw *hw, struct ice_sw_recipe *recps, u8 rid, /* Complete initialization of the root recipe entry */ lkup_exts->n_val_words = fv_word_idx; recps[rid].big_recp = (num_recps > 1); - recps[rid].n_grp_count = num_recps; + recps[rid].n_grp_count = (u8)num_recps; recps[rid].root_buf = (struct ice_aqc_recipe_data_elem *) ice_memdup(hw, tmp, recps[rid].n_grp_count * sizeof(*recps[rid].root_buf), ICE_NONDMA_TO_NONDMA); -- 2.13.6