Use hardware timestamps to report packet timestamps

for SO_TIMESTAMP and other similar socket options.

Provide new control message SCM_TIME_INFO to supply information about
timestamp.  Currently it indicates that the timestamp was
hardware-assisted and high-precision, for software timestamps the
message is not returned.  Reserved fields are added to ABI to report
additional info about it, it is expected that raw hardware clock value
might be useful for some applications.

Reviewed by:	gallatin (previous version), hselasky
Sponsored by:	Mellanox Technologies
MFC after:	2 weeks
X-Differential revision:	https://reviews.freebsd.org/D12638
This commit is contained in:
kib 2017-11-07 09:46:26 +00:00 committed by Sebastian Huber
parent 7ff81234c4
commit 91e828be4f
1 changed files with 11 additions and 0 deletions

View File

@ -563,6 +563,17 @@ struct sockcred {
#define SCM_BINTIME 0x04 /* timestamp (struct bintime) */
#define SCM_REALTIME 0x05 /* timestamp (struct timespec) */
#define SCM_MONOTONIC 0x06 /* timestamp (struct timespec) */
#define SCM_TIME_INFO 0x07 /* timestamp info */
struct sock_timestamp_info {
__uint32_t st_info_flags;
__uint32_t st_info_pad0;
__uint64_t st_info_rsv[7];
};
#define ST_INFO_HW 0x0001 /* SCM_TIMESTAMP was hw */
#define ST_INFO_HW_HPREC 0x0002 /* SCM_TIMESTAMP was hw-assisted
on entrance */
#endif
#if __BSD_VISIBLE