eth: fbnic: report software queue stats
Subsystems (3)
Jakub Kicinski
maintainercover eth: fbnic: report software queue stats
Fill in typical software queue stats.
# ./pyynl/cli.py --spec netlink/specs/netdev.yaml --dump qstats-get
[{'ifindex': 2,
'rx-alloc-fail': 0,
'rx-bytes': 398064076,
'rx-csum-complete': 271,
'rx-csum-none': 0,
'rx-packets': 276044,
'tx-bytes': 7223770,
'tx-needs-csum': 28148,
'tx-packets': 28449,
'tx-stop': 0,
'tx-wake': 0}]Note that we don't collect csum-unnecessary, just the uncommon cases (and unnecessary is all the rest of the packets). There is no programatic use for these stats AFAIK, just manual debug.
Jakub Kicinski (5):
net: report csum_complete via qstats
eth: fbnic: wrap tx queue stats in a struct
eth: fbnic: report software Rx queue stats
eth: fbnic: report software Tx queue stats
eth: fbnic: re-sort the objects in the Makefile
drivers/net/ethernet/meta/fbnic/Makefile | 3 +- drivers/net/ethernet/meta/fbnic/fbnic_txrx.h | 16 +++- include/net/netdev_queues.h | 1 + .../net/ethernet/meta/fbnic/fbnic_ethtool.c | 8 +- .../net/ethernet/meta/fbnic/fbnic_netdev.c | 22 +++++- drivers/net/ethernet/meta/fbnic/fbnic_txrx.c | 74 +++++++++++++++---- net/core/netdev-genl.c | 1 + 7 files changed, 102 insertions(+), 23 deletions(-)
Signature · 1 line
2.48.1
Jakub Kicinski
maintainerPATCH 1/5 net: report csum_complete via qstats
Commit 13c7c941e729 ("netdev: add qstat for csum complete") reserved the entry for csum complete in the qstats uAPI. Start reporting this value now that we have a driver which needs it.
---
CC: [email protected]
--- include/net/netdev_queues.h | 1 + net/core/netdev-genl.c | 1 + 2 files changed, 2 insertions(+)
include/net/netdev_queues.h +1 -0
@@ -23,6 +23,7 @@ struct netdev_queue_stats_rx {u64 hw_drops;u64 hw_drop_overruns; +u64 csum_complete;u64 csum_unnecessary;u64 csum_none;u64 csum_bad;
net/core/netdev-genl.c +1 -0
@@ -581,6 +581,7 @@ netdev_nl_stats_write_rx(struct sk_buff *rsp, struct netdev_queue_stats_rx *rx)netdev_stat_put (rsp,NETDEV_A_QSTATS_RX_ALLOC_FAIL , rx->alloc_fail) ||netdev_stat_put (rsp,NETDEV_A_QSTATS_RX_HW_DROPS , rx->hw_drops) ||netdev_stat_put (rsp,NETDEV_A_QSTATS_RX_HW_DROP_OVERRUNS , rx->hw_drop_overruns) || +netdev_stat_put (rsp,NETDEV_A_QSTATS_RX_CSUM_COMPLETE , rx->csum_complete) ||netdev_stat_put (rsp,NETDEV_A_QSTATS_RX_CSUM_UNNECESSARY , rx->csum_unnecessary) ||netdev_stat_put (rsp,NETDEV_A_QSTATS_RX_CSUM_NONE , rx->csum_none) || netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_CSUM_BAD, rx->csum_bad) ||
Signature · 1 line
2.48.1
Re: [PATCH net-next 1/5] net: report csum_complete via qstats
Quoted 29 lines · Jakub Kicinski
Commit
13c7c941e729("netdev: add qstat for csum complete") reserved the entry for csum complete in the qstats uAPI. Start reporting this value now that we have a driver which needs it.Signed-off-by Jakub Kicinski <[email protected]>---
CC: [email protected]--- include/net/netdev_queues.h | 1 + net/core/netdev-genl.c | 1 + 2 files changed, 2 insertions(+)include/net/netdev_queues.h +1
-0@@ -23,6 +23,7 @@ struct netdev_queue_stats_rx {u64 hw_drops;u64 hw_drop_overruns; +u64 csum_complete;u64 csum_unnecessary;u64 csum_none;u64 csum_bad;net/core/netdev-genl.c +0
-0
net/core/netdev-genl.c netdev_nl_stats_write_rx(struct sk_buff *rsp, struct netdev_queue_stats_rx *rx) · line 587
Quoted 7 lines
net/core/netdev-genl.c +1
-0@@ -581,6 +581,7 @@ netdev_nl_stats_write_rx(struct sk_buff *rsp, struct netdev_queue_stats_rx *rx)netdev_stat_put (rsp,NETDEV_A_QSTATS_RX_ALLOC_FAIL , rx->alloc_fail) ||netdev_stat_put (rsp,NETDEV_A_QSTATS_RX_HW_DROPS , rx->hw_drops) ||netdev_stat_put (rsp,NETDEV_A_QSTATS_RX_HW_DROP_OVERRUNS , rx->hw_drop_overruns) || +netdev_stat_put (rsp,NETDEV_A_QSTATS_RX_CSUM_COMPLETE , rx->csum_complete) ||netdev_stat_put (rsp,NETDEV_A_QSTATS_RX_CSUM_UNNECESSARY , rx->csum_unnecessary) ||netdev_stat_put (rsp,NETDEV_A_QSTATS_RX_CSUM_NONE , rx->csum_none) || netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_CSUM_BAD, rx->csum_bad) ||
Jakub Kicinski
maintainerPATCH 2/5 eth: fbnic: wrap tx queue stats in a struct
In reply to Jakub KicinskiThe queue stats struct is used for Rx and Tx queues. Wrap the Tx stats in a struct and a union, so that we can reuse the same space for Rx stats on Rx queues.
This also makes it easy to add an assert to the stat handling code to catch new stats not being aggregated on shutdown.
--- drivers/net/ethernet/meta/fbnic/fbnic_txrx.h | 8 ++++++-- drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c | 8 ++++---- drivers/net/ethernet/meta/fbnic/fbnic_txrx.c | 10 ++++++---- 3 files changed, 16 insertions(+), 10 deletions(-)
drivers/net/ethernet/meta/fbnic/fbnic_txrx.h +6 -2
@@ -57,8 +57,12 @@ struct fbnic_queue_stats {u64 packets;u64 bytes;u64 dropped; -u64 ts_packets; -u64 ts_lost; +union { +struct { +u64 ts_packets; +u64 ts_lost; + } twq; + };struct u64_stats_sync syncp; };
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c +4 -4
@@ -1224,14 +1224,14 @@ static void fbnic_get_ts_stats(struct net_device *netdev,unsigned int start;int i; - ts_stats->pkts = fbn->tx_stats.ts_packets; - ts_stats->lost = fbn->tx_stats.ts_lost; + ts_stats->pkts = fbn->tx_stats.twq.ts_packets; + ts_stats->lost = fbn->tx_stats.twq.ts_lost;for (i =0 ; i < fbn->num_tx_queues; i++) { ring = fbn->tx[i];do { start =u64_stats_fetch_begin (&ring->stats.syncp); - ts_packets = ring->stats.ts_packets; - ts_lost = ring->stats.ts_lost; + ts_packets = ring->stats.twq.ts_packets; + ts_lost = ring->stats.twq.ts_lost; }while (u64_stats_fetch_retry (&ring->stats.syncp, start)); ts_stats->pkts += ts_packets; ts_stats->lost += ts_lost;
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c +6 -4
@@ -444,7 +444,7 @@ static void fbnic_clean_twq0(struct fbnic_napi_vector *nv, int napi_budget,if (unlikely (discard)) {u64_stats_update_begin (&ring->stats.syncp); ring->stats.dropped += total_packets; - ring->stats.ts_lost += ts_lost; + ring->stats.twq.ts_lost += ts_lost;u64_stats_update_end (&ring->stats.syncp);netdev_tx_completed_queue (txq, total_packets, total_bytes);
@@ -507,7 +507,7 @@ static void fbnic_clean_tsq(struct fbnic_napi_vector *nv,skb_tstamp_tx (skb, &hwtstamp);u64_stats_update_begin (&ring->stats.syncp); - ring->stats.ts_packets++; + ring->stats.twq.ts_packets++;u64_stats_update_end (&ring->stats.syncp); }
@@ -1065,8 +1065,10 @@ void fbnic_aggregate_ring_tx_counters(struct fbnic_net *fbn, fbn->tx_stats.bytes += stats->bytes; fbn->tx_stats.packets += stats->packets; fbn->tx_stats.dropped += stats->dropped; - fbn->tx_stats.ts_lost += stats->ts_lost; - fbn->tx_stats.ts_packets += stats->ts_packets; + fbn->tx_stats.twq.ts_lost += stats->twq.ts_lost; + fbn->tx_stats.twq.ts_packets += stats->twq.ts_packets; +/* Remember to add new stats here */ +BUILD_BUG_ON (sizeof (fbn->tx_stats.twq) /8 !=2 ); } static void fbnic_remove_tx_ring(struct fbnic_net *fbn,
Signature · 1 line
2.48.1
Re: [PATCH net-next 2/5] eth: fbnic: wrap tx queue stats in a struct
Quoted 7 lines · Jakub Kicinski
The queue stats struct is used for Rx and Tx queues. Wrap the Tx stats in a struct and a union, so that we can reuse the same space for Rx stats on Rx queues.
This also makes it easy to add an assert to the stat handling code to catch new stats not being aggregated on shutdown.
Quoted 6 lines
Signed-off-by Jakub Kicinski <[email protected]>--- drivers/net/ethernet/meta/fbnic/fbnic_txrx.h | 8 ++++++-- drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c | 8 ++++---- drivers/net/ethernet/meta/fbnic/fbnic_txrx.c | 10 ++++++---- 3 files changed, 16 insertions(+), 10 deletions(-)
Read through the driver and changes look good to me. Since I don't have an fbnic or a lot of familiarity with the driver, I'll provide a more modest:
Jakub Kicinski
maintainerPATCH 3/5 eth: fbnic: report software Rx queue stats
In reply to Jakub KicinskiGather and report software Rx queue stats - checksum stats and allocation failures.
--- drivers/net/ethernet/meta/fbnic/fbnic_txrx.h | 5 +++ .../net/ethernet/meta/fbnic/fbnic_netdev.c | 12 +++++- drivers/net/ethernet/meta/fbnic/fbnic_txrx.c | 43 +++++++++++++++---- 3 files changed, 51 insertions(+), 9 deletions(-)
drivers/net/ethernet/meta/fbnic/fbnic_txrx.h +5 -0
@@ -62,6 +62,11 @@ struct fbnic_queue_stats {u64 ts_packets;u64 ts_lost; } twq; +struct { +u64 alloc_failed; +u64 csum_complete; +u64 csum_none; + } rx; };struct u64_stats_sync syncp; };
drivers/net/ethernet/meta/fbnic/fbnic_netdev.c +11 -1
@@ -487,8 +487,9 @@ static void fbnic_get_queue_stats_rx(struct net_device *dev, int idx,struct fbnic_net *fbn =netdev_priv (dev);struct fbnic_ring *rxr = fbn->rx[idx];struct fbnic_queue_stats *stats; +u64 bytes, packets, alloc_fail; +u64 csum_complete, csum_none;unsigned int start; -u64 bytes, packets;if (!rxr)return ;
@@ -498,10 +499,16 @@ static void fbnic_get_queue_stats_rx(struct net_device *dev, int idx, start =u64_stats_fetch_begin (&stats->syncp); bytes = stats->bytes; packets = stats->packets; + alloc_fail = stats->rx.alloc_failed; + csum_complete = stats->rx.csum_complete; + csum_none = stats->rx.csum_none; }while (u64_stats_fetch_retry (&stats->syncp, start)); rx->bytes = bytes; rx->packets = packets; + rx->alloc_fail = alloc_fail; + rx->csum_complete = csum_complete; + rx->csum_none = csum_none; } static void fbnic_get_queue_stats_tx(struct net_device *dev, int idx,
@@ -538,6 +545,9 @@ static void fbnic_get_base_stats(struct net_device *dev, rx->bytes = fbn->rx_stats.bytes; rx->packets = fbn->rx_stats.packets; + rx->alloc_fail = fbn->rx_stats.rx.alloc_failed; + rx->csum_complete = fbn->rx_stats.rx.csum_complete; + rx->csum_none = fbn->rx_stats.rx.csum_none; }static const struct netdev_stat_ops fbnic_stat_ops = {
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c +35 -8
106 lines not on this page · raw message
Signature · 1 line
2.48.1
Re: [PATCH net-next 3/5] eth: fbnic: report software Rx queue stats
Quoted 9 lines · Jakub Kicinski
Gather and report software Rx queue stats - checksum stats and allocation failures.
Signed-off-by Jakub Kicinski <[email protected]>--- drivers/net/ethernet/meta/fbnic/fbnic_txrx.h | 5 +++ .../net/ethernet/meta/fbnic/fbnic_netdev.c | 12 +++++- drivers/net/ethernet/meta/fbnic/fbnic_txrx.c | 43 +++++++++++++++---- 3 files changed, 51 insertions(+), 9 deletions(-)
Jakub Kicinski
maintainerPATCH 4/5 eth: fbnic: report software Tx queue stats
In reply to Jakub KicinskiGather and report software Tx queue stats - checksum stats and queue stop / start.
--- drivers/net/ethernet/meta/fbnic/fbnic_txrx.h | 3 +++ .../net/ethernet/meta/fbnic/fbnic_netdev.c | 10 ++++++++ drivers/net/ethernet/meta/fbnic/fbnic_txrx.c | 23 +++++++++++++++---- 3 files changed, 32 insertions(+), 4 deletions(-)
drivers/net/ethernet/meta/fbnic/fbnic_txrx.h +3 -0
@@ -59,8 +59,11 @@ struct fbnic_queue_stats {u64 dropped;union {struct { +u64 csum_partial;u64 ts_packets;u64 ts_lost; +u64 stop; +u64 wake; } twq;struct {u64 alloc_failed;
drivers/net/ethernet/meta/fbnic/fbnic_netdev.c +10 -0
@@ -517,6 +517,7 @@ static void fbnic_get_queue_stats_tx(struct net_device *dev, int idx,struct fbnic_net *fbn =netdev_priv (dev);struct fbnic_ring *txr = fbn->tx[idx];struct fbnic_queue_stats *stats; +u64 stop, wake, csum;unsigned int start;u64 bytes, packets;
@@ -528,10 +529,16 @@ static void fbnic_get_queue_stats_tx(struct net_device *dev, int idx, start =u64_stats_fetch_begin (&stats->syncp); bytes = stats->bytes; packets = stats->packets; + csum = stats->twq.csum_partial; + stop = stats->twq.stop; + wake = stats->twq.wake; }while (u64_stats_fetch_retry (&stats->syncp, start)); tx->bytes = bytes; tx->packets = packets; + tx->needs_csum = csum; + tx->stop = stop; + tx->wake = wake; } static void fbnic_get_base_stats(struct net_device *dev,
@@ -542,6 +549,9 @@ static void fbnic_get_base_stats(struct net_device *dev, tx->bytes = fbn->tx_stats.bytes; tx->packets = fbn->tx_stats.packets; + tx->needs_csum = fbn->tx_stats.twq.csum_partial; + tx->stop = fbn->tx_stats.twq.stop; + tx->wake = fbn->tx_stats.twq.wake; rx->bytes = fbn->rx_stats.bytes; rx->packets = fbn->rx_stats.packets;
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c +19 -4
@@ -113,6 +113,11 @@ static int fbnic_maybe_stop_tx(const struct net_device *dev, res =netif_txq_maybe_stop (txq,fbnic_desc_unused (ring), size,FBNIC_TX_DESC_WAKEUP ); +if (!res) { +u64_stats_update_begin (&ring->stats.syncp); + ring->stats.twq.stop++; +u64_stats_update_end (&ring->stats.syncp); + }return !res; }
@@ -191,6 +196,9 @@ fbnic_tx_offloads(struct fbnic_ring *ring, struct sk_buff *skb, __le64 *meta) skb->csum_offset / 2)); *meta |=cpu_to_le64 (FBNIC_TWD_FLAG_REQ_CSO ); +u64_stats_update_begin (&ring->stats.syncp); + ring->stats.twq.csum_partial++; +u64_stats_update_end (&ring->stats.syncp); *meta |=cpu_to_le64 (FIELD_PREP (FBNIC_TWD_L2_HLEN_MASK , l2len /2 ) |FIELD_PREP (FBNIC_TWD_L3_IHLEN_MASK , i3len /2 ));
@@ -460,9 +468,13 @@ static void fbnic_clean_twq0(struct fbnic_napi_vector *nv, int napi_budget, ring->stats.packets += total_packets;u64_stats_update_end (&ring->stats.syncp); -netif_txq_completed_wake (txq, total_packets, total_bytes, -fbnic_desc_unused (ring), -FBNIC_TX_DESC_WAKEUP ); +if (!netif_txq_completed_wake (txq, total_packets, total_bytes, +fbnic_desc_unused (ring), +FBNIC_TX_DESC_WAKEUP )) { +u64_stats_update_begin (&ring->stats.syncp); + ring->stats.twq.wake++; +u64_stats_update_end (&ring->stats.syncp); + } } static void fbnic_clean_tsq(struct fbnic_napi_vector *nv,
@@ -1092,10 +1104,13 @@ void fbnic_aggregate_ring_tx_counters(struct fbnic_net *fbn, fbn->tx_stats.bytes += stats->bytes; fbn->tx_stats.packets += stats->packets; fbn->tx_stats.dropped += stats->dropped; + fbn->tx_stats.twq.csum_partial += stats->twq.csum_partial; fbn->tx_stats.twq.ts_lost += stats->twq.ts_lost; fbn->tx_stats.twq.ts_packets += stats->twq.ts_packets; + fbn->tx_stats.twq.stop += stats->twq.stop; + fbn->tx_stats.twq.wake += stats->twq.wake;/* Remember to add new stats here */ -BUILD_BUG_ON (sizeof (fbn->tx_stats.twq) /8 !=2 ); +BUILD_BUG_ON (sizeof (fbn->tx_stats.twq) /8 !=5 ); } static void fbnic_remove_tx_ring(struct fbnic_net *fbn,
Signature · 1 line
2.48.1
Re: [PATCH net-next 4/5] eth: fbnic: report software Tx queue stats
Quoted 9 lines · Jakub Kicinski
Gather and report software Tx queue stats - checksum stats and queue stop / start.
Signed-off-by Jakub Kicinski <[email protected]>--- drivers/net/ethernet/meta/fbnic/fbnic_txrx.h | 3 +++ .../net/ethernet/meta/fbnic/fbnic_netdev.c | 10 ++++++++ drivers/net/ethernet/meta/fbnic/fbnic_txrx.c | 23 +++++++++++++++---- 3 files changed, 32 insertions(+), 4 deletions(-)
Jakub Kicinski
maintainerPATCH 5/5 eth: fbnic: re-sort the objects in the Makefile
In reply to Jakub KicinskiLooks like recent commit broke the sort order, fix it.
--- drivers/net/ethernet/meta/fbnic/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/meta/fbnic/Makefile +2 -1
@@ -20,6 +20,7 @@ fbnic-y := fbnic_csr.o \ fbnic_pci.o \ fbnic_phylink.o \ fbnic_rpc.o \ + fbnic_time.o \ fbnic_tlv.o \ fbnic_txrx.o \ - fbnic_time.o +# End of objects
Signature · 1 line
2.48.1
Re: [PATCH net-next 5/5] eth: fbnic: re-sort the objects in the Makefile
Quoted 12 lines · Jakub Kicinski
Looks like recent commit broke the sort order, fix it.
Signed-off-by Jakub Kicinski <[email protected]>--- drivers/net/ethernet/meta/fbnic/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/net/ethernet/meta/fbnic/Makefile +0
-0
drivers/net/ethernet/meta/fbnic/Makefile fbnic-y := fbnic_csr.o \ · line 26
Quoted 8 lines
drivers/net/ethernet/meta/fbnic/Makefile +2
-1@@ -20,6 +20,7 @@ fbnic-y := fbnic_csr.o \ fbnic_pci.o \ fbnic_phylink.o \ fbnic_rpc.o \ + fbnic_time.o \ fbnic_tlv.o \ fbnic_txrx.o \ - fbnic_time.o +# End of objects
Incredibly minor nit, do you want to remove the trailing '\' after fbnic_txrx.o which is the new last line to keep the format consistent with how it was previously?
Your call, but I definitely feel bad pointing that out and potentially causing a re-spin, so:
Jakub Kicinski
maintainerRe: [PATCH net-next 5/5] eth: fbnic: re-sort the objects in the Makefile
Quoted 3 lines · On Tue, 11 Feb 2025 11:54:37 -0800 Joe Damato wrote:
Incredibly minor nit, do you want to remove the trailing '\' after fbnic_txrx.o which is the new last line to keep the format consistent with how it was previously?
The point of having the comment is that the last real line can have the trailing \ and therefore will not need to be modified when an object is added after it :)
Thanks for the reviews!
Alexander Lobakin
Reviewed-byRe: [PATCH net-next 5/5] eth: fbnic: re-sort the objects in the Makefile
From: Jakub Kicinski <[email protected]>
Date: Tue, 11 Feb 2025 14:32:34 -0800
Quoted 8 lines · On Tue, 11 Feb 2025 11:54:37 -0800 Joe Damato wrote:
Quoted 3 lines
Incredibly minor nit, do you want to remove the trailing '\' after fbnic_txrx.o which is the new last line to keep the format consistent with how it was previously?
The point of having the comment is that the last real line can have the trailing \ and therefore will not need to be modified when an object is added after it :)
Nice idea :D
Quoted 2 lines
Thanks for the reviews!
Series:
Thanks,
Olek
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 15 lines · On Tue, 11 Feb 2025 10:13:51 -0800 you wrote:
Fill in typical software queue stats.
# ./pyynl/cli.py --spec netlink/specs/netdev.yaml --dump qstats-get [{'ifindex': 2, 'rx-alloc-fail': 0, 'rx-bytes': 398064076, 'rx-csum-complete': 271, 'rx-csum-none': 0, 'rx-packets': 276044, 'tx-bytes': 7223770, 'tx-needs-csum': 28148, 'tx-packets': 28449, 'tx-stop': 0, 'tx-wake': 0}]
Quoted 1 line
[...]
Here is the summary with links:
- [net-next,1/5] net: report csum_complete via qstats
https://git.kernel.org/netdev/net-next/c/34eea78a1112 - [net-next,2/5] eth: fbnic: wrap tx queue stats in a struct (no matching commit) - [net-next,3/5] eth: fbnic: report software Rx queue stats (no matching commit) - [net-next,4/5] eth: fbnic: report software Tx queue stats (no matching commit) - [net-next,5/5] eth: fbnic: re-sort the objects in the Makefile https://git.kernel.org/netdev/net-next/c/0ec023282a9d
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html