mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
synced 2025-09-05 11:53:41 +00:00

Add support for receive timestamps to the Rx hotpath. This support only works when using the flexible descriptor format, so make sure that we request this format by default if we have receive timestamp support available in the PTP capabilities. In order to report the timestamps to userspace, we need to perform timestamp extension. The Rx descriptor does actually contain the "40 bit" timestamp. However, upper 32 bits which contain nanoseconds are conveniently stored separately in the descriptor. We could extract the 32bits and lower 8 bits, then perform a bitwise OR to calculate the 40bit value. This makes no sense, because the timestamp extension algorithm would simply discard the lower 8 bits anyways. Thus, implement timestamp extension as iavf_ptp_extend_32b_timestamp(), and extract and forward only the 32bits of nominal nanoseconds. Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> Reviewed-by: Rahul Rameshbabu <rrameshbabu@nvidia.com> Reviewed-by: Sunil Goutham <sgoutham@marvell.com> Reviewed-by: Simon Horman <horms@kernel.org> Tested-by: Rafal Romanowski <rafal.romanowski@intel.com> Signed-off-by: Mateusz Polchlopek <mateusz.polchlopek@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
48 lines
1.6 KiB
C
48 lines
1.6 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/* Copyright(c) 2024 Intel Corporation. */
|
|
|
|
#ifndef _IAVF_PTP_H_
|
|
#define _IAVF_PTP_H_
|
|
|
|
#include "iavf_types.h"
|
|
|
|
/* bit indicating whether a 40bit timestamp is valid */
|
|
#define IAVF_PTP_40B_TSTAMP_VALID BIT(24)
|
|
|
|
#if IS_ENABLED(CONFIG_PTP_1588_CLOCK)
|
|
void iavf_ptp_init(struct iavf_adapter *adapter);
|
|
void iavf_ptp_release(struct iavf_adapter *adapter);
|
|
void iavf_ptp_process_caps(struct iavf_adapter *adapter);
|
|
bool iavf_ptp_cap_supported(const struct iavf_adapter *adapter, u32 cap);
|
|
void iavf_virtchnl_send_ptp_cmd(struct iavf_adapter *adapter);
|
|
int iavf_ptp_set_ts_config(struct iavf_adapter *adapter,
|
|
struct kernel_hwtstamp_config *config,
|
|
struct netlink_ext_ack *extack);
|
|
u64 iavf_ptp_extend_32b_timestamp(u64 cached_phc_time, u32 in_tstamp);
|
|
#else /* IS_ENABLED(CONFIG_PTP_1588_CLOCK) */
|
|
static inline void iavf_ptp_init(struct iavf_adapter *adapter) { }
|
|
static inline void iavf_ptp_release(struct iavf_adapter *adapter) { }
|
|
static inline void iavf_ptp_process_caps(struct iavf_adapter *adapter) { }
|
|
static inline bool iavf_ptp_cap_supported(const struct iavf_adapter *adapter,
|
|
u32 cap)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
static inline void iavf_virtchnl_send_ptp_cmd(struct iavf_adapter *adapter) { }
|
|
static inline int iavf_ptp_set_ts_config(struct iavf_adapter *adapter,
|
|
struct kernel_hwtstamp_config *config,
|
|
struct netlink_ext_ack *extack)
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
static inline u64 iavf_ptp_extend_32b_timestamp(u64 cached_phc_time,
|
|
u32 in_tstamp)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
#endif /* IS_ENABLED(CONFIG_PTP_1588_CLOCK) */
|
|
#endif /* _IAVF_PTP_H_ */
|