Skip to content

Commit 817b189

Browse files
hzouStevenanguy11
authored andcommitted
ice: Refactor FW data type and fix bitmap casting issue
According to the datasheet, the recipe association data is an 8-byte little-endian value. It is described as 'Bitmap of the recipe indexes associated with this profile', it is from 24 to 31 byte area in FW. Therefore, it is defined to '__le64 recipe_assoc' in struct ice_aqc_recipe_to_profile. And then fix the bitmap casting issue, as we must never ever use castings for bitmap type. Fixes: 1e0f988 ("ice: Flesh out implementation of support for SRIOV on bonded interface") Reviewed-by: Przemek Kitszel <[email protected]> Reviewed-by: Andrii Staikov <[email protected]> Reviewed-by: Jan Sokolowski <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: Steven Zou <[email protected]> Tested-by: Sujai Buvaneswaran <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent c2deb2e commit 817b189

File tree

4 files changed

+20
-15
lines changed

4 files changed

+20
-15
lines changed

drivers/net/ethernet/intel/ice/ice_adminq_cmd.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,8 +593,9 @@ struct ice_aqc_recipe_data_elem {
593593
struct ice_aqc_recipe_to_profile {
594594
__le16 profile_id;
595595
u8 rsvd[6];
596-
DECLARE_BITMAP(recipe_assoc, ICE_MAX_NUM_RECIPES);
596+
__le64 recipe_assoc;
597597
};
598+
static_assert(sizeof(struct ice_aqc_recipe_to_profile) == 16);
598599

599600
/* Add/Update/Remove/Get switch rules (indirect 0x02A0, 0x02A1, 0x02A2, 0x02A3)
600601
*/

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2041,15 +2041,15 @@ int ice_init_lag(struct ice_pf *pf)
20412041
/* associate recipes to profiles */
20422042
for (n = 0; n < ICE_PROFID_IPV6_GTPU_IPV6_TCP_INNER; n++) {
20432043
err = ice_aq_get_recipe_to_profile(&pf->hw, n,
2044-
(u8 *)&recipe_bits, NULL);
2044+
&recipe_bits, NULL);
20452045
if (err)
20462046
continue;
20472047

20482048
if (recipe_bits & BIT(ICE_SW_LKUP_DFLT)) {
20492049
recipe_bits |= BIT(lag->pf_recipe) |
20502050
BIT(lag->lport_recipe);
20512051
ice_aq_map_recipe_to_profile(&pf->hw, n,
2052-
(u8 *)&recipe_bits, NULL);
2052+
recipe_bits, NULL);
20532053
}
20542054
}
20552055

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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2025,12 +2025,12 @@ ice_update_recipe_lkup_idx(struct ice_hw *hw,
20252025
* ice_aq_map_recipe_to_profile - Map recipe to packet profile
20262026
* @hw: pointer to the HW struct
20272027
* @profile_id: package profile ID to associate the recipe with
2028-
* @r_bitmap: Recipe bitmap filled in and need to be returned as response
2028+
* @r_assoc: Recipe bitmap filled in and need to be returned as response
20292029
* @cd: pointer to command details structure or NULL
20302030
* Recipe to profile association (0x0291)
20312031
*/
20322032
int
2033-
ice_aq_map_recipe_to_profile(struct ice_hw *hw, u32 profile_id, u8 *r_bitmap,
2033+
ice_aq_map_recipe_to_profile(struct ice_hw *hw, u32 profile_id, u64 r_assoc,
20342034
struct ice_sq_cd *cd)
20352035
{
20362036
struct ice_aqc_recipe_to_profile *cmd;
@@ -2042,7 +2042,7 @@ ice_aq_map_recipe_to_profile(struct ice_hw *hw, u32 profile_id, u8 *r_bitmap,
20422042
/* Set the recipe ID bit in the bitmask to let the device know which
20432043
* profile we are associating the recipe to
20442044
*/
2045-
memcpy(cmd->recipe_assoc, r_bitmap, sizeof(cmd->recipe_assoc));
2045+
cmd->recipe_assoc = cpu_to_le64(r_assoc);
20462046

20472047
return ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
20482048
}
@@ -2051,12 +2051,12 @@ ice_aq_map_recipe_to_profile(struct ice_hw *hw, u32 profile_id, u8 *r_bitmap,
20512051
* ice_aq_get_recipe_to_profile - Map recipe to packet profile
20522052
* @hw: pointer to the HW struct
20532053
* @profile_id: package profile ID to associate the recipe with
2054-
* @r_bitmap: Recipe bitmap filled in and need to be returned as response
2054+
* @r_assoc: Recipe bitmap filled in and need to be returned as response
20552055
* @cd: pointer to command details structure or NULL
20562056
* Associate profile ID with given recipe (0x0293)
20572057
*/
20582058
int
2059-
ice_aq_get_recipe_to_profile(struct ice_hw *hw, u32 profile_id, u8 *r_bitmap,
2059+
ice_aq_get_recipe_to_profile(struct ice_hw *hw, u32 profile_id, u64 *r_assoc,
20602060
struct ice_sq_cd *cd)
20612061
{
20622062
struct ice_aqc_recipe_to_profile *cmd;
@@ -2069,7 +2069,7 @@ ice_aq_get_recipe_to_profile(struct ice_hw *hw, u32 profile_id, u8 *r_bitmap,
20692069

20702070
status = ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
20712071
if (!status)
2072-
memcpy(r_bitmap, cmd->recipe_assoc, sizeof(cmd->recipe_assoc));
2072+
*r_assoc = le64_to_cpu(cmd->recipe_assoc);
20732073

20742074
return status;
20752075
}
@@ -2108,15 +2108,17 @@ int ice_alloc_recipe(struct ice_hw *hw, u16 *rid)
21082108
static void ice_get_recp_to_prof_map(struct ice_hw *hw)
21092109
{
21102110
DECLARE_BITMAP(r_bitmap, ICE_MAX_NUM_RECIPES);
2111+
u64 recp_assoc;
21112112
u16 i;
21122113

21132114
for (i = 0; i < hw->switch_info->max_used_prof_index + 1; i++) {
21142115
u16 j;
21152116

21162117
bitmap_zero(profile_to_recipe[i], ICE_MAX_NUM_RECIPES);
21172118
bitmap_zero(r_bitmap, ICE_MAX_NUM_RECIPES);
2118-
if (ice_aq_get_recipe_to_profile(hw, i, (u8 *)r_bitmap, NULL))
2119+
if (ice_aq_get_recipe_to_profile(hw, i, &recp_assoc, NULL))
21192120
continue;
2121+
bitmap_from_arr64(r_bitmap, &recp_assoc, ICE_MAX_NUM_RECIPES);
21202122
bitmap_copy(profile_to_recipe[i], r_bitmap,
21212123
ICE_MAX_NUM_RECIPES);
21222124
for_each_set_bit(j, r_bitmap, ICE_MAX_NUM_RECIPES)
@@ -5390,22 +5392,24 @@ ice_add_adv_recipe(struct ice_hw *hw, struct ice_adv_lkup_elem *lkups,
53905392
*/
53915393
list_for_each_entry(fvit, &rm->fv_list, list_entry) {
53925394
DECLARE_BITMAP(r_bitmap, ICE_MAX_NUM_RECIPES);
5395+
u64 recp_assoc;
53935396
u16 j;
53945397

53955398
status = ice_aq_get_recipe_to_profile(hw, fvit->profile_id,
5396-
(u8 *)r_bitmap, NULL);
5399+
&recp_assoc, NULL);
53975400
if (status)
53985401
goto err_unroll;
53995402

5403+
bitmap_from_arr64(r_bitmap, &recp_assoc, ICE_MAX_NUM_RECIPES);
54005404
bitmap_or(r_bitmap, r_bitmap, rm->r_bitmap,
54015405
ICE_MAX_NUM_RECIPES);
54025406
status = ice_acquire_change_lock(hw, ICE_RES_WRITE);
54035407
if (status)
54045408
goto err_unroll;
54055409

5410+
bitmap_to_arr64(&recp_assoc, r_bitmap, ICE_MAX_NUM_RECIPES);
54065411
status = ice_aq_map_recipe_to_profile(hw, fvit->profile_id,
5407-
(u8 *)r_bitmap,
5408-
NULL);
5412+
recp_assoc, NULL);
54095413
ice_release_change_lock(hw);
54105414

54115415
if (status)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,10 @@ int ice_aq_add_recipe(struct ice_hw *hw,
424424
struct ice_aqc_recipe_data_elem *s_recipe_list,
425425
u16 num_recipes, struct ice_sq_cd *cd);
426426
int
427-
ice_aq_get_recipe_to_profile(struct ice_hw *hw, u32 profile_id, u8 *r_bitmap,
427+
ice_aq_get_recipe_to_profile(struct ice_hw *hw, u32 profile_id, u64 *r_assoc,
428428
struct ice_sq_cd *cd);
429429
int
430-
ice_aq_map_recipe_to_profile(struct ice_hw *hw, u32 profile_id, u8 *r_bitmap,
430+
ice_aq_map_recipe_to_profile(struct ice_hw *hw, u32 profile_id, u64 r_assoc,
431431
struct ice_sq_cd *cd);
432432

433433
#endif /* _ICE_SWITCH_H_ */

0 commit comments

Comments
 (0)