net/mlx5e: Report more netdev stats
Subsystems (5)
Tariq Toukan
maintainerv2 cover net/mlx5e: Report more netdev stats
Hi,
This series by Gal extends the set of counters reported in netdev stats, by adding:
- hw_gso_packets/bytes
- RX HW-GRO stats
- TX/RX csum
- TX queue stop/wake
Regards,
Tariq
V2:
- Link to V1: https://lore.kernel.org/all/[email protected]/
- Fix GRO counters of patch #2.
Gal Pressman (5):
net/mlx5e: Report hw_gso_packets and hw_gso_bytes netdev stats net/mlx5e: Report RX HW-GRO netdev stats
net/mlx5e: Report TX csum netdev stats
net/mlx5e: Report RX csum netdev stats
net/mlx5e: Report stop and wake TX queue stats
.../net/ethernet/mellanox/mlx5/core/en_main.c | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+)
base-commit: 0bcac7b11262557c990da1ac564d45777eb6b005
Signature · 1 line
2.44.0
Tariq Toukan
maintainerPATCH v2 1/5 net/mlx5e: Report hw_gso_packets and hw_gso_bytes netdev stats
From: Gal Pressman <[email protected]>
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.
--- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +14 -0
@@ -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; } } }
Signature · 1 line
2.44.0
Jakub Kicinski
maintainerRe: [PATCH net-next V2 1/5] net/mlx5e: Report hw_gso_packets and hw_gso_bytes netdev stats
Quoted 4 lines · On Mon, 9 Mar 2026 11:55:15 +0200 Tariq Toukan wrote:
From: Gal Pressman <[email protected]>
Report hardware GSO statistics via the netdev queue stats API by mapping the existing TSO counters to
hw_gso_packetsandhw_gso_bytesfields.
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
Thanks for the review on the series Jakub!
Quoted 11 lines · Jakub Kicinski
Quoted 4 lines · On Mon, 9 Mar 2026 11:55:15 +0200 Tariq Toukan wrote:
From: Gal Pressman <[email protected]>
Report hardware GSO statistics via the netdev queue stats API by mapping the existing TSO counters to
hw_gso_packetsandhw_gso_bytesfields.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 ofskb->lenof 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.
Tariq Toukan
maintainerPATCH v2 2/5 net/mlx5e: Report RX HW-GRO netdev stats
In reply to Tariq ToukanFrom: Gal Pressman <[email protected]>
Report RX hardware GRO statistics via the netdev queue stats API by mapping the existing gro_packets, gro_bytes and gro_skbs counters to the hw_gro_wire_packets, hw_gro_wire_bytes and hw_gro_packets fields.
--- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +14 -0
@@ -5461,6 +5461,11 @@ static void mlx5e_get_queue_stats_rx(struct net_device *dev, int i, stats->bytes = rq_stats->bytes + xskrq_stats->bytes; stats->alloc_fail = rq_stats->buff_alloc_err + xskrq_stats->buff_alloc_err; + + stats->hw_gro_packets = rq_stats->gro_skbs + xskrq_stats->gro_skbs; + 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; } static void mlx5e_get_queue_stats_tx(struct net_device *dev, int i,
@@ -5497,6 +5502,9 @@ static void mlx5e_get_base_stats(struct net_device *dev, rx->packets =0 ; rx->bytes =0 ; rx->alloc_fail =0 ; + rx->hw_gro_packets =0 ; + rx->hw_gro_wire_packets =0 ; + rx->hw_gro_wire_bytes =0 ;for (i = priv->channels.params.num_channels; i < priv->stats_nch; i++) {struct netdev_queue_stats_rx rx_i = {0 };
@@ -5506,6 +5514,9 @@ static void mlx5e_get_base_stats(struct net_device *dev, rx->packets += rx_i.packets; rx->bytes += rx_i.bytes; rx->alloc_fail += rx_i.alloc_fail; + 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; }/* always report PTP RX stats from base as there is no
@@ -5517,6 +5528,9 @@ static void mlx5e_get_base_stats(struct net_device *dev, rx->packets += rq_stats->packets; rx->bytes += rq_stats->bytes; + 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; } }
Signature · 1 line
2.44.0
Re: [PATCH net-next V2 2/5] net/mlx5e: Report RX HW-GRO netdev stats
Quoted 3 lines · On Mon, 9 Mar 2026 11:55:16 +0200 Tariq Toukan wrote:
Report RX hardware GRO statistics via the netdev queue stats API by mapping the existing
gro_packets,gro_bytesandgro_skbscounters to thehw_gro_wire_packets,hw_gro_wire_bytesandhw_gro_packetsfields.
This looks right now:
Tariq Toukan
maintainerPATCH v2 3/5 net/mlx5e: Report TX csum netdev stats
In reply to Tariq ToukanFrom: Gal Pressman <[email protected]>
Report TX checksum statistics via the netdev queue stats API by mapping the existing csum_none and csum_partial counters to the csum_none and needs_csum fields.
--- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +12 -0
@@ -5488,6 +5488,10 @@ static void mlx5e_get_queue_stats_tx(struct net_device *dev, int i, 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; + + stats->csum_none = sq_stats->csum_none; + stats->needs_csum = + sq_stats->csum_partial + sq_stats->csum_partial_inner; } static void mlx5e_get_base_stats(struct net_device *dev,
@@ -5538,6 +5542,8 @@ static void mlx5e_get_base_stats(struct net_device *dev, tx->bytes =0 ; tx->hw_gso_packets =0 ; tx->hw_gso_bytes =0 ; + tx->csum_none =0 ; + tx->needs_csum =0 ;for (i =0 ; i < priv->stats_nch; i++) {struct mlx5e_channel_stats *channel_stats = priv->channel_stats[i];
@@ -5568,6 +5574,9 @@ static void mlx5e_get_base_stats(struct net_device *dev, sq_stats->tso_inner_packets; tx->hw_gso_bytes += sq_stats->tso_bytes + sq_stats->tso_inner_bytes; + tx->csum_none += sq_stats->csum_none; + tx->needs_csum += sq_stats->csum_partial + + sq_stats->csum_partial_inner; } }
@@ -5590,6 +5599,9 @@ static void mlx5e_get_base_stats(struct net_device *dev, sq_stats->tso_inner_packets; tx->hw_gso_bytes += sq_stats->tso_bytes + sq_stats->tso_inner_bytes; + tx->csum_none += sq_stats->csum_none; + tx->needs_csum += sq_stats->csum_partial + + sq_stats->csum_partial_inner; } } }
Signature · 1 line
2.44.0
Jakub Kicinski
maintainerRe: [PATCH net-next V2 3/5] net/mlx5e: Report TX csum netdev stats
Quoted 3 lines · On Mon, 9 Mar 2026 11:55:17 +0200 Tariq Toukan wrote:
Report TX checksum statistics via the netdev queue stats API by mapping the existing
csum_noneandcsum_partialcounters to thecsum_noneandneeds_csumfields.
-
name: tx-needs-csum
doc: |
Number of packets that required the device to calculate the checksum. This counter includes the number of GSO wire packets for which device calculated the L4 checksum.
type: uint
Looking at drivers currently implementing this it seems like the idea was to avoid having to increment two counters in the drivers, given that TSO always implies csum offload
Re: [PATCH net-next V2 3/5] net/mlx5e: Report TX csum netdev stats
Quoted 5 lines · Jakub Kicinski
Quoted 3 lines · On Mon, 9 Mar 2026 11:55:17 +0200 Tariq Toukan wrote:
Report TX checksum statistics via the netdev queue stats API by mapping the existing
csum_noneandcsum_partialcounters to thecsum_noneandneeds_csumfields.
Quoted 7 lines
-
name: tx-needs-csum
doc: |
Number of packets that required the device to calculate the checksum. This counter includes the number of GSO wire packets for which device calculated the L4 checksum.
type: uint
Yea, we count GSO packets as one, so not a direct fit.
Quoted 4 lines
Looking at drivers currently implementing this it seems like the idea was to avoid having to increment two counters in the drivers, given that TSO always implies csum offload
I don't think I understand what you're trying to say here.
Jakub Kicinski
maintainerRe: [PATCH net-next V2 3/5] net/mlx5e: Report TX csum netdev stats
Quoted 5 lines · On Thu, 12 Mar 2026 11:50:10 +0200 Gal Pressman wrote:
Quoted 3 lines
Looking at drivers currently implementing this it seems like the idea was to avoid having to increment two counters in the drivers, given that TSO always implies csum offload
I don't think I understand what you're trying to say here.
The existing drivers seem to do something like:
tx->needs_csum += just_csum + tso_segs;
IOW for packets that need tso/uso they don't increment any csum stat on the fastpath.
Tariq Toukan
maintainerPATCH v2 4/5 net/mlx5e: Report RX csum netdev stats
In reply to Tariq ToukanFrom: Gal Pressman <[email protected]>
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.
--- .../net/ethernet/mellanox/mlx5/core/en_main.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +19 -0
@@ -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; } }
Signature · 1 line
2.44.0
Jakub Kicinski
maintainerRe: [PATCH net-next V2 4/5] net/mlx5e: Report RX csum netdev stats
Quoted 4 lines · 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, andcsum_nonecounters to thecsum_complete,csum_unnecessaryandcsum_nonefields.
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
Quoted 8 lines · Jakub Kicinski
Quoted 4 lines · 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, andcsum_nonecounters to thecsum_complete,csum_unnecessaryandcsum_nonefields.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.
Tariq Toukan
maintainerPATCH v2 5/5 net/mlx5e: Report stop and wake TX queue stats
In reply to Tariq ToukanFrom: Gal Pressman <[email protected]>
Report TX queue stop and wake statistics via the netdev queue stats API by mapping the existing stopped and wake counters to the stop and wake fields.
--- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +9 -0
@@ -5500,6 +5500,9 @@ static void mlx5e_get_queue_stats_tx(struct net_device *dev, int i, stats->csum_none = sq_stats->csum_none; stats->needs_csum = sq_stats->csum_partial + sq_stats->csum_partial_inner; + + stats->stop = sq_stats->stopped; + stats->wake = sq_stats->wake; } static void mlx5e_get_base_stats(struct net_device *dev,
@@ -5563,6 +5566,8 @@ static void mlx5e_get_base_stats(struct net_device *dev, tx->hw_gso_bytes =0 ; tx->csum_none =0 ; tx->needs_csum =0 ; + tx->stop =0 ; + tx->wake =0 ;for (i =0 ; i < priv->stats_nch; i++) {struct mlx5e_channel_stats *channel_stats = priv->channel_stats[i];
@@ -5596,6 +5601,8 @@ static void mlx5e_get_base_stats(struct net_device *dev, tx->csum_none += sq_stats->csum_none; tx->needs_csum += sq_stats->csum_partial + sq_stats->csum_partial_inner; + tx->stop += sq_stats->stopped; + tx->wake += sq_stats->wake; } }
@@ -5621,6 +5628,8 @@ static void mlx5e_get_base_stats(struct net_device *dev, tx->csum_none += sq_stats->csum_none; tx->needs_csum += sq_stats->csum_partial + sq_stats->csum_partial_inner; + tx->stop += sq_stats->stopped; + tx->wake += sq_stats->wake; } } }
Signature · 1 line
2.44.0
Quoted 9 lines · Tariq Toukan
Hi,
This series by Gal extends the set of counters reported in netdev stats, by adding:
- hw_gso_packets/bytes
- RX HW-GRO stats
- TX/RX csum
- TX queue stop/wake
Quoted 6 lines
Regards,
TariqV2:
- Link to V1: https://lore.kernel.org/all/[email protected]/
- Fix GRO counters of patch #2.
Thanks.
For the series,
...