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

net: macb: Convert to ndo_hwtstamp_get() and ndo_hwtstamp_set()

The hardware timestamping through ndo_eth_ioctl() is going away.
Convert the macb driver to the new API before that can be removed.

Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Kory Maincent and committed by
David S. Miller
202cb220 b8768dc4

+53 -32
+10 -5
drivers/net/ethernet/cadence/macb.h
··· 1165 1165 int (*get_ts_info)(struct net_device *dev, 1166 1166 struct ethtool_ts_info *info); 1167 1167 int (*get_hwtst)(struct net_device *netdev, 1168 - struct ifreq *ifr); 1168 + struct kernel_hwtstamp_config *tstamp_config); 1169 1169 int (*set_hwtst)(struct net_device *netdev, 1170 - struct ifreq *ifr, int cmd); 1170 + struct kernel_hwtstamp_config *tstamp_config, 1171 + struct netlink_ext_ack *extack); 1171 1172 }; 1172 1173 1173 1174 struct macb_pm_data { ··· 1315 1314 struct ptp_clock *ptp_clock; 1316 1315 struct ptp_clock_info ptp_clock_info; 1317 1316 struct tsu_incr tsu_incr; 1318 - struct hwtstamp_config tstamp_config; 1317 + struct kernel_hwtstamp_config tstamp_config; 1319 1318 1320 1319 /* RX queue filer rule set*/ 1321 1320 struct ethtool_rx_fs_list rx_fs_list; ··· 1364 1363 1365 1364 gem_ptp_rxstamp(bp, skb, desc); 1366 1365 } 1367 - int gem_get_hwtst(struct net_device *dev, struct ifreq *rq); 1368 - int gem_set_hwtst(struct net_device *dev, struct ifreq *ifr, int cmd); 1366 + 1367 + int gem_get_hwtst(struct net_device *dev, 1368 + struct kernel_hwtstamp_config *tstamp_config); 1369 + int gem_set_hwtst(struct net_device *dev, 1370 + struct kernel_hwtstamp_config *tstamp_config, 1371 + struct netlink_ext_ack *extack); 1369 1372 #else 1370 1373 static inline void gem_ptp_init(struct net_device *ndev) { } 1371 1374 static inline void gem_ptp_remove(struct net_device *ndev) { }
+33 -9
drivers/net/ethernet/cadence/macb_main.c
··· 3773 3773 if (!netif_running(dev)) 3774 3774 return -EINVAL; 3775 3775 3776 - if (bp->ptp_info) { 3777 - switch (cmd) { 3778 - case SIOCSHWTSTAMP: 3779 - return bp->ptp_info->set_hwtst(dev, rq, cmd); 3780 - case SIOCGHWTSTAMP: 3781 - return bp->ptp_info->get_hwtst(dev, rq); 3782 - } 3783 - } 3784 - 3785 3776 return phylink_mii_ioctl(bp->phylink, rq, cmd); 3777 + } 3778 + 3779 + static int macb_hwtstamp_get(struct net_device *dev, 3780 + struct kernel_hwtstamp_config *cfg) 3781 + { 3782 + struct macb *bp = netdev_priv(dev); 3783 + 3784 + if (!netif_running(dev)) 3785 + return -EINVAL; 3786 + 3787 + if (!bp->ptp_info) 3788 + return -EOPNOTSUPP; 3789 + 3790 + return bp->ptp_info->get_hwtst(dev, cfg); 3791 + } 3792 + 3793 + static int macb_hwtstamp_set(struct net_device *dev, 3794 + struct kernel_hwtstamp_config *cfg, 3795 + struct netlink_ext_ack *extack) 3796 + { 3797 + struct macb *bp = netdev_priv(dev); 3798 + 3799 + if (!netif_running(dev)) 3800 + return -EINVAL; 3801 + 3802 + if (!bp->ptp_info) 3803 + return -EOPNOTSUPP; 3804 + 3805 + return bp->ptp_info->set_hwtst(dev, cfg, extack); 3786 3806 } 3787 3807 3788 3808 static inline void macb_set_txcsum_feature(struct macb *bp, ··· 3904 3884 #endif 3905 3885 .ndo_set_features = macb_set_features, 3906 3886 .ndo_features_check = macb_features_check, 3887 + .ndo_hwtstamp_set = macb_hwtstamp_set, 3888 + .ndo_hwtstamp_get = macb_hwtstamp_get, 3907 3889 }; 3908 3890 3909 3891 /* Configure peripheral capabilities according to device tree ··· 4561 4539 #ifdef CONFIG_NET_POLL_CONTROLLER 4562 4540 .ndo_poll_controller = at91ether_poll_controller, 4563 4541 #endif 4542 + .ndo_hwtstamp_set = macb_hwtstamp_set, 4543 + .ndo_hwtstamp_get = macb_hwtstamp_get, 4564 4544 }; 4565 4545 4566 4546 static int at91ether_clk_init(struct platform_device *pdev, struct clk **pclk,
+10 -18
drivers/net/ethernet/cadence/macb_ptp.c
··· 374 374 return 0; 375 375 } 376 376 377 - int gem_get_hwtst(struct net_device *dev, struct ifreq *rq) 377 + int gem_get_hwtst(struct net_device *dev, 378 + struct kernel_hwtstamp_config *tstamp_config) 378 379 { 379 - struct hwtstamp_config *tstamp_config; 380 380 struct macb *bp = netdev_priv(dev); 381 381 382 - tstamp_config = &bp->tstamp_config; 382 + *tstamp_config = bp->tstamp_config; 383 383 if ((bp->hw_dma_cap & HW_DMA_CAP_PTP) == 0) 384 384 return -EOPNOTSUPP; 385 385 386 - if (copy_to_user(rq->ifr_data, tstamp_config, sizeof(*tstamp_config))) 387 - return -EFAULT; 388 - else 389 - return 0; 386 + return 0; 390 387 } 391 388 392 389 static void gem_ptp_set_one_step_sync(struct macb *bp, u8 enable) ··· 398 401 macb_writel(bp, NCR, reg_val & ~MACB_BIT(OSSMODE)); 399 402 } 400 403 401 - int gem_set_hwtst(struct net_device *dev, struct ifreq *ifr, int cmd) 404 + int gem_set_hwtst(struct net_device *dev, 405 + struct kernel_hwtstamp_config *tstamp_config, 406 + struct netlink_ext_ack *extack) 402 407 { 403 408 enum macb_bd_control tx_bd_control = TSTAMP_DISABLED; 404 409 enum macb_bd_control rx_bd_control = TSTAMP_DISABLED; 405 - struct hwtstamp_config *tstamp_config; 406 410 struct macb *bp = netdev_priv(dev); 407 411 u32 regval; 408 412 409 - tstamp_config = &bp->tstamp_config; 410 413 if ((bp->hw_dma_cap & HW_DMA_CAP_PTP) == 0) 411 414 return -EOPNOTSUPP; 412 - 413 - if (copy_from_user(tstamp_config, ifr->ifr_data, 414 - sizeof(*tstamp_config))) 415 - return -EFAULT; 416 415 417 416 switch (tstamp_config->tx_type) { 418 417 case HWTSTAMP_TX_OFF: ··· 456 463 return -ERANGE; 457 464 } 458 465 466 + bp->tstamp_config = *tstamp_config; 467 + 459 468 if (gem_ptp_set_ts_mode(bp, tx_bd_control, rx_bd_control) != 0) 460 469 return -ERANGE; 461 470 462 - if (copy_to_user(ifr->ifr_data, tstamp_config, sizeof(*tstamp_config))) 463 - return -EFAULT; 464 - else 465 - return 0; 471 + return 0; 466 472 } 467 473