Commit fd468c74 authored by Ben Hutchings's avatar Ben Hutchings

net_tstamp: Add SIOCGHWTSTAMP ioctl to match SIOCSHWTSTAMP

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: default avatarBen Hutchings <bhutchings@solarflare.com>
parent 590d4693
...@@ -85,7 +85,7 @@ Filled in if SOF_TIMESTAMPING_SYS_HARDWARE is set. Requires support ...@@ -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. 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 Hardware time stamping must also be initialized for each device driver
that is expected to do hardware time stamping. The parameter is defined in 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 ...@@ -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 space is responsible to ensure that multiple processes don't interfere
with each other and that the settings are reset. 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 */ /* possible values for hwtstamp_config->tx_type */
enum { enum {
/* /*
...@@ -157,7 +161,8 @@ DEVICE IMPLEMENTATION ...@@ -157,7 +161,8 @@ DEVICE IMPLEMENTATION
A driver which supports hardware time stamping must support the A driver which supports hardware time stamping must support the
SIOCSHWTSTAMP ioctl and update the supplied struct hwtstamp_config with 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 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 to the shared time stamp structure of the skb call skb_hwtstamps(). Then
......
...@@ -26,17 +26,17 @@ enum { ...@@ -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_* * @tx_type: one of HWTSTAMP_TX_*
* @rx_filter: one of HWTSTAMP_FILTER_* * @rx_filter: one of HWTSTAMP_FILTER_*
* *
* %SIOCSHWTSTAMP expects a &struct ifreq with a ifr_data pointer to * %SIOCGHWTSTAMP and %SIOCSHWTSTAMP expect a &struct ifreq with a
* this structure. If the driver or hardware does not support the * ifr_data pointer to this structure. For %SIOCSHWTSTAMP, if the
* requested @rx_filter value, the driver may use a more general * driver or hardware does not support the requested @rx_filter value,
* filter mode. In this case @rx_filter will indicate the actual mode * the driver may use a more general filter mode. In this case
* on return. * @rx_filter will indicate the actual mode on return.
*/ */
struct hwtstamp_config { struct hwtstamp_config {
int flags; int flags;
......
...@@ -125,7 +125,8 @@ ...@@ -125,7 +125,8 @@
#define SIOCBRDELIF 0x89a3 /* remove interface from bridge */ #define SIOCBRDELIF 0x89a3 /* remove interface from bridge */
/* hardware time stamping: parameters in linux/net_tstamp.h */ /* 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 */ /* Device private ioctl calls */
......
...@@ -327,6 +327,7 @@ static int dev_ifsioc(struct net *net, struct ifreq *ifr, unsigned int cmd) ...@@ -327,6 +327,7 @@ static int dev_ifsioc(struct net *net, struct ifreq *ifr, unsigned int cmd)
cmd == SIOCBRADDIF || cmd == SIOCBRADDIF ||
cmd == SIOCBRDELIF || cmd == SIOCBRDELIF ||
cmd == SIOCSHWTSTAMP || cmd == SIOCSHWTSTAMP ||
cmd == SIOCGHWTSTAMP ||
cmd == SIOCWANDEV) { cmd == SIOCWANDEV) {
err = -EOPNOTSUPP; err = -EOPNOTSUPP;
if (ops->ndo_do_ioctl) { if (ops->ndo_do_ioctl) {
...@@ -546,6 +547,7 @@ int dev_ioctl(struct net *net, unsigned int cmd, void __user *arg) ...@@ -546,6 +547,7 @@ int dev_ioctl(struct net *net, unsigned int cmd, void __user *arg)
*/ */
default: default:
if (cmd == SIOCWANDEV || if (cmd == SIOCWANDEV ||
cmd == SIOCGHWTSTAMP ||
(cmd >= SIOCDEVPRIVATE && (cmd >= SIOCDEVPRIVATE &&
cmd <= SIOCDEVPRIVATE + 15)) { cmd <= SIOCDEVPRIVATE + 15)) {
dev_load(net, ifr.ifr_name); dev_load(net, ifr.ifr_name);
......
...@@ -3231,6 +3231,7 @@ static int compat_sock_ioctl_trans(struct file *file, struct socket *sock, ...@@ -3231,6 +3231,7 @@ static int compat_sock_ioctl_trans(struct file *file, struct socket *sock,
case SIOCBONDSLAVEINFOQUERY: case SIOCBONDSLAVEINFOQUERY:
case SIOCBONDINFOQUERY: case SIOCBONDINFOQUERY:
case SIOCSHWTSTAMP: case SIOCSHWTSTAMP:
case SIOCGHWTSTAMP:
return compat_ifr_data_ioctl(net, cmd, argp); return compat_ifr_data_ioctl(net, cmd, argp);
case FIOSETOWN: case FIOSETOWN:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment