mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-28 20:02:17 +00:00
![Vladimir Oltean](/assets/img/avatar_default.png)
It is desirable that the new .ndo_hwtstamp_set() API gives more uniformity, less overhead and future flexibility w.r.t. the PHY timestamping behavior. Currently there are some drivers which allow PHY timestamping through the procedure mentioned in Documentation/networking/timestamping.rst. They don't do anything locally if phy_has_hwtstamp() is set, except for lan966x which installs PTP packet traps. Centralize that behavior in a new dev_set_hwtstamp_phylib() code function, which calls either phy_mii_ioctl() for the phylib PHY, or .ndo_hwtstamp_set() of the netdev, based on a single policy (currently simplistic: phy_has_hwtstamp()). Any driver converted to .ndo_hwtstamp_set() will automatically opt into the centralized phylib timestamping policy. Unconverted drivers still get to choose whether they let the PHY handle timestamping or not. Netdev drivers with integrated PHY drivers that don't use phylib presumably don't set dev->phydev, and those will always see HWTSTAMP_SOURCE_NETDEV requests even when converted. The timestamping policy will remain 100% up to them. 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-13-vladimir.oltean@nxp.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
63 lines
1.9 KiB
C
63 lines
1.9 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
#ifndef _LINUX_NET_TIMESTAMPING_H_
|
|
#define _LINUX_NET_TIMESTAMPING_H_
|
|
|
|
#include <uapi/linux/net_tstamp.h>
|
|
|
|
enum hwtstamp_source {
|
|
HWTSTAMP_SOURCE_NETDEV,
|
|
HWTSTAMP_SOURCE_PHYLIB,
|
|
};
|
|
|
|
/**
|
|
* 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
|
|
* @ifr: pointer to ifreq structure from the original ioctl request, to pass to
|
|
* a legacy implementation of a lower driver
|
|
* @copied_to_user: request was passed to a legacy implementation which already
|
|
* copied the ioctl request back to user space
|
|
* @source: indication whether timestamps should come from the netdev or from
|
|
* an attached phylib PHY
|
|
*
|
|
* 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;
|
|
struct ifreq *ifr;
|
|
bool copied_to_user;
|
|
enum hwtstamp_source source;
|
|
};
|
|
|
|
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;
|
|
}
|
|
|
|
static inline bool kernel_hwtstamp_config_changed(const struct kernel_hwtstamp_config *a,
|
|
const struct kernel_hwtstamp_config *b)
|
|
{
|
|
return a->flags != b->flags ||
|
|
a->tx_type != b->tx_type ||
|
|
a->rx_filter != b->rx_filter;
|
|
}
|
|
|
|
#endif /* _LINUX_NET_TIMESTAMPING_H_ */
|