net: lan743x: convert to ndo_hwtstamp_set()
authorVladimir Oltean <vladimir.oltean@nxp.com>
Wed, 14 May 2025 15:19:29 +0000 (18:19 +0300)
committerJakub Kicinski <kuba@kernel.org>
Fri, 16 May 2025 00:56:38 +0000 (17:56 -0700)
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>
Reviewed-by: Gerhard Engleder <gerhard@engleder-embedded.com>
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Link: https://patch.msgid.link/20250514151931.1988047-1-vladimir.oltean@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/microchip/lan743x_main.c
drivers/net/ethernet/microchip/lan743x_ptp.c
drivers/net/ethernet/microchip/lan743x_ptp.h

index 73dfc85fa67e86be8902e919b995aa2c2f48d1ed..b01695bf4f55251425839403141a005133cd6a31 100644 (file)
@@ -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)
index b07f5b099a2b400bc47ff04573dc2ea7a0be0cee..026d1660fd745d395b0c271f84a3668c44bf5446 100644 (file)
@@ -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);
 }
index 0d29914cd460632c452bd76640543fb753ef5d15..9581a7992ff6fa3dd0b84b36cf77a98da24fe990 100644 (file)
@@ -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)