diff mbox series

[net-next,4/6] sfc: implement per-queue rx drop and overrun stats

Message ID 379cc84db6cfb516f8eb677a1b703cbacfa46e02.1724852597.git.ecree.xilinx@gmail.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series sfc: per-queue stats | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 17 this patch: 17
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 1 maintainers not CCed: habetsm.xilinx@gmail.com
netdev/build_clang success Errors and warnings before: 17 this patch: 17
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 22 this patch: 22
netdev/checkpatch warning WARNING: Missing commit description - Add an appropriate one WARNING: line length of 83 exceeds 80 columns WARNING: line length of 85 exceeds 80 columns
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 60 this patch: 60
netdev/source_inline success Was 0 now: 0
netdev/contest fail net-next-2024-08-29--00-00 (tests: 713)

Commit Message

edward.cree@amd.com Aug. 28, 2024, 1:45 p.m. UTC
From: Edward Cree <ecree.xilinx@gmail.com>

Signed-off-by: Edward Cree <ecree.xilinx@gmail.com>
---
 drivers/net/ethernet/sfc/efx.c          | 15 +++++++++++++--
 drivers/net/ethernet/sfc/efx_channels.c |  4 ++++
 drivers/net/ethernet/sfc/efx_channels.h |  7 +++++++
 drivers/net/ethernet/sfc/net_driver.h   |  7 +++++++
 4 files changed, 31 insertions(+), 2 deletions(-)

Comments

Jacob Keller Aug. 28, 2024, 10:24 p.m. UTC | #1
On 8/28/2024 6:45 AM, edward.cree@amd.com wrote:
> From: Edward Cree <ecree.xilinx@gmail.com>
> 
> Signed-off-by: Edward Cree <ecree.xilinx@gmail.com>
> ---

Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>

>  drivers/net/ethernet/sfc/efx.c          | 15 +++++++++++++--
>  drivers/net/ethernet/sfc/efx_channels.c |  4 ++++
>  drivers/net/ethernet/sfc/efx_channels.h |  7 +++++++
>  drivers/net/ethernet/sfc/net_driver.h   |  7 +++++++
>  4 files changed, 31 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c
> index e4656efce969..8b46d143b6c7 100644
> --- a/drivers/net/ethernet/sfc/efx.c
> +++ b/drivers/net/ethernet/sfc/efx.c
> @@ -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,
> @@ -669,6 +673,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;
>  
>  	/* Count all packets on non-core queues, and packets before last
> @@ -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 +
> diff --git a/drivers/net/ethernet/sfc/efx_channels.c b/drivers/net/ethernet/sfc/efx_channels.c
> index c9e17a8208a9..90b9986ceaa3 100644
> --- a/drivers/net/ethernet/sfc/efx_channels.c
> +++ b/drivers/net/ethernet/sfc/efx_channels.c
> @@ -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);
> diff --git a/drivers/net/ethernet/sfc/efx_channels.h b/drivers/net/ethernet/sfc/efx_channels.h
> index b3b5e18a69cc..cccbc7d66e77 100644
> --- a/drivers/net/ethernet/sfc/efx_channels.h
> +++ b/drivers/net/ethernet/sfc/efx_channels.h
> @@ -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);
> diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h
> index cc96716d8dbe..25701f37aa40 100644
> --- a/drivers/net/ethernet/sfc/net_driver.h
> +++ b/drivers/net/ethernet/sfc/net_driver.h
> @@ -472,6 +472,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
> @@ -534,6 +538,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;
>  
>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c
index e4656efce969..8b46d143b6c7 100644
--- a/drivers/net/ethernet/sfc/efx.c
+++ b/drivers/net/ethernet/sfc/efx.c
@@ -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,
@@ -669,6 +673,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;
 
 	/* Count all packets on non-core queues, and packets before last
@@ -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 +
diff --git a/drivers/net/ethernet/sfc/efx_channels.c b/drivers/net/ethernet/sfc/efx_channels.c
index c9e17a8208a9..90b9986ceaa3 100644
--- a/drivers/net/ethernet/sfc/efx_channels.c
+++ b/drivers/net/ethernet/sfc/efx_channels.c
@@ -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);
diff --git a/drivers/net/ethernet/sfc/efx_channels.h b/drivers/net/ethernet/sfc/efx_channels.h
index b3b5e18a69cc..cccbc7d66e77 100644
--- a/drivers/net/ethernet/sfc/efx_channels.h
+++ b/drivers/net/ethernet/sfc/efx_channels.h
@@ -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);
diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h
index cc96716d8dbe..25701f37aa40 100644
--- a/drivers/net/ethernet/sfc/net_driver.h
+++ b/drivers/net/ethernet/sfc/net_driver.h
@@ -472,6 +472,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
@@ -534,6 +538,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;