1 /* SPDX-License-Identifier: GPL-2.0 */
3 #ifndef _LINUX_NET_TIMESTAMPING_H_
4 #define _LINUX_NET_TIMESTAMPING_H_
6 #include <uapi/linux/net_tstamp.h>
8 #define SOF_TIMESTAMPING_SOFTWARE_MASK (SOF_TIMESTAMPING_RX_SOFTWARE | \
9 SOF_TIMESTAMPING_TX_SOFTWARE | \
10 SOF_TIMESTAMPING_SOFTWARE)
12 #define SOF_TIMESTAMPING_HARDWARE_MASK (SOF_TIMESTAMPING_RX_HARDWARE | \
13 SOF_TIMESTAMPING_TX_HARDWARE | \
14 SOF_TIMESTAMPING_RAW_HARDWARE)
16 enum hwtstamp_source {
17 HWTSTAMP_SOURCE_UNSPEC,
18 HWTSTAMP_SOURCE_NETDEV,
19 HWTSTAMP_SOURCE_PHYLIB,
23 * struct kernel_hwtstamp_config - Kernel copy of struct hwtstamp_config
25 * @flags: see struct hwtstamp_config
26 * @tx_type: see struct hwtstamp_config
27 * @rx_filter: see struct hwtstamp_config
28 * @ifr: pointer to ifreq structure from the original ioctl request, to pass to
29 * a legacy implementation of a lower driver
30 * @copied_to_user: request was passed to a legacy implementation which already
31 * copied the ioctl request back to user space
32 * @source: indication whether timestamps should come from the netdev or from
33 * an attached phylib PHY
35 * Prefer using this structure for in-kernel processing of hardware
36 * timestamping configuration, over the inextensible struct hwtstamp_config
37 * exposed to the %SIOCGHWTSTAMP and %SIOCSHWTSTAMP ioctl UAPI.
39 struct kernel_hwtstamp_config {
45 enum hwtstamp_source source;
48 static inline void hwtstamp_config_to_kernel(struct kernel_hwtstamp_config *kernel_cfg,
49 const struct hwtstamp_config *cfg)
51 kernel_cfg->flags = cfg->flags;
52 kernel_cfg->tx_type = cfg->tx_type;
53 kernel_cfg->rx_filter = cfg->rx_filter;
56 static inline void hwtstamp_config_from_kernel(struct hwtstamp_config *cfg,
57 const struct kernel_hwtstamp_config *kernel_cfg)
59 cfg->flags = kernel_cfg->flags;
60 cfg->tx_type = kernel_cfg->tx_type;
61 cfg->rx_filter = kernel_cfg->rx_filter;
64 static inline bool kernel_hwtstamp_config_changed(const struct kernel_hwtstamp_config *a,
65 const struct kernel_hwtstamp_config *b)
67 return a->flags != b->flags ||
68 a->tx_type != b->tx_type ||
69 a->rx_filter != b->rx_filter;
72 #endif /* _LINUX_NET_TIMESTAMPING_H_ */