brintos

brintos / linux-shallow public Read only

0
0
Text · 2.2 KiB · 662074b Raw
73 lines · c
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 16enum 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_config24 *25 * @flags: see struct hwtstamp_config26 * @tx_type: see struct hwtstamp_config27 * @rx_filter: see struct hwtstamp_config28 * @ifr: pointer to ifreq structure from the original ioctl request, to pass to29 *	a legacy implementation of a lower driver30 * @copied_to_user: request was passed to a legacy implementation which already31 *	copied the ioctl request back to user space32 * @source: indication whether timestamps should come from the netdev or from33 *	an attached phylib PHY34 *35 * Prefer using this structure for in-kernel processing of hardware36 * timestamping configuration, over the inextensible struct hwtstamp_config37 * exposed to the %SIOCGHWTSTAMP and %SIOCSHWTSTAMP ioctl UAPI.38 */39struct 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 48static 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 56static 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 64static 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_ */73