summaryrefslogtreecommitdiff
path: root/ring.h
diff options
context:
space:
mode:
authorDaniel Borkmann <dborkman@redhat.com>2013-03-16 17:59:35 +0100
committerDaniel Borkmann <dborkman@redhat.com>2013-03-16 17:59:35 +0100
commit4262e95c1c0a09c7f98ea6623d364bfda41e8bec (patch)
tree64309f7b022b5ed7e730d35589a221c6b336f026 /ring.h
parent7a3b0f2226f7ad5f5ba20bcab5ef0f5c2b75e17d (diff)
ring: don't care if we cannot active hw timestamping
Hw timestaming is currently done, if we have the header file from the kernel available. If it fails, we currently bail out, which is bullshit. Just returning is enough, since some users might have the header available, but not a NIC supporting hw timestaming. Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Diffstat (limited to 'ring.h')
-rw-r--r--ring.h21
1 files changed, 8 insertions, 13 deletions
diff --git a/ring.h b/ring.h
index 75f4d26..3306ba1 100644
--- a/ring.h
+++ b/ring.h
@@ -134,14 +134,14 @@ static inline void set_sockopt_tpacket(int sock)
#ifdef __WITH_HARDWARE_TIMESTAMPING
# include <linux/net_tstamp.h>
-static inline void set_sockopt_hwtimestamp(int sock, const char *dev)
+static inline int set_sockopt_hwtimestamp(int sock, const char *dev)
{
int timesource, ret;
struct hwtstamp_config hwconfig;
struct ifreq ifr;
if (!strncmp("any", dev, strlen("any")))
- return;
+ return -1;
memset(&hwconfig, 0, sizeof(hwconfig));
hwconfig.tx_type = HWTSTAMP_TX_ON;
@@ -152,23 +152,18 @@ static inline void set_sockopt_hwtimestamp(int sock, const char *dev)
ifr.ifr_data = &hwconfig;
ret = ioctl(sock, SIOCSHWTSTAMP, &ifr);
- if (ret < 0) {
- if (errno == EOPNOTSUPP)
- return;
- panic("Cannot set timestamping: %s\n", strerror(errno));
- }
+ if (ret < 0)
+ return -1;
timesource = SOF_TIMESTAMPING_RAW_HARDWARE;
- ret = setsockopt(sock, SOL_PACKET, PACKET_TIMESTAMP, &timesource,
- sizeof(timesource));
- if (ret)
- panic("Cannot set timestamping: %s!\n", strerror(errno));
+ return setsockopt(sock, SOL_PACKET, PACKET_TIMESTAMP, &timesource,
+ sizeof(timesource));
}
#else
-static inline void set_sockopt_hwtimestamp(int sock, const char *dev)
+static inline int set_sockopt_hwtimestamp(int sock, const char *dev)
{
- return;
+ return -1;
}
#endif
#endif /* RING_H */