net: mvpp2: convert to ndo_hwtstamp_get() and ndo_hwtstamp_set()
Subsystems (3)
PATCH 1/1 net: mvpp2: convert to ndo_hwtstamp_get() and ndo_hwtstamp_set()
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 mvpp2 driver to the new API, so that the ndo_eth_ioctl() path can be removed completely.
Note that on the !port->hwtstamp condition, the old code used to fall through in mvpp2_ioctl(), and return either -ENOTSUPP if !port->phylink, or -EOPNOTSUPP, in phylink_mii_ioctl(). Keep the test for port->hwtstamp in the newly introduced net_device_ops, but consolidate the error code to just -EOPNOTSUPP. The other one is documented as NFS-specific, it's best to avoid it anyway.
---
Only compile-tested.
.../net/ethernet/marvell/mvpp2/mvpp2_main.c | 58 ++++++++----------- 1 file changed, 23 insertions(+), 35 deletions(-)
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +23 -35
@@ -5173,38 +5173,40 @@ mvpp2_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) stats->tx_dropped = dev->stats.tx_dropped; } -static int mvpp2_set_ts_config (struct mvpp2_port *port,struct ifreq *ifr) +static int mvpp2_hwtstamp_set (struct net_device *dev, +struct kernel_hwtstamp_config *config, +struct netlink_ext_ack *extack) { -struct hwtstamp_config config; +struct mvpp2_port *port =netdev_priv (dev);void __iomem *ptp;u32 gcr, int_mask; -if (copy_from_user (&config, ifr->ifr_data,sizeof (config))) -return -EFAULT ; +if (!port->hwtstamp) +return -EOPNOTSUPP ; -if (config.tx_type !=HWTSTAMP_TX_OFF && - config.tx_type !=HWTSTAMP_TX_ON ) +if (config->tx_type !=HWTSTAMP_TX_OFF && + config->tx_type !=HWTSTAMP_TX_ON )return -ERANGE ; ptp = port->priv->iface_base +MVPP22_PTP_BASE (port->gop_id); int_mask = gcr =0 ; -if (config.tx_type !=HWTSTAMP_TX_OFF ) { +if (config->tx_type !=HWTSTAMP_TX_OFF ) { gcr |=MVPP22_PTP_GCR_TSU_ENABLE |MVPP22_PTP_GCR_TX_RESET ; int_mask |=MVPP22_PTP_INT_MASK_QUEUE1 |MVPP22_PTP_INT_MASK_QUEUE0 ; }/* It seems we must also release the TX reset when enabling the TSU */ -if (config.rx_filter !=HWTSTAMP_FILTER_NONE ) +if (config->rx_filter !=HWTSTAMP_FILTER_NONE ) gcr |=MVPP22_PTP_GCR_TSU_ENABLE |MVPP22_PTP_GCR_RX_RESET |MVPP22_PTP_GCR_TX_RESET ;if (gcr &MVPP22_PTP_GCR_TSU_ENABLE )mvpp22_tai_start (port->priv->tai); -if (config.rx_filter !=HWTSTAMP_FILTER_NONE ) { - config.rx_filter =HWTSTAMP_FILTER_ALL ; +if (config->rx_filter !=HWTSTAMP_FILTER_NONE ) { + config->rx_filter =HWTSTAMP_FILTER_ALL ; mvpp2_modify(ptp + MVPP22_PTP_GCR, MVPP22_PTP_GCR_RX_RESET | MVPP22_PTP_GCR_TX_RESET |
@@ -5225,26 +5227,22 @@ static int mvpp2_set_ts_config(struct mvpp2_port *port, struct ifreq *ifr)if (!(gcr &MVPP22_PTP_GCR_TSU_ENABLE ))mvpp22_tai_stop (port->priv->tai); - port->tx_hwtstamp_type = config.tx_type; - -if (copy_to_user (ifr->ifr_data, &config,sizeof (config))) -return -EFAULT ; + port->tx_hwtstamp_type = config->tx_type;return 0 ; } -static int mvpp2_get_ts_config (struct mvpp2_port *port,struct ifreq *ifr) +static int mvpp2_hwtstamp_get (struct net_device *dev, +struct kernel_hwtstamp_config *config) { -struct hwtstamp_config config; - -memset (&config,0 ,sizeof (config)); +struct mvpp2_port *port =netdev_priv (dev); - config.tx_type = port->tx_hwtstamp_type; - config.rx_filter = port->rx_hwtstamp ? -HWTSTAMP_FILTER_ALL :HWTSTAMP_FILTER_NONE ; +if (!port->hwtstamp) +return -EOPNOTSUPP ; -if (copy_to_user (ifr->ifr_data, &config,sizeof (config))) -return -EFAULT ; + config->tx_type = port->tx_hwtstamp_type; + config->rx_filter = port->rx_hwtstamp ?HWTSTAMP_FILTER_ALL : +HWTSTAMP_FILTER_NONE ;return 0 ; }
@@ -5274,18 +5272,6 @@ static int mvpp2_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) {struct mvpp2_port *port =netdev_priv (dev); -switch (cmd) { -case SIOCSHWTSTAMP : -if (port->hwtstamp) -return mvpp2_set_ts_config (port, ifr); -break ; - -case SIOCGHWTSTAMP : -if (port->hwtstamp) -return mvpp2_get_ts_config (port, ifr); -break ; - } -if (!port->phylink)return -ENOTSUPP ;
@@ -5799,6 +5785,8 @@ static const struct net_device_ops mvpp2_netdev_ops = { .ndo_set_features = mvpp2_set_features, .ndo_bpf = mvpp2_xdp, .ndo_xdp_xmit = mvpp2_xdp_xmit, + .ndo_hwtstamp_get = mvpp2_hwtstamp_get, + .ndo_hwtstamp_set = mvpp2_hwtstamp_set, };static const struct ethtool_ops mvpp2_eth_tool_ops = {
Signature · 1 line
2.43.0
Quoted 5 lines · Vladimir Oltean
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 mvpp2 driver to the new API, so that thendo_eth_ioctl()path can be removed completely.
Quoted 8 lines
Note that on the !port->hwtstamp condition, the old code used to fall through in
mvpp2_ioctl(), and return either-ENOTSUPPif !port->phylink, or-EOPNOTSUPP, inphylink_mii_ioctl(). Keep the test forport->hwtstampin the newly introducednet_device_ops, but consolidate the error code to just-EOPNOTSUPP. The other one is documented as NFS-specific, it's best to avoid it anyway.Signed-off-by Vladimir Oltean <[email protected]>
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 5 lines · On Thu, 8 May 2025 17:46:30 +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 mvpp2 driver to the new API, so that thendo_eth_ioctl()path can be removed completely.
Quoted 8 lines
Note that on the !port->hwtstamp condition, the old code used to fall through in
mvpp2_ioctl(), and return either-ENOTSUPPif !port->phylink, or-EOPNOTSUPP, inphylink_mii_ioctl(). Keep the test forport->hwtstampin the newly introducednet_device_ops, but consolidate the error code to just-EOPNOTSUPP. The other one is documented as NFS-specific, it's best to avoid it anyway.[...]
Here is the summary with links:
- [net-next] net: mvpp2: convert to ndo_hwtstamp_get() and ndo_hwtstamp_set()
https://git.kernel.org/netdev/net-next/c/3c9ff6eb2de5
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html