net/mlx5e: Introduce timestamps statistic counter for Tx DMA layer
authorRahul Rameshbabu <rrameshbabu@nvidia.com>
Wed, 3 Apr 2024 21:28:41 +0000 (14:28 -0700)
committerJakub Kicinski <kuba@kernel.org>
Sat, 6 Apr 2024 05:24:09 +0000 (22:24 -0700)
Count number of transmitted packets that were hardware timestamped at the
device DMA layer.

Signed-off-by: Rahul Rameshbabu <rrameshbabu@nvidia.com>
Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
Link: https://lore.kernel.org/r/20240403212931.128541-4-rrameshbabu@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_stats.c
drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
drivers/net/ethernet/mellanox/mlx5/core/en_tx.c

index 5464cd9e2694a4498d42426e7af4a3ee525c2f21..fed821ef9b0940af4387df99e1b3f110afb0afa0 100644 (file)
@@ -300,6 +300,11 @@ the software port.
        in the beginning of the queue. This is a normal condition.
      - Informative
 
+   * - `tx[i]_timestamps`
+     - Transmitted packets that were hardware timestamped at the device's DMA
+       layer.
+     - Informative
+
    * - `tx[i]_added_vlan_packets`
      - The number of packets sent where vlan tag insertion was offloaded to the
        hardware.
index 3004778e253eb6fe0a9080682ae76f652693f037..aa1de8bf084102f70557551830dbf07f84e9b287 100644 (file)
@@ -2066,6 +2066,7 @@ static const struct counter_desc sq_stats_desc[] = {
        { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, csum_partial_inner) },
        { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, added_vlan_packets) },
        { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, nop) },
+       { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, timestamps) },
        { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, mpwqe_blks) },
        { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, mpwqe_pkts) },
 #ifdef CONFIG_MLX5_EN_TLS
@@ -2218,6 +2219,7 @@ static const struct counter_desc qos_sq_stats_desc[] = {
        { MLX5E_DECLARE_QOS_TX_STAT(struct mlx5e_sq_stats, csum_partial_inner) },
        { MLX5E_DECLARE_QOS_TX_STAT(struct mlx5e_sq_stats, added_vlan_packets) },
        { MLX5E_DECLARE_QOS_TX_STAT(struct mlx5e_sq_stats, nop) },
+       { MLX5E_DECLARE_QOS_TX_STAT(struct mlx5e_sq_stats, timestamps) },
        { MLX5E_DECLARE_QOS_TX_STAT(struct mlx5e_sq_stats, mpwqe_blks) },
        { MLX5E_DECLARE_QOS_TX_STAT(struct mlx5e_sq_stats, mpwqe_pkts) },
 #ifdef CONFIG_MLX5_EN_TLS
index ccc67a471f68aae70a52bd3d0fd00ecbfa6b39da..b0090ad133aaf9b796229542098675953885c792 100644 (file)
@@ -431,6 +431,7 @@ struct mlx5e_sq_stats {
        u64 stopped;
        u64 dropped;
        u64 recover;
+       u64 timestamps;
        /* dirtied @completion */
        u64 cqes ____cacheline_aligned_in_smp;
        u64 wake;
index 2fa076b23fbead06bceb6697e0ebb0238bb5be7e..09a592909101515a5fa26e49b8100ef974873267 100644 (file)
@@ -750,11 +750,13 @@ static void mlx5e_consume_skb(struct mlx5e_txqsq *sq, struct sk_buff *skb,
                u64 ts = get_cqe_ts(cqe);
 
                hwts.hwtstamp = mlx5e_cqe_ts_to_ns(sq->ptp_cyc2time, sq->clock, ts);
-               if (sq->ptpsq)
+               if (sq->ptpsq) {
                        mlx5e_skb_cb_hwtstamp_handler(skb, MLX5E_SKB_CB_CQE_HWTSTAMP,
                                                      hwts.hwtstamp, sq->ptpsq->cq_stats);
-               else
+               } else {
                        skb_tstamp_tx(skb, &hwts);
+                       sq->stats->timestamps++;
+               }
        }
 
        napi_consume_skb(skb, napi_budget);