Skip to contentSkip to conversation

ethtool: add support show/set-hwtstamp

PATCH Superseded Kevin(Yudong) Yang 4 participants 5 messages Sep 1, 2020 – Sep 2, 2020 1 message not in the archive

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ethtool: add support show/set-hwtstamp

Before this patch, ethtool has -T/--show-time-stamping that only shows the device's time stamping capabilities but not the time stamping policy that is used by the device.

This patch adds support to set/get device time stamping policy at the driver level by calling ioctl(SIOCSHWTSTAMP).

Tested: ran following cmds on a Mellanox NIC with mlx4_en driver:
./ethtool -T eth1
Hardware Transmit Timestamp Modes:
off (HWTSTAMP_TX_OFF)
on (HWTSTAMP_TX_ON)
Hardware Receive Filter Modes:
none (HWTSTAMP_FILTER_NONE)
all (HWTSTAMP_FILTER_ALL)

./ethtool --show-hwtstamp eth1;
Rx filter 0, none (HWTSTAMP_FILTER_NONE)
Tx type 0, off (HWTSTAMP_TX_OFF)

./ethtool --set-hwtstamp eth1 rx 1; ./ethtool --show-hwtstamp eth1;
Rx filter 1, all (HWTSTAMP_FILTER_ALL)
Tx type 0, off (HWTSTAMP_TX_OFF)

./ethtool --set-hwtstamp eth1 rx 1 tx 1; ./ethtool --show-hwtstamp eth1; rx unmodified, ignoring
Rx filter 1, all (HWTSTAMP_FILTER_ALL)
Tx type 1, on (HWTSTAMP_TX_ON)

./ethtool --set-hwtstamp eth1 rx 0; ./ethtool --show-hwtstamp eth1;
Rx filter 0, none (HWTSTAMP_FILTER_NONE)
Tx type 1, on (HWTSTAMP_TX_ON)

./ethtool --set-hwtstamp eth1 tx 0; ./ethtool --show-hwtstamp eth1
Rx filter 0, none (HWTSTAMP_FILTER_NONE)
Tx type 0, off (HWTSTAMP_TX_OFF)

./ethtool --set-hwtstamp eth1 rx 123 tx 456
rx should be in [0..15], tx should be in [0..2]

---
 ethtool.8.in | 14 +++++++++
 ethtool.c    | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 99 insertions(+)
ethtool.8.in +14 -0
index a50a476..c2d1b42 100644
@@ -315,6 +315,14 @@ ethtool \- query or control network driver and hardware settings
 .B ethtool \-T|\-\-show\-time\-stamping
 .I devname
 .HP
+.B ethtool \-\-show\-hwtstamp
+.I devname
+.HP
+.B ethtool \-\-set\-hwtstamp
+.I devname
+.BN rx
+.BN tx
+.HP
 .B ethtool \-x|\-\-show\-rxfh\-indir|\-\-show\-rxfh
 .I devname
 .HP
@@ -1026,6 +1034,12 @@ Sets the dump flag for the device.
 Show the device's time stamping capabilities and associated PTP
 hardware clock.
 .TP
+.B \-\-show\-hwtstamp
+Show the device's time stamping policy at the driver level.
+.TP
+.B \-\-set\-hwtstamp
+Set the device's time stamping policy at the driver level.
+.TP
 .B \-x \-\-show\-rxfh\-indir \-\-show\-rxfh
 Retrieves the receive flow hash indirection table and/or RSS hash key.
 .TP
ethtool.c +85 -0

97 lines not on this page · raw message

Signature · 1 line
2.28.0.402.g5ffc5be6b7-goog
#1 lore raw
Quoted 3 lines · Kevin(Yudong) Yang

Before this patch, ethtool has -T/--show-time-stamping that only shows the device's time stamping capabilities but not the time stamping policy that is used by the device.

Hi Kavin

How does this differ from hwstamp_ctl(1)?

Andrew

#3 lore raw
In reply to a message not in the archive
Quoted 9 lines · Kevin Yang

Hi Andrew,

They are pretty much the same, both use ioctl(SIOCSHWTSTAMP).

Adding this to ethtool is because:
- This time stamping policy is a hardware setting aligned with ethtool's purpose "query and control network device driver and hardware settings"
- ethtool is widely used, system administrators don't need to install another binary to control this feature.

Absolutely. ethtool has -T support already, and is the facto tool for things not covered by iproute2 suite.

Having to remember a myriad of binaries that basically use a single ioctl() is time consuming.

Quoted 14 lines

Kevin

Quoted 11 lines · Andrew Lunn
Quoted 3 lines · Kevin(Yudong) Yang

Before this patch, ethtool has -T/--show-time-stamping that only shows the device's time stamping capabilities but not the time stamping policy that is used by the device.

Hi Kavin

How does this differ from hwstamp_ctl(1)?

Andrew

#4 lore raw
In reply to a message not in the archive
Quoted 8 lines · Kevin Yang
Quoted 6 lines · Andrew Lunn
Quoted 3 lines · Kevin(Yudong) Yang

Before this patch, ethtool has -T/--show-time-stamping that only shows the device's time stamping capabilities but not the time stamping policy that is used by the device.

How does this differ from hwstamp_ctl(1)?

Quoted 7 lines

They are pretty much the same, both use ioctl(SIOCSHWTSTAMP).

Adding this to ethtool is because:
- This time stamping policy is a hardware setting aligned with ethtool's purpose "query and control network device driver and hardware settings"
- ethtool is widely used, system administrators don't need to install another binary to control this feature.

Adding this feature to ethtool IMHO makes good sense, I'm just not sure if it's necessary to add new subcommands, perhaps we could add the "show" part to -T / --show-time-stamping and add --set-time-stamping.

However, I don't like the idea of adding a new ioctl based interface to ethtool while we are working on replacing and deprecating existing one. I would much rather like adding this to the netlink interface (which would, of course, require also kernel side implementation).

Michal

author
#5 lore raw
Quoted 18 lines · Michal Kubecek
Quoted 8 lines · Kevin Yang
Quoted 6 lines · Andrew Lunn
Quoted 3 lines · Kevin(Yudong) Yang

Before this patch, ethtool has -T/--show-time-stamping that only shows the device's time stamping capabilities but not the time stamping policy that is used by the device.

How does this differ from hwstamp_ctl(1)?

Quoted 7 lines

They are pretty much the same, both use ioctl(SIOCSHWTSTAMP).

Adding this to ethtool is because:
- This time stamping policy is a hardware setting aligned with ethtool's purpose "query and control network device driver and hardware settings"
- ethtool is widely used, system administrators don't need to install another binary to control this feature.

Quoted 3 lines

Adding this feature to ethtool IMHO makes good sense, I'm just not sure if it's necessary to add new subcommands, perhaps we could add the "show" part to -T / --show-time-stamping and add --set-time-stamping.

Thanks for the nice suggestion. This sounds good to me, I will work on v2 to have:
"-T / --show-time-stamping" to show capabilities AND current policy; and "--set-time-stamping" to change the policy.

Quoted 6 lines

However, I don't like the idea of adding a new ioctl based interface to ethtool while we are working on replacing and deprecating existing one. I would much rather like adding this to the netlink interface (which would, of course, require also kernel side implementation).

Michal