From b7001f2d9fc711df8fc130e8795c9559b5f7cc2d Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 25 Sep 2026 16:35:17 +0000 Subject: [PATCH] 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 --- include/sys/socket.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/include/sys/socket.h b/include/sys/socket.h index 50424bff924..6471fdc2f0a 100644 --- a/include/sys/socket.h +++ b/include/sys/socket.h @@ -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