linux-stable/include/linux/net_tstamp.h
Maxim Georgiev 66f7223039 net: add NDOs for configuring hardware timestamping
Current hardware timestamping API for NICs requires implementing
.ndo_eth_ioctl() for SIOCGHWTSTAMP and SIOCSHWTSTAMP.

That API has some boilerplate such as request parameter translation
between user and kernel address spaces, handling possible translation
failures correctly, etc. Since it is the same all across the board, it
would be desirable to handle it through generic code.

Here we introduce .ndo_hwtstamp_get() and .ndo_hwtstamp_set(), which
implement that boilerplate and allow drivers to just act upon requests.

Suggested-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Maxim Georgiev <glipus@gmail.com>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Link: https://lore.kernel.org/r/20230801142824.1772134-2-vladimir.oltean@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2023-08-02 19:11:05 -07:00

41 lines
1.2 KiB
C

/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _LINUX_NET_TIMESTAMPING_H_
#define _LINUX_NET_TIMESTAMPING_H_
#include <uapi/linux/net_tstamp.h>
/**
* struct kernel_hwtstamp_config - Kernel copy of struct hwtstamp_config
*
* @flags: see struct hwtstamp_config
* @tx_type: see struct hwtstamp_config
* @rx_filter: see struct hwtstamp_config
*
* Prefer using this structure for in-kernel processing of hardware
* timestamping configuration, over the inextensible struct hwtstamp_config
* exposed to the %SIOCGHWTSTAMP and %SIOCSHWTSTAMP ioctl UAPI.
*/
struct kernel_hwtstamp_config {
int flags;
int tx_type;
int rx_filter;
};
static inline void hwtstamp_config_to_kernel(struct kernel_hwtstamp_config *kernel_cfg,
const struct hwtstamp_config *cfg)
{
kernel_cfg->flags = cfg->flags;
kernel_cfg->tx_type = cfg->tx_type;
kernel_cfg->rx_filter = cfg->rx_filter;
}
static inline void hwtstamp_config_from_kernel(struct hwtstamp_config *cfg,
const struct kernel_hwtstamp_config *kernel_cfg)
{
cfg->flags = kernel_cfg->flags;
cfg->tx_type = kernel_cfg->tx_type;
cfg->rx_filter = kernel_cfg->rx_filter;
}
#endif /* _LINUX_NET_TIMESTAMPING_H_ */