Skip to content

Commit d31cd57

Browse files
Michael Chandavem330
authored andcommitted
bnxt_en: Remap TC to hardware queues when configuring PFC.
Initially, the MQPRIO TCs are mapped 1:1 directly to the hardware queues. Some of these hardware queues are configured to be lossless. When PFC is enabled on one of more TCs, we now need to remap the TCs that have PFC enabled to the lossless hardware queues. After remapping, we need to close and open the NIC for the new mapping to take effect. We also need to reprogram all ETS parameters. Signed-off-by: Michael Chan <michael.chan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 2e8ef77 commit d31cd57

File tree

1 file changed

+60
-41
lines changed

1 file changed

+60
-41
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt_dcb.c

Lines changed: 60 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -173,44 +173,59 @@ static int bnxt_hwrm_queue_cos2bw_qcfg(struct bnxt *bp, struct ieee_ets *ets)
173173
return 0;
174174
}
175175

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)
177177
{
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;
180181

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+
}
183195

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+
}
187204

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;
197211
}
198212
}
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;
209227
}
210228
}
211-
if (netif_running(bp->dev))
212-
bnxt_tx_enable(bp);
213-
214229
return 0;
215230
}
216231

@@ -220,7 +235,7 @@ static int bnxt_hwrm_queue_pfc_cfg(struct bnxt *bp, struct ieee_pfc *pfc)
220235
struct ieee_ets *my_ets = bp->ieee_ets;
221236
unsigned int tc_mask = 0, pri_mask = 0;
222237
u8 i, pri, lltc_count = 0;
223-
bool need_q_recfg = false;
238+
bool need_q_remap = false;
224239
int rc;
225240

226241
if (!my_ets)
@@ -240,21 +255,25 @@ static int bnxt_hwrm_queue_pfc_cfg(struct bnxt *bp, struct ieee_pfc *pfc)
240255
if (lltc_count > bp->max_lltc)
241256
return -EINVAL;
242257

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-
249258
for (i = 0; i < bp->max_tc; i++) {
250259
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+
}
253266
}
254267
}
255268

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;
258277

259278
return rc;
260279
}

0 commit comments

Comments
 (0)