* [PATCH net-next 01/16] net_tstamp: Improve kernel-doc for struct hwtstamp_config
2013-12-05 23:37 Pull request: SIOCGHWTSTAMP ioctl Ben Hutchings
@ 2013-12-05 23:38 ` Ben Hutchings
2013-12-05 23:42 ` [PATCH net-next 02/16] net/compat: Fix minor information leak in siocdevprivate_ioctl() Ben Hutchings
` (15 subsequent siblings)
16 siblings, 0 replies; 24+ messages in thread
From: Ben Hutchings @ 2013-12-05 23:38 UTC (permalink / raw)
To: David Miller; +Cc: netdev, linux-net-drivers, Richard Cochran
Fix the name of the rx_filter field.
Remove text about 32/64-bit compatibility; this works just the same as
for most socket ioctls and as the structure is not allowed to grow
there is no need to remind anyone how to maintain it.
Add explanation about drivers changing the filter mode.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
include/uapi/linux/net_tstamp.h | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/include/uapi/linux/net_tstamp.h b/include/uapi/linux/net_tstamp.h
index ae5df122e42f..c9a7de2a6276 100644
--- a/include/uapi/linux/net_tstamp.h
+++ b/include/uapi/linux/net_tstamp.h
@@ -30,13 +30,13 @@ enum {
*
* @flags: no flags defined right now, must be zero
* @tx_type: one of HWTSTAMP_TX_*
- * @rx_type: one of one of HWTSTAMP_FILTER_*
+ * @rx_filter: one of HWTSTAMP_FILTER_*
*
* %SIOCSHWTSTAMP expects a &struct ifreq with a ifr_data pointer to
- * this structure. dev_ifsioc() in the kernel takes care of the
- * translation between 32 bit userspace and 64 bit kernel. The
- * structure is intentionally chosen so that it has the same layout on
- * 32 and 64 bit systems, don't break this!
+ * this structure. If the driver or hardware does not support the
+ * requested @rx_filter value, the driver may use a more general
+ * filter mode. In this case @rx_filter will indicate the actual mode
+ * on return.
*/
struct hwtstamp_config {
int flags;
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH net-next 02/16] net/compat: Fix minor information leak in siocdevprivate_ioctl()
2013-12-05 23:37 Pull request: SIOCGHWTSTAMP ioctl Ben Hutchings
2013-12-05 23:38 ` [PATCH net-next 01/16] net_tstamp: Improve kernel-doc for struct hwtstamp_config Ben Hutchings
@ 2013-12-05 23:42 ` Ben Hutchings
2013-12-05 23:43 ` [PATCH net-next 03/16] net/compat: Merge multiple implementations of ifreq::ifr_data conversion Ben Hutchings
` (14 subsequent siblings)
16 siblings, 0 replies; 24+ messages in thread
From: Ben Hutchings @ 2013-12-05 23:42 UTC (permalink / raw)
To: David Miller; +Cc: netdev, linux-net-drivers, Richard Cochran
We don't need to check that ifr_data itself is a valid user pointer,
but we should check &ifr_data is. Thankfully the copy of ifr_name is
checked, so this can only leak a few bytes from immediately above the
user address limit.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
This might deserve to go into net instead. Not sure.
Ben.
net/socket.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/net/socket.c b/net/socket.c
index c226aceee65b..fbb6ec13b1f4 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -3015,19 +3015,16 @@ static int siocdevprivate_ioctl(struct net *net, unsigned int cmd,
if (copy_from_user(&tmp_buf[0], &(u_ifreq32->ifr_ifrn.ifrn_name[0]),
IFNAMSIZ))
return -EFAULT;
- if (__get_user(data32, &u_ifreq32->ifr_ifru.ifru_data))
+ if (get_user(data32, &u_ifreq32->ifr_ifru.ifru_data))
return -EFAULT;
data64 = compat_ptr(data32);
u_ifreq64 = compat_alloc_user_space(sizeof(*u_ifreq64));
- /* Don't check these user accesses, just let that get trapped
- * in the ioctl handler instead.
- */
if (copy_to_user(&u_ifreq64->ifr_ifrn.ifrn_name[0], &tmp_buf[0],
IFNAMSIZ))
return -EFAULT;
- if (__put_user(data64, &u_ifreq64->ifr_ifru.ifru_data))
+ if (put_user(data64, &u_ifreq64->ifr_ifru.ifru_data))
return -EFAULT;
return dev_ioctl(net, cmd, u_ifreq64);
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH net-next 03/16] net/compat: Merge multiple implementations of ifreq::ifr_data conversion
2013-12-05 23:37 Pull request: SIOCGHWTSTAMP ioctl Ben Hutchings
2013-12-05 23:38 ` [PATCH net-next 01/16] net_tstamp: Improve kernel-doc for struct hwtstamp_config Ben Hutchings
2013-12-05 23:42 ` [PATCH net-next 02/16] net/compat: Fix minor information leak in siocdevprivate_ioctl() Ben Hutchings
@ 2013-12-05 23:43 ` Ben Hutchings
2013-12-05 23:45 ` [PATCH net-next 04/16] net_tstamp: Add SIOCGHWTSTAMP ioctl to match SIOCSHWTSTAMP Ben Hutchings
` (13 subsequent siblings)
16 siblings, 0 replies; 24+ messages in thread
From: Ben Hutchings @ 2013-12-05 23:43 UTC (permalink / raw)
To: David Miller; +Cc: netdev, linux-net-drivers, Richard Cochran
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
net/socket.c | 49 ++++++-------------------------------------------
1 file changed, 6 insertions(+), 43 deletions(-)
diff --git a/net/socket.c b/net/socket.c
index fbb6ec13b1f4..7a766ab83ca5 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -2964,11 +2964,8 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
struct compat_ifreq __user *ifr32)
{
struct ifreq kifr;
- struct ifreq __user *uifr;
mm_segment_t old_fs;
int err;
- u32 data;
- void __user *datap;
switch (cmd) {
case SIOCBONDENSLAVE:
@@ -2985,26 +2982,13 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
set_fs(old_fs);
return err;
- case SIOCBONDSLAVEINFOQUERY:
- case SIOCBONDINFOQUERY:
- uifr = compat_alloc_user_space(sizeof(*uifr));
- if (copy_in_user(&uifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ))
- return -EFAULT;
-
- if (get_user(data, &ifr32->ifr_ifru.ifru_data))
- return -EFAULT;
-
- datap = compat_ptr(data);
- if (put_user(datap, &uifr->ifr_ifru.ifru_data))
- return -EFAULT;
-
- return dev_ioctl(net, cmd, uifr);
default:
return -ENOIOCTLCMD;
}
}
-static int siocdevprivate_ioctl(struct net *net, unsigned int cmd,
+/* Handle ioctls that use ifreq::ifr_data and just need struct ifreq converted */
+static int compat_ifr_data_ioctl(struct net *net, unsigned int cmd,
struct compat_ifreq __user *u_ifreq32)
{
struct ifreq __user *u_ifreq64;
@@ -3104,27 +3088,6 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
return err;
}
-static int compat_siocshwtstamp(struct net *net, struct compat_ifreq __user *uifr32)
-{
- void __user *uptr;
- compat_uptr_t uptr32;
- struct ifreq __user *uifr;
-
- uifr = compat_alloc_user_space(sizeof(*uifr));
- if (copy_in_user(uifr, uifr32, sizeof(struct compat_ifreq)))
- return -EFAULT;
-
- if (get_user(uptr32, &uifr32->ifr_data))
- return -EFAULT;
-
- uptr = compat_ptr(uptr32);
-
- if (put_user(uptr, &uifr->ifr_data))
- return -EFAULT;
-
- return dev_ioctl(net, SIOCSHWTSTAMP, uifr);
-}
-
struct rtentry32 {
u32 rt_pad1;
struct sockaddr rt_dst; /* target address */
@@ -3236,7 +3199,7 @@ static int compat_sock_ioctl_trans(struct file *file, struct socket *sock,
struct net *net = sock_net(sk);
if (cmd >= SIOCDEVPRIVATE && cmd <= (SIOCDEVPRIVATE + 15))
- return siocdevprivate_ioctl(net, cmd, argp);
+ return compat_ifr_data_ioctl(net, cmd, argp);
switch (cmd) {
case SIOCSIFBR:
@@ -3256,8 +3219,6 @@ static int compat_sock_ioctl_trans(struct file *file, struct socket *sock,
case SIOCBONDENSLAVE:
case SIOCBONDRELEASE:
case SIOCBONDSETHWADDR:
- case SIOCBONDSLAVEINFOQUERY:
- case SIOCBONDINFOQUERY:
case SIOCBONDCHANGEACTIVE:
return bond_ioctl(net, cmd, argp);
case SIOCADDRT:
@@ -3267,8 +3228,10 @@ static int compat_sock_ioctl_trans(struct file *file, struct socket *sock,
return do_siocgstamp(net, sock, cmd, argp);
case SIOCGSTAMPNS:
return do_siocgstampns(net, sock, cmd, argp);
+ case SIOCBONDSLAVEINFOQUERY:
+ case SIOCBONDINFOQUERY:
case SIOCSHWTSTAMP:
- return compat_siocshwtstamp(net, argp);
+ return compat_ifr_data_ioctl(net, cmd, argp);
case FIOSETOWN:
case SIOCSPGRP:
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH net-next 04/16] net_tstamp: Add SIOCGHWTSTAMP ioctl to match SIOCSHWTSTAMP
2013-12-05 23:37 Pull request: SIOCGHWTSTAMP ioctl Ben Hutchings
` (2 preceding siblings ...)
2013-12-05 23:43 ` [PATCH net-next 03/16] net/compat: Merge multiple implementations of ifreq::ifr_data conversion Ben Hutchings
@ 2013-12-05 23:45 ` Ben Hutchings
2013-12-05 23:45 ` [PATCH net-next 05/16] sfc: Implement the SIOCGHWTSTAMP ioctl Ben Hutchings
` (12 subsequent siblings)
16 siblings, 0 replies; 24+ messages in thread
From: Ben Hutchings @ 2013-12-05 23:45 UTC (permalink / raw)
To: David Miller; +Cc: netdev, linux-net-drivers, Richard Cochran
SIOCSHWTSTAMP returns the real configuration to the application
using it, but there is currently no way for any other
application to find out the configuration non-destructively.
Add a new ioctl for this, making it unprivileged.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
v2: Include documentation update and compat ioctl
Documentation/networking/timestamping.txt | 9 +++++++--
include/uapi/linux/net_tstamp.h | 14 +++++++-------
include/uapi/linux/sockios.h | 3 ++-
net/core/dev_ioctl.c | 2 ++
net/socket.c | 1 +
5 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/Documentation/networking/timestamping.txt b/Documentation/networking/timestamping.txt
index 98097d8cb910..661d3c316a17 100644
--- a/Documentation/networking/timestamping.txt
+++ b/Documentation/networking/timestamping.txt
@@ -85,7 +85,7 @@ Filled in if SOF_TIMESTAMPING_SYS_HARDWARE is set. Requires support
by the network device and will be empty without that support.
-SIOCSHWTSTAMP:
+SIOCSHWTSTAMP, SIOCGHWTSTAMP:
Hardware time stamping must also be initialized for each device driver
that is expected to do hardware time stamping. The parameter is defined in
@@ -115,6 +115,10 @@ Only a processes with admin rights may change the configuration. User
space is responsible to ensure that multiple processes don't interfere
with each other and that the settings are reset.
+Any process can read the actual configuration by passing this
+structure to ioctl(SIOCGHWTSTAMP) in the same way. However, this has
+not been implemented in all drivers.
+
/* possible values for hwtstamp_config->tx_type */
enum {
/*
@@ -157,7 +161,8 @@ DEVICE IMPLEMENTATION
A driver which supports hardware time stamping must support the
SIOCSHWTSTAMP ioctl and update the supplied struct hwtstamp_config with
-the actual values as described in the section on SIOCSHWTSTAMP.
+the actual values as described in the section on SIOCSHWTSTAMP. It
+should also support SIOCGHWTSTAMP.
Time stamps for received packets must be stored in the skb. To get a pointer
to the shared time stamp structure of the skb call skb_hwtstamps(). Then
diff --git a/include/uapi/linux/net_tstamp.h b/include/uapi/linux/net_tstamp.h
index c9a7de2a6276..f53879c0f590 100644
--- a/include/uapi/linux/net_tstamp.h
+++ b/include/uapi/linux/net_tstamp.h
@@ -26,17 +26,17 @@ enum {
};
/**
- * struct hwtstamp_config - %SIOCSHWTSTAMP parameter
+ * struct hwtstamp_config - %SIOCGHWTSTAMP and %SIOCSHWTSTAMP parameter
*
- * @flags: no flags defined right now, must be zero
+ * @flags: no flags defined right now, must be zero for %SIOCSHWTSTAMP
* @tx_type: one of HWTSTAMP_TX_*
* @rx_filter: one of HWTSTAMP_FILTER_*
*
- * %SIOCSHWTSTAMP expects a &struct ifreq with a ifr_data pointer to
- * this structure. If the driver or hardware does not support the
- * requested @rx_filter value, the driver may use a more general
- * filter mode. In this case @rx_filter will indicate the actual mode
- * on return.
+ * %SIOCGHWTSTAMP and %SIOCSHWTSTAMP expect a &struct ifreq with a
+ * ifr_data pointer to this structure. For %SIOCSHWTSTAMP, if the
+ * driver or hardware does not support the requested @rx_filter value,
+ * the driver may use a more general filter mode. In this case
+ * @rx_filter will indicate the actual mode on return.
*/
struct hwtstamp_config {
int flags;
diff --git a/include/uapi/linux/sockios.h b/include/uapi/linux/sockios.h
index 7997a506ad41..e888b1aed69f 100644
--- a/include/uapi/linux/sockios.h
+++ b/include/uapi/linux/sockios.h
@@ -125,7 +125,8 @@
#define SIOCBRDELIF 0x89a3 /* remove interface from bridge */
/* hardware time stamping: parameters in linux/net_tstamp.h */
-#define SIOCSHWTSTAMP 0x89b0
+#define SIOCSHWTSTAMP 0x89b0 /* set and get config */
+#define SIOCGHWTSTAMP 0x89b1 /* get config */
/* Device private ioctl calls */
diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
index 5b7d0e1d0664..cf999e09bcd2 100644
--- a/net/core/dev_ioctl.c
+++ b/net/core/dev_ioctl.c
@@ -327,6 +327,7 @@ static int dev_ifsioc(struct net *net, struct ifreq *ifr, unsigned int cmd)
cmd == SIOCBRADDIF ||
cmd == SIOCBRDELIF ||
cmd == SIOCSHWTSTAMP ||
+ cmd == SIOCGHWTSTAMP ||
cmd == SIOCWANDEV) {
err = -EOPNOTSUPP;
if (ops->ndo_do_ioctl) {
@@ -546,6 +547,7 @@ int dev_ioctl(struct net *net, unsigned int cmd, void __user *arg)
*/
default:
if (cmd == SIOCWANDEV ||
+ cmd == SIOCGHWTSTAMP ||
(cmd >= SIOCDEVPRIVATE &&
cmd <= SIOCDEVPRIVATE + 15)) {
dev_load(net, ifr.ifr_name);
diff --git a/net/socket.c b/net/socket.c
index 7a766ab83ca5..1a548b70ef3a 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -3231,6 +3231,7 @@ static int compat_sock_ioctl_trans(struct file *file, struct socket *sock,
case SIOCBONDSLAVEINFOQUERY:
case SIOCBONDINFOQUERY:
case SIOCSHWTSTAMP:
+ case SIOCGHWTSTAMP:
return compat_ifr_data_ioctl(net, cmd, argp);
case FIOSETOWN:
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH net-next 05/16] sfc: Implement the SIOCGHWTSTAMP ioctl
2013-12-05 23:37 Pull request: SIOCGHWTSTAMP ioctl Ben Hutchings
` (3 preceding siblings ...)
2013-12-05 23:45 ` [PATCH net-next 04/16] net_tstamp: Add SIOCGHWTSTAMP ioctl to match SIOCSHWTSTAMP Ben Hutchings
@ 2013-12-05 23:45 ` Ben Hutchings
2013-12-05 23:47 ` [PATCH net-next 06/16] bfin_mac: " Ben Hutchings
` (11 subsequent siblings)
16 siblings, 0 replies; 24+ messages in thread
From: Ben Hutchings @ 2013-12-05 23:45 UTC (permalink / raw)
To: David Miller; +Cc: netdev, linux-net-drivers, Richard Cochran
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
drivers/net/ethernet/sfc/efx.c | 4 +++-
drivers/net/ethernet/sfc/nic.h | 3 ++-
drivers/net/ethernet/sfc/ptp.c | 11 ++++++++++-
3 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c
index 07c9bc4c61bc..22ca5cd3f722 100644
--- a/drivers/net/ethernet/sfc/efx.c
+++ b/drivers/net/ethernet/sfc/efx.c
@@ -1857,7 +1857,9 @@ static int efx_ioctl(struct net_device *net_dev, struct ifreq *ifr, int cmd)
struct mii_ioctl_data *data = if_mii(ifr);
if (cmd == SIOCSHWTSTAMP)
- return efx_ptp_ioctl(efx, ifr, cmd);
+ return efx_ptp_set_ts_config(efx, ifr);
+ if (cmd == SIOCGHWTSTAMP)
+ return efx_ptp_get_ts_config(efx, ifr);
/* Convert phy_id from older PRTAD/DEVAD format */
if ((cmd == SIOCGMIIREG || cmd == SIOCSMIIREG) &&
diff --git a/drivers/net/ethernet/sfc/nic.h b/drivers/net/ethernet/sfc/nic.h
index 11b6112d9249..33852e824f12 100644
--- a/drivers/net/ethernet/sfc/nic.h
+++ b/drivers/net/ethernet/sfc/nic.h
@@ -555,7 +555,8 @@ int efx_sriov_set_vf_spoofchk(struct net_device *net_dev, int vf,
struct ethtool_ts_info;
void efx_ptp_probe(struct efx_nic *efx);
-int efx_ptp_ioctl(struct efx_nic *efx, struct ifreq *ifr, int cmd);
+int efx_ptp_set_ts_config(struct efx_nic *efx, struct ifreq *ifr);
+int efx_ptp_get_ts_config(struct efx_nic *efx, struct ifreq *ifr);
void efx_ptp_get_ts_info(struct efx_nic *efx, struct ethtool_ts_info *ts_info);
bool efx_ptp_is_ptp_tx(struct efx_nic *efx, struct sk_buff *skb);
int efx_ptp_tx(struct efx_nic *efx, struct sk_buff *skb);
diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
index 03acf57df045..afd4d3a50460 100644
--- a/drivers/net/ethernet/sfc/ptp.c
+++ b/drivers/net/ethernet/sfc/ptp.c
@@ -1231,7 +1231,7 @@ void efx_ptp_get_ts_info(struct efx_nic *efx, struct ethtool_ts_info *ts_info)
1 << HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ);
}
-int efx_ptp_ioctl(struct efx_nic *efx, struct ifreq *ifr, int cmd)
+int efx_ptp_set_ts_config(struct efx_nic *efx, struct ifreq *ifr)
{
struct hwtstamp_config config;
int rc;
@@ -1251,6 +1251,15 @@ int efx_ptp_ioctl(struct efx_nic *efx, struct ifreq *ifr, int cmd)
? -EFAULT : 0;
}
+int efx_ptp_get_ts_config(struct efx_nic *efx, struct ifreq *ifr)
+{
+ if (!efx->ptp_data)
+ return -EOPNOTSUPP;
+
+ return copy_to_user(ifr->ifr_data, &efx->ptp_data->config,
+ sizeof(efx->ptp_data->config)) ? -EFAULT : 0;
+}
+
static void ptp_event_failure(struct efx_nic *efx, int expected_frag_len)
{
struct efx_ptp_data *ptp = efx->ptp_data;
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH net-next 06/16] bfin_mac: Implement the SIOCGHWTSTAMP ioctl
2013-12-05 23:37 Pull request: SIOCGHWTSTAMP ioctl Ben Hutchings
` (4 preceding siblings ...)
2013-12-05 23:45 ` [PATCH net-next 05/16] sfc: Implement the SIOCGHWTSTAMP ioctl Ben Hutchings
@ 2013-12-05 23:47 ` Ben Hutchings
2013-12-05 23:49 ` [PATCH net-next 07/16] tg3: " Ben Hutchings
` (10 subsequent siblings)
16 siblings, 0 replies; 24+ messages in thread
From: Ben Hutchings @ 2013-12-05 23:47 UTC (permalink / raw)
To: David Miller
Cc: netdev, linux-net-drivers, Richard Cochran, uclinux-dist-devel
Compile-tested only (thanks to the kbuild test robot).
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
drivers/net/ethernet/adi/bfin_mac.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/adi/bfin_mac.c b/drivers/net/ethernet/adi/bfin_mac.c
index 75fb1d20d6fd..0d4f29579879 100644
--- a/drivers/net/ethernet/adi/bfin_mac.c
+++ b/drivers/net/ethernet/adi/bfin_mac.c
@@ -667,8 +667,8 @@ static u32 bfin_select_phc_clock(u32 input_clk, unsigned int *shift_result)
return 1000000000UL / ppn;
}
-static int bfin_mac_hwtstamp_ioctl(struct net_device *netdev,
- struct ifreq *ifr, int cmd)
+static int bfin_mac_hwtstamp_set(struct net_device *netdev,
+ struct ifreq *ifr)
{
struct hwtstamp_config config;
struct bfin_mac_local *lp = netdev_priv(netdev);
@@ -824,6 +824,16 @@ static int bfin_mac_hwtstamp_ioctl(struct net_device *netdev,
-EFAULT : 0;
}
+static int bfin_mac_hwtstamp_get(struct net_device *netdev,
+ struct ifreq *ifr)
+{
+ struct bfin_mac_local *lp = netdev_priv(netdev);
+
+ return copy_to_user(ifr->ifr_data, &lp->stamp_cfg,
+ sizeof(lp->stamp_cfg)) ?
+ -EFAULT : 0;
+}
+
static void bfin_tx_hwtstamp(struct net_device *netdev, struct sk_buff *skb)
{
struct bfin_mac_local *lp = netdev_priv(netdev);
@@ -1062,7 +1072,8 @@ static void bfin_phc_release(struct bfin_mac_local *lp)
#else
# define bfin_mac_hwtstamp_is_none(cfg) 0
# define bfin_mac_hwtstamp_init(dev)
-# define bfin_mac_hwtstamp_ioctl(dev, ifr, cmd) (-EOPNOTSUPP)
+# define bfin_mac_hwtstamp_set(dev, ifr) (-EOPNOTSUPP)
+# define bfin_mac_hwtstamp_get(dev, ifr) (-EOPNOTSUPP)
# define bfin_rx_hwtstamp(dev, skb)
# define bfin_tx_hwtstamp(dev, skb)
# define bfin_phc_init(netdev, dev) 0
@@ -1496,7 +1507,9 @@ static int bfin_mac_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
switch (cmd) {
case SIOCSHWTSTAMP:
- return bfin_mac_hwtstamp_ioctl(netdev, ifr, cmd);
+ return bfin_mac_hwtstamp_set(netdev, ifr);
+ case SIOCGHWTSTAMP:
+ return bfin_mac_hwtstamp_get(netdev, ifr);
default:
if (lp->phydev)
return phy_mii_ioctl(lp->phydev, ifr, cmd);
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH net-next 07/16] tg3: Implement the SIOCGHWTSTAMP ioctl
2013-12-05 23:37 Pull request: SIOCGHWTSTAMP ioctl Ben Hutchings
` (5 preceding siblings ...)
2013-12-05 23:47 ` [PATCH net-next 06/16] bfin_mac: " Ben Hutchings
@ 2013-12-05 23:49 ` Ben Hutchings
2013-12-06 0:14 ` Nithin Nayak Sujir
2013-12-05 23:52 ` [PATCH net-next 08/16] fec: " Ben Hutchings
` (9 subsequent siblings)
16 siblings, 1 reply; 24+ messages in thread
From: Ben Hutchings @ 2013-12-05 23:49 UTC (permalink / raw)
To: David Miller
Cc: netdev, linux-net-drivers, Richard Cochran, Nithin Nayak Sujir,
Michael Chan
While we're doing this, fix the error code for SIOCSHWTSTAMP ioctl on
non-timestamping hardware.
Compile-tested only.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
drivers/net/ethernet/broadcom/tg3.c | 71 ++++++++++++++++++++++++++++++++++---
1 file changed, 67 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index a9e068423ba0..539c6ace1706 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -13603,14 +13603,13 @@ static void tg3_self_test(struct net_device *dev, struct ethtool_test *etest,
}
-static int tg3_hwtstamp_ioctl(struct net_device *dev,
- struct ifreq *ifr, int cmd)
+static int tg3_hwtstamp_set(struct net_device *dev, struct ifreq *ifr)
{
struct tg3 *tp = netdev_priv(dev);
struct hwtstamp_config stmpconf;
if (!tg3_flag(tp, PTP_CAPABLE))
- return -EINVAL;
+ return -EOPNOTSUPP;
if (copy_from_user(&stmpconf, ifr->ifr_data, sizeof(stmpconf)))
return -EFAULT;
@@ -13691,6 +13690,67 @@ static int tg3_hwtstamp_ioctl(struct net_device *dev,
-EFAULT : 0;
}
+static int tg3_hwtstamp_get(struct net_device *dev, struct ifreq *ifr)
+{
+ struct tg3 *tp = netdev_priv(dev);
+ struct hwtstamp_config stmpconf;
+
+ if (!tg3_flag(tp, PTP_CAPABLE))
+ return -EOPNOTSUPP;
+
+ stmpconf.flags = 0;
+ stmpconf.tx_type = (tg3_flag(tp, TX_TSTAMP_EN) ?
+ HWTSTAMP_TX_ON : HWTSTAMP_TX_OFF);
+
+ switch (tp->rxptpctl) {
+ case 0:
+ stmpconf.rx_filter = HWTSTAMP_FILTER_NONE;
+ break;
+ case TG3_RX_PTP_CTL_RX_PTP_V1_EN | TG3_RX_PTP_CTL_ALL_V1_EVENTS:
+ stmpconf.rx_filter = HWTSTAMP_FILTER_PTP_V1_L4_EVENT;
+ break;
+ case TG3_RX_PTP_CTL_RX_PTP_V1_EN | TG3_RX_PTP_CTL_SYNC_EVNT:
+ stmpconf.rx_filter = HWTSTAMP_FILTER_PTP_V1_L4_SYNC;
+ break;
+ case TG3_RX_PTP_CTL_RX_PTP_V1_EN | TG3_RX_PTP_CTL_DELAY_REQ:
+ stmpconf.rx_filter = HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ;
+ break;
+ case TG3_RX_PTP_CTL_RX_PTP_V2_EN | TG3_RX_PTP_CTL_ALL_V2_EVENTS:
+ stmpconf.rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT;
+ break;
+ case TG3_RX_PTP_CTL_RX_PTP_V2_L2_EN | TG3_RX_PTP_CTL_ALL_V2_EVENTS:
+ stmpconf.rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_EVENT;
+ break;
+ case TG3_RX_PTP_CTL_RX_PTP_V2_L4_EN | TG3_RX_PTP_CTL_ALL_V2_EVENTS:
+ stmpconf.rx_filter = HWTSTAMP_FILTER_PTP_V2_L4_EVENT;
+ break;
+ case TG3_RX_PTP_CTL_RX_PTP_V2_EN | TG3_RX_PTP_CTL_SYNC_EVNT:
+ stmpconf.rx_filter = HWTSTAMP_FILTER_PTP_V2_SYNC;
+ break;
+ case TG3_RX_PTP_CTL_RX_PTP_V2_L2_EN | TG3_RX_PTP_CTL_SYNC_EVNT:
+ stmpconf.rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_SYNC;
+ break;
+ case TG3_RX_PTP_CTL_RX_PTP_V2_L4_EN | TG3_RX_PTP_CTL_SYNC_EVNT:
+ stmpconf.rx_filter = HWTSTAMP_FILTER_PTP_V2_L4_SYNC;
+ break;
+ case TG3_RX_PTP_CTL_RX_PTP_V2_EN | TG3_RX_PTP_CTL_DELAY_REQ:
+ stmpconf.rx_filter = HWTSTAMP_FILTER_PTP_V2_DELAY_REQ;
+ break;
+ case TG3_RX_PTP_CTL_RX_PTP_V2_L2_EN | TG3_RX_PTP_CTL_DELAY_REQ:
+ stmpconf.rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ;
+ break;
+ case TG3_RX_PTP_CTL_RX_PTP_V2_L4_EN | TG3_RX_PTP_CTL_DELAY_REQ:
+ stmpconf.rx_filter = HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ;
+ break;
+ default:
+ WARN_ON_ONCE(1);
+ return -ERANGE;
+ }
+
+ return copy_to_user(ifr->ifr_data, &stmpconf, sizeof(stmpconf)) ?
+ -EFAULT : 0;
+}
+
static int tg3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
{
struct mii_ioctl_data *data = if_mii(ifr);
@@ -13744,7 +13804,10 @@ static int tg3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
return err;
case SIOCSHWTSTAMP:
- return tg3_hwtstamp_ioctl(dev, ifr, cmd);
+ return tg3_hwtstamp_set(dev, ifr);
+
+ case SIOCGHWTSTAMP:
+ return tg3_hwtstamp_get(dev, ifr);
default:
/* do nothing */
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply related [flat|nested] 24+ messages in thread
* Re: [PATCH net-next 07/16] tg3: Implement the SIOCGHWTSTAMP ioctl
2013-12-05 23:49 ` [PATCH net-next 07/16] tg3: " Ben Hutchings
@ 2013-12-06 0:14 ` Nithin Nayak Sujir
0 siblings, 0 replies; 24+ messages in thread
From: Nithin Nayak Sujir @ 2013-12-06 0:14 UTC (permalink / raw)
To: Ben Hutchings, David Miller
Cc: netdev, linux-net-drivers, Richard Cochran, Michael Chan
On 12/05/2013 03:49 PM, Ben Hutchings wrote:
> While we're doing this, fix the error code for SIOCSHWTSTAMP ioctl on
> non-timestamping hardware.
>
> Compile-tested only.
>
> Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
> ---
> drivers/net/ethernet/broadcom/tg3.c | 71 ++++++++++++++++++++++++++++++++++---
> 1 file changed, 67 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
> index a9e068423ba0..539c6ace1706 100644
> --- a/drivers/net/ethernet/broadcom/tg3.c
> +++ b/drivers/net/ethernet/broadcom/tg3.c
> @@ -13603,14 +13603,13 @@ static void tg3_self_test(struct net_device *dev, struct ethtool_test *etest,
>
> }
>
> -static int tg3_hwtstamp_ioctl(struct net_device *dev,
> - struct ifreq *ifr, int cmd)
> +static int tg3_hwtstamp_set(struct net_device *dev, struct ifreq *ifr)
> {
> struct tg3 *tp = netdev_priv(dev);
> struct hwtstamp_config stmpconf;
>
> if (!tg3_flag(tp, PTP_CAPABLE))
> - return -EINVAL;
> + return -EOPNOTSUPP;
>
> if (copy_from_user(&stmpconf, ifr->ifr_data, sizeof(stmpconf)))
> return -EFAULT;
> @@ -13691,6 +13690,67 @@ static int tg3_hwtstamp_ioctl(struct net_device *dev,
> -EFAULT : 0;
> }
>
> +static int tg3_hwtstamp_get(struct net_device *dev, struct ifreq *ifr)
> +{
> + struct tg3 *tp = netdev_priv(dev);
> + struct hwtstamp_config stmpconf;
> +
> + if (!tg3_flag(tp, PTP_CAPABLE))
> + return -EOPNOTSUPP;
> +
> + stmpconf.flags = 0;
> + stmpconf.tx_type = (tg3_flag(tp, TX_TSTAMP_EN) ?
> + HWTSTAMP_TX_ON : HWTSTAMP_TX_OFF);
> +
> + switch (tp->rxptpctl) {
> + case 0:
> + stmpconf.rx_filter = HWTSTAMP_FILTER_NONE;
> + break;
> + case TG3_RX_PTP_CTL_RX_PTP_V1_EN | TG3_RX_PTP_CTL_ALL_V1_EVENTS:
> + stmpconf.rx_filter = HWTSTAMP_FILTER_PTP_V1_L4_EVENT;
> + break;
> + case TG3_RX_PTP_CTL_RX_PTP_V1_EN | TG3_RX_PTP_CTL_SYNC_EVNT:
> + stmpconf.rx_filter = HWTSTAMP_FILTER_PTP_V1_L4_SYNC;
> + break;
> + case TG3_RX_PTP_CTL_RX_PTP_V1_EN | TG3_RX_PTP_CTL_DELAY_REQ:
> + stmpconf.rx_filter = HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ;
> + break;
> + case TG3_RX_PTP_CTL_RX_PTP_V2_EN | TG3_RX_PTP_CTL_ALL_V2_EVENTS:
> + stmpconf.rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT;
> + break;
> + case TG3_RX_PTP_CTL_RX_PTP_V2_L2_EN | TG3_RX_PTP_CTL_ALL_V2_EVENTS:
> + stmpconf.rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_EVENT;
> + break;
> + case TG3_RX_PTP_CTL_RX_PTP_V2_L4_EN | TG3_RX_PTP_CTL_ALL_V2_EVENTS:
> + stmpconf.rx_filter = HWTSTAMP_FILTER_PTP_V2_L4_EVENT;
> + break;
> + case TG3_RX_PTP_CTL_RX_PTP_V2_EN | TG3_RX_PTP_CTL_SYNC_EVNT:
> + stmpconf.rx_filter = HWTSTAMP_FILTER_PTP_V2_SYNC;
> + break;
> + case TG3_RX_PTP_CTL_RX_PTP_V2_L2_EN | TG3_RX_PTP_CTL_SYNC_EVNT:
> + stmpconf.rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_SYNC;
> + break;
> + case TG3_RX_PTP_CTL_RX_PTP_V2_L4_EN | TG3_RX_PTP_CTL_SYNC_EVNT:
> + stmpconf.rx_filter = HWTSTAMP_FILTER_PTP_V2_L4_SYNC;
> + break;
> + case TG3_RX_PTP_CTL_RX_PTP_V2_EN | TG3_RX_PTP_CTL_DELAY_REQ:
> + stmpconf.rx_filter = HWTSTAMP_FILTER_PTP_V2_DELAY_REQ;
> + break;
> + case TG3_RX_PTP_CTL_RX_PTP_V2_L2_EN | TG3_RX_PTP_CTL_DELAY_REQ:
> + stmpconf.rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ;
> + break;
> + case TG3_RX_PTP_CTL_RX_PTP_V2_L4_EN | TG3_RX_PTP_CTL_DELAY_REQ:
> + stmpconf.rx_filter = HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ;
> + break;
> + default:
> + WARN_ON_ONCE(1);
> + return -ERANGE;
> + }
> +
> + return copy_to_user(ifr->ifr_data, &stmpconf, sizeof(stmpconf)) ?
> + -EFAULT : 0;
> +}
> +
> static int tg3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
> {
> struct mii_ioctl_data *data = if_mii(ifr);
> @@ -13744,7 +13804,10 @@ static int tg3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
> return err;
>
> case SIOCSHWTSTAMP:
> - return tg3_hwtstamp_ioctl(dev, ifr, cmd);
> + return tg3_hwtstamp_set(dev, ifr);
> +
> + case SIOCGHWTSTAMP:
> + return tg3_hwtstamp_get(dev, ifr);
>
> default:
> /* do nothing */
>
>
Acked-by: Nithin Nayak Sujir <nsujir@broadcom.com>
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH net-next 08/16] fec: Implement the SIOCGHWTSTAMP ioctl
2013-12-05 23:37 Pull request: SIOCGHWTSTAMP ioctl Ben Hutchings
` (6 preceding siblings ...)
2013-12-05 23:49 ` [PATCH net-next 07/16] tg3: " Ben Hutchings
@ 2013-12-05 23:52 ` Ben Hutchings
2013-12-06 3:19 ` Fugang Duan
2013-12-05 23:53 ` [PATCH net-next 09/16] gianfar: " Ben Hutchings
` (8 subsequent siblings)
16 siblings, 1 reply; 24+ messages in thread
From: Ben Hutchings @ 2013-12-05 23:52 UTC (permalink / raw)
To: David Miller
Cc: netdev, linux-net-drivers, Richard Cochran, Frank Li, Fugang Duan,
Fabio Estevam
This is untested.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
drivers/net/ethernet/freescale/fec.h | 3 ++-
drivers/net/ethernet/freescale/fec_main.c | 8 ++++++--
drivers/net/ethernet/freescale/fec_ptp.c | 16 +++++++++++++++-
3 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h
index 0120217a16dd..3b8d6d19ff05 100644
--- a/drivers/net/ethernet/freescale/fec.h
+++ b/drivers/net/ethernet/freescale/fec.h
@@ -339,7 +339,8 @@ struct fec_enet_private {
void fec_ptp_init(struct platform_device *pdev);
void fec_ptp_start_cyclecounter(struct net_device *ndev);
-int fec_ptp_ioctl(struct net_device *ndev, struct ifreq *ifr, int cmd);
+int fec_ptp_set(struct net_device *ndev, struct ifreq *ifr);
+int fec_ptp_get(struct net_device *ndev, struct ifreq *ifr);
/****************************************************************************/
#endif /* FEC_H */
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 4cbebf3d80eb..40e953e81eb5 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -1684,8 +1684,12 @@ static int fec_enet_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)
if (!phydev)
return -ENODEV;
- if (cmd == SIOCSHWTSTAMP && fep->bufdesc_ex)
- return fec_ptp_ioctl(ndev, rq, cmd);
+ if (fep->bufdesc_ex) {
+ if (cmd == SIOCSHWTSTAMP)
+ return fec_ptp_set(ndev, rq);
+ if (cmd == SIOCGHWTSTAMP)
+ return fec_ptp_get(ndev, rq);
+ }
return phy_mii_ioctl(phydev, rq, cmd);
}
diff --git a/drivers/net/ethernet/freescale/fec_ptp.c b/drivers/net/ethernet/freescale/fec_ptp.c
index 5007e4f9fff9..3a74ea48fd40 100644
--- a/drivers/net/ethernet/freescale/fec_ptp.c
+++ b/drivers/net/ethernet/freescale/fec_ptp.c
@@ -274,7 +274,7 @@ static int fec_ptp_enable(struct ptp_clock_info *ptp,
* @ifreq: ioctl data
* @cmd: particular ioctl requested
*/
-int fec_ptp_ioctl(struct net_device *ndev, struct ifreq *ifr, int cmd)
+int fec_ptp_set(struct net_device *ndev, struct ifreq *ifr)
{
struct fec_enet_private *fep = netdev_priv(ndev);
@@ -321,6 +321,20 @@ int fec_ptp_ioctl(struct net_device *ndev, struct ifreq *ifr, int cmd)
-EFAULT : 0;
}
+int fec_ptp_get(struct net_device *ndev, struct ifreq *ifr)
+{
+ struct fec_enet_private *fep = netdev_priv(ndev);
+ struct hwtstamp_config config;
+
+ config.flags = 0;
+ config.tx_type = fep->hwts_tx_en ? HWTSTAMP_TX_ON : HWTSTAMP_TX_OFF;
+ config.rx_filter = (fep->hwts_rx_en ?
+ HWTSTAMP_FILTER_ALL : HWTSTAMP_FILTER_NONE);
+
+ return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ?
+ -EFAULT : 0;
+}
+
/**
* fec_time_keep - call timecounter_read every second to avoid timer overrun
* because ENET just support 32bit counter, will timeout in 4s
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply related [flat|nested] 24+ messages in thread
* RE: [PATCH net-next 08/16] fec: Implement the SIOCGHWTSTAMP ioctl
2013-12-05 23:52 ` [PATCH net-next 08/16] fec: " Ben Hutchings
@ 2013-12-06 3:19 ` Fugang Duan
0 siblings, 0 replies; 24+ messages in thread
From: Fugang Duan @ 2013-12-06 3:19 UTC (permalink / raw)
To: Ben Hutchings, David Miller
Cc: netdev@vger.kernel.org, linux-net-drivers@solarflare.com,
Richard Cochran, Frank Li, Fabio Estevam
From: Ben Hutchings <bhutchings@solarflare.com>
Sent: Friday, December 06, 2013 7:53 AM
>To: David Miller
>Cc: netdev@vger.kernel.org; linux-net-drivers@solarflare.com; Richard Cochran;
>Frank Li; Duan Fugang-B38611; Estevam Fabio-R49496
>Subject: [PATCH net-next 08/16] fec: Implement the SIOCGHWTSTAMP ioctl
>
>This is untested.
>
>Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
>---
> drivers/net/ethernet/freescale/fec.h | 3 ++-
> drivers/net/ethernet/freescale/fec_main.c | 8 ++++++--
>drivers/net/ethernet/freescale/fec_ptp.c | 16 +++++++++++++++-
> 3 files changed, 23 insertions(+), 4 deletions(-)
>
>diff --git a/drivers/net/ethernet/freescale/fec.h
>b/drivers/net/ethernet/freescale/fec.h
>index 0120217a16dd..3b8d6d19ff05 100644
>--- a/drivers/net/ethernet/freescale/fec.h
>+++ b/drivers/net/ethernet/freescale/fec.h
>@@ -339,7 +339,8 @@ struct fec_enet_private {
>
> void fec_ptp_init(struct platform_device *pdev); void
>fec_ptp_start_cyclecounter(struct net_device *ndev); -int fec_ptp_ioctl(struct
>net_device *ndev, struct ifreq *ifr, int cmd);
>+int fec_ptp_set(struct net_device *ndev, struct ifreq *ifr); int
>+fec_ptp_get(struct net_device *ndev, struct ifreq *ifr);
>
> /****************************************************************************/
> #endif /* FEC_H */
>diff --git a/drivers/net/ethernet/freescale/fec_main.c
>b/drivers/net/ethernet/freescale/fec_main.c
>index 4cbebf3d80eb..40e953e81eb5 100644
>--- a/drivers/net/ethernet/freescale/fec_main.c
>+++ b/drivers/net/ethernet/freescale/fec_main.c
>@@ -1684,8 +1684,12 @@ static int fec_enet_ioctl(struct net_device *ndev,
>struct ifreq *rq, int cmd)
> if (!phydev)
> return -ENODEV;
>
>- if (cmd == SIOCSHWTSTAMP && fep->bufdesc_ex)
>- return fec_ptp_ioctl(ndev, rq, cmd);
>+ if (fep->bufdesc_ex) {
>+ if (cmd == SIOCSHWTSTAMP)
>+ return fec_ptp_set(ndev, rq);
>+ if (cmd == SIOCGHWTSTAMP)
>+ return fec_ptp_get(ndev, rq);
>+ }
>
> return phy_mii_ioctl(phydev, rq, cmd); } diff --git
>a/drivers/net/ethernet/freescale/fec_ptp.c
>b/drivers/net/ethernet/freescale/fec_ptp.c
>index 5007e4f9fff9..3a74ea48fd40 100644
>--- a/drivers/net/ethernet/freescale/fec_ptp.c
>+++ b/drivers/net/ethernet/freescale/fec_ptp.c
>@@ -274,7 +274,7 @@ static int fec_ptp_enable(struct ptp_clock_info *ptp,
> * @ifreq: ioctl data
> * @cmd: particular ioctl requested
> */
>-int fec_ptp_ioctl(struct net_device *ndev, struct ifreq *ifr, int cmd)
>+int fec_ptp_set(struct net_device *ndev, struct ifreq *ifr)
> {
> struct fec_enet_private *fep = netdev_priv(ndev);
>
>@@ -321,6 +321,20 @@ int fec_ptp_ioctl(struct net_device *ndev, struct ifreq
>*ifr, int cmd)
> -EFAULT : 0;
> }
>
>+int fec_ptp_get(struct net_device *ndev, struct ifreq *ifr) {
>+ struct fec_enet_private *fep = netdev_priv(ndev);
>+ struct hwtstamp_config config;
>+
>+ config.flags = 0;
>+ config.tx_type = fep->hwts_tx_en ? HWTSTAMP_TX_ON : HWTSTAMP_TX_OFF;
>+ config.rx_filter = (fep->hwts_rx_en ?
>+ HWTSTAMP_FILTER_ALL : HWTSTAMP_FILTER_NONE);
>+
>+ return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ?
>+ -EFAULT : 0;
>+}
>+
> /**
> * fec_time_keep - call timecounter_read every second to avoid timer overrun
> * because ENET just support 32bit counter, will timeout in 4s
>
>
After apply the patch set, and test Linuxptp stack show it work fine, test result as below:
...
ptp4l[260.495]: master offset 17 s2 adj -85012 path delay 703
ptp4l[260.744]: master offset 0 s2 adj -85024 path delay 705
ptp4l[260.993]: master offset -57 s2 adj -85081 path delay 710
ptp4l[261.242]: master offset -13 s2 adj -85054 path delay 709
ptp4l[261.490]: master offset 5 s2 adj -85040 path delay 708
ptp4l[261.739]: master offset -42 s2 adj -85085 path delay 707
ptp4l[261.988]: master offset -19 s2 adj -85075 path delay 707
ptp4l[262.236]: master offset 41 s2 adj -85021 path delay 704
ptp4l[262.484]: master offset -11 s2 adj -85060 path delay 704
ptp4l[262.733]: master offset 10 s2 adj -85043 path delay 701
ptp4l[262.982]: master offset 23 s2 adj -85027 path delay 701
ptp4l[263.231]: master offset -27 s2 adj -85070 path delay 700
ptp4l[263.479]: master offset 19 s2 adj -85032 path delay 695
ptp4l[263.728]: master offset -14 s2 adj -85059 path delay 698
ptp4l[263.976]: master offset 40 s2 adj -85009 path delay 697
ptp4l[264.225]: master offset 26 s2 adj -85011 path delay 697
ptp4l[264.473]: master offset 30 s2 adj -85000 path delay 699
ptp4l[264.722]: master offset -32 s2 adj -85053 path delay 704
ptp4l[264.971]: master offset 23 s2 adj -85007 path delay 704
ptp4l[265.220]: master offset 5 s2 adj -85018 path delay 708
ptp4l[265.468]: master offset -71 s2 adj -85093 path delay 711
ptp4l[265.716]: master offset -7 s2 adj -85050 path delay 708
ptp4l[265.965]: master offset -31 s2 adj -85076 path delay 708
ptp4l[266.214]: master offset -29 s2 adj -85084 path delay 708
ptp4l[266.462]: master offset 16 s2 adj -85047 path delay 707
ptp4l[266.711]: master offset -30 s2 adj -85088 path delay 708
ptp4l[266.960]: master offset -5 s2 adj -85072 path delay 708
...
Tested-by: Fugang Duan <B38611@freescale.com>
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH net-next 09/16] gianfar: Implement the SIOCGHWTSTAMP ioctl
2013-12-05 23:37 Pull request: SIOCGHWTSTAMP ioctl Ben Hutchings
` (7 preceding siblings ...)
2013-12-05 23:52 ` [PATCH net-next 08/16] fec: " Ben Hutchings
@ 2013-12-05 23:53 ` Ben Hutchings
2013-12-05 23:54 ` [PATCH net-next 10/16] e1000e: " Ben Hutchings
` (7 subsequent siblings)
16 siblings, 0 replies; 24+ messages in thread
From: Ben Hutchings @ 2013-12-05 23:53 UTC (permalink / raw)
To: David Miller; +Cc: netdev, linux-net-drivers, Richard Cochran, Claudiu Manoil
This is untested.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
drivers/net/ethernet/freescale/gianfar.c | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
index b14d7904a075..365342d293e8 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -795,8 +795,7 @@ err_grp_init:
return err;
}
-static int gfar_hwtstamp_ioctl(struct net_device *netdev,
- struct ifreq *ifr, int cmd)
+static int gfar_hwtstamp_set(struct net_device *netdev, struct ifreq *ifr)
{
struct hwtstamp_config config;
struct gfar_private *priv = netdev_priv(netdev);
@@ -845,7 +844,20 @@ static int gfar_hwtstamp_ioctl(struct net_device *netdev,
-EFAULT : 0;
}
-/* Ioctl MII Interface */
+static int gfar_hwtstamp_get(struct net_device *netdev, struct ifreq *ifr)
+{
+ struct hwtstamp_config config;
+ struct gfar_private *priv = netdev_priv(netdev);
+
+ config.flags = 0;
+ config.tx_type = priv->hwts_tx_en ? HWTSTAMP_TX_ON : HWTSTAMP_TX_OFF;
+ config.rx_filter = (priv->hwts_rx_en ?
+ HWTSTAMP_FILTER_ALL : HWTSTAMP_FILTER_NONE);
+
+ return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ?
+ -EFAULT : 0;
+}
+
static int gfar_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{
struct gfar_private *priv = netdev_priv(dev);
@@ -854,7 +866,9 @@ static int gfar_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
return -EINVAL;
if (cmd == SIOCSHWTSTAMP)
- return gfar_hwtstamp_ioctl(dev, rq, cmd);
+ return gfar_hwtstamp_set(dev, rq);
+ if (cmd == SIOCGHWTSTAMP)
+ return gfar_hwtstamp_get(dev, rq);
if (!priv->phydev)
return -ENODEV;
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH net-next 10/16] e1000e: Implement the SIOCGHWTSTAMP ioctl
2013-12-05 23:37 Pull request: SIOCGHWTSTAMP ioctl Ben Hutchings
` (8 preceding siblings ...)
2013-12-05 23:53 ` [PATCH net-next 09/16] gianfar: " Ben Hutchings
@ 2013-12-05 23:54 ` Ben Hutchings
2013-12-05 23:54 ` [PATCH net-next 11/16] mlx4_en: " Ben Hutchings
` (6 subsequent siblings)
16 siblings, 0 replies; 24+ messages in thread
From: Ben Hutchings @ 2013-12-05 23:54 UTC (permalink / raw)
To: David Miller; +Cc: netdev, linux-net-drivers, Richard Cochran, e1000-devel
Compile-tested only.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
drivers/net/ethernet/intel/e1000e/netdev.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
index f02816575369..03e6af736de4 100644
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
@@ -5790,7 +5790,7 @@ static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,
* specified. Matching the kind of event packet is not supported, with the
* exception of "all V2 events regardless of level 2 or 4".
**/
-static int e1000e_hwtstamp_ioctl(struct net_device *netdev, struct ifreq *ifr)
+static int e1000e_hwtstamp_set(struct net_device *netdev, struct ifreq *ifr)
{
struct e1000_adapter *adapter = netdev_priv(netdev);
struct hwtstamp_config config;
@@ -5825,6 +5825,14 @@ static int e1000e_hwtstamp_ioctl(struct net_device *netdev, struct ifreq *ifr)
sizeof(config)) ? -EFAULT : 0;
}
+static int e1000e_hwtstamp_get(struct net_device *netdev, struct ifreq *ifr)
+{
+ struct e1000_adapter *adapter = netdev_priv(netdev);
+
+ return copy_to_user(ifr->ifr_data, &adapter->hwtstamp_config,
+ sizeof(adapter->hwtstamp_config)) ? -EFAULT : 0;
+}
+
static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
{
switch (cmd) {
@@ -5833,7 +5841,9 @@ static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
case SIOCSMIIREG:
return e1000_mii_ioctl(netdev, ifr, cmd);
case SIOCSHWTSTAMP:
- return e1000e_hwtstamp_ioctl(netdev, ifr);
+ return e1000e_hwtstamp_set(netdev, ifr);
+ case SIOCGHWTSTAMP:
+ return e1000e_hwtstamp_get(netdev, ifr);
default:
return -EOPNOTSUPP;
}
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH net-next 11/16] mlx4_en: Implement the SIOCGHWTSTAMP ioctl
2013-12-05 23:37 Pull request: SIOCGHWTSTAMP ioctl Ben Hutchings
` (9 preceding siblings ...)
2013-12-05 23:54 ` [PATCH net-next 10/16] e1000e: " Ben Hutchings
@ 2013-12-05 23:54 ` Ben Hutchings
2013-12-05 23:55 ` [PATCH net-next 12/16] vxge: " Ben Hutchings
` (5 subsequent siblings)
16 siblings, 0 replies; 24+ messages in thread
From: Ben Hutchings @ 2013-12-05 23:54 UTC (permalink / raw)
To: David Miller; +Cc: netdev, linux-net-drivers, Richard Cochran, Amir Vadai
Compile-tested only.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index e72d8a112a6b..709e5ec5ce14 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -2025,7 +2025,7 @@ static int mlx4_en_change_mtu(struct net_device *dev, int new_mtu)
return 0;
}
-static int mlx4_en_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr)
+static int mlx4_en_hwtstamp_set(struct net_device *dev, struct ifreq *ifr)
{
struct mlx4_en_priv *priv = netdev_priv(dev);
struct mlx4_en_dev *mdev = priv->mdev;
@@ -2084,11 +2084,21 @@ static int mlx4_en_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr)
sizeof(config)) ? -EFAULT : 0;
}
+static int mlx4_en_hwtstamp_get(struct net_device *dev, struct ifreq *ifr)
+{
+ struct mlx4_en_priv *priv = netdev_priv(dev);
+
+ return copy_to_user(ifr->ifr_data, &priv->hwtstamp_config,
+ sizeof(priv->hwtstamp_config)) ? -EFAULT : 0;
+}
+
static int mlx4_en_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
{
switch (cmd) {
case SIOCSHWTSTAMP:
- return mlx4_en_hwtstamp_ioctl(dev, ifr);
+ return mlx4_en_hwtstamp_set(dev, ifr);
+ case SIOCGHWTSTAMP:
+ return mlx4_en_hwtstamp_get(dev, ifr);
default:
return -EOPNOTSUPP;
}
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH net-next 12/16] vxge: Implement the SIOCGHWTSTAMP ioctl
2013-12-05 23:37 Pull request: SIOCGHWTSTAMP ioctl Ben Hutchings
` (10 preceding siblings ...)
2013-12-05 23:54 ` [PATCH net-next 11/16] mlx4_en: " Ben Hutchings
@ 2013-12-05 23:55 ` Ben Hutchings
2013-12-05 23:56 ` [PATCH net-next 13/16] ti_cpsw: " Ben Hutchings
` (4 subsequent siblings)
16 siblings, 0 replies; 24+ messages in thread
From: Ben Hutchings @ 2013-12-05 23:55 UTC (permalink / raw)
To: David Miller; +Cc: netdev, linux-net-drivers, Richard Cochran, Jon Mason
Compile-tested only.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
drivers/net/ethernet/neterion/vxge/vxge-main.c | 27 ++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/neterion/vxge/vxge-main.c b/drivers/net/ethernet/neterion/vxge/vxge-main.c
index 8614eeb7de81..33f98eca5dc3 100644
--- a/drivers/net/ethernet/neterion/vxge/vxge-main.c
+++ b/drivers/net/ethernet/neterion/vxge/vxge-main.c
@@ -3185,7 +3185,7 @@ static enum vxge_hw_status vxge_timestamp_config(struct __vxge_hw_device *devh)
return status;
}
-static int vxge_hwtstamp_ioctl(struct vxgedev *vdev, void __user *data)
+static int vxge_hwtstamp_set(struct vxgedev *vdev, void __user *data)
{
struct hwtstamp_config config;
int i;
@@ -3246,6 +3246,21 @@ static int vxge_hwtstamp_ioctl(struct vxgedev *vdev, void __user *data)
return 0;
}
+static int vxge_hwtstamp_get(struct vxgedev *vdev, void __user *data)
+{
+ struct hwtstamp_config config;
+
+ config.flags = 0;
+ config.tx_type = HWTSTAMP_TX_OFF;
+ config.rx_filter = (vdev->rx_hwts ?
+ HWTSTAMP_FILTER_ALL : HWTSTAMP_FILTER_NONE);
+
+ if (copy_to_user(data, &config, sizeof(config)))
+ return -EFAULT;
+
+ return 0;
+}
+
/**
* vxge_ioctl
* @dev: Device pointer.
@@ -3259,19 +3274,15 @@ static int vxge_hwtstamp_ioctl(struct vxgedev *vdev, void __user *data)
static int vxge_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{
struct vxgedev *vdev = netdev_priv(dev);
- int ret;
switch (cmd) {
case SIOCSHWTSTAMP:
- ret = vxge_hwtstamp_ioctl(vdev, rq->ifr_data);
- if (ret)
- return ret;
- break;
+ return vxge_hwtstamp_set(vdev, rq->ifr_data);
+ case SIOCGHWTSTAMP:
+ return vxge_hwtstamp_get(vdev, rq->ifr_data);
default:
return -EOPNOTSUPP;
}
-
- return 0;
}
/**
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH net-next 13/16] ti_cpsw: Implement the SIOCGHWTSTAMP ioctl
2013-12-05 23:37 Pull request: SIOCGHWTSTAMP ioctl Ben Hutchings
` (11 preceding siblings ...)
2013-12-05 23:55 ` [PATCH net-next 12/16] vxge: " Ben Hutchings
@ 2013-12-05 23:56 ` Ben Hutchings
2013-12-05 23:57 ` [PATCH net-next 14/16] tile_net: " Ben Hutchings
` (3 subsequent siblings)
16 siblings, 0 replies; 24+ messages in thread
From: Ben Hutchings @ 2013-12-05 23:56 UTC (permalink / raw)
To: David Miller; +Cc: netdev, linux-net-drivers, Richard Cochran, Mugunthan V N
This is untested.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
drivers/net/ethernet/ti/cpsw.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 7536a4c01293..bc0cb154fc53 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -1322,7 +1322,7 @@ static void cpsw_hwtstamp_v2(struct cpsw_priv *priv)
__raw_writel(ETH_P_1588, &priv->regs->ts_ltype);
}
-static int cpsw_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr)
+static int cpsw_hwtstamp_set(struct net_device *dev, struct ifreq *ifr)
{
struct cpsw_priv *priv = netdev_priv(dev);
struct cpts *cpts = priv->cpts;
@@ -1383,6 +1383,24 @@ static int cpsw_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr)
return copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0;
}
+static int cpsw_hwtstamp_get(struct net_device *dev, struct ifreq *ifr)
+{
+ struct cpsw_priv *priv = netdev_priv(dev);
+ struct cpts *cpts = priv->cpts;
+ struct hwtstamp_config cfg;
+
+ if (priv->version != CPSW_VERSION_1 &&
+ priv->version != CPSW_VERSION_2)
+ return -EOPNOTSUPP;
+
+ cfg.flags = 0;
+ cfg.tx_type = cpts->tx_enable ? HWTSTAMP_TX_ON : HWTSTAMP_TX_OFF;
+ cfg.rx_filter = (cpts->rx_enable ?
+ HWTSTAMP_FILTER_PTP_V2_EVENT : HWTSTAMP_FILTER_NONE);
+
+ return copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0;
+}
+
#endif /*CONFIG_TI_CPTS*/
static int cpsw_ndo_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
@@ -1397,7 +1415,9 @@ static int cpsw_ndo_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
switch (cmd) {
#ifdef CONFIG_TI_CPTS
case SIOCSHWTSTAMP:
- return cpsw_hwtstamp_ioctl(dev, req);
+ return cpsw_hwtstamp_set(dev, req);
+ case SIOCGHWTSTAMP:
+ return cpsw_hwtstamp_get(dev, req);
#endif
case SIOCGMIIPHY:
data->phy_id = priv->slaves[slave_no].phy->addr;
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH net-next 14/16] tile_net: Implement the SIOCGHWTSTAMP ioctl
2013-12-05 23:37 Pull request: SIOCGHWTSTAMP ioctl Ben Hutchings
` (12 preceding siblings ...)
2013-12-05 23:56 ` [PATCH net-next 13/16] ti_cpsw: " Ben Hutchings
@ 2013-12-05 23:57 ` Ben Hutchings
2013-12-09 19:39 ` Chris Metcalf
2013-12-05 23:57 ` [PATCH net-next 15/16] ixp4xx_eth: " Ben Hutchings
` (2 subsequent siblings)
16 siblings, 1 reply; 24+ messages in thread
From: Ben Hutchings @ 2013-12-05 23:57 UTC (permalink / raw)
To: David Miller; +Cc: netdev, linux-net-drivers, Richard Cochran, Chris Metcalf
Compile-tested only (thanks to the kbuild test robot).
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
drivers/net/ethernet/tile/tilegx.c | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/tile/tilegx.c b/drivers/net/ethernet/tile/tilegx.c
index 628b736e5ae7..858f9a786b8c 100644
--- a/drivers/net/ethernet/tile/tilegx.c
+++ b/drivers/net/ethernet/tile/tilegx.c
@@ -481,8 +481,7 @@ static void tile_tx_timestamp(struct sk_buff *skb, int instance)
}
/* Use ioctl() to enable or disable TX or RX timestamping. */
-static int tile_hwtstamp_ioctl(struct net_device *dev, struct ifreq *rq,
- int cmd)
+static int tile_hwtstamp_set(struct net_device *dev, struct ifreq *rq)
{
#ifdef CONFIG_PTP_1588_CLOCK_TILEGX
struct hwtstamp_config config;
@@ -535,6 +534,21 @@ static int tile_hwtstamp_ioctl(struct net_device *dev, struct ifreq *rq,
#endif
}
+static int tile_hwtstamp_get(struct net_device *dev, struct ifreq *rq)
+{
+#ifdef CONFIG_PTP_1588_CLOCK_TILEGX
+ struct tile_net_priv *priv = netdev_priv(dev);
+
+ if (copy_to_user(rq->ifr_data, &priv->stamp_cfg,
+ sizeof(priv->stamp_cfg)))
+ return -EFAULT;
+
+ return 0;
+#else
+ return -EOPNOTSUPP;
+#endif
+}
+
static inline bool filter_packet(struct net_device *dev, void *buf)
{
/* Filter packets received before we're up. */
@@ -2098,7 +2112,9 @@ static void tile_net_tx_timeout(struct net_device *dev)
static int tile_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{
if (cmd == SIOCSHWTSTAMP)
- return tile_hwtstamp_ioctl(dev, rq, cmd);
+ return tile_hwtstamp_set(dev, rq);
+ if (cmd == SIOCGHWTSTAMP)
+ return tile_hwtstamp_get(dev, rq);
return -EOPNOTSUPP;
}
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH net-next 15/16] ixp4xx_eth: Implement the SIOCGHWTSTAMP ioctl
2013-12-05 23:37 Pull request: SIOCGHWTSTAMP ioctl Ben Hutchings
` (13 preceding siblings ...)
2013-12-05 23:57 ` [PATCH net-next 14/16] tile_net: " Ben Hutchings
@ 2013-12-05 23:57 ` Ben Hutchings
2013-12-05 23:58 ` [PATCH net-next 16/16] net_tstamp,doc: Add test program for SIOC{G,S}HWTSTAMP Ben Hutchings
2013-12-06 0:46 ` Pull request: SIOCGHWTSTAMP ioctl David Miller
16 siblings, 0 replies; 24+ messages in thread
From: Ben Hutchings @ 2013-12-05 23:57 UTC (permalink / raw)
To: David Miller; +Cc: netdev, linux-net-drivers, Richard Cochran, Krzysztof Halasa
This is untested.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
drivers/net/ethernet/xscale/ixp4xx_eth.c | 36 +++++++++++++++++++++++++++++---
1 file 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)
__raw_writel(TX_SNAPSHOT_LOCKED, ®s->channel[ch].ch_event);
}
-static int hwtstamp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
+static int hwtstamp_set(struct net_device *netdev, struct ifreq *ifr)
{
struct hwtstamp_config cfg;
struct ixp46x_ts_regs *regs;
@@ -417,6 +417,32 @@ static int hwtstamp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
return copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0;
}
+static int hwtstamp_get(struct net_device *netdev, struct ifreq *ifr)
+{
+ struct hwtstamp_config cfg;
+ struct port *port = netdev_priv(netdev);
+
+ cfg.flags = 0;
+ cfg.tx_type = port->hwts_tx_en ? HWTSTAMP_TX_ON : HWTSTAMP_TX_OFF;
+
+ switch (port->hwts_rx_en) {
+ case 0:
+ cfg.rx_filter = HWTSTAMP_FILTER_NONE;
+ break;
+ case PTP_SLAVE_MODE:
+ cfg.rx_filter = HWTSTAMP_FILTER_PTP_V1_L4_SYNC;
+ break;
+ case PTP_MASTER_MODE:
+ cfg.rx_filter = HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ;
+ break;
+ default:
+ WARN_ON_ONCE(1);
+ return -ERANGE;
+ }
+
+ return copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0;
+}
+
static int ixp4xx_mdio_cmd(struct mii_bus *bus, int phy_id, int location,
int write, u16 cmd)
{
@@ -959,8 +985,12 @@ static int eth_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
if (!netif_running(dev))
return -EINVAL;
- if (cpu_is_ixp46x() && cmd == SIOCSHWTSTAMP)
- return hwtstamp_ioctl(dev, req, cmd);
+ if (cpu_is_ixp46x()) {
+ if (cmd == SIOCSHWTSTAMP)
+ return hwtstamp_set(dev, req);
+ if (cmd == SIOCGHWTSTAMP)
+ return hwtstamp_get(dev, req);
+ }
return phy_mii_ioctl(port->phydev, req, cmd);
}
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH net-next 16/16] net_tstamp,doc: Add test program for SIOC{G,S}HWTSTAMP
2013-12-05 23:37 Pull request: SIOCGHWTSTAMP ioctl Ben Hutchings
` (14 preceding siblings ...)
2013-12-05 23:57 ` [PATCH net-next 15/16] ixp4xx_eth: " Ben Hutchings
@ 2013-12-05 23:58 ` Ben Hutchings
2013-12-06 0:46 ` Pull request: SIOCGHWTSTAMP ioctl David Miller
16 siblings, 0 replies; 24+ messages in thread
From: Ben Hutchings @ 2013-12-05 23:58 UTC (permalink / raw)
To: David Miller; +Cc: netdev, linux-net-drivers, Richard Cochran
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
Documentation/networking/timestamping/.gitignore | 1 +
Documentation/networking/timestamping/Makefile | 5 +-
.../networking/timestamping/hwtstamp_config.c | 134 +++++++++++++++++++++
3 files changed, 138 insertions(+), 2 deletions(-)
create mode 100644 Documentation/networking/timestamping/hwtstamp_config.c
diff --git a/Documentation/networking/timestamping/.gitignore b/Documentation/networking/timestamping/.gitignore
index 71e81eb2e22f..a380159765ce 100644
--- a/Documentation/networking/timestamping/.gitignore
+++ b/Documentation/networking/timestamping/.gitignore
@@ -1 +1,2 @@
timestamping
+hwtstamp_config
diff --git a/Documentation/networking/timestamping/Makefile b/Documentation/networking/timestamping/Makefile
index e79973443e9f..d934afc8306a 100644
--- a/Documentation/networking/timestamping/Makefile
+++ b/Documentation/networking/timestamping/Makefile
@@ -2,12 +2,13 @@
obj- := dummy.o
# List of programs to build
-hostprogs-y := timestamping
+hostprogs-y := timestamping hwtstamp_config
# Tell kbuild to always build the programs
always := $(hostprogs-y)
HOSTCFLAGS_timestamping.o += -I$(objtree)/usr/include
+HOSTCFLAGS_hwtstamp_config.o += -I$(objtree)/usr/include
clean:
- rm -f timestamping
+ rm -f timestamping hwtstamp_config
diff --git a/Documentation/networking/timestamping/hwtstamp_config.c b/Documentation/networking/timestamping/hwtstamp_config.c
new file mode 100644
index 000000000000..e8b685a7f15f
--- /dev/null
+++ b/Documentation/networking/timestamping/hwtstamp_config.c
@@ -0,0 +1,134 @@
+/* Test program for SIOC{G,S}HWTSTAMP
+ * Copyright 2013 Solarflare Communications
+ * Author: Ben Hutchings
+ */
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+
+#include <linux/if.h>
+#include <linux/net_tstamp.h>
+#include <linux/sockios.h>
+
+static int
+lookup_value(const char **names, int size, const char *name)
+{
+ int value;
+
+ for (value = 0; value < size; value++)
+ if (names[value] && strcasecmp(names[value], name) == 0)
+ return value;
+
+ return -1;
+}
+
+static const char *
+lookup_name(const char **names, int size, int value)
+{
+ return (value >= 0 && value < size) ? names[value] : NULL;
+}
+
+static void list_names(FILE *f, const char **names, int size)
+{
+ int value;
+
+ for (value = 0; value < size; value++)
+ if (names[value])
+ fprintf(f, " %s\n", names[value]);
+}
+
+static const char *tx_types[] = {
+#define TX_TYPE(name) [HWTSTAMP_TX_ ## name] = #name
+ TX_TYPE(OFF),
+ TX_TYPE(ON),
+ TX_TYPE(ONESTEP_SYNC)
+#undef TX_TYPE
+};
+#define N_TX_TYPES ((int)(sizeof(tx_types) / sizeof(tx_types[0])))
+
+static const char *rx_filters[] = {
+#define RX_FILTER(name) [HWTSTAMP_FILTER_ ## name] = #name
+ RX_FILTER(NONE),
+ RX_FILTER(ALL),
+ RX_FILTER(SOME),
+ RX_FILTER(PTP_V1_L4_EVENT),
+ RX_FILTER(PTP_V1_L4_SYNC),
+ RX_FILTER(PTP_V1_L4_DELAY_REQ),
+ RX_FILTER(PTP_V2_L4_EVENT),
+ RX_FILTER(PTP_V2_L4_SYNC),
+ RX_FILTER(PTP_V2_L4_DELAY_REQ),
+ RX_FILTER(PTP_V2_L2_EVENT),
+ RX_FILTER(PTP_V2_L2_SYNC),
+ RX_FILTER(PTP_V2_L2_DELAY_REQ),
+ RX_FILTER(PTP_V2_EVENT),
+ RX_FILTER(PTP_V2_SYNC),
+ RX_FILTER(PTP_V2_DELAY_REQ),
+#undef RX_FILTER
+};
+#define N_RX_FILTERS ((int)(sizeof(rx_filters) / sizeof(rx_filters[0])))
+
+static void usage(void)
+{
+ fputs("Usage: hwtstamp_config if_name [tx_type rx_filter]\n"
+ "tx_type is any of (case-insensitive):\n",
+ stderr);
+ list_names(stderr, tx_types, N_TX_TYPES);
+ fputs("rx_filter is any of (case-insensitive):\n", stderr);
+ list_names(stderr, rx_filters, N_RX_FILTERS);
+}
+
+int main(int argc, char **argv)
+{
+ struct ifreq ifr;
+ struct hwtstamp_config config;
+ const char *name;
+ int sock;
+
+ if ((argc != 2 && argc != 4) || (strlen(argv[1]) >= IFNAMSIZ)) {
+ usage();
+ return 2;
+ }
+
+ if (argc == 4) {
+ config.flags = 0;
+ config.tx_type = lookup_value(tx_types, N_TX_TYPES, argv[2]);
+ config.rx_filter = lookup_value(rx_filters, N_RX_FILTERS, argv[3]);
+ if (config.tx_type < 0 || config.rx_filter < 0) {
+ usage();
+ return 2;
+ }
+ }
+
+ sock = socket(AF_INET, SOCK_DGRAM, 0);
+ if (sock < 0) {
+ perror("socket");
+ return 1;
+ }
+
+ strcpy(ifr.ifr_name, argv[1]);
+ ifr.ifr_data = (caddr_t)&config;
+
+ if (ioctl(sock, (argc == 2) ? SIOCGHWTSTAMP : SIOCSHWTSTAMP, &ifr)) {
+ perror("ioctl");
+ return 1;
+ }
+
+ printf("flags = %#x\n", config.flags);
+ name = lookup_name(tx_types, N_TX_TYPES, config.tx_type);
+ if (name)
+ printf("tx_type = %s\n", name);
+ else
+ printf("tx_type = %d\n", config.tx_type);
+ name = lookup_name(rx_filters, N_RX_FILTERS, config.rx_filter);
+ if (name)
+ printf("rx_filter = %s\n", name);
+ else
+ printf("rx_filter = %d\n", config.rx_filter);
+
+ return 0;
+}
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply related [flat|nested] 24+ messages in thread
* Re: Pull request: SIOCGHWTSTAMP ioctl
2013-12-05 23:37 Pull request: SIOCGHWTSTAMP ioctl Ben Hutchings
` (15 preceding siblings ...)
2013-12-05 23:58 ` [PATCH net-next 16/16] net_tstamp,doc: Add test program for SIOC{G,S}HWTSTAMP Ben Hutchings
@ 2013-12-06 0:46 ` David Miller
2013-12-06 17:38 ` Ben Hutchings
16 siblings, 1 reply; 24+ messages in thread
From: David Miller @ 2013-12-06 0:46 UTC (permalink / raw)
To: bhutchings; +Cc: linux-net-drivers, netdev, richardcochran
From: Ben Hutchings <bhutchings@solarflare.com>
Date: Thu, 5 Dec 2013 23:37:12 +0000
> 1. Add the SIOCGHWTSTAMP ioctl and update the timestamping
> documentation.
> 2. Implement SIOCGHWTSTAMP in most drivers that support SIOCSHWTSTAMP.
> 3. Add a test program to exercise SIOC{G,S}HWTSTAMP.
Pulled, thanks Ben.
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: Pull request: SIOCGHWTSTAMP ioctl
2013-12-06 0:46 ` Pull request: SIOCGHWTSTAMP ioctl David Miller
@ 2013-12-06 17:38 ` Ben Hutchings
2013-12-06 17:41 ` David Daney
2013-12-07 7:30 ` [E1000-devel] " Jeff Kirsher
0 siblings, 2 replies; 24+ messages in thread
From: Ben Hutchings @ 2013-12-06 17:38 UTC (permalink / raw)
To: David Miller, richardcochran
Cc: netdev, e1000-devel, David Daney, Veaceslav Falico,
Takahiro Shimizu, Giuseppe Cavallaro
On Thu, 2013-12-05 at 19:46 -0500, David Miller wrote:
> From: Ben Hutchings <bhutchings@solarflare.com>
> Date: Thu, 5 Dec 2013 23:37:12 +0000
>
> > 1. Add the SIOCGHWTSTAMP ioctl and update the timestamping
> > documentation.
> > 2. Implement SIOCGHWTSTAMP in most drivers that support SIOCSHWTSTAMP.
> > 3. Add a test program to exercise SIOC{G,S}HWTSTAMP.
>
> Pulled, thanks Ben.
Thanks. I hope all the drivers still work, as you didn't leave long for
review.
There are a few drivers I didn't touch because they don't appear to keep
a soft copy of the timestamp configuration:
drivers/net/ethernet/intel/igb/igb_main.c
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
drivers/net/ethernet/octeon/octeon_mgmt.c
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
phylib and the dp83640 driver will also need to be updated to support
this.
Ben.
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: Pull request: SIOCGHWTSTAMP ioctl
2013-12-06 17:38 ` Ben Hutchings
@ 2013-12-06 17:41 ` David Daney
2013-12-07 7:30 ` [E1000-devel] " Jeff Kirsher
1 sibling, 0 replies; 24+ messages in thread
From: David Daney @ 2013-12-06 17:41 UTC (permalink / raw)
To: Ben Hutchings
Cc: Veaceslav Falico, David Daney, e1000-devel, netdev,
Takahiro Shimizu, Giuseppe Cavallaro, David Miller
On 12/06/2013 09:38 AM, Ben Hutchings wrote:
> On Thu, 2013-12-05 at 19:46 -0500, David Miller wrote:
>> From: Ben Hutchings <bhutchings@solarflare.com>
>> Date: Thu, 5 Dec 2013 23:37:12 +0000
>>
>>> 1. Add the SIOCGHWTSTAMP ioctl and update the timestamping
>>> documentation.
>>> 2. Implement SIOCGHWTSTAMP in most drivers that support SIOCSHWTSTAMP.
>>> 3. Add a test program to exercise SIOC{G,S}HWTSTAMP.
>>
>> Pulled, thanks Ben.
>
> Thanks. I hope all the drivers still work, as you didn't leave long for
> review.
>
> There are a few drivers I didn't touch because they don't appear to keep
> a soft copy of the timestamp configuration:
>
> drivers/net/ethernet/intel/igb/igb_main.c
> drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
> drivers/net/ethernet/octeon/octeon_mgmt.c
I will look at modifying octeon_mgmt to support this.
Thanks,
David Daney
> drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
>
> phylib and the dp83640 driver will also need to be updated to support
> this.
>
> Ben.
>
------------------------------------------------------------------------------
Sponsored by Intel(R) XDK
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
E1000-devel mailing list
E1000-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel® Ethernet, visit http://communities.intel.com/community/wired
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [E1000-devel] Pull request: SIOCGHWTSTAMP ioctl
2013-12-06 17:38 ` Ben Hutchings
2013-12-06 17:41 ` David Daney
@ 2013-12-07 7:30 ` Jeff Kirsher
1 sibling, 0 replies; 24+ messages in thread
From: Jeff Kirsher @ 2013-12-07 7:30 UTC (permalink / raw)
To: Ben Hutchings
Cc: David Miller, richardcochran, Veaceslav Falico, David Daney,
e1000-devel, netdev, Takahiro Shimizu, Giuseppe Cavallaro
[-- Attachment #1: Type: text/plain, Size: 1242 bytes --]
On Fri, 2013-12-06 at 17:38 +0000, Ben Hutchings wrote:
> On Thu, 2013-12-05 at 19:46 -0500, David Miller wrote:
> > From: Ben Hutchings <bhutchings@solarflare.com>
> > Date: Thu, 5 Dec 2013 23:37:12 +0000
> >
> > > 1. Add the SIOCGHWTSTAMP ioctl and update the timestamping
> > > documentation.
> > > 2. Implement SIOCGHWTSTAMP in most drivers that support
> SIOCSHWTSTAMP.
> > > 3. Add a test program to exercise SIOC{G,S}HWTSTAMP.
> >
> > Pulled, thanks Ben.
>
> Thanks. I hope all the drivers still work, as you didn't leave long
> for
> review.
>
> There are a few drivers I didn't touch because they don't appear to
> keep
> a soft copy of the timestamp configuration:
>
> drivers/net/ethernet/intel/igb/igb_main.c
> drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
> drivers/net/ethernet/octeon/octeon_mgmt.c
> drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
>
> phylib and the dp83640 driver will also need to be updated to support
> this.
>
> Ben.
Thanks Ben, I have let Carolyn Wyborny (igb/igbvf) and Don Skidmore
(ixgbe/ixgbevf) aware of your changes so that they can possible make the
changes to those drivers as well, if need be.
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 24+ messages in thread