* [PATCH net-next v2 0/7] convert net drivers to ndo_hwtstamp API part 1
@ 2025-10-14 22:42 Vadim Fedorenko
2025-10-14 22:42 ` [PATCH net-next v2 1/7] net: ti: am65-cpsw: move hw timestamping to ndo callback Vadim Fedorenko
` (6 more replies)
0 siblings, 7 replies; 29+ messages in thread
From: Vadim Fedorenko @ 2025-10-14 22:42 UTC (permalink / raw)
To: Shyam Sundar S K, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Egor Pomozov, Potnuri Bharat Teja,
Dimitris Michailidis, MD Danish Anwar, Roger Quadros
Cc: Richard Cochran, Russell King, Vladimir Oltean, Simon Horman,
netdev, Vadim Fedorenko
This is part 1 of patchset to convert drivers which support HW
timestamping to use .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks.
The new API uses netlink to communicate with user-space and have some
test coverage. Part 2 will contain another 6 patches from v1 of the
series.
There are some drivers left with old ioctl interface after this series:
- mlx5 driver be shortly converted by nVidia folks
- TI netcp ethss driver which needs separate series which I'll post
after this one.
v1 -> v2:
- split series into 2 to avoid spamming a lot of maintainers
Vadim Fedorenko (7):
net: ti: am65-cpsw: move hw timestamping to ndo callback
ti: icssg: convert to ndo_hwtstamp API
amd-xgbe: convert to ndo_hwtstamp callbacks
net: atlantic: convert to ndo_hwtstamp API
cxgb4: convert to ndo_hwtstamp API
tsnep: convert to ndo_hwtstatmp API
funeth: convert to ndo_hwtstamp API
drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 24 +--
drivers/net/ethernet/amd/xgbe/xgbe-hwtstamp.c | 28 ++--
drivers/net/ethernet/amd/xgbe/xgbe.h | 11 +-
.../net/ethernet/aquantia/atlantic/aq_main.c | 66 ++------
.../net/ethernet/aquantia/atlantic/aq_ptp.c | 6 +-
.../net/ethernet/aquantia/atlantic/aq_ptp.h | 8 +-
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | 2 +-
.../net/ethernet/chelsio/cxgb4/cxgb4_main.c | 154 +++++++++---------
drivers/net/ethernet/engleder/tsnep.h | 8 +-
drivers/net/ethernet/engleder/tsnep_main.c | 14 +-
drivers/net/ethernet/engleder/tsnep_ptp.c | 88 +++++-----
drivers/net/ethernet/fungible/funeth/funeth.h | 4 +-
.../ethernet/fungible/funeth/funeth_main.c | 40 ++---
drivers/net/ethernet/ti/am65-cpsw-nuss.c | 44 +++--
drivers/net/ethernet/ti/icssg/icssg_common.c | 47 ++----
drivers/net/ethernet/ti/icssg/icssg_prueth.c | 4 +-
drivers/net/ethernet/ti/icssg/icssg_prueth.h | 6 +-
.../net/ethernet/ti/icssg/icssg_prueth_sr1.c | 4 +-
18 files changed, 235 insertions(+), 323 deletions(-)
--
2.47.3
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH net-next v2 1/7] net: ti: am65-cpsw: move hw timestamping to ndo callback
2025-10-14 22:42 [PATCH net-next v2 0/7] convert net drivers to ndo_hwtstamp API part 1 Vadim Fedorenko
@ 2025-10-14 22:42 ` Vadim Fedorenko
2025-10-15 14:39 ` Simon Horman
2025-10-15 19:45 ` Jacob Keller
2025-10-14 22:42 ` [PATCH net-next v2 2/7] ti: icssg: convert to ndo_hwtstamp API Vadim Fedorenko
` (5 subsequent siblings)
6 siblings, 2 replies; 29+ messages in thread
From: Vadim Fedorenko @ 2025-10-14 22:42 UTC (permalink / raw)
To: Shyam Sundar S K, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Egor Pomozov, Potnuri Bharat Teja,
Dimitris Michailidis, MD Danish Anwar, Roger Quadros
Cc: Richard Cochran, Russell King, Vladimir Oltean, Simon Horman,
netdev, Vadim Fedorenko
Migrate driver to new API for HW timestamping.
Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
---
drivers/net/ethernet/ti/am65-cpsw-nuss.c | 44 +++++++++++-------------
1 file changed, 20 insertions(+), 24 deletions(-)
diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
index 110eb2da8dbc..d5f358ec9820 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
@@ -1788,28 +1788,28 @@ static int am65_cpsw_nuss_ndo_slave_set_mac_address(struct net_device *ndev,
}
static int am65_cpsw_nuss_hwtstamp_set(struct net_device *ndev,
- struct ifreq *ifr)
+ struct kernel_hwtstamp_config *cfg,
+ struct netlink_ext_ack *extack)
{
struct am65_cpsw_port *port = am65_ndev_to_port(ndev);
u32 ts_ctrl, seq_id, ts_ctrl_ltype2, ts_vlan_ltype;
- struct hwtstamp_config cfg;
- if (!IS_ENABLED(CONFIG_TI_K3_AM65_CPTS))
+ if (!IS_ENABLED(CONFIG_TI_K3_AM65_CPTS)) {
+ NL_SET_ERR_MSG(extack, "Time stamping is not supported");
return -EOPNOTSUPP;
-
- if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg)))
- return -EFAULT;
+ }
/* TX HW timestamp */
- switch (cfg.tx_type) {
+ switch (cfg->tx_type) {
case HWTSTAMP_TX_OFF:
case HWTSTAMP_TX_ON:
break;
default:
+ NL_SET_ERR_MSG(extack, "TX mode is not supported");
return -ERANGE;
}
- switch (cfg.rx_filter) {
+ switch (cfg->rx_filter) {
case HWTSTAMP_FILTER_NONE:
port->rx_ts_enabled = false;
break;
@@ -1826,17 +1826,19 @@ static int am65_cpsw_nuss_hwtstamp_set(struct net_device *ndev,
case HWTSTAMP_FILTER_PTP_V2_SYNC:
case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ:
port->rx_ts_enabled = true;
- cfg.rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT | HWTSTAMP_FILTER_PTP_V1_L4_EVENT;
+ cfg->rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT | HWTSTAMP_FILTER_PTP_V1_L4_EVENT;
break;
case HWTSTAMP_FILTER_ALL:
case HWTSTAMP_FILTER_SOME:
case HWTSTAMP_FILTER_NTP_ALL:
+ NL_SET_ERR_MSG(extack, "RX filter is not supported");
return -EOPNOTSUPP;
default:
+ NL_SET_ERR_MSG(extack, "RX filter is not supported");
return -ERANGE;
}
- port->tx_ts_enabled = (cfg.tx_type == HWTSTAMP_TX_ON);
+ port->tx_ts_enabled = (cfg->tx_type == HWTSTAMP_TX_ON);
/* cfg TX timestamp */
seq_id = (AM65_CPSW_TS_SEQ_ID_OFFSET <<
@@ -1872,25 +1874,24 @@ static int am65_cpsw_nuss_hwtstamp_set(struct net_device *ndev,
AM65_CPSW_PORTN_REG_TS_CTL_LTYPE2);
writel(ts_ctrl, port->port_base + AM65_CPSW_PORTN_REG_TS_CTL);
- return copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0;
+ return 0;
}
static int am65_cpsw_nuss_hwtstamp_get(struct net_device *ndev,
- struct ifreq *ifr)
+ struct kernel_hwtstamp_config *cfg)
{
struct am65_cpsw_port *port = am65_ndev_to_port(ndev);
- struct hwtstamp_config cfg;
if (!IS_ENABLED(CONFIG_TI_K3_AM65_CPTS))
return -EOPNOTSUPP;
- cfg.flags = 0;
- cfg.tx_type = port->tx_ts_enabled ?
+ cfg->flags = 0;
+ cfg->tx_type = port->tx_ts_enabled ?
HWTSTAMP_TX_ON : HWTSTAMP_TX_OFF;
- cfg.rx_filter = port->rx_ts_enabled ? HWTSTAMP_FILTER_PTP_V2_EVENT |
+ cfg->rx_filter = port->rx_ts_enabled ? HWTSTAMP_FILTER_PTP_V2_EVENT |
HWTSTAMP_FILTER_PTP_V1_L4_EVENT : HWTSTAMP_FILTER_NONE;
- return copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0;
+ return 0;
}
static int am65_cpsw_nuss_ndo_slave_ioctl(struct net_device *ndev,
@@ -1901,13 +1902,6 @@ static int am65_cpsw_nuss_ndo_slave_ioctl(struct net_device *ndev,
if (!netif_running(ndev))
return -EINVAL;
- switch (cmd) {
- case SIOCSHWTSTAMP:
- return am65_cpsw_nuss_hwtstamp_set(ndev, req);
- case SIOCGHWTSTAMP:
- return am65_cpsw_nuss_hwtstamp_get(ndev, req);
- }
-
return phylink_mii_ioctl(port->slave.phylink, req, cmd);
}
@@ -1991,6 +1985,8 @@ static const struct net_device_ops am65_cpsw_nuss_netdev_ops = {
.ndo_set_tx_maxrate = am65_cpsw_qos_ndo_tx_p0_set_maxrate,
.ndo_bpf = am65_cpsw_ndo_bpf,
.ndo_xdp_xmit = am65_cpsw_ndo_xdp_xmit,
+ .ndo_hwtstamp_get = am65_cpsw_nuss_hwtstamp_get,
+ .ndo_hwtstamp_set = am65_cpsw_nuss_hwtstamp_set,
};
static void am65_cpsw_disable_phy(struct phy *phy)
--
2.47.3
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH net-next v2 2/7] ti: icssg: convert to ndo_hwtstamp API
2025-10-14 22:42 [PATCH net-next v2 0/7] convert net drivers to ndo_hwtstamp API part 1 Vadim Fedorenko
2025-10-14 22:42 ` [PATCH net-next v2 1/7] net: ti: am65-cpsw: move hw timestamping to ndo callback Vadim Fedorenko
@ 2025-10-14 22:42 ` Vadim Fedorenko
2025-10-15 14:39 ` Simon Horman
2025-10-15 19:46 ` Jacob Keller
2025-10-14 22:42 ` [PATCH net-next v2 3/7] amd-xgbe: convert to ndo_hwtstamp callbacks Vadim Fedorenko
` (4 subsequent siblings)
6 siblings, 2 replies; 29+ messages in thread
From: Vadim Fedorenko @ 2025-10-14 22:42 UTC (permalink / raw)
To: Shyam Sundar S K, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Egor Pomozov, Potnuri Bharat Teja,
Dimitris Michailidis, MD Danish Anwar, Roger Quadros
Cc: Richard Cochran, Russell King, Vladimir Oltean, Simon Horman,
netdev, Vadim Fedorenko
Convert driver to use .ndo_hwtstamp_get()/.ndo_hwtstamp_set() API.
.ndo_eth_ioctl() implementation becomes pure phy_do_ioctl(), remove
it from common module, remove exported symbol and replace ndo callback.
Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
---
drivers/net/ethernet/ti/icssg/icssg_common.c | 47 ++++++-------------
drivers/net/ethernet/ti/icssg/icssg_prueth.c | 4 +-
drivers/net/ethernet/ti/icssg/icssg_prueth.h | 6 ++-
.../net/ethernet/ti/icssg/icssg_prueth_sr1.c | 4 +-
4 files changed, 26 insertions(+), 35 deletions(-)
diff --git a/drivers/net/ethernet/ti/icssg/icssg_common.c b/drivers/net/ethernet/ti/icssg/icssg_common.c
index 57e5f1c88f50..0eed29d6187a 100644
--- a/drivers/net/ethernet/ti/icssg/icssg_common.c
+++ b/drivers/net/ethernet/ti/icssg/icssg_common.c
@@ -1223,15 +1223,13 @@ void icssg_ndo_tx_timeout(struct net_device *ndev, unsigned int txqueue)
}
EXPORT_SYMBOL_GPL(icssg_ndo_tx_timeout);
-static int emac_set_ts_config(struct net_device *ndev, struct ifreq *ifr)
+int icssg_ndo_set_ts_config(struct net_device *ndev,
+ struct kernel_hwtstamp_config *config,
+ struct netlink_ext_ack *extack)
{
struct prueth_emac *emac = netdev_priv(ndev);
- struct hwtstamp_config config;
- if (copy_from_user(&config, ifr->ifr_data, sizeof(config)))
- return -EFAULT;
-
- switch (config.tx_type) {
+ switch (config->tx_type) {
case HWTSTAMP_TX_OFF:
emac->tx_ts_enabled = 0;
break;
@@ -1242,7 +1240,7 @@ static int emac_set_ts_config(struct net_device *ndev, struct ifreq *ifr)
return -ERANGE;
}
- switch (config.rx_filter) {
+ switch (config->rx_filter) {
case HWTSTAMP_FILTER_NONE:
emac->rx_ts_enabled = 0;
break;
@@ -1262,43 +1260,28 @@ static int emac_set_ts_config(struct net_device *ndev, struct ifreq *ifr)
case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ:
case HWTSTAMP_FILTER_NTP_ALL:
emac->rx_ts_enabled = 1;
- config.rx_filter = HWTSTAMP_FILTER_ALL;
+ config->rx_filter = HWTSTAMP_FILTER_ALL;
break;
default:
return -ERANGE;
}
- return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ?
- -EFAULT : 0;
+ return 0;
}
+EXPORT_SYMBOL_GPL(icssg_ndo_set_ts_config);
-static int emac_get_ts_config(struct net_device *ndev, struct ifreq *ifr)
+int icssg_ndo_get_ts_config(struct net_device *ndev,
+ struct kernel_hwtstamp_config *config)
{
struct prueth_emac *emac = netdev_priv(ndev);
- struct hwtstamp_config config;
-
- config.flags = 0;
- config.tx_type = emac->tx_ts_enabled ? HWTSTAMP_TX_ON : HWTSTAMP_TX_OFF;
- config.rx_filter = emac->rx_ts_enabled ? HWTSTAMP_FILTER_ALL : HWTSTAMP_FILTER_NONE;
-
- return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ?
- -EFAULT : 0;
-}
-int icssg_ndo_ioctl(struct net_device *ndev, struct ifreq *ifr, int cmd)
-{
- switch (cmd) {
- case SIOCGHWTSTAMP:
- return emac_get_ts_config(ndev, ifr);
- case SIOCSHWTSTAMP:
- return emac_set_ts_config(ndev, ifr);
- default:
- break;
- }
+ config->flags = 0;
+ config->tx_type = emac->tx_ts_enabled ? HWTSTAMP_TX_ON : HWTSTAMP_TX_OFF;
+ config->rx_filter = emac->rx_ts_enabled ? HWTSTAMP_FILTER_ALL : HWTSTAMP_FILTER_NONE;
- return phy_do_ioctl(ndev, ifr, cmd);
+ return 0;
}
-EXPORT_SYMBOL_GPL(icssg_ndo_ioctl);
+EXPORT_SYMBOL_GPL(icssg_ndo_get_ts_config);
void icssg_ndo_get_stats64(struct net_device *ndev,
struct rtnl_link_stats64 *stats)
diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.c b/drivers/net/ethernet/ti/icssg/icssg_prueth.c
index e42d0fdefee1..1c1f4394ff1f 100644
--- a/drivers/net/ethernet/ti/icssg/icssg_prueth.c
+++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.c
@@ -1168,7 +1168,7 @@ static const struct net_device_ops emac_netdev_ops = {
.ndo_validate_addr = eth_validate_addr,
.ndo_tx_timeout = icssg_ndo_tx_timeout,
.ndo_set_rx_mode = emac_ndo_set_rx_mode,
- .ndo_eth_ioctl = icssg_ndo_ioctl,
+ .ndo_eth_ioctl = phy_do_ioctl,
.ndo_get_stats64 = icssg_ndo_get_stats64,
.ndo_get_phys_port_name = icssg_ndo_get_phys_port_name,
.ndo_fix_features = emac_ndo_fix_features,
@@ -1176,6 +1176,8 @@ static const struct net_device_ops emac_netdev_ops = {
.ndo_vlan_rx_kill_vid = emac_ndo_vlan_rx_del_vid,
.ndo_bpf = emac_ndo_bpf,
.ndo_xdp_xmit = emac_xdp_xmit,
+ .ndo_hwtstamp_get = icssg_ndo_get_ts_config,
+ .ndo_hwtstamp_set = icssg_ndo_set_ts_config,
};
static int prueth_netdev_init(struct prueth *prueth,
diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.h b/drivers/net/ethernet/ti/icssg/icssg_prueth.h
index ca8a22a4a5da..f0fa9688d9a0 100644
--- a/drivers/net/ethernet/ti/icssg/icssg_prueth.h
+++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.h
@@ -479,7 +479,11 @@ void prueth_reset_tx_chan(struct prueth_emac *emac, int ch_num,
void prueth_reset_rx_chan(struct prueth_rx_chn *chn,
int num_flows, bool disable);
void icssg_ndo_tx_timeout(struct net_device *ndev, unsigned int txqueue);
-int icssg_ndo_ioctl(struct net_device *ndev, struct ifreq *ifr, int cmd);
+int icssg_ndo_get_ts_config(struct net_device *ndev,
+ struct kernel_hwtstamp_config *config);
+int icssg_ndo_set_ts_config(struct net_device *ndev,
+ struct kernel_hwtstamp_config *config,
+ struct netlink_ext_ack *extack);
void icssg_ndo_get_stats64(struct net_device *ndev,
struct rtnl_link_stats64 *stats);
int icssg_ndo_get_phys_port_name(struct net_device *ndev, char *name,
diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c b/drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c
index 5e225310c9de..2a8c8847a6bd 100644
--- a/drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c
+++ b/drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c
@@ -747,9 +747,11 @@ static const struct net_device_ops emac_netdev_ops = {
.ndo_validate_addr = eth_validate_addr,
.ndo_tx_timeout = icssg_ndo_tx_timeout,
.ndo_set_rx_mode = emac_ndo_set_rx_mode_sr1,
- .ndo_eth_ioctl = icssg_ndo_ioctl,
+ .ndo_eth_ioctl = phy_do_ioctl,
.ndo_get_stats64 = icssg_ndo_get_stats64,
.ndo_get_phys_port_name = icssg_ndo_get_phys_port_name,
+ .ndo_hwtstamp_get = icssg_ndo_get_ts_config,
+ .ndo_hwtstamp_set = icssg_ndo_set_ts_config,
};
static int prueth_netdev_init(struct prueth *prueth,
--
2.47.3
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH net-next v2 3/7] amd-xgbe: convert to ndo_hwtstamp callbacks
2025-10-14 22:42 [PATCH net-next v2 0/7] convert net drivers to ndo_hwtstamp API part 1 Vadim Fedorenko
2025-10-14 22:42 ` [PATCH net-next v2 1/7] net: ti: am65-cpsw: move hw timestamping to ndo callback Vadim Fedorenko
2025-10-14 22:42 ` [PATCH net-next v2 2/7] ti: icssg: convert to ndo_hwtstamp API Vadim Fedorenko
@ 2025-10-14 22:42 ` Vadim Fedorenko
2025-10-15 14:40 ` Simon Horman
2025-10-15 19:47 ` Jacob Keller
2025-10-14 22:42 ` [PATCH net-next v2 4/7] net: atlantic: convert to ndo_hwtstamp API Vadim Fedorenko
` (3 subsequent siblings)
6 siblings, 2 replies; 29+ messages in thread
From: Vadim Fedorenko @ 2025-10-14 22:42 UTC (permalink / raw)
To: Shyam Sundar S K, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Egor Pomozov, Potnuri Bharat Teja,
Dimitris Michailidis, MD Danish Anwar, Roger Quadros
Cc: Richard Cochran, Russell King, Vladimir Oltean, Simon Horman,
netdev, Vadim Fedorenko
Convert driver to use .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks.
.ndo_eth_ioctl() becomes empty function, remove it.
Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
---
drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 24 ++--------------
drivers/net/ethernet/amd/xgbe/xgbe-hwtstamp.c | 28 +++++++++----------
drivers/net/ethernet/amd/xgbe/xgbe.h | 11 ++++----
3 files changed, 21 insertions(+), 42 deletions(-)
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
index f0989aa01855..16160e19e07a 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
@@ -1755,27 +1755,6 @@ static int xgbe_set_mac_address(struct net_device *netdev, void *addr)
return 0;
}
-static int xgbe_ioctl(struct net_device *netdev, struct ifreq *ifreq, int cmd)
-{
- struct xgbe_prv_data *pdata = netdev_priv(netdev);
- int ret;
-
- switch (cmd) {
- case SIOCGHWTSTAMP:
- ret = xgbe_get_hwtstamp_settings(pdata, ifreq);
- break;
-
- case SIOCSHWTSTAMP:
- ret = xgbe_set_hwtstamp_settings(pdata, ifreq);
- break;
-
- default:
- ret = -EOPNOTSUPP;
- }
-
- return ret;
-}
-
static int xgbe_change_mtu(struct net_device *netdev, int mtu)
{
struct xgbe_prv_data *pdata = netdev_priv(netdev);
@@ -2021,7 +2000,6 @@ static const struct net_device_ops xgbe_netdev_ops = {
.ndo_set_rx_mode = xgbe_set_rx_mode,
.ndo_set_mac_address = xgbe_set_mac_address,
.ndo_validate_addr = eth_validate_addr,
- .ndo_eth_ioctl = xgbe_ioctl,
.ndo_change_mtu = xgbe_change_mtu,
.ndo_tx_timeout = xgbe_tx_timeout,
.ndo_get_stats64 = xgbe_get_stats64,
@@ -2034,6 +2012,8 @@ static const struct net_device_ops xgbe_netdev_ops = {
.ndo_fix_features = xgbe_fix_features,
.ndo_set_features = xgbe_set_features,
.ndo_features_check = xgbe_features_check,
+ .ndo_hwtstamp_get = xgbe_get_hwtstamp_settings,
+ .ndo_hwtstamp_set = xgbe_set_hwtstamp_settings,
};
const struct net_device_ops *xgbe_get_netdev_ops(void)
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-hwtstamp.c b/drivers/net/ethernet/amd/xgbe/xgbe-hwtstamp.c
index bc52e5ec6420..0127988e10be 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-hwtstamp.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-hwtstamp.c
@@ -157,26 +157,24 @@ void xgbe_tx_tstamp(struct work_struct *work)
spin_unlock_irqrestore(&pdata->tstamp_lock, flags);
}
-int xgbe_get_hwtstamp_settings(struct xgbe_prv_data *pdata, struct ifreq *ifreq)
+int xgbe_get_hwtstamp_settings(struct net_device *netdev,
+ struct kernel_hwtstamp_config *config)
{
- if (copy_to_user(ifreq->ifr_data, &pdata->tstamp_config,
- sizeof(pdata->tstamp_config)))
- return -EFAULT;
+ struct xgbe_prv_data *pdata = netdev_priv(netdev);
+
+ *config = pdata->tstamp_config;
return 0;
}
-int xgbe_set_hwtstamp_settings(struct xgbe_prv_data *pdata, struct ifreq *ifreq)
+int xgbe_set_hwtstamp_settings(struct net_device *netdev,
+ struct kernel_hwtstamp_config *config,
+ struct netlink_ext_ack *extack)
{
- struct hwtstamp_config config;
- unsigned int mac_tscr;
-
- if (copy_from_user(&config, ifreq->ifr_data, sizeof(config)))
- return -EFAULT;
-
- mac_tscr = 0;
+ struct xgbe_prv_data *pdata = netdev_priv(netdev);
+ unsigned int mac_tscr = 0;
- switch (config.tx_type) {
+ switch (config->tx_type) {
case HWTSTAMP_TX_OFF:
break;
@@ -188,7 +186,7 @@ int xgbe_set_hwtstamp_settings(struct xgbe_prv_data *pdata, struct ifreq *ifreq)
return -ERANGE;
}
- switch (config.rx_filter) {
+ switch (config->rx_filter) {
case HWTSTAMP_FILTER_NONE:
break;
@@ -290,7 +288,7 @@ int xgbe_set_hwtstamp_settings(struct xgbe_prv_data *pdata, struct ifreq *ifreq)
xgbe_config_tstamp(pdata, mac_tscr);
- memcpy(&pdata->tstamp_config, &config, sizeof(config));
+ pdata->tstamp_config = *config;
return 0;
}
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe.h b/drivers/net/ethernet/amd/xgbe/xgbe.h
index e8bbb6805901..381f72a33d1a 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe.h
+++ b/drivers/net/ethernet/amd/xgbe/xgbe.h
@@ -1146,7 +1146,7 @@ struct xgbe_prv_data {
spinlock_t tstamp_lock;
struct ptp_clock_info ptp_clock_info;
struct ptp_clock *ptp_clock;
- struct hwtstamp_config tstamp_config;
+ struct kernel_hwtstamp_config tstamp_config;
unsigned int tstamp_addend;
struct work_struct tx_tstamp_work;
struct sk_buff *tx_tstamp_skb;
@@ -1307,10 +1307,11 @@ void xgbe_update_tstamp_addend(struct xgbe_prv_data *pdata,
void xgbe_set_tstamp_time(struct xgbe_prv_data *pdata, unsigned int sec,
unsigned int nsec);
void xgbe_tx_tstamp(struct work_struct *work);
-int xgbe_get_hwtstamp_settings(struct xgbe_prv_data *pdata,
- struct ifreq *ifreq);
-int xgbe_set_hwtstamp_settings(struct xgbe_prv_data *pdata,
- struct ifreq *ifreq);
+int xgbe_get_hwtstamp_settings(struct net_device *netdev,
+ struct kernel_hwtstamp_config *config);
+int xgbe_set_hwtstamp_settings(struct net_device *netdev,
+ struct kernel_hwtstamp_config *config,
+ struct netlink_ext_ack *extack);
void xgbe_prep_tx_tstamp(struct xgbe_prv_data *pdata,
struct sk_buff *skb,
struct xgbe_packet_data *packet);
--
2.47.3
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH net-next v2 4/7] net: atlantic: convert to ndo_hwtstamp API
2025-10-14 22:42 [PATCH net-next v2 0/7] convert net drivers to ndo_hwtstamp API part 1 Vadim Fedorenko
` (2 preceding siblings ...)
2025-10-14 22:42 ` [PATCH net-next v2 3/7] amd-xgbe: convert to ndo_hwtstamp callbacks Vadim Fedorenko
@ 2025-10-14 22:42 ` Vadim Fedorenko
2025-10-15 14:40 ` Simon Horman
2025-10-15 19:49 ` Jacob Keller
2025-10-14 22:42 ` [PATCH net-next v2 5/7] cxgb4: " Vadim Fedorenko
` (2 subsequent siblings)
6 siblings, 2 replies; 29+ messages in thread
From: Vadim Fedorenko @ 2025-10-14 22:42 UTC (permalink / raw)
To: Shyam Sundar S K, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Egor Pomozov, Potnuri Bharat Teja,
Dimitris Michailidis, MD Danish Anwar, Roger Quadros
Cc: Richard Cochran, Russell King, Vladimir Oltean, Simon Horman,
netdev, Vadim Fedorenko
Convert driver to .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks.
.ndo_eth_ioctl() becomes empty so remove it. Also simplify code with no
functional changes.
Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
---
.../net/ethernet/aquantia/atlantic/aq_main.c | 66 +++++--------------
.../net/ethernet/aquantia/atlantic/aq_ptp.c | 6 +-
.../net/ethernet/aquantia/atlantic/aq_ptp.h | 8 +--
3 files changed, 22 insertions(+), 58 deletions(-)
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_main.c b/drivers/net/ethernet/aquantia/atlantic/aq_main.c
index b565189e5913..4ef4fe64b8ac 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_main.c
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_main.c
@@ -258,10 +258,15 @@ static void aq_ndev_set_multicast_settings(struct net_device *ndev)
(void)aq_nic_set_multicast_list(aq_nic, ndev);
}
-#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK)
-static int aq_ndev_config_hwtstamp(struct aq_nic_s *aq_nic,
- struct hwtstamp_config *config)
+static int aq_ndev_hwtstamp_set(struct net_device *netdev,
+ struct kernel_hwtstamp_config *config,
+ struct netlink_ext_ack *extack)
{
+ struct aq_nic_s *aq_nic = netdev_priv(netdev);
+
+ if (!IS_REACHABLE(CONFIG_PTP_1588_CLOCK) || !aq_nic->aq_ptp)
+ return -EOPNOTSUPP;
+
switch (config->tx_type) {
case HWTSTAMP_TX_OFF:
case HWTSTAMP_TX_ON:
@@ -290,59 +295,17 @@ static int aq_ndev_config_hwtstamp(struct aq_nic_s *aq_nic,
return aq_ptp_hwtstamp_config_set(aq_nic->aq_ptp, config);
}
-#endif
-
-static int aq_ndev_hwtstamp_set(struct aq_nic_s *aq_nic, struct ifreq *ifr)
-{
- struct hwtstamp_config config;
-#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK)
- int ret_val;
-#endif
-
- if (!aq_nic->aq_ptp)
- return -EOPNOTSUPP;
-
- if (copy_from_user(&config, ifr->ifr_data, sizeof(config)))
- return -EFAULT;
-#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK)
- ret_val = aq_ndev_config_hwtstamp(aq_nic, &config);
- if (ret_val)
- return ret_val;
-#endif
-
- return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ?
- -EFAULT : 0;
-}
-#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK)
-static int aq_ndev_hwtstamp_get(struct aq_nic_s *aq_nic, struct ifreq *ifr)
+static int aq_ndev_hwtstamp_get(struct net_device *netdev,
+ struct kernel_hwtstamp_config *config)
{
- struct hwtstamp_config config;
+ struct aq_nic_s *aq_nic = netdev_priv(netdev);
if (!aq_nic->aq_ptp)
return -EOPNOTSUPP;
- aq_ptp_hwtstamp_config_get(aq_nic->aq_ptp, &config);
- return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ?
- -EFAULT : 0;
-}
-#endif
-
-static int aq_ndev_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
-{
- struct aq_nic_s *aq_nic = netdev_priv(netdev);
-
- switch (cmd) {
- case SIOCSHWTSTAMP:
- return aq_ndev_hwtstamp_set(aq_nic, ifr);
-
-#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK)
- case SIOCGHWTSTAMP:
- return aq_ndev_hwtstamp_get(aq_nic, ifr);
-#endif
- }
-
- return -EOPNOTSUPP;
+ aq_ptp_hwtstamp_config_get(aq_nic->aq_ptp, config);
+ return 0;
}
static int aq_ndo_vlan_rx_add_vid(struct net_device *ndev, __be16 proto,
@@ -500,12 +463,13 @@ static const struct net_device_ops aq_ndev_ops = {
.ndo_set_mac_address = aq_ndev_set_mac_address,
.ndo_set_features = aq_ndev_set_features,
.ndo_fix_features = aq_ndev_fix_features,
- .ndo_eth_ioctl = aq_ndev_ioctl,
.ndo_vlan_rx_add_vid = aq_ndo_vlan_rx_add_vid,
.ndo_vlan_rx_kill_vid = aq_ndo_vlan_rx_kill_vid,
.ndo_setup_tc = aq_ndo_setup_tc,
.ndo_bpf = aq_xdp,
.ndo_xdp_xmit = aq_xdp_xmit,
+ .ndo_hwtstamp_get = aq_ndev_hwtstamp_get,
+ .ndo_hwtstamp_set = aq_ndev_hwtstamp_set,
};
static int __init aq_ndev_init_module(void)
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_ptp.c b/drivers/net/ethernet/aquantia/atlantic/aq_ptp.c
index 5acb3e16b567..0fa0f891c0e0 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_ptp.c
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_ptp.c
@@ -51,7 +51,7 @@ struct ptp_tx_timeout {
struct aq_ptp_s {
struct aq_nic_s *aq_nic;
- struct hwtstamp_config hwtstamp_config;
+ struct kernel_hwtstamp_config hwtstamp_config;
spinlock_t ptp_lock;
spinlock_t ptp_ring_lock;
struct ptp_clock *ptp_clock;
@@ -567,7 +567,7 @@ static void aq_ptp_rx_hwtstamp(struct aq_ptp_s *aq_ptp, struct skb_shared_hwtsta
}
void aq_ptp_hwtstamp_config_get(struct aq_ptp_s *aq_ptp,
- struct hwtstamp_config *config)
+ struct kernel_hwtstamp_config *config)
{
*config = aq_ptp->hwtstamp_config;
}
@@ -588,7 +588,7 @@ static void aq_ptp_prepare_filters(struct aq_ptp_s *aq_ptp)
}
int aq_ptp_hwtstamp_config_set(struct aq_ptp_s *aq_ptp,
- struct hwtstamp_config *config)
+ struct kernel_hwtstamp_config *config)
{
struct aq_nic_s *aq_nic = aq_ptp->aq_nic;
const struct aq_hw_ops *hw_ops;
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_ptp.h b/drivers/net/ethernet/aquantia/atlantic/aq_ptp.h
index 210b723f2207..5e643ec7cc06 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_ptp.h
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_ptp.h
@@ -60,9 +60,9 @@ void aq_ptp_tx_hwtstamp(struct aq_nic_s *aq_nic, u64 timestamp);
/* Must be to check available of PTP before call */
void aq_ptp_hwtstamp_config_get(struct aq_ptp_s *aq_ptp,
- struct hwtstamp_config *config);
+ struct kernel_hwtstamp_config *config);
int aq_ptp_hwtstamp_config_set(struct aq_ptp_s *aq_ptp,
- struct hwtstamp_config *config);
+ struct kernel_hwtstamp_config *config);
/* Return either ring is belong to PTP or not*/
bool aq_ptp_ring(struct aq_nic_s *aq_nic, struct aq_ring_s *ring);
@@ -130,9 +130,9 @@ static inline int aq_ptp_xmit(struct aq_nic_s *aq_nic, struct sk_buff *skb)
static inline void aq_ptp_tx_hwtstamp(struct aq_nic_s *aq_nic, u64 timestamp) {}
static inline void aq_ptp_hwtstamp_config_get(struct aq_ptp_s *aq_ptp,
- struct hwtstamp_config *config) {}
+ struct kernel_hwtstamp_config *config) {}
static inline int aq_ptp_hwtstamp_config_set(struct aq_ptp_s *aq_ptp,
- struct hwtstamp_config *config)
+ struct kernel_hwtstamp_config *config)
{
return 0;
}
--
2.47.3
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH net-next v2 5/7] cxgb4: convert to ndo_hwtstamp API
2025-10-14 22:42 [PATCH net-next v2 0/7] convert net drivers to ndo_hwtstamp API part 1 Vadim Fedorenko
` (3 preceding siblings ...)
2025-10-14 22:42 ` [PATCH net-next v2 4/7] net: atlantic: convert to ndo_hwtstamp API Vadim Fedorenko
@ 2025-10-14 22:42 ` Vadim Fedorenko
2025-10-15 10:05 ` Simon Horman
2025-10-14 22:42 ` [PATCH net-next v2 6/7] tsnep: convert to ndo_hwtstatmp API Vadim Fedorenko
2025-10-14 22:42 ` [PATCH net-next v2 7/7] funeth: convert to ndo_hwtstamp API Vadim Fedorenko
6 siblings, 1 reply; 29+ messages in thread
From: Vadim Fedorenko @ 2025-10-14 22:42 UTC (permalink / raw)
To: Shyam Sundar S K, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Egor Pomozov, Potnuri Bharat Teja,
Dimitris Michailidis, MD Danish Anwar, Roger Quadros
Cc: Richard Cochran, Russell King, Vladimir Oltean, Simon Horman,
netdev, Vadim Fedorenko
Convert to use .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks.
Though I'm not quite sure it worked properly before the conversion.
Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
---
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | 2 +-
.../net/ethernet/chelsio/cxgb4/cxgb4_main.c | 154 +++++++++---------
2 files changed, 79 insertions(+), 77 deletions(-)
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index 0d85198fb03d..f20f4bc58492 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -674,7 +674,7 @@ struct port_info {
struct cxgb_fcoe fcoe;
#endif /* CONFIG_CHELSIO_T4_FCOE */
bool rxtstamp; /* Enable TS */
- struct hwtstamp_config tstamp_config;
+ struct kernel_hwtstamp_config tstamp_config;
bool ptp_enable;
struct sched_table *sched_tbl;
u32 eth_flags;
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 392723ef14e5..7e2283c95b97 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -3042,12 +3042,87 @@ static void cxgb_get_stats(struct net_device *dev,
ns->rx_length_errors + stats.rx_len_err + ns->rx_fifo_errors;
}
+static int cxgb_hwtstamp_get(struct net_device *dev,
+ struct kernel_hwtstamp_config *config)
+{
+ struct port_info *pi = netdev_priv(dev);
+
+ *config = pi->tstamp_config;
+ return 0;
+}
+
+static int cxgb_hwtstamp_set(struct net_device *dev,
+ struct kernel_hwtstamp_config *config,
+ struct netlink_ext_ack *extack)
+{
+ struct port_info *pi = netdev_priv(dev);
+ struct adapter *adapter = pi->adapter;
+
+ if (is_t4(adapter->params.chip)) {
+ /* For T4 Adapters */
+ switch (config->rx_filter) {
+ case HWTSTAMP_FILTER_NONE:
+ pi->rxtstamp = false;
+ break;
+ case HWTSTAMP_FILTER_ALL:
+ pi->rxtstamp = true;
+ break;
+ default:
+ return -ERANGE;
+ }
+ pi->tstamp_config = *config;
+ return 0;
+ }
+
+ switch (config->tx_type) {
+ case HWTSTAMP_TX_OFF:
+ case HWTSTAMP_TX_ON:
+ break;
+ default:
+ return -ERANGE;
+ }
+
+ switch (config->rx_filter) {
+ case HWTSTAMP_FILTER_NONE:
+ pi->rxtstamp = false;
+ break;
+ case HWTSTAMP_FILTER_PTP_V1_L4_EVENT:
+ case HWTSTAMP_FILTER_PTP_V2_L4_EVENT:
+ cxgb4_ptprx_timestamping(pi, pi->port_id, PTP_TS_L4);
+ break;
+ case HWTSTAMP_FILTER_PTP_V2_EVENT:
+ cxgb4_ptprx_timestamping(pi, pi->port_id, PTP_TS_L2_L4);
+ break;
+ case HWTSTAMP_FILTER_ALL:
+ case HWTSTAMP_FILTER_PTP_V1_L4_SYNC:
+ case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ:
+ case HWTSTAMP_FILTER_PTP_V2_L4_SYNC:
+ case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ:
+ pi->rxtstamp = true;
+ break;
+ default:
+ return -ERANGE;
+ }
+
+ if (config->tx_type == HWTSTAMP_TX_OFF &&
+ config->rx_filter == HWTSTAMP_FILTER_NONE) {
+ if (cxgb4_ptp_txtype(adapter, pi->port_id) >= 0)
+ pi->ptp_enable = false;
+ }
+
+ if (config->rx_filter != HWTSTAMP_FILTER_NONE) {
+ if (cxgb4_ptp_redirect_rx_packet(adapter, pi) >= 0)
+ pi->ptp_enable = true;
+ }
+ pi->tstamp_config = *config;
+ return 0;
+}
+
static int cxgb_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
{
unsigned int mbox;
int ret = 0, prtad, devad;
struct port_info *pi = netdev_priv(dev);
- struct adapter *adapter = pi->adapter;
struct mii_ioctl_data *data = (struct mii_ioctl_data *)&req->ifr_data;
switch (cmd) {
@@ -3076,81 +3151,6 @@ static int cxgb_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
ret = t4_mdio_wr(pi->adapter, mbox, prtad, devad,
data->reg_num, data->val_in);
break;
- case SIOCGHWTSTAMP:
- return copy_to_user(req->ifr_data, &pi->tstamp_config,
- sizeof(pi->tstamp_config)) ?
- -EFAULT : 0;
- case SIOCSHWTSTAMP:
- if (copy_from_user(&pi->tstamp_config, req->ifr_data,
- sizeof(pi->tstamp_config)))
- return -EFAULT;
-
- if (!is_t4(adapter->params.chip)) {
- switch (pi->tstamp_config.tx_type) {
- case HWTSTAMP_TX_OFF:
- case HWTSTAMP_TX_ON:
- break;
- default:
- return -ERANGE;
- }
-
- switch (pi->tstamp_config.rx_filter) {
- case HWTSTAMP_FILTER_NONE:
- pi->rxtstamp = false;
- break;
- case HWTSTAMP_FILTER_PTP_V1_L4_EVENT:
- case HWTSTAMP_FILTER_PTP_V2_L4_EVENT:
- cxgb4_ptprx_timestamping(pi, pi->port_id,
- PTP_TS_L4);
- break;
- case HWTSTAMP_FILTER_PTP_V2_EVENT:
- cxgb4_ptprx_timestamping(pi, pi->port_id,
- PTP_TS_L2_L4);
- break;
- case HWTSTAMP_FILTER_ALL:
- case HWTSTAMP_FILTER_PTP_V1_L4_SYNC:
- case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ:
- case HWTSTAMP_FILTER_PTP_V2_L4_SYNC:
- case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ:
- pi->rxtstamp = true;
- break;
- default:
- pi->tstamp_config.rx_filter =
- HWTSTAMP_FILTER_NONE;
- return -ERANGE;
- }
-
- if ((pi->tstamp_config.tx_type == HWTSTAMP_TX_OFF) &&
- (pi->tstamp_config.rx_filter ==
- HWTSTAMP_FILTER_NONE)) {
- if (cxgb4_ptp_txtype(adapter, pi->port_id) >= 0)
- pi->ptp_enable = false;
- }
-
- if (pi->tstamp_config.rx_filter !=
- HWTSTAMP_FILTER_NONE) {
- if (cxgb4_ptp_redirect_rx_packet(adapter,
- pi) >= 0)
- pi->ptp_enable = true;
- }
- } else {
- /* For T4 Adapters */
- switch (pi->tstamp_config.rx_filter) {
- case HWTSTAMP_FILTER_NONE:
- pi->rxtstamp = false;
- break;
- case HWTSTAMP_FILTER_ALL:
- pi->rxtstamp = true;
- break;
- default:
- pi->tstamp_config.rx_filter =
- HWTSTAMP_FILTER_NONE;
- return -ERANGE;
- }
- }
- return copy_to_user(req->ifr_data, &pi->tstamp_config,
- sizeof(pi->tstamp_config)) ?
- -EFAULT : 0;
default:
return -EOPNOTSUPP;
}
@@ -3875,6 +3875,8 @@ static const struct net_device_ops cxgb4_netdev_ops = {
.ndo_setup_tc = cxgb_setup_tc,
.ndo_features_check = cxgb_features_check,
.ndo_fix_features = cxgb_fix_features,
+ .ndo_hwtstamp_get = cxgb_hwtstamp_get,
+ .ndo_hwtstamp_set = cxgb_hwtstamp_set,
};
#ifdef CONFIG_PCI_IOV
--
2.47.3
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH net-next v2 6/7] tsnep: convert to ndo_hwtstatmp API
2025-10-14 22:42 [PATCH net-next v2 0/7] convert net drivers to ndo_hwtstamp API part 1 Vadim Fedorenko
` (4 preceding siblings ...)
2025-10-14 22:42 ` [PATCH net-next v2 5/7] cxgb4: " Vadim Fedorenko
@ 2025-10-14 22:42 ` Vadim Fedorenko
2025-10-15 10:03 ` Simon Horman
2025-10-14 22:42 ` [PATCH net-next v2 7/7] funeth: convert to ndo_hwtstamp API Vadim Fedorenko
6 siblings, 1 reply; 29+ messages in thread
From: Vadim Fedorenko @ 2025-10-14 22:42 UTC (permalink / raw)
To: Shyam Sundar S K, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Egor Pomozov, Potnuri Bharat Teja,
Dimitris Michailidis, MD Danish Anwar, Roger Quadros
Cc: Richard Cochran, Russell King, Vladimir Oltean, Simon Horman,
netdev, Vadim Fedorenko
Convert to .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks.
After conversions the rest of tsnep_netdev_ioctl() becomes pure
phy_do_ioctl_running(), so remove tsnep_netdev_ioctl() and replace
it with phy_do_ioctl_running() in .ndo_eth_ioctl.
Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
---
drivers/net/ethernet/engleder/tsnep.h | 8 +-
drivers/net/ethernet/engleder/tsnep_main.c | 14 +---
drivers/net/ethernet/engleder/tsnep_ptp.c | 88 +++++++++++-----------
3 files changed, 51 insertions(+), 59 deletions(-)
diff --git a/drivers/net/ethernet/engleder/tsnep.h b/drivers/net/ethernet/engleder/tsnep.h
index f188fba021a6..03e19aea9ea4 100644
--- a/drivers/net/ethernet/engleder/tsnep.h
+++ b/drivers/net/ethernet/engleder/tsnep.h
@@ -176,7 +176,7 @@ struct tsnep_adapter {
struct tsnep_gcl gcl[2];
int next_gcl;
- struct hwtstamp_config hwtstamp_config;
+ struct kernel_hwtstamp_config hwtstamp_config;
struct ptp_clock *ptp_clock;
struct ptp_clock_info ptp_clock_info;
/* ptp clock lock */
@@ -203,7 +203,11 @@ extern const struct ethtool_ops tsnep_ethtool_ops;
int tsnep_ptp_init(struct tsnep_adapter *adapter);
void tsnep_ptp_cleanup(struct tsnep_adapter *adapter);
-int tsnep_ptp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd);
+int tsnep_ptp_hwtstamp_get(struct net_device *netdev,
+ struct kernel_hwtstamp_config *config);
+int tsnep_ptp_hwtstamp_set(struct net_device *netdev,
+ struct kernel_hwtstamp_config *config,
+ struct netlink_ext_ack *extack);
int tsnep_tc_init(struct tsnep_adapter *adapter);
void tsnep_tc_cleanup(struct tsnep_adapter *adapter);
diff --git a/drivers/net/ethernet/engleder/tsnep_main.c b/drivers/net/ethernet/engleder/tsnep_main.c
index eba73246f986..b118407c30e8 100644
--- a/drivers/net/ethernet/engleder/tsnep_main.c
+++ b/drivers/net/ethernet/engleder/tsnep_main.c
@@ -2168,16 +2168,6 @@ static netdev_tx_t tsnep_netdev_xmit_frame(struct sk_buff *skb,
return tsnep_xmit_frame_ring(skb, &adapter->tx[queue_mapping]);
}
-static int tsnep_netdev_ioctl(struct net_device *netdev, struct ifreq *ifr,
- int cmd)
-{
- if (!netif_running(netdev))
- return -EINVAL;
- if (cmd == SIOCSHWTSTAMP || cmd == SIOCGHWTSTAMP)
- return tsnep_ptp_ioctl(netdev, ifr, cmd);
- return phy_mii_ioctl(netdev->phydev, ifr, cmd);
-}
-
static void tsnep_netdev_set_multicast(struct net_device *netdev)
{
struct tsnep_adapter *adapter = netdev_priv(netdev);
@@ -2384,7 +2374,7 @@ static const struct net_device_ops tsnep_netdev_ops = {
.ndo_open = tsnep_netdev_open,
.ndo_stop = tsnep_netdev_close,
.ndo_start_xmit = tsnep_netdev_xmit_frame,
- .ndo_eth_ioctl = tsnep_netdev_ioctl,
+ .ndo_eth_ioctl = phy_do_ioctl_running,
.ndo_set_rx_mode = tsnep_netdev_set_multicast,
.ndo_get_stats64 = tsnep_netdev_get_stats64,
.ndo_set_mac_address = tsnep_netdev_set_mac_address,
@@ -2394,6 +2384,8 @@ static const struct net_device_ops tsnep_netdev_ops = {
.ndo_bpf = tsnep_netdev_bpf,
.ndo_xdp_xmit = tsnep_netdev_xdp_xmit,
.ndo_xsk_wakeup = tsnep_netdev_xsk_wakeup,
+ .ndo_hwtstamp_get = tsnep_ptp_hwtstamp_get,
+ .ndo_hwtstamp_set = tsnep_ptp_hwtstamp_set,
};
static int tsnep_mac_init(struct tsnep_adapter *adapter)
diff --git a/drivers/net/ethernet/engleder/tsnep_ptp.c b/drivers/net/ethernet/engleder/tsnep_ptp.c
index 54fbf0126815..ae1308eb813d 100644
--- a/drivers/net/ethernet/engleder/tsnep_ptp.c
+++ b/drivers/net/ethernet/engleder/tsnep_ptp.c
@@ -19,57 +19,53 @@ void tsnep_get_system_time(struct tsnep_adapter *adapter, u64 *time)
*time = (((u64)high) << 32) | ((u64)low);
}
-int tsnep_ptp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
+int tsnep_ptp_hwtstamp_get(struct net_device *netdev,
+ struct kernel_hwtstamp_config *config)
{
struct tsnep_adapter *adapter = netdev_priv(netdev);
- struct hwtstamp_config config;
-
- if (!ifr)
- return -EINVAL;
-
- if (cmd == SIOCSHWTSTAMP) {
- if (copy_from_user(&config, ifr->ifr_data, sizeof(config)))
- return -EFAULT;
-
- switch (config.tx_type) {
- case HWTSTAMP_TX_OFF:
- case HWTSTAMP_TX_ON:
- break;
- default:
- return -ERANGE;
- }
-
- switch (config.rx_filter) {
- case HWTSTAMP_FILTER_NONE:
- break;
- case HWTSTAMP_FILTER_ALL:
- case HWTSTAMP_FILTER_PTP_V1_L4_EVENT:
- case HWTSTAMP_FILTER_PTP_V1_L4_SYNC:
- case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ:
- case HWTSTAMP_FILTER_PTP_V2_L4_EVENT:
- case HWTSTAMP_FILTER_PTP_V2_L4_SYNC:
- case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ:
- case HWTSTAMP_FILTER_PTP_V2_L2_EVENT:
- case HWTSTAMP_FILTER_PTP_V2_L2_SYNC:
- case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ:
- case HWTSTAMP_FILTER_PTP_V2_EVENT:
- case HWTSTAMP_FILTER_PTP_V2_SYNC:
- case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ:
- case HWTSTAMP_FILTER_NTP_ALL:
- config.rx_filter = HWTSTAMP_FILTER_ALL;
- break;
- default:
- return -ERANGE;
- }
-
- memcpy(&adapter->hwtstamp_config, &config,
- sizeof(adapter->hwtstamp_config));
+
+ *config = adapter->hwtstamp_config;
+ return 0;
+}
+
+int tsnep_ptp_hwtstamp_set(struct net_device *netdev,
+ struct kernel_hwtstamp_config *config,
+ struct netlink_ext_ack *extack)
+{
+ struct tsnep_adapter *adapter = netdev_priv(netdev);
+
+ switch (config->tx_type) {
+ case HWTSTAMP_TX_OFF:
+ case HWTSTAMP_TX_ON:
+ break;
+ default:
+ return -ERANGE;
}
- if (copy_to_user(ifr->ifr_data, &adapter->hwtstamp_config,
- sizeof(adapter->hwtstamp_config)))
- return -EFAULT;
+ switch (config->rx_filter) {
+ case HWTSTAMP_FILTER_NONE:
+ break;
+ case HWTSTAMP_FILTER_ALL:
+ case HWTSTAMP_FILTER_PTP_V1_L4_EVENT:
+ case HWTSTAMP_FILTER_PTP_V1_L4_SYNC:
+ case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ:
+ case HWTSTAMP_FILTER_PTP_V2_L4_EVENT:
+ case HWTSTAMP_FILTER_PTP_V2_L4_SYNC:
+ case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ:
+ case HWTSTAMP_FILTER_PTP_V2_L2_EVENT:
+ case HWTSTAMP_FILTER_PTP_V2_L2_SYNC:
+ case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ:
+ case HWTSTAMP_FILTER_PTP_V2_EVENT:
+ case HWTSTAMP_FILTER_PTP_V2_SYNC:
+ case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ:
+ case HWTSTAMP_FILTER_NTP_ALL:
+ config->rx_filter = HWTSTAMP_FILTER_ALL;
+ break;
+ default:
+ return -ERANGE;
+ }
+ adapter->hwtstamp_config = *config;
return 0;
}
--
2.47.3
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH net-next v2 7/7] funeth: convert to ndo_hwtstamp API
2025-10-14 22:42 [PATCH net-next v2 0/7] convert net drivers to ndo_hwtstamp API part 1 Vadim Fedorenko
` (5 preceding siblings ...)
2025-10-14 22:42 ` [PATCH net-next v2 6/7] tsnep: convert to ndo_hwtstatmp API Vadim Fedorenko
@ 2025-10-14 22:42 ` Vadim Fedorenko
2025-10-15 14:40 ` Simon Horman
2025-10-15 20:20 ` Jacob Keller
6 siblings, 2 replies; 29+ messages in thread
From: Vadim Fedorenko @ 2025-10-14 22:42 UTC (permalink / raw)
To: Shyam Sundar S K, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Egor Pomozov, Potnuri Bharat Teja,
Dimitris Michailidis, MD Danish Anwar, Roger Quadros
Cc: Richard Cochran, Russell King, Vladimir Oltean, Simon Horman,
netdev, Vadim Fedorenko
Convert driver to use .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks.
.ndo_eth_ioctl() implementation becomes empty, remove it.
Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
---
drivers/net/ethernet/fungible/funeth/funeth.h | 4 +-
.../ethernet/fungible/funeth/funeth_main.c | 40 +++++++------------
2 files changed, 16 insertions(+), 28 deletions(-)
diff --git a/drivers/net/ethernet/fungible/funeth/funeth.h b/drivers/net/ethernet/fungible/funeth/funeth.h
index 1250e10d21db..55e705e239f8 100644
--- a/drivers/net/ethernet/fungible/funeth/funeth.h
+++ b/drivers/net/ethernet/fungible/funeth/funeth.h
@@ -4,7 +4,7 @@
#define _FUNETH_H
#include <uapi/linux/if_ether.h>
-#include <uapi/linux/net_tstamp.h>
+#include <linux/net_tstamp.h>
#include <linux/mutex.h>
#include <linux/seqlock.h>
#include <linux/xarray.h>
@@ -121,7 +121,7 @@ struct funeth_priv {
u8 rx_coal_usec;
u8 rx_coal_count;
- struct hwtstamp_config hwtstamp_cfg;
+ struct kernel_hwtstamp_config hwtstamp_cfg;
/* cumulative queue stats from earlier queue instances */
u64 tx_packets;
diff --git a/drivers/net/ethernet/fungible/funeth/funeth_main.c b/drivers/net/ethernet/fungible/funeth/funeth_main.c
index ac86179a0a81..792cddac6f1b 100644
--- a/drivers/net/ethernet/fungible/funeth/funeth_main.c
+++ b/drivers/net/ethernet/fungible/funeth/funeth_main.c
@@ -1014,26 +1014,25 @@ static int fun_get_port_attributes(struct net_device *netdev)
return 0;
}
-static int fun_hwtstamp_get(struct net_device *dev, struct ifreq *ifr)
+static int fun_hwtstamp_get(struct net_device *dev,
+ struct kernel_hwtstamp_config *config)
{
const struct funeth_priv *fp = netdev_priv(dev);
- return copy_to_user(ifr->ifr_data, &fp->hwtstamp_cfg,
- sizeof(fp->hwtstamp_cfg)) ? -EFAULT : 0;
+ *config = fp->hwtstamp_cfg;
+ return 0;
}
-static int fun_hwtstamp_set(struct net_device *dev, struct ifreq *ifr)
+static int fun_hwtstamp_set(struct net_device *dev,
+ struct kernel_hwtstamp_config *config,
+ struct netlink_ext_ack *extack)
{
struct funeth_priv *fp = netdev_priv(dev);
- struct hwtstamp_config cfg;
-
- if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg)))
- return -EFAULT;
/* no TX HW timestamps */
- cfg.tx_type = HWTSTAMP_TX_OFF;
+ config->tx_type = HWTSTAMP_TX_OFF;
- switch (cfg.rx_filter) {
+ switch (config->rx_filter) {
case HWTSTAMP_FILTER_NONE:
break;
case HWTSTAMP_FILTER_ALL:
@@ -1051,26 +1050,14 @@ static int fun_hwtstamp_set(struct net_device *dev, struct ifreq *ifr)
case HWTSTAMP_FILTER_PTP_V2_SYNC:
case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ:
case HWTSTAMP_FILTER_NTP_ALL:
- cfg.rx_filter = HWTSTAMP_FILTER_ALL;
+ config->rx_filter = HWTSTAMP_FILTER_ALL;
break;
default:
return -ERANGE;
}
- fp->hwtstamp_cfg = cfg;
- return copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0;
-}
-
-static int fun_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
-{
- switch (cmd) {
- case SIOCSHWTSTAMP:
- return fun_hwtstamp_set(dev, ifr);
- case SIOCGHWTSTAMP:
- return fun_hwtstamp_get(dev, ifr);
- default:
- return -EOPNOTSUPP;
- }
+ fp->hwtstamp_cfg = *config;
+ return 0;
}
/* Prepare the queues for XDP. */
@@ -1340,7 +1327,6 @@ static const struct net_device_ops fun_netdev_ops = {
.ndo_change_mtu = fun_change_mtu,
.ndo_set_mac_address = fun_set_macaddr,
.ndo_validate_addr = eth_validate_addr,
- .ndo_eth_ioctl = fun_ioctl,
.ndo_uninit = fun_uninit,
.ndo_bpf = fun_xdp,
.ndo_xdp_xmit = fun_xdp_xmit_frames,
@@ -1348,6 +1334,8 @@ static const struct net_device_ops fun_netdev_ops = {
.ndo_set_vf_vlan = fun_set_vf_vlan,
.ndo_set_vf_rate = fun_set_vf_rate,
.ndo_get_vf_config = fun_get_vf_config,
+ .ndo_hwtstamp_get = fun_hwtstamp_get,
+ .ndo_hwtstamp_set = fun_hwtstamp_set,
};
#define GSO_ENCAP_FLAGS (NETIF_F_GSO_GRE | NETIF_F_GSO_IPXIP4 | \
--
2.47.3
^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [PATCH net-next v2 6/7] tsnep: convert to ndo_hwtstatmp API
2025-10-14 22:42 ` [PATCH net-next v2 6/7] tsnep: convert to ndo_hwtstatmp API Vadim Fedorenko
@ 2025-10-15 10:03 ` Simon Horman
2025-10-15 10:38 ` Vadim Fedorenko
0 siblings, 1 reply; 29+ messages in thread
From: Simon Horman @ 2025-10-15 10:03 UTC (permalink / raw)
To: Vadim Fedorenko
Cc: Shyam Sundar S K, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Egor Pomozov, Potnuri Bharat Teja,
Dimitris Michailidis, MD Danish Anwar, Roger Quadros,
Richard Cochran, Russell King, Vladimir Oltean, netdev
On Tue, Oct 14, 2025 at 10:42:15PM +0000, Vadim Fedorenko wrote:
> Convert to .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks.
> After conversions the rest of tsnep_netdev_ioctl() becomes pure
> phy_do_ioctl_running(), so remove tsnep_netdev_ioctl() and replace
> it with phy_do_ioctl_running() in .ndo_eth_ioctl.
>
> Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
...
> diff --git a/drivers/net/ethernet/engleder/tsnep_ptp.c b/drivers/net/ethernet/engleder/tsnep_ptp.c
> index 54fbf0126815..ae1308eb813d 100644
> --- a/drivers/net/ethernet/engleder/tsnep_ptp.c
> +++ b/drivers/net/ethernet/engleder/tsnep_ptp.c
> @@ -19,57 +19,53 @@ void tsnep_get_system_time(struct tsnep_adapter *adapter, u64 *time)
> *time = (((u64)high) << 32) | ((u64)low);
> }
>
> -int tsnep_ptp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
> +int tsnep_ptp_hwtstamp_get(struct net_device *netdev,
> + struct kernel_hwtstamp_config *config)
> {
> struct tsnep_adapter *adapter = netdev_priv(netdev);
> - struct hwtstamp_config config;
> -
> - if (!ifr)
> - return -EINVAL;
> -
> - if (cmd == SIOCSHWTSTAMP) {
> - if (copy_from_user(&config, ifr->ifr_data, sizeof(config)))
> - return -EFAULT;
> -
> - switch (config.tx_type) {
> - case HWTSTAMP_TX_OFF:
> - case HWTSTAMP_TX_ON:
> - break;
> - default:
> - return -ERANGE;
> - }
> -
> - switch (config.rx_filter) {
> - case HWTSTAMP_FILTER_NONE:
> - break;
> - case HWTSTAMP_FILTER_ALL:
> - case HWTSTAMP_FILTER_PTP_V1_L4_EVENT:
> - case HWTSTAMP_FILTER_PTP_V1_L4_SYNC:
> - case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ:
> - case HWTSTAMP_FILTER_PTP_V2_L4_EVENT:
> - case HWTSTAMP_FILTER_PTP_V2_L4_SYNC:
> - case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ:
> - case HWTSTAMP_FILTER_PTP_V2_L2_EVENT:
> - case HWTSTAMP_FILTER_PTP_V2_L2_SYNC:
> - case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ:
> - case HWTSTAMP_FILTER_PTP_V2_EVENT:
> - case HWTSTAMP_FILTER_PTP_V2_SYNC:
> - case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ:
> - case HWTSTAMP_FILTER_NTP_ALL:
> - config.rx_filter = HWTSTAMP_FILTER_ALL;
> - break;
> - default:
> - return -ERANGE;
> - }
Hi Vadim,
I'm probably missing something obvious, but it's not clear to me why
removing the inner switch statements above is ok. Or, perhaps more to the
point, it seems inconsistent with other patches in this series.
OTOH, I do see why dropping the outer if conditions makes sense.
> -
> - memcpy(&adapter->hwtstamp_config, &config,
> - sizeof(adapter->hwtstamp_config));
> +
> + *config = adapter->hwtstamp_config;
> + return 0;
> +}
...
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH net-next v2 5/7] cxgb4: convert to ndo_hwtstamp API
2025-10-14 22:42 ` [PATCH net-next v2 5/7] cxgb4: " Vadim Fedorenko
@ 2025-10-15 10:05 ` Simon Horman
2025-10-15 10:33 ` Vadim Fedorenko
0 siblings, 1 reply; 29+ messages in thread
From: Simon Horman @ 2025-10-15 10:05 UTC (permalink / raw)
To: Vadim Fedorenko
Cc: Shyam Sundar S K, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Egor Pomozov, Potnuri Bharat Teja,
Dimitris Michailidis, MD Danish Anwar, Roger Quadros,
Richard Cochran, Russell King, Vladimir Oltean, netdev
On Tue, Oct 14, 2025 at 10:42:14PM +0000, Vadim Fedorenko wrote:
> Convert to use .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks.
>
> Though I'm not quite sure it worked properly before the conversion.
>
> Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Hi Vadim,
There is quite a lot of change here. Probably it's not worth "fixing"
the current code before migrating it. But I think it would be worth
expanding a bit on the statement about not being sure it worked?
...
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH net-next v2 5/7] cxgb4: convert to ndo_hwtstamp API
2025-10-15 10:05 ` Simon Horman
@ 2025-10-15 10:33 ` Vadim Fedorenko
2025-10-15 14:37 ` Simon Horman
2025-10-15 20:18 ` Jacob Keller
0 siblings, 2 replies; 29+ messages in thread
From: Vadim Fedorenko @ 2025-10-15 10:33 UTC (permalink / raw)
To: Simon Horman
Cc: Shyam Sundar S K, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Egor Pomozov, Potnuri Bharat Teja,
Dimitris Michailidis, MD Danish Anwar, Roger Quadros,
Richard Cochran, Russell King, Vladimir Oltean, netdev
On 15/10/2025 11:05, Simon Horman wrote:
> On Tue, Oct 14, 2025 at 10:42:14PM +0000, Vadim Fedorenko wrote:
>> Convert to use .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks.
>>
>> Though I'm not quite sure it worked properly before the conversion.
>>
>> Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
>
> Hi Vadim,
>
> There is quite a lot of change here. Probably it's not worth "fixing"
> the current code before migrating it. But I think it would be worth
> expanding a bit on the statement about not being sure it worked?
Hi Simon!
Well, let me try to explain the statement about not being sure it
worked. The original code was copying new configuration into netdev's
private structure before validating that the values are acceptable by
the hardware. In case of error, the driver was not restoring original
values, and after the call:
ioctl(SIOCSHWTSTAMP, <unsupported_config>) = -ERANGE
the driver would have configuration which could not be reapplied and not
synced to the actual hardware config:
ioctl(SIOCGHWTSTAMP) = <unsupported_config>
The logic change in the patch is to just keep original configuration in
case of -ERANGE error. Otherwise the logic is not changed.
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH net-next v2 6/7] tsnep: convert to ndo_hwtstatmp API
2025-10-15 10:03 ` Simon Horman
@ 2025-10-15 10:38 ` Vadim Fedorenko
2025-10-15 14:38 ` Simon Horman
0 siblings, 1 reply; 29+ messages in thread
From: Vadim Fedorenko @ 2025-10-15 10:38 UTC (permalink / raw)
To: Simon Horman
Cc: Shyam Sundar S K, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Egor Pomozov, Potnuri Bharat Teja,
Dimitris Michailidis, MD Danish Anwar, Roger Quadros,
Richard Cochran, Russell King, Vladimir Oltean, netdev
On 15/10/2025 11:03, Simon Horman wrote:
> On Tue, Oct 14, 2025 at 10:42:15PM +0000, Vadim Fedorenko wrote:
>> Convert to .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks.
>> After conversions the rest of tsnep_netdev_ioctl() becomes pure
>> phy_do_ioctl_running(), so remove tsnep_netdev_ioctl() and replace
>> it with phy_do_ioctl_running() in .ndo_eth_ioctl.
>>
>> Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
>
> ...
>
>> diff --git a/drivers/net/ethernet/engleder/tsnep_ptp.c b/drivers/net/ethernet/engleder/tsnep_ptp.c
>> index 54fbf0126815..ae1308eb813d 100644
>> --- a/drivers/net/ethernet/engleder/tsnep_ptp.c
>> +++ b/drivers/net/ethernet/engleder/tsnep_ptp.c
>> @@ -19,57 +19,53 @@ void tsnep_get_system_time(struct tsnep_adapter *adapter, u64 *time)
>> *time = (((u64)high) << 32) | ((u64)low);
>> }
>>
>> -int tsnep_ptp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
>> +int tsnep_ptp_hwtstamp_get(struct net_device *netdev,
>> + struct kernel_hwtstamp_config *config)
>> {
>> struct tsnep_adapter *adapter = netdev_priv(netdev);
>> - struct hwtstamp_config config;
>> -
>> - if (!ifr)
>> - return -EINVAL;
>> -
>> - if (cmd == SIOCSHWTSTAMP) {
>> - if (copy_from_user(&config, ifr->ifr_data, sizeof(config)))
>> - return -EFAULT;
>> -
>> - switch (config.tx_type) {
>> - case HWTSTAMP_TX_OFF:
>> - case HWTSTAMP_TX_ON:
>> - break;
>> - default:
>> - return -ERANGE;
>> - }
>> -
>> - switch (config.rx_filter) {
>> - case HWTSTAMP_FILTER_NONE:
>> - break;
>> - case HWTSTAMP_FILTER_ALL:
>> - case HWTSTAMP_FILTER_PTP_V1_L4_EVENT:
>> - case HWTSTAMP_FILTER_PTP_V1_L4_SYNC:
>> - case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ:
>> - case HWTSTAMP_FILTER_PTP_V2_L4_EVENT:
>> - case HWTSTAMP_FILTER_PTP_V2_L4_SYNC:
>> - case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ:
>> - case HWTSTAMP_FILTER_PTP_V2_L2_EVENT:
>> - case HWTSTAMP_FILTER_PTP_V2_L2_SYNC:
>> - case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ:
>> - case HWTSTAMP_FILTER_PTP_V2_EVENT:
>> - case HWTSTAMP_FILTER_PTP_V2_SYNC:
>> - case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ:
>> - case HWTSTAMP_FILTER_NTP_ALL:
>> - config.rx_filter = HWTSTAMP_FILTER_ALL;
>> - break;
>> - default:
>> - return -ERANGE;
>> - }
>
> Hi Vadim,
>
> I'm probably missing something obvious, but it's not clear to me why
> removing the inner switch statements above is ok. Or, perhaps more to the
> point, it seems inconsistent with other patches in this series.
>
> OTOH, I do see why dropping the outer if conditions makes sense.
I believe it's just a question for git diff. It replaces original
tsnep_ptp_ioctl() function with get() callback. The only thing that new
function does is copying actual config into reply.
The switch statement goes to set() callback where the logic is kept as
is. Original tsnep_ptp_ioctl() was serving both get and set operations,
but the logic was applied to set operation only.
>
>> -
>> - memcpy(&adapter->hwtstamp_config, &config,
>> - sizeof(adapter->hwtstamp_config));
>> +
>> + *config = adapter->hwtstamp_config;
>> + return 0;
>> +}
>
> ...
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH net-next v2 5/7] cxgb4: convert to ndo_hwtstamp API
2025-10-15 10:33 ` Vadim Fedorenko
@ 2025-10-15 14:37 ` Simon Horman
2025-10-15 20:05 ` Vadim Fedorenko
2025-10-15 20:18 ` Jacob Keller
1 sibling, 1 reply; 29+ messages in thread
From: Simon Horman @ 2025-10-15 14:37 UTC (permalink / raw)
To: Vadim Fedorenko
Cc: Shyam Sundar S K, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Egor Pomozov, Potnuri Bharat Teja,
Dimitris Michailidis, MD Danish Anwar, Roger Quadros,
Richard Cochran, Russell King, Vladimir Oltean, netdev
On Wed, Oct 15, 2025 at 11:33:02AM +0100, Vadim Fedorenko wrote:
> On 15/10/2025 11:05, Simon Horman wrote:
> > On Tue, Oct 14, 2025 at 10:42:14PM +0000, Vadim Fedorenko wrote:
> > > Convert to use .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks.
> > >
> > > Though I'm not quite sure it worked properly before the conversion.
> > >
> > > Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
> >
> > Hi Vadim,
> >
> > There is quite a lot of change here. Probably it's not worth "fixing"
> > the current code before migrating it. But I think it would be worth
> > expanding a bit on the statement about not being sure it worked?
>
> Hi Simon!
>
> Well, let me try to explain the statement about not being sure it
> worked. The original code was copying new configuration into netdev's
> private structure before validating that the values are acceptable by
> the hardware. In case of error, the driver was not restoring original
> values, and after the call:
>
> ioctl(SIOCSHWTSTAMP, <unsupported_config>) = -ERANGE
>
> the driver would have configuration which could not be reapplied and not
> synced to the actual hardware config:
>
> ioctl(SIOCGHWTSTAMP) = <unsupported_config>
>
> The logic change in the patch is to just keep original configuration in
> case of -ERANGE error. Otherwise the logic is not changed.
Thanks Vadim,
I see that now and it makes sense to me.
I do think it would be worth mentioning in the patch description.
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH net-next v2 6/7] tsnep: convert to ndo_hwtstatmp API
2025-10-15 10:38 ` Vadim Fedorenko
@ 2025-10-15 14:38 ` Simon Horman
0 siblings, 0 replies; 29+ messages in thread
From: Simon Horman @ 2025-10-15 14:38 UTC (permalink / raw)
To: Vadim Fedorenko
Cc: Shyam Sundar S K, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Egor Pomozov, Potnuri Bharat Teja,
Dimitris Michailidis, MD Danish Anwar, Roger Quadros,
Richard Cochran, Russell King, Vladimir Oltean, netdev
On Wed, Oct 15, 2025 at 11:38:34AM +0100, Vadim Fedorenko wrote:
> On 15/10/2025 11:03, Simon Horman wrote:
> > On Tue, Oct 14, 2025 at 10:42:15PM +0000, Vadim Fedorenko wrote:
...
> > Hi Vadim,
> >
> > I'm probably missing something obvious, but it's not clear to me why
> > removing the inner switch statements above is ok. Or, perhaps more to the
> > point, it seems inconsistent with other patches in this series.
> >
> > OTOH, I do see why dropping the outer if conditions makes sense.
>
> I believe it's just a question for git diff. It replaces original
> tsnep_ptp_ioctl() function with get() callback. The only thing that new
> function does is copying actual config into reply.
>
> The switch statement goes to set() callback where the logic is kept as
> is. Original tsnep_ptp_ioctl() was serving both get and set operations,
> but the logic was applied to set operation only.
Thanks, silly me. I see that now.
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH net-next v2 1/7] net: ti: am65-cpsw: move hw timestamping to ndo callback
2025-10-14 22:42 ` [PATCH net-next v2 1/7] net: ti: am65-cpsw: move hw timestamping to ndo callback Vadim Fedorenko
@ 2025-10-15 14:39 ` Simon Horman
2025-10-15 19:45 ` Jacob Keller
1 sibling, 0 replies; 29+ messages in thread
From: Simon Horman @ 2025-10-15 14:39 UTC (permalink / raw)
To: Vadim Fedorenko
Cc: Shyam Sundar S K, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Egor Pomozov, Potnuri Bharat Teja,
Dimitris Michailidis, MD Danish Anwar, Roger Quadros,
Richard Cochran, Russell King, Vladimir Oltean, netdev
On Tue, Oct 14, 2025 at 10:42:10PM +0000, Vadim Fedorenko wrote:
> Migrate driver to new API for HW timestamping.
>
> Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH net-next v2 2/7] ti: icssg: convert to ndo_hwtstamp API
2025-10-14 22:42 ` [PATCH net-next v2 2/7] ti: icssg: convert to ndo_hwtstamp API Vadim Fedorenko
@ 2025-10-15 14:39 ` Simon Horman
2025-10-15 19:46 ` Jacob Keller
1 sibling, 0 replies; 29+ messages in thread
From: Simon Horman @ 2025-10-15 14:39 UTC (permalink / raw)
To: Vadim Fedorenko
Cc: Shyam Sundar S K, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Egor Pomozov, Potnuri Bharat Teja,
Dimitris Michailidis, MD Danish Anwar, Roger Quadros,
Richard Cochran, Russell King, Vladimir Oltean, netdev
On Tue, Oct 14, 2025 at 10:42:11PM +0000, Vadim Fedorenko wrote:
> Convert driver to use .ndo_hwtstamp_get()/.ndo_hwtstamp_set() API.
> .ndo_eth_ioctl() implementation becomes pure phy_do_ioctl(), remove
> it from common module, remove exported symbol and replace ndo callback.
>
> Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH net-next v2 3/7] amd-xgbe: convert to ndo_hwtstamp callbacks
2025-10-14 22:42 ` [PATCH net-next v2 3/7] amd-xgbe: convert to ndo_hwtstamp callbacks Vadim Fedorenko
@ 2025-10-15 14:40 ` Simon Horman
2025-10-15 19:47 ` Jacob Keller
1 sibling, 0 replies; 29+ messages in thread
From: Simon Horman @ 2025-10-15 14:40 UTC (permalink / raw)
To: Vadim Fedorenko
Cc: Shyam Sundar S K, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Egor Pomozov, Potnuri Bharat Teja,
Dimitris Michailidis, MD Danish Anwar, Roger Quadros,
Richard Cochran, Russell King, Vladimir Oltean, netdev
On Tue, Oct 14, 2025 at 10:42:12PM +0000, Vadim Fedorenko wrote:
> Convert driver to use .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks.
> .ndo_eth_ioctl() becomes empty function, remove it.
>
> Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH net-next v2 4/7] net: atlantic: convert to ndo_hwtstamp API
2025-10-14 22:42 ` [PATCH net-next v2 4/7] net: atlantic: convert to ndo_hwtstamp API Vadim Fedorenko
@ 2025-10-15 14:40 ` Simon Horman
2025-10-15 19:49 ` Jacob Keller
1 sibling, 0 replies; 29+ messages in thread
From: Simon Horman @ 2025-10-15 14:40 UTC (permalink / raw)
To: Vadim Fedorenko
Cc: Shyam Sundar S K, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Egor Pomozov, Potnuri Bharat Teja,
Dimitris Michailidis, MD Danish Anwar, Roger Quadros,
Richard Cochran, Russell King, Vladimir Oltean, netdev
On Tue, Oct 14, 2025 at 10:42:13PM +0000, Vadim Fedorenko wrote:
> Convert driver to .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks.
> .ndo_eth_ioctl() becomes empty so remove it. Also simplify code with no
> functional changes.
>
> Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH net-next v2 7/7] funeth: convert to ndo_hwtstamp API
2025-10-14 22:42 ` [PATCH net-next v2 7/7] funeth: convert to ndo_hwtstamp API Vadim Fedorenko
@ 2025-10-15 14:40 ` Simon Horman
2025-10-15 20:20 ` Jacob Keller
1 sibling, 0 replies; 29+ messages in thread
From: Simon Horman @ 2025-10-15 14:40 UTC (permalink / raw)
To: Vadim Fedorenko
Cc: Shyam Sundar S K, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Egor Pomozov, Potnuri Bharat Teja,
Dimitris Michailidis, MD Danish Anwar, Roger Quadros,
Richard Cochran, Russell King, Vladimir Oltean, netdev
On Tue, Oct 14, 2025 at 10:42:16PM +0000, Vadim Fedorenko wrote:
> Convert driver to use .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks.
> .ndo_eth_ioctl() implementation becomes empty, remove it.
>
> Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH net-next v2 1/7] net: ti: am65-cpsw: move hw timestamping to ndo callback
2025-10-14 22:42 ` [PATCH net-next v2 1/7] net: ti: am65-cpsw: move hw timestamping to ndo callback Vadim Fedorenko
2025-10-15 14:39 ` Simon Horman
@ 2025-10-15 19:45 ` Jacob Keller
1 sibling, 0 replies; 29+ messages in thread
From: Jacob Keller @ 2025-10-15 19:45 UTC (permalink / raw)
To: Vadim Fedorenko, Shyam Sundar S K, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Egor Pomozov,
Potnuri Bharat Teja, Dimitris Michailidis, MD Danish Anwar,
Roger Quadros
Cc: Richard Cochran, Russell King, Vladimir Oltean, Simon Horman,
netdev
[-- Attachment #1.1: Type: text/plain, Size: 1889 bytes --]
On 10/14/2025 3:42 PM, Vadim Fedorenko wrote:
> Migrate driver to new API for HW timestamping.
>
> Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
> ---
> drivers/net/ethernet/ti/am65-cpsw-nuss.c | 44 +++++++++++-------------
> 1 file changed, 20 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> index 110eb2da8dbc..d5f358ec9820 100644
> --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> @@ -1788,28 +1788,28 @@ static int am65_cpsw_nuss_ndo_slave_set_mac_address(struct net_device *ndev,
> }
>
> static int am65_cpsw_nuss_hwtstamp_set(struct net_device *ndev,
> - struct ifreq *ifr)
> + struct kernel_hwtstamp_config *cfg,
> + struct netlink_ext_ack *extack)
> {
> struct am65_cpsw_port *port = am65_ndev_to_port(ndev);
> u32 ts_ctrl, seq_id, ts_ctrl_ltype2, ts_vlan_ltype;
> - struct hwtstamp_config cfg;
>
> - if (!IS_ENABLED(CONFIG_TI_K3_AM65_CPTS))
> + if (!IS_ENABLED(CONFIG_TI_K3_AM65_CPTS)) {
> + NL_SET_ERR_MSG(extack, "Time stamping is not supported");
> return -EOPNOTSUPP;
> -
> - if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg)))
> - return -EFAULT;
> + }
>
> /* TX HW timestamp */
> - switch (cfg.tx_type) {
> + switch (cfg->tx_type) {
> case HWTSTAMP_TX_OFF:
> case HWTSTAMP_TX_ON:
> break;
> default:
> + NL_SET_ERR_MSG(extack, "TX mode is not supported");
We could use NL_ST_ERR_MSG_MOD_FMT and format the particular invalid
type here, but not certain how helpful that would be in practice.
Perhaps the unsupported filter type is obvious from context of sending
the invalid netlink command?
Either way, the conversion looks quite straight forward.
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH net-next v2 2/7] ti: icssg: convert to ndo_hwtstamp API
2025-10-14 22:42 ` [PATCH net-next v2 2/7] ti: icssg: convert to ndo_hwtstamp API Vadim Fedorenko
2025-10-15 14:39 ` Simon Horman
@ 2025-10-15 19:46 ` Jacob Keller
1 sibling, 0 replies; 29+ messages in thread
From: Jacob Keller @ 2025-10-15 19:46 UTC (permalink / raw)
To: Vadim Fedorenko, Shyam Sundar S K, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Egor Pomozov,
Potnuri Bharat Teja, Dimitris Michailidis, MD Danish Anwar,
Roger Quadros
Cc: Richard Cochran, Russell King, Vladimir Oltean, Simon Horman,
netdev
[-- Attachment #1.1: Type: text/plain, Size: 394 bytes --]
On 10/14/2025 3:42 PM, Vadim Fedorenko wrote:
> Convert driver to use .ndo_hwtstamp_get()/.ndo_hwtstamp_set() API.
> .ndo_eth_ioctl() implementation becomes pure phy_do_ioctl(), remove
> it from common module, remove exported symbol and replace ndo callback.
>
> Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
> ---
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH net-next v2 3/7] amd-xgbe: convert to ndo_hwtstamp callbacks
2025-10-14 22:42 ` [PATCH net-next v2 3/7] amd-xgbe: convert to ndo_hwtstamp callbacks Vadim Fedorenko
2025-10-15 14:40 ` Simon Horman
@ 2025-10-15 19:47 ` Jacob Keller
2025-10-15 19:58 ` Vadim Fedorenko
1 sibling, 1 reply; 29+ messages in thread
From: Jacob Keller @ 2025-10-15 19:47 UTC (permalink / raw)
To: Vadim Fedorenko, Shyam Sundar S K, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Egor Pomozov,
Potnuri Bharat Teja, Dimitris Michailidis, MD Danish Anwar,
Roger Quadros
Cc: Richard Cochran, Russell King, Vladimir Oltean, Simon Horman,
netdev
[-- Attachment #1.1: Type: text/plain, Size: 1537 bytes --]
On 10/14/2025 3:42 PM, Vadim Fedorenko wrote:
> diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-hwtstamp.c b/drivers/net/ethernet/amd/xgbe/xgbe-hwtstamp.c
> index bc52e5ec6420..0127988e10be 100644
> --- a/drivers/net/ethernet/amd/xgbe/xgbe-hwtstamp.c
> +++ b/drivers/net/ethernet/amd/xgbe/xgbe-hwtstamp.c
> @@ -157,26 +157,24 @@ void xgbe_tx_tstamp(struct work_struct *work)
> spin_unlock_irqrestore(&pdata->tstamp_lock, flags);
> }
>
> -int xgbe_get_hwtstamp_settings(struct xgbe_prv_data *pdata, struct ifreq *ifreq)
> +int xgbe_get_hwtstamp_settings(struct net_device *netdev,
> + struct kernel_hwtstamp_config *config)
> {
> - if (copy_to_user(ifreq->ifr_data, &pdata->tstamp_config,
> - sizeof(pdata->tstamp_config)))
> - return -EFAULT;
> + struct xgbe_prv_data *pdata = netdev_priv(netdev);
> +
> + *config = pdata->tstamp_config;
>
> return 0;
> }
>
> -int xgbe_set_hwtstamp_settings(struct xgbe_prv_data *pdata, struct ifreq *ifreq)
> +int xgbe_set_hwtstamp_settings(struct net_device *netdev,
> + struct kernel_hwtstamp_config *config,
> + struct netlink_ext_ack *extack)
> {
> - struct hwtstamp_config config;
> - unsigned int mac_tscr;
> -
> - if (copy_from_user(&config, ifreq->ifr_data, sizeof(config)))
> - return -EFAULT;
> -
> - mac_tscr = 0;
> + struct xgbe_prv_data *pdata = netdev_priv(netdev);
> + unsigned int mac_tscr = 0;
>
I noticed in this driver you didn't bother to add NL_SET_ERR_MSG calls.
Any particular reason?
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH net-next v2 4/7] net: atlantic: convert to ndo_hwtstamp API
2025-10-14 22:42 ` [PATCH net-next v2 4/7] net: atlantic: convert to ndo_hwtstamp API Vadim Fedorenko
2025-10-15 14:40 ` Simon Horman
@ 2025-10-15 19:49 ` Jacob Keller
1 sibling, 0 replies; 29+ messages in thread
From: Jacob Keller @ 2025-10-15 19:49 UTC (permalink / raw)
To: Vadim Fedorenko, Shyam Sundar S K, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Egor Pomozov,
Potnuri Bharat Teja, Dimitris Michailidis, MD Danish Anwar,
Roger Quadros
Cc: Richard Cochran, Russell King, Vladimir Oltean, Simon Horman,
netdev
[-- Attachment #1.1: Type: text/plain, Size: 350 bytes --]
On 10/14/2025 3:42 PM, Vadim Fedorenko wrote:
> Convert driver to .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks.
> .ndo_eth_ioctl() becomes empty so remove it. Also simplify code with no
> functional changes.
>
> Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
> ---
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH net-next v2 3/7] amd-xgbe: convert to ndo_hwtstamp callbacks
2025-10-15 19:47 ` Jacob Keller
@ 2025-10-15 19:58 ` Vadim Fedorenko
2025-10-15 20:23 ` Jacob Keller
0 siblings, 1 reply; 29+ messages in thread
From: Vadim Fedorenko @ 2025-10-15 19:58 UTC (permalink / raw)
To: Jacob Keller, Shyam Sundar S K, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Egor Pomozov,
Potnuri Bharat Teja, Dimitris Michailidis, MD Danish Anwar,
Roger Quadros
Cc: Richard Cochran, Russell King, Vladimir Oltean, Simon Horman,
netdev
On 15.10.2025 20:47, Jacob Keller wrote:
>
>
> On 10/14/2025 3:42 PM, Vadim Fedorenko wrote:
>> diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-hwtstamp.c b/drivers/net/ethernet/amd/xgbe/xgbe-hwtstamp.c
>> index bc52e5ec6420..0127988e10be 100644
>> --- a/drivers/net/ethernet/amd/xgbe/xgbe-hwtstamp.c
>> +++ b/drivers/net/ethernet/amd/xgbe/xgbe-hwtstamp.c
>> @@ -157,26 +157,24 @@ void xgbe_tx_tstamp(struct work_struct *work)
>> spin_unlock_irqrestore(&pdata->tstamp_lock, flags);
>> }
>>
>> -int xgbe_get_hwtstamp_settings(struct xgbe_prv_data *pdata, struct ifreq *ifreq)
>> +int xgbe_get_hwtstamp_settings(struct net_device *netdev,
>> + struct kernel_hwtstamp_config *config)
>> {
>> - if (copy_to_user(ifreq->ifr_data, &pdata->tstamp_config,
>> - sizeof(pdata->tstamp_config)))
>> - return -EFAULT;
>> + struct xgbe_prv_data *pdata = netdev_priv(netdev);
>> +
>> + *config = pdata->tstamp_config;
>>
>> return 0;
>> }
>>
>> -int xgbe_set_hwtstamp_settings(struct xgbe_prv_data *pdata, struct ifreq *ifreq)
>> +int xgbe_set_hwtstamp_settings(struct net_device *netdev,
>> + struct kernel_hwtstamp_config *config,
>> + struct netlink_ext_ack *extack)
>> {
>> - struct hwtstamp_config config;
>> - unsigned int mac_tscr;
>> -
>> - if (copy_from_user(&config, ifreq->ifr_data, sizeof(config)))
>> - return -EFAULT;
>> -
>> - mac_tscr = 0;
>> + struct xgbe_prv_data *pdata = netdev_priv(netdev);
>> + unsigned int mac_tscr = 0;
>>
>
> I noticed in this driver you didn't bother to add NL_SET_ERR_MSG calls.
> Any particular reason?
The only error here is the -ERANGE which is self-explanatory, so I decided to
keep the amount of changed lines as low as possible.
We might think of adding netlink error message for ERANGE error in
dev_set_hwtstamp() in case the driver skips setting specific message.
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH net-next v2 5/7] cxgb4: convert to ndo_hwtstamp API
2025-10-15 14:37 ` Simon Horman
@ 2025-10-15 20:05 ` Vadim Fedorenko
2025-10-16 8:10 ` Simon Horman
0 siblings, 1 reply; 29+ messages in thread
From: Vadim Fedorenko @ 2025-10-15 20:05 UTC (permalink / raw)
To: Simon Horman
Cc: Shyam Sundar S K, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Egor Pomozov, Potnuri Bharat Teja,
Dimitris Michailidis, MD Danish Anwar, Roger Quadros,
Richard Cochran, Russell King, Vladimir Oltean, netdev
On 15.10.2025 15:37, Simon Horman wrote:
> On Wed, Oct 15, 2025 at 11:33:02AM +0100, Vadim Fedorenko wrote:
>> On 15/10/2025 11:05, Simon Horman wrote:
>>> On Tue, Oct 14, 2025 at 10:42:14PM +0000, Vadim Fedorenko wrote:
>>>> Convert to use .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks.
>>>>
>>>> Though I'm not quite sure it worked properly before the conversion.
>>>>
>>>> Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
>>>
>>> Hi Vadim,
>>>
>>> There is quite a lot of change here. Probably it's not worth "fixing"
>>> the current code before migrating it. But I think it would be worth
>>> expanding a bit on the statement about not being sure it worked?
>>
>> Hi Simon!
>>
>> Well, let me try to explain the statement about not being sure it
>> worked. The original code was copying new configuration into netdev's
>> private structure before validating that the values are acceptable by
>> the hardware. In case of error, the driver was not restoring original
>> values, and after the call:
>>
>> ioctl(SIOCSHWTSTAMP, <unsupported_config>) = -ERANGE
>>
>> the driver would have configuration which could not be reapplied and not
>> synced to the actual hardware config:
>>
>> ioctl(SIOCGHWTSTAMP) = <unsupported_config>
>>
>> The logic change in the patch is to just keep original configuration in
>> case of -ERANGE error. Otherwise the logic is not changed.
>
> Thanks Vadim,
>
> I see that now and it makes sense to me.
> I do think it would be worth mentioning in the patch description.
Fair point, I'll update commit message for v3.
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH net-next v2 5/7] cxgb4: convert to ndo_hwtstamp API
2025-10-15 10:33 ` Vadim Fedorenko
2025-10-15 14:37 ` Simon Horman
@ 2025-10-15 20:18 ` Jacob Keller
1 sibling, 0 replies; 29+ messages in thread
From: Jacob Keller @ 2025-10-15 20:18 UTC (permalink / raw)
To: Vadim Fedorenko, Simon Horman
Cc: Shyam Sundar S K, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Egor Pomozov, Potnuri Bharat Teja,
Dimitris Michailidis, MD Danish Anwar, Roger Quadros,
Richard Cochran, Russell King, Vladimir Oltean, netdev
[-- Attachment #1.1: Type: text/plain, Size: 1635 bytes --]
On 10/15/2025 3:33 AM, Vadim Fedorenko wrote:
> On 15/10/2025 11:05, Simon Horman wrote:
>> On Tue, Oct 14, 2025 at 10:42:14PM +0000, Vadim Fedorenko wrote:
>>> Convert to use .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks.
>>>
>>> Though I'm not quite sure it worked properly before the conversion.
>>>
>>> Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
>>
>> Hi Vadim,
>>
>> There is quite a lot of change here. Probably it's not worth "fixing"
>> the current code before migrating it. But I think it would be worth
>> expanding a bit on the statement about not being sure it worked?
>
> Hi Simon!
>
> Well, let me try to explain the statement about not being sure it
> worked. The original code was copying new configuration into netdev's
> private structure before validating that the values are acceptable by
> the hardware. In case of error, the driver was not restoring original
> values, and after the call:
>
> ioctl(SIOCSHWTSTAMP, <unsupported_config>) = -ERANGE
>
> the driver would have configuration which could not be reapplied and not
> synced to the actual hardware config:
>
> ioctl(SIOCGHWTSTAMP) = <unsupported_config>
>
> The logic change in the patch is to just keep original configuration in
> case of -ERANGE error. Otherwise the logic is not changed.
>
>
Makes sense. It isn't entirely clear if that could cause an actual
problem since the flags the driver uses appear to be set after
validation (ptp_enable and the call to cxgb4_ptprx_timstamping) .. But
having stale data there seems like it could lead to trouble and is worth
cleaning up.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH net-next v2 7/7] funeth: convert to ndo_hwtstamp API
2025-10-14 22:42 ` [PATCH net-next v2 7/7] funeth: convert to ndo_hwtstamp API Vadim Fedorenko
2025-10-15 14:40 ` Simon Horman
@ 2025-10-15 20:20 ` Jacob Keller
1 sibling, 0 replies; 29+ messages in thread
From: Jacob Keller @ 2025-10-15 20:20 UTC (permalink / raw)
To: Vadim Fedorenko, Shyam Sundar S K, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Egor Pomozov,
Potnuri Bharat Teja, Dimitris Michailidis, MD Danish Anwar,
Roger Quadros
Cc: Richard Cochran, Russell King, Vladimir Oltean, Simon Horman,
netdev
[-- Attachment #1.1: Type: text/plain, Size: 315 bytes --]
On 10/14/2025 3:42 PM, Vadim Fedorenko wrote:
> Convert driver to use .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks.
> .ndo_eth_ioctl() implementation becomes empty, remove it.
>
> Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
> ---
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH net-next v2 3/7] amd-xgbe: convert to ndo_hwtstamp callbacks
2025-10-15 19:58 ` Vadim Fedorenko
@ 2025-10-15 20:23 ` Jacob Keller
0 siblings, 0 replies; 29+ messages in thread
From: Jacob Keller @ 2025-10-15 20:23 UTC (permalink / raw)
To: Vadim Fedorenko, Shyam Sundar S K, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Egor Pomozov,
Potnuri Bharat Teja, Dimitris Michailidis, MD Danish Anwar,
Roger Quadros
Cc: Richard Cochran, Russell King, Vladimir Oltean, Simon Horman,
netdev
[-- Attachment #1.1: Type: text/plain, Size: 2197 bytes --]
On 10/15/2025 12:58 PM, Vadim Fedorenko wrote:
> On 15.10.2025 20:47, Jacob Keller wrote:
>>
>>
>> On 10/14/2025 3:42 PM, Vadim Fedorenko wrote:
>>> diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-hwtstamp.c b/drivers/net/ethernet/amd/xgbe/xgbe-hwtstamp.c
>>> index bc52e5ec6420..0127988e10be 100644
>>> --- a/drivers/net/ethernet/amd/xgbe/xgbe-hwtstamp.c
>>> +++ b/drivers/net/ethernet/amd/xgbe/xgbe-hwtstamp.c
>>> @@ -157,26 +157,24 @@ void xgbe_tx_tstamp(struct work_struct *work)
>>> spin_unlock_irqrestore(&pdata->tstamp_lock, flags);
>>> }
>>>
>>> -int xgbe_get_hwtstamp_settings(struct xgbe_prv_data *pdata, struct ifreq *ifreq)
>>> +int xgbe_get_hwtstamp_settings(struct net_device *netdev,
>>> + struct kernel_hwtstamp_config *config)
>>> {
>>> - if (copy_to_user(ifreq->ifr_data, &pdata->tstamp_config,
>>> - sizeof(pdata->tstamp_config)))
>>> - return -EFAULT;
>>> + struct xgbe_prv_data *pdata = netdev_priv(netdev);
>>> +
>>> + *config = pdata->tstamp_config;
>>>
>>> return 0;
>>> }
>>>
>>> -int xgbe_set_hwtstamp_settings(struct xgbe_prv_data *pdata, struct ifreq *ifreq)
>>> +int xgbe_set_hwtstamp_settings(struct net_device *netdev,
>>> + struct kernel_hwtstamp_config *config,
>>> + struct netlink_ext_ack *extack)
>>> {
>>> - struct hwtstamp_config config;
>>> - unsigned int mac_tscr;
>>> -
>>> - if (copy_from_user(&config, ifreq->ifr_data, sizeof(config)))
>>> - return -EFAULT;
>>> -
>>> - mac_tscr = 0;
>>> + struct xgbe_prv_data *pdata = netdev_priv(netdev);
>>> + unsigned int mac_tscr = 0;
>>>
>>
>> I noticed in this driver you didn't bother to add NL_SET_ERR_MSG calls.
>> Any particular reason?
>
> The only error here is the -ERANGE which is self-explanatory, so I decided to
> keep the amount of changed lines as low as possible.
>
Makes sense.
> We might think of adding netlink error message for ERANGE error in
> dev_set_hwtstamp() in case the driver skips setting specific message.
I think this is a good approach. Use a generic message when unset by the
driver.
For the patch:
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH net-next v2 5/7] cxgb4: convert to ndo_hwtstamp API
2025-10-15 20:05 ` Vadim Fedorenko
@ 2025-10-16 8:10 ` Simon Horman
0 siblings, 0 replies; 29+ messages in thread
From: Simon Horman @ 2025-10-16 8:10 UTC (permalink / raw)
To: Vadim Fedorenko
Cc: Shyam Sundar S K, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Egor Pomozov, Potnuri Bharat Teja,
Dimitris Michailidis, MD Danish Anwar, Roger Quadros,
Richard Cochran, Russell King, Vladimir Oltean, netdev
On Wed, Oct 15, 2025 at 09:05:16PM +0100, Vadim Fedorenko wrote:
> On 15.10.2025 15:37, Simon Horman wrote:
> > On Wed, Oct 15, 2025 at 11:33:02AM +0100, Vadim Fedorenko wrote:
> > > On 15/10/2025 11:05, Simon Horman wrote:
> > > > On Tue, Oct 14, 2025 at 10:42:14PM +0000, Vadim Fedorenko wrote:
> > > > > Convert to use .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks.
> > > > >
> > > > > Though I'm not quite sure it worked properly before the conversion.
> > > > >
> > > > > Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
> > > >
> > > > Hi Vadim,
> > > >
> > > > There is quite a lot of change here. Probably it's not worth "fixing"
> > > > the current code before migrating it. But I think it would be worth
> > > > expanding a bit on the statement about not being sure it worked?
> > >
> > > Hi Simon!
> > >
> > > Well, let me try to explain the statement about not being sure it
> > > worked. The original code was copying new configuration into netdev's
> > > private structure before validating that the values are acceptable by
> > > the hardware. In case of error, the driver was not restoring original
> > > values, and after the call:
> > >
> > > ioctl(SIOCSHWTSTAMP, <unsupported_config>) = -ERANGE
> > >
> > > the driver would have configuration which could not be reapplied and not
> > > synced to the actual hardware config:
> > >
> > > ioctl(SIOCGHWTSTAMP) = <unsupported_config>
> > >
> > > The logic change in the patch is to just keep original configuration in
> > > case of -ERANGE error. Otherwise the logic is not changed.
> >
> > Thanks Vadim,
> >
> > I see that now and it makes sense to me.
> > I do think it would be worth mentioning in the patch description.
>
> Fair point, I'll update commit message for v3.
Thanks, much appreciated.
^ permalink raw reply [flat|nested] 29+ messages in thread
end of thread, other threads:[~2025-10-16 8:10 UTC | newest]
Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-14 22:42 [PATCH net-next v2 0/7] convert net drivers to ndo_hwtstamp API part 1 Vadim Fedorenko
2025-10-14 22:42 ` [PATCH net-next v2 1/7] net: ti: am65-cpsw: move hw timestamping to ndo callback Vadim Fedorenko
2025-10-15 14:39 ` Simon Horman
2025-10-15 19:45 ` Jacob Keller
2025-10-14 22:42 ` [PATCH net-next v2 2/7] ti: icssg: convert to ndo_hwtstamp API Vadim Fedorenko
2025-10-15 14:39 ` Simon Horman
2025-10-15 19:46 ` Jacob Keller
2025-10-14 22:42 ` [PATCH net-next v2 3/7] amd-xgbe: convert to ndo_hwtstamp callbacks Vadim Fedorenko
2025-10-15 14:40 ` Simon Horman
2025-10-15 19:47 ` Jacob Keller
2025-10-15 19:58 ` Vadim Fedorenko
2025-10-15 20:23 ` Jacob Keller
2025-10-14 22:42 ` [PATCH net-next v2 4/7] net: atlantic: convert to ndo_hwtstamp API Vadim Fedorenko
2025-10-15 14:40 ` Simon Horman
2025-10-15 19:49 ` Jacob Keller
2025-10-14 22:42 ` [PATCH net-next v2 5/7] cxgb4: " Vadim Fedorenko
2025-10-15 10:05 ` Simon Horman
2025-10-15 10:33 ` Vadim Fedorenko
2025-10-15 14:37 ` Simon Horman
2025-10-15 20:05 ` Vadim Fedorenko
2025-10-16 8:10 ` Simon Horman
2025-10-15 20:18 ` Jacob Keller
2025-10-14 22:42 ` [PATCH net-next v2 6/7] tsnep: convert to ndo_hwtstatmp API Vadim Fedorenko
2025-10-15 10:03 ` Simon Horman
2025-10-15 10:38 ` Vadim Fedorenko
2025-10-15 14:38 ` Simon Horman
2025-10-14 22:42 ` [PATCH net-next v2 7/7] funeth: convert to ndo_hwtstamp API Vadim Fedorenko
2025-10-15 14:40 ` Simon Horman
2025-10-15 20:20 ` Jacob Keller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).