netlink: tsconfig: add HW time stamping configuration
Subsystems (2)
PATCH v3 1/1 netlink: tsconfig: add HW time stamping configuration
The kernel supports configuring HW time stamping modes via netlink messages, but previous implementation added support for HW time stamping source configuration. Add support to configure TX/RX time stamping. We keep TX type and RX filter configuration as a bit value, but if we will need multibit value to be set in the future, there is an option to use "rx-filters" keyword which will be mutually exclusive with current "rx-filter" keyword. The same applies to "tx-type".
---
v2 -> v3:
* improve code style
v1 -> v2:
* improve commit message
--- ethtool.8.in | 12 +++++++- ethtool.c | 1 + netlink/tsconfig.c | 77 +++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 88 insertions(+), 2 deletions(-)
ethtool.8.in +11 -1
@@ -357,6 +357,10 @@ ethtool \- query or control network driver and hardware settings .IR N .BI qualifier .IR precise|approx ] +.RB [ tx +.IR TX-TYPE ] +.RB [ rx-filter +.IR RX-FILTER ] .HP .B ethtool \-x|\-\-show\-rxfh\-indir|\-\-show\-rxfh .I devname
@@ -1287,7 +1291,7 @@ for IEEE 1588 quality and "approx" is for NICs DMA point. Show the selected time stamping PTP hardware clock configuration. .TP .B \-\-set\-hwtimestamp\-cfg -Select the device's time stamping PTP hardware clock. +Sets the device's time stamping PTP hardware clock configuration. .RS 4 .TP .BI index \ N
@@ -1296,6 +1300,12 @@ Index of the ptp hardware clock .BI qualifier \ precise | approx Qualifier of the ptp hardware clock. Mainly "precise" the default one is for IEEE 1588 quality and "approx" is for NICs DMA point. +.TP +.BI tx \ TX-TYPE +Type of TX time stamping to configure +.TP +.BI rx-filter \ RX-FILTER +Type of RX time stamping filter to configure .RE .TP .B \-x \-\-show\-rxfh\-indir \-\-show\-rxfh
ethtool.c +1 -0
@@ -6068,6 +6068,7 @@ static const struct option args[] = { .nlfunc = nl_stsconfig, .help = "Select hardware time stamping", .xhelp =" [ index N qualifier precise|approx ]\n" +" [ tx TX-TYPE ] [ rx-filter RX-FILTER ]\n" }, { .opts = "-x|--show-rxfh-indir|--show-rxfh",
netlink/tsconfig.c +76 -1
101 lines not on this page · raw message
Signature · 1 line
2.47.3
Quoted 115 lines · On Fri, 7 Nov 2025 18:20:44 +0000 Vadim Fedorenko <[email protected]>…
The kernel supports configuring HW time stamping modes via netlink messages, but previous implementation added support for HW time stamping source configuration. Add support to configure TX/RX time stamping. We keep TX type and RX filter configuration as a bit value, but if we will need multibit value to be set in the future, there is an option to use "rx-filters" keyword which will be mutually exclusive with current "rx-filter" keyword. The same applies to "tx-type".
Signed-off-by Vadim Fedorenko <[email protected]>Reviewed-by Kory Maincent <[email protected]>---
v2 -> v3:
* improve code style
v1 -> v2:
* improve commit message--- ethtool.8.in | 12 +++++++- ethtool.c | 1 + netlink/tsconfig.c | 77 +++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 88 insertions(+), 2 deletions(-)ethtool.8.in +0
-0@@ -357,6 +357,10 @@ ethtool \- query or control network driver and hardwaresettings .IR N
.BI qualifier
.IR precise|approx ]
+.RB [ tx
+.IR TX-TYPE ]
+.RB [ rx-filter
+.IR RX-FILTER ]
.HP
.B ethtool \-x|\-\-show\-rxfh\-indir|\-\-show\-rxfh .I devnameethtool.8.in +0
-0@@ -1287,7 +1291,7 @@ for IEEE 1588 quality and "approx" is for NICs DMApoint. Show the selected time stamping PTP hardware clock configuration.
.TP
.B \-\-set\-hwtimestamp\-cfgethtool.8.in +7
-1-Select the device's time stamping PTP hardware clock. +Sets the device's time stamping PTP hardware clock configuration. .RS 4 .TP .BI index \ N@@ -1296,6 +1300,12 @@ Index of the ptp hardware clock .BI qualifier \ precise | approx Qualifier of the ptp hardware clock. Mainly "precise" the default one is for IEEE 1588 quality and "approx" is for NICs DMA point. +.TP +.BI tx \ TX-TYPE +Type of TX time stamping to configure +.TP +.BI rx-filter \ RX-FILTER +Type of RX time stamping filter to configure .RE .TP .B \-x \-\-show\-rxfh\-indir \-\-show\-rxfhethtool.c +0
-0@@ -6068,6 +6068,7 @@ static const struct option args[] = { .nlfunc = nl_stsconfig, .help = "Select hardware time stamping", .xhelp = " [ index N qualifierprecise|approx ]\n"
ethtool.c +1
-0+ " [ tx TX-TYPE ] [ rx-filterRX-FILTER ]\n" },
ethtool.c +0
-0{ .opts = "-x|--show-rxfh-indir|--show-rxfh",netlink/tsconfig.c +27
-0@@ -17,6 +17,7 @@#include "netlink.h" #include "bitset.h" #include "parser.h" +#include "strset.h" #include "ts.h" /* TSCONFIG_GET */ @@ -94,6 +95,66 @@ int nl_gtsconfig(struct cmd_context *ctx)/* TSCONFIG_SET */ +int tsconfig_txrx_parser (struct nl_context *nlctx,uint16_t type, +const void *data__maybe_unused , +struct nl_msg_buff *msgbuff, +void *dest__maybe_unused ) +{ +struct nlattr *bits_attr, *bit_attr; +const struct stringset *values; +const char *arg = *nlctx->argp; +unsigned int count, i; + + nlctx->argp++; + nlctx->argc--; +if (netlink_init_ethnl2_socket (nlctx) <0 ) +return -EIO ; + +switch (type) { +case ETHTOOL_A_TSCONFIG_TX_TYPES : + values =global_stringset (ETH_SS_TS_TX_TYPES , nlctx->ethnl2_socket); +break ; +case ETHTOOL_A_TSCONFIG_RX_FILTERS : + values =global_stringset (ETH_SS_TS_RX_FILTERS , nlctx->ethnl2_socket); +break ; +default : +return -EINVAL ; + } +
netlink/tsconfig.c int nl_gtsconfig(struct cmd_context *ctx) · line 135
Quoted 10 lines
netlink/tsconfig.c +10
-0+ count =get_count (values); +for (i =0 ; i < count; i++) { +const char *name =get_string (values, i); + +if (!strcmp (name, arg)) +break ; + } + +if (i != count) +return -EINVAL ;
It seems you update your patch too quickly and don't test it. It should be "if (i == count)" here.
Regards,
Signature · 3 lines
Köry Maincent, Bootlin Embedded Linux and kernel engineering https://bootlin.com
Quoted 123 lines · Kory Maincent
Quoted 120 lines · On Fri, 7 Nov 2025 18:20:44 +0000 Vadim Fedorenko <[email protected]>…
The kernel supports configuring HW time stamping modes via netlink messages, but previous implementation added support for HW time stamping source configuration. Add support to configure TX/RX time stamping. We keep TX type and RX filter configuration as a bit value, but if we will need multibit value to be set in the future, there is an option to use "rx-filters" keyword which will be mutually exclusive with current "rx-filter" keyword. The same applies to "tx-type".
Signed-off-by Vadim Fedorenko <[email protected]>Reviewed-by Kory Maincent <[email protected]>---
v2 -> v3:
* improve code style
v1 -> v2:
* improve commit message--- ethtool.8.in | 12 +++++++- ethtool.c | 1 + netlink/tsconfig.c | 77 +++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 88 insertions(+), 2 deletions(-)ethtool.8.in +0
-0@@ -357,6 +357,10 @@ ethtool \- query or control network driver and hardwaresettings .IR N
.BI qualifier
.IR precise|approx ]
+.RB [ tx
+.IR TX-TYPE ]
+.RB [ rx-filter
+.IR RX-FILTER ]
.HP
.B ethtool \-x|\-\-show\-rxfh\-indir|\-\-show\-rxfh .I devnameethtool.8.in +0
-0@@ -1287,7 +1291,7 @@ for IEEE 1588 quality and "approx" is for NICs DMApoint. Show the selected time stamping PTP hardware clock configuration.
.TP
.B \-\-set\-hwtimestamp\-cfgethtool.8.in +7
-1-Select the device's time stamping PTP hardware clock. +Sets the device's time stamping PTP hardware clock configuration. .RS 4 .TP .BI index \ N@@ -1296,6 +1300,12 @@ Index of the ptp hardware clock .BI qualifier \ precise | approx Qualifier of the ptp hardware clock. Mainly "precise" the default one is for IEEE 1588 quality and "approx" is for NICs DMA point. +.TP +.BI tx \ TX-TYPE +Type of TX time stamping to configure +.TP +.BI rx-filter \ RX-FILTER +Type of RX time stamping filter to configure .RE .TP .B \-x \-\-show\-rxfh\-indir \-\-show\-rxfhethtool.c +0
-0@@ -6068,6 +6068,7 @@ static const struct option args[] = { .nlfunc = nl_stsconfig, .help = "Select hardware time stamping", .xhelp = " [ index N qualifierprecise|approx ]\n"
ethtool.c +1
-0+ " [ tx TX-TYPE ] [ rx-filterRX-FILTER ]\n" },
{
.opts = "-x|--show-rxfh-indir|--show-rxfh",netlink/tsconfig.c +32
-0@@ -17,6 +17,7 @@#include "netlink.h" #include "bitset.h" #include "parser.h" +#include "strset.h" #include "ts.h" /* TSCONFIG_GET */ @@ -94,6 +95,66 @@ int nl_gtsconfig(struct cmd_context *ctx)/* TSCONFIG_SET */ +int tsconfig_txrx_parser (struct nl_context *nlctx,uint16_t type, +const void *data__maybe_unused , +struct nl_msg_buff *msgbuff, +void *dest__maybe_unused ) +{ +struct nlattr *bits_attr, *bit_attr; +const struct stringset *values; +const char *arg = *nlctx->argp; +unsigned int count, i; + + nlctx->argp++; + nlctx->argc--; +if (netlink_init_ethnl2_socket (nlctx) <0 ) +return -EIO ; + +switch (type) { +case ETHTOOL_A_TSCONFIG_TX_TYPES : + values =global_stringset (ETH_SS_TS_TX_TYPES , nlctx->ethnl2_socket); +break ; +case ETHTOOL_A_TSCONFIG_RX_FILTERS : + values =global_stringset (ETH_SS_TS_RX_FILTERS , nlctx->ethnl2_socket); +break ; +default : +return -EINVAL ; + } + + count =get_count (values); +for (i =0 ; i < count; i++) { +const char *name =get_string (values, i); + +if (!strcmp (name, arg))
Quoted 8 lines
netlink/tsconfig.c int nl_gtsconfig(struct cmd_context *ctx) · line 133
Quoted 5 lines
netlink/tsconfig.c +5
-0+break ; + } + +if (i != count) +return -EINVAL ;It seems you update your patch too quickly and don't test it. It should be "if (i == count)" here.
You are right, thanks for catching it.
v4 is on the way.