]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-6.6/ice-refactor-fw-data-type-and-fix-bitmap-casting-iss.patch
Linux 6.1.85
[thirdparty/kernel/stable-queue.git] / queue-6.6 / ice-refactor-fw-data-type-and-fix-bitmap-casting-iss.patch
1 From c80f0a331b43451a72ddf776de4c9249a2356165 Mon Sep 17 00:00:00 2001
2 From: Sasha Levin <sashal@kernel.org>
3 Date: Wed, 7 Feb 2024 09:49:59 +0800
4 Subject: ice: Refactor FW data type and fix bitmap casting issue
5
6 From: Steven Zou <steven.zou@intel.com>
7
8 [ Upstream commit 817b18965b58a6e5fb6ce97abf01b03a205a6aea ]
9
10 According to the datasheet, the recipe association data is an 8-byte
11 little-endian value. It is described as 'Bitmap of the recipe indexes
12 associated with this profile', it is from 24 to 31 byte area in FW.
13 Therefore, it is defined to '__le64 recipe_assoc' in struct
14 ice_aqc_recipe_to_profile. And then fix the bitmap casting issue, as we
15 must never ever use castings for bitmap type.
16
17 Fixes: 1e0f9881ef79 ("ice: Flesh out implementation of support for SRIOV on bonded interface")
18 Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
19 Reviewed-by: Andrii Staikov <andrii.staikov@intel.com>
20 Reviewed-by: Jan Sokolowski <jan.sokolowski@intel.com>
21 Reviewed-by: Simon Horman <horms@kernel.org>
22 Signed-off-by: Steven Zou <steven.zou@intel.com>
23 Tested-by: Sujai Buvaneswaran <sujai.buvaneswaran@intel.com>
24 Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
25 Signed-off-by: Sasha Levin <sashal@kernel.org>
26 ---
27 .../net/ethernet/intel/ice/ice_adminq_cmd.h | 3 ++-
28 drivers/net/ethernet/intel/ice/ice_lag.c | 4 ++--
29 drivers/net/ethernet/intel/ice/ice_switch.c | 24 +++++++++++--------
30 drivers/net/ethernet/intel/ice/ice_switch.h | 4 ++--
31 4 files changed, 20 insertions(+), 15 deletions(-)
32
33 diff --git a/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h b/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h
34 index 45f3e351653db..72ca2199c9572 100644
35 --- a/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h
36 +++ b/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h
37 @@ -592,8 +592,9 @@ struct ice_aqc_recipe_data_elem {
38 struct ice_aqc_recipe_to_profile {
39 __le16 profile_id;
40 u8 rsvd[6];
41 - DECLARE_BITMAP(recipe_assoc, ICE_MAX_NUM_RECIPES);
42 + __le64 recipe_assoc;
43 };
44 +static_assert(sizeof(struct ice_aqc_recipe_to_profile) == 16);
45
46 /* Add/Update/Remove/Get switch rules (indirect 0x02A0, 0x02A1, 0x02A2, 0x02A3)
47 */
48 diff --git a/drivers/net/ethernet/intel/ice/ice_lag.c b/drivers/net/ethernet/intel/ice/ice_lag.c
49 index 23e197c3d02a7..4e675c7c199fa 100644
50 --- a/drivers/net/ethernet/intel/ice/ice_lag.c
51 +++ b/drivers/net/ethernet/intel/ice/ice_lag.c
52 @@ -2000,14 +2000,14 @@ int ice_init_lag(struct ice_pf *pf)
53 /* associate recipes to profiles */
54 for (n = 0; n < ICE_PROFID_IPV6_GTPU_IPV6_TCP_INNER; n++) {
55 err = ice_aq_get_recipe_to_profile(&pf->hw, n,
56 - (u8 *)&recipe_bits, NULL);
57 + &recipe_bits, NULL);
58 if (err)
59 continue;
60
61 if (recipe_bits & BIT(ICE_SW_LKUP_DFLT)) {
62 recipe_bits |= BIT(lag->pf_recipe);
63 ice_aq_map_recipe_to_profile(&pf->hw, n,
64 - (u8 *)&recipe_bits, NULL);
65 + recipe_bits, NULL);
66 }
67 }
68
69 diff --git a/drivers/net/ethernet/intel/ice/ice_switch.c b/drivers/net/ethernet/intel/ice/ice_switch.c
70 index 2f77b684ff765..4c6d58bb2690d 100644
71 --- a/drivers/net/ethernet/intel/ice/ice_switch.c
72 +++ b/drivers/net/ethernet/intel/ice/ice_switch.c
73 @@ -2032,12 +2032,12 @@ ice_update_recipe_lkup_idx(struct ice_hw *hw,
74 * ice_aq_map_recipe_to_profile - Map recipe to packet profile
75 * @hw: pointer to the HW struct
76 * @profile_id: package profile ID to associate the recipe with
77 - * @r_bitmap: Recipe bitmap filled in and need to be returned as response
78 + * @r_assoc: Recipe bitmap filled in and need to be returned as response
79 * @cd: pointer to command details structure or NULL
80 * Recipe to profile association (0x0291)
81 */
82 int
83 -ice_aq_map_recipe_to_profile(struct ice_hw *hw, u32 profile_id, u8 *r_bitmap,
84 +ice_aq_map_recipe_to_profile(struct ice_hw *hw, u32 profile_id, u64 r_assoc,
85 struct ice_sq_cd *cd)
86 {
87 struct ice_aqc_recipe_to_profile *cmd;
88 @@ -2049,7 +2049,7 @@ ice_aq_map_recipe_to_profile(struct ice_hw *hw, u32 profile_id, u8 *r_bitmap,
89 /* Set the recipe ID bit in the bitmask to let the device know which
90 * profile we are associating the recipe to
91 */
92 - memcpy(cmd->recipe_assoc, r_bitmap, sizeof(cmd->recipe_assoc));
93 + cmd->recipe_assoc = cpu_to_le64(r_assoc);
94
95 return ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
96 }
97 @@ -2058,12 +2058,12 @@ ice_aq_map_recipe_to_profile(struct ice_hw *hw, u32 profile_id, u8 *r_bitmap,
98 * ice_aq_get_recipe_to_profile - Map recipe to packet profile
99 * @hw: pointer to the HW struct
100 * @profile_id: package profile ID to associate the recipe with
101 - * @r_bitmap: Recipe bitmap filled in and need to be returned as response
102 + * @r_assoc: Recipe bitmap filled in and need to be returned as response
103 * @cd: pointer to command details structure or NULL
104 * Associate profile ID with given recipe (0x0293)
105 */
106 int
107 -ice_aq_get_recipe_to_profile(struct ice_hw *hw, u32 profile_id, u8 *r_bitmap,
108 +ice_aq_get_recipe_to_profile(struct ice_hw *hw, u32 profile_id, u64 *r_assoc,
109 struct ice_sq_cd *cd)
110 {
111 struct ice_aqc_recipe_to_profile *cmd;
112 @@ -2076,7 +2076,7 @@ ice_aq_get_recipe_to_profile(struct ice_hw *hw, u32 profile_id, u8 *r_bitmap,
113
114 status = ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
115 if (!status)
116 - memcpy(r_bitmap, cmd->recipe_assoc, sizeof(cmd->recipe_assoc));
117 + *r_assoc = le64_to_cpu(cmd->recipe_assoc);
118
119 return status;
120 }
121 @@ -2121,6 +2121,7 @@ int ice_alloc_recipe(struct ice_hw *hw, u16 *rid)
122 static void ice_get_recp_to_prof_map(struct ice_hw *hw)
123 {
124 DECLARE_BITMAP(r_bitmap, ICE_MAX_NUM_RECIPES);
125 + u64 recp_assoc;
126 u16 i;
127
128 for (i = 0; i < hw->switch_info->max_used_prof_index + 1; i++) {
129 @@ -2128,8 +2129,9 @@ static void ice_get_recp_to_prof_map(struct ice_hw *hw)
130
131 bitmap_zero(profile_to_recipe[i], ICE_MAX_NUM_RECIPES);
132 bitmap_zero(r_bitmap, ICE_MAX_NUM_RECIPES);
133 - if (ice_aq_get_recipe_to_profile(hw, i, (u8 *)r_bitmap, NULL))
134 + if (ice_aq_get_recipe_to_profile(hw, i, &recp_assoc, NULL))
135 continue;
136 + bitmap_from_arr64(r_bitmap, &recp_assoc, ICE_MAX_NUM_RECIPES);
137 bitmap_copy(profile_to_recipe[i], r_bitmap,
138 ICE_MAX_NUM_RECIPES);
139 for_each_set_bit(j, r_bitmap, ICE_MAX_NUM_RECIPES)
140 @@ -5431,22 +5433,24 @@ ice_add_adv_recipe(struct ice_hw *hw, struct ice_adv_lkup_elem *lkups,
141 */
142 list_for_each_entry(fvit, &rm->fv_list, list_entry) {
143 DECLARE_BITMAP(r_bitmap, ICE_MAX_NUM_RECIPES);
144 + u64 recp_assoc;
145 u16 j;
146
147 status = ice_aq_get_recipe_to_profile(hw, fvit->profile_id,
148 - (u8 *)r_bitmap, NULL);
149 + &recp_assoc, NULL);
150 if (status)
151 goto err_unroll;
152
153 + bitmap_from_arr64(r_bitmap, &recp_assoc, ICE_MAX_NUM_RECIPES);
154 bitmap_or(r_bitmap, r_bitmap, rm->r_bitmap,
155 ICE_MAX_NUM_RECIPES);
156 status = ice_acquire_change_lock(hw, ICE_RES_WRITE);
157 if (status)
158 goto err_unroll;
159
160 + bitmap_to_arr64(&recp_assoc, r_bitmap, ICE_MAX_NUM_RECIPES);
161 status = ice_aq_map_recipe_to_profile(hw, fvit->profile_id,
162 - (u8 *)r_bitmap,
163 - NULL);
164 + recp_assoc, NULL);
165 ice_release_change_lock(hw);
166
167 if (status)
168 diff --git a/drivers/net/ethernet/intel/ice/ice_switch.h b/drivers/net/ethernet/intel/ice/ice_switch.h
169 index db7e501b7e0a4..89ffa1b51b5ad 100644
170 --- a/drivers/net/ethernet/intel/ice/ice_switch.h
171 +++ b/drivers/net/ethernet/intel/ice/ice_switch.h
172 @@ -424,10 +424,10 @@ int ice_aq_add_recipe(struct ice_hw *hw,
173 struct ice_aqc_recipe_data_elem *s_recipe_list,
174 u16 num_recipes, struct ice_sq_cd *cd);
175 int
176 -ice_aq_get_recipe_to_profile(struct ice_hw *hw, u32 profile_id, u8 *r_bitmap,
177 +ice_aq_get_recipe_to_profile(struct ice_hw *hw, u32 profile_id, u64 *r_assoc,
178 struct ice_sq_cd *cd);
179 int
180 -ice_aq_map_recipe_to_profile(struct ice_hw *hw, u32 profile_id, u8 *r_bitmap,
181 +ice_aq_map_recipe_to_profile(struct ice_hw *hw, u32 profile_id, u64 r_assoc,
182 struct ice_sq_cd *cd);
183
184 #endif /* _ICE_SWITCH_H_ */
185 --
186 2.43.0
187