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 hwtstamp_provider_desc - hwtstamp provider description
25 * @index: index of the hwtstamp provider.
26 * @qualifier: hwtstamp provider qualifier.
28 struct hwtstamp_provider_desc
{
30 enum hwtstamp_provider_qualifier qualifier
;
34 * struct hwtstamp_provider - hwtstamp provider object
36 * @rcu_head: RCU callback used to free the struct.
37 * @source: source of the hwtstamp provider.
38 * @phydev: pointer of the phydev source in case a PTP coming from phylib
39 * @desc: hwtstamp provider description.
42 struct hwtstamp_provider
{
43 struct rcu_head rcu_head
;
44 enum hwtstamp_source source
;
45 struct phy_device
*phydev
;
46 struct hwtstamp_provider_desc desc
;
50 * struct kernel_hwtstamp_config - Kernel copy of struct hwtstamp_config
52 * @flags: see struct hwtstamp_config
53 * @tx_type: see struct hwtstamp_config
54 * @rx_filter: see struct hwtstamp_config
55 * @ifr: pointer to ifreq structure from the original ioctl request, to pass to
56 * a legacy implementation of a lower driver
57 * @copied_to_user: request was passed to a legacy implementation which already
58 * copied the ioctl request back to user space
59 * @source: indication whether timestamps should come from the netdev or from
60 * an attached phylib PHY
61 * @qualifier: qualifier of the hwtstamp provider
63 * Prefer using this structure for in-kernel processing of hardware
64 * timestamping configuration, over the inextensible struct hwtstamp_config
65 * exposed to the %SIOCGHWTSTAMP and %SIOCSHWTSTAMP ioctl UAPI.
67 struct kernel_hwtstamp_config
{
73 enum hwtstamp_source source
;
74 enum hwtstamp_provider_qualifier qualifier
;
77 static inline void hwtstamp_config_to_kernel(struct kernel_hwtstamp_config
*kernel_cfg
,
78 const struct hwtstamp_config
*cfg
)
80 kernel_cfg
->flags
= cfg
->flags
;
81 kernel_cfg
->tx_type
= cfg
->tx_type
;
82 kernel_cfg
->rx_filter
= cfg
->rx_filter
;
85 static inline void hwtstamp_config_from_kernel(struct hwtstamp_config
*cfg
,
86 const struct kernel_hwtstamp_config
*kernel_cfg
)
88 cfg
->flags
= kernel_cfg
->flags
;
89 cfg
->tx_type
= kernel_cfg
->tx_type
;
90 cfg
->rx_filter
= kernel_cfg
->rx_filter
;
93 static inline bool kernel_hwtstamp_config_changed(const struct kernel_hwtstamp_config
*a
,
94 const struct kernel_hwtstamp_config
*b
)
96 return a
->flags
!= b
->flags
||
97 a
->tx_type
!= b
->tx_type
||
98 a
->rx_filter
!= b
->rx_filter
;
101 #endif /* _LINUX_NET_TIMESTAMPING_H_ */