]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
igb: convert to ndo_hwtstamp_get() and ndo_hwtstamp_set()
authorVladimir Oltean <vladimir.oltean@nxp.com>
Tue, 13 May 2025 10:11:30 +0000 (13:11 +0300)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Thu, 3 Jul 2025 16:38:46 +0000 (09:38 -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 Intel igb 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: Simon Horman <horms@kernel.org>
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Reviewed-by: Milena Olech <milena.olech@intel.com>
Tested-by: Rinitha S <sx.rinitha@intel.com> (A Contingent worker at Intel)
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/igb/igb.h
drivers/net/ethernet/intel/igb/igb_main.c
drivers/net/ethernet/intel/igb/igb_ptp.c

index f34ead8243e9f0176a068299138c5c16f7faab2e..c3f4f7cd264e9b2ff70f03b580f95b15b528028c 100644 (file)
@@ -626,7 +626,7 @@ struct igb_adapter {
        struct delayed_work ptp_overflow_work;
        struct work_struct ptp_tx_work;
        struct sk_buff *ptp_tx_skb;
-       struct hwtstamp_config tstamp_config;
+       struct kernel_hwtstamp_config tstamp_config;
        unsigned long ptp_tx_start;
        unsigned long last_rx_ptp_check;
        unsigned long last_rx_timestamp;
@@ -771,8 +771,11 @@ void igb_ptp_tx_hang(struct igb_adapter *adapter);
 void igb_ptp_rx_rgtstamp(struct igb_q_vector *q_vector, struct sk_buff *skb);
 int igb_ptp_rx_pktstamp(struct igb_q_vector *q_vector, void *va,
                        ktime_t *timestamp);
-int igb_ptp_set_ts_config(struct net_device *netdev, struct ifreq *ifr);
-int igb_ptp_get_ts_config(struct net_device *netdev, struct ifreq *ifr);
+int igb_ptp_hwtstamp_get(struct net_device *netdev,
+                        struct kernel_hwtstamp_config *config);
+int igb_ptp_hwtstamp_set(struct net_device *netdev,
+                        struct kernel_hwtstamp_config *config,
+                        struct netlink_ext_ack *extack);
 void igb_set_flag_queue_pairs(struct igb_adapter *, const u32);
 unsigned int igb_get_max_rss_queues(struct igb_adapter *);
 #ifdef CONFIG_IGB_HWMON
index b76a154e635e0007911875e097f35acdcedaba76..a9a7a94ae61e93aa737b0103e00580e73601d62b 100644 (file)
@@ -3062,6 +3062,8 @@ static const struct net_device_ops igb_netdev_ops = {
        .ndo_bpf                = igb_xdp,
        .ndo_xdp_xmit           = igb_xdp_xmit,
        .ndo_xsk_wakeup         = igb_xsk_wakeup,
+       .ndo_hwtstamp_get       = igb_ptp_hwtstamp_get,
+       .ndo_hwtstamp_set       = igb_ptp_hwtstamp_set,
 };
 
 /**
@@ -9317,10 +9319,6 @@ static int igb_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
        case SIOCGMIIREG:
        case SIOCSMIIREG:
                return igb_mii_ioctl(netdev, ifr, cmd);
-       case SIOCGHWTSTAMP:
-               return igb_ptp_get_ts_config(netdev, ifr);
-       case SIOCSHWTSTAMP:
-               return igb_ptp_set_ts_config(netdev, ifr);
        default:
                return -EOPNOTSUPP;
        }
index 793c96016288089844f521a36da8908ba820e3db..05d30aba66db9d7af9210ae94a9ada291c3b495f 100644 (file)
@@ -1094,21 +1094,22 @@ void igb_ptp_rx_rgtstamp(struct igb_q_vector *q_vector, struct sk_buff *skb)
 }
 
 /**
- * igb_ptp_get_ts_config - get hardware time stamping config
+ * igb_ptp_hwtstamp_get - get hardware time stamping config
  * @netdev: netdev struct
- * @ifr: interface struct
+ * @config: timestamping configuration structure
  *
  * Get the hwtstamp_config settings to return to the user. Rather than attempt
  * to deconstruct the settings from the registers, just return a shadow copy
  * of the last known settings.
  **/
-int igb_ptp_get_ts_config(struct net_device *netdev, struct ifreq *ifr)
+int igb_ptp_hwtstamp_get(struct net_device *netdev,
+                        struct kernel_hwtstamp_config *config)
 {
        struct igb_adapter *adapter = netdev_priv(netdev);
-       struct hwtstamp_config *config = &adapter->tstamp_config;
 
-       return copy_to_user(ifr->ifr_data, config, sizeof(*config)) ?
-               -EFAULT : 0;
+       *config = adapter->tstamp_config;
+
+       return 0;
 }
 
 /**
@@ -1129,7 +1130,7 @@ int igb_ptp_get_ts_config(struct net_device *netdev, struct ifreq *ifr)
  * level 2 or 4".
  */
 static int igb_ptp_set_timestamp_mode(struct igb_adapter *adapter,
-                                     struct hwtstamp_config *config)
+                                     struct kernel_hwtstamp_config *config)
 {
        struct e1000_hw *hw = &adapter->hw;
        u32 tsync_tx_ctl = E1000_TSYNCTXCTL_ENABLED;
@@ -1275,30 +1276,26 @@ static int igb_ptp_set_timestamp_mode(struct igb_adapter *adapter,
 }
 
 /**
- * igb_ptp_set_ts_config - set hardware time stamping config
+ * igb_ptp_hwtstamp_set - set hardware time stamping config
  * @netdev: netdev struct
- * @ifr: interface struct
- *
+ * @config: timestamping configuration structure
+ * @extack: netlink extended ack structure for error reporting
  **/
-int igb_ptp_set_ts_config(struct net_device *netdev, struct ifreq *ifr)
+int igb_ptp_hwtstamp_set(struct net_device *netdev,
+                        struct kernel_hwtstamp_config *config,
+                        struct netlink_ext_ack *extack)
 {
        struct igb_adapter *adapter = netdev_priv(netdev);
-       struct hwtstamp_config config;
        int err;
 
-       if (copy_from_user(&config, ifr->ifr_data, sizeof(config)))
-               return -EFAULT;
-
-       err = igb_ptp_set_timestamp_mode(adapter, &config);
+       err = igb_ptp_set_timestamp_mode(adapter, config);
        if (err)
                return err;
 
        /* save these settings for future reference */
-       memcpy(&adapter->tstamp_config, &config,
-              sizeof(adapter->tstamp_config));
+       adapter->tstamp_config = *config;
 
-       return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ?
-               -EFAULT : 0;
+       return 0;
 }
 
 /**