From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3FAF04404F; Wed, 12 Jun 2024 17:06:07 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5F34C40EDC; Wed, 12 Jun 2024 17:03:41 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) by mails.dpdk.org (Postfix) with ESMTP id D59A8410DD for ; Wed, 12 Jun 2024 17:03:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718204620; x=1749740620; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=D6FGCYB4aXJsloACEJCrsSC6/uHEBySpLeHJd+1adtQ=; b=ivwUr0fYP0T78VSiJAYtW0lx2Mf3AA9lm8UGKNUfJLTU/gtnn1ZLVcMb CGxhwpLHONB1MUW2LZIfnpfNeaJkJlAoiO/BZPuM6Z2GDB6Xr4W9+2dHw wkjEJYf8ciQIbEMCLhYF/n2lJUlibWXxaehFhf4B3L7S9TvFREet0sQPr YLNL6z02lwEMOLnKhXITuUoTMM8pGYE3SbZ4lll/DD/i/z4yNak3m/msr LaU7c1J+R75fW90Cu8C5D21dv2yYPaYrpCZIS7ewl4P31jnffJClaYQhJ J7UWRmwUjMhVWbcG74kpA3ti6n4s/zzgTkAXrvd2reQBKBK+suZs/C82k Q==; X-CSE-ConnectionGUID: dVWt6jz3SZS8aD7p6pyziA== X-CSE-MsgGUID: 72LktZmoQTqwmgLMuNUBog== X-IronPort-AV: E=McAfee;i="6700,10204,11101"; a="32459169" X-IronPort-AV: E=Sophos;i="6.08,233,1712646000"; d="scan'208";a="32459169" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jun 2024 08:03:38 -0700 X-CSE-ConnectionGUID: LwC2pDwlSUip0zntMQU6bQ== X-CSE-MsgGUID: zv4+WhF+Rx2nHwJeXBO7Zw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,233,1712646000"; d="scan'208";a="39924898" Received: from silpixa00401119.ir.intel.com ([10.55.129.167]) by orviesa009.jf.intel.com with ESMTP; 12 Jun 2024 08:03:36 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: Ian Stokes , bruce.richardson@intel.com, Ashish Shah Subject: [PATCH v2 013/148] net/ice/base: update flow seg fields to declared bitmaps Date: Wed, 12 Jun 2024 16:00:07 +0100 Message-ID: <9a86f0462e4425833bd913b6703ffec2c107b8f3.1718204528.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: <20240430154014.1026-1-ian.stokes@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 From: Ian Stokes ice_flow_seg_info fields match and range are being used with bit operations but not declared as bitmaps. This can cause issues when casting values greater than 32. This change is to declare them as proper bitmaps so that the bitmap operations can function as intended. Signed-off-by: Ashish Shah Signed-off-by: Ian Stokes --- drivers/net/ice/base/ice_flow.c | 53 ++++++++++++++++++++++----------- drivers/net/ice/base/ice_flow.h | 6 ++-- 2 files changed, 39 insertions(+), 20 deletions(-) diff --git a/drivers/net/ice/base/ice_flow.c b/drivers/net/ice/base/ice_flow.c index 0b9974aee2..3a34771f21 100644 --- a/drivers/net/ice/base/ice_flow.c +++ b/drivers/net/ice/base/ice_flow.c @@ -1371,7 +1371,7 @@ ice_flow_xtract_pkt_flags(struct ice_hw *hw, */ static int ice_flow_xtract_fld(struct ice_hw *hw, struct ice_flow_prof_params *params, - u8 seg, enum ice_flow_field fld, u64 match) + u8 seg, enum ice_flow_field fld, ice_bitmap_t *match) { enum ice_flow_field sib = ICE_FLOW_FIELD_IDX_MAX; u8 fv_words = (u8)hw->blk[params->blk].es.fvw; @@ -1420,7 +1420,7 @@ ice_flow_xtract_fld(struct ice_hw *hw, struct ice_flow_prof_params *params, /* If the sibling field is also included, that field's * mask needs to be included. */ - if (match & BIT(sib)) + if (ice_is_bit_set(match, sib)) sib_mask = ice_flds_info[sib].mask; break; case ICE_FLOW_FIELD_IDX_IPV6_TTL: @@ -1451,7 +1451,7 @@ ice_flow_xtract_fld(struct ice_hw *hw, struct ice_flow_prof_params *params, /* If the sibling field is also included, that field's * mask needs to be included. */ - if (match & BIT(sib)) + if (ice_is_bit_set(match, sib)) sib_mask = ice_flds_info[sib].mask; break; case ICE_FLOW_FIELD_IDX_IPV4_SA: @@ -1722,15 +1722,16 @@ ice_flow_create_xtrct_seq(struct ice_hw *hw, } for (i = 0; i < params->prof->segs_cnt; i++) { - u64 match = params->prof->segs[i].match; + ice_declare_bitmap(match, ICE_FLOW_FIELD_IDX_MAX); enum ice_flow_field j; - ice_for_each_set_bit(j, (ice_bitmap_t *)&match, - ICE_FLOW_FIELD_IDX_MAX) { + ice_cp_bitmap(match, params->prof->segs[i].match, + ICE_FLOW_FIELD_IDX_MAX); + ice_for_each_set_bit(j, match, ICE_FLOW_FIELD_IDX_MAX) { status = ice_flow_xtract_fld(hw, params, i, j, match); if (status) return status; - ice_clear_bit(j, (ice_bitmap_t *)&match); + ice_clear_bit(j, match); } /* Process raw matching bytes */ @@ -1789,7 +1790,7 @@ ice_flow_acl_def_entry_frmt(struct ice_flow_prof_params *params) struct ice_flow_seg_info *seg = ¶ms->prof->segs[i]; u16 j; - ice_for_each_set_bit(j, (ice_bitmap_t *)&seg->match, + ice_for_each_set_bit(j, seg->match, (u16)ICE_FLOW_FIELD_IDX_MAX) { struct ice_flow_fld_info *fld = &seg->fields[j]; @@ -1932,7 +1933,10 @@ ice_flow_find_prof_conds(struct ice_hw *hw, enum ice_block blk, for (i = 0; i < segs_cnt; i++) if (segs[i].hdrs != p->segs[i].hdrs || ((conds & ICE_FLOW_FIND_PROF_CHK_FLDS) && - segs[i].match != p->segs[i].match)) + (ice_cmp_bitmap(segs[i].match, + p->segs[i].match, + ICE_FLOW_FIELD_IDX_MAX) == + false))) break; /* A match is found if all segments are matched */ @@ -2432,7 +2436,7 @@ ice_flow_acl_set_xtrct_seq(struct ice_hw *hw, struct ice_flow_prof *prof) struct ice_flow_seg_info *seg = &prof->segs[i]; u16 j; - ice_for_each_set_bit(j, (ice_bitmap_t *)&seg->match, + ice_for_each_set_bit(j, seg->match, ICE_FLOW_FIELD_IDX_MAX) { info = &seg->fields[j]; @@ -3002,7 +3006,7 @@ ice_flow_acl_frmt_entry(struct ice_hw *hw, struct ice_flow_prof *prof, struct ice_flow_seg_info *seg = &prof->segs[i]; u16 j; - ice_for_each_set_bit(j, (ice_bitmap_t *)&seg->match, + ice_for_each_set_bit(j, seg->match, (u16)ICE_FLOW_FIELD_IDX_MAX) { struct ice_flow_fld_info *info = &seg->fields[j]; @@ -3576,11 +3580,9 @@ ice_flow_set_fld_ext(struct ice_flow_seg_info *seg, enum ice_flow_field fld, enum ice_flow_fld_match_type field_type, u16 val_loc, u16 mask_loc, u16 last_loc) { - u64 bit = BIT_ULL(fld); - - seg->match |= bit; + ice_set_bit(fld, seg->match); if (field_type == ICE_FLOW_FLD_TYPE_RANGE) - seg->range |= bit; + ice_set_bit(fld, seg->range); seg->fields[fld].type = field_type; seg->fields[fld].src.val = val_loc; @@ -3929,6 +3931,14 @@ ice_rem_rss_list(struct ice_hw *hw, u16 vsi_handle, struct ice_flow_prof *prof) { enum ice_rss_cfg_hdr_type hdr_type; struct ice_rss_cfg *r, *tmp; + u64 seg_match = 0; + u16 i; + + /* convert match bitmap to u64 for hash field comparison */ + ice_for_each_set_bit(i, prof->segs[prof->segs_cnt - 1].match, + ICE_FLOW_FIELD_IDX_MAX) { + seg_match |= 1ULL << i; + } /* Search for RSS hash fields associated to the VSI that match the * hash configurations associated to the flow profile. If found @@ -3937,7 +3947,7 @@ ice_rem_rss_list(struct ice_hw *hw, u16 vsi_handle, struct ice_flow_prof *prof) hdr_type = ice_get_rss_hdr_type(prof); LIST_FOR_EACH_ENTRY_SAFE(r, tmp, &hw->rss_list_head, ice_rss_cfg, l_entry) - if (r->hash.hash_flds == prof->segs[prof->segs_cnt - 1].match && + if (r->hash.hash_flds == seg_match && r->hash.addl_hdrs == prof->segs[prof->segs_cnt - 1].hdrs && r->hash.hdr_type == hdr_type) { ice_clear_bit(vsi_handle, r->vsis); @@ -3962,11 +3972,18 @@ ice_add_rss_list(struct ice_hw *hw, u16 vsi_handle, struct ice_flow_prof *prof) { enum ice_rss_cfg_hdr_type hdr_type; struct ice_rss_cfg *r, *rss_cfg; + u64 seg_match = 0; + u16 i; + + ice_for_each_set_bit(i, prof->segs[prof->segs_cnt - 1].match, + ICE_FLOW_FIELD_IDX_MAX) { + seg_match |= 1ULL << i; + } hdr_type = ice_get_rss_hdr_type(prof); LIST_FOR_EACH_ENTRY(r, &hw->rss_list_head, ice_rss_cfg, l_entry) - if (r->hash.hash_flds == prof->segs[prof->segs_cnt - 1].match && + if (r->hash.hash_flds == seg_match && r->hash.addl_hdrs == prof->segs[prof->segs_cnt - 1].hdrs && r->hash.hdr_type == hdr_type) { ice_set_bit(vsi_handle, r->vsis); @@ -3977,7 +3994,7 @@ ice_add_rss_list(struct ice_hw *hw, u16 vsi_handle, struct ice_flow_prof *prof) if (!rss_cfg) return ICE_ERR_NO_MEMORY; - rss_cfg->hash.hash_flds = prof->segs[prof->segs_cnt - 1].match; + rss_cfg->hash.hash_flds = seg_match; rss_cfg->hash.addl_hdrs = prof->segs[prof->segs_cnt - 1].hdrs; rss_cfg->hash.hdr_type = hdr_type; rss_cfg->hash.symm = prof->cfg.symm; diff --git a/drivers/net/ice/base/ice_flow.h b/drivers/net/ice/base/ice_flow.h index 7811c38e15..c1658be477 100644 --- a/drivers/net/ice/base/ice_flow.h +++ b/drivers/net/ice/base/ice_flow.h @@ -453,8 +453,10 @@ struct ice_flow_seg_fld_raw { struct ice_flow_seg_info { u32 hdrs; /* Bitmask indicating protocol headers present */ - u64 match; /* Bitmask indicating header fields to be matched */ - u64 range; /* Bitmask indicating header fields matched as ranges */ + /* Bitmask indicating header fields to be matched */ + ice_declare_bitmap(match, ICE_FLOW_FIELD_IDX_MAX); + /* Bitmask indicating header fields matched as ranges */ + ice_declare_bitmap(range, ICE_FLOW_FIELD_IDX_MAX); struct ice_flow_fld_info fields[ICE_FLOW_FIELD_IDX_MAX]; -- 2.43.0