Skip to content

Commit 3125eb5

Browse files
Michal Swiatkowskianguy11
authored andcommitted
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: Michal Swiatkowski <[email protected]> Reviewed-by: Przemek Kitszel <[email protected]> Co-developed-by: Marcin Szycik <[email protected]> Signed-off-by: Marcin Szycik <[email protected]> Tested-by: Sujai Buvaneswaran <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent c563908 commit 3125eb5

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

drivers/net/ethernet/intel/ice/ice_switch.c

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5067,6 +5067,10 @@ ice_find_free_recp_res_idx(struct ice_hw *hw, const unsigned long *profiles,
50675067
return (u16)bitmap_weight(free_idx, ICE_MAX_FV_WORDS);
50685068
}
50695069

5070+
/* For memcpy in ice_add_sw_recipe. */
5071+
static_assert(sizeof_field(struct ice_aqc_recipe_data_elem, recipe_bitmap) ==
5072+
sizeof_field(struct ice_sw_recipe, r_bitmap));
5073+
50705074
/**
50715075
* ice_add_sw_recipe - function to call AQ calls to create switch recipe
50725076
* @hw: pointer to hardware structure
@@ -5187,13 +5191,9 @@ ice_add_sw_recipe(struct ice_hw *hw, struct ice_sw_recipe *rm,
51875191
rm->root_rid = buf[0].recipe_indx;
51885192
set_bit(buf[0].recipe_indx, rm->r_bitmap);
51895193
buf[0].content.rid = rm->root_rid | ICE_AQ_RECIPE_ID_IS_ROOT;
5190-
if (sizeof(buf[0].recipe_bitmap) >= sizeof(rm->r_bitmap)) {
5191-
memcpy(buf[0].recipe_bitmap, rm->r_bitmap,
5192-
sizeof(buf[0].recipe_bitmap));
5193-
} else {
5194-
status = -EINVAL;
5195-
goto err_unroll;
5196-
}
5194+
memcpy(buf[0].recipe_bitmap, rm->r_bitmap,
5195+
sizeof(buf[0].recipe_bitmap));
5196+
51975197
/* Applicable only for ROOT_RECIPE, set the fwd_priority for
51985198
* the recipe which is getting created if specified
51995199
* 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,
52565256
set_bit(entry->rid, rm->r_bitmap);
52575257
}
52585258
list_add(&last_chain_entry->l_entry, &rm->rg_list);
5259-
if (sizeof(buf[recps].recipe_bitmap) >=
5260-
sizeof(rm->r_bitmap)) {
5261-
memcpy(buf[recps].recipe_bitmap, rm->r_bitmap,
5262-
sizeof(buf[recps].recipe_bitmap));
5263-
} else {
5264-
status = -EINVAL;
5265-
goto err_unroll;
5266-
}
5259+
memcpy(buf[recps].recipe_bitmap, rm->r_bitmap,
5260+
sizeof(buf[recps].recipe_bitmap));
52675261
content->act_ctrl_fwd_priority = rm->priority;
52685262

52695263
recps++;

0 commit comments

Comments
 (0)