@@ -331,16 +331,16 @@ static void bnxt_sched_reset_rxr(struct bnxt *bp, struct bnxt_rx_ring_info *rxr)
331331}
332332
333333void bnxt_sched_reset_txr (struct bnxt * bp , struct bnxt_tx_ring_info * txr ,
334- int idx )
334+ u16 curr )
335335{
336336 struct bnxt_napi * bnapi = txr -> bnapi ;
337337
338338 if (bnapi -> tx_fault )
339339 return ;
340340
341- netdev_err (bp -> dev , "Invalid Tx completion (ring:%d tx_pkts:%d cons:%u prod:%u i:%d )" ,
342- txr -> txq_index , bnapi -> tx_pkts ,
343- txr -> tx_cons , txr -> tx_prod , idx );
341+ netdev_err (bp -> dev , "Invalid Tx completion (ring:%d tx_hw_cons:%u cons:%u prod:%u curr:%u )" ,
342+ txr -> txq_index , txr -> tx_hw_cons ,
343+ txr -> tx_cons , txr -> tx_prod , curr );
344344 WARN_ON_ONCE (1 );
345345 bnapi -> tx_fault = 1 ;
346346 bnxt_queue_sp_work (bp , BNXT_RESET_TASK_SP_EVENT );
@@ -691,13 +691,13 @@ static void bnxt_tx_int(struct bnxt *bp, struct bnxt_napi *bnapi, int budget)
691691{
692692 struct bnxt_tx_ring_info * txr = bnapi -> tx_ring ;
693693 struct netdev_queue * txq = netdev_get_tx_queue (bp -> dev , txr -> txq_index );
694+ u16 hw_cons = txr -> tx_hw_cons ;
694695 u16 cons = txr -> tx_cons ;
695696 struct pci_dev * pdev = bp -> pdev ;
696- int nr_pkts = bnapi -> tx_pkts ;
697- int i ;
698697 unsigned int tx_bytes = 0 ;
698+ int tx_pkts = 0 ;
699699
700- for ( i = 0 ; i < nr_pkts ; i ++ ) {
700+ while ( cons != hw_cons ) {
701701 struct bnxt_sw_tx_bd * tx_buf ;
702702 struct sk_buff * skb ;
703703 int j , last ;
@@ -708,10 +708,11 @@ static void bnxt_tx_int(struct bnxt *bp, struct bnxt_napi *bnapi, int budget)
708708 tx_buf -> skb = NULL ;
709709
710710 if (unlikely (!skb )) {
711- bnxt_sched_reset_txr (bp , txr , i );
711+ bnxt_sched_reset_txr (bp , txr , cons );
712712 return ;
713713 }
714714
715+ tx_pkts ++ ;
715716 tx_bytes += skb -> len ;
716717
717718 if (tx_buf -> is_push ) {
@@ -748,10 +749,10 @@ static void bnxt_tx_int(struct bnxt *bp, struct bnxt_napi *bnapi, int budget)
748749 dev_consume_skb_any (skb );
749750 }
750751
751- bnapi -> tx_pkts = 0 ;
752+ bnapi -> events &= ~ BNXT_TX_CMP_EVENT ;
752753 WRITE_ONCE (txr -> tx_cons , cons );
753754
754- __netif_txq_completed_wake (txq , nr_pkts , tx_bytes ,
755+ __netif_txq_completed_wake (txq , tx_pkts , tx_bytes ,
755756 bnxt_tx_avail (bp , txr ), bp -> tx_wake_thresh ,
756757 READ_ONCE (txr -> dev_state ) == BNXT_DEV_STATE_CLOSING );
757758}
@@ -2588,14 +2589,15 @@ static int __bnxt_poll_work(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
25882589{
25892590 struct bnxt_napi * bnapi = cpr -> bnapi ;
25902591 u32 raw_cons = cpr -> cp_raw_cons ;
2592+ struct bnxt_tx_ring_info * txr ;
25912593 u32 cons ;
2592- int tx_pkts = 0 ;
25932594 int rx_pkts = 0 ;
25942595 u8 event = 0 ;
25952596 struct tx_cmp * txcmp ;
25962597
25972598 cpr -> has_more_work = 0 ;
25982599 cpr -> had_work_done = 1 ;
2600+ txr = bnapi -> tx_ring ;
25992601 while (1 ) {
26002602 int rc ;
26012603
@@ -2610,9 +2612,15 @@ static int __bnxt_poll_work(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
26102612 */
26112613 dma_rmb ();
26122614 if (TX_CMP_TYPE (txcmp ) == CMP_TYPE_TX_L2_CMP ) {
2613- tx_pkts ++ ;
2615+ u32 opaque = txcmp -> tx_cmp_opaque ;
2616+ u16 tx_freed ;
2617+
2618+ event |= BNXT_TX_CMP_EVENT ;
2619+ txr -> tx_hw_cons = TX_OPAQUE_PROD (bp , opaque );
2620+ tx_freed = (txr -> tx_hw_cons - txr -> tx_cons ) &
2621+ bp -> tx_ring_mask ;
26142622 /* return full budget so NAPI will complete. */
2615- if (unlikely (tx_pkts >= bp -> tx_wake_thresh )) {
2623+ if (unlikely (tx_freed >= bp -> tx_wake_thresh )) {
26162624 rx_pkts = budget ;
26172625 raw_cons = NEXT_RAW_CMP (raw_cons );
26182626 if (budget )
@@ -2666,15 +2674,14 @@ static int __bnxt_poll_work(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
26662674 }
26672675
26682676 cpr -> cp_raw_cons = raw_cons ;
2669- bnapi -> tx_pkts += tx_pkts ;
26702677 bnapi -> events |= event ;
26712678 return rx_pkts ;
26722679}
26732680
26742681static void __bnxt_poll_work_done (struct bnxt * bp , struct bnxt_napi * bnapi ,
26752682 int budget )
26762683{
2677- if (bnapi -> tx_pkts && !bnapi -> tx_fault )
2684+ if (( bnapi -> events & BNXT_TX_CMP_EVENT ) && !bnapi -> tx_fault )
26782685 bnapi -> tx_int (bp , bnapi , budget );
26792686
26802687 if ((bnapi -> events & BNXT_RX_EVENT ) && !(bnapi -> in_reset )) {
@@ -2687,7 +2694,7 @@ static void __bnxt_poll_work_done(struct bnxt *bp, struct bnxt_napi *bnapi,
26872694
26882695 bnxt_db_write (bp , & rxr -> rx_agg_db , rxr -> rx_agg_prod );
26892696 }
2690- bnapi -> events = 0 ;
2697+ bnapi -> events &= BNXT_TX_CMP_EVENT ;
26912698}
26922699
26932700static int bnxt_poll_work (struct bnxt * bp , struct bnxt_cp_ring_info * cpr ,
@@ -4515,6 +4522,7 @@ static void bnxt_clear_ring_indices(struct bnxt *bp)
45154522 if (txr ) {
45164523 txr -> tx_prod = 0 ;
45174524 txr -> tx_cons = 0 ;
4525+ txr -> tx_hw_cons = 0 ;
45184526 }
45194527
45204528 rxr = bnapi -> rx_ring ;
@@ -4524,6 +4532,7 @@ static void bnxt_clear_ring_indices(struct bnxt *bp)
45244532 rxr -> rx_sw_agg_prod = 0 ;
45254533 rxr -> rx_next_cons = 0 ;
45264534 }
4535+ bnapi -> events = 0 ;
45274536 }
45284537}
45294538
@@ -9528,8 +9537,6 @@ static void bnxt_enable_napi(struct bnxt *bp)
95289537 cpr = & bnapi -> cp_ring ;
95299538 bnapi -> in_reset = false;
95309539
9531- bnapi -> tx_pkts = 0 ;
9532-
95339540 if (bnapi -> rx_ring ) {
95349541 INIT_WORK (& cpr -> dim .work , bnxt_dim_work );
95359542 cpr -> dim .mode = DIM_CQ_PERIOD_MODE_START_FROM_EQE ;
0 commit comments