Skip to content

Commit c563908

Browse files
Michal Swiatkowskianguy11
authored andcommitted
ice: Remove reading all recipes before adding a new one
The content of the first read recipe is used as a template when adding a recipe. It isn't needed - only prune index is directly set from there. Set it in the code instead. Also, now there's no need to set rid and lookup indexes to 0, as the whole recipe buffer is initialized to 0. Signed-off-by: Michal Swiatkowski <[email protected]> Reviewed-by: Przemek Kitszel <[email protected]> Signed-off-by: Marcin Szycik <[email protected]> Tested-by: Sujai Buvaneswaran <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent e247267 commit c563908

File tree

1 file changed

+2
-27
lines changed

1 file changed

+2
-27
lines changed

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

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5079,11 +5079,9 @@ ice_add_sw_recipe(struct ice_hw *hw, struct ice_sw_recipe *rm,
50795079
{
50805080
DECLARE_BITMAP(result_idx_bm, ICE_MAX_FV_WORDS);
50815081
struct ice_aqc_recipe_content *content;
5082-
struct ice_aqc_recipe_data_elem *tmp;
50835082
struct ice_aqc_recipe_data_elem *buf;
50845083
struct ice_recp_grp_entry *entry;
50855084
u16 free_res_idx;
5086-
u16 recipe_count;
50875085
u8 chain_idx;
50885086
u8 recps = 0;
50895087
int status;
@@ -5110,10 +5108,6 @@ ice_add_sw_recipe(struct ice_hw *hw, struct ice_sw_recipe *rm,
51105108
if (rm->n_grp_count > ICE_MAX_CHAIN_RECIPE)
51115109
return -ENOSPC;
51125110

5113-
tmp = kcalloc(ICE_MAX_NUM_RECIPES, sizeof(*tmp), GFP_KERNEL);
5114-
if (!tmp)
5115-
return -ENOMEM;
5116-
51175111
buf = devm_kcalloc(ice_hw_to_dev(hw), rm->n_grp_count, sizeof(*buf),
51185112
GFP_KERNEL);
51195113
if (!buf) {
@@ -5122,11 +5116,6 @@ ice_add_sw_recipe(struct ice_hw *hw, struct ice_sw_recipe *rm,
51225116
}
51235117

51245118
bitmap_zero(rm->r_bitmap, ICE_MAX_NUM_RECIPES);
5125-
recipe_count = ICE_MAX_NUM_RECIPES;
5126-
status = ice_aq_get_recipe(hw, tmp, &recipe_count, ICE_SW_LKUP_MAC,
5127-
NULL);
5128-
if (status || recipe_count == 0)
5129-
goto err_unroll;
51305119

51315120
/* Allocate the recipe resources, and configure them according to the
51325121
* match fields from protocol headers and extracted field vectors.
@@ -5141,19 +5130,9 @@ ice_add_sw_recipe(struct ice_hw *hw, struct ice_sw_recipe *rm,
51415130

51425131
content = &buf[recps].content;
51435132

5144-
/* Clear the result index of the located recipe, as this will be
5145-
* updated, if needed, later in the recipe creation process.
5146-
*/
5147-
tmp[0].content.result_indx = 0;
5148-
5149-
buf[recps] = tmp[0];
51505133
buf[recps].recipe_indx = (u8)entry->rid;
5151-
/* if the recipe is a non-root recipe RID should be programmed
5152-
* as 0 for the rules to be applied correctly.
5153-
*/
5154-
content->rid = 0;
5155-
memset(&content->lkup_indx, 0,
5156-
sizeof(content->lkup_indx));
5134+
5135+
buf[recps].content.act_ctrl |= ICE_AQ_RECIPE_ACT_PRUNE_INDX_M;
51575136

51585137
/* All recipes use look-up index 0 to match switch ID. */
51595138
content->lkup_indx[0] = ICE_AQ_SW_ID_LKUP_IDX;
@@ -5192,8 +5171,6 @@ ice_add_sw_recipe(struct ice_hw *hw, struct ice_sw_recipe *rm,
51925171
}
51935172

51945173
/* fill recipe dependencies */
5195-
bitmap_zero((unsigned long *)buf[recps].recipe_bitmap,
5196-
ICE_MAX_NUM_RECIPES);
51975174
set_bit(buf[recps].recipe_indx,
51985175
(unsigned long *)buf[recps].recipe_bitmap);
51995176
content->act_ctrl_fwd_priority = rm->priority;
@@ -5357,12 +5334,10 @@ ice_add_sw_recipe(struct ice_hw *hw, struct ice_sw_recipe *rm,
53575334
recp->recp_created = true;
53585335
}
53595336
rm->root_buf = buf;
5360-
kfree(tmp);
53615337
return status;
53625338

53635339
err_unroll:
53645340
err_mem:
5365-
kfree(tmp);
53665341
devm_kfree(ice_hw_to_dev(hw), buf);
53675342
return status;
53685343
}

0 commit comments

Comments
 (0)