[PATCH net-next V2 4/5] net/mlx5e: Report RX csum netdev stats

Tariq Toukan posted 5 patches 3 weeks, 2 days ago
[PATCH net-next V2 4/5] net/mlx5e: Report RX csum netdev stats
Posted by Tariq Toukan 3 weeks, 2 days ago
From: Gal Pressman <gal@nvidia.com>

Report RX checksum statistics via the netdev queue stats API by mapping
the existing csum_complete, csum_unnecessary, csum_unnecessary_inner,
and csum_none counters to the csum_complete, csum_unnecessary and
csum_none fields.

Signed-off-by: Gal Pressman <gal@nvidia.com>
Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
 .../net/ethernet/mellanox/mlx5/core/en_main.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index e2f98b1f8636..a03fbf1cb362 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -5466,6 +5466,14 @@ static void mlx5e_get_queue_stats_rx(struct net_device *dev, int i,
 	stats->hw_gro_wire_packets =
 		rq_stats->gro_packets + xskrq_stats->gro_packets;
 	stats->hw_gro_wire_bytes = rq_stats->gro_bytes + xskrq_stats->gro_bytes;
+
+	stats->csum_complete =
+		rq_stats->csum_complete + xskrq_stats->csum_complete;
+	stats->csum_unnecessary = rq_stats->csum_unnecessary +
+				  xskrq_stats->csum_unnecessary +
+				  rq_stats->csum_unnecessary_inner +
+				  xskrq_stats->csum_unnecessary_inner;
+	stats->csum_none = rq_stats->csum_none + xskrq_stats->csum_none;
 }
 
 static void mlx5e_get_queue_stats_tx(struct net_device *dev, int i,
@@ -5509,6 +5517,9 @@ static void mlx5e_get_base_stats(struct net_device *dev,
 		rx->hw_gro_packets = 0;
 		rx->hw_gro_wire_packets = 0;
 		rx->hw_gro_wire_bytes = 0;
+		rx->csum_complete = 0;
+		rx->csum_unnecessary = 0;
+		rx->csum_none = 0;
 
 		for (i = priv->channels.params.num_channels; i < priv->stats_nch; i++) {
 			struct netdev_queue_stats_rx rx_i = {0};
@@ -5521,6 +5532,9 @@ static void mlx5e_get_base_stats(struct net_device *dev,
 			rx->hw_gro_packets += rx_i.hw_gro_packets;
 			rx->hw_gro_wire_packets += rx_i.hw_gro_wire_packets;
 			rx->hw_gro_wire_bytes += rx_i.hw_gro_wire_bytes;
+			rx->csum_complete += rx_i.csum_complete;
+			rx->csum_unnecessary += rx_i.csum_unnecessary;
+			rx->csum_none += rx_i.csum_none;
 		}
 
 		/* always report PTP RX stats from base as there is no
@@ -5535,6 +5549,11 @@ static void mlx5e_get_base_stats(struct net_device *dev,
 			rx->hw_gro_packets += rq_stats->gro_skbs;
 			rx->hw_gro_wire_packets += rq_stats->gro_packets;
 			rx->hw_gro_wire_bytes += rq_stats->gro_bytes;
+			rx->csum_complete += rq_stats->csum_complete;
+			rx->csum_unnecessary +=
+				rq_stats->csum_unnecessary +
+				rq_stats->csum_unnecessary_inner;
+			rx->csum_none += rq_stats->csum_none;
 		}
 	}
 
-- 
2.44.0
Re: [PATCH net-next V2 4/5] net/mlx5e: Report RX csum netdev stats
Posted by Jakub Kicinski 3 weeks ago
On Mon, 9 Mar 2026 11:55:18 +0200 Tariq Toukan wrote:
> Report RX checksum statistics via the netdev queue stats API by mapping
> the existing csum_complete, csum_unnecessary, csum_unnecessary_inner,
> and csum_none counters to the csum_complete, csum_unnecessary and
> csum_none fields.

The doc doesnt say clearly but I'd assume this should also count wire
frames for consistency with the Tx one
Re: [PATCH net-next V2 4/5] net/mlx5e: Report RX csum netdev stats
Posted by Gal Pressman 2 weeks, 6 days ago
On 11/03/2026 5:20, Jakub Kicinski wrote:
> On Mon, 9 Mar 2026 11:55:18 +0200 Tariq Toukan wrote:
>> Report RX checksum statistics via the netdev queue stats API by mapping
>> the existing csum_complete, csum_unnecessary, csum_unnecessary_inner,
>> and csum_none counters to the csum_complete, csum_unnecessary and
>> csum_none fields.
> 
> The doc doesnt say clearly but I'd assume this should also count wire
> frames for consistency with the Tx one

Makes sense, so this also doesn't fit naturally.