aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2013-11-18 18:28:30 -0500
committerBen Hutchings <bhutchings@solarflare.com>2013-11-21 12:17:48 -0500
commit81fc347a0f0ab460276e3800147aaf2e8b32b466 (patch)
tree24431dc1466b22c348212d61b15c23a38f4705af
parent6ab96d1e06ba1452d583f3e45d6a3a45bb36b1c3 (diff)
ixp4xx_eth: Implement the SIOCGHWTSTAMP ioctl
This is untested. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
-rw-r--r--drivers/net/ethernet/xscale/ixp4xx_eth.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c
index bcc224a83734..25283f17d82f 100644
--- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
+++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
@@ -373,7 +373,7 @@ static void ixp_tx_timestamp(struct port *port, struct sk_buff *skb)
373 __raw_writel(TX_SNAPSHOT_LOCKED, &regs->channel[ch].ch_event); 373 __raw_writel(TX_SNAPSHOT_LOCKED, &regs->channel[ch].ch_event);
374} 374}
375 375
376static int hwtstamp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) 376static int hwtstamp_set(struct net_device *netdev, struct ifreq *ifr)
377{ 377{
378 struct hwtstamp_config cfg; 378 struct hwtstamp_config cfg;
379 struct ixp46x_ts_regs *regs; 379 struct ixp46x_ts_regs *regs;
@@ -417,6 +417,32 @@ static int hwtstamp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
417 return copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0; 417 return copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0;
418} 418}
419 419
420static int hwtstamp_get(struct net_device *netdev, struct ifreq *ifr)
421{
422 struct hwtstamp_config cfg;
423 struct port *port = netdev_priv(netdev);
424
425 cfg.flags = 0;
426 cfg.tx_type = port->hwts_tx_en ? HWTSTAMP_TX_ON : HWTSTAMP_TX_OFF;
427
428 switch (port->hwts_rx_en) {
429 case 0:
430 cfg.rx_filter = HWTSTAMP_FILTER_NONE;
431 break;
432 case PTP_SLAVE_MODE:
433 cfg.rx_filter = HWTSTAMP_FILTER_PTP_V1_L4_SYNC;
434 break;
435 case PTP_MASTER_MODE:
436 cfg.rx_filter = HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ;
437 break;
438 default:
439 WARN_ON_ONCE(1);
440 return -ERANGE;
441 }
442
443 return copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0;
444}
445
420static int ixp4xx_mdio_cmd(struct mii_bus *bus, int phy_id, int location, 446static int ixp4xx_mdio_cmd(struct mii_bus *bus, int phy_id, int location,
421 int write, u16 cmd) 447 int write, u16 cmd)
422{ 448{
@@ -959,8 +985,12 @@ static int eth_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
959 if (!netif_running(dev)) 985 if (!netif_running(dev))
960 return -EINVAL; 986 return -EINVAL;
961 987
962 if (cpu_is_ixp46x() && cmd == SIOCSHWTSTAMP) 988 if (cpu_is_ixp46x()) {
963 return hwtstamp_ioctl(dev, req, cmd); 989 if (cmd == SIOCSHWTSTAMP)
990 return hwtstamp_set(dev, req);
991 if (cmd == SIOCGHWTSTAMP)
992 return hwtstamp_get(dev, req);
993 }
964 994
965 return phy_mii_ioctl(port->phydev, req, cmd); 995 return phy_mii_ioctl(port->phydev, req, cmd);
966} 996}