Merge tag 'soc-ep93xx-dt-6.12' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
[linux-block.git] / include / linux / net_tstamp.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2
3 #ifndef _LINUX_NET_TIMESTAMPING_H_
4 #define _LINUX_NET_TIMESTAMPING_H_
5
6 #include <uapi/linux/net_tstamp.h>
7
8 #define SOF_TIMESTAMPING_SOFTWARE_MASK  (SOF_TIMESTAMPING_RX_SOFTWARE | \
9                                          SOF_TIMESTAMPING_TX_SOFTWARE | \
10                                          SOF_TIMESTAMPING_SOFTWARE)
11
12 #define SOF_TIMESTAMPING_HARDWARE_MASK  (SOF_TIMESTAMPING_RX_HARDWARE | \
13                                          SOF_TIMESTAMPING_TX_HARDWARE | \
14                                          SOF_TIMESTAMPING_RAW_HARDWARE)
15
16 enum hwtstamp_source {
17         HWTSTAMP_SOURCE_UNSPEC,
18         HWTSTAMP_SOURCE_NETDEV,
19         HWTSTAMP_SOURCE_PHYLIB,
20 };
21
22 /**
23  * struct kernel_hwtstamp_config - Kernel copy of struct hwtstamp_config
24  *
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
34  *
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.
38  */
39 struct kernel_hwtstamp_config {
40         int flags;
41         int tx_type;
42         int rx_filter;
43         struct ifreq *ifr;
44         bool copied_to_user;
45         enum hwtstamp_source source;
46 };
47
48 static inline void hwtstamp_config_to_kernel(struct kernel_hwtstamp_config *kernel_cfg,
49                                              const struct hwtstamp_config *cfg)
50 {
51         kernel_cfg->flags = cfg->flags;
52         kernel_cfg->tx_type = cfg->tx_type;
53         kernel_cfg->rx_filter = cfg->rx_filter;
54 }
55
56 static inline void hwtstamp_config_from_kernel(struct hwtstamp_config *cfg,
57                                                const struct kernel_hwtstamp_config *kernel_cfg)
58 {
59         cfg->flags = kernel_cfg->flags;
60         cfg->tx_type = kernel_cfg->tx_type;
61         cfg->rx_filter = kernel_cfg->rx_filter;
62 }
63
64 static inline bool kernel_hwtstamp_config_changed(const struct kernel_hwtstamp_config *a,
65                                                   const struct kernel_hwtstamp_config *b)
66 {
67         return a->flags != b->flags ||
68                a->tx_type != b->tx_type ||
69                a->rx_filter != b->rx_filter;
70 }
71
72 #endif /* _LINUX_NET_TIMESTAMPING_H_ */