]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
sfc: implement per-queue rx drop and overrun stats
authorEdward Cree <ecree.xilinx@gmail.com>
Mon, 30 Sep 2024 13:52:43 +0000 (14:52 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sun, 6 Oct 2024 15:02:23 +0000 (16:02 +0100)
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/efx.c
drivers/net/ethernet/sfc/efx_channels.c
drivers/net/ethernet/sfc/efx_channels.h
drivers/net/ethernet/sfc/net_driver.h

index ea1e0e8ecbddf87355e988c5c8621ff4dfe88c90..b0ea4ca82cd87b56a642337ac1b426a20b7a74a5 100644 (file)
@@ -638,6 +638,10 @@ 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->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 -
+                                 channel->old_n_rx_hw_drop_overruns;
 }
 
 static void efx_get_queue_stats_tx(struct net_device *net_dev, int idx,
@@ -668,6 +672,8 @@ static void efx_get_base_stats(struct net_device *net_dev,
        struct efx_channel *channel;
 
        rx->packets = 0;
+       rx->hw_drops = 0;
+       rx->hw_drop_overruns = 0;
        tx->packets = 0;
        tx->bytes = 0;
 
@@ -676,10 +682,15 @@ static void efx_get_base_stats(struct net_device *net_dev,
         */
        efx_for_each_channel(channel, efx) {
                rx_queue = efx_channel_get_rx_queue(channel);
-               if (channel->channel >= net_dev->real_num_rx_queues)
+               if (channel->channel >= net_dev->real_num_rx_queues) {
                        rx->packets += rx_queue->rx_packets;
-               else
+                       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->hw_drops += channel->old_n_rx_hw_drops;
+                       rx->hw_drop_overruns += channel->old_n_rx_hw_drop_overruns;
+               }
                efx_for_each_channel_tx_queue(tx_queue, channel) {
                        if (channel->channel < efx->tx_channel_offset ||
                            channel->channel >= efx->tx_channel_offset +
index 834d51812e2b1bbefb9840690e4e2a41fd69f073..44d92c0e1b6319220c7d357c3e69d16c870810c4 100644 (file)
@@ -1100,6 +1100,10 @@ void efx_start_channels(struct efx_nic *efx)
                        atomic_inc(&efx->active_queues);
                }
 
+               /* reset per-queue stats */
+               channel->old_n_rx_hw_drops = efx_get_queue_stat_rx_hw_drops(channel);
+               channel->old_n_rx_hw_drop_overruns = channel->n_rx_nodesc_trunc;
+
                efx_for_each_channel_rx_queue(rx_queue, channel) {
                        efx_init_rx_queue(rx_queue);
                        atomic_inc(&efx->active_queues);
index 46b702648721e5dac51faa95db2e1d4d2c640869..547cf94014a31f18bca51d876bde0cee5d016aef 100644 (file)
@@ -43,6 +43,13 @@ struct efx_channel *efx_copy_channel(const struct efx_channel *old_channel);
 void efx_start_channels(struct efx_nic *efx);
 void efx_stop_channels(struct efx_nic *efx);
 
+static inline u64 efx_get_queue_stat_rx_hw_drops(struct efx_channel *channel)
+{
+       return channel->n_rx_eth_crc_err + channel->n_rx_frm_trunc +
+              channel->n_rx_overlength + channel->n_rx_nodesc_trunc +
+              channel->n_rx_mport_bad;
+}
+
 void efx_init_napi_channel(struct efx_channel *channel);
 void efx_init_napi(struct efx_nic *efx);
 void efx_fini_napi_channel(struct efx_channel *channel);
index aba106d03d415a46d059f638185d271b17dc56e5..f6632f8185b2562a3ff394d742b3e5309b7e4ad7 100644 (file)
@@ -494,6 +494,10 @@ enum efx_sync_events_state {
  * @n_rx_xdp_redirect: Count of RX packets redirected to a different NIC by XDP
  * @n_rx_mport_bad: Count of RX packets dropped because their ingress mport was
  *     not recognised
+ * @old_n_rx_hw_drops: Count of all RX packets dropped for any reason as of last
+ *     efx_start_channels()
+ * @old_n_rx_hw_drop_overruns: Value of @n_rx_nodesc_trunc as of last
+ *     efx_start_channels()
  * @rx_pkt_n_frags: Number of fragments in next packet to be delivered by
  *     __efx_rx_packet(), or zero if there is none
  * @rx_pkt_index: Ring index of first buffer for next packet to be delivered
@@ -556,6 +560,9 @@ struct efx_channel {
        unsigned int n_rx_xdp_redirect;
        unsigned int n_rx_mport_bad;
 
+       unsigned int old_n_rx_hw_drops;
+       unsigned int old_n_rx_hw_drop_overruns;
+
        unsigned int rx_pkt_n_frags;
        unsigned int rx_pkt_index;