]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
eth: fbnic: wrap tx queue stats in a struct
authorJakub Kicinski <kuba@kernel.org>
Tue, 11 Feb 2025 18:13:53 +0000 (10:13 -0800)
committerJakub Kicinski <kuba@kernel.org>
Thu, 13 Feb 2025 00:38:51 +0000 (16:38 -0800)
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.

Acked-by: Joe Damato <jdamato@fastly.com>
Reviewed-by: Alexander Lobakin <aleksander.lobakin@intel.com>
Link: https://patch.msgid.link/20250211181356.580800-3-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
drivers/net/ethernet/meta/fbnic/fbnic_txrx.h

index 9503c36620c6ba89fa58d7a19e2fd23f8aee4ad5..fb7139a1da4654ff07275ecc777fdee250bad044 100644 (file)
@@ -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;
index d4d7027df9a033578c0ad88590eb058e796f9646..b60dd1c9918e4d1f333a90b300c530b44b950457 100644 (file)
@@ -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,
index c2a94f31f71bd5831abd607622fd057276753c6d..6b549b0e7fa4aa288285f1f4bcfb8d9c4a658724 100644 (file)
@@ -56,9 +56,13 @@ struct fbnic_pkt_buff {
 struct fbnic_queue_stats {
        u64 packets;
        u64 bytes;
+       union {
+               struct {
+                       u64 ts_packets;
+                       u64 ts_lost;
+               } twq;
+       };
        u64 dropped;
-       u64 ts_packets;
-       u64 ts_lost;
        struct u64_stats_sync syncp;
 };