include/sys/socket.h: give SOF_TIMESTAMPING_* their Linux values

All SOF_TIMESTAMPING_* flags currently alias 1 << SO_TIMESTAMPING, so
they cannot tell hardware from software or RX from TX.  Give them their
distinct Linux values, and add SOF_TIMESTAMPING_RX_HARDWARE,
SOF_TIMESTAMPING_RX_SOFTWARE and SOF_TIMESTAMPING_SYS_HARDWARE, so that
they can also describe the timestamping capabilities of an interface
(so_timestamping of ETHTOOL_GET_TS_INFO).

This does not change behaviour: setsockopt(SO_TIMESTAMPING) only checks
for a non-zero value and getsockopt() returns 0 or 1, so existing users
and binaries built with the previous values keep working.  The
individual flags are still not honoured.

Assisted-by: Claude:claude-sonnet-5
Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com>
This commit is contained in:
Claude 2026-09-25 16:35:17 +00:00 • committed by Alan C. Assis
parent 68dd87f4df
commit b7001f2d9f

View file

@ -230,15 +230,24 @@
#define __SO_PROTOCOL 16
/* SO_TIMESTAMPING flags, with the same values as Linux so that they can
* also describe the capabilities of an interface (ETHTOOL_GET_TS_INFO).
* setsockopt(SO_TIMESTAMPING) currently treats any non-zero value as
* "enabled" and does not honour the individual flags.
*/
/* Timestamp generation */
#define SOF_TIMESTAMPING_TX_HARDWARE (1 << SO_TIMESTAMPING)
#define SOF_TIMESTAMPING_TX_SOFTWARE SOF_TIMESTAMPING_TX_HARDWARE
#define SOF_TIMESTAMPING_TX_HARDWARE (1 << 0)
#define SOF_TIMESTAMPING_TX_SOFTWARE (1 << 1)
#define SOF_TIMESTAMPING_RX_HARDWARE (1 << 2)
#define SOF_TIMESTAMPING_RX_SOFTWARE (1 << 3)
/* Timestamp reporting */
#define SOF_TIMESTAMPING_SOFTWARE SOF_TIMESTAMPING_TX_SOFTWARE
#define SOF_TIMESTAMPING_RAW_HARDWARE SOF_TIMESTAMPING_TX_HARDWARE
#define SOF_TIMESTAMPING_SOFTWARE (1 << 4)
#define SOF_TIMESTAMPING_SYS_HARDWARE (1 << 5)
#define SOF_TIMESTAMPING_RAW_HARDWARE (1 << 6)
/* The options are unsupported but included for compatibility
* and portability