[PATCH net-next V2 1/5] net/mlx5e: Report hw_gso_packets and hw_gso_bytes netdev stats

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

Report hardware GSO statistics via the netdev queue stats API by mapping
the existing TSO counters to hw_gso_packets and hw_gso_bytes fields.

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

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index f7009da94f0b..3e934e269139 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -5479,6 +5479,10 @@ static void mlx5e_get_queue_stats_tx(struct net_device *dev, int i,
 	sq_stats = priv->txq2sq_stats[i];
 	stats->packets = sq_stats->packets;
 	stats->bytes = sq_stats->bytes;
+
+	stats->hw_gso_packets =
+		sq_stats->tso_packets + sq_stats->tso_inner_packets;
+	stats->hw_gso_bytes = sq_stats->tso_bytes + sq_stats->tso_inner_bytes;
 }
 
 static void mlx5e_get_base_stats(struct net_device *dev,
@@ -5518,6 +5522,8 @@ static void mlx5e_get_base_stats(struct net_device *dev,
 
 	tx->packets = 0;
 	tx->bytes = 0;
+	tx->hw_gso_packets = 0;
+	tx->hw_gso_bytes = 0;
 
 	for (i = 0; i < priv->stats_nch; i++) {
 		struct mlx5e_channel_stats *channel_stats = priv->channel_stats[i];
@@ -5544,6 +5550,10 @@ static void mlx5e_get_base_stats(struct net_device *dev,
 
 			tx->packets += sq_stats->packets;
 			tx->bytes += sq_stats->bytes;
+			tx->hw_gso_packets += sq_stats->tso_packets +
+					      sq_stats->tso_inner_packets;
+			tx->hw_gso_bytes += sq_stats->tso_bytes +
+					    sq_stats->tso_inner_bytes;
 		}
 	}
 
@@ -5562,6 +5572,10 @@ static void mlx5e_get_base_stats(struct net_device *dev,
 
 			tx->packets += sq_stats->packets;
 			tx->bytes   += sq_stats->bytes;
+			tx->hw_gso_packets += sq_stats->tso_packets +
+					      sq_stats->tso_inner_packets;
+			tx->hw_gso_bytes += sq_stats->tso_bytes +
+					    sq_stats->tso_inner_bytes;
 		}
 	}
 }
-- 
2.44.0
Re: [PATCH net-next V2 1/5] net/mlx5e: Report hw_gso_packets and hw_gso_bytes netdev stats
Posted by Jakub Kicinski 3 weeks ago
On Mon, 9 Mar 2026 11:55:15 +0200 Tariq Toukan wrote:
> From: Gal Pressman <gal@nvidia.com>
> 
> Report hardware GSO statistics via the netdev queue stats API by mapping
> the existing TSO counters to hw_gso_packets and hw_gso_bytes fields.

The docs on our stats are based on the virtio spec:
https://github.com/oasis-tcs/virtio-spec/commit/42f389989823039724f95bbbd243291ab0064f82
which is not very detailed, but to me "bytes of TSO packets"
is a sum of skb->len of those packets. And mlx5 seems to only
be counting payloads??

Maybe given the ambiguity / mismatch report just the packet
count? IDK how useful the bytes are in real life anyway.
Re: [PATCH net-next V2 1/5] net/mlx5e: Report hw_gso_packets and hw_gso_bytes netdev stats
Posted by Gal Pressman 2 weeks, 6 days ago
Thanks for the review on the series Jakub!

On 11/03/2026 5:12, Jakub Kicinski wrote:
> On Mon, 9 Mar 2026 11:55:15 +0200 Tariq Toukan wrote:
>> From: Gal Pressman <gal@nvidia.com>
>>
>> Report hardware GSO statistics via the netdev queue stats API by mapping
>> the existing TSO counters to hw_gso_packets and hw_gso_bytes fields.
> 
> The docs on our stats are based on the virtio spec:
> https://github.com/oasis-tcs/virtio-spec/commit/42f389989823039724f95bbbd243291ab0064f82
> which is not very detailed, but to me "bytes of TSO packets"
> is a sum of skb->len of those packets. And mlx5 seems to only
> be counting payloads??

TBH, I'm surprised this is our behavior, not intuitive at all..

I'm inclined to just change it to account for the headers, hope it won't
break anything.