at master 3.0 kB view raw
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#include <uapi/linux/ethtool_netlink_generated.h> 8 9#define SOF_TIMESTAMPING_SOFTWARE_MASK (SOF_TIMESTAMPING_RX_SOFTWARE | \ 10 SOF_TIMESTAMPING_TX_SOFTWARE | \ 11 SOF_TIMESTAMPING_SOFTWARE) 12 13#define SOF_TIMESTAMPING_HARDWARE_MASK (SOF_TIMESTAMPING_RX_HARDWARE | \ 14 SOF_TIMESTAMPING_TX_HARDWARE | \ 15 SOF_TIMESTAMPING_RAW_HARDWARE) 16 17/** 18 * struct hwtstamp_provider_desc - hwtstamp provider description 19 * 20 * @index: index of the hwtstamp provider. 21 * @qualifier: hwtstamp provider qualifier. 22 */ 23struct hwtstamp_provider_desc { 24 int index; 25 enum hwtstamp_provider_qualifier qualifier; 26}; 27 28/** 29 * struct hwtstamp_provider - hwtstamp provider object 30 * 31 * @rcu_head: RCU callback used to free the struct. 32 * @source: source of the hwtstamp provider. 33 * @phydev: pointer of the phydev source in case a PTP coming from phylib 34 * @desc: hwtstamp provider description. 35 */ 36 37struct hwtstamp_provider { 38 struct rcu_head rcu_head; 39 enum hwtstamp_source source; 40 struct phy_device *phydev; 41 struct hwtstamp_provider_desc desc; 42}; 43 44/** 45 * struct kernel_hwtstamp_config - Kernel copy of struct hwtstamp_config 46 * 47 * @flags: see struct hwtstamp_config 48 * @tx_type: see struct hwtstamp_config 49 * @rx_filter: see struct hwtstamp_config 50 * @ifr: pointer to ifreq structure from the original ioctl request, to pass to 51 * a legacy implementation of a lower driver 52 * @copied_to_user: request was passed to a legacy implementation which already 53 * copied the ioctl request back to user space 54 * @source: indication whether timestamps should come from the netdev or from 55 * an attached phylib PHY 56 * @qualifier: qualifier of the hwtstamp provider 57 * 58 * Prefer using this structure for in-kernel processing of hardware 59 * timestamping configuration, over the inextensible struct hwtstamp_config 60 * exposed to the %SIOCGHWTSTAMP and %SIOCSHWTSTAMP ioctl UAPI. 61 */ 62struct kernel_hwtstamp_config { 63 int flags; 64 int tx_type; 65 int rx_filter; 66 struct ifreq *ifr; 67 bool copied_to_user; 68 enum hwtstamp_source source; 69 enum hwtstamp_provider_qualifier qualifier; 70}; 71 72static inline void hwtstamp_config_to_kernel(struct kernel_hwtstamp_config *kernel_cfg, 73 const struct hwtstamp_config *cfg) 74{ 75 kernel_cfg->flags = cfg->flags; 76 kernel_cfg->tx_type = cfg->tx_type; 77 kernel_cfg->rx_filter = cfg->rx_filter; 78} 79 80static inline void hwtstamp_config_from_kernel(struct hwtstamp_config *cfg, 81 const struct kernel_hwtstamp_config *kernel_cfg) 82{ 83 cfg->flags = kernel_cfg->flags; 84 cfg->tx_type = kernel_cfg->tx_type; 85 cfg->rx_filter = kernel_cfg->rx_filter; 86} 87 88static inline bool kernel_hwtstamp_config_changed(const struct kernel_hwtstamp_config *a, 89 const struct kernel_hwtstamp_config *b) 90{ 91 return a->flags != b->flags || 92 a->tx_type != b->tx_type || 93 a->rx_filter != b->rx_filter; 94} 95 96#endif /* _LINUX_NET_TIMESTAMPING_H_ */