Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'convert-net-drivers-to-ndo_hwtstamp-api-part-1'

Vadim Fedorenko says:

====================
convert net drivers to ndo_hwtstamp API part 1

This is part 1 of patchset to convert drivers which support HW
timestamping to use .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks.
The new API uses netlink to communicate with user-space and have some
test coverage. Part 2 will contain another 6 patches from v1 of the
series.
There are some drivers left with old ioctl interface after this series:
- mlx5 driver be shortly converted by nVidia folks
- TI netcp ethss driver which needs separate series which I'll post
after this one.
====================

Link: https://patch.msgid.link/20251016152515.3510991-1-vadim.fedorenko@linux.dev
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+233 -321
+2 -22
drivers/net/ethernet/amd/xgbe/xgbe-drv.c
··· 1754 1754 return 0; 1755 1755 } 1756 1756 1757 - static int xgbe_ioctl(struct net_device *netdev, struct ifreq *ifreq, int cmd) 1758 - { 1759 - struct xgbe_prv_data *pdata = netdev_priv(netdev); 1760 - int ret; 1761 - 1762 - switch (cmd) { 1763 - case SIOCGHWTSTAMP: 1764 - ret = xgbe_get_hwtstamp_settings(pdata, ifreq); 1765 - break; 1766 - 1767 - case SIOCSHWTSTAMP: 1768 - ret = xgbe_set_hwtstamp_settings(pdata, ifreq); 1769 - break; 1770 - 1771 - default: 1772 - ret = -EOPNOTSUPP; 1773 - } 1774 - 1775 - return ret; 1776 - } 1777 - 1778 1757 static int xgbe_change_mtu(struct net_device *netdev, int mtu) 1779 1758 { 1780 1759 struct xgbe_prv_data *pdata = netdev_priv(netdev); ··· 1999 2020 .ndo_set_rx_mode = xgbe_set_rx_mode, 2000 2021 .ndo_set_mac_address = xgbe_set_mac_address, 2001 2022 .ndo_validate_addr = eth_validate_addr, 2002 - .ndo_eth_ioctl = xgbe_ioctl, 2003 2023 .ndo_change_mtu = xgbe_change_mtu, 2004 2024 .ndo_tx_timeout = xgbe_tx_timeout, 2005 2025 .ndo_get_stats64 = xgbe_get_stats64, ··· 2011 2033 .ndo_fix_features = xgbe_fix_features, 2012 2034 .ndo_set_features = xgbe_set_features, 2013 2035 .ndo_features_check = xgbe_features_check, 2036 + .ndo_hwtstamp_get = xgbe_get_hwtstamp_settings, 2037 + .ndo_hwtstamp_set = xgbe_set_hwtstamp_settings, 2014 2038 }; 2015 2039 2016 2040 const struct net_device_ops *xgbe_get_netdev_ops(void)
+13 -15
drivers/net/ethernet/amd/xgbe/xgbe-hwtstamp.c
··· 157 157 spin_unlock_irqrestore(&pdata->tstamp_lock, flags); 158 158 } 159 159 160 - int xgbe_get_hwtstamp_settings(struct xgbe_prv_data *pdata, struct ifreq *ifreq) 160 + int xgbe_get_hwtstamp_settings(struct net_device *netdev, 161 + struct kernel_hwtstamp_config *config) 161 162 { 162 - if (copy_to_user(ifreq->ifr_data, &pdata->tstamp_config, 163 - sizeof(pdata->tstamp_config))) 164 - return -EFAULT; 163 + struct xgbe_prv_data *pdata = netdev_priv(netdev); 164 + 165 + *config = pdata->tstamp_config; 165 166 166 167 return 0; 167 168 } 168 169 169 - int xgbe_set_hwtstamp_settings(struct xgbe_prv_data *pdata, struct ifreq *ifreq) 170 + int xgbe_set_hwtstamp_settings(struct net_device *netdev, 171 + struct kernel_hwtstamp_config *config, 172 + struct netlink_ext_ack *extack) 170 173 { 171 - struct hwtstamp_config config; 172 - unsigned int mac_tscr; 174 + struct xgbe_prv_data *pdata = netdev_priv(netdev); 175 + unsigned int mac_tscr = 0; 173 176 174 - if (copy_from_user(&config, ifreq->ifr_data, sizeof(config))) 175 - return -EFAULT; 176 - 177 - mac_tscr = 0; 178 - 179 - switch (config.tx_type) { 177 + switch (config->tx_type) { 180 178 case HWTSTAMP_TX_OFF: 181 179 break; 182 180 ··· 186 188 return -ERANGE; 187 189 } 188 190 189 - switch (config.rx_filter) { 191 + switch (config->rx_filter) { 190 192 case HWTSTAMP_FILTER_NONE: 191 193 break; 192 194 ··· 288 290 289 291 xgbe_config_tstamp(pdata, mac_tscr); 290 292 291 - memcpy(&pdata->tstamp_config, &config, sizeof(config)); 293 + pdata->tstamp_config = *config; 292 294 293 295 return 0; 294 296 }
+6 -5
drivers/net/ethernet/amd/xgbe/xgbe.h
··· 1146 1146 spinlock_t tstamp_lock; 1147 1147 struct ptp_clock_info ptp_clock_info; 1148 1148 struct ptp_clock *ptp_clock; 1149 - struct hwtstamp_config tstamp_config; 1149 + struct kernel_hwtstamp_config tstamp_config; 1150 1150 unsigned int tstamp_addend; 1151 1151 struct work_struct tx_tstamp_work; 1152 1152 struct sk_buff *tx_tstamp_skb; ··· 1307 1307 void xgbe_set_tstamp_time(struct xgbe_prv_data *pdata, unsigned int sec, 1308 1308 unsigned int nsec); 1309 1309 void xgbe_tx_tstamp(struct work_struct *work); 1310 - int xgbe_get_hwtstamp_settings(struct xgbe_prv_data *pdata, 1311 - struct ifreq *ifreq); 1312 - int xgbe_set_hwtstamp_settings(struct xgbe_prv_data *pdata, 1313 - struct ifreq *ifreq); 1310 + int xgbe_get_hwtstamp_settings(struct net_device *netdev, 1311 + struct kernel_hwtstamp_config *config); 1312 + int xgbe_set_hwtstamp_settings(struct net_device *netdev, 1313 + struct kernel_hwtstamp_config *config, 1314 + struct netlink_ext_ack *extack); 1314 1315 void xgbe_prep_tx_tstamp(struct xgbe_prv_data *pdata, 1315 1316 struct sk_buff *skb, 1316 1317 struct xgbe_packet_data *packet);
+16 -52
drivers/net/ethernet/aquantia/atlantic/aq_main.c
··· 258 258 (void)aq_nic_set_multicast_list(aq_nic, ndev); 259 259 } 260 260 261 - #if IS_REACHABLE(CONFIG_PTP_1588_CLOCK) 262 - static int aq_ndev_config_hwtstamp(struct aq_nic_s *aq_nic, 263 - struct hwtstamp_config *config) 261 + static int aq_ndev_hwtstamp_set(struct net_device *netdev, 262 + struct kernel_hwtstamp_config *config, 263 + struct netlink_ext_ack *extack) 264 264 { 265 + struct aq_nic_s *aq_nic = netdev_priv(netdev); 266 + 267 + if (!IS_REACHABLE(CONFIG_PTP_1588_CLOCK) || !aq_nic->aq_ptp) 268 + return -EOPNOTSUPP; 269 + 265 270 switch (config->tx_type) { 266 271 case HWTSTAMP_TX_OFF: 267 272 case HWTSTAMP_TX_ON: ··· 295 290 296 291 return aq_ptp_hwtstamp_config_set(aq_nic->aq_ptp, config); 297 292 } 298 - #endif 299 293 300 - static int aq_ndev_hwtstamp_set(struct aq_nic_s *aq_nic, struct ifreq *ifr) 301 - { 302 - struct hwtstamp_config config; 303 - #if IS_REACHABLE(CONFIG_PTP_1588_CLOCK) 304 - int ret_val; 305 - #endif 306 - 307 - if (!aq_nic->aq_ptp) 308 - return -EOPNOTSUPP; 309 - 310 - if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) 311 - return -EFAULT; 312 - #if IS_REACHABLE(CONFIG_PTP_1588_CLOCK) 313 - ret_val = aq_ndev_config_hwtstamp(aq_nic, &config); 314 - if (ret_val) 315 - return ret_val; 316 - #endif 317 - 318 - return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ? 319 - -EFAULT : 0; 320 - } 321 - 322 - #if IS_REACHABLE(CONFIG_PTP_1588_CLOCK) 323 - static int aq_ndev_hwtstamp_get(struct aq_nic_s *aq_nic, struct ifreq *ifr) 324 - { 325 - struct hwtstamp_config config; 326 - 327 - if (!aq_nic->aq_ptp) 328 - return -EOPNOTSUPP; 329 - 330 - aq_ptp_hwtstamp_config_get(aq_nic->aq_ptp, &config); 331 - return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ? 332 - -EFAULT : 0; 333 - } 334 - #endif 335 - 336 - static int aq_ndev_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) 294 + static int aq_ndev_hwtstamp_get(struct net_device *netdev, 295 + struct kernel_hwtstamp_config *config) 337 296 { 338 297 struct aq_nic_s *aq_nic = netdev_priv(netdev); 339 298 340 - switch (cmd) { 341 - case SIOCSHWTSTAMP: 342 - return aq_ndev_hwtstamp_set(aq_nic, ifr); 299 + if (!aq_nic->aq_ptp) 300 + return -EOPNOTSUPP; 343 301 344 - #if IS_REACHABLE(CONFIG_PTP_1588_CLOCK) 345 - case SIOCGHWTSTAMP: 346 - return aq_ndev_hwtstamp_get(aq_nic, ifr); 347 - #endif 348 - } 349 - 350 - return -EOPNOTSUPP; 302 + aq_ptp_hwtstamp_config_get(aq_nic->aq_ptp, config); 303 + return 0; 351 304 } 352 305 353 306 static int aq_ndo_vlan_rx_add_vid(struct net_device *ndev, __be16 proto, ··· 463 500 .ndo_set_mac_address = aq_ndev_set_mac_address, 464 501 .ndo_set_features = aq_ndev_set_features, 465 502 .ndo_fix_features = aq_ndev_fix_features, 466 - .ndo_eth_ioctl = aq_ndev_ioctl, 467 503 .ndo_vlan_rx_add_vid = aq_ndo_vlan_rx_add_vid, 468 504 .ndo_vlan_rx_kill_vid = aq_ndo_vlan_rx_kill_vid, 469 505 .ndo_setup_tc = aq_ndo_setup_tc, 470 506 .ndo_bpf = aq_xdp, 471 507 .ndo_xdp_xmit = aq_xdp_xmit, 508 + .ndo_hwtstamp_get = aq_ndev_hwtstamp_get, 509 + .ndo_hwtstamp_set = aq_ndev_hwtstamp_set, 472 510 }; 473 511 474 512 static int __init aq_ndev_init_module(void)
+3 -3
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c
··· 51 51 52 52 struct aq_ptp_s { 53 53 struct aq_nic_s *aq_nic; 54 - struct hwtstamp_config hwtstamp_config; 54 + struct kernel_hwtstamp_config hwtstamp_config; 55 55 spinlock_t ptp_lock; 56 56 spinlock_t ptp_ring_lock; 57 57 struct ptp_clock *ptp_clock; ··· 567 567 } 568 568 569 569 void aq_ptp_hwtstamp_config_get(struct aq_ptp_s *aq_ptp, 570 - struct hwtstamp_config *config) 570 + struct kernel_hwtstamp_config *config) 571 571 { 572 572 *config = aq_ptp->hwtstamp_config; 573 573 } ··· 588 588 } 589 589 590 590 int aq_ptp_hwtstamp_config_set(struct aq_ptp_s *aq_ptp, 591 - struct hwtstamp_config *config) 591 + struct kernel_hwtstamp_config *config) 592 592 { 593 593 struct aq_nic_s *aq_nic = aq_ptp->aq_nic; 594 594 const struct aq_hw_ops *hw_ops;
+4 -4
drivers/net/ethernet/aquantia/atlantic/aq_ptp.h
··· 60 60 61 61 /* Must be to check available of PTP before call */ 62 62 void aq_ptp_hwtstamp_config_get(struct aq_ptp_s *aq_ptp, 63 - struct hwtstamp_config *config); 63 + struct kernel_hwtstamp_config *config); 64 64 int aq_ptp_hwtstamp_config_set(struct aq_ptp_s *aq_ptp, 65 - struct hwtstamp_config *config); 65 + struct kernel_hwtstamp_config *config); 66 66 67 67 /* Return either ring is belong to PTP or not*/ 68 68 bool aq_ptp_ring(struct aq_nic_s *aq_nic, struct aq_ring_s *ring); ··· 130 130 131 131 static inline void aq_ptp_tx_hwtstamp(struct aq_nic_s *aq_nic, u64 timestamp) {} 132 132 static inline void aq_ptp_hwtstamp_config_get(struct aq_ptp_s *aq_ptp, 133 - struct hwtstamp_config *config) {} 133 + struct kernel_hwtstamp_config *config) {} 134 134 static inline int aq_ptp_hwtstamp_config_set(struct aq_ptp_s *aq_ptp, 135 - struct hwtstamp_config *config) 135 + struct kernel_hwtstamp_config *config) 136 136 { 137 137 return 0; 138 138 }
+1 -1
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
··· 674 674 struct cxgb_fcoe fcoe; 675 675 #endif /* CONFIG_CHELSIO_T4_FCOE */ 676 676 bool rxtstamp; /* Enable TS */ 677 - struct hwtstamp_config tstamp_config; 677 + struct kernel_hwtstamp_config tstamp_config; 678 678 bool ptp_enable; 679 679 struct sched_table *sched_tbl; 680 680 u32 eth_flags;
+78 -76
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
··· 3042 3042 ns->rx_length_errors + stats.rx_len_err + ns->rx_fifo_errors; 3043 3043 } 3044 3044 3045 + static int cxgb_hwtstamp_get(struct net_device *dev, 3046 + struct kernel_hwtstamp_config *config) 3047 + { 3048 + struct port_info *pi = netdev_priv(dev); 3049 + 3050 + *config = pi->tstamp_config; 3051 + return 0; 3052 + } 3053 + 3054 + static int cxgb_hwtstamp_set(struct net_device *dev, 3055 + struct kernel_hwtstamp_config *config, 3056 + struct netlink_ext_ack *extack) 3057 + { 3058 + struct port_info *pi = netdev_priv(dev); 3059 + struct adapter *adapter = pi->adapter; 3060 + 3061 + if (is_t4(adapter->params.chip)) { 3062 + /* For T4 Adapters */ 3063 + switch (config->rx_filter) { 3064 + case HWTSTAMP_FILTER_NONE: 3065 + pi->rxtstamp = false; 3066 + break; 3067 + case HWTSTAMP_FILTER_ALL: 3068 + pi->rxtstamp = true; 3069 + break; 3070 + default: 3071 + return -ERANGE; 3072 + } 3073 + pi->tstamp_config = *config; 3074 + return 0; 3075 + } 3076 + 3077 + switch (config->tx_type) { 3078 + case HWTSTAMP_TX_OFF: 3079 + case HWTSTAMP_TX_ON: 3080 + break; 3081 + default: 3082 + return -ERANGE; 3083 + } 3084 + 3085 + switch (config->rx_filter) { 3086 + case HWTSTAMP_FILTER_NONE: 3087 + pi->rxtstamp = false; 3088 + break; 3089 + case HWTSTAMP_FILTER_PTP_V1_L4_EVENT: 3090 + case HWTSTAMP_FILTER_PTP_V2_L4_EVENT: 3091 + cxgb4_ptprx_timestamping(pi, pi->port_id, PTP_TS_L4); 3092 + break; 3093 + case HWTSTAMP_FILTER_PTP_V2_EVENT: 3094 + cxgb4_ptprx_timestamping(pi, pi->port_id, PTP_TS_L2_L4); 3095 + break; 3096 + case HWTSTAMP_FILTER_ALL: 3097 + case HWTSTAMP_FILTER_PTP_V1_L4_SYNC: 3098 + case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ: 3099 + case HWTSTAMP_FILTER_PTP_V2_L4_SYNC: 3100 + case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ: 3101 + pi->rxtstamp = true; 3102 + break; 3103 + default: 3104 + return -ERANGE; 3105 + } 3106 + 3107 + if (config->tx_type == HWTSTAMP_TX_OFF && 3108 + config->rx_filter == HWTSTAMP_FILTER_NONE) { 3109 + if (cxgb4_ptp_txtype(adapter, pi->port_id) >= 0) 3110 + pi->ptp_enable = false; 3111 + } 3112 + 3113 + if (config->rx_filter != HWTSTAMP_FILTER_NONE) { 3114 + if (cxgb4_ptp_redirect_rx_packet(adapter, pi) >= 0) 3115 + pi->ptp_enable = true; 3116 + } 3117 + pi->tstamp_config = *config; 3118 + return 0; 3119 + } 3120 + 3045 3121 static int cxgb_ioctl(struct net_device *dev, struct ifreq *req, int cmd) 3046 3122 { 3047 3123 unsigned int mbox; 3048 3124 int ret = 0, prtad, devad; 3049 3125 struct port_info *pi = netdev_priv(dev); 3050 - struct adapter *adapter = pi->adapter; 3051 3126 struct mii_ioctl_data *data = (struct mii_ioctl_data *)&req->ifr_data; 3052 3127 3053 3128 switch (cmd) { ··· 3151 3076 ret = t4_mdio_wr(pi->adapter, mbox, prtad, devad, 3152 3077 data->reg_num, data->val_in); 3153 3078 break; 3154 - case SIOCGHWTSTAMP: 3155 - return copy_to_user(req->ifr_data, &pi->tstamp_config, 3156 - sizeof(pi->tstamp_config)) ? 3157 - -EFAULT : 0; 3158 - case SIOCSHWTSTAMP: 3159 - if (copy_from_user(&pi->tstamp_config, req->ifr_data, 3160 - sizeof(pi->tstamp_config))) 3161 - return -EFAULT; 3162 - 3163 - if (!is_t4(adapter->params.chip)) { 3164 - switch (pi->tstamp_config.tx_type) { 3165 - case HWTSTAMP_TX_OFF: 3166 - case HWTSTAMP_TX_ON: 3167 - break; 3168 - default: 3169 - return -ERANGE; 3170 - } 3171 - 3172 - switch (pi->tstamp_config.rx_filter) { 3173 - case HWTSTAMP_FILTER_NONE: 3174 - pi->rxtstamp = false; 3175 - break; 3176 - case HWTSTAMP_FILTER_PTP_V1_L4_EVENT: 3177 - case HWTSTAMP_FILTER_PTP_V2_L4_EVENT: 3178 - cxgb4_ptprx_timestamping(pi, pi->port_id, 3179 - PTP_TS_L4); 3180 - break; 3181 - case HWTSTAMP_FILTER_PTP_V2_EVENT: 3182 - cxgb4_ptprx_timestamping(pi, pi->port_id, 3183 - PTP_TS_L2_L4); 3184 - break; 3185 - case HWTSTAMP_FILTER_ALL: 3186 - case HWTSTAMP_FILTER_PTP_V1_L4_SYNC: 3187 - case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ: 3188 - case HWTSTAMP_FILTER_PTP_V2_L4_SYNC: 3189 - case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ: 3190 - pi->rxtstamp = true; 3191 - break; 3192 - default: 3193 - pi->tstamp_config.rx_filter = 3194 - HWTSTAMP_FILTER_NONE; 3195 - return -ERANGE; 3196 - } 3197 - 3198 - if ((pi->tstamp_config.tx_type == HWTSTAMP_TX_OFF) && 3199 - (pi->tstamp_config.rx_filter == 3200 - HWTSTAMP_FILTER_NONE)) { 3201 - if (cxgb4_ptp_txtype(adapter, pi->port_id) >= 0) 3202 - pi->ptp_enable = false; 3203 - } 3204 - 3205 - if (pi->tstamp_config.rx_filter != 3206 - HWTSTAMP_FILTER_NONE) { 3207 - if (cxgb4_ptp_redirect_rx_packet(adapter, 3208 - pi) >= 0) 3209 - pi->ptp_enable = true; 3210 - } 3211 - } else { 3212 - /* For T4 Adapters */ 3213 - switch (pi->tstamp_config.rx_filter) { 3214 - case HWTSTAMP_FILTER_NONE: 3215 - pi->rxtstamp = false; 3216 - break; 3217 - case HWTSTAMP_FILTER_ALL: 3218 - pi->rxtstamp = true; 3219 - break; 3220 - default: 3221 - pi->tstamp_config.rx_filter = 3222 - HWTSTAMP_FILTER_NONE; 3223 - return -ERANGE; 3224 - } 3225 - } 3226 - return copy_to_user(req->ifr_data, &pi->tstamp_config, 3227 - sizeof(pi->tstamp_config)) ? 3228 - -EFAULT : 0; 3229 3079 default: 3230 3080 return -EOPNOTSUPP; 3231 3081 } ··· 3875 3875 .ndo_setup_tc = cxgb_setup_tc, 3876 3876 .ndo_features_check = cxgb_features_check, 3877 3877 .ndo_fix_features = cxgb_fix_features, 3878 + .ndo_hwtstamp_get = cxgb_hwtstamp_get, 3879 + .ndo_hwtstamp_set = cxgb_hwtstamp_set, 3878 3880 }; 3879 3881 3880 3882 #ifdef CONFIG_PCI_IOV
+6 -2
drivers/net/ethernet/engleder/tsnep.h
··· 176 176 struct tsnep_gcl gcl[2]; 177 177 int next_gcl; 178 178 179 - struct hwtstamp_config hwtstamp_config; 179 + struct kernel_hwtstamp_config hwtstamp_config; 180 180 struct ptp_clock *ptp_clock; 181 181 struct ptp_clock_info ptp_clock_info; 182 182 /* ptp clock lock */ ··· 203 203 204 204 int tsnep_ptp_init(struct tsnep_adapter *adapter); 205 205 void tsnep_ptp_cleanup(struct tsnep_adapter *adapter); 206 - int tsnep_ptp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd); 206 + int tsnep_ptp_hwtstamp_get(struct net_device *netdev, 207 + struct kernel_hwtstamp_config *config); 208 + int tsnep_ptp_hwtstamp_set(struct net_device *netdev, 209 + struct kernel_hwtstamp_config *config, 210 + struct netlink_ext_ack *extack); 207 211 208 212 int tsnep_tc_init(struct tsnep_adapter *adapter); 209 213 void tsnep_tc_cleanup(struct tsnep_adapter *adapter);
+3 -11
drivers/net/ethernet/engleder/tsnep_main.c
··· 2168 2168 return tsnep_xmit_frame_ring(skb, &adapter->tx[queue_mapping]); 2169 2169 } 2170 2170 2171 - static int tsnep_netdev_ioctl(struct net_device *netdev, struct ifreq *ifr, 2172 - int cmd) 2173 - { 2174 - if (!netif_running(netdev)) 2175 - return -EINVAL; 2176 - if (cmd == SIOCSHWTSTAMP || cmd == SIOCGHWTSTAMP) 2177 - return tsnep_ptp_ioctl(netdev, ifr, cmd); 2178 - return phy_mii_ioctl(netdev->phydev, ifr, cmd); 2179 - } 2180 - 2181 2171 static void tsnep_netdev_set_multicast(struct net_device *netdev) 2182 2172 { 2183 2173 struct tsnep_adapter *adapter = netdev_priv(netdev); ··· 2374 2384 .ndo_open = tsnep_netdev_open, 2375 2385 .ndo_stop = tsnep_netdev_close, 2376 2386 .ndo_start_xmit = tsnep_netdev_xmit_frame, 2377 - .ndo_eth_ioctl = tsnep_netdev_ioctl, 2387 + .ndo_eth_ioctl = phy_do_ioctl_running, 2378 2388 .ndo_set_rx_mode = tsnep_netdev_set_multicast, 2379 2389 .ndo_get_stats64 = tsnep_netdev_get_stats64, 2380 2390 .ndo_set_mac_address = tsnep_netdev_set_mac_address, ··· 2384 2394 .ndo_bpf = tsnep_netdev_bpf, 2385 2395 .ndo_xdp_xmit = tsnep_netdev_xdp_xmit, 2386 2396 .ndo_xsk_wakeup = tsnep_netdev_xsk_wakeup, 2397 + .ndo_hwtstamp_get = tsnep_ptp_hwtstamp_get, 2398 + .ndo_hwtstamp_set = tsnep_ptp_hwtstamp_set, 2387 2399 }; 2388 2400 2389 2401 static int tsnep_mac_init(struct tsnep_adapter *adapter)
+39 -43
drivers/net/ethernet/engleder/tsnep_ptp.c
··· 19 19 *time = (((u64)high) << 32) | ((u64)low); 20 20 } 21 21 22 - int tsnep_ptp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) 22 + int tsnep_ptp_hwtstamp_get(struct net_device *netdev, 23 + struct kernel_hwtstamp_config *config) 23 24 { 24 25 struct tsnep_adapter *adapter = netdev_priv(netdev); 25 - struct hwtstamp_config config; 26 26 27 - if (!ifr) 28 - return -EINVAL; 27 + *config = adapter->hwtstamp_config; 28 + return 0; 29 + } 29 30 30 - if (cmd == SIOCSHWTSTAMP) { 31 - if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) 32 - return -EFAULT; 31 + int tsnep_ptp_hwtstamp_set(struct net_device *netdev, 32 + struct kernel_hwtstamp_config *config, 33 + struct netlink_ext_ack *extack) 34 + { 35 + struct tsnep_adapter *adapter = netdev_priv(netdev); 33 36 34 - switch (config.tx_type) { 35 - case HWTSTAMP_TX_OFF: 36 - case HWTSTAMP_TX_ON: 37 - break; 38 - default: 39 - return -ERANGE; 40 - } 41 - 42 - switch (config.rx_filter) { 43 - case HWTSTAMP_FILTER_NONE: 44 - break; 45 - case HWTSTAMP_FILTER_ALL: 46 - case HWTSTAMP_FILTER_PTP_V1_L4_EVENT: 47 - case HWTSTAMP_FILTER_PTP_V1_L4_SYNC: 48 - case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ: 49 - case HWTSTAMP_FILTER_PTP_V2_L4_EVENT: 50 - case HWTSTAMP_FILTER_PTP_V2_L4_SYNC: 51 - case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ: 52 - case HWTSTAMP_FILTER_PTP_V2_L2_EVENT: 53 - case HWTSTAMP_FILTER_PTP_V2_L2_SYNC: 54 - case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ: 55 - case HWTSTAMP_FILTER_PTP_V2_EVENT: 56 - case HWTSTAMP_FILTER_PTP_V2_SYNC: 57 - case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ: 58 - case HWTSTAMP_FILTER_NTP_ALL: 59 - config.rx_filter = HWTSTAMP_FILTER_ALL; 60 - break; 61 - default: 62 - return -ERANGE; 63 - } 64 - 65 - memcpy(&adapter->hwtstamp_config, &config, 66 - sizeof(adapter->hwtstamp_config)); 37 + switch (config->tx_type) { 38 + case HWTSTAMP_TX_OFF: 39 + case HWTSTAMP_TX_ON: 40 + break; 41 + default: 42 + return -ERANGE; 67 43 } 68 44 69 - if (copy_to_user(ifr->ifr_data, &adapter->hwtstamp_config, 70 - sizeof(adapter->hwtstamp_config))) 71 - return -EFAULT; 45 + switch (config->rx_filter) { 46 + case HWTSTAMP_FILTER_NONE: 47 + break; 48 + case HWTSTAMP_FILTER_ALL: 49 + case HWTSTAMP_FILTER_PTP_V1_L4_EVENT: 50 + case HWTSTAMP_FILTER_PTP_V1_L4_SYNC: 51 + case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ: 52 + case HWTSTAMP_FILTER_PTP_V2_L4_EVENT: 53 + case HWTSTAMP_FILTER_PTP_V2_L4_SYNC: 54 + case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ: 55 + case HWTSTAMP_FILTER_PTP_V2_L2_EVENT: 56 + case HWTSTAMP_FILTER_PTP_V2_L2_SYNC: 57 + case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ: 58 + case HWTSTAMP_FILTER_PTP_V2_EVENT: 59 + case HWTSTAMP_FILTER_PTP_V2_SYNC: 60 + case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ: 61 + case HWTSTAMP_FILTER_NTP_ALL: 62 + config->rx_filter = HWTSTAMP_FILTER_ALL; 63 + break; 64 + default: 65 + return -ERANGE; 66 + } 72 67 68 + adapter->hwtstamp_config = *config; 73 69 return 0; 74 70 } 75 71
+2 -2
drivers/net/ethernet/fungible/funeth/funeth.h
··· 4 4 #define _FUNETH_H 5 5 6 6 #include <uapi/linux/if_ether.h> 7 - #include <uapi/linux/net_tstamp.h> 7 + #include <linux/net_tstamp.h> 8 8 #include <linux/mutex.h> 9 9 #include <linux/seqlock.h> 10 10 #include <linux/xarray.h> ··· 121 121 u8 rx_coal_usec; 122 122 u8 rx_coal_count; 123 123 124 - struct hwtstamp_config hwtstamp_cfg; 124 + struct kernel_hwtstamp_config hwtstamp_cfg; 125 125 126 126 /* cumulative queue stats from earlier queue instances */ 127 127 u64 tx_packets;
+14 -26
drivers/net/ethernet/fungible/funeth/funeth_main.c
··· 1014 1014 return 0; 1015 1015 } 1016 1016 1017 - static int fun_hwtstamp_get(struct net_device *dev, struct ifreq *ifr) 1017 + static int fun_hwtstamp_get(struct net_device *dev, 1018 + struct kernel_hwtstamp_config *config) 1018 1019 { 1019 1020 const struct funeth_priv *fp = netdev_priv(dev); 1020 1021 1021 - return copy_to_user(ifr->ifr_data, &fp->hwtstamp_cfg, 1022 - sizeof(fp->hwtstamp_cfg)) ? -EFAULT : 0; 1022 + *config = fp->hwtstamp_cfg; 1023 + return 0; 1023 1024 } 1024 1025 1025 - static int fun_hwtstamp_set(struct net_device *dev, struct ifreq *ifr) 1026 + static int fun_hwtstamp_set(struct net_device *dev, 1027 + struct kernel_hwtstamp_config *config, 1028 + struct netlink_ext_ack *extack) 1026 1029 { 1027 1030 struct funeth_priv *fp = netdev_priv(dev); 1028 - struct hwtstamp_config cfg; 1029 - 1030 - if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg))) 1031 - return -EFAULT; 1032 1031 1033 1032 /* no TX HW timestamps */ 1034 - cfg.tx_type = HWTSTAMP_TX_OFF; 1033 + config->tx_type = HWTSTAMP_TX_OFF; 1035 1034 1036 - switch (cfg.rx_filter) { 1035 + switch (config->rx_filter) { 1037 1036 case HWTSTAMP_FILTER_NONE: 1038 1037 break; 1039 1038 case HWTSTAMP_FILTER_ALL: ··· 1050 1051 case HWTSTAMP_FILTER_PTP_V2_SYNC: 1051 1052 case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ: 1052 1053 case HWTSTAMP_FILTER_NTP_ALL: 1053 - cfg.rx_filter = HWTSTAMP_FILTER_ALL; 1054 + config->rx_filter = HWTSTAMP_FILTER_ALL; 1054 1055 break; 1055 1056 default: 1056 1057 return -ERANGE; 1057 1058 } 1058 1059 1059 - fp->hwtstamp_cfg = cfg; 1060 - return copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0; 1061 - } 1062 - 1063 - static int fun_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) 1064 - { 1065 - switch (cmd) { 1066 - case SIOCSHWTSTAMP: 1067 - return fun_hwtstamp_set(dev, ifr); 1068 - case SIOCGHWTSTAMP: 1069 - return fun_hwtstamp_get(dev, ifr); 1070 - default: 1071 - return -EOPNOTSUPP; 1072 - } 1060 + fp->hwtstamp_cfg = *config; 1061 + return 0; 1073 1062 } 1074 1063 1075 1064 /* Prepare the queues for XDP. */ ··· 1327 1340 .ndo_change_mtu = fun_change_mtu, 1328 1341 .ndo_set_mac_address = fun_set_macaddr, 1329 1342 .ndo_validate_addr = eth_validate_addr, 1330 - .ndo_eth_ioctl = fun_ioctl, 1331 1343 .ndo_uninit = fun_uninit, 1332 1344 .ndo_bpf = fun_xdp, 1333 1345 .ndo_xdp_xmit = fun_xdp_xmit_frames, ··· 1334 1348 .ndo_set_vf_vlan = fun_set_vf_vlan, 1335 1349 .ndo_set_vf_rate = fun_set_vf_rate, 1336 1350 .ndo_get_vf_config = fun_get_vf_config, 1351 + .ndo_hwtstamp_get = fun_hwtstamp_get, 1352 + .ndo_hwtstamp_set = fun_hwtstamp_set, 1337 1353 }; 1338 1354 1339 1355 #define GSO_ENCAP_FLAGS (NETIF_F_GSO_GRE | NETIF_F_GSO_IPXIP4 | \
+20 -24
drivers/net/ethernet/ti/am65-cpsw-nuss.c
··· 1788 1788 } 1789 1789 1790 1790 static int am65_cpsw_nuss_hwtstamp_set(struct net_device *ndev, 1791 - struct ifreq *ifr) 1791 + struct kernel_hwtstamp_config *cfg, 1792 + struct netlink_ext_ack *extack) 1792 1793 { 1793 1794 struct am65_cpsw_port *port = am65_ndev_to_port(ndev); 1794 1795 u32 ts_ctrl, seq_id, ts_ctrl_ltype2, ts_vlan_ltype; 1795 - struct hwtstamp_config cfg; 1796 1796 1797 - if (!IS_ENABLED(CONFIG_TI_K3_AM65_CPTS)) 1797 + if (!IS_ENABLED(CONFIG_TI_K3_AM65_CPTS)) { 1798 + NL_SET_ERR_MSG(extack, "Time stamping is not supported"); 1798 1799 return -EOPNOTSUPP; 1799 - 1800 - if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg))) 1801 - return -EFAULT; 1800 + } 1802 1801 1803 1802 /* TX HW timestamp */ 1804 - switch (cfg.tx_type) { 1803 + switch (cfg->tx_type) { 1805 1804 case HWTSTAMP_TX_OFF: 1806 1805 case HWTSTAMP_TX_ON: 1807 1806 break; 1808 1807 default: 1808 + NL_SET_ERR_MSG(extack, "TX mode is not supported"); 1809 1809 return -ERANGE; 1810 1810 } 1811 1811 1812 - switch (cfg.rx_filter) { 1812 + switch (cfg->rx_filter) { 1813 1813 case HWTSTAMP_FILTER_NONE: 1814 1814 port->rx_ts_enabled = false; 1815 1815 break; ··· 1826 1826 case HWTSTAMP_FILTER_PTP_V2_SYNC: 1827 1827 case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ: 1828 1828 port->rx_ts_enabled = true; 1829 - cfg.rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT | HWTSTAMP_FILTER_PTP_V1_L4_EVENT; 1829 + cfg->rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT | HWTSTAMP_FILTER_PTP_V1_L4_EVENT; 1830 1830 break; 1831 1831 case HWTSTAMP_FILTER_ALL: 1832 1832 case HWTSTAMP_FILTER_SOME: 1833 1833 case HWTSTAMP_FILTER_NTP_ALL: 1834 + NL_SET_ERR_MSG(extack, "RX filter is not supported"); 1834 1835 return -EOPNOTSUPP; 1835 1836 default: 1837 + NL_SET_ERR_MSG(extack, "RX filter is not supported"); 1836 1838 return -ERANGE; 1837 1839 } 1838 1840 1839 - port->tx_ts_enabled = (cfg.tx_type == HWTSTAMP_TX_ON); 1841 + port->tx_ts_enabled = (cfg->tx_type == HWTSTAMP_TX_ON); 1840 1842 1841 1843 /* cfg TX timestamp */ 1842 1844 seq_id = (AM65_CPSW_TS_SEQ_ID_OFFSET << ··· 1874 1872 AM65_CPSW_PORTN_REG_TS_CTL_LTYPE2); 1875 1873 writel(ts_ctrl, port->port_base + AM65_CPSW_PORTN_REG_TS_CTL); 1876 1874 1877 - return copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0; 1875 + return 0; 1878 1876 } 1879 1877 1880 1878 static int am65_cpsw_nuss_hwtstamp_get(struct net_device *ndev, 1881 - struct ifreq *ifr) 1879 + struct kernel_hwtstamp_config *cfg) 1882 1880 { 1883 1881 struct am65_cpsw_port *port = am65_ndev_to_port(ndev); 1884 - struct hwtstamp_config cfg; 1885 1882 1886 1883 if (!IS_ENABLED(CONFIG_TI_K3_AM65_CPTS)) 1887 1884 return -EOPNOTSUPP; 1888 1885 1889 - cfg.flags = 0; 1890 - cfg.tx_type = port->tx_ts_enabled ? 1886 + cfg->flags = 0; 1887 + cfg->tx_type = port->tx_ts_enabled ? 1891 1888 HWTSTAMP_TX_ON : HWTSTAMP_TX_OFF; 1892 - cfg.rx_filter = port->rx_ts_enabled ? HWTSTAMP_FILTER_PTP_V2_EVENT | 1889 + cfg->rx_filter = port->rx_ts_enabled ? HWTSTAMP_FILTER_PTP_V2_EVENT | 1893 1890 HWTSTAMP_FILTER_PTP_V1_L4_EVENT : HWTSTAMP_FILTER_NONE; 1894 1891 1895 - return copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0; 1892 + return 0; 1896 1893 } 1897 1894 1898 1895 static int am65_cpsw_nuss_ndo_slave_ioctl(struct net_device *ndev, ··· 1901 1900 1902 1901 if (!netif_running(ndev)) 1903 1902 return -EINVAL; 1904 - 1905 - switch (cmd) { 1906 - case SIOCSHWTSTAMP: 1907 - return am65_cpsw_nuss_hwtstamp_set(ndev, req); 1908 - case SIOCGHWTSTAMP: 1909 - return am65_cpsw_nuss_hwtstamp_get(ndev, req); 1910 - } 1911 1903 1912 1904 return phylink_mii_ioctl(port->slave.phylink, req, cmd); 1913 1905 } ··· 1985 1991 .ndo_set_tx_maxrate = am65_cpsw_qos_ndo_tx_p0_set_maxrate, 1986 1992 .ndo_bpf = am65_cpsw_ndo_bpf, 1987 1993 .ndo_xdp_xmit = am65_cpsw_ndo_xdp_xmit, 1994 + .ndo_hwtstamp_get = am65_cpsw_nuss_hwtstamp_get, 1995 + .ndo_hwtstamp_set = am65_cpsw_nuss_hwtstamp_set, 1988 1996 }; 1989 1997 1990 1998 static void am65_cpsw_disable_phy(struct phy *phy)
+15 -32
drivers/net/ethernet/ti/icssg/icssg_common.c
··· 1223 1223 } 1224 1224 EXPORT_SYMBOL_GPL(icssg_ndo_tx_timeout); 1225 1225 1226 - static int emac_set_ts_config(struct net_device *ndev, struct ifreq *ifr) 1226 + int icssg_ndo_set_ts_config(struct net_device *ndev, 1227 + struct kernel_hwtstamp_config *config, 1228 + struct netlink_ext_ack *extack) 1227 1229 { 1228 1230 struct prueth_emac *emac = netdev_priv(ndev); 1229 - struct hwtstamp_config config; 1230 1231 1231 - if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) 1232 - return -EFAULT; 1233 - 1234 - switch (config.tx_type) { 1232 + switch (config->tx_type) { 1235 1233 case HWTSTAMP_TX_OFF: 1236 1234 emac->tx_ts_enabled = 0; 1237 1235 break; ··· 1240 1242 return -ERANGE; 1241 1243 } 1242 1244 1243 - switch (config.rx_filter) { 1245 + switch (config->rx_filter) { 1244 1246 case HWTSTAMP_FILTER_NONE: 1245 1247 emac->rx_ts_enabled = 0; 1246 1248 break; ··· 1260 1262 case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ: 1261 1263 case HWTSTAMP_FILTER_NTP_ALL: 1262 1264 emac->rx_ts_enabled = 1; 1263 - config.rx_filter = HWTSTAMP_FILTER_ALL; 1265 + config->rx_filter = HWTSTAMP_FILTER_ALL; 1264 1266 break; 1265 1267 default: 1266 1268 return -ERANGE; 1267 1269 } 1268 1270 1269 - return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ? 1270 - -EFAULT : 0; 1271 + return 0; 1271 1272 } 1273 + EXPORT_SYMBOL_GPL(icssg_ndo_set_ts_config); 1272 1274 1273 - static int emac_get_ts_config(struct net_device *ndev, struct ifreq *ifr) 1275 + int icssg_ndo_get_ts_config(struct net_device *ndev, 1276 + struct kernel_hwtstamp_config *config) 1274 1277 { 1275 1278 struct prueth_emac *emac = netdev_priv(ndev); 1276 - struct hwtstamp_config config; 1277 1279 1278 - config.flags = 0; 1279 - config.tx_type = emac->tx_ts_enabled ? HWTSTAMP_TX_ON : HWTSTAMP_TX_OFF; 1280 - config.rx_filter = emac->rx_ts_enabled ? HWTSTAMP_FILTER_ALL : HWTSTAMP_FILTER_NONE; 1280 + config->flags = 0; 1281 + config->tx_type = emac->tx_ts_enabled ? HWTSTAMP_TX_ON : HWTSTAMP_TX_OFF; 1282 + config->rx_filter = emac->rx_ts_enabled ? HWTSTAMP_FILTER_ALL : HWTSTAMP_FILTER_NONE; 1281 1283 1282 - return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ? 1283 - -EFAULT : 0; 1284 + return 0; 1284 1285 } 1285 - 1286 - int icssg_ndo_ioctl(struct net_device *ndev, struct ifreq *ifr, int cmd) 1287 - { 1288 - switch (cmd) { 1289 - case SIOCGHWTSTAMP: 1290 - return emac_get_ts_config(ndev, ifr); 1291 - case SIOCSHWTSTAMP: 1292 - return emac_set_ts_config(ndev, ifr); 1293 - default: 1294 - break; 1295 - } 1296 - 1297 - return phy_do_ioctl(ndev, ifr, cmd); 1298 - } 1299 - EXPORT_SYMBOL_GPL(icssg_ndo_ioctl); 1286 + EXPORT_SYMBOL_GPL(icssg_ndo_get_ts_config); 1300 1287 1301 1288 void icssg_ndo_get_stats64(struct net_device *ndev, 1302 1289 struct rtnl_link_stats64 *stats)
+3 -1
drivers/net/ethernet/ti/icssg/icssg_prueth.c
··· 1168 1168 .ndo_validate_addr = eth_validate_addr, 1169 1169 .ndo_tx_timeout = icssg_ndo_tx_timeout, 1170 1170 .ndo_set_rx_mode = emac_ndo_set_rx_mode, 1171 - .ndo_eth_ioctl = icssg_ndo_ioctl, 1171 + .ndo_eth_ioctl = phy_do_ioctl, 1172 1172 .ndo_get_stats64 = icssg_ndo_get_stats64, 1173 1173 .ndo_get_phys_port_name = icssg_ndo_get_phys_port_name, 1174 1174 .ndo_fix_features = emac_ndo_fix_features, ··· 1176 1176 .ndo_vlan_rx_kill_vid = emac_ndo_vlan_rx_del_vid, 1177 1177 .ndo_bpf = emac_ndo_bpf, 1178 1178 .ndo_xdp_xmit = emac_xdp_xmit, 1179 + .ndo_hwtstamp_get = icssg_ndo_get_ts_config, 1180 + .ndo_hwtstamp_set = icssg_ndo_set_ts_config, 1179 1181 }; 1180 1182 1181 1183 static int prueth_netdev_init(struct prueth *prueth,
+5 -1
drivers/net/ethernet/ti/icssg/icssg_prueth.h
··· 479 479 void prueth_reset_rx_chan(struct prueth_rx_chn *chn, 480 480 int num_flows, bool disable); 481 481 void icssg_ndo_tx_timeout(struct net_device *ndev, unsigned int txqueue); 482 - int icssg_ndo_ioctl(struct net_device *ndev, struct ifreq *ifr, int cmd); 482 + int icssg_ndo_get_ts_config(struct net_device *ndev, 483 + struct kernel_hwtstamp_config *config); 484 + int icssg_ndo_set_ts_config(struct net_device *ndev, 485 + struct kernel_hwtstamp_config *config, 486 + struct netlink_ext_ack *extack); 483 487 void icssg_ndo_get_stats64(struct net_device *ndev, 484 488 struct rtnl_link_stats64 *stats); 485 489 int icssg_ndo_get_phys_port_name(struct net_device *ndev, char *name,
+3 -1
drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c
··· 747 747 .ndo_validate_addr = eth_validate_addr, 748 748 .ndo_tx_timeout = icssg_ndo_tx_timeout, 749 749 .ndo_set_rx_mode = emac_ndo_set_rx_mode_sr1, 750 - .ndo_eth_ioctl = icssg_ndo_ioctl, 750 + .ndo_eth_ioctl = phy_do_ioctl, 751 751 .ndo_get_stats64 = icssg_ndo_get_stats64, 752 752 .ndo_get_phys_port_name = icssg_ndo_get_phys_port_name, 753 + .ndo_hwtstamp_get = icssg_ndo_get_ts_config, 754 + .ndo_hwtstamp_set = icssg_ndo_set_ts_config, 753 755 }; 754 756 755 757 static int prueth_netdev_init(struct prueth *prueth,