]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
tg3: convert to ndo_hwtstamp_get() and ndo_hwtstamp_set()
authorVadim Fedorenko <vadim.fedorenko@linux.dev>
Tue, 23 Sep 2025 17:33:07 +0000 (17:33 +0000)
committerJakub Kicinski <kuba@kernel.org>
Thu, 25 Sep 2025 01:13:02 +0000 (18:13 -0700)
Convert tg3 driver to new timestamping configuration API.

Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Reviewed-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Link: https://patch.msgid.link/20250923173310.139623-2-vadim.fedorenko@linux.dev
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/broadcom/tg3.c

index b4dc93a487184c216c43e8f7c569127e168620d1..7f00ec7fd7b90dcd18fed75a90aa1aeaaf1b25a9 100644 (file)
@@ -13929,22 +13929,20 @@ static void tg3_self_test(struct net_device *dev, struct ethtool_test *etest,
 
 }
 
-static int tg3_hwtstamp_set(struct net_device *dev, struct ifreq *ifr)
+static int tg3_hwtstamp_set(struct net_device *dev,
+                           struct kernel_hwtstamp_config *stmpconf,
+                           struct netlink_ext_ack *extack)
 {
        struct tg3 *tp = netdev_priv(dev);
-       struct hwtstamp_config stmpconf;
 
        if (!tg3_flag(tp, PTP_CAPABLE))
                return -EOPNOTSUPP;
 
-       if (copy_from_user(&stmpconf, ifr->ifr_data, sizeof(stmpconf)))
-               return -EFAULT;
-
-       if (stmpconf.tx_type != HWTSTAMP_TX_ON &&
-           stmpconf.tx_type != HWTSTAMP_TX_OFF)
+       if (stmpconf->tx_type != HWTSTAMP_TX_ON &&
+           stmpconf->tx_type != HWTSTAMP_TX_OFF)
                return -ERANGE;
 
-       switch (stmpconf.rx_filter) {
+       switch (stmpconf->rx_filter) {
        case HWTSTAMP_FILTER_NONE:
                tp->rxptpctl = 0;
                break;
@@ -14004,74 +14002,72 @@ static int tg3_hwtstamp_set(struct net_device *dev, struct ifreq *ifr)
                tw32(TG3_RX_PTP_CTL,
                     tp->rxptpctl | TG3_RX_PTP_CTL_HWTS_INTERLOCK);
 
-       if (stmpconf.tx_type == HWTSTAMP_TX_ON)
+       if (stmpconf->tx_type == HWTSTAMP_TX_ON)
                tg3_flag_set(tp, TX_TSTAMP_EN);
        else
                tg3_flag_clear(tp, TX_TSTAMP_EN);
 
-       return copy_to_user(ifr->ifr_data, &stmpconf, sizeof(stmpconf)) ?
-               -EFAULT : 0;
+       return 0;
 }
 
-static int tg3_hwtstamp_get(struct net_device *dev, struct ifreq *ifr)
+static int tg3_hwtstamp_get(struct net_device *dev,
+                           struct kernel_hwtstamp_config *stmpconf)
 {
        struct tg3 *tp = netdev_priv(dev);
-       struct hwtstamp_config stmpconf;
 
        if (!tg3_flag(tp, PTP_CAPABLE))
                return -EOPNOTSUPP;
 
-       stmpconf.flags = 0;
-       stmpconf.tx_type = (tg3_flag(tp, TX_TSTAMP_EN) ?
-                           HWTSTAMP_TX_ON : HWTSTAMP_TX_OFF);
+       stmpconf->flags = 0;
+       stmpconf->tx_type = tg3_flag(tp, TX_TSTAMP_EN) ?
+                           HWTSTAMP_TX_ON : HWTSTAMP_TX_OFF;
 
        switch (tp->rxptpctl) {
        case 0:
-               stmpconf.rx_filter = HWTSTAMP_FILTER_NONE;
+               stmpconf->rx_filter = HWTSTAMP_FILTER_NONE;
                break;
        case TG3_RX_PTP_CTL_RX_PTP_V1_EN | TG3_RX_PTP_CTL_ALL_V1_EVENTS:
-               stmpconf.rx_filter = HWTSTAMP_FILTER_PTP_V1_L4_EVENT;
+               stmpconf->rx_filter = HWTSTAMP_FILTER_PTP_V1_L4_EVENT;
                break;
        case TG3_RX_PTP_CTL_RX_PTP_V1_EN | TG3_RX_PTP_CTL_SYNC_EVNT:
-               stmpconf.rx_filter = HWTSTAMP_FILTER_PTP_V1_L4_SYNC;
+               stmpconf->rx_filter = HWTSTAMP_FILTER_PTP_V1_L4_SYNC;
                break;
        case TG3_RX_PTP_CTL_RX_PTP_V1_EN | TG3_RX_PTP_CTL_DELAY_REQ:
-               stmpconf.rx_filter = HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ;
+               stmpconf->rx_filter = HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ;
                break;
        case TG3_RX_PTP_CTL_RX_PTP_V2_EN | TG3_RX_PTP_CTL_ALL_V2_EVENTS:
-               stmpconf.rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT;
+               stmpconf->rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT;
                break;
        case TG3_RX_PTP_CTL_RX_PTP_V2_L2_EN | TG3_RX_PTP_CTL_ALL_V2_EVENTS:
-               stmpconf.rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_EVENT;
+               stmpconf->rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_EVENT;
                break;
        case TG3_RX_PTP_CTL_RX_PTP_V2_L4_EN | TG3_RX_PTP_CTL_ALL_V2_EVENTS:
-               stmpconf.rx_filter = HWTSTAMP_FILTER_PTP_V2_L4_EVENT;
+               stmpconf->rx_filter = HWTSTAMP_FILTER_PTP_V2_L4_EVENT;
                break;
        case TG3_RX_PTP_CTL_RX_PTP_V2_EN | TG3_RX_PTP_CTL_SYNC_EVNT:
-               stmpconf.rx_filter = HWTSTAMP_FILTER_PTP_V2_SYNC;
+               stmpconf->rx_filter = HWTSTAMP_FILTER_PTP_V2_SYNC;
                break;
        case TG3_RX_PTP_CTL_RX_PTP_V2_L2_EN | TG3_RX_PTP_CTL_SYNC_EVNT:
-               stmpconf.rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_SYNC;
+               stmpconf->rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_SYNC;
                break;
        case TG3_RX_PTP_CTL_RX_PTP_V2_L4_EN | TG3_RX_PTP_CTL_SYNC_EVNT:
-               stmpconf.rx_filter = HWTSTAMP_FILTER_PTP_V2_L4_SYNC;
+               stmpconf->rx_filter = HWTSTAMP_FILTER_PTP_V2_L4_SYNC;
                break;
        case TG3_RX_PTP_CTL_RX_PTP_V2_EN | TG3_RX_PTP_CTL_DELAY_REQ:
-               stmpconf.rx_filter = HWTSTAMP_FILTER_PTP_V2_DELAY_REQ;
+               stmpconf->rx_filter = HWTSTAMP_FILTER_PTP_V2_DELAY_REQ;
                break;
        case TG3_RX_PTP_CTL_RX_PTP_V2_L2_EN | TG3_RX_PTP_CTL_DELAY_REQ:
-               stmpconf.rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ;
+               stmpconf->rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ;
                break;
        case TG3_RX_PTP_CTL_RX_PTP_V2_L4_EN | TG3_RX_PTP_CTL_DELAY_REQ:
-               stmpconf.rx_filter = HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ;
+               stmpconf->rx_filter = HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ;
                break;
        default:
                WARN_ON_ONCE(1);
                return -ERANGE;
        }
 
-       return copy_to_user(ifr->ifr_data, &stmpconf, sizeof(stmpconf)) ?
-               -EFAULT : 0;
+       return 0;
 }
 
 static int tg3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
@@ -14126,12 +14122,6 @@ static int tg3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
 
                return err;
 
-       case SIOCSHWTSTAMP:
-               return tg3_hwtstamp_set(dev, ifr);
-
-       case SIOCGHWTSTAMP:
-               return tg3_hwtstamp_get(dev, ifr);
-
        default:
                /* do nothing */
                break;
@@ -14407,6 +14397,8 @@ static const struct net_device_ops tg3_netdev_ops = {
 #ifdef CONFIG_NET_POLL_CONTROLLER
        .ndo_poll_controller    = tg3_poll_controller,
 #endif
+       .ndo_hwtstamp_get       = tg3_hwtstamp_get,
+       .ndo_hwtstamp_set       = tg3_hwtstamp_set,
 };
 
 static void tg3_get_eeprom_size(struct tg3 *tp)