]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: dpaa2-eth: convert to ndo_hwtstamp_set()
authorVladimir Oltean <vladimir.oltean@nxp.com>
Thu, 8 May 2025 13:41:01 +0000 (16:41 +0300)
committerJakub Kicinski <kuba@kernel.org>
Fri, 9 May 2025 23:41:51 +0000 (16:41 -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 DPAA2 Ethernet driver to the new API, so that the
ndo_eth_ioctl() path can be removed completely.

This driver only responds to SIOCSHWTSTAMP (not SIOCGHWTSTAMP) so
convert just that.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com> # LX2160A
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Link: https://patch.msgid.link/20250508134102.1747075-1-vladimir.oltean@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c

index 29886a8ba73f33d31d9045719bd4b166a8ad1ba8..13b44fc170dc2ee85b20a848d83477c9649c6978 100644 (file)
@@ -2585,40 +2585,37 @@ static int dpaa2_eth_set_features(struct net_device *net_dev,
        return 0;
 }
 
-static int dpaa2_eth_ts_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
+static int dpaa2_eth_hwtstamp_set(struct net_device *dev,
+                                 struct kernel_hwtstamp_config *config,
+                                 struct netlink_ext_ack *extack)
 {
        struct dpaa2_eth_priv *priv = netdev_priv(dev);
-       struct hwtstamp_config config;
 
        if (!dpaa2_ptp)
                return -EINVAL;
 
-       if (copy_from_user(&config, rq->ifr_data, sizeof(config)))
-               return -EFAULT;
-
-       switch (config.tx_type) {
+       switch (config->tx_type) {
        case HWTSTAMP_TX_OFF:
        case HWTSTAMP_TX_ON:
        case HWTSTAMP_TX_ONESTEP_SYNC:
-               priv->tx_tstamp_type = config.tx_type;
+               priv->tx_tstamp_type = config->tx_type;
                break;
        default:
                return -ERANGE;
        }
 
-       if (config.rx_filter == HWTSTAMP_FILTER_NONE) {
+       if (config->rx_filter == HWTSTAMP_FILTER_NONE) {
                priv->rx_tstamp = false;
        } else {
                priv->rx_tstamp = true;
                /* TS is set for all frame types, not only those requested */
-               config.rx_filter = HWTSTAMP_FILTER_ALL;
+               config->rx_filter = HWTSTAMP_FILTER_ALL;
        }
 
        if (priv->tx_tstamp_type == HWTSTAMP_TX_ONESTEP_SYNC)
                dpaa2_ptp_onestep_reg_update_method(priv);
 
-       return copy_to_user(rq->ifr_data, &config, sizeof(config)) ?
-                       -EFAULT : 0;
+       return 0;
 }
 
 static int dpaa2_eth_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
@@ -2626,9 +2623,6 @@ static int dpaa2_eth_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
        struct dpaa2_eth_priv *priv = netdev_priv(dev);
        int err;
 
-       if (cmd == SIOCSHWTSTAMP)
-               return dpaa2_eth_ts_ioctl(dev, rq, cmd);
-
        mutex_lock(&priv->mac_lock);
 
        if (dpaa2_eth_is_type_phy(priv)) {
@@ -3034,7 +3028,8 @@ static const struct net_device_ops dpaa2_eth_ops = {
        .ndo_xsk_wakeup = dpaa2_xsk_wakeup,
        .ndo_setup_tc = dpaa2_eth_setup_tc,
        .ndo_vlan_rx_add_vid = dpaa2_eth_rx_add_vid,
-       .ndo_vlan_rx_kill_vid = dpaa2_eth_rx_kill_vid
+       .ndo_vlan_rx_kill_vid = dpaa2_eth_rx_kill_vid,
+       .ndo_hwtstamp_set = dpaa2_eth_hwtstamp_set,
 };
 
 static void dpaa2_eth_cdan_cb(struct dpaa2_io_notification_ctx *ctx)