1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright(c) 2024 Intel Corporation. */
3
4 #ifndef _IAVF_PTP_H_
5 #define _IAVF_PTP_H_
6
7 #include "iavf_types.h"
8
9 /* bit indicating whether a 40bit timestamp is valid */
10 #define IAVF_PTP_40B_TSTAMP_VALID BIT(24)
11
12 #if IS_ENABLED(CONFIG_PTP_1588_CLOCK)
13 void iavf_ptp_init(struct iavf_adapter *adapter);
14 void iavf_ptp_release(struct iavf_adapter *adapter);
15 void iavf_ptp_process_caps(struct iavf_adapter *adapter);
16 bool iavf_ptp_cap_supported(const struct iavf_adapter *adapter, u32 cap);
17 void iavf_virtchnl_send_ptp_cmd(struct iavf_adapter *adapter);
18 int iavf_ptp_set_ts_config(struct iavf_adapter *adapter,
19 struct kernel_hwtstamp_config *config,
20 struct netlink_ext_ack *extack);
21 u64 iavf_ptp_extend_32b_timestamp(u64 cached_phc_time, u32 in_tstamp);
22 #else /* IS_ENABLED(CONFIG_PTP_1588_CLOCK) */
iavf_ptp_init(struct iavf_adapter * adapter)23 static inline void iavf_ptp_init(struct iavf_adapter *adapter) { }
iavf_ptp_release(struct iavf_adapter * adapter)24 static inline void iavf_ptp_release(struct iavf_adapter *adapter) { }
iavf_ptp_process_caps(struct iavf_adapter * adapter)25 static inline void iavf_ptp_process_caps(struct iavf_adapter *adapter) { }
iavf_ptp_cap_supported(const struct iavf_adapter * adapter,u32 cap)26 static inline bool iavf_ptp_cap_supported(const struct iavf_adapter *adapter,
27 u32 cap)
28 {
29 return false;
30 }
31
iavf_virtchnl_send_ptp_cmd(struct iavf_adapter * adapter)32 static inline void iavf_virtchnl_send_ptp_cmd(struct iavf_adapter *adapter) { }
iavf_ptp_set_ts_config(struct iavf_adapter * adapter,struct kernel_hwtstamp_config * config,struct netlink_ext_ack * extack)33 static inline int iavf_ptp_set_ts_config(struct iavf_adapter *adapter,
34 struct kernel_hwtstamp_config *config,
35 struct netlink_ext_ack *extack)
36 {
37 return -1;
38 }
39
iavf_ptp_extend_32b_timestamp(u64 cached_phc_time,u32 in_tstamp)40 static inline u64 iavf_ptp_extend_32b_timestamp(u64 cached_phc_time,
41 u32 in_tstamp)
42 {
43 return 0;
44 }
45
46 #endif /* IS_ENABLED(CONFIG_PTP_1588_CLOCK) */
47 #endif /* _IAVF_PTP_H_ */
48