* [PATCH net-next 2/2] net: lan743x: implement ndo_hwtstamp_get()
2025-05-14 15:19 [PATCH net-next 1/2] net: lan743x: convert to ndo_hwtstamp_set() Vladimir Oltean
@ 2025-05-14 15:19 ` Vladimir Oltean
2025-05-14 19:00 ` Gerhard Engleder
2025-05-14 21:27 ` Vadim Fedorenko
2025-05-14 18:57 ` [PATCH net-next 1/2] net: lan743x: convert to ndo_hwtstamp_set() Gerhard Engleder
` (2 subsequent siblings)
3 siblings, 2 replies; 7+ messages in thread
From: Vladimir Oltean @ 2025-05-14 15:19 UTC (permalink / raw)
To: netdev
Cc: Bryan Whitehead, Raju Lakkaraju, Vishvambar Panth S,
UNGLinuxDriver, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, Vadim Fedorenko,
Richard Cochran
Permit programs such as "hwtstamp_ctl -i eth0" to retrieve the current
timestamping configuration of the NIC, rather than returning "Device
driver does not have support for non-destructive SIOCGHWTSTAMP."
The driver configures all channels with the same timestamping settings.
On TX, retrieve the settings of the first channel, those should be
representative for the entire NIC. On RX, save the filter settings in a
new adapter field.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
drivers/net/ethernet/microchip/lan743x_main.c | 2 ++
drivers/net/ethernet/microchip/lan743x_main.h | 1 +
drivers/net/ethernet/microchip/lan743x_ptp.c | 18 ++++++++++++++++++
drivers/net/ethernet/microchip/lan743x_ptp.h | 3 ++-
4 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c
index b01695bf4f55..880681085df2 100644
--- a/drivers/net/ethernet/microchip/lan743x_main.c
+++ b/drivers/net/ethernet/microchip/lan743x_main.c
@@ -1729,6 +1729,7 @@ int lan743x_rx_set_tstamp_mode(struct lan743x_adapter *adapter,
default:
return -ERANGE;
}
+ adapter->rx_tstamp_filter = rx_filter;
return 0;
}
@@ -3445,6 +3446,7 @@ static const struct net_device_ops lan743x_netdev_ops = {
.ndo_change_mtu = lan743x_netdev_change_mtu,
.ndo_get_stats64 = lan743x_netdev_get_stats64,
.ndo_set_mac_address = lan743x_netdev_set_mac_address,
+ .ndo_hwtstamp_get = lan743x_ptp_hwtstamp_get,
.ndo_hwtstamp_set = lan743x_ptp_hwtstamp_set,
};
diff --git a/drivers/net/ethernet/microchip/lan743x_main.h b/drivers/net/ethernet/microchip/lan743x_main.h
index db5fc73e41cc..02a28b709163 100644
--- a/drivers/net/ethernet/microchip/lan743x_main.h
+++ b/drivers/net/ethernet/microchip/lan743x_main.h
@@ -1087,6 +1087,7 @@ struct lan743x_adapter {
phy_interface_t phy_interface;
struct phylink *phylink;
struct phylink_config phylink_config;
+ int rx_tstamp_filter;
};
#define LAN743X_COMPONENT_FLAG_RX(channel) BIT(20 + (channel))
diff --git a/drivers/net/ethernet/microchip/lan743x_ptp.c b/drivers/net/ethernet/microchip/lan743x_ptp.c
index 026d1660fd74..a3b48388b3fd 100644
--- a/drivers/net/ethernet/microchip/lan743x_ptp.c
+++ b/drivers/net/ethernet/microchip/lan743x_ptp.c
@@ -1736,6 +1736,24 @@ void lan743x_ptp_tx_timestamp_skb(struct lan743x_adapter *adapter,
lan743x_ptp_tx_ts_complete(adapter);
}
+int lan743x_ptp_hwtstamp_get(struct net_device *netdev,
+ struct kernel_hwtstamp_config *config)
+{
+ struct lan743x_adapter *adapter = netdev_priv(netdev);
+ struct lan743x_tx *tx = &adapter->tx[0];
+
+ if (tx->ts_flags & TX_TS_FLAG_ONE_STEP_SYNC)
+ config->tx_type = HWTSTAMP_TX_ONESTEP_SYNC;
+ else if (tx->ts_flags & TX_TS_FLAG_TIMESTAMPING_ENABLED)
+ config->tx_type = HWTSTAMP_TX_ON;
+ else
+ config->tx_type = HWTSTAMP_TX_OFF;
+
+ config->rx_filter = adapter->rx_tstamp_filter;
+
+ return 0;
+}
+
int lan743x_ptp_hwtstamp_set(struct net_device *netdev,
struct kernel_hwtstamp_config *config,
struct netlink_ext_ack *extack)
diff --git a/drivers/net/ethernet/microchip/lan743x_ptp.h b/drivers/net/ethernet/microchip/lan743x_ptp.h
index 9581a7992ff6..e8d073bfa2ca 100644
--- a/drivers/net/ethernet/microchip/lan743x_ptp.h
+++ b/drivers/net/ethernet/microchip/lan743x_ptp.h
@@ -51,7 +51,8 @@ int lan743x_ptp_open(struct lan743x_adapter *adapter);
void lan743x_ptp_close(struct lan743x_adapter *adapter);
void lan743x_ptp_update_latency(struct lan743x_adapter *adapter,
u32 link_speed);
-
+int lan743x_ptp_hwtstamp_get(struct net_device *netdev,
+ struct kernel_hwtstamp_config *config);
int lan743x_ptp_hwtstamp_set(struct net_device *netdev,
struct kernel_hwtstamp_config *config,
struct netlink_ext_ack *extack);
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH net-next 2/2] net: lan743x: implement ndo_hwtstamp_get()
2025-05-14 15:19 ` [PATCH net-next 2/2] net: lan743x: implement ndo_hwtstamp_get() Vladimir Oltean
@ 2025-05-14 19:00 ` Gerhard Engleder
2025-05-14 21:27 ` Vadim Fedorenko
1 sibling, 0 replies; 7+ messages in thread
From: Gerhard Engleder @ 2025-05-14 19:00 UTC (permalink / raw)
To: Vladimir Oltean, netdev
Cc: Bryan Whitehead, Raju Lakkaraju, Vishvambar Panth S,
UNGLinuxDriver, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, Vadim Fedorenko,
Richard Cochran
On 14.05.25 17:19, Vladimir Oltean wrote:
> Permit programs such as "hwtstamp_ctl -i eth0" to retrieve the current
> timestamping configuration of the NIC, rather than returning "Device
> driver does not have support for non-destructive SIOCGHWTSTAMP."
>
> The driver configures all channels with the same timestamping settings.
> On TX, retrieve the settings of the first channel, those should be
> representative for the entire NIC. On RX, save the filter settings in a
> new adapter field.
>
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> ---
> drivers/net/ethernet/microchip/lan743x_main.c | 2 ++
> drivers/net/ethernet/microchip/lan743x_main.h | 1 +
> drivers/net/ethernet/microchip/lan743x_ptp.c | 18 ++++++++++++++++++
> drivers/net/ethernet/microchip/lan743x_ptp.h | 3 ++-
> 4 files changed, 23 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c
> index b01695bf4f55..880681085df2 100644
> --- a/drivers/net/ethernet/microchip/lan743x_main.c
> +++ b/drivers/net/ethernet/microchip/lan743x_main.c
> @@ -1729,6 +1729,7 @@ int lan743x_rx_set_tstamp_mode(struct lan743x_adapter *adapter,
> default:
> return -ERANGE;
> }
> + adapter->rx_tstamp_filter = rx_filter;
> return 0;
> }
>
> @@ -3445,6 +3446,7 @@ static const struct net_device_ops lan743x_netdev_ops = {
> .ndo_change_mtu = lan743x_netdev_change_mtu,
> .ndo_get_stats64 = lan743x_netdev_get_stats64,
> .ndo_set_mac_address = lan743x_netdev_set_mac_address,
> + .ndo_hwtstamp_get = lan743x_ptp_hwtstamp_get,
> .ndo_hwtstamp_set = lan743x_ptp_hwtstamp_set,
> };
>
> diff --git a/drivers/net/ethernet/microchip/lan743x_main.h b/drivers/net/ethernet/microchip/lan743x_main.h
> index db5fc73e41cc..02a28b709163 100644
> --- a/drivers/net/ethernet/microchip/lan743x_main.h
> +++ b/drivers/net/ethernet/microchip/lan743x_main.h
> @@ -1087,6 +1087,7 @@ struct lan743x_adapter {
> phy_interface_t phy_interface;
> struct phylink *phylink;
> struct phylink_config phylink_config;
> + int rx_tstamp_filter;
> };
>
> #define LAN743X_COMPONENT_FLAG_RX(channel) BIT(20 + (channel))
> diff --git a/drivers/net/ethernet/microchip/lan743x_ptp.c b/drivers/net/ethernet/microchip/lan743x_ptp.c
> index 026d1660fd74..a3b48388b3fd 100644
> --- a/drivers/net/ethernet/microchip/lan743x_ptp.c
> +++ b/drivers/net/ethernet/microchip/lan743x_ptp.c
> @@ -1736,6 +1736,24 @@ void lan743x_ptp_tx_timestamp_skb(struct lan743x_adapter *adapter,
> lan743x_ptp_tx_ts_complete(adapter);
> }
>
> +int lan743x_ptp_hwtstamp_get(struct net_device *netdev,
> + struct kernel_hwtstamp_config *config)
> +{
> + struct lan743x_adapter *adapter = netdev_priv(netdev);
> + struct lan743x_tx *tx = &adapter->tx[0];
> +
> + if (tx->ts_flags & TX_TS_FLAG_ONE_STEP_SYNC)
> + config->tx_type = HWTSTAMP_TX_ONESTEP_SYNC;
> + else if (tx->ts_flags & TX_TS_FLAG_TIMESTAMPING_ENABLED)
> + config->tx_type = HWTSTAMP_TX_ON;
> + else
> + config->tx_type = HWTSTAMP_TX_OFF;
> +
> + config->rx_filter = adapter->rx_tstamp_filter;
> +
> + return 0;
> +}
> +
> int lan743x_ptp_hwtstamp_set(struct net_device *netdev,
> struct kernel_hwtstamp_config *config,
> struct netlink_ext_ack *extack)
> diff --git a/drivers/net/ethernet/microchip/lan743x_ptp.h b/drivers/net/ethernet/microchip/lan743x_ptp.h
> index 9581a7992ff6..e8d073bfa2ca 100644
> --- a/drivers/net/ethernet/microchip/lan743x_ptp.h
> +++ b/drivers/net/ethernet/microchip/lan743x_ptp.h
> @@ -51,7 +51,8 @@ int lan743x_ptp_open(struct lan743x_adapter *adapter);
> void lan743x_ptp_close(struct lan743x_adapter *adapter);
> void lan743x_ptp_update_latency(struct lan743x_adapter *adapter,
> u32 link_speed);
> -
> +int lan743x_ptp_hwtstamp_get(struct net_device *netdev,
> + struct kernel_hwtstamp_config *config);
> int lan743x_ptp_hwtstamp_set(struct net_device *netdev,
> struct kernel_hwtstamp_config *config,
> struct netlink_ext_ack *extack);
Reviewed-by: Gerhard Engleder <gerhard@engleder-embedded.com>
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH net-next 2/2] net: lan743x: implement ndo_hwtstamp_get()
2025-05-14 15:19 ` [PATCH net-next 2/2] net: lan743x: implement ndo_hwtstamp_get() Vladimir Oltean
2025-05-14 19:00 ` Gerhard Engleder
@ 2025-05-14 21:27 ` Vadim Fedorenko
1 sibling, 0 replies; 7+ messages in thread
From: Vadim Fedorenko @ 2025-05-14 21:27 UTC (permalink / raw)
To: Vladimir Oltean, netdev
Cc: Bryan Whitehead, Raju Lakkaraju, Vishvambar Panth S,
UNGLinuxDriver, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, Richard Cochran
On 14/05/2025 16:19, Vladimir Oltean wrote:
> Permit programs such as "hwtstamp_ctl -i eth0" to retrieve the current
> timestamping configuration of the NIC, rather than returning "Device
> driver does not have support for non-destructive SIOCGHWTSTAMP."
>
> The driver configures all channels with the same timestamping settings.
> On TX, retrieve the settings of the first channel, those should be
> representative for the entire NIC. On RX, save the filter settings in a
> new adapter field.
>
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> ---
> drivers/net/ethernet/microchip/lan743x_main.c | 2 ++
> drivers/net/ethernet/microchip/lan743x_main.h | 1 +
> drivers/net/ethernet/microchip/lan743x_ptp.c | 18 ++++++++++++++++++
> drivers/net/ethernet/microchip/lan743x_ptp.h | 3 ++-
> 4 files changed, 23 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c
> index b01695bf4f55..880681085df2 100644
> --- a/drivers/net/ethernet/microchip/lan743x_main.c
> +++ b/drivers/net/ethernet/microchip/lan743x_main.c
> @@ -1729,6 +1729,7 @@ int lan743x_rx_set_tstamp_mode(struct lan743x_adapter *adapter,
> default:
> return -ERANGE;
> }
> + adapter->rx_tstamp_filter = rx_filter;
> return 0;
> }
>
> @@ -3445,6 +3446,7 @@ static const struct net_device_ops lan743x_netdev_ops = {
> .ndo_change_mtu = lan743x_netdev_change_mtu,
> .ndo_get_stats64 = lan743x_netdev_get_stats64,
> .ndo_set_mac_address = lan743x_netdev_set_mac_address,
> + .ndo_hwtstamp_get = lan743x_ptp_hwtstamp_get,
> .ndo_hwtstamp_set = lan743x_ptp_hwtstamp_set,
> };
>
> diff --git a/drivers/net/ethernet/microchip/lan743x_main.h b/drivers/net/ethernet/microchip/lan743x_main.h
> index db5fc73e41cc..02a28b709163 100644
> --- a/drivers/net/ethernet/microchip/lan743x_main.h
> +++ b/drivers/net/ethernet/microchip/lan743x_main.h
> @@ -1087,6 +1087,7 @@ struct lan743x_adapter {
> phy_interface_t phy_interface;
> struct phylink *phylink;
> struct phylink_config phylink_config;
> + int rx_tstamp_filter;
> };
>
> #define LAN743X_COMPONENT_FLAG_RX(channel) BIT(20 + (channel))
> diff --git a/drivers/net/ethernet/microchip/lan743x_ptp.c b/drivers/net/ethernet/microchip/lan743x_ptp.c
> index 026d1660fd74..a3b48388b3fd 100644
> --- a/drivers/net/ethernet/microchip/lan743x_ptp.c
> +++ b/drivers/net/ethernet/microchip/lan743x_ptp.c
> @@ -1736,6 +1736,24 @@ void lan743x_ptp_tx_timestamp_skb(struct lan743x_adapter *adapter,
> lan743x_ptp_tx_ts_complete(adapter);
> }
>
> +int lan743x_ptp_hwtstamp_get(struct net_device *netdev,
> + struct kernel_hwtstamp_config *config)
> +{
> + struct lan743x_adapter *adapter = netdev_priv(netdev);
> + struct lan743x_tx *tx = &adapter->tx[0];
> +
> + if (tx->ts_flags & TX_TS_FLAG_ONE_STEP_SYNC)
> + config->tx_type = HWTSTAMP_TX_ONESTEP_SYNC;
> + else if (tx->ts_flags & TX_TS_FLAG_TIMESTAMPING_ENABLED)
> + config->tx_type = HWTSTAMP_TX_ON;
> + else
> + config->tx_type = HWTSTAMP_TX_OFF;
> +
> + config->rx_filter = adapter->rx_tstamp_filter;
> +
> + return 0;
> +}
> +
> int lan743x_ptp_hwtstamp_set(struct net_device *netdev,
> struct kernel_hwtstamp_config *config,
> struct netlink_ext_ack *extack)
> diff --git a/drivers/net/ethernet/microchip/lan743x_ptp.h b/drivers/net/ethernet/microchip/lan743x_ptp.h
> index 9581a7992ff6..e8d073bfa2ca 100644
> --- a/drivers/net/ethernet/microchip/lan743x_ptp.h
> +++ b/drivers/net/ethernet/microchip/lan743x_ptp.h
> @@ -51,7 +51,8 @@ int lan743x_ptp_open(struct lan743x_adapter *adapter);
> void lan743x_ptp_close(struct lan743x_adapter *adapter);
> void lan743x_ptp_update_latency(struct lan743x_adapter *adapter,
> u32 link_speed);
> -
> +int lan743x_ptp_hwtstamp_get(struct net_device *netdev,
> + struct kernel_hwtstamp_config *config);
> int lan743x_ptp_hwtstamp_set(struct net_device *netdev,
> struct kernel_hwtstamp_config *config,
> struct netlink_ext_ack *extack);
Thanks for making this improvement. Looks like the pattern of not having
"get" callbacks got into this from phy drivers.
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next 1/2] net: lan743x: convert to ndo_hwtstamp_set()
2025-05-14 15:19 [PATCH net-next 1/2] net: lan743x: convert to ndo_hwtstamp_set() Vladimir Oltean
2025-05-14 15:19 ` [PATCH net-next 2/2] net: lan743x: implement ndo_hwtstamp_get() Vladimir Oltean
@ 2025-05-14 18:57 ` Gerhard Engleder
2025-05-14 21:25 ` Vadim Fedorenko
2025-05-16 1:00 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 7+ messages in thread
From: Gerhard Engleder @ 2025-05-14 18:57 UTC (permalink / raw)
To: Vladimir Oltean, netdev
Cc: Bryan Whitehead, Raju Lakkaraju, Vishvambar Panth S,
UNGLinuxDriver, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, Vadim Fedorenko,
Richard Cochran
On 14.05.25 17:19, Vladimir Oltean wrote:
> New timestamping API was introduced in commit 66f7223039c0 ("net: add
> NDOs for configuring hardware timestamping") from kernel v6.6.
>
> It is time to convert the lan743x driver to the new API, so that
> timestamping configuration can be removed from the ndo_eth_ioctl()
> path completely.
>
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> ---
> drivers/net/ethernet/microchip/lan743x_main.c | 3 +-
> drivers/net/ethernet/microchip/lan743x_ptp.c | 32 +++++--------------
> drivers/net/ethernet/microchip/lan743x_ptp.h | 4 ++-
> 3 files changed, 12 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c
> index 73dfc85fa67e..b01695bf4f55 100644
> --- a/drivers/net/ethernet/microchip/lan743x_main.c
> +++ b/drivers/net/ethernet/microchip/lan743x_main.c
> @@ -3351,8 +3351,6 @@ static int lan743x_netdev_ioctl(struct net_device *netdev,
>
> if (!netif_running(netdev))
> return -EINVAL;
> - if (cmd == SIOCSHWTSTAMP)
> - return lan743x_ptp_ioctl(netdev, ifr, cmd);
>
> return phylink_mii_ioctl(adapter->phylink, ifr, cmd);
> }
> @@ -3447,6 +3445,7 @@ static const struct net_device_ops lan743x_netdev_ops = {
> .ndo_change_mtu = lan743x_netdev_change_mtu,
> .ndo_get_stats64 = lan743x_netdev_get_stats64,
> .ndo_set_mac_address = lan743x_netdev_set_mac_address,
> + .ndo_hwtstamp_set = lan743x_ptp_hwtstamp_set,
> };
>
> static void lan743x_hardware_cleanup(struct lan743x_adapter *adapter)
> diff --git a/drivers/net/ethernet/microchip/lan743x_ptp.c b/drivers/net/ethernet/microchip/lan743x_ptp.c
> index b07f5b099a2b..026d1660fd74 100644
> --- a/drivers/net/ethernet/microchip/lan743x_ptp.c
> +++ b/drivers/net/ethernet/microchip/lan743x_ptp.c
> @@ -1736,23 +1736,14 @@ void lan743x_ptp_tx_timestamp_skb(struct lan743x_adapter *adapter,
> lan743x_ptp_tx_ts_complete(adapter);
> }
>
> -int lan743x_ptp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
> +int lan743x_ptp_hwtstamp_set(struct net_device *netdev,
> + struct kernel_hwtstamp_config *config,
> + struct netlink_ext_ack *extack)
> {
> struct lan743x_adapter *adapter = netdev_priv(netdev);
> - struct hwtstamp_config config;
> - int ret = 0;
> int index;
>
> - if (!ifr) {
> - netif_err(adapter, drv, adapter->netdev,
> - "SIOCSHWTSTAMP, ifr == NULL\n");
> - return -EINVAL;
> - }
> -
> - if (copy_from_user(&config, ifr->ifr_data, sizeof(config)))
> - return -EFAULT;
> -
> - switch (config.tx_type) {
> + switch (config->tx_type) {
> case HWTSTAMP_TX_OFF:
> for (index = 0; index < adapter->used_tx_channels;
> index++)
> @@ -1776,19 +1767,12 @@ int lan743x_ptp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
> lan743x_ptp_set_sync_ts_insert(adapter, true);
> break;
> case HWTSTAMP_TX_ONESTEP_P2P:
> - ret = -ERANGE;
> - break;
> + return -ERANGE;
> default:
> netif_warn(adapter, drv, adapter->netdev,
> - " tx_type = %d, UNKNOWN\n", config.tx_type);
> - ret = -EINVAL;
> - break;
> + " tx_type = %d, UNKNOWN\n", config->tx_type);
> + return -EINVAL;
> }
>
> - ret = lan743x_rx_set_tstamp_mode(adapter, config.rx_filter);
> -
> - if (!ret)
> - return copy_to_user(ifr->ifr_data, &config,
> - sizeof(config)) ? -EFAULT : 0;
> - return ret;
> + return lan743x_rx_set_tstamp_mode(adapter, config->rx_filter);
> }
> diff --git a/drivers/net/ethernet/microchip/lan743x_ptp.h b/drivers/net/ethernet/microchip/lan743x_ptp.h
> index 0d29914cd460..9581a7992ff6 100644
> --- a/drivers/net/ethernet/microchip/lan743x_ptp.h
> +++ b/drivers/net/ethernet/microchip/lan743x_ptp.h
> @@ -52,7 +52,9 @@ void lan743x_ptp_close(struct lan743x_adapter *adapter);
> void lan743x_ptp_update_latency(struct lan743x_adapter *adapter,
> u32 link_speed);
>
> -int lan743x_ptp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd);
> +int lan743x_ptp_hwtstamp_set(struct net_device *netdev,
> + struct kernel_hwtstamp_config *config,
> + struct netlink_ext_ack *extack);
>
> #define LAN743X_PTP_NUMBER_OF_TX_TIMESTAMPS (4)
Reviewed-by: Gerhard Engleder <gerhard@engleder-embedded.com>
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH net-next 1/2] net: lan743x: convert to ndo_hwtstamp_set()
2025-05-14 15:19 [PATCH net-next 1/2] net: lan743x: convert to ndo_hwtstamp_set() Vladimir Oltean
2025-05-14 15:19 ` [PATCH net-next 2/2] net: lan743x: implement ndo_hwtstamp_get() Vladimir Oltean
2025-05-14 18:57 ` [PATCH net-next 1/2] net: lan743x: convert to ndo_hwtstamp_set() Gerhard Engleder
@ 2025-05-14 21:25 ` Vadim Fedorenko
2025-05-16 1:00 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 7+ messages in thread
From: Vadim Fedorenko @ 2025-05-14 21:25 UTC (permalink / raw)
To: Vladimir Oltean, netdev
Cc: Bryan Whitehead, Raju Lakkaraju, Vishvambar Panth S,
UNGLinuxDriver, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, Richard Cochran
On 14/05/2025 16:19, Vladimir Oltean wrote:
> New timestamping API was introduced in commit 66f7223039c0 ("net: add
> NDOs for configuring hardware timestamping") from kernel v6.6.
>
> It is time to convert the lan743x driver to the new API, so that
> timestamping configuration can be removed from the ndo_eth_ioctl()
> path completely.
>
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> ---
> drivers/net/ethernet/microchip/lan743x_main.c | 3 +-
> drivers/net/ethernet/microchip/lan743x_ptp.c | 32 +++++--------------
> drivers/net/ethernet/microchip/lan743x_ptp.h | 4 ++-
> 3 files changed, 12 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c
> index 73dfc85fa67e..b01695bf4f55 100644
> --- a/drivers/net/ethernet/microchip/lan743x_main.c
> +++ b/drivers/net/ethernet/microchip/lan743x_main.c
> @@ -3351,8 +3351,6 @@ static int lan743x_netdev_ioctl(struct net_device *netdev,
>
> if (!netif_running(netdev))
> return -EINVAL;
> - if (cmd == SIOCSHWTSTAMP)
> - return lan743x_ptp_ioctl(netdev, ifr, cmd);
>
> return phylink_mii_ioctl(adapter->phylink, ifr, cmd);
> }
> @@ -3447,6 +3445,7 @@ static const struct net_device_ops lan743x_netdev_ops = {
> .ndo_change_mtu = lan743x_netdev_change_mtu,
> .ndo_get_stats64 = lan743x_netdev_get_stats64,
> .ndo_set_mac_address = lan743x_netdev_set_mac_address,
> + .ndo_hwtstamp_set = lan743x_ptp_hwtstamp_set,
> };
>
> static void lan743x_hardware_cleanup(struct lan743x_adapter *adapter)
> diff --git a/drivers/net/ethernet/microchip/lan743x_ptp.c b/drivers/net/ethernet/microchip/lan743x_ptp.c
> index b07f5b099a2b..026d1660fd74 100644
> --- a/drivers/net/ethernet/microchip/lan743x_ptp.c
> +++ b/drivers/net/ethernet/microchip/lan743x_ptp.c
> @@ -1736,23 +1736,14 @@ void lan743x_ptp_tx_timestamp_skb(struct lan743x_adapter *adapter,
> lan743x_ptp_tx_ts_complete(adapter);
> }
>
> -int lan743x_ptp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
> +int lan743x_ptp_hwtstamp_set(struct net_device *netdev,
> + struct kernel_hwtstamp_config *config,
> + struct netlink_ext_ack *extack)
> {
> struct lan743x_adapter *adapter = netdev_priv(netdev);
> - struct hwtstamp_config config;
> - int ret = 0;
> int index;
>
> - if (!ifr) {
> - netif_err(adapter, drv, adapter->netdev,
> - "SIOCSHWTSTAMP, ifr == NULL\n");
> - return -EINVAL;
> - }
> -
> - if (copy_from_user(&config, ifr->ifr_data, sizeof(config)))
> - return -EFAULT;
> -
> - switch (config.tx_type) {
> + switch (config->tx_type) {
> case HWTSTAMP_TX_OFF:
> for (index = 0; index < adapter->used_tx_channels;
> index++)
> @@ -1776,19 +1767,12 @@ int lan743x_ptp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
> lan743x_ptp_set_sync_ts_insert(adapter, true);
> break;
> case HWTSTAMP_TX_ONESTEP_P2P:
> - ret = -ERANGE;
> - break;
> + return -ERANGE;
> default:
> netif_warn(adapter, drv, adapter->netdev,
> - " tx_type = %d, UNKNOWN\n", config.tx_type);
> - ret = -EINVAL;
> - break;
> + " tx_type = %d, UNKNOWN\n", config->tx_type);
> + return -EINVAL;
nit: can be easily transformed to extack, but I can do it later as a
follow-up
> }
>
> - ret = lan743x_rx_set_tstamp_mode(adapter, config.rx_filter);
> -
> - if (!ret)
> - return copy_to_user(ifr->ifr_data, &config,
> - sizeof(config)) ? -EFAULT : 0;
> - return ret;
> + return lan743x_rx_set_tstamp_mode(adapter, config->rx_filter);
> }
> diff --git a/drivers/net/ethernet/microchip/lan743x_ptp.h b/drivers/net/ethernet/microchip/lan743x_ptp.h
> index 0d29914cd460..9581a7992ff6 100644
> --- a/drivers/net/ethernet/microchip/lan743x_ptp.h
> +++ b/drivers/net/ethernet/microchip/lan743x_ptp.h
> @@ -52,7 +52,9 @@ void lan743x_ptp_close(struct lan743x_adapter *adapter);
> void lan743x_ptp_update_latency(struct lan743x_adapter *adapter,
> u32 link_speed);
>
> -int lan743x_ptp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd);
> +int lan743x_ptp_hwtstamp_set(struct net_device *netdev,
> + struct kernel_hwtstamp_config *config,
> + struct netlink_ext_ack *extack);
>
> #define LAN743X_PTP_NUMBER_OF_TX_TIMESTAMPS (4)
>
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH net-next 1/2] net: lan743x: convert to ndo_hwtstamp_set()
2025-05-14 15:19 [PATCH net-next 1/2] net: lan743x: convert to ndo_hwtstamp_set() Vladimir Oltean
` (2 preceding siblings ...)
2025-05-14 21:25 ` Vadim Fedorenko
@ 2025-05-16 1:00 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 7+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-05-16 1:00 UTC (permalink / raw)
To: Vladimir Oltean
Cc: netdev, bryan.whitehead, Raju.Lakkaraju, vishvambarpanth.s,
UNGLinuxDriver, andrew, davem, edumazet, kuba, pabeni, horms,
vadim.fedorenko, richardcochran
Hello:
This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Wed, 14 May 2025 18:19:29 +0300 you wrote:
> New timestamping API was introduced in commit 66f7223039c0 ("net: add
> NDOs for configuring hardware timestamping") from kernel v6.6.
>
> It is time to convert the lan743x driver to the new API, so that
> timestamping configuration can be removed from the ndo_eth_ioctl()
> path completely.
>
> [...]
Here is the summary with links:
- [net-next,1/2] net: lan743x: convert to ndo_hwtstamp_set()
https://git.kernel.org/netdev/net-next/c/958a857a626c
- [net-next,2/2] net: lan743x: implement ndo_hwtstamp_get()
https://git.kernel.org/netdev/net-next/c/abb258eb78a9
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 7+ messages in thread