]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ti: icssg: convert to ndo_hwtstamp API
authorVadim Fedorenko <vadim.fedorenko@linux.dev>
Thu, 16 Oct 2025 15:25:10 +0000 (15:25 +0000)
committerJakub Kicinski <kuba@kernel.org>
Tue, 21 Oct 2025 00:30:25 +0000 (17:30 -0700)
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.

Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Link: https://patch.msgid.link/20251016152515.3510991-3-vadim.fedorenko@linux.dev
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/ti/icssg/icssg_common.c
drivers/net/ethernet/ti/icssg/icssg_prueth.c
drivers/net/ethernet/ti/icssg/icssg_prueth.h
drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c

index 57e5f1c88f5098d3cb62875ea31490dbef84c9ca..0eed29d6187a6030e853415dfc9c14f79def4d20 100644 (file)
@@ -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)
index e42d0fdefee1284033f740f871efe8f456487224..1c1f4394ff1f2670b69d5eb0fa284bbe2af297aa 100644 (file)
@@ -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,
index ca8a22a4a5daa550d37c2138ffd9816bf1a5ef8a..f0fa9688d9a08c95479ff847f1dfcdb00f7c530e 100644 (file)
@@ -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,
index 5e225310c9deaf17a278420a0e10161301147d92..2a8c8847a6bd05e449615a5262cbde7f27d9d4f4 100644 (file)
@@ -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,