Commit 202cb220 authored by Kory Maincent's avatar Kory Maincent Committed by David S. Miller

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: default avatarKory Maincent <kory.maincent@bootlin.com>
Reviewed-by: default avatarFlorian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b8768dc4
...@@ -1165,9 +1165,10 @@ struct macb_ptp_info { ...@@ -1165,9 +1165,10 @@ struct macb_ptp_info {
int (*get_ts_info)(struct net_device *dev, int (*get_ts_info)(struct net_device *dev,
struct ethtool_ts_info *info); struct ethtool_ts_info *info);
int (*get_hwtst)(struct net_device *netdev, int (*get_hwtst)(struct net_device *netdev,
struct ifreq *ifr); struct kernel_hwtstamp_config *tstamp_config);
int (*set_hwtst)(struct net_device *netdev, int (*set_hwtst)(struct net_device *netdev,
struct ifreq *ifr, int cmd); struct kernel_hwtstamp_config *tstamp_config,
struct netlink_ext_ack *extack);
}; };
struct macb_pm_data { struct macb_pm_data {
...@@ -1314,7 +1315,7 @@ struct macb { ...@@ -1314,7 +1315,7 @@ struct macb {
struct ptp_clock *ptp_clock; struct ptp_clock *ptp_clock;
struct ptp_clock_info ptp_clock_info; struct ptp_clock_info ptp_clock_info;
struct tsu_incr tsu_incr; struct tsu_incr tsu_incr;
struct hwtstamp_config tstamp_config; struct kernel_hwtstamp_config tstamp_config;
/* RX queue filer rule set*/ /* RX queue filer rule set*/
struct ethtool_rx_fs_list rx_fs_list; struct ethtool_rx_fs_list rx_fs_list;
...@@ -1363,8 +1364,12 @@ static inline void gem_ptp_do_rxstamp(struct macb *bp, struct sk_buff *skb, stru ...@@ -1363,8 +1364,12 @@ static inline void gem_ptp_do_rxstamp(struct macb *bp, struct sk_buff *skb, stru
gem_ptp_rxstamp(bp, skb, desc); gem_ptp_rxstamp(bp, skb, desc);
} }
int gem_get_hwtst(struct net_device *dev, struct ifreq *rq);
int gem_set_hwtst(struct net_device *dev, struct ifreq *ifr, int cmd); int gem_get_hwtst(struct net_device *dev,
struct kernel_hwtstamp_config *tstamp_config);
int gem_set_hwtst(struct net_device *dev,
struct kernel_hwtstamp_config *tstamp_config,
struct netlink_ext_ack *extack);
#else #else
static inline void gem_ptp_init(struct net_device *ndev) { } static inline void gem_ptp_init(struct net_device *ndev) { }
static inline void gem_ptp_remove(struct net_device *ndev) { } static inline void gem_ptp_remove(struct net_device *ndev) { }
......
...@@ -3773,18 +3773,38 @@ static int macb_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) ...@@ -3773,18 +3773,38 @@ static int macb_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
if (!netif_running(dev)) if (!netif_running(dev))
return -EINVAL; return -EINVAL;
if (bp->ptp_info) {
switch (cmd) {
case SIOCSHWTSTAMP:
return bp->ptp_info->set_hwtst(dev, rq, cmd);
case SIOCGHWTSTAMP:
return bp->ptp_info->get_hwtst(dev, rq);
}
}
return phylink_mii_ioctl(bp->phylink, rq, cmd); return phylink_mii_ioctl(bp->phylink, rq, cmd);
} }
static int macb_hwtstamp_get(struct net_device *dev,
struct kernel_hwtstamp_config *cfg)
{
struct macb *bp = netdev_priv(dev);
if (!netif_running(dev))
return -EINVAL;
if (!bp->ptp_info)
return -EOPNOTSUPP;
return bp->ptp_info->get_hwtst(dev, cfg);
}
static int macb_hwtstamp_set(struct net_device *dev,
struct kernel_hwtstamp_config *cfg,
struct netlink_ext_ack *extack)
{
struct macb *bp = netdev_priv(dev);
if (!netif_running(dev))
return -EINVAL;
if (!bp->ptp_info)
return -EOPNOTSUPP;
return bp->ptp_info->set_hwtst(dev, cfg, extack);
}
static inline void macb_set_txcsum_feature(struct macb *bp, static inline void macb_set_txcsum_feature(struct macb *bp,
netdev_features_t features) netdev_features_t features)
{ {
...@@ -3884,6 +3904,8 @@ static const struct net_device_ops macb_netdev_ops = { ...@@ -3884,6 +3904,8 @@ static const struct net_device_ops macb_netdev_ops = {
#endif #endif
.ndo_set_features = macb_set_features, .ndo_set_features = macb_set_features,
.ndo_features_check = macb_features_check, .ndo_features_check = macb_features_check,
.ndo_hwtstamp_set = macb_hwtstamp_set,
.ndo_hwtstamp_get = macb_hwtstamp_get,
}; };
/* Configure peripheral capabilities according to device tree /* Configure peripheral capabilities according to device tree
...@@ -4539,6 +4561,8 @@ static const struct net_device_ops at91ether_netdev_ops = { ...@@ -4539,6 +4561,8 @@ static const struct net_device_ops at91ether_netdev_ops = {
#ifdef CONFIG_NET_POLL_CONTROLLER #ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = at91ether_poll_controller, .ndo_poll_controller = at91ether_poll_controller,
#endif #endif
.ndo_hwtstamp_set = macb_hwtstamp_set,
.ndo_hwtstamp_get = macb_hwtstamp_get,
}; };
static int at91ether_clk_init(struct platform_device *pdev, struct clk **pclk, static int at91ether_clk_init(struct platform_device *pdev, struct clk **pclk,
......
...@@ -374,19 +374,16 @@ static int gem_ptp_set_ts_mode(struct macb *bp, ...@@ -374,19 +374,16 @@ static int gem_ptp_set_ts_mode(struct macb *bp,
return 0; return 0;
} }
int gem_get_hwtst(struct net_device *dev, struct ifreq *rq) int gem_get_hwtst(struct net_device *dev,
struct kernel_hwtstamp_config *tstamp_config)
{ {
struct hwtstamp_config *tstamp_config;
struct macb *bp = netdev_priv(dev); struct macb *bp = netdev_priv(dev);
tstamp_config = &bp->tstamp_config; *tstamp_config = bp->tstamp_config;
if ((bp->hw_dma_cap & HW_DMA_CAP_PTP) == 0) if ((bp->hw_dma_cap & HW_DMA_CAP_PTP) == 0)
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (copy_to_user(rq->ifr_data, tstamp_config, sizeof(*tstamp_config))) return 0;
return -EFAULT;
else
return 0;
} }
static void gem_ptp_set_one_step_sync(struct macb *bp, u8 enable) static void gem_ptp_set_one_step_sync(struct macb *bp, u8 enable)
...@@ -401,22 +398,18 @@ static void gem_ptp_set_one_step_sync(struct macb *bp, u8 enable) ...@@ -401,22 +398,18 @@ static void gem_ptp_set_one_step_sync(struct macb *bp, u8 enable)
macb_writel(bp, NCR, reg_val & ~MACB_BIT(OSSMODE)); macb_writel(bp, NCR, reg_val & ~MACB_BIT(OSSMODE));
} }
int gem_set_hwtst(struct net_device *dev, struct ifreq *ifr, int cmd) int gem_set_hwtst(struct net_device *dev,
struct kernel_hwtstamp_config *tstamp_config,
struct netlink_ext_ack *extack)
{ {
enum macb_bd_control tx_bd_control = TSTAMP_DISABLED; enum macb_bd_control tx_bd_control = TSTAMP_DISABLED;
enum macb_bd_control rx_bd_control = TSTAMP_DISABLED; enum macb_bd_control rx_bd_control = TSTAMP_DISABLED;
struct hwtstamp_config *tstamp_config;
struct macb *bp = netdev_priv(dev); struct macb *bp = netdev_priv(dev);
u32 regval; u32 regval;
tstamp_config = &bp->tstamp_config;
if ((bp->hw_dma_cap & HW_DMA_CAP_PTP) == 0) if ((bp->hw_dma_cap & HW_DMA_CAP_PTP) == 0)
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (copy_from_user(tstamp_config, ifr->ifr_data,
sizeof(*tstamp_config)))
return -EFAULT;
switch (tstamp_config->tx_type) { switch (tstamp_config->tx_type) {
case HWTSTAMP_TX_OFF: case HWTSTAMP_TX_OFF:
break; break;
...@@ -463,12 +456,11 @@ int gem_set_hwtst(struct net_device *dev, struct ifreq *ifr, int cmd) ...@@ -463,12 +456,11 @@ int gem_set_hwtst(struct net_device *dev, struct ifreq *ifr, int cmd)
return -ERANGE; return -ERANGE;
} }
bp->tstamp_config = *tstamp_config;
if (gem_ptp_set_ts_mode(bp, tx_bd_control, rx_bd_control) != 0) if (gem_ptp_set_ts_mode(bp, tx_bd_control, rx_bd_control) != 0)
return -ERANGE; return -ERANGE;
if (copy_to_user(ifr->ifr_data, tstamp_config, sizeof(*tstamp_config))) return 0;
return -EFAULT;
else
return 0;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment