Skip to content

Commit 5e7baf0

Browse files
Manish Chopradavem330
authored andcommitted
qed/qede: Multi CoS support.
This patch adds support for tc mqprio offload, using this different traffic classes on the adapter can be utilized based on configured priority to tc map. For example - tc qdisc add dev eth0 root mqprio num_tc 4 map 0 1 2 3 This will cause SKBs with priority 0,1,2,3 to transmit over tc 0,1,2,3 hardware queues respectively. Signed-off-by: Manish Chopra <manish.chopra@cavium.com> Signed-off-by: Ariel Elior <ariel.elior@cavium.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 2eee32a commit 5e7baf0

7 files changed

Lines changed: 200 additions & 49 deletions

File tree

‎drivers/net/ethernet/qlogic/qed/qed_l2.c‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2188,16 +2188,17 @@ int qed_get_queue_coalesce(struct qed_hwfn *p_hwfn, u16 *p_coal, void *handle)
21882188
static int qed_fill_eth_dev_info(struct qed_dev *cdev,
21892189
struct qed_dev_eth_info *info)
21902190
{
2191+
struct qed_hwfn *p_hwfn = QED_LEADING_HWFN(cdev);
21912192
int i;
21922193

21932194
memset(info, 0, sizeof(*info));
21942195

2195-
info->num_tc = 1;
2196-
21972196
if (IS_PF(cdev)) {
21982197
int max_vf_vlan_filters = 0;
21992198
int max_vf_mac_filters = 0;
22002199

2200+
info->num_tc = p_hwfn->hw_info.num_hw_tc;
2201+
22012202
if (cdev->int_params.out.int_mode == QED_INT_MODE_MSIX) {
22022203
u16 num_queues = 0;
22032204

@@ -2248,6 +2249,8 @@ static int qed_fill_eth_dev_info(struct qed_dev *cdev,
22482249
} else {
22492250
u16 total_cids = 0;
22502251

2252+
info->num_tc = 1;
2253+
22512254
/* Determine queues & XDP support */
22522255
for_each_hwfn(cdev, i) {
22532256
struct qed_hwfn *p_hwfn = &cdev->hwfns[i];
@@ -2554,7 +2557,7 @@ static int qed_start_txq(struct qed_dev *cdev,
25542557

25552558
rc = qed_eth_tx_queue_start(p_hwfn,
25562559
p_hwfn->hw_info.opaque_fid,
2557-
p_params, 0,
2560+
p_params, p_params->tc,
25582561
pbl_addr, pbl_size, ret_params);
25592562

25602563
if (rc) {

‎drivers/net/ethernet/qlogic/qed/qed_main.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -948,13 +948,14 @@ static void qed_update_pf_params(struct qed_dev *cdev,
948948
params->eth_pf_params.num_arfs_filters = 0;
949949

950950
/* In case we might support RDMA, don't allow qede to be greedy
951-
* with the L2 contexts. Allow for 64 queues [rx, tx, xdp] per hwfn.
951+
* with the L2 contexts. Allow for 64 queues [rx, tx cos, xdp]
952+
* per hwfn.
952953
*/
953954
if (QED_IS_RDMA_PERSONALITY(QED_LEADING_HWFN(cdev))) {
954955
u16 *num_cons;
955956

956957
num_cons = &params->eth_pf_params.num_cons;
957-
*num_cons = min_t(u16, *num_cons, 192);
958+
*num_cons = min_t(u16, *num_cons, QED_MAX_L2_CONS);
958959
}
959960

960961
for (i = 0; i < cdev->num_hwfns; i++) {

‎drivers/net/ethernet/qlogic/qede/qede.h‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,15 @@ struct qede_tx_queue {
386386
#define QEDE_TXQ_XDP_TO_IDX(edev, txq) ((txq)->index - \
387387
QEDE_MAX_TSS_CNT(edev))
388388
#define QEDE_TXQ_IDX_TO_XDP(edev, idx) ((idx) + QEDE_MAX_TSS_CNT(edev))
389+
#define QEDE_NDEV_TXQ_ID_TO_FP_ID(edev, idx) ((edev)->fp_num_rx + \
390+
((idx) % QEDE_TSS_COUNT(edev)))
391+
#define QEDE_NDEV_TXQ_ID_TO_TXQ_COS(edev, idx) ((idx) / QEDE_TSS_COUNT(edev))
392+
#define QEDE_TXQ_TO_NDEV_TXQ_ID(edev, txq) ((QEDE_TSS_COUNT(edev) * \
393+
(txq)->cos) + (txq)->index)
394+
#define QEDE_NDEV_TXQ_ID_TO_TXQ(edev, idx) \
395+
(&((edev)->fp_array[QEDE_NDEV_TXQ_ID_TO_FP_ID(edev, idx)].txq \
396+
[QEDE_NDEV_TXQ_ID_TO_TXQ_COS(edev, idx)]))
397+
#define QEDE_FP_TC0_TXQ(fp) (&((fp)->txq[0]))
389398

390399
/* Regular Tx requires skb + metadata for release purpose,
391400
* while XDP requires the pages and the mapped address.
@@ -399,6 +408,8 @@ struct qede_tx_queue {
399408

400409
/* Slowpath; Should be kept in end [unless missing padding] */
401410
void *handle;
411+
u16 cos;
412+
u16 ndev_txq_id;
402413
};
403414

404415
#define BD_UNMAP_ADDR(bd) HILO_U64(le32_to_cpu((bd)->addr.hi), \
@@ -541,5 +552,7 @@ void qede_update_rx_prod(struct qede_dev *edev, struct qede_rx_queue *rxq);
541552
#define QEDE_RX_HDR_SIZE 256
542553
#define QEDE_MAX_JUMBO_PACKET_SIZE 9600
543554
#define for_each_queue(i) for (i = 0; i < edev->num_queues; i++)
555+
#define for_each_cos_in_txq(edev, var) \
556+
for ((var) = 0; (var) < (edev)->dev_info.num_tc; (var)++)
544557

545558
#endif /* _QEDE_H_ */

‎drivers/net/ethernet/qlogic/qede/qede_ethtool.c‎

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ static void qede_get_strings_stats_txq(struct qede_dev *edev,
222222
QEDE_TXQ_XDP_TO_IDX(edev, txq),
223223
qede_tqstats_arr[i].string);
224224
else
225-
sprintf(*buf, "%d: %s", txq->index,
225+
sprintf(*buf, "%d_%d: %s", txq->index, txq->cos,
226226
qede_tqstats_arr[i].string);
227227
*buf += ETH_GSTRING_LEN;
228228
}
@@ -262,8 +262,13 @@ static void qede_get_strings_stats(struct qede_dev *edev, u8 *buf)
262262
if (fp->type & QEDE_FASTPATH_XDP)
263263
qede_get_strings_stats_txq(edev, fp->xdp_tx, &buf);
264264

265-
if (fp->type & QEDE_FASTPATH_TX)
266-
qede_get_strings_stats_txq(edev, fp->txq, &buf);
265+
if (fp->type & QEDE_FASTPATH_TX) {
266+
int cos;
267+
268+
for_each_cos_in_txq(edev, cos)
269+
qede_get_strings_stats_txq(edev,
270+
&fp->txq[cos], &buf);
271+
}
267272
}
268273

269274
/* Account for non-queue statistics */
@@ -338,8 +343,12 @@ static void qede_get_ethtool_stats(struct net_device *dev,
338343
if (fp->type & QEDE_FASTPATH_XDP)
339344
qede_get_ethtool_stats_txq(fp->xdp_tx, &buf);
340345

341-
if (fp->type & QEDE_FASTPATH_TX)
342-
qede_get_ethtool_stats_txq(fp->txq, &buf);
346+
if (fp->type & QEDE_FASTPATH_TX) {
347+
int cos;
348+
349+
for_each_cos_in_txq(edev, cos)
350+
qede_get_ethtool_stats_txq(&fp->txq[cos], &buf);
351+
}
343352
}
344353

345354
for (i = 0; i < QEDE_NUM_STATS; i++) {
@@ -366,7 +375,8 @@ static int qede_get_sset_count(struct net_device *dev, int stringset)
366375
num_stats--;
367376

368377
/* Account for the Regular Tx statistics */
369-
num_stats += QEDE_TSS_COUNT(edev) * QEDE_NUM_TQSTATS;
378+
num_stats += QEDE_TSS_COUNT(edev) * QEDE_NUM_TQSTATS *
379+
edev->dev_info.num_tc;
370380

371381
/* Account for the Regular Rx statistics */
372382
num_stats += QEDE_RSS_COUNT(edev) * QEDE_NUM_RQSTATS;
@@ -741,9 +751,17 @@ static int qede_get_coalesce(struct net_device *dev,
741751
}
742752

743753
for_each_queue(i) {
754+
struct qede_tx_queue *txq;
755+
744756
fp = &edev->fp_array[i];
757+
758+
/* All TX queues of given fastpath uses same
759+
* coalescing value, so no need to iterate over
760+
* all TCs, TC0 txq should suffice.
761+
*/
745762
if (fp->type & QEDE_FASTPATH_TX) {
746-
tx_handle = fp->txq->handle;
763+
txq = QEDE_FP_TC0_TXQ(fp);
764+
tx_handle = txq->handle;
747765
break;
748766
}
749767
}
@@ -801,9 +819,17 @@ static int qede_set_coalesce(struct net_device *dev,
801819
}
802820

803821
if (edev->fp_array[i].type & QEDE_FASTPATH_TX) {
822+
struct qede_tx_queue *txq;
823+
824+
/* All TX queues of given fastpath uses same
825+
* coalescing value, so no need to iterate over
826+
* all TCs, TC0 txq should suffice.
827+
*/
828+
txq = QEDE_FP_TC0_TXQ(fp);
829+
804830
rc = edev->ops->common->set_coalesce(edev->cdev,
805831
0, txc,
806-
fp->txq->handle);
832+
txq->handle);
807833
if (rc) {
808834
DP_INFO(edev,
809835
"Set TX coalesce error, rc = %d\n", rc);
@@ -1385,8 +1411,10 @@ static int qede_selftest_transmit_traffic(struct qede_dev *edev,
13851411
u16 val;
13861412

13871413
for_each_queue(i) {
1388-
if (edev->fp_array[i].type & QEDE_FASTPATH_TX) {
1389-
txq = edev->fp_array[i].txq;
1414+
struct qede_fastpath *fp = &edev->fp_array[i];
1415+
1416+
if (fp->type & QEDE_FASTPATH_TX) {
1417+
txq = QEDE_FP_TC0_TXQ(fp);
13901418
break;
13911419
}
13921420
}

‎drivers/net/ethernet/qlogic/qede/qede_fp.c‎

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -408,12 +408,12 @@ static void qede_xdp_tx_int(struct qede_dev *edev, struct qede_tx_queue *txq)
408408

409409
static int qede_tx_int(struct qede_dev *edev, struct qede_tx_queue *txq)
410410
{
411+
unsigned int pkts_compl = 0, bytes_compl = 0;
411412
struct netdev_queue *netdev_txq;
412413
u16 hw_bd_cons;
413-
unsigned int pkts_compl = 0, bytes_compl = 0;
414414
int rc;
415415

416-
netdev_txq = netdev_get_tx_queue(edev->ndev, txq->index);
416+
netdev_txq = netdev_get_tx_queue(edev->ndev, txq->ndev_txq_id);
417417

418418
hw_bd_cons = le16_to_cpu(*txq->hw_cons_ptr);
419419
barrier();
@@ -1365,9 +1365,14 @@ static bool qede_poll_is_more_work(struct qede_fastpath *fp)
13651365
if (qede_txq_has_work(fp->xdp_tx))
13661366
return true;
13671367

1368-
if (likely(fp->type & QEDE_FASTPATH_TX))
1369-
if (qede_txq_has_work(fp->txq))
1370-
return true;
1368+
if (likely(fp->type & QEDE_FASTPATH_TX)) {
1369+
int cos;
1370+
1371+
for_each_cos_in_txq(fp->edev, cos) {
1372+
if (qede_txq_has_work(&fp->txq[cos]))
1373+
return true;
1374+
}
1375+
}
13711376

13721377
return false;
13731378
}
@@ -1382,8 +1387,14 @@ int qede_poll(struct napi_struct *napi, int budget)
13821387
struct qede_dev *edev = fp->edev;
13831388
int rx_work_done = 0;
13841389

1385-
if (likely(fp->type & QEDE_FASTPATH_TX) && qede_txq_has_work(fp->txq))
1386-
qede_tx_int(edev, fp->txq);
1390+
if (likely(fp->type & QEDE_FASTPATH_TX)) {
1391+
int cos;
1392+
1393+
for_each_cos_in_txq(fp->edev, cos) {
1394+
if (qede_txq_has_work(&fp->txq[cos]))
1395+
qede_tx_int(edev, &fp->txq[cos]);
1396+
}
1397+
}
13871398

13881399
if ((fp->type & QEDE_FASTPATH_XDP) && qede_txq_has_work(fp->xdp_tx))
13891400
qede_xdp_tx_int(edev, fp->xdp_tx);
@@ -1444,8 +1455,8 @@ netdev_tx_t qede_start_xmit(struct sk_buff *skb, struct net_device *ndev)
14441455

14451456
/* Get tx-queue context and netdev index */
14461457
txq_index = skb_get_queue_mapping(skb);
1447-
WARN_ON(txq_index >= QEDE_TSS_COUNT(edev));
1448-
txq = edev->fp_array[edev->fp_num_rx + txq_index].txq;
1458+
WARN_ON(txq_index >= QEDE_TSS_COUNT(edev) * edev->dev_info.num_tc);
1459+
txq = QEDE_NDEV_TXQ_ID_TO_TXQ(edev, txq_index);
14491460
netdev_txq = netdev_get_tx_queue(ndev, txq_index);
14501461

14511462
WARN_ON(qed_chain_get_elem_left(&txq->tx_pbl) < (MAX_SKB_FRAGS + 1));

0 commit comments

Comments
 (0)