diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c index a94d2dec946f..807e71150222 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c @@ -1406,6 +1406,19 @@ static int am65_cpsw_nuss_tx_compl_packets(struct am65_cpsw_common *common, netdev_tx_completed_queue(netif_txq, num_tx, total_bytes); + atomic64_add(total_bytes, &tx_chn->debug_bytes_completed); + atomic64_inc(&tx_chn->debug_packets_completed); + pr_debug("TX_COMPL: completed %u bytes, total_completed=%lld, dql_avail=%d\n", + total_bytes, atomic64_read(&tx_chn->debug_bytes_completed), + dql_avail(&netif_txq->dql)); + + // Check for imbalance + if (atomic64_read(&tx_chn->debug_bytes_completed) > + atomic64_read(&tx_chn->debug_bytes_queued)) { + pr_err("BQL MISMATCH: completed more than queued!\n"); + WARN_ON(1); + } + am65_cpsw_nuss_tx_wake(tx_chn, ndev, netif_txq); } @@ -1656,6 +1669,12 @@ static netdev_tx_t am65_cpsw_nuss_ndo_slave_xmit(struct sk_buff *skb, /* report bql before sending packet */ netdev_tx_sent_queue(netif_txq, pkt_len); + atomic64_add(pkt_len, &tx_chn->debug_bytes_queued); + atomic64_inc(&tx_chn->debug_packets_queued); + pr_debug("TX[%d]: queued pkt_len=%u, total_queued=%lld, dql_avail=%d\n", tx_chn->id, + pkt_len, atomic64_read(&tx_chn->debug_bytes_queued), + dql_avail(&netif_txq->dql)); + cppi5_hdesc_set_pktlen(first_desc, pkt_len); desc_dma = k3_cppi_desc_pool_virt2dma(tx_chn->desc_pool, first_desc); if (AM65_CPSW_IS_CPSW2G(common)) { diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.h b/drivers/net/ethernet/ti/am65-cpsw-nuss.h index 3948a59ad99c..2b4ad230931f 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.h +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.h @@ -94,6 +94,11 @@ struct am65_cpsw_tx_chn { unsigned char dsize_log2; char tx_chn_name[128]; u32 rate_mbps; + atomic64_t debug_bytes_queued; + atomic64_t debug_bytes_completed; + atomic64_t debug_packets_queued; + atomic64_t debug_packets_completed; + spinlock_t debug_lock; }; struct am65_cpsw_rx_chn {