Commit 3125eb55 authored by Michal Swiatkowski's avatar Michal Swiatkowski Committed by Tony Nguyen

ice: Simplify bitmap setting in adding recipe

Remove unnecessary size checks when copying bitmaps in ice_add_sw_recipe()
and replace them with compile time assert. Check if the bitmaps are equal
size, as they are copied both ways.
Signed-off-by: default avatarMichal Swiatkowski <michal.swiatkowski@linux.intel.com>
Reviewed-by: default avatarPrzemek Kitszel <przemyslaw.kitszel@intel.com>
Co-developed-by: default avatarMarcin Szycik <marcin.szycik@linux.intel.com>
Signed-off-by: default avatarMarcin Szycik <marcin.szycik@linux.intel.com>
Tested-by: default avatarSujai Buvaneswaran <sujai.buvaneswaran@intel.com>
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
parent c5639084
...@@ -5067,6 +5067,10 @@ ice_find_free_recp_res_idx(struct ice_hw *hw, const unsigned long *profiles, ...@@ -5067,6 +5067,10 @@ ice_find_free_recp_res_idx(struct ice_hw *hw, const unsigned long *profiles,
return (u16)bitmap_weight(free_idx, ICE_MAX_FV_WORDS); return (u16)bitmap_weight(free_idx, ICE_MAX_FV_WORDS);
} }
/* For memcpy in ice_add_sw_recipe. */
static_assert(sizeof_field(struct ice_aqc_recipe_data_elem, recipe_bitmap) ==
sizeof_field(struct ice_sw_recipe, r_bitmap));
/** /**
* ice_add_sw_recipe - function to call AQ calls to create switch recipe * ice_add_sw_recipe - function to call AQ calls to create switch recipe
* @hw: pointer to hardware structure * @hw: pointer to hardware structure
...@@ -5187,13 +5191,9 @@ ice_add_sw_recipe(struct ice_hw *hw, struct ice_sw_recipe *rm, ...@@ -5187,13 +5191,9 @@ ice_add_sw_recipe(struct ice_hw *hw, struct ice_sw_recipe *rm,
rm->root_rid = buf[0].recipe_indx; rm->root_rid = buf[0].recipe_indx;
set_bit(buf[0].recipe_indx, rm->r_bitmap); set_bit(buf[0].recipe_indx, rm->r_bitmap);
buf[0].content.rid = rm->root_rid | ICE_AQ_RECIPE_ID_IS_ROOT; buf[0].content.rid = rm->root_rid | ICE_AQ_RECIPE_ID_IS_ROOT;
if (sizeof(buf[0].recipe_bitmap) >= sizeof(rm->r_bitmap)) { memcpy(buf[0].recipe_bitmap, rm->r_bitmap,
memcpy(buf[0].recipe_bitmap, rm->r_bitmap, sizeof(buf[0].recipe_bitmap));
sizeof(buf[0].recipe_bitmap));
} else {
status = -EINVAL;
goto err_unroll;
}
/* Applicable only for ROOT_RECIPE, set the fwd_priority for /* Applicable only for ROOT_RECIPE, set the fwd_priority for
* the recipe which is getting created if specified * the recipe which is getting created if specified
* by user. Usually any advanced switch filter, which results * by user. Usually any advanced switch filter, which results
...@@ -5256,14 +5256,8 @@ ice_add_sw_recipe(struct ice_hw *hw, struct ice_sw_recipe *rm, ...@@ -5256,14 +5256,8 @@ ice_add_sw_recipe(struct ice_hw *hw, struct ice_sw_recipe *rm,
set_bit(entry->rid, rm->r_bitmap); set_bit(entry->rid, rm->r_bitmap);
} }
list_add(&last_chain_entry->l_entry, &rm->rg_list); list_add(&last_chain_entry->l_entry, &rm->rg_list);
if (sizeof(buf[recps].recipe_bitmap) >= memcpy(buf[recps].recipe_bitmap, rm->r_bitmap,
sizeof(rm->r_bitmap)) { sizeof(buf[recps].recipe_bitmap));
memcpy(buf[recps].recipe_bitmap, rm->r_bitmap,
sizeof(buf[recps].recipe_bitmap));
} else {
status = -EINVAL;
goto err_unroll;
}
content->act_ctrl_fwd_priority = rm->priority; content->act_ctrl_fwd_priority = rm->priority;
recps++; recps++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment