* [PATCH RFC 0/8] ethtool: support time stamping and phc clocks
@ 2012-03-17 12:12 Richard Cochran
2012-03-17 12:12 ` [PATCH RFC 1/8] phc: Add a method for obtaining the device index Richard Cochran
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: Richard Cochran @ 2012-03-17 12:12 UTC (permalink / raw)
To: netdev; +Cc: David Miller, Ben Hutchings
* Warning - for discussion only, not tested, barely compiled!
Support for SO_TIMESTAMPING of network packets and PTP Hardware Clocks
has been expanding over the last year or two. In an ideal world,
every host would have exactly one PTP hardware clock, and every
Ethernet MAC would support SO_TIMESTAMPING on both the transmit and
receive paths.
However, since we do not yet have full coverage for these features,
user space programs need a way to discover what a given interface
supports in these two areas:
* PTP Hardware Clocks
The relationship between the network interfaces and the (possibly
multiple) PHC devices is not discoverable except by knowing what
hardware you have got and carefully looking into the kernel log.
* SO_TIMESTAMPING
- Receive software time stamps are implemented in the stack
and thus work for all MAC hardware.
- Transmit software time stamps are only supported by a dozen
drivers or so.
- Some special devices support Tx/Rx time stamping in hardware.
- None of this is discoverable except by looking into the kernel
sources.
This series is a draft idea of how to make the hardware and driver
capabilities known to user space via ethtool. Since the PHC code was
first merged, this has become the number one requested new feature.
Patch number 4 applies on top of my recent two igb/phc patches.
Thanks in advance for your comments,
Richard
Richard Cochran (8):
phc: Add a method for obtaining the device index.
ethtool: Introduce a method for getting time stamping capabilities.
bfin_mac: Support the get_ts_info ethtool method.
igb: Support the get_ts_info ethtool method.
gianfar: Support the get_ts_info ethtool method.
ixp4xx_eth: Support the get_ts_info ethtool method.
dp83640: Support the get_ts_info ethtool method.
davinci_emac: Support the get_ts_info ethtool method.
arch/arm/mach-ixp4xx/include/mach/ixp46x_ts.h | 3 ++
drivers/net/ethernet/adi/bfin_mac.c | 20 ++++++++++++
drivers/net/ethernet/freescale/gianfar.h | 3 ++
drivers/net/ethernet/freescale/gianfar_ethtool.c | 29 +++++++++++++++++
drivers/net/ethernet/freescale/gianfar_ptp.c | 2 +
drivers/net/ethernet/intel/igb/igb_ethtool.c | 31 +++++++++++++++++++
drivers/net/ethernet/ti/davinci_emac.c | 10 ++++++
drivers/net/ethernet/xscale/ixp4xx_eth.c | 29 +++++++++++++++++
drivers/net/phy/dp83640.c | 31 +++++++++++++++++++
drivers/ptp/ptp_clock.c | 6 ++++
drivers/ptp/ptp_ixp46x.c | 3 ++
include/linux/ethtool.h | 20 ++++++++++++
include/linux/phy.h | 3 ++
include/linux/ptp_clock_kernel.h | 9 +++++
net/core/ethtool.c | 36 ++++++++++++++++++++++
15 files changed, 235 insertions(+), 0 deletions(-)
--
1.7.2.5
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH RFC 1/8] phc: Add a method for obtaining the device index.
2012-03-17 12:12 [PATCH RFC 0/8] ethtool: support time stamping and phc clocks Richard Cochran
@ 2012-03-17 12:12 ` Richard Cochran
2012-03-17 12:12 ` [PATCH RFC 2/8] ethtool: Introduce a method for getting time stamping capabilities Richard Cochran
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Richard Cochran @ 2012-03-17 12:12 UTC (permalink / raw)
To: netdev; +Cc: David Miller, Ben Hutchings
This commit adds a method that MAC drivers may call in order to find out
the device number of their associated PTP Hardware Clock.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
---
drivers/ptp/ptp_clock.c | 6 ++++++
include/linux/ptp_clock_kernel.h | 9 +++++++++
2 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c
index f519a13..1e528b5 100644
--- a/drivers/ptp/ptp_clock.c
+++ b/drivers/ptp/ptp_clock.c
@@ -304,6 +304,12 @@ void ptp_clock_event(struct ptp_clock *ptp, struct ptp_clock_event *event)
}
EXPORT_SYMBOL(ptp_clock_event);
+int ptp_clock_index(struct ptp_clock *ptp)
+{
+ return ptp->index;
+}
+EXPORT_SYMBOL(ptp_clock_index);
+
/* module operations */
static void __exit ptp_exit(void)
diff --git a/include/linux/ptp_clock_kernel.h b/include/linux/ptp_clock_kernel.h
index dd2e44f..58008a2 100644
--- a/include/linux/ptp_clock_kernel.h
+++ b/include/linux/ptp_clock_kernel.h
@@ -136,4 +136,13 @@ struct ptp_clock_event {
extern void ptp_clock_event(struct ptp_clock *ptp,
struct ptp_clock_event *event);
+/**
+ * ptp_clock_index() - obtain the device index of a PTP clock
+ *
+ * @ptp: The clock obtained from ptp_clock_register().
+ * @event: Message structure describing the event.
+ */
+
+extern int ptp_clock_index(struct ptp_clock *ptp);
+
#endif
--
1.7.2.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH RFC 2/8] ethtool: Introduce a method for getting time stamping capabilities.
2012-03-17 12:12 [PATCH RFC 0/8] ethtool: support time stamping and phc clocks Richard Cochran
2012-03-17 12:12 ` [PATCH RFC 1/8] phc: Add a method for obtaining the device index Richard Cochran
@ 2012-03-17 12:12 ` Richard Cochran
2012-03-17 12:12 ` [PATCH RFC 3/8] bfin_mac: Support the get_ts_info ethtool method Richard Cochran
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Richard Cochran @ 2012-03-17 12:12 UTC (permalink / raw)
To: netdev; +Cc: David Miller, Ben Hutchings
This commit adds a new ethtool ioctl that exposes the SO_TIMESTAMPING
capabilities of a network interface. In addition, user space programs
can use this ioctl to discover the PTP Hardware Clock (PHC) device
associated with the interface.
Since software receive time stamps are handled by the stack, the generic
ethtool code can answer the query correctly in case the MAC or PHY
drivers lack special time stamping features.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
---
include/linux/ethtool.h | 20 ++++++++++++++++++++
include/linux/phy.h | 3 +++
net/core/ethtool.c | 36 ++++++++++++++++++++++++++++++++++++
3 files changed, 59 insertions(+), 0 deletions(-)
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index e1d9e0e..72ffda9 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -726,6 +726,24 @@ struct ethtool_sfeatures {
struct ethtool_set_features_block features[0];
};
+/**
+ * struct ethtool_ts_info - holds a device's timestamping and PHC association
+ * @cmd: command number = %ETHTOOL_GET_TS_INFO
+ * @so_timestamping: bit mask of SO_TIMESTAMPING modes supported by the device
+ * @phc_index: device index of the associated PHC, or -1 if there is none
+ * @tx_types: bit mask of hwtstamp_tx_types modes supported by the device
+ * @rx_filters: bit mask of hwtstamp_rx_filters modes supported by the device
+ */
+struct ethtool_ts_info {
+ __u32 cmd;
+ __u32 so_timestamping;
+ __s32 phc_index;
+ __u32 tx_types;
+ __u32 tx_reserved[3];
+ __u32 rx_filters;
+ __u32 rx_reserved[3];
+};
+
/*
* %ETHTOOL_SFEATURES changes features present in features[].valid to the
* values of corresponding bits in features[].requested. Bits in .requested
@@ -955,6 +973,7 @@ struct ethtool_ops {
int (*get_dump_data)(struct net_device *,
struct ethtool_dump *, void *);
int (*set_dump)(struct net_device *, struct ethtool_dump *);
+ int (*get_ts_info)(struct net_device *, struct ethtool_ts_info *);
};
#endif /* __KERNEL__ */
@@ -1029,6 +1048,7 @@ struct ethtool_ops {
#define ETHTOOL_SET_DUMP 0x0000003e /* Set dump settings */
#define ETHTOOL_GET_DUMP_FLAG 0x0000003f /* Get dump settings */
#define ETHTOOL_GET_DUMP_DATA 0x00000040 /* Get dump data */
+#define ETHTOOL_GET_TS_INFO 0x00000041 /* Get time stamping and PHC info */
/* compatibility with older code */
#define SPARC_ETH_GSET ETHTOOL_GSET
diff --git a/include/linux/phy.h b/include/linux/phy.h
index c599f7ec..497b5c0 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -411,6 +411,9 @@ struct phy_driver {
/* Clears up any memory if needed */
void (*remove)(struct phy_device *phydev);
+ /* Handles ethtool queries for hardware time stamping. */
+ int (*ts_info)(struct phy_device *phydev, struct ethtool_ts_info *ti);
+
/* Handles SIOCSHWTSTAMP ioctl for hardware time stamping. */
int (*hwtstamp)(struct phy_device *phydev, struct ifreq *ifr);
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 6d6d7d2..d6eff4b 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -17,6 +17,8 @@
#include <linux/errno.h>
#include <linux/ethtool.h>
#include <linux/netdevice.h>
+#include <linux/net_tstamp.h>
+#include <linux/phy.h>
#include <linux/bitops.h>
#include <linux/uaccess.h>
#include <linux/vmalloc.h>
@@ -1278,6 +1280,37 @@ out:
return ret;
}
+static int ethtool_get_ts_info(struct net_device *dev, void __user *useraddr)
+{
+ int err = 0;
+ struct ethtool_ts_info info;
+ const struct ethtool_ops *ops = dev->ethtool_ops;
+ struct phy_device *phydev = dev->phydev;
+
+ memset(&info, 0, sizeof(info));
+ info.cmd = ETHTOOL_GET_TS_INFO;
+
+ if (phydev && phydev->drv && phydev->drv->ts_info)
+ err = phydev->drv->ts_info(phydev, &info);
+
+ else if (dev->ethtool_ops->get_ts_info)
+ err = ops->get_ts_info(dev, &info);
+ else {
+ info.so_timestamping =
+ SOF_TIMESTAMPING_RX_SOFTWARE |
+ SOF_TIMESTAMPING_SOFTWARE;
+ info.phc_index = -1;
+ }
+
+ if (err)
+ return err;
+
+ if (copy_to_user(useraddr, &info, sizeof(info)))
+ err = -EFAULT;
+
+ return err;
+}
+
/* The main entry point in this file. Called from net/core/dev.c */
int dev_ethtool(struct net *net, struct ifreq *ifr)
@@ -1496,6 +1529,9 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
case ETHTOOL_GET_DUMP_DATA:
rc = ethtool_get_dump_data(dev, useraddr);
break;
+ case ETHTOOL_GET_TS_INFO:
+ rc = ethtool_get_ts_info(dev, useraddr);
+ break;
default:
rc = -EOPNOTSUPP;
}
--
1.7.2.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH RFC 3/8] bfin_mac: Support the get_ts_info ethtool method.
2012-03-17 12:12 [PATCH RFC 0/8] ethtool: support time stamping and phc clocks Richard Cochran
2012-03-17 12:12 ` [PATCH RFC 1/8] phc: Add a method for obtaining the device index Richard Cochran
2012-03-17 12:12 ` [PATCH RFC 2/8] ethtool: Introduce a method for getting time stamping capabilities Richard Cochran
@ 2012-03-17 12:12 ` Richard Cochran
2012-03-17 12:12 ` [PATCH RFC 4/8] igb: " Richard Cochran
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Richard Cochran @ 2012-03-17 12:12 UTC (permalink / raw)
To: netdev; +Cc: David Miller, Ben Hutchings
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
---
drivers/net/ethernet/adi/bfin_mac.c | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/drivers/net/ethernet/adi/bfin_mac.c b/drivers/net/ethernet/adi/bfin_mac.c
index ab4daec..db22278 100644
--- a/drivers/net/ethernet/adi/bfin_mac.c
+++ b/drivers/net/ethernet/adi/bfin_mac.c
@@ -548,6 +548,25 @@ static int bfin_mac_ethtool_setwol(struct net_device *dev,
return 0;
}
+static int bfin_mac_ethtool_get_ts_info(struct net_device *dev,
+ struct ethtool_ts_info *info);
+{
+ info->so_timestamping =
+ SOF_TIMESTAMPING_TX_HARDWARE |
+ SOF_TIMESTAMPING_RX_HARDWARE |
+ SOF_TIMESTAMPING_SYS_HARDWARE;
+ info->phc_index = -1;
+ info->tx_types =
+ (1 << HWTSTAMP_TX_OFF) |
+ (1 << HWTSTAMP_TX_ON);
+ info->rx_filters =
+ (1 << HWTSTAMP_FILTER_NONE) |
+ (1 << HWTSTAMP_FILTER_PTP_V1_L4_EVENT) |
+ (1 << HWTSTAMP_FILTER_PTP_V2_L2_EVENT) |
+ (1 << HWTSTAMP_FILTER_PTP_V2_L4_EVENT);
+ return 0;
+}
+
static const struct ethtool_ops bfin_mac_ethtool_ops = {
.get_settings = bfin_mac_ethtool_getsettings,
.set_settings = bfin_mac_ethtool_setsettings,
@@ -555,6 +574,7 @@ static const struct ethtool_ops bfin_mac_ethtool_ops = {
.get_drvinfo = bfin_mac_ethtool_getdrvinfo,
.get_wol = bfin_mac_ethtool_getwol,
.set_wol = bfin_mac_ethtool_setwol,
+ .get_ts_info = bfin_mac_ethtool_get_ts_info,
};
/**************************************************************************/
--
1.7.2.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH RFC 4/8] igb: Support the get_ts_info ethtool method.
2012-03-17 12:12 [PATCH RFC 0/8] ethtool: support time stamping and phc clocks Richard Cochran
` (2 preceding siblings ...)
2012-03-17 12:12 ` [PATCH RFC 3/8] bfin_mac: Support the get_ts_info ethtool method Richard Cochran
@ 2012-03-17 12:12 ` Richard Cochran
2012-03-17 12:12 ` [PATCH RFC 5/8] gianfar: " Richard Cochran
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Richard Cochran @ 2012-03-17 12:12 UTC (permalink / raw)
To: netdev; +Cc: David Miller, Ben Hutchings
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
---
drivers/net/ethernet/intel/igb/igb_ethtool.c | 31 ++++++++++++++++++++++++++
1 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c b/drivers/net/ethernet/intel/igb/igb_ethtool.c
index e10821a..245fec0 100644
--- a/drivers/net/ethernet/intel/igb/igb_ethtool.c
+++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c
@@ -2182,6 +2182,36 @@ static void igb_ethtool_complete(struct net_device *netdev)
pm_runtime_put(&adapter->pdev->dev);
}
+static int igb_ethtool_get_ts_info(struct net_device *dev,
+ struct ethtool_ts_info *info)
+{
+ struct igb_adapter *adapter = netdev_priv(dev);
+
+ info->so_timestamping =
+ SOF_TIMESTAMPING_TX_HARDWARE |
+ SOF_TIMESTAMPING_RX_HARDWARE |
+ SOF_TIMESTAMPING_RAW_HARDWARE;
+
+ if (adapter->ptp_clock)
+ info->phc_index = ptp_clock_index(adapter->ptp_clock);
+ else
+ info->phc_index = -1;
+
+ info->tx_types =
+ (1 << HWTSTAMP_TX_OFF) |
+ (1 << HWTSTAMP_TX_ON);
+
+ info->rx_filters =
+ (1 << HWTSTAMP_FILTER_NONE) |
+ (1 << HWTSTAMP_FILTER_ALL) |
+ (1 << HWTSTAMP_FILTER_SOME) |
+ (1 << HWTSTAMP_FILTER_PTP_V1_L4_SYNC) |
+ (1 << HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ) |
+ (1 << HWTSTAMP_FILTER_PTP_V2_EVENT);
+
+ return 0;
+}
+
static const struct ethtool_ops igb_ethtool_ops = {
.get_settings = igb_get_settings,
.set_settings = igb_set_settings,
@@ -2210,6 +2240,7 @@ static const struct ethtool_ops igb_ethtool_ops = {
.set_coalesce = igb_set_coalesce,
.begin = igb_ethtool_begin,
.complete = igb_ethtool_complete,
+ .get_ts_info = igb_ethtool_get_ts_info,
};
void igb_set_ethtool_ops(struct net_device *netdev)
--
1.7.2.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH RFC 5/8] gianfar: Support the get_ts_info ethtool method.
2012-03-17 12:12 [PATCH RFC 0/8] ethtool: support time stamping and phc clocks Richard Cochran
` (3 preceding siblings ...)
2012-03-17 12:12 ` [PATCH RFC 4/8] igb: " Richard Cochran
@ 2012-03-17 12:12 ` Richard Cochran
2012-03-17 12:12 ` [PATCH RFC 6/8] ixp4xx_eth: " Richard Cochran
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Richard Cochran @ 2012-03-17 12:12 UTC (permalink / raw)
To: netdev; +Cc: David Miller, Ben Hutchings
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
---
drivers/net/ethernet/freescale/gianfar.h | 3 ++
drivers/net/ethernet/freescale/gianfar_ethtool.c | 29 ++++++++++++++++++++++
drivers/net/ethernet/freescale/gianfar_ptp.c | 2 +
3 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/drivers/net/ethernet/freescale/gianfar.h b/drivers/net/ethernet/freescale/gianfar.h
index 4fe0f34..e1829e2 100644
--- a/drivers/net/ethernet/freescale/gianfar.h
+++ b/drivers/net/ethernet/freescale/gianfar.h
@@ -1213,4 +1213,7 @@ struct filer_table {
struct gfar_filer_entry fe[MAX_FILER_CACHE_IDX + 20];
};
+/* The gianfar_ptp module will set this variable */
+extern int gfar_phc_index;
+
#endif /* __GIANFAR_H */
diff --git a/drivers/net/ethernet/freescale/gianfar_ethtool.c b/drivers/net/ethernet/freescale/gianfar_ethtool.c
index 5a78d55..3115c4a 100644
--- a/drivers/net/ethernet/freescale/gianfar_ethtool.c
+++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c
@@ -1739,6 +1739,34 @@ static int gfar_get_nfc(struct net_device *dev, struct ethtool_rxnfc *cmd,
return ret;
}
+int gfar_phc_index = -1;
+
+static int gfar_get_ts_info(struct net_device *dev,
+ struct ethtool_ts_info *info)
+{
+ struct gfar_private *priv = netdev_priv(dev);
+
+ if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_TIMER)) {
+ info->so_timestamping =
+ SOF_TIMESTAMPING_RX_SOFTWARE |
+ SOF_TIMESTAMPING_SOFTWARE;
+ info->phc_index = -1;
+ return 0;
+ }
+ info->so_timestamping =
+ SOF_TIMESTAMPING_TX_HARDWARE |
+ SOF_TIMESTAMPING_RX_HARDWARE |
+ SOF_TIMESTAMPING_RAW_HARDWARE;
+ info->phc_index = gfar_phc_index;
+ info->tx_types =
+ (1 << HWTSTAMP_TX_OFF) |
+ (1 << HWTSTAMP_TX_ON);
+ info->rx_filters =
+ (1 << HWTSTAMP_FILTER_NONE) |
+ (1 << HWTSTAMP_FILTER_ALL);
+ return 0;
+}
+
const struct ethtool_ops gfar_ethtool_ops = {
.get_settings = gfar_gsettings,
.set_settings = gfar_ssettings,
@@ -1761,4 +1789,5 @@ const struct ethtool_ops gfar_ethtool_ops = {
#endif
.set_rxnfc = gfar_set_nfc,
.get_rxnfc = gfar_get_nfc,
+ .get_ts_info = gfar_get_ts_info,
};
diff --git a/drivers/net/ethernet/freescale/gianfar_ptp.c b/drivers/net/ethernet/freescale/gianfar_ptp.c
index 5fd620b..c08e5d4 100644
--- a/drivers/net/ethernet/freescale/gianfar_ptp.c
+++ b/drivers/net/ethernet/freescale/gianfar_ptp.c
@@ -515,6 +515,7 @@ static int gianfar_ptp_probe(struct platform_device *dev)
err = PTR_ERR(etsects->clock);
goto no_clock;
}
+ gfar_phc_clock = ptp_clock_index(etsects->clock);
dev_set_drvdata(&dev->dev, etsects);
@@ -538,6 +539,7 @@ static int gianfar_ptp_remove(struct platform_device *dev)
gfar_write(&etsects->regs->tmr_temask, 0);
gfar_write(&etsects->regs->tmr_ctrl, 0);
+ gfar_phc_clock = -1;
ptp_clock_unregister(etsects->clock);
iounmap(etsects->regs);
release_resource(etsects->rsrc);
--
1.7.2.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH RFC 6/8] ixp4xx_eth: Support the get_ts_info ethtool method.
2012-03-17 12:12 [PATCH RFC 0/8] ethtool: support time stamping and phc clocks Richard Cochran
` (4 preceding siblings ...)
2012-03-17 12:12 ` [PATCH RFC 5/8] gianfar: " Richard Cochran
@ 2012-03-17 12:12 ` Richard Cochran
2012-03-17 12:12 ` [PATCH RFC 7/8] dp83640: " Richard Cochran
2012-03-17 12:12 ` [PATCH RFC 8/8] davinci_emac: " Richard Cochran
7 siblings, 0 replies; 9+ messages in thread
From: Richard Cochran @ 2012-03-17 12:12 UTC (permalink / raw)
To: netdev; +Cc: David Miller, Ben Hutchings
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
---
arch/arm/mach-ixp4xx/include/mach/ixp46x_ts.h | 3 ++
drivers/net/ethernet/xscale/ixp4xx_eth.c | 29 +++++++++++++++++++++++++
drivers/ptp/ptp_ixp46x.c | 3 ++
3 files changed, 35 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-ixp4xx/include/mach/ixp46x_ts.h b/arch/arm/mach-ixp4xx/include/mach/ixp46x_ts.h
index 292d55e..cf03614 100644
--- a/arch/arm/mach-ixp4xx/include/mach/ixp46x_ts.h
+++ b/arch/arm/mach-ixp4xx/include/mach/ixp46x_ts.h
@@ -75,4 +75,7 @@ struct ixp46x_ts_regs {
#define TX_SNAPSHOT_LOCKED (1<<0)
#define RX_SNAPSHOT_LOCKED (1<<1)
+/* The ptp_ixp46x module will set this variable */
+extern int ixp46x_phc_index;
+
#endif
diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c
index 41a8b5a..482648f 100644
--- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
+++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
@@ -1002,12 +1002,41 @@ static int ixp4xx_nway_reset(struct net_device *dev)
return phy_start_aneg(port->phydev);
}
+int ixp46x_phc_index = -1;
+
+static int ixp4xx_get_ts_info(struct net_device *dev,
+ struct ethtool_ts_info *info)
+{
+ if (!cpu_is_ixp46x()) {
+ info->so_timestamping =
+ SOF_TIMESTAMPING_TX_SOFTWARE |
+ SOF_TIMESTAMPING_RX_SOFTWARE |
+ SOF_TIMESTAMPING_SOFTWARE;
+ info->phc_index = -1;
+ return 0;
+ }
+ info->so_timestamping =
+ SOF_TIMESTAMPING_TX_HARDWARE |
+ SOF_TIMESTAMPING_RX_HARDWARE |
+ SOF_TIMESTAMPING_RAW_HARDWARE;
+ info->phc_index = ixp46x_phc_index;
+ info->tx_types =
+ (1 << HWTSTAMP_TX_OFF) |
+ (1 << HWTSTAMP_TX_ON);
+ info->rx_filters =
+ (1 << HWTSTAMP_FILTER_NONE) |
+ (1 << HWTSTAMP_FILTER_PTP_V1_L4_SYNC) |
+ (1 << HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ);
+ return 0;
+}
+
static const struct ethtool_ops ixp4xx_ethtool_ops = {
.get_drvinfo = ixp4xx_get_drvinfo,
.get_settings = ixp4xx_get_settings,
.set_settings = ixp4xx_set_settings,
.nway_reset = ixp4xx_nway_reset,
.get_link = ethtool_op_get_link,
+ .get_ts_info = ixp4xx_get_ts_info,
};
diff --git a/drivers/ptp/ptp_ixp46x.c b/drivers/ptp/ptp_ixp46x.c
index 6f2782b..9d13a71 100644
--- a/drivers/ptp/ptp_ixp46x.c
+++ b/drivers/ptp/ptp_ixp46x.c
@@ -284,6 +284,7 @@ static void __exit ptp_ixp_exit(void)
{
free_irq(MASTER_IRQ, &ixp_clock);
free_irq(SLAVE_IRQ, &ixp_clock);
+ ixp46x_phc_clock = -1;
ptp_clock_unregister(ixp_clock.ptp_clock);
}
@@ -302,6 +303,8 @@ static int __init ptp_ixp_init(void)
if (IS_ERR(ixp_clock.ptp_clock))
return PTR_ERR(ixp_clock.ptp_clock);
+ ixp46x_phc_clock = ptp_clock_index(ixp_clock.ptp_clock);
+
__raw_writel(DEFAULT_ADDEND, &ixp_clock.regs->addend);
__raw_writel(1, &ixp_clock.regs->trgt_lo);
__raw_writel(0, &ixp_clock.regs->trgt_hi);
--
1.7.2.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH RFC 7/8] dp83640: Support the get_ts_info ethtool method.
2012-03-17 12:12 [PATCH RFC 0/8] ethtool: support time stamping and phc clocks Richard Cochran
` (5 preceding siblings ...)
2012-03-17 12:12 ` [PATCH RFC 6/8] ixp4xx_eth: " Richard Cochran
@ 2012-03-17 12:12 ` Richard Cochran
2012-03-17 12:12 ` [PATCH RFC 8/8] davinci_emac: " Richard Cochran
7 siblings, 0 replies; 9+ messages in thread
From: Richard Cochran @ 2012-03-17 12:12 UTC (permalink / raw)
To: netdev; +Cc: David Miller, Ben Hutchings
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
---
drivers/net/phy/dp83640.c | 31 +++++++++++++++++++++++++++++++
1 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c
index dd7ae19..940b290 100644
--- a/drivers/net/phy/dp83640.c
+++ b/drivers/net/phy/dp83640.c
@@ -1215,6 +1215,36 @@ static void dp83640_txtstamp(struct phy_device *phydev,
}
}
+static int dp83640_ts_info(struct phy_device *dev, struct ethtool_ts_info *info)
+{
+ struct dp83640_private *dp83640 = dev->priv;
+
+ info->so_timestamping =
+ SOF_TIMESTAMPING_TX_HARDWARE |
+ SOF_TIMESTAMPING_RX_HARDWARE |
+ SOF_TIMESTAMPING_RAW_HARDWARE;
+ info->phc_index = ptp_clock_index(dp83640->clock->ptp_clock);
+ info->tx_types =
+ (1 << HWTSTAMP_TX_OFF) |
+ (1 << HWTSTAMP_TX_ON) |
+ (1 << HWTSTAMP_TX_ONESTEP_SYNC);
+ info->rx_filters =
+ (1 << HWTSTAMP_FILTER_NONE) |
+ (1 << HWTSTAMP_FILTER_PTP_V1_L4_EVENT) |
+ (1 << HWTSTAMP_FILTER_PTP_V1_L4_SYNC) |
+ (1 << HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ) |
+ (1 << HWTSTAMP_FILTER_PTP_V2_L4_EVENT) |
+ (1 << HWTSTAMP_FILTER_PTP_V2_L4_SYNC) |
+ (1 << HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ) |
+ (1 << HWTSTAMP_FILTER_PTP_V2_L2_EVENT) |
+ (1 << HWTSTAMP_FILTER_PTP_V2_L2_SYNC) |
+ (1 << HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ) |
+ (1 << HWTSTAMP_FILTER_PTP_V2_EVENT) |
+ (1 << HWTSTAMP_FILTER_PTP_V2_SYNC) |
+ (1 << HWTSTAMP_FILTER_PTP_V2_DELAY_REQ);
+ return 0;
+}
+
static struct phy_driver dp83640_driver = {
.phy_id = DP83640_PHY_ID,
.phy_id_mask = 0xfffffff0,
@@ -1225,6 +1255,7 @@ static struct phy_driver dp83640_driver = {
.remove = dp83640_remove,
.config_aneg = genphy_config_aneg,
.read_status = genphy_read_status,
+ .ts_info = dp83640_ts_info,
.hwtstamp = dp83640_hwtstamp,
.rxtstamp = dp83640_rxtstamp,
.txtstamp = dp83640_txtstamp,
--
1.7.2.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH RFC 8/8] davinci_emac: Support the get_ts_info ethtool method.
2012-03-17 12:12 [PATCH RFC 0/8] ethtool: support time stamping and phc clocks Richard Cochran
` (6 preceding siblings ...)
2012-03-17 12:12 ` [PATCH RFC 7/8] dp83640: " Richard Cochran
@ 2012-03-17 12:12 ` Richard Cochran
7 siblings, 0 replies; 9+ messages in thread
From: Richard Cochran @ 2012-03-17 12:12 UTC (permalink / raw)
To: netdev; +Cc: David Miller, Ben Hutchings
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
---
drivers/net/ethernet/ti/davinci_emac.c | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
index 174a334..155a178 100644
--- a/drivers/net/ethernet/ti/davinci_emac.c
+++ b/drivers/net/ethernet/ti/davinci_emac.c
@@ -613,6 +613,15 @@ static int emac_set_coalesce(struct net_device *ndev,
}
+static int emac_get_ts_info(struct net_device *nd, struct ethtool_ts_info *info)
+{
+ info->so_timestamping =
+ SOF_TIMESTAMPING_TX_SOFTWARE |
+ SOF_TIMESTAMPING_RX_SOFTWARE |
+ SOF_TIMESTAMPING_SOFTWARE;
+ info->phc_index = -1;
+ return 0;
+}
/**
* ethtool_ops: DaVinci EMAC Ethtool structure
@@ -627,6 +636,7 @@ static const struct ethtool_ops ethtool_ops = {
.get_link = ethtool_op_get_link,
.get_coalesce = emac_get_coalesce,
.set_coalesce = emac_set_coalesce,
+ .get_ts_info = emac_get_ts_info,
};
/**
--
1.7.2.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2012-03-17 12:13 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-17 12:12 [PATCH RFC 0/8] ethtool: support time stamping and phc clocks Richard Cochran
2012-03-17 12:12 ` [PATCH RFC 1/8] phc: Add a method for obtaining the device index Richard Cochran
2012-03-17 12:12 ` [PATCH RFC 2/8] ethtool: Introduce a method for getting time stamping capabilities Richard Cochran
2012-03-17 12:12 ` [PATCH RFC 3/8] bfin_mac: Support the get_ts_info ethtool method Richard Cochran
2012-03-17 12:12 ` [PATCH RFC 4/8] igb: " Richard Cochran
2012-03-17 12:12 ` [PATCH RFC 5/8] gianfar: " Richard Cochran
2012-03-17 12:12 ` [PATCH RFC 6/8] ixp4xx_eth: " Richard Cochran
2012-03-17 12:12 ` [PATCH RFC 7/8] dp83640: " Richard Cochran
2012-03-17 12:12 ` [PATCH RFC 8/8] davinci_emac: " Richard Cochran
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).