1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
2 /* QLogic qede NIC Driver
3 * Copyright (c) 2015-2017 QLogic Corporation
4 * Copyright (c) 2019-2020 Marvell International Ltd.
5 */
6
7 #ifndef _QEDE_PTP_H_
8 #define _QEDE_PTP_H_
9
10 #include <linux/ptp_clock_kernel.h>
11 #include <linux/net_tstamp.h>
12 #include <linux/timecounter.h>
13 #include "qede.h"
14
15 void qede_ptp_rx_ts(struct qede_dev *edev, struct sk_buff *skb);
16 void qede_ptp_tx_ts(struct qede_dev *edev, struct sk_buff *skb);
17 int qede_ptp_hw_ts(struct qede_dev *edev, struct ifreq *req);
18 void qede_ptp_disable(struct qede_dev *edev);
19 int qede_ptp_enable(struct qede_dev *edev);
20 int qede_ptp_get_ts_info(struct qede_dev *edev, struct kernel_ethtool_ts_info *ts);
21
qede_ptp_record_rx_ts(struct qede_dev * edev,union eth_rx_cqe * cqe,struct sk_buff * skb)22 static inline void qede_ptp_record_rx_ts(struct qede_dev *edev,
23 union eth_rx_cqe *cqe,
24 struct sk_buff *skb)
25 {
26 /* Check if this packet was timestamped */
27 if (unlikely(le16_to_cpu(cqe->fast_path_regular.pars_flags.flags) &
28 (1 << PARSING_AND_ERR_FLAGS_TIMESTAMPRECORDED_SHIFT))) {
29 if (likely(le16_to_cpu(cqe->fast_path_regular.pars_flags.flags)
30 & (1 << PARSING_AND_ERR_FLAGS_TIMESYNCPKT_SHIFT))) {
31 qede_ptp_rx_ts(edev, skb);
32 } else {
33 DP_INFO(edev,
34 "Timestamp recorded for non PTP packets\n");
35 }
36 }
37 }
38 #endif /* _QEDE_PTP_H_ */
39