@@ -173,44 +173,59 @@ static int bnxt_hwrm_queue_cos2bw_qcfg(struct bnxt *bp, struct ieee_ets *ets)
173
173
return 0 ;
174
174
}
175
175
176
- static int bnxt_hwrm_queue_cfg (struct bnxt * bp , unsigned int lltc_mask )
176
+ static int bnxt_queue_remap (struct bnxt * bp , unsigned int lltc_mask )
177
177
{
178
- struct hwrm_queue_cfg_input req = {0 };
179
- int i ;
178
+ unsigned long qmap = 0 ;
179
+ int max = bp -> max_tc ;
180
+ int i , j , rc ;
180
181
181
- if (netif_running (bp -> dev ))
182
- bnxt_tx_disable (bp );
182
+ /* Assign lossless TCs first */
183
+ for (i = 0 , j = 0 ; i < max ; ) {
184
+ if (lltc_mask & (1 << i )) {
185
+ if (BNXT_LLQ (bp -> q_info [j ].queue_profile )) {
186
+ bp -> tc_to_qidx [i ] = j ;
187
+ __set_bit (j , & qmap );
188
+ i ++ ;
189
+ }
190
+ j ++ ;
191
+ continue ;
192
+ }
193
+ i ++ ;
194
+ }
183
195
184
- bnxt_hwrm_cmd_hdr_init (bp , & req , HWRM_QUEUE_CFG , -1 , -1 );
185
- req .flags = cpu_to_le32 (QUEUE_CFG_REQ_FLAGS_PATH_BIDIR );
186
- req .enables = cpu_to_le32 (QUEUE_CFG_REQ_ENABLES_SERVICE_PROFILE );
196
+ for (i = 0 , j = 0 ; i < max ; i ++ ) {
197
+ if (lltc_mask & (1 << i ))
198
+ continue ;
199
+ j = find_next_zero_bit (& qmap , max , j );
200
+ bp -> tc_to_qidx [i ] = j ;
201
+ __set_bit (j , & qmap );
202
+ j ++ ;
203
+ }
187
204
188
- /* Configure lossless queues to lossy first */
189
- req .service_profile = QUEUE_CFG_REQ_SERVICE_PROFILE_LOSSY ;
190
- for (i = 0 ; i < bp -> max_tc ; i ++ ) {
191
- if (BNXT_LLQ (bp -> q_info [i ].queue_profile )) {
192
- req .queue_id = cpu_to_le32 (bp -> q_info [i ].queue_id );
193
- hwrm_send_message (bp , & req , sizeof (req ),
194
- HWRM_CMD_TIMEOUT );
195
- bp -> q_info [i ].queue_profile =
196
- QUEUE_CFG_REQ_SERVICE_PROFILE_LOSSY ;
205
+ if (netif_running (bp -> dev )) {
206
+ bnxt_close_nic (bp , false, false);
207
+ rc = bnxt_open_nic (bp , false, false);
208
+ if (rc ) {
209
+ netdev_warn (bp -> dev , "failed to open NIC, rc = %d\n" , rc );
210
+ return rc ;
197
211
}
198
212
}
199
-
200
- /* Now configure desired queues to lossless */
201
- req .service_profile = QUEUE_CFG_REQ_SERVICE_PROFILE_LOSSLESS ;
202
- for (i = 0 ; i < bp -> max_tc ; i ++ ) {
203
- if (lltc_mask & (1 << i )) {
204
- req .queue_id = cpu_to_le32 (bp -> q_info [i ].queue_id );
205
- hwrm_send_message (bp , & req , sizeof (req ),
206
- HWRM_CMD_TIMEOUT );
207
- bp -> q_info [i ].queue_profile =
208
- QUEUE_CFG_REQ_SERVICE_PROFILE_LOSSLESS ;
213
+ if (bp -> ieee_ets ) {
214
+ int tc = netdev_get_num_tc (bp -> dev );
215
+
216
+ if (!tc )
217
+ tc = 1 ;
218
+ rc = bnxt_hwrm_queue_cos2bw_cfg (bp , bp -> ieee_ets , tc );
219
+ if (rc ) {
220
+ netdev_warn (bp -> dev , "failed to config BW, rc = %d\n" , rc );
221
+ return rc ;
222
+ }
223
+ rc = bnxt_hwrm_queue_pri2cos_cfg (bp , bp -> ieee_ets );
224
+ if (rc ) {
225
+ netdev_warn (bp -> dev , "failed to config prio, rc = %d\n" , rc );
226
+ return rc ;
209
227
}
210
228
}
211
- if (netif_running (bp -> dev ))
212
- bnxt_tx_enable (bp );
213
-
214
229
return 0 ;
215
230
}
216
231
@@ -220,7 +235,7 @@ static int bnxt_hwrm_queue_pfc_cfg(struct bnxt *bp, struct ieee_pfc *pfc)
220
235
struct ieee_ets * my_ets = bp -> ieee_ets ;
221
236
unsigned int tc_mask = 0 , pri_mask = 0 ;
222
237
u8 i , pri , lltc_count = 0 ;
223
- bool need_q_recfg = false;
238
+ bool need_q_remap = false;
224
239
int rc ;
225
240
226
241
if (!my_ets )
@@ -240,21 +255,25 @@ static int bnxt_hwrm_queue_pfc_cfg(struct bnxt *bp, struct ieee_pfc *pfc)
240
255
if (lltc_count > bp -> max_lltc )
241
256
return - EINVAL ;
242
257
243
- bnxt_hwrm_cmd_hdr_init (bp , & req , HWRM_QUEUE_PFCENABLE_CFG , -1 , -1 );
244
- req .flags = cpu_to_le32 (pri_mask );
245
- rc = hwrm_send_message (bp , & req , sizeof (req ), HWRM_CMD_TIMEOUT );
246
- if (rc )
247
- return rc ;
248
-
249
258
for (i = 0 ; i < bp -> max_tc ; i ++ ) {
250
259
if (tc_mask & (1 << i )) {
251
- if (!BNXT_LLQ (bp -> q_info [i ].queue_profile ))
252
- need_q_recfg = true;
260
+ u8 qidx = bp -> tc_to_qidx [i ];
261
+
262
+ if (!BNXT_LLQ (bp -> q_info [qidx ].queue_profile )) {
263
+ need_q_remap = true;
264
+ break ;
265
+ }
253
266
}
254
267
}
255
268
256
- if (need_q_recfg )
257
- rc = bnxt_hwrm_queue_cfg (bp , tc_mask );
269
+ if (need_q_remap )
270
+ rc = bnxt_queue_remap (bp , tc_mask );
271
+
272
+ bnxt_hwrm_cmd_hdr_init (bp , & req , HWRM_QUEUE_PFCENABLE_CFG , -1 , -1 );
273
+ req .flags = cpu_to_le32 (pri_mask );
274
+ rc = hwrm_send_message (bp , & req , sizeof (req ), HWRM_CMD_TIMEOUT );
275
+ if (rc )
276
+ return rc ;
258
277
259
278
return rc ;
260
279
}
0 commit comments