Commit 571faefe authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge branch 'ethtool-hw-timestamping-statistics'

Rahul Rameshbabu says:

====================
ethtool HW timestamping statistics

The goal of this patch series is to introduce a common set of ethtool
statistics for hardware timestamping that a driver implementer can hook into.
The statistics counters added are based on what I believe are common
patterns/behaviors found across various hardware timestamping implementations
seen in the kernel tree today. The mlx5 family of devices is used
as the PoC for this patch series. Other vendors are more than welcome
to chime in on this series.

Link: https://lore.kernel.org/netdev/20240402205223.137565-1-rrameshbabu@nvidia.com/
Link: https://lore.kernel.org/netdev/20240309084440.299358-1-rrameshbabu@nvidia.com/
Link: https://lore.kernel.org/netdev/20240223192658.45893-1-rrameshbabu@nvidia.com/


Signed-off-by: default avatarRahul Rameshbabu <rrameshbabu@nvidia.com>
====================

Link: https://lore.kernel.org/r/20240403212931.128541-1-rrameshbabu@nvidia.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 4196aee0 2e0e148c
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ definitions:
    entries: []
  -
    name: header-flags
    enum-name:
    type: flags
    entries: [ compact-bitsets, omit-reply, stats ]

@@ -565,6 +564,18 @@ attribute-sets:
      -
        name: tx-lpi-timer
        type: u32
  -
    name: ts-stat
    attributes:
      -
        name: tx-pkts
        type: uint
      -
        name: tx-lost
        type: uint
      -
        name: tx-err
        type: uint
  -
    name: tsinfo
    attributes:
@@ -587,6 +598,10 @@ attribute-sets:
      -
        name: phc-index
        type: u32
      -
        name: stats
        type: nest
        nested-attributes: ts-stat
  -
    name: cable-result
    attributes:
@@ -1394,6 +1409,7 @@ operations:
            - tx-types
            - rx-filters
            - phc-index
            - stats
      dump: *tsinfo-get-op
    -
      name: cable-test-act
+11 −0
Original line number Diff line number Diff line
@@ -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.
@@ -702,6 +707,12 @@ the software port.
       the device typically ensures not posting the CQE.
     - Error

   * - `ptp_cq[i]_lost_cqe`
     - Number of times a CQE is expected to not be delivered on the PTP
       timestamping CQE by the device due to a time delta elapsing. If such a
       CQE is somehow delivered, `ptp_cq[i]_late_cqe` is incremented.
     - Error

.. [#ring_global] The corresponding ring and global counters do not share the
                  same name (i.e. do not follow the common naming scheme).

+9 −0
Original line number Diff line number Diff line
@@ -1237,12 +1237,21 @@ Kernel response contents:
  ``ETHTOOL_A_TSINFO_TX_TYPES``          bitset  supported Tx types
  ``ETHTOOL_A_TSINFO_RX_FILTERS``        bitset  supported Rx filters
  ``ETHTOOL_A_TSINFO_PHC_INDEX``         u32     PTP hw clock index
  ``ETHTOOL_A_TSINFO_STATS``             nested  HW timestamping statistics
  =====================================  ======  ==========================

``ETHTOOL_A_TSINFO_PHC_INDEX`` is absent if there is no associated PHC (there
is no special value for this case). The bitset attributes are omitted if they
would be empty (no bit set).

Additional hardware timestamping statistics response contents:

  =====================================  ======  ===================================
  ``ETHTOOL_A_TS_STAT_TX_PKTS``          u64     Packets with Tx HW timestamps
  ``ETHTOOL_A_TS_STAT_TX_LOST``          u64     Tx HW timestamp not arrived count
  ``ETHTOOL_A_TS_STAT_TX_ERR``           u64     HW error request Tx timestamp count
  =====================================  ======  ===================================

CABLE_TEST
==========

+1 −0
Original line number Diff line number Diff line
@@ -169,6 +169,7 @@ static void mlx5e_ptpsq_mark_ts_cqes_undelivered(struct mlx5e_ptpsq *ptpsq,
		WARN_ON_ONCE(!pos->inuse);
		pos->inuse = false;
		list_del(&pos->entry);
		ptpsq->cq_stats->lost_cqe++;
	}
	spin_unlock_bh(&cqe_list->tracker_list_lock);
}
+9 −0
Original line number Diff line number Diff line
@@ -2387,6 +2387,14 @@ static void mlx5e_get_rmon_stats(struct net_device *netdev,
	mlx5e_stats_rmon_get(priv, rmon_stats, ranges);
}

static void mlx5e_get_ts_stats(struct net_device *netdev,
			       struct ethtool_ts_stats *ts_stats)
{
	struct mlx5e_priv *priv = netdev_priv(netdev);

	mlx5e_stats_ts_get(priv, ts_stats);
}

const struct ethtool_ops mlx5e_ethtool_ops = {
	.cap_rss_ctx_supported	= true,
	.supported_coalesce_params = ETHTOOL_COALESCE_USECS |
@@ -2436,5 +2444,6 @@ const struct ethtool_ops mlx5e_ethtool_ops = {
	.get_eth_mac_stats = mlx5e_get_eth_mac_stats,
	.get_eth_ctrl_stats = mlx5e_get_eth_ctrl_stats,
	.get_rmon_stats    = mlx5e_get_rmon_stats,
	.get_ts_stats      = mlx5e_get_ts_stats,
	.get_link_ext_stats = mlx5e_get_link_ext_stats
};
Loading