]> www.infradead.org Git - users/hch/misc.git/commitdiff
net: ethtool: ts: add separate counter for unconfirmed one-step TX timestamps
authorVladimir Oltean <vladimir.oltean@nxp.com>
Thu, 16 Jan 2025 10:46:25 +0000 (12:46 +0200)
committerJakub Kicinski <kuba@kernel.org>
Sat, 18 Jan 2025 04:01:09 +0000 (20:01 -0800)
For packets with two-step timestamp requests, the hardware timestamp
comes back to the driver through a confirmation mechanism of sorts,
which allows the driver to confidently bump the successful "pkts"
counter.

For one-step PTP, the NIC is supposed to autonomously insert its
hardware TX timestamp in the packet headers while simultaneously
transmitting it. There may be a confirmation that this was done
successfully, or there may not.

None of the current drivers which implement ethtool_ops :: get_ts_stats()
also support HWTSTAMP_TX_ONESTEP_SYNC or HWTSTAMP_TX_ONESTEP_SYNC, so it
is a bit unclear which model to follow. But there are NICs, such as DSA,
where there is no transmit confirmation at all. Here, it would be wrong /
misleading to increment the successful "pkts" counter, because one-step
PTP packets can be dropped on TX just like any other packets.

So introduce a special counter which signifies "yes, an attempt was made,
but we don't know whether it also exited the port or not". I expect that
for one-step PTP packets where a confirmation is available, the "pkts"
counter would be bumped.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Link: https://patch.msgid.link/20250116104628.123555-2-vladimir.oltean@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Documentation/netlink/specs/ethtool.yaml
Documentation/networking/ethtool-netlink.rst
include/linux/ethtool.h
include/uapi/linux/ethtool_netlink_generated.h
net/ethtool/tsinfo.c

index 66be040130481900a6d26c160212e9f519e2885a..259cb211a3382fd5f52a53232907915a3e29c00c 100644 (file)
@@ -842,6 +842,9 @@ attribute-sets:
       -
         name: tx-err
         type: uint
+      -
+        name: tx-onestep-pkts-unconfirmed
+        type: uint
   -
     name: ts-hwtstamp-provider
     attr-cnt-name: __ethtool-a-ts-hwtstamp-provider-cnt
index f70c0249860cd5f2555bf163e4e7f3ed6e7aea0a..3770a22945097faab4553dbc48fc44603e5e3862 100644 (file)
@@ -1281,11 +1281,17 @@ would be empty (no bit set).
 
 Additional hardware timestamping statistics response contents:
 
-  =====================================  ======  ===================================
-  ``ETHTOOL_A_TS_STAT_TX_PKTS``          uint    Packets with Tx HW timestamps
-  ``ETHTOOL_A_TS_STAT_TX_LOST``          uint    Tx HW timestamp not arrived count
-  ``ETHTOOL_A_TS_STAT_TX_ERR``           uint    HW error request Tx timestamp count
-  =====================================  ======  ===================================
+  ==================================================  ======  =====================
+  ``ETHTOOL_A_TS_STAT_TX_PKTS``                       uint    Packets with Tx
+                                                              HW timestamps
+  ``ETHTOOL_A_TS_STAT_TX_LOST``                       uint    Tx HW timestamp
+                                                              not arrived count
+  ``ETHTOOL_A_TS_STAT_TX_ERR``                        uint    HW error request
+                                                              Tx timestamp count
+  ``ETHTOOL_A_TS_STAT_TX_ONESTEP_PKTS_UNCONFIRMED``   uint    Packets with one-step
+                                                              HW TX timestamps with
+                                                              unconfirmed delivery
+  ==================================================  ======  =====================
 
 CABLE_TEST
 ==========
index e4136b0df89236de03174c8d1197bb2f076b20dd..64301ddf2f598337f79612dc1e90001e493377ac 100644 (file)
@@ -559,6 +559,12 @@ struct ethtool_rmon_stats {
 /**
  * struct ethtool_ts_stats - HW timestamping statistics
  * @pkts: Number of packets successfully timestamped by the hardware.
+ * @onestep_pkts_unconfirmed: Number of PTP packets with one-step TX
+ *                           timestamping that were sent, but for which the
+ *                           device offers no confirmation whether they made
+ *                           it onto the wire and the timestamp was inserted
+ *                           in the originTimestamp or correctionField, or
+ *                           not.
  * @lost: Number of hardware timestamping requests where the timestamping
  *     information from the hardware never arrived for submission with
  *     the skb.
@@ -571,6 +577,7 @@ struct ethtool_rmon_stats {
 struct ethtool_ts_stats {
        struct_group(tx_stats,
                u64 pkts;
+               u64 onestep_pkts_unconfirmed;
                u64 lost;
                u64 err;
        );
index 2e17ff348f89e304d5888cf381b428afcf4f6f1a..fe24c3459ac0f2afb317629b9ab594cb3b3dbe5b 100644 (file)
@@ -382,6 +382,7 @@ enum {
        ETHTOOL_A_TS_STAT_TX_PKTS,
        ETHTOOL_A_TS_STAT_TX_LOST,
        ETHTOOL_A_TS_STAT_TX_ERR,
+       ETHTOOL_A_TS_STAT_TX_ONESTEP_PKTS_UNCONFIRMED,
 
        __ETHTOOL_A_TS_STAT_CNT,
        ETHTOOL_A_TS_STAT_MAX = (__ETHTOOL_A_TS_STAT_CNT - 1)
index 7e495a41aeec54c8e24cd16555f3a9470cf11ab9..691be6c445b3816e32c97388aa9d4fbf3386b35c 100644 (file)
@@ -186,6 +186,8 @@ static int tsinfo_put_stats(struct sk_buff *skb,
 
        if (tsinfo_put_stat(skb, stats->tx_stats.pkts,
                            ETHTOOL_A_TS_STAT_TX_PKTS) ||
+           tsinfo_put_stat(skb, stats->tx_stats.onestep_pkts_unconfirmed,
+                           ETHTOOL_A_TS_STAT_TX_ONESTEP_PKTS_UNCONFIRMED) ||
            tsinfo_put_stat(skb, stats->tx_stats.lost,
                            ETHTOOL_A_TS_STAT_TX_LOST) ||
            tsinfo_put_stat(skb, stats->tx_stats.err,