Skip to content

Commit 2e8ef77

Browse files
Michael Chandavem330
authored andcommitted
bnxt_en: Add TC to hardware QoS queue mapping logic.
The current driver maps MQPRIO traffic classes directly 1:1 to the internal hardware queues (TC0 maps to hardware queue 0, etc). This direct mapping requires the internal hardware queues to be reconfigured from lossless to lossy and vice versa when necessary. This involves reconfiguring internal buffer thresholds which is disruptive and not always reliable. Implement a new scheme to map TCs to internal hardware queues by matching up their PFC requirements. This will eliminate the need to reconfigure a hardware queue internal buffers at run time. After remapping, the NIC is closed and opened for the new TC to hardware queues to take effect. This patch only adds the basic mapping logic. Signed-off-by: Michael Chan <michael.chan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent c347b92 commit 2e8ef77

File tree

3 files changed

+47
-24
lines changed

3 files changed

+47
-24
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2383,6 +2383,7 @@ static int bnxt_alloc_tx_rings(struct bnxt *bp)
23832383
for (i = 0, j = 0; i < bp->tx_nr_rings; i++) {
23842384
struct bnxt_tx_ring_info *txr = &bp->tx_ring[i];
23852385
struct bnxt_ring_struct *ring;
2386+
u8 qidx;
23862387

23872388
ring = &txr->tx_ring_struct;
23882389

@@ -2411,7 +2412,8 @@ static int bnxt_alloc_tx_rings(struct bnxt *bp)
24112412

24122413
memset(txr->tx_push, 0, sizeof(struct tx_push_bd));
24132414
}
2414-
ring->queue_id = bp->q_info[j].queue_id;
2415+
qidx = bp->tc_to_qidx[j];
2416+
ring->queue_id = bp->q_info[qidx].queue_id;
24152417
if (i < bp->tx_nr_rings_xdp)
24162418
continue;
24172419
if (i % bp->tx_nr_rings_per_tc == (bp->tx_nr_rings_per_tc - 1))
@@ -5309,6 +5311,7 @@ static int bnxt_hwrm_queue_qportcfg(struct bnxt *bp)
53095311
for (i = 0; i < bp->max_tc; i++) {
53105312
bp->q_info[i].queue_id = *qptr++;
53115313
bp->q_info[i].queue_profile = *qptr++;
5314+
bp->tc_to_qidx[i] = i;
53125315
}
53135316

53145317
qportcfg_exit:

drivers/net/ethernet/broadcom/bnxt/bnxt.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,6 +1242,7 @@ struct bnxt {
12421242
u8 max_tc;
12431243
u8 max_lltc; /* lossless TCs */
12441244
struct bnxt_queue_info q_info[BNXT_MAX_QUEUE];
1245+
u8 tc_to_qidx[BNXT_MAX_QUEUE];
12451246

12461247
unsigned int current_interval;
12471248
#define BNXT_TIMER_INTERVAL HZ

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

Lines changed: 42 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,21 @@
2121
#include "bnxt_dcb.h"
2222

2323
#ifdef CONFIG_BNXT_DCB
24+
static int bnxt_queue_to_tc(struct bnxt *bp, u8 queue_id)
25+
{
26+
int i, j;
27+
28+
for (i = 0; i < bp->max_tc; i++) {
29+
if (bp->q_info[i].queue_id == queue_id) {
30+
for (j = 0; j < bp->max_tc; j++) {
31+
if (bp->tc_to_qidx[j] == i)
32+
return j;
33+
}
34+
}
35+
}
36+
return -EINVAL;
37+
}
38+
2439
static int bnxt_hwrm_queue_pri2cos_cfg(struct bnxt *bp, struct ieee_ets *ets)
2540
{
2641
struct hwrm_queue_pri2cos_cfg_input req = {0};
@@ -33,10 +48,13 @@ static int bnxt_hwrm_queue_pri2cos_cfg(struct bnxt *bp, struct ieee_ets *ets)
3348

3449
pri2cos = &req.pri0_cos_queue_id;
3550
for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
51+
u8 qidx;
52+
3653
req.enables |= cpu_to_le32(
3754
QUEUE_PRI2COS_CFG_REQ_ENABLES_PRI0_COS_QUEUE_ID << i);
3855

39-
pri2cos[i] = bp->q_info[ets->prio_tc[i]].queue_id;
56+
qidx = bp->tc_to_qidx[ets->prio_tc[i]];
57+
pri2cos[i] = bp->q_info[qidx].queue_id;
4058
}
4159
rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
4260
return rc;
@@ -55,17 +73,15 @@ static int bnxt_hwrm_queue_pri2cos_qcfg(struct bnxt *bp, struct ieee_ets *ets)
5573
rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
5674
if (!rc) {
5775
u8 *pri2cos = &resp->pri0_cos_queue_id;
58-
int i, j;
76+
int i;
5977

6078
for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
6179
u8 queue_id = pri2cos[i];
80+
int tc;
6281

63-
for (j = 0; j < bp->max_tc; j++) {
64-
if (bp->q_info[j].queue_id == queue_id) {
65-
ets->prio_tc[i] = j;
66-
break;
67-
}
68-
}
82+
tc = bnxt_queue_to_tc(bp, queue_id);
83+
if (tc >= 0)
84+
ets->prio_tc[i] = tc;
6985
}
7086
}
7187
mutex_unlock(&bp->hwrm_cmd_lock);
@@ -81,13 +97,15 @@ static int bnxt_hwrm_queue_cos2bw_cfg(struct bnxt *bp, struct ieee_ets *ets,
8197
void *data;
8298

8399
bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_QUEUE_COS2BW_CFG, -1, -1);
84-
data = &req.unused_0;
85-
for (i = 0; i < max_tc; i++, data += sizeof(cos2bw) - 4) {
100+
for (i = 0; i < max_tc; i++) {
101+
u8 qidx;
102+
86103
req.enables |= cpu_to_le32(
87104
QUEUE_COS2BW_CFG_REQ_ENABLES_COS_QUEUE_ID0_VALID << i);
88105

89106
memset(&cos2bw, 0, sizeof(cos2bw));
90-
cos2bw.queue_id = bp->q_info[i].queue_id;
107+
qidx = bp->tc_to_qidx[i];
108+
cos2bw.queue_id = bp->q_info[qidx].queue_id;
91109
if (ets->tc_tsa[i] == IEEE_8021QAZ_TSA_STRICT) {
92110
cos2bw.tsa =
93111
QUEUE_COS2BW_QCFG_RESP_QUEUE_ID0_TSA_ASSIGN_SP;
@@ -103,8 +121,9 @@ static int bnxt_hwrm_queue_cos2bw_cfg(struct bnxt *bp, struct ieee_ets *ets,
103121
cpu_to_le32((ets->tc_tx_bw[i] * 100) |
104122
BW_VALUE_UNIT_PERCENT1_100);
105123
}
124+
data = &req.unused_0 + qidx * (sizeof(cos2bw) - 4);
106125
memcpy(data, &cos2bw.queue_id, sizeof(cos2bw) - 4);
107-
if (i == 0) {
126+
if (qidx == 0) {
108127
req.queue_id0 = cos2bw.queue_id;
109128
req.unused_0 = 0;
110129
}
@@ -132,22 +151,22 @@ static int bnxt_hwrm_queue_cos2bw_qcfg(struct bnxt *bp, struct ieee_ets *ets)
132151

133152
data = &resp->queue_id0 + offsetof(struct bnxt_cos2bw_cfg, queue_id);
134153
for (i = 0; i < bp->max_tc; i++, data += sizeof(cos2bw) - 4) {
135-
int j;
154+
int tc;
136155

137156
memcpy(&cos2bw.queue_id, data, sizeof(cos2bw) - 4);
138157
if (i == 0)
139158
cos2bw.queue_id = resp->queue_id0;
140159

141-
for (j = 0; j < bp->max_tc; j++) {
142-
if (bp->q_info[j].queue_id != cos2bw.queue_id)
143-
continue;
144-
if (cos2bw.tsa ==
145-
QUEUE_COS2BW_QCFG_RESP_QUEUE_ID0_TSA_ASSIGN_SP) {
146-
ets->tc_tsa[j] = IEEE_8021QAZ_TSA_STRICT;
147-
} else {
148-
ets->tc_tsa[j] = IEEE_8021QAZ_TSA_ETS;
149-
ets->tc_tx_bw[j] = cos2bw.bw_weight;
150-
}
160+
tc = bnxt_queue_to_tc(bp, cos2bw.queue_id);
161+
if (tc < 0)
162+
continue;
163+
164+
if (cos2bw.tsa ==
165+
QUEUE_COS2BW_QCFG_RESP_QUEUE_ID0_TSA_ASSIGN_SP) {
166+
ets->tc_tsa[tc] = IEEE_8021QAZ_TSA_STRICT;
167+
} else {
168+
ets->tc_tsa[tc] = IEEE_8021QAZ_TSA_ETS;
169+
ets->tc_tx_bw[tc] = cos2bw.bw_weight;
151170
}
152171
}
153172
mutex_unlock(&bp->hwrm_cmd_lock);

0 commit comments

Comments
 (0)