net/ice/base: introduce and use bitmap set API

Introduce ice_bitmap_set() and use it instead of open-coding that
functionality.

Signed-off-by: Bruce Allan <bruce.w.allan@intel.com>
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Acked-by: Qiming Yang <qiming.yang@intel.com>
This commit is contained in:
Qi Zhang 2020-08-26 15:04:26 +08:00 committed by Ferruh Yigit
parent 170d34ac43
commit dd4a3cef55
4 changed files with 23 additions and 12 deletions

View File

@ -354,7 +354,6 @@ ice_acl_create_tbl(struct ice_hw *hw, struct ice_acl_tbl_params *params)
/* call the AQ command to create the ACL table with these values */
status = ice_aq_alloc_acl_tbl(hw, &tbl_alloc, NULL);
if (status) {
if (LE16_TO_CPU(tbl_alloc.buf.resp_buf.alloc_id) <
ICE_AQC_ALLOC_ID_LESS_THAN_4K)
@ -415,8 +414,7 @@ ice_acl_create_tbl(struct ice_hw *hw, struct ice_acl_tbl_params *params)
(tbl->last_entry / ICE_ACL_ENTRY_ALLOC_UNIT);
/* Indicate available entries in the table */
for (i = first_e; i <= last_e; i++)
ice_set_bit(i, tbl->avail);
ice_bitmap_set(tbl->avail, first_e, last_e - first_e + 1);
INIT_LIST_HEAD(&tbl->scens);
out:

View File

@ -375,6 +375,25 @@ static inline void ice_cp_bitmap(ice_bitmap_t *dst, ice_bitmap_t *src, u16 size)
ICE_NONDMA_TO_NONDMA);
}
/**
* ice_bitmap_set - set a number of bits in bitmap from a starting position
* @dst: bitmap destination
* @pos: first bit position to set
* @num_bits: number of bits to set
*
* This function sets bits in a bitmap from pos to (pos + num_bits) - 1.
* Note that this function assumes it is operating on a bitmap declared using
* ice_declare_bitmap.
*/
static inline void
ice_bitmap_set(ice_bitmap_t *dst, u16 pos, u16 num_bits)
{
u16 i;
for (i = pos; i < num_bits; i++)
ice_set_bit(i, dst);
}
/**
* ice_cmp_bitmaps - compares two bitmaps.
* @bmp1: the bitmap to compare

View File

@ -1580,18 +1580,13 @@ ice_get_sw_fv_bitmap(struct ice_hw *hw, enum ice_prof_type req_profs,
struct ice_seg *ice_seg;
struct ice_fv *fv;
ice_memset(&state, 0, sizeof(state), ICE_NONDMA_MEM);
if (req_profs == ICE_PROF_ALL) {
u16 i;
for (i = 0; i < ICE_MAX_NUM_PROFILES; i++)
ice_set_bit(i, bm);
ice_bitmap_set(bm, 0, ICE_MAX_NUM_PROFILES);
return;
}
ice_memset(&state, 0, sizeof(state), ICE_NONDMA_MEM);
ice_zero_bitmap(bm, ICE_MAX_NUM_PROFILES);
ice_seg = hw->seg;
do {
enum ice_prof_type prof_type;

View File

@ -5940,8 +5940,7 @@ ice_find_free_recp_res_idx(struct ice_hw *hw, const ice_bitmap_t *profiles,
ice_zero_bitmap(used_idx, ICE_MAX_FV_WORDS);
ice_zero_bitmap(free_idx, ICE_MAX_FV_WORDS);
for (count = 0; count < ICE_MAX_FV_WORDS; count++)
ice_set_bit(count, possible_idx);
ice_bitmap_set(possible_idx, 0, ICE_MAX_FV_WORDS);
/* For each profile we are going to associate the recipe with, add the
* recipes that are associated with that profile. This will give us