sfc: add per-queue RX bytes stats
authorEdward Cree <ecree.xilinx@gmail.com>
Mon, 30 Sep 2024 13:52:45 +0000 (14:52 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sun, 6 Oct 2024 15:02:23 +0000 (16:02 +0100)
While this does add overhead to the fast path, it should be minimal
 as the cacheline should already be held for write from updating the
 queue's rx_packets stat.

Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Edward Cree <ecree.xilinx@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/sfc/ef100_rx.c
drivers/net/ethernet/sfc/efx.c
drivers/net/ethernet/sfc/net_driver.h
drivers/net/ethernet/sfc/rx.c
drivers/net/ethernet/sfc/rx_common.c

index 992151775cb83e75aff6a3975e90d41293401e27..44dc75feb1629e82982f017967bf065b6dac1a8a 100644 (file)
@@ -135,6 +135,7 @@ void __ef100_rx_packet(struct efx_channel *channel)
        }
 
        ++rx_queue->rx_packets;
+       rx_queue->rx_bytes += rx_buf->len;
 
        efx_rx_packet_gro(channel, rx_buf, channel->rx_pkt_n_frags, eh, csum);
        goto out;
index 68ddb28d3141a169933d59f350ad9aefa9344b6e..90bb7db15519d0853b71614d44be2db52d765110 100644 (file)
@@ -638,6 +638,7 @@ static void efx_get_queue_stats_rx(struct net_device *net_dev, int idx,
        rx_queue = efx_channel_get_rx_queue(channel);
        /* Count only packets since last time datapath was started */
        stats->packets = rx_queue->rx_packets - rx_queue->old_rx_packets;
+       stats->bytes = rx_queue->rx_bytes - rx_queue->old_rx_bytes;
        stats->hw_drops = efx_get_queue_stat_rx_hw_drops(channel) -
                          channel->old_n_rx_hw_drops;
        stats->hw_drop_overruns = channel->n_rx_nodesc_trunc -
@@ -682,6 +683,7 @@ static void efx_get_base_stats(struct net_device *net_dev,
        struct efx_channel *channel;
 
        rx->packets = 0;
+       rx->bytes = 0;
        rx->hw_drops = 0;
        rx->hw_drop_overruns = 0;
        tx->packets = 0;
@@ -696,10 +698,12 @@ static void efx_get_base_stats(struct net_device *net_dev,
                rx_queue = efx_channel_get_rx_queue(channel);
                if (channel->channel >= net_dev->real_num_rx_queues) {
                        rx->packets += rx_queue->rx_packets;
+                       rx->bytes += rx_queue->rx_bytes;
                        rx->hw_drops += efx_get_queue_stat_rx_hw_drops(channel);
                        rx->hw_drop_overruns += channel->n_rx_nodesc_trunc;
                } else {
                        rx->packets += rx_queue->old_rx_packets;
+                       rx->bytes += rx_queue->old_rx_bytes;
                        rx->hw_drops += channel->old_n_rx_hw_drops;
                        rx->hw_drop_overruns += channel->old_n_rx_hw_drop_overruns;
                }
index 4ca48db3e1685c52532e11e66c6abbf62f6c3034..b54662d32f55a2df43f23709cbeac5a6296191cd 100644 (file)
@@ -400,7 +400,9 @@ struct efx_rx_page_state {
  * @slow_fill: Timer used to defer efx_nic_generate_fill_event().
  * @grant_work: workitem used to grant credits to the MAE if @grant_credits
  * @rx_packets: Number of packets received since this struct was created
+ * @rx_bytes: Number of bytes received since this struct was created
  * @old_rx_packets: Value of @rx_packets as of last efx_init_rx_queue()
+ * @old_rx_bytes: Value of @rx_bytes as of last efx_init_rx_queue()
  * @xdp_rxq_info: XDP specific RX queue information.
  * @xdp_rxq_info_valid: Is xdp_rxq_info valid data?.
  */
@@ -437,7 +439,9 @@ struct efx_rx_queue {
        struct work_struct grant_work;
        /* Statistics to supplement MAC stats */
        unsigned long rx_packets;
+       unsigned long rx_bytes;
        unsigned long old_rx_packets;
+       unsigned long old_rx_bytes;
        struct xdp_rxq_info xdp_rxq_info;
        bool xdp_rxq_info_valid;
 };
index f074955821253627ba6c7f8f92e2909b1e32cf12..ffca82207e47367222162aa59fc36a930a217b3f 100644 (file)
@@ -393,6 +393,7 @@ void __efx_rx_packet(struct efx_channel *channel)
        }
 
        rx_queue->rx_packets++;
+       rx_queue->rx_bytes += rx_buf->len;
 
        if (!efx_do_xdp(efx, channel, rx_buf, &eh))
                goto out;
index bdb4325a7c2c59df87e2f896da94705d64469128..ab358fe13e1df037e02f9076a10c70cdb2363686 100644 (file)
@@ -242,6 +242,7 @@ void efx_init_rx_queue(struct efx_rx_queue *rx_queue)
        rx_queue->page_recycle_full = 0;
 
        rx_queue->old_rx_packets = rx_queue->rx_packets;
+       rx_queue->old_rx_bytes = rx_queue->rx_bytes;
 
        /* Initialise limit fields */
        max_fill = efx->rxq_entries - EFX_RXD_HEAD_ROOM;