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

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
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -1165,9 +1165,10 @@ struct macb_ptp_info {
	int (*get_ts_info)(struct net_device *dev,
			   struct ethtool_ts_info *info);
	int (*get_hwtst)(struct net_device *netdev,
			 struct ifreq *ifr);
			 struct kernel_hwtstamp_config *tstamp_config);
	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 {
@@ -1314,7 +1315,7 @@ struct macb {
	struct ptp_clock *ptp_clock;
	struct ptp_clock_info ptp_clock_info;
	struct tsu_incr tsu_incr;
	struct hwtstamp_config tstamp_config;
	struct kernel_hwtstamp_config tstamp_config;

	/* RX queue filer rule set*/
	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

	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
static inline void gem_ptp_init(struct net_device *ndev) { }
static inline void gem_ptp_remove(struct net_device *ndev) { }
+33 −9
Original line number Diff line number Diff line
@@ -3773,16 +3773,36 @@ static int macb_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
	if (!netif_running(dev))
		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);
}

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);
}

	return phylink_mii_ioctl(bp->phylink, rq, cmd);
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,
@@ -3884,6 +3904,8 @@ static const struct net_device_ops macb_netdev_ops = {
#endif
	.ndo_set_features	= macb_set_features,
	.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
@@ -4539,6 +4561,8 @@ static const struct net_device_ops at91ether_netdev_ops = {
#ifdef CONFIG_NET_POLL_CONTROLLER
	.ndo_poll_controller	= at91ether_poll_controller,
#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,
+10 −18
Original line number Diff line number Diff line
@@ -374,18 +374,15 @@ static int gem_ptp_set_ts_mode(struct macb *bp,
	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);

	tstamp_config = &bp->tstamp_config;
	*tstamp_config = bp->tstamp_config;
	if ((bp->hw_dma_cap & HW_DMA_CAP_PTP) == 0)
		return -EOPNOTSUPP;

	if (copy_to_user(rq->ifr_data, tstamp_config, sizeof(*tstamp_config)))
		return -EFAULT;
	else
	return 0;
}

@@ -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));
}

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 rx_bd_control = TSTAMP_DISABLED;
	struct hwtstamp_config *tstamp_config;
	struct macb *bp = netdev_priv(dev);
	u32 regval;

	tstamp_config = &bp->tstamp_config;
	if ((bp->hw_dma_cap & HW_DMA_CAP_PTP) == 0)
		return -EOPNOTSUPP;

	if (copy_from_user(tstamp_config, ifr->ifr_data,
			   sizeof(*tstamp_config)))
		return -EFAULT;

	switch (tstamp_config->tx_type) {
	case HWTSTAMP_TX_OFF:
		break;
@@ -463,12 +456,11 @@ int gem_set_hwtst(struct net_device *dev, struct ifreq *ifr, int cmd)
		return -ERANGE;
	}

	bp->tstamp_config = *tstamp_config;

	if (gem_ptp_set_ts_mode(bp, tx_bd_control, rx_bd_control) != 0)
		return -ERANGE;

	if (copy_to_user(ifr->ifr_data, tstamp_config, sizeof(*tstamp_config)))
		return -EFAULT;
	else
	return 0;
}