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>
9 HWTSTAMP_SOURCE_NETDEV,
10 HWTSTAMP_SOURCE_PHYLIB,
14 * struct kernel_hwtstamp_config - Kernel copy of struct hwtstamp_config
16 * @flags: see struct hwtstamp_config
17 * @tx_type: see struct hwtstamp_config
18 * @rx_filter: see struct hwtstamp_config
19 * @ifr: pointer to ifreq structure from the original ioctl request, to pass to
20 * a legacy implementation of a lower driver
21 * @copied_to_user: request was passed to a legacy implementation which already
22 * copied the ioctl request back to user space
23 * @source: indication whether timestamps should come from the netdev or from
24 * an attached phylib PHY
26 * Prefer using this structure for in-kernel processing of hardware
27 * timestamping configuration, over the inextensible struct hwtstamp_config
28 * exposed to the %SIOCGHWTSTAMP and %SIOCSHWTSTAMP ioctl UAPI.
30 struct kernel_hwtstamp_config {
36 enum hwtstamp_source source;
39 static inline void hwtstamp_config_to_kernel(struct kernel_hwtstamp_config *kernel_cfg,
40 const struct hwtstamp_config *cfg)
42 kernel_cfg->flags = cfg->flags;
43 kernel_cfg->tx_type = cfg->tx_type;
44 kernel_cfg->rx_filter = cfg->rx_filter;
47 static inline void hwtstamp_config_from_kernel(struct hwtstamp_config *cfg,
48 const struct kernel_hwtstamp_config *kernel_cfg)
50 cfg->flags = kernel_cfg->flags;
51 cfg->tx_type = kernel_cfg->tx_type;
52 cfg->rx_filter = kernel_cfg->rx_filter;
55 static inline bool kernel_hwtstamp_config_changed(const struct kernel_hwtstamp_config *a,
56 const struct kernel_hwtstamp_config *b)
58 return a->flags != b->flags ||
59 a->tx_type != b->tx_type ||
60 a->rx_filter != b->rx_filter;
63 #endif /* _LINUX_NET_TIMESTAMPING_H_ */