diff options
author | Patrick Ohly <patrick.ohly@intel.com> | 2009-02-12 00:03:36 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-02-16 01:43:33 -0500 |
commit | cb9eff097831007afb30d64373f29d99825d0068 (patch) | |
tree | 823a5668c6f4b3f577a1d4cc73b3df2d7e33c5c4 /include/linux | |
parent | a75244c3d519fcb490ca2bf3f123c98017f1e8d0 (diff) |
net: new user space API for time stamping of incoming and outgoing packets
User space can request hardware and/or software time stamping.
Reporting of the result(s) via a new control message is enabled
separately for each field in the message because some of the
fields may require additional computation and thus cause overhead.
User space can tell the different kinds of time stamps apart
and choose what suits its needs.
When a TX timestamp operation is requested, the TX skb will be cloned
and the clone will be time stamped (in hardware or software) and added
to the socket error queue of the skb, if the skb has a socket
associated with it.
The actual TX timestamp will reach userspace as a RX timestamp on the
cloned packet. If timestamping is requested and no timestamping is
done in the device driver (potentially this may use hardware
timestamping), it will be done in software after the device's
start_hard_xmit routine.
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/errqueue.h | 1 | ||||
-rw-r--r-- | include/linux/net_tstamp.h | 104 | ||||
-rw-r--r-- | include/linux/sockios.h | 3 |
3 files changed, 108 insertions, 0 deletions
diff --git a/include/linux/errqueue.h b/include/linux/errqueue.h index ceb1454b6977..ec12cc74366f 100644 --- a/include/linux/errqueue.h +++ b/include/linux/errqueue.h | |||
@@ -18,6 +18,7 @@ struct sock_extended_err | |||
18 | #define SO_EE_ORIGIN_LOCAL 1 | 18 | #define SO_EE_ORIGIN_LOCAL 1 |
19 | #define SO_EE_ORIGIN_ICMP 2 | 19 | #define SO_EE_ORIGIN_ICMP 2 |
20 | #define SO_EE_ORIGIN_ICMP6 3 | 20 | #define SO_EE_ORIGIN_ICMP6 3 |
21 | #define SO_EE_ORIGIN_TIMESTAMPING 4 | ||
21 | 22 | ||
22 | #define SO_EE_OFFENDER(ee) ((struct sockaddr*)((ee)+1)) | 23 | #define SO_EE_OFFENDER(ee) ((struct sockaddr*)((ee)+1)) |
23 | 24 | ||
diff --git a/include/linux/net_tstamp.h b/include/linux/net_tstamp.h new file mode 100644 index 000000000000..a3b8546354ac --- /dev/null +++ b/include/linux/net_tstamp.h | |||
@@ -0,0 +1,104 @@ | |||
1 | /* | ||
2 | * Userspace API for hardware time stamping of network packets | ||
3 | * | ||
4 | * Copyright (C) 2008,2009 Intel Corporation | ||
5 | * Author: Patrick Ohly <patrick.ohly@intel.com> | ||
6 | * | ||
7 | */ | ||
8 | |||
9 | #ifndef _NET_TIMESTAMPING_H | ||
10 | #define _NET_TIMESTAMPING_H | ||
11 | |||
12 | #include <linux/socket.h> /* for SO_TIMESTAMPING */ | ||
13 | |||
14 | /* SO_TIMESTAMPING gets an integer bit field comprised of these values */ | ||
15 | enum { | ||
16 | SOF_TIMESTAMPING_TX_HARDWARE = (1<<0), | ||
17 | SOF_TIMESTAMPING_TX_SOFTWARE = (1<<1), | ||
18 | SOF_TIMESTAMPING_RX_HARDWARE = (1<<2), | ||
19 | SOF_TIMESTAMPING_RX_SOFTWARE = (1<<3), | ||
20 | SOF_TIMESTAMPING_SOFTWARE = (1<<4), | ||
21 | SOF_TIMESTAMPING_SYS_HARDWARE = (1<<5), | ||
22 | SOF_TIMESTAMPING_RAW_HARDWARE = (1<<6), | ||
23 | SOF_TIMESTAMPING_MASK = | ||
24 | (SOF_TIMESTAMPING_RAW_HARDWARE - 1) | | ||
25 | SOF_TIMESTAMPING_RAW_HARDWARE | ||
26 | }; | ||
27 | |||
28 | /** | ||
29 | * struct hwtstamp_config - %SIOCSHWTSTAMP parameter | ||
30 | * | ||
31 | * @flags: no flags defined right now, must be zero | ||
32 | * @tx_type: one of HWTSTAMP_TX_* | ||
33 | * @rx_type: one of one of HWTSTAMP_FILTER_* | ||
34 | * | ||
35 | * %SIOCSHWTSTAMP expects a &struct ifreq with a ifr_data pointer to | ||
36 | * this structure. dev_ifsioc() in the kernel takes care of the | ||
37 | * translation between 32 bit userspace and 64 bit kernel. The | ||
38 | * structure is intentionally chosen so that it has the same layout on | ||
39 | * 32 and 64 bit systems, don't break this! | ||
40 | */ | ||
41 | struct hwtstamp_config { | ||
42 | int flags; | ||
43 | int tx_type; | ||
44 | int rx_filter; | ||
45 | }; | ||
46 | |||
47 | /* possible values for hwtstamp_config->tx_type */ | ||
48 | enum { | ||
49 | /* | ||
50 | * No outgoing packet will need hardware time stamping; | ||
51 | * should a packet arrive which asks for it, no hardware | ||
52 | * time stamping will be done. | ||
53 | */ | ||
54 | HWTSTAMP_TX_OFF, | ||
55 | |||
56 | /* | ||
57 | * Enables hardware time stamping for outgoing packets; | ||
58 | * the sender of the packet decides which are to be | ||
59 | * time stamped by setting %SOF_TIMESTAMPING_TX_SOFTWARE | ||
60 | * before sending the packet. | ||
61 | */ | ||
62 | HWTSTAMP_TX_ON, | ||
63 | }; | ||
64 | |||
65 | /* possible values for hwtstamp_config->rx_filter */ | ||
66 | enum { | ||
67 | /* time stamp no incoming packet at all */ | ||
68 | HWTSTAMP_FILTER_NONE, | ||
69 | |||
70 | /* time stamp any incoming packet */ | ||
71 | HWTSTAMP_FILTER_ALL, | ||
72 | |||
73 | /* return value: time stamp all packets requested plus some others */ | ||
74 | HWTSTAMP_FILTER_SOME, | ||
75 | |||
76 | /* PTP v1, UDP, any kind of event packet */ | ||
77 | HWTSTAMP_FILTER_PTP_V1_L4_EVENT, | ||
78 | /* PTP v1, UDP, Sync packet */ | ||
79 | HWTSTAMP_FILTER_PTP_V1_L4_SYNC, | ||
80 | /* PTP v1, UDP, Delay_req packet */ | ||
81 | HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ, | ||
82 | /* PTP v2, UDP, any kind of event packet */ | ||
83 | HWTSTAMP_FILTER_PTP_V2_L4_EVENT, | ||
84 | /* PTP v2, UDP, Sync packet */ | ||
85 | HWTSTAMP_FILTER_PTP_V2_L4_SYNC, | ||
86 | /* PTP v2, UDP, Delay_req packet */ | ||
87 | HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ, | ||
88 | |||
89 | /* 802.AS1, Ethernet, any kind of event packet */ | ||
90 | HWTSTAMP_FILTER_PTP_V2_L2_EVENT, | ||
91 | /* 802.AS1, Ethernet, Sync packet */ | ||
92 | HWTSTAMP_FILTER_PTP_V2_L2_SYNC, | ||
93 | /* 802.AS1, Ethernet, Delay_req packet */ | ||
94 | HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ, | ||
95 | |||
96 | /* PTP v2/802.AS1, any layer, any kind of event packet */ | ||
97 | HWTSTAMP_FILTER_PTP_V2_EVENT, | ||
98 | /* PTP v2/802.AS1, any layer, Sync packet */ | ||
99 | HWTSTAMP_FILTER_PTP_V2_SYNC, | ||
100 | /* PTP v2/802.AS1, any layer, Delay_req packet */ | ||
101 | HWTSTAMP_FILTER_PTP_V2_DELAY_REQ, | ||
102 | }; | ||
103 | |||
104 | #endif /* _NET_TIMESTAMPING_H */ | ||
diff --git a/include/linux/sockios.h b/include/linux/sockios.h index abef7596655a..241f179347d9 100644 --- a/include/linux/sockios.h +++ b/include/linux/sockios.h | |||
@@ -122,6 +122,9 @@ | |||
122 | #define SIOCBRADDIF 0x89a2 /* add interface to bridge */ | 122 | #define SIOCBRADDIF 0x89a2 /* add interface to bridge */ |
123 | #define SIOCBRDELIF 0x89a3 /* remove interface from bridge */ | 123 | #define SIOCBRDELIF 0x89a3 /* remove interface from bridge */ |
124 | 124 | ||
125 | /* hardware time stamping: parameters in linux/net_tstamp.h */ | ||
126 | #define SIOCSHWTSTAMP 0x89b0 | ||
127 | |||
125 | /* Device private ioctl calls */ | 128 | /* Device private ioctl calls */ |
126 | 129 | ||
127 | /* | 130 | /* |