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-2'

Vadim Fedorenko says:

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

This is part 2 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.
====================

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

+216 -220
+5
drivers/net/ethernet/hisilicon/hns3/hnae3.h
··· 804 804 int (*dbg_get_read_func)(struct hnae3_handle *handle, 805 805 enum hnae3_dbg_cmd cmd, 806 806 read_func *func); 807 + int (*hwtstamp_get)(struct hnae3_handle *handle, 808 + struct kernel_hwtstamp_config *config); 809 + int (*hwtstamp_set)(struct hnae3_handle *handle, 810 + struct kernel_hwtstamp_config *config, 811 + struct netlink_ext_ack *extack); 807 812 }; 808 813 809 814 struct hnae3_dcb_ops {
+31
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
··· 2419 2419 return h->ae_algo->ops->do_ioctl(h, ifr, cmd); 2420 2420 } 2421 2421 2422 + static int hns3_nic_hwtstamp_get(struct net_device *netdev, 2423 + struct kernel_hwtstamp_config *config) 2424 + { 2425 + struct hnae3_handle *h = hns3_get_handle(netdev); 2426 + 2427 + if (!netif_running(netdev)) 2428 + return -EINVAL; 2429 + 2430 + if (!h->ae_algo->ops->hwtstamp_get) 2431 + return -EOPNOTSUPP; 2432 + 2433 + return h->ae_algo->ops->hwtstamp_get(h, config); 2434 + } 2435 + 2436 + static int hns3_nic_hwtstamp_set(struct net_device *netdev, 2437 + struct kernel_hwtstamp_config *config, 2438 + struct netlink_ext_ack *extack) 2439 + { 2440 + struct hnae3_handle *h = hns3_get_handle(netdev); 2441 + 2442 + if (!netif_running(netdev)) 2443 + return -EINVAL; 2444 + 2445 + if (!h->ae_algo->ops->hwtstamp_set) 2446 + return -EOPNOTSUPP; 2447 + 2448 + return h->ae_algo->ops->hwtstamp_set(h, config, extack); 2449 + } 2450 + 2422 2451 static int hns3_nic_set_features(struct net_device *netdev, 2423 2452 netdev_features_t features) 2424 2453 { ··· 3077 3048 .ndo_set_vf_rate = hns3_nic_set_vf_rate, 3078 3049 .ndo_set_vf_mac = hns3_nic_set_vf_mac, 3079 3050 .ndo_select_queue = hns3_nic_select_queue, 3051 + .ndo_hwtstamp_get = hns3_nic_hwtstamp_get, 3052 + .ndo_hwtstamp_set = hns3_nic_hwtstamp_set, 3080 3053 }; 3081 3054 3082 3055 bool hns3_is_phys_func(struct pci_dev *pdev)
+4 -9
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
··· 9445 9445 struct hclge_vport *vport = hclge_get_vport(handle); 9446 9446 struct hclge_dev *hdev = vport->back; 9447 9447 9448 - switch (cmd) { 9449 - case SIOCGHWTSTAMP: 9450 - return hclge_ptp_get_cfg(hdev, ifr); 9451 - case SIOCSHWTSTAMP: 9452 - return hclge_ptp_set_cfg(hdev, ifr); 9453 - default: 9454 - if (!hdev->hw.mac.phydev) 9455 - return hclge_mii_ioctl(hdev, ifr, cmd); 9456 - } 9448 + if (!hdev->hw.mac.phydev) 9449 + return hclge_mii_ioctl(hdev, ifr, cmd); 9457 9450 9458 9451 return phy_mii_ioctl(hdev->hw.mac.phydev, ifr, cmd); 9459 9452 } ··· 12894 12901 .get_dscp_prio = hclge_get_dscp_prio, 12895 12902 .get_wol = hclge_get_wol, 12896 12903 .set_wol = hclge_set_wol, 12904 + .hwtstamp_get = hclge_ptp_get_cfg, 12905 + .hwtstamp_set = hclge_ptp_set_cfg, 12897 12906 }; 12898 12907 12899 12908 static struct hnae3_ae_algo ae_algo = {
+18 -14
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.c
··· 204 204 return 0; 205 205 } 206 206 207 - int hclge_ptp_get_cfg(struct hclge_dev *hdev, struct ifreq *ifr) 207 + int hclge_ptp_get_cfg(struct hnae3_handle *handle, 208 + struct kernel_hwtstamp_config *config) 208 209 { 210 + struct hclge_vport *vport = hclge_get_vport(handle); 211 + struct hclge_dev *hdev = vport->back; 212 + 209 213 if (!test_bit(HCLGE_STATE_PTP_EN, &hdev->state)) 210 214 return -EOPNOTSUPP; 211 215 212 - return copy_to_user(ifr->ifr_data, &hdev->ptp->ts_cfg, 213 - sizeof(struct hwtstamp_config)) ? -EFAULT : 0; 216 + *config = hdev->ptp->ts_cfg; 217 + return 0; 214 218 } 215 219 216 220 static int hclge_ptp_int_en(struct hclge_dev *hdev, bool en) ··· 273 269 return ret; 274 270 } 275 271 276 - static int hclge_ptp_set_tx_mode(struct hwtstamp_config *cfg, 272 + static int hclge_ptp_set_tx_mode(struct kernel_hwtstamp_config *cfg, 277 273 unsigned long *flags, u32 *ptp_cfg) 278 274 { 279 275 switch (cfg->tx_type) { ··· 291 287 return 0; 292 288 } 293 289 294 - static int hclge_ptp_set_rx_mode(struct hwtstamp_config *cfg, 290 + static int hclge_ptp_set_rx_mode(struct kernel_hwtstamp_config *cfg, 295 291 unsigned long *flags, u32 *ptp_cfg) 296 292 { 297 293 int rx_filter = cfg->rx_filter; ··· 336 332 } 337 333 338 334 static int hclge_ptp_set_ts_mode(struct hclge_dev *hdev, 339 - struct hwtstamp_config *cfg) 335 + struct kernel_hwtstamp_config *cfg) 340 336 { 341 337 unsigned long flags = hdev->ptp->flags; 342 338 u32 ptp_cfg = 0; ··· 363 359 return 0; 364 360 } 365 361 366 - int hclge_ptp_set_cfg(struct hclge_dev *hdev, struct ifreq *ifr) 362 + int hclge_ptp_set_cfg(struct hnae3_handle *handle, 363 + struct kernel_hwtstamp_config *config, 364 + struct netlink_ext_ack *extack) 367 365 { 368 - struct hwtstamp_config cfg; 366 + struct hclge_vport *vport = hclge_get_vport(handle); 367 + struct hclge_dev *hdev = vport->back; 369 368 int ret; 370 369 371 370 if (!test_bit(HCLGE_STATE_PTP_EN, &hdev->state)) { ··· 376 369 return -EOPNOTSUPP; 377 370 } 378 371 379 - if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg))) 380 - return -EFAULT; 381 - 382 - ret = hclge_ptp_set_ts_mode(hdev, &cfg); 372 + ret = hclge_ptp_set_ts_mode(hdev, config); 383 373 if (ret) 384 374 return ret; 385 375 386 - hdev->ptp->ts_cfg = cfg; 376 + hdev->ptp->ts_cfg = *config; 387 377 388 - return copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0; 378 + return 0; 389 379 } 390 380 391 381 int hclge_ptp_get_ts_info(struct hnae3_handle *handle,
+6 -3
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.h
··· 62 62 unsigned long flags; 63 63 void __iomem *io_base; 64 64 struct ptp_clock_info info; 65 - struct hwtstamp_config ts_cfg; 65 + struct kernel_hwtstamp_config ts_cfg; 66 66 spinlock_t lock; /* protects ptp registers */ 67 67 u32 ptp_cfg; 68 68 u32 last_tx_seqid; ··· 133 133 void hclge_ptp_clean_tx_hwts(struct hclge_dev *hdev); 134 134 void hclge_ptp_get_rx_hwts(struct hnae3_handle *handle, struct sk_buff *skb, 135 135 u32 nsec, u32 sec); 136 - int hclge_ptp_get_cfg(struct hclge_dev *hdev, struct ifreq *ifr); 137 - int hclge_ptp_set_cfg(struct hclge_dev *hdev, struct ifreq *ifr); 136 + int hclge_ptp_get_cfg(struct hnae3_handle *handle, 137 + struct kernel_hwtstamp_config *config); 138 + int hclge_ptp_set_cfg(struct hnae3_handle *handle, 139 + struct kernel_hwtstamp_config *config, 140 + struct netlink_ext_ack *extack); 138 141 int hclge_ptp_init(struct hclge_dev *hdev); 139 142 void hclge_ptp_uninit(struct hclge_dev *hdev); 140 143 int hclge_ptp_get_ts_info(struct hnae3_handle *handle,
+6 -3
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h
··· 527 527 u32 nix_lmt_size; 528 528 529 529 struct otx2_ptp *ptp; 530 - struct hwtstamp_config tstamp; 530 + struct kernel_hwtstamp_config tstamp; 531 531 532 532 unsigned long rq_bmap; 533 533 ··· 1098 1098 int otx2_stop(struct net_device *netdev); 1099 1099 int otx2_set_real_num_queues(struct net_device *netdev, 1100 1100 int tx_queues, int rx_queues); 1101 - int otx2_ioctl(struct net_device *netdev, struct ifreq *req, int cmd); 1102 - int otx2_config_hwtstamp(struct net_device *netdev, struct ifreq *ifr); 1101 + int otx2_config_hwtstamp_get(struct net_device *netdev, 1102 + struct kernel_hwtstamp_config *config); 1103 + int otx2_config_hwtstamp_set(struct net_device *netdev, 1104 + struct kernel_hwtstamp_config *config, 1105 + struct netlink_ext_ack *extack); 1103 1106 1104 1107 /* MCAM filter related APIs */ 1105 1108 int otx2_mcam_flow_init(struct otx2_nic *pf);
+25 -31
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
··· 2445 2445 return 0; 2446 2446 } 2447 2447 2448 - int otx2_config_hwtstamp(struct net_device *netdev, struct ifreq *ifr) 2448 + int otx2_config_hwtstamp_get(struct net_device *netdev, 2449 + struct kernel_hwtstamp_config *config) 2449 2450 { 2450 2451 struct otx2_nic *pfvf = netdev_priv(netdev); 2451 - struct hwtstamp_config config; 2452 + 2453 + *config = pfvf->tstamp; 2454 + return 0; 2455 + } 2456 + EXPORT_SYMBOL(otx2_config_hwtstamp_get); 2457 + 2458 + int otx2_config_hwtstamp_set(struct net_device *netdev, 2459 + struct kernel_hwtstamp_config *config, 2460 + struct netlink_ext_ack *extack) 2461 + { 2462 + struct otx2_nic *pfvf = netdev_priv(netdev); 2452 2463 2453 2464 if (!pfvf->ptp) 2454 2465 return -ENODEV; 2455 2466 2456 - if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) 2457 - return -EFAULT; 2458 - 2459 - switch (config.tx_type) { 2467 + switch (config->tx_type) { 2460 2468 case HWTSTAMP_TX_OFF: 2461 2469 if (pfvf->flags & OTX2_FLAG_PTP_ONESTEP_SYNC) 2462 2470 pfvf->flags &= ~OTX2_FLAG_PTP_ONESTEP_SYNC; ··· 2473 2465 otx2_config_hw_tx_tstamp(pfvf, false); 2474 2466 break; 2475 2467 case HWTSTAMP_TX_ONESTEP_SYNC: 2476 - if (!test_bit(CN10K_PTP_ONESTEP, &pfvf->hw.cap_flag)) 2468 + if (!test_bit(CN10K_PTP_ONESTEP, &pfvf->hw.cap_flag)) { 2469 + NL_SET_ERR_MSG_MOD(extack, 2470 + "One-step time stamping is not supported"); 2477 2471 return -ERANGE; 2472 + } 2478 2473 pfvf->flags |= OTX2_FLAG_PTP_ONESTEP_SYNC; 2479 2474 schedule_delayed_work(&pfvf->ptp->synctstamp_work, 2480 2475 msecs_to_jiffies(500)); ··· 2489 2478 return -ERANGE; 2490 2479 } 2491 2480 2492 - switch (config.rx_filter) { 2481 + switch (config->rx_filter) { 2493 2482 case HWTSTAMP_FILTER_NONE: 2494 2483 otx2_config_hw_rx_tstamp(pfvf, false); 2495 2484 break; ··· 2508 2497 case HWTSTAMP_FILTER_PTP_V2_SYNC: 2509 2498 case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ: 2510 2499 otx2_config_hw_rx_tstamp(pfvf, true); 2511 - config.rx_filter = HWTSTAMP_FILTER_ALL; 2500 + config->rx_filter = HWTSTAMP_FILTER_ALL; 2512 2501 break; 2513 2502 default: 2514 2503 return -ERANGE; 2515 2504 } 2516 2505 2517 - memcpy(&pfvf->tstamp, &config, sizeof(config)); 2506 + pfvf->tstamp = *config; 2518 2507 2519 - return copy_to_user(ifr->ifr_data, &config, 2520 - sizeof(config)) ? -EFAULT : 0; 2508 + return 0; 2521 2509 } 2522 - EXPORT_SYMBOL(otx2_config_hwtstamp); 2523 - 2524 - int otx2_ioctl(struct net_device *netdev, struct ifreq *req, int cmd) 2525 - { 2526 - struct otx2_nic *pfvf = netdev_priv(netdev); 2527 - struct hwtstamp_config *cfg = &pfvf->tstamp; 2528 - 2529 - switch (cmd) { 2530 - case SIOCSHWTSTAMP: 2531 - return otx2_config_hwtstamp(netdev, req); 2532 - case SIOCGHWTSTAMP: 2533 - return copy_to_user(req->ifr_data, cfg, 2534 - sizeof(*cfg)) ? -EFAULT : 0; 2535 - default: 2536 - return -EOPNOTSUPP; 2537 - } 2538 - } 2539 - EXPORT_SYMBOL(otx2_ioctl); 2510 + EXPORT_SYMBOL(otx2_config_hwtstamp_set); 2540 2511 2541 2512 static int otx2_do_set_vf_mac(struct otx2_nic *pf, int vf, const u8 *mac) 2542 2513 { ··· 2935 2942 .ndo_set_features = otx2_set_features, 2936 2943 .ndo_tx_timeout = otx2_tx_timeout, 2937 2944 .ndo_get_stats64 = otx2_get_stats64, 2938 - .ndo_eth_ioctl = otx2_ioctl, 2939 2945 .ndo_set_vf_mac = otx2_set_vf_mac, 2940 2946 .ndo_set_vf_vlan = otx2_set_vf_vlan, 2941 2947 .ndo_get_vf_config = otx2_get_vf_config, ··· 2943 2951 .ndo_xdp_xmit = otx2_xdp_xmit, 2944 2952 .ndo_setup_tc = otx2_setup_tc, 2945 2953 .ndo_set_vf_trust = otx2_ndo_set_vf_trust, 2954 + .ndo_hwtstamp_get = otx2_config_hwtstamp_get, 2955 + .ndo_hwtstamp_set = otx2_config_hwtstamp_set, 2946 2956 }; 2947 2957 2948 2958 int otx2_wq_init(struct otx2_nic *pf)
+2 -1
drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c
··· 534 534 .ndo_set_features = otx2vf_set_features, 535 535 .ndo_get_stats64 = otx2_get_stats64, 536 536 .ndo_tx_timeout = otx2_tx_timeout, 537 - .ndo_eth_ioctl = otx2_ioctl, 538 537 .ndo_setup_tc = otx2_setup_tc, 538 + .ndo_hwtstamp_get = otx2_config_hwtstamp_get, 539 + .ndo_hwtstamp_set = otx2_config_hwtstamp_set, 539 540 }; 540 541 541 542 static int otx2_vf_wq_init(struct otx2_nic *vf)
+26 -36
drivers/net/ethernet/mellanox/mlx4/en_netdev.c
··· 2420 2420 return 0; 2421 2421 } 2422 2422 2423 - static int mlx4_en_hwtstamp_set(struct net_device *dev, struct ifreq *ifr) 2423 + static int mlx4_en_hwtstamp_set(struct net_device *dev, 2424 + struct kernel_hwtstamp_config *config, 2425 + struct netlink_ext_ack *extack) 2424 2426 { 2425 2427 struct mlx4_en_priv *priv = netdev_priv(dev); 2426 2428 struct mlx4_en_dev *mdev = priv->mdev; 2427 - struct hwtstamp_config config; 2428 - 2429 - if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) 2430 - return -EFAULT; 2431 2429 2432 2430 /* device doesn't support time stamping */ 2433 - if (!(mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_TS)) 2431 + if (!(mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_TS)) { 2432 + NL_SET_ERR_MSG_MOD(extack, 2433 + "device doesn't support time stamping"); 2434 2434 return -EINVAL; 2435 + } 2435 2436 2436 2437 /* TX HW timestamp */ 2437 - switch (config.tx_type) { 2438 + switch (config->tx_type) { 2438 2439 case HWTSTAMP_TX_OFF: 2439 2440 case HWTSTAMP_TX_ON: 2440 2441 break; ··· 2444 2443 } 2445 2444 2446 2445 /* RX HW timestamp */ 2447 - switch (config.rx_filter) { 2446 + switch (config->rx_filter) { 2448 2447 case HWTSTAMP_FILTER_NONE: 2449 2448 break; 2450 2449 case HWTSTAMP_FILTER_ALL: ··· 2462 2461 case HWTSTAMP_FILTER_PTP_V2_SYNC: 2463 2462 case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ: 2464 2463 case HWTSTAMP_FILTER_NTP_ALL: 2465 - config.rx_filter = HWTSTAMP_FILTER_ALL; 2464 + config->rx_filter = HWTSTAMP_FILTER_ALL; 2466 2465 break; 2467 2466 default: 2468 2467 return -ERANGE; 2469 2468 } 2470 2469 2471 2470 if (mlx4_en_reset_config(dev, config, dev->features)) { 2472 - config.tx_type = HWTSTAMP_TX_OFF; 2473 - config.rx_filter = HWTSTAMP_FILTER_NONE; 2471 + config->tx_type = HWTSTAMP_TX_OFF; 2472 + config->rx_filter = HWTSTAMP_FILTER_NONE; 2474 2473 } 2475 2474 2476 - return copy_to_user(ifr->ifr_data, &config, 2477 - sizeof(config)) ? -EFAULT : 0; 2475 + return 0; 2478 2476 } 2479 2477 2480 - static int mlx4_en_hwtstamp_get(struct net_device *dev, struct ifreq *ifr) 2478 + static int mlx4_en_hwtstamp_get(struct net_device *dev, 2479 + struct kernel_hwtstamp_config *config) 2481 2480 { 2482 2481 struct mlx4_en_priv *priv = netdev_priv(dev); 2483 2482 2484 - return copy_to_user(ifr->ifr_data, &priv->hwtstamp_config, 2485 - sizeof(priv->hwtstamp_config)) ? -EFAULT : 0; 2486 - } 2487 - 2488 - static int mlx4_en_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) 2489 - { 2490 - switch (cmd) { 2491 - case SIOCSHWTSTAMP: 2492 - return mlx4_en_hwtstamp_set(dev, ifr); 2493 - case SIOCGHWTSTAMP: 2494 - return mlx4_en_hwtstamp_get(dev, ifr); 2495 - default: 2496 - return -EOPNOTSUPP; 2497 - } 2483 + *config = priv->hwtstamp_config; 2484 + return 0; 2498 2485 } 2499 2486 2500 2487 static netdev_features_t mlx4_en_fix_features(struct net_device *netdev, ··· 2549 2560 } 2550 2561 2551 2562 if (reset) { 2552 - ret = mlx4_en_reset_config(netdev, priv->hwtstamp_config, 2563 + ret = mlx4_en_reset_config(netdev, &priv->hwtstamp_config, 2553 2564 features); 2554 2565 if (ret) 2555 2566 return ret; ··· 2833 2844 .ndo_set_mac_address = mlx4_en_set_mac, 2834 2845 .ndo_validate_addr = eth_validate_addr, 2835 2846 .ndo_change_mtu = mlx4_en_change_mtu, 2836 - .ndo_eth_ioctl = mlx4_en_ioctl, 2837 2847 .ndo_tx_timeout = mlx4_en_tx_timeout, 2838 2848 .ndo_vlan_rx_add_vid = mlx4_en_vlan_rx_add_vid, 2839 2849 .ndo_vlan_rx_kill_vid = mlx4_en_vlan_rx_kill_vid, ··· 2846 2858 .ndo_features_check = mlx4_en_features_check, 2847 2859 .ndo_set_tx_maxrate = mlx4_en_set_tx_maxrate, 2848 2860 .ndo_bpf = mlx4_xdp, 2861 + .ndo_hwtstamp_get = mlx4_en_hwtstamp_get, 2862 + .ndo_hwtstamp_set = mlx4_en_hwtstamp_set, 2849 2863 }; 2850 2864 2851 2865 static const struct net_device_ops mlx4_netdev_ops_master = { ··· 3502 3512 } 3503 3513 3504 3514 int mlx4_en_reset_config(struct net_device *dev, 3505 - struct hwtstamp_config ts_config, 3515 + struct kernel_hwtstamp_config *ts_config, 3506 3516 netdev_features_t features) 3507 3517 { 3508 3518 struct mlx4_en_priv *priv = netdev_priv(dev); ··· 3512 3522 int port_up = 0; 3513 3523 int err = 0; 3514 3524 3515 - if (priv->hwtstamp_config.tx_type == ts_config.tx_type && 3516 - priv->hwtstamp_config.rx_filter == ts_config.rx_filter && 3525 + if (priv->hwtstamp_config.tx_type == ts_config->tx_type && 3526 + priv->hwtstamp_config.rx_filter == ts_config->rx_filter && 3517 3527 !DEV_FEATURE_CHANGED(dev, features, NETIF_F_HW_VLAN_CTAG_RX) && 3518 3528 !DEV_FEATURE_CHANGED(dev, features, NETIF_F_RXFCS)) 3519 3529 return 0; /* Nothing to change */ ··· 3532 3542 mutex_lock(&mdev->state_lock); 3533 3543 3534 3544 memcpy(&new_prof, priv->prof, sizeof(struct mlx4_en_port_profile)); 3535 - memcpy(&new_prof.hwtstamp_config, &ts_config, sizeof(ts_config)); 3545 + memcpy(&new_prof.hwtstamp_config, ts_config, sizeof(*ts_config)); 3536 3546 3537 3547 err = mlx4_en_try_alloc_resources(priv, tmp, &new_prof, true); 3538 3548 if (err) ··· 3550 3560 dev->features |= NETIF_F_HW_VLAN_CTAG_RX; 3551 3561 else 3552 3562 dev->features &= ~NETIF_F_HW_VLAN_CTAG_RX; 3553 - } else if (ts_config.rx_filter == HWTSTAMP_FILTER_NONE) { 3563 + } else if (ts_config->rx_filter == HWTSTAMP_FILTER_NONE) { 3554 3564 /* RX time-stamping is OFF, update the RX vlan offload 3555 3565 * to the latest wanted state 3556 3566 */ ··· 3571 3581 * Regardless of the caller's choice, 3572 3582 * Turn Off RX vlan offload in case of time-stamping is ON 3573 3583 */ 3574 - if (ts_config.rx_filter != HWTSTAMP_FILTER_NONE) { 3584 + if (ts_config->rx_filter != HWTSTAMP_FILTER_NONE) { 3575 3585 if (dev->features & NETIF_F_HW_VLAN_CTAG_RX) 3576 3586 en_warn(priv, "Turning off RX vlan offload since RX time-stamping is ON\n"); 3577 3587 dev->features &= ~NETIF_F_HW_VLAN_CTAG_RX;
+3 -3
drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
··· 388 388 u8 num_up; 389 389 int rss_rings; 390 390 int inline_thold; 391 - struct hwtstamp_config hwtstamp_config; 391 + struct kernel_hwtstamp_config hwtstamp_config; 392 392 }; 393 393 394 394 struct mlx4_en_profile { ··· 612 612 bool wol; 613 613 struct device *ddev; 614 614 struct hlist_head mac_hash[MLX4_EN_MAC_HASH_SIZE]; 615 - struct hwtstamp_config hwtstamp_config; 615 + struct kernel_hwtstamp_config hwtstamp_config; 616 616 u32 counter_index; 617 617 618 618 #ifdef CONFIG_MLX4_EN_DCB ··· 780 780 781 781 int mlx4_en_moderation_update(struct mlx4_en_priv *priv); 782 782 int mlx4_en_reset_config(struct net_device *dev, 783 - struct hwtstamp_config ts_config, 783 + struct kernel_hwtstamp_config *ts_config, 784 784 netdev_features_t new_features); 785 785 void mlx4_en_update_pfc_stats_bitmap(struct mlx4_dev *dev, 786 786 struct mlx4_en_stats_bitmap *stats_bitmap,
+2 -15
drivers/net/ethernet/pensando/ionic/ionic_lif.c
··· 2335 2335 return 0; 2336 2336 } 2337 2337 2338 - static int ionic_eth_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) 2339 - { 2340 - struct ionic_lif *lif = netdev_priv(netdev); 2341 - 2342 - switch (cmd) { 2343 - case SIOCSHWTSTAMP: 2344 - return ionic_lif_hwstamp_set(lif, ifr); 2345 - case SIOCGHWTSTAMP: 2346 - return ionic_lif_hwstamp_get(lif, ifr); 2347 - default: 2348 - return -EOPNOTSUPP; 2349 - } 2350 - } 2351 - 2352 2338 static int ionic_get_vf_config(struct net_device *netdev, 2353 2339 int vf, struct ifla_vf_info *ivf) 2354 2340 { ··· 2798 2812 static const struct net_device_ops ionic_netdev_ops = { 2799 2813 .ndo_open = ionic_open, 2800 2814 .ndo_stop = ionic_stop, 2801 - .ndo_eth_ioctl = ionic_eth_ioctl, 2802 2815 .ndo_start_xmit = ionic_start_xmit, 2803 2816 .ndo_bpf = ionic_xdp, 2804 2817 .ndo_xdp_xmit = ionic_xdp_xmit, ··· 2818 2833 .ndo_get_vf_config = ionic_get_vf_config, 2819 2834 .ndo_set_vf_link_state = ionic_set_vf_link_state, 2820 2835 .ndo_get_vf_stats = ionic_get_vf_stats, 2836 + .ndo_hwtstamp_get = ionic_hwstamp_get, 2837 + .ndo_hwtstamp_set = ionic_hwstamp_set, 2821 2838 }; 2822 2839 2823 2840 static int ionic_cmb_reconfig(struct ionic_lif *lif,
+12 -6
drivers/net/ethernet/pensando/ionic/ionic_lif.h
··· 6 6 7 7 #include <linux/ptp_clock_kernel.h> 8 8 #include <linux/timecounter.h> 9 - #include <uapi/linux/net_tstamp.h> 9 + #include <linux/net_tstamp.h> 10 10 #include <linux/dim.h> 11 11 #include <linux/pci.h> 12 12 #include "ionic_rx_filter.h" ··· 254 254 struct timecounter tc; 255 255 256 256 struct mutex config_lock; /* lock for ts_config */ 257 - struct hwtstamp_config ts_config; 257 + struct kernel_hwtstamp_config ts_config; 258 258 u64 ts_config_rx_filt; 259 259 u32 ts_config_tx_mode; 260 260 ··· 362 362 #if IS_ENABLED(CONFIG_PTP_1588_CLOCK) 363 363 void ionic_lif_hwstamp_replay(struct ionic_lif *lif); 364 364 void ionic_lif_hwstamp_recreate_queues(struct ionic_lif *lif); 365 - int ionic_lif_hwstamp_set(struct ionic_lif *lif, struct ifreq *ifr); 366 - int ionic_lif_hwstamp_get(struct ionic_lif *lif, struct ifreq *ifr); 365 + int ionic_hwstamp_set(struct net_device *netdev, 366 + struct kernel_hwtstamp_config *config, 367 + struct netlink_ext_ack *extack); 368 + int ionic_hwstamp_get(struct net_device *netdev, 369 + struct kernel_hwtstamp_config *config); 367 370 ktime_t ionic_lif_phc_ktime(struct ionic_lif *lif, u64 counter); 368 371 void ionic_lif_register_phc(struct ionic_lif *lif); 369 372 void ionic_lif_unregister_phc(struct ionic_lif *lif); ··· 376 373 static inline void ionic_lif_hwstamp_replay(struct ionic_lif *lif) {} 377 374 static inline void ionic_lif_hwstamp_recreate_queues(struct ionic_lif *lif) {} 378 375 379 - static inline int ionic_lif_hwstamp_set(struct ionic_lif *lif, struct ifreq *ifr) 376 + static inline int ionic_hwstamp_set(struct net_device *netdev, 377 + struct kernel_hwtstamp_config *config, 378 + struct netlink_ext_ack *extack) 380 379 { 381 380 return -EOPNOTSUPP; 382 381 } 383 382 384 - static inline int ionic_lif_hwstamp_get(struct ionic_lif *lif, struct ifreq *ifr) 383 + static inline int ionic_hwstamp_get(struct net_device *netdev, 384 + struct kernel_hwtstamp_config *config) 385 385 { 386 386 return -EOPNOTSUPP; 387 387 }
+38 -23
drivers/net/ethernet/pensando/ionic/ionic_phc.c
··· 65 65 } 66 66 67 67 static int ionic_lif_hwstamp_set_ts_config(struct ionic_lif *lif, 68 - struct hwtstamp_config *new_ts) 68 + struct kernel_hwtstamp_config *new_ts, 69 + struct netlink_ext_ack *extack) 69 70 { 71 + struct kernel_hwtstamp_config *config; 72 + struct kernel_hwtstamp_config ts = {}; 70 73 struct ionic *ionic = lif->ionic; 71 - struct hwtstamp_config *config; 72 - struct hwtstamp_config ts; 73 74 int tx_mode = 0; 74 75 u64 rx_filt = 0; 75 76 int err, err2; ··· 100 99 101 100 tx_mode = ionic_hwstamp_tx_mode(config->tx_type); 102 101 if (tx_mode < 0) { 102 + NL_SET_ERR_MSG_MOD(extack, 103 + "TX time stamping mode isn't supported"); 103 104 err = tx_mode; 104 105 goto err_queues; 105 106 } 106 107 107 108 mask = cpu_to_le64(BIT_ULL(tx_mode)); 108 109 if ((ionic->ident.lif.eth.hwstamp_tx_modes & mask) != mask) { 110 + NL_SET_ERR_MSG_MOD(extack, 111 + "TX time stamping mode isn't supported"); 109 112 err = -ERANGE; 110 113 goto err_queues; 111 114 } ··· 129 124 130 125 if (tx_mode) { 131 126 err = ionic_lif_create_hwstamp_txq(lif); 132 - if (err) 127 + if (err) { 128 + NL_SET_ERR_MSG_MOD(extack, 129 + "Error creating TX timestamp queue"); 133 130 goto err_queues; 131 + } 134 132 } 135 133 136 134 if (rx_filt) { 137 135 err = ionic_lif_create_hwstamp_rxq(lif); 138 - if (err) 136 + if (err) { 137 + NL_SET_ERR_MSG_MOD(extack, 138 + "Error creating RX timestamp queue"); 139 139 goto err_queues; 140 + } 140 141 } 141 142 142 143 if (tx_mode != lif->phc->ts_config_tx_mode) { 143 144 err = ionic_lif_set_hwstamp_txmode(lif, tx_mode); 144 - if (err) 145 + if (err) { 146 + NL_SET_ERR_MSG_MOD(extack, 147 + "Error enabling TX timestamp mode"); 145 148 goto err_txmode; 149 + } 146 150 } 147 151 148 152 if (rx_filt != lif->phc->ts_config_rx_filt) { 149 153 err = ionic_lif_set_hwstamp_rxfilt(lif, rx_filt); 150 - if (err) 154 + if (err) { 155 + NL_SET_ERR_MSG_MOD(extack, 156 + "Error enabling RX timestamp mode"); 151 157 goto err_rxfilt; 158 + } 152 159 } 153 160 154 161 if (rx_all != (lif->phc->ts_config.rx_filter == HWTSTAMP_FILTER_ALL)) { 155 162 err = ionic_lif_config_hwstamp_rxq_all(lif, rx_all); 156 - if (err) 163 + if (err) { 164 + NL_SET_ERR_MSG_MOD(extack, 165 + "Error enabling RX timestamp mode"); 157 166 goto err_rxall; 167 + } 158 168 } 159 169 160 170 memcpy(&lif->phc->ts_config, config, sizeof(*config)); ··· 203 183 return err; 204 184 } 205 185 206 - int ionic_lif_hwstamp_set(struct ionic_lif *lif, struct ifreq *ifr) 186 + int ionic_hwstamp_set(struct net_device *netdev, 187 + struct kernel_hwtstamp_config *config, 188 + struct netlink_ext_ack *extack) 207 189 { 208 - struct hwtstamp_config config; 190 + struct ionic_lif *lif = netdev_priv(netdev); 209 191 int err; 210 192 211 193 if (!lif->phc || !lif->phc->ptp) 212 194 return -EOPNOTSUPP; 213 195 214 - if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) 215 - return -EFAULT; 216 - 217 196 mutex_lock(&lif->queue_lock); 218 - err = ionic_lif_hwstamp_set_ts_config(lif, &config); 197 + err = ionic_lif_hwstamp_set_ts_config(lif, config, extack); 219 198 mutex_unlock(&lif->queue_lock); 220 199 if (err) { 221 200 netdev_info(lif->netdev, "hwstamp set failed: %d\n", err); 222 201 return err; 223 202 } 224 - 225 - if (copy_to_user(ifr->ifr_data, &config, sizeof(config))) 226 - return -EFAULT; 227 203 228 204 return 0; 229 205 } ··· 232 216 return; 233 217 234 218 mutex_lock(&lif->queue_lock); 235 - err = ionic_lif_hwstamp_set_ts_config(lif, NULL); 219 + err = ionic_lif_hwstamp_set_ts_config(lif, NULL, NULL); 236 220 mutex_unlock(&lif->queue_lock); 237 221 if (err) 238 222 netdev_info(lif->netdev, "hwstamp replay failed: %d\n", err); ··· 262 246 mutex_unlock(&lif->phc->config_lock); 263 247 } 264 248 265 - int ionic_lif_hwstamp_get(struct ionic_lif *lif, struct ifreq *ifr) 249 + int ionic_hwstamp_get(struct net_device *netdev, 250 + struct kernel_hwtstamp_config *config) 266 251 { 267 - struct hwtstamp_config config; 252 + struct ionic_lif *lif = netdev_priv(netdev); 268 253 269 254 if (!lif->phc || !lif->phc->ptp) 270 255 return -EOPNOTSUPP; 271 256 272 257 mutex_lock(&lif->phc->config_lock); 273 - memcpy(&config, &lif->phc->ts_config, sizeof(config)); 258 + memcpy(config, &lif->phc->ts_config, sizeof(*config)); 274 259 mutex_unlock(&lif->phc->config_lock); 275 260 276 - if (copy_to_user(ifr->ifr_data, &config, sizeof(config))) 277 - return -EFAULT; 278 261 return 0; 279 262 } 280 263
+19 -42
drivers/net/ethernet/renesas/ravb_main.c
··· 2410 2410 return 0; 2411 2411 } 2412 2412 2413 - static int ravb_hwtstamp_get(struct net_device *ndev, struct ifreq *req) 2413 + static int ravb_hwtstamp_get(struct net_device *ndev, 2414 + struct kernel_hwtstamp_config *config) 2414 2415 { 2415 2416 struct ravb_private *priv = netdev_priv(ndev); 2416 - struct hwtstamp_config config; 2417 2417 2418 - config.flags = 0; 2419 - config.tx_type = priv->tstamp_tx_ctrl ? HWTSTAMP_TX_ON : 2420 - HWTSTAMP_TX_OFF; 2418 + config->flags = 0; 2419 + config->tx_type = priv->tstamp_tx_ctrl ? HWTSTAMP_TX_ON : 2420 + HWTSTAMP_TX_OFF; 2421 2421 switch (priv->tstamp_rx_ctrl & RAVB_RXTSTAMP_TYPE) { 2422 2422 case RAVB_RXTSTAMP_TYPE_V2_L2_EVENT: 2423 - config.rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_EVENT; 2423 + config->rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_EVENT; 2424 2424 break; 2425 2425 case RAVB_RXTSTAMP_TYPE_ALL: 2426 - config.rx_filter = HWTSTAMP_FILTER_ALL; 2426 + config->rx_filter = HWTSTAMP_FILTER_ALL; 2427 2427 break; 2428 2428 default: 2429 - config.rx_filter = HWTSTAMP_FILTER_NONE; 2429 + config->rx_filter = HWTSTAMP_FILTER_NONE; 2430 2430 } 2431 2431 2432 - return copy_to_user(req->ifr_data, &config, sizeof(config)) ? 2433 - -EFAULT : 0; 2432 + return 0; 2434 2433 } 2435 2434 2436 2435 /* Control hardware time stamping */ 2437 - static int ravb_hwtstamp_set(struct net_device *ndev, struct ifreq *req) 2436 + static int ravb_hwtstamp_set(struct net_device *ndev, 2437 + struct kernel_hwtstamp_config *config, 2438 + struct netlink_ext_ack *extack) 2438 2439 { 2439 2440 struct ravb_private *priv = netdev_priv(ndev); 2440 - struct hwtstamp_config config; 2441 2441 u32 tstamp_rx_ctrl = RAVB_RXTSTAMP_ENABLED; 2442 2442 u32 tstamp_tx_ctrl; 2443 2443 2444 - if (copy_from_user(&config, req->ifr_data, sizeof(config))) 2445 - return -EFAULT; 2446 - 2447 - switch (config.tx_type) { 2444 + switch (config->tx_type) { 2448 2445 case HWTSTAMP_TX_OFF: 2449 2446 tstamp_tx_ctrl = 0; 2450 2447 break; ··· 2452 2455 return -ERANGE; 2453 2456 } 2454 2457 2455 - switch (config.rx_filter) { 2458 + switch (config->rx_filter) { 2456 2459 case HWTSTAMP_FILTER_NONE: 2457 2460 tstamp_rx_ctrl = 0; 2458 2461 break; ··· 2460 2463 tstamp_rx_ctrl |= RAVB_RXTSTAMP_TYPE_V2_L2_EVENT; 2461 2464 break; 2462 2465 default: 2463 - config.rx_filter = HWTSTAMP_FILTER_ALL; 2466 + config->rx_filter = HWTSTAMP_FILTER_ALL; 2464 2467 tstamp_rx_ctrl |= RAVB_RXTSTAMP_TYPE_ALL; 2465 2468 } 2466 2469 2467 2470 priv->tstamp_tx_ctrl = tstamp_tx_ctrl; 2468 2471 priv->tstamp_rx_ctrl = tstamp_rx_ctrl; 2469 2472 2470 - return copy_to_user(req->ifr_data, &config, sizeof(config)) ? 2471 - -EFAULT : 0; 2472 - } 2473 - 2474 - /* ioctl to device function */ 2475 - static int ravb_do_ioctl(struct net_device *ndev, struct ifreq *req, int cmd) 2476 - { 2477 - struct phy_device *phydev = ndev->phydev; 2478 - 2479 - if (!netif_running(ndev)) 2480 - return -EINVAL; 2481 - 2482 - if (!phydev) 2483 - return -ENODEV; 2484 - 2485 - switch (cmd) { 2486 - case SIOCGHWTSTAMP: 2487 - return ravb_hwtstamp_get(ndev, req); 2488 - case SIOCSHWTSTAMP: 2489 - return ravb_hwtstamp_set(ndev, req); 2490 - } 2491 - 2492 - return phy_mii_ioctl(phydev, req, cmd); 2473 + return 0; 2493 2474 } 2494 2475 2495 2476 static int ravb_change_mtu(struct net_device *ndev, int new_mtu) ··· 2603 2628 .ndo_get_stats = ravb_get_stats, 2604 2629 .ndo_set_rx_mode = ravb_set_rx_mode, 2605 2630 .ndo_tx_timeout = ravb_tx_timeout, 2606 - .ndo_eth_ioctl = ravb_do_ioctl, 2631 + .ndo_eth_ioctl = phy_do_ioctl_running, 2607 2632 .ndo_change_mtu = ravb_change_mtu, 2608 2633 .ndo_validate_addr = eth_validate_addr, 2609 2634 .ndo_set_mac_address = eth_mac_addr, 2610 2635 .ndo_set_features = ravb_set_features, 2636 + .ndo_hwtstamp_get = ravb_hwtstamp_get, 2637 + .ndo_hwtstamp_set = ravb_hwtstamp_set, 2611 2638 }; 2612 2639 2613 2640 /* MDIO bus init function */
+19 -34
drivers/net/ethernet/renesas/rswitch_main.c
··· 1793 1793 return &ndev->stats; 1794 1794 } 1795 1795 1796 - static int rswitch_hwstamp_get(struct net_device *ndev, struct ifreq *req) 1796 + static int rswitch_hwstamp_get(struct net_device *ndev, 1797 + struct kernel_hwtstamp_config *config) 1797 1798 { 1798 1799 struct rswitch_device *rdev = netdev_priv(ndev); 1799 1800 struct rcar_gen4_ptp_private *ptp_priv; 1800 - struct hwtstamp_config config; 1801 1801 1802 1802 ptp_priv = rdev->priv->ptp_priv; 1803 1803 1804 - config.flags = 0; 1805 - config.tx_type = ptp_priv->tstamp_tx_ctrl ? HWTSTAMP_TX_ON : 1804 + config->flags = 0; 1805 + config->tx_type = ptp_priv->tstamp_tx_ctrl ? HWTSTAMP_TX_ON : 1806 1806 HWTSTAMP_TX_OFF; 1807 1807 switch (ptp_priv->tstamp_rx_ctrl & RCAR_GEN4_RXTSTAMP_TYPE) { 1808 1808 case RCAR_GEN4_RXTSTAMP_TYPE_V2_L2_EVENT: 1809 - config.rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_EVENT; 1809 + config->rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_EVENT; 1810 1810 break; 1811 1811 case RCAR_GEN4_RXTSTAMP_TYPE_ALL: 1812 - config.rx_filter = HWTSTAMP_FILTER_ALL; 1812 + config->rx_filter = HWTSTAMP_FILTER_ALL; 1813 1813 break; 1814 1814 default: 1815 - config.rx_filter = HWTSTAMP_FILTER_NONE; 1815 + config->rx_filter = HWTSTAMP_FILTER_NONE; 1816 1816 break; 1817 1817 } 1818 1818 1819 - return copy_to_user(req->ifr_data, &config, sizeof(config)) ? -EFAULT : 0; 1819 + return 0; 1820 1820 } 1821 1821 1822 - static int rswitch_hwstamp_set(struct net_device *ndev, struct ifreq *req) 1822 + static int rswitch_hwstamp_set(struct net_device *ndev, 1823 + struct kernel_hwtstamp_config *config, 1824 + struct netlink_ext_ack *extack) 1823 1825 { 1824 1826 struct rswitch_device *rdev = netdev_priv(ndev); 1825 1827 u32 tstamp_rx_ctrl = RCAR_GEN4_RXTSTAMP_ENABLED; 1826 - struct hwtstamp_config config; 1827 1828 u32 tstamp_tx_ctrl; 1828 1829 1829 - if (copy_from_user(&config, req->ifr_data, sizeof(config))) 1830 - return -EFAULT; 1831 - 1832 - if (config.flags) 1830 + if (config->flags) 1833 1831 return -EINVAL; 1834 1832 1835 - switch (config.tx_type) { 1833 + switch (config->tx_type) { 1836 1834 case HWTSTAMP_TX_OFF: 1837 1835 tstamp_tx_ctrl = 0; 1838 1836 break; ··· 1841 1843 return -ERANGE; 1842 1844 } 1843 1845 1844 - switch (config.rx_filter) { 1846 + switch (config->rx_filter) { 1845 1847 case HWTSTAMP_FILTER_NONE: 1846 1848 tstamp_rx_ctrl = 0; 1847 1849 break; ··· 1849 1851 tstamp_rx_ctrl |= RCAR_GEN4_RXTSTAMP_TYPE_V2_L2_EVENT; 1850 1852 break; 1851 1853 default: 1852 - config.rx_filter = HWTSTAMP_FILTER_ALL; 1854 + config->rx_filter = HWTSTAMP_FILTER_ALL; 1853 1855 tstamp_rx_ctrl |= RCAR_GEN4_RXTSTAMP_TYPE_ALL; 1854 1856 break; 1855 1857 } ··· 1857 1859 rdev->priv->ptp_priv->tstamp_tx_ctrl = tstamp_tx_ctrl; 1858 1860 rdev->priv->ptp_priv->tstamp_rx_ctrl = tstamp_rx_ctrl; 1859 1861 1860 - return copy_to_user(req->ifr_data, &config, sizeof(config)) ? -EFAULT : 0; 1861 - } 1862 - 1863 - static int rswitch_eth_ioctl(struct net_device *ndev, struct ifreq *req, int cmd) 1864 - { 1865 - if (!netif_running(ndev)) 1866 - return -EINVAL; 1867 - 1868 - switch (cmd) { 1869 - case SIOCGHWTSTAMP: 1870 - return rswitch_hwstamp_get(ndev, req); 1871 - case SIOCSHWTSTAMP: 1872 - return rswitch_hwstamp_set(ndev, req); 1873 - default: 1874 - return phy_mii_ioctl(ndev->phydev, req, cmd); 1875 - } 1862 + return 0; 1876 1863 } 1877 1864 1878 1865 static int rswitch_get_port_parent_id(struct net_device *ndev, ··· 1888 1905 .ndo_stop = rswitch_stop, 1889 1906 .ndo_start_xmit = rswitch_start_xmit, 1890 1907 .ndo_get_stats = rswitch_get_stats, 1891 - .ndo_eth_ioctl = rswitch_eth_ioctl, 1908 + .ndo_eth_ioctl = phy_do_ioctl_running, 1892 1909 .ndo_get_port_parent_id = rswitch_get_port_parent_id, 1893 1910 .ndo_get_phys_port_name = rswitch_get_phys_port_name, 1894 1911 .ndo_validate_addr = eth_validate_addr, 1895 1912 .ndo_set_mac_address = eth_mac_addr, 1913 + .ndo_hwtstamp_get = rswitch_hwstamp_get, 1914 + .ndo_hwtstamp_set = rswitch_hwstamp_set, 1896 1915 }; 1897 1916 1898 1917 bool is_rdev(const struct net_device *ndev)