net/mlx5e: SHAMPO, Make GRO counters more precise
authorDragos Tatulea <dtatulea@nvidia.com>
Mon, 3 Jun 2024 21:22:14 +0000 (00:22 +0300)
committerJakub Kicinski <kuba@kernel.org>
Thu, 6 Jun 2024 03:20:46 +0000 (20:20 -0700)
Don't count non GRO packets. A non GRO packet is a packet with
a GRO cb count of 1.

Signed-off-by: Dragos Tatulea <dtatulea@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://lore.kernel.org/r/20240603212219.1037656-10-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Documentation/networking/device_drivers/ethernet/mellanox/mlx5/counters.rst
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c

index fed821ef9b0940af4387df99e1b3f110afb0afa0..7ed010dbe4696834cb22ea8089406192b66af8c6 100644 (file)
@@ -189,17 +189,19 @@ the software port.
 
    * - `rx[i]_gro_packets`
      - Number of received packets processed using hardware-accelerated GRO. The
-       number of hardware GRO offloaded packets received on ring i.
+       number of hardware GRO offloaded packets received on ring i. Only true GRO
+       packets are counted: only packets that are in an SKB with a GRO count > 1.
      - Acceleration
 
    * - `rx[i]_gro_bytes`
      - Number of received bytes processed using hardware-accelerated GRO. The
-       number of hardware GRO offloaded bytes received on ring i.
+       number of hardware GRO offloaded bytes received on ring i. Only true GRO
+       packets are counted: only packets that are in an SKB with a GRO count > 1.
      - Acceleration
 
    * - `rx[i]_gro_skbs`
-     - The number of receive SKBs constructed while performing
-       hardware-accelerated GRO.
+     - The number of GRO SKBs constructed from hardware-accelerated GRO. Only SKBs
+       with a GRO count > 1 are counted.
      - Informative
 
    * - `rx[i]_gro_match_packets`
index 3f76c33aada04e3714e421036b6126561f351683..79b486d5475d98d648d5caf3dfca0221330ee335 100644 (file)
@@ -1596,9 +1596,7 @@ static void mlx5e_shampo_complete_rx_cqe(struct mlx5e_rq *rq,
        struct mlx5e_rq_stats *stats = rq->stats;
 
        stats->packets++;
-       stats->gro_packets++;
        stats->bytes += cqe_bcnt;
-       stats->gro_bytes += cqe_bcnt;
        if (NAPI_GRO_CB(skb)->count != 1)
                return;
        mlx5e_build_rx_skb(cqe, cqe_bcnt, rq, skb);
@@ -2240,14 +2238,19 @@ mlx5e_shampo_flush_skb(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe, bool match)
 {
        struct sk_buff *skb = rq->hw_gro_data->skb;
        struct mlx5e_rq_stats *stats = rq->stats;
+       u16 gro_count = NAPI_GRO_CB(skb)->count;
 
-       stats->gro_skbs++;
        if (likely(skb_shinfo(skb)->nr_frags))
                mlx5e_shampo_align_fragment(skb, rq->mpwqe.log_stride_sz);
-       if (NAPI_GRO_CB(skb)->count > 1)
+       if (gro_count > 1) {
+               stats->gro_skbs++;
+               stats->gro_packets += gro_count;
+               stats->gro_bytes += skb->data_len + skb_headlen(skb) * gro_count;
+
                mlx5e_shampo_update_hdr(rq, cqe, match);
-       else
+       } else {
                skb_shinfo(skb)->gso_size = 0;
+       }
        napi_gro_receive(rq->cq.napi, skb);
        rq->hw_gro_data->skb = NULL;
 }