Skip to content

Commit 6a128cd

Browse files
vladimirolteankuba-moo
authored andcommitted
net: ethtool: ts: add separate counter for unconfirmed one-step TX timestamps
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 <[email protected]> Reviewed-by: Jakub Kicinski <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 19e1e17 commit 6a128cd

File tree

5 files changed

+24
-5
lines changed

5 files changed

+24
-5
lines changed

Documentation/netlink/specs/ethtool.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,9 @@ attribute-sets:
842842
-
843843
name: tx-err
844844
type: uint
845+
-
846+
name: tx-onestep-pkts-unconfirmed
847+
type: uint
845848
-
846849
name: ts-hwtstamp-provider
847850
attr-cnt-name: __ethtool-a-ts-hwtstamp-provider-cnt

Documentation/networking/ethtool-netlink.rst

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,11 +1281,17 @@ would be empty (no bit set).
12811281

12821282
Additional hardware timestamping statistics response contents:
12831283

1284-
===================================== ====== ===================================
1285-
``ETHTOOL_A_TS_STAT_TX_PKTS`` uint Packets with Tx HW timestamps
1286-
``ETHTOOL_A_TS_STAT_TX_LOST`` uint Tx HW timestamp not arrived count
1287-
``ETHTOOL_A_TS_STAT_TX_ERR`` uint HW error request Tx timestamp count
1288-
===================================== ====== ===================================
1284+
================================================== ====== =====================
1285+
``ETHTOOL_A_TS_STAT_TX_PKTS`` uint Packets with Tx
1286+
HW timestamps
1287+
``ETHTOOL_A_TS_STAT_TX_LOST`` uint Tx HW timestamp
1288+
not arrived count
1289+
``ETHTOOL_A_TS_STAT_TX_ERR`` uint HW error request
1290+
Tx timestamp count
1291+
``ETHTOOL_A_TS_STAT_TX_ONESTEP_PKTS_UNCONFIRMED`` uint Packets with one-step
1292+
HW TX timestamps with
1293+
unconfirmed delivery
1294+
================================================== ====== =====================
12891295

12901296
CABLE_TEST
12911297
==========

include/linux/ethtool.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,12 @@ struct ethtool_rmon_stats {
559559
/**
560560
* struct ethtool_ts_stats - HW timestamping statistics
561561
* @pkts: Number of packets successfully timestamped by the hardware.
562+
* @onestep_pkts_unconfirmed: Number of PTP packets with one-step TX
563+
* timestamping that were sent, but for which the
564+
* device offers no confirmation whether they made
565+
* it onto the wire and the timestamp was inserted
566+
* in the originTimestamp or correctionField, or
567+
* not.
562568
* @lost: Number of hardware timestamping requests where the timestamping
563569
* information from the hardware never arrived for submission with
564570
* the skb.
@@ -571,6 +577,7 @@ struct ethtool_rmon_stats {
571577
struct ethtool_ts_stats {
572578
struct_group(tx_stats,
573579
u64 pkts;
580+
u64 onestep_pkts_unconfirmed;
574581
u64 lost;
575582
u64 err;
576583
);

include/uapi/linux/ethtool_netlink_generated.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ enum {
382382
ETHTOOL_A_TS_STAT_TX_PKTS,
383383
ETHTOOL_A_TS_STAT_TX_LOST,
384384
ETHTOOL_A_TS_STAT_TX_ERR,
385+
ETHTOOL_A_TS_STAT_TX_ONESTEP_PKTS_UNCONFIRMED,
385386

386387
__ETHTOOL_A_TS_STAT_CNT,
387388
ETHTOOL_A_TS_STAT_MAX = (__ETHTOOL_A_TS_STAT_CNT - 1)

net/ethtool/tsinfo.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ static int tsinfo_put_stats(struct sk_buff *skb,
186186

187187
if (tsinfo_put_stat(skb, stats->tx_stats.pkts,
188188
ETHTOOL_A_TS_STAT_TX_PKTS) ||
189+
tsinfo_put_stat(skb, stats->tx_stats.onestep_pkts_unconfirmed,
190+
ETHTOOL_A_TS_STAT_TX_ONESTEP_PKTS_UNCONFIRMED) ||
189191
tsinfo_put_stat(skb, stats->tx_stats.lost,
190192
ETHTOOL_A_TS_STAT_TX_LOST) ||
191193
tsinfo_put_stat(skb, stats->tx_stats.err,

0 commit comments

Comments
 (0)