Skip to content

Commit 74840b8

Browse files
Sunil Gouthamdavem330
authored andcommitted
net: thunderx: Wakeup TXQ only if CQE_TX are processed
Previously TXQ is wakedup whenever napi is executed and irrespective of if any CQE_TX are processed or not. Added 'txq_stop' and 'txq_wake' counters to aid in debugging if there are any future issues. Signed-off-by: Sunil Goutham <[email protected]> Signed-off-by: Aleksey Makarov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f8ce966 commit 74840b8

File tree

3 files changed

+31
-15
lines changed

3 files changed

+31
-15
lines changed

drivers/net/ethernet/cavium/thunder/nic.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,9 @@ struct nicvf_drv_stats {
216216
/* Tx */
217217
u64 tx_frames_ok;
218218
u64 tx_drops;
219-
u64 tx_busy;
220219
u64 tx_tso;
220+
u64 txq_stop;
221+
u64 txq_wake;
221222
};
222223

223224
struct nicvf {

drivers/net/ethernet/cavium/thunder/nicvf_ethtool.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,10 @@ static const struct nicvf_stat nicvf_drv_stats[] = {
6666
NICVF_DRV_STAT(rx_frames_jumbo),
6767
NICVF_DRV_STAT(rx_drops),
6868
NICVF_DRV_STAT(tx_frames_ok),
69-
NICVF_DRV_STAT(tx_busy),
7069
NICVF_DRV_STAT(tx_tso),
7170
NICVF_DRV_STAT(tx_drops),
71+
NICVF_DRV_STAT(txq_stop),
72+
NICVF_DRV_STAT(txq_wake),
7273
};
7374

7475
static const struct nicvf_stat nicvf_queue_stats[] = {

drivers/net/ethernet/cavium/thunder/nicvf_main.c

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -477,12 +477,13 @@ static void nicvf_rcv_pkt_handler(struct net_device *netdev,
477477
static int nicvf_cq_intr_handler(struct net_device *netdev, u8 cq_idx,
478478
struct napi_struct *napi, int budget)
479479
{
480-
int processed_cqe, work_done = 0;
480+
int processed_cqe, work_done = 0, tx_done = 0;
481481
int cqe_count, cqe_head;
482482
struct nicvf *nic = netdev_priv(netdev);
483483
struct queue_set *qs = nic->qs;
484484
struct cmp_queue *cq = &qs->cq[cq_idx];
485485
struct cqe_rx_t *cq_desc;
486+
struct netdev_queue *txq;
486487

487488
spin_lock_bh(&cq->lock);
488489
loop:
@@ -497,8 +498,8 @@ static int nicvf_cq_intr_handler(struct net_device *netdev, u8 cq_idx,
497498
cqe_head = nicvf_queue_reg_read(nic, NIC_QSET_CQ_0_7_HEAD, cq_idx) >> 9;
498499
cqe_head &= 0xFFFF;
499500

500-
netdev_dbg(nic->netdev, "%s cqe_count %d cqe_head %d\n",
501-
__func__, cqe_count, cqe_head);
501+
netdev_dbg(nic->netdev, "%s CQ%d cqe_count %d cqe_head %d\n",
502+
__func__, cq_idx, cqe_count, cqe_head);
502503
while (processed_cqe < cqe_count) {
503504
/* Get the CQ descriptor */
504505
cq_desc = (struct cqe_rx_t *)GET_CQ_DESC(cq, cqe_head);
@@ -512,8 +513,8 @@ static int nicvf_cq_intr_handler(struct net_device *netdev, u8 cq_idx,
512513
break;
513514
}
514515

515-
netdev_dbg(nic->netdev, "cq_desc->cqe_type %d\n",
516-
cq_desc->cqe_type);
516+
netdev_dbg(nic->netdev, "CQ%d cq_desc->cqe_type %d\n",
517+
cq_idx, cq_desc->cqe_type);
517518
switch (cq_desc->cqe_type) {
518519
case CQE_TYPE_RX:
519520
nicvf_rcv_pkt_handler(netdev, napi, cq,
@@ -523,6 +524,7 @@ static int nicvf_cq_intr_handler(struct net_device *netdev, u8 cq_idx,
523524
case CQE_TYPE_SEND:
524525
nicvf_snd_pkt_handler(netdev, cq,
525526
(void *)cq_desc, CQE_TYPE_SEND);
527+
tx_done++;
526528
break;
527529
case CQE_TYPE_INVALID:
528530
case CQE_TYPE_RX_SPLIT:
@@ -533,8 +535,9 @@ static int nicvf_cq_intr_handler(struct net_device *netdev, u8 cq_idx,
533535
}
534536
processed_cqe++;
535537
}
536-
netdev_dbg(nic->netdev, "%s processed_cqe %d work_done %d budget %d\n",
537-
__func__, processed_cqe, work_done, budget);
538+
netdev_dbg(nic->netdev,
539+
"%s CQ%d processed_cqe %d work_done %d budget %d\n",
540+
__func__, cq_idx, processed_cqe, work_done, budget);
538541

539542
/* Ring doorbell to inform H/W to reuse processed CQEs */
540543
nicvf_queue_reg_write(nic, NIC_QSET_CQ_0_7_DOOR,
@@ -544,6 +547,19 @@ static int nicvf_cq_intr_handler(struct net_device *netdev, u8 cq_idx,
544547
goto loop;
545548

546549
done:
550+
/* Wakeup TXQ if its stopped earlier due to SQ full */
551+
if (tx_done) {
552+
txq = netdev_get_tx_queue(netdev, cq_idx);
553+
if (netif_tx_queue_stopped(txq)) {
554+
netif_tx_wake_queue(txq);
555+
nic->drv_stats.txq_wake++;
556+
if (netif_msg_tx_err(nic))
557+
netdev_warn(netdev,
558+
"%s: Transmit queue wakeup SQ%d\n",
559+
netdev->name, cq_idx);
560+
}
561+
}
562+
547563
spin_unlock_bh(&cq->lock);
548564
return work_done;
549565
}
@@ -555,15 +571,10 @@ static int nicvf_poll(struct napi_struct *napi, int budget)
555571
struct net_device *netdev = napi->dev;
556572
struct nicvf *nic = netdev_priv(netdev);
557573
struct nicvf_cq_poll *cq;
558-
struct netdev_queue *txq;
559574

560575
cq = container_of(napi, struct nicvf_cq_poll, napi);
561576
work_done = nicvf_cq_intr_handler(netdev, cq->cq_idx, napi, budget);
562577

563-
txq = netdev_get_tx_queue(netdev, cq->cq_idx);
564-
if (netif_tx_queue_stopped(txq))
565-
netif_tx_wake_queue(txq);
566-
567578
if (work_done < budget) {
568579
/* Slow packet rate, exit polling */
569580
napi_complete(napi);
@@ -836,7 +847,7 @@ static netdev_tx_t nicvf_xmit(struct sk_buff *skb, struct net_device *netdev)
836847

837848
if (!nicvf_sq_append_skb(nic, skb) && !netif_tx_queue_stopped(txq)) {
838849
netif_tx_stop_queue(txq);
839-
nic->drv_stats.tx_busy++;
850+
nic->drv_stats.txq_stop++;
840851
if (netif_msg_tx_err(nic))
841852
netdev_warn(netdev,
842853
"%s: Transmit ring full, stopping SQ%d\n",
@@ -989,6 +1000,9 @@ int nicvf_open(struct net_device *netdev)
9891000
for (qidx = 0; qidx < qs->rbdr_cnt; qidx++)
9901001
nicvf_enable_intr(nic, NICVF_INTR_RBDR, qidx);
9911002

1003+
nic->drv_stats.txq_stop = 0;
1004+
nic->drv_stats.txq_wake = 0;
1005+
9921006
netif_carrier_on(netdev);
9931007
netif_tx_start_all_queues(netdev);
9941008

0 commit comments

Comments
 (0)