diff mbox series

[net-next] net: lantiq_etop: add stats support

Message ID 20220315232733.134340-1-olek2@wp.pl (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: lantiq_etop: add stats support | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 4 of 4 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 16 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Aleksander Jan Bajkowski March 15, 2022, 11:27 p.m. UTC
This patch adds support for software packet and byte counters.

Signed-off-by: Aleksander Jan Bajkowski <olek2@wp.pl>
---
 drivers/net/ethernet/lantiq_etop.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Jakub Kicinski March 17, 2022, 2:28 a.m. UTC | #1
On Wed, 16 Mar 2022 00:27:33 +0100 Aleksander Jan Bajkowski wrote:
> This patch adds support for software packet and byte counters.

On a quick look this driver supports multiple queues, so bumping
per-device stats without holding locks (on the rx side) seems racy.
Plus the netdev->stats are deprecated. The "modern" way of implementing
stats is to add the appropriate members to the ring / channel structure
and implement .ndo_get_stats64()
diff mbox series

Patch

diff --git a/drivers/net/ethernet/lantiq_etop.c b/drivers/net/ethernet/lantiq_etop.c
index 9b6fa27b7daf..9841551796f2 100644
--- a/drivers/net/ethernet/lantiq_etop.c
+++ b/drivers/net/ethernet/lantiq_etop.c
@@ -145,6 +145,8 @@  ltq_etop_hw_receive(struct ltq_etop_chan *ch)
 	skb_put(skb, len);
 	skb->protocol = eth_type_trans(skb, ch->netdev);
 	netif_receive_skb(skb);
+	ch->netdev->stats.rx_packets++;
+	ch->netdev->stats.rx_bytes += len;
 }
 
 static int
@@ -182,6 +184,8 @@  ltq_etop_poll_tx(struct napi_struct *napi, int budget)
 	spin_lock_irqsave(&priv->lock, flags);
 	while ((ch->dma.desc_base[ch->tx_free].ctl &
 			(LTQ_DMA_OWN | LTQ_DMA_C)) == LTQ_DMA_C) {
+		ch->netdev->stats.tx_packets++;
+		ch->netdev->stats.tx_bytes += ch->skb[ch->tx_free]->len;
 		dev_kfree_skb_any(ch->skb[ch->tx_free]);
 		ch->skb[ch->tx_free] = NULL;
 		memset(&ch->dma.desc_base[ch->tx_free], 0,