xref: /openbmc/linux/drivers/net/ethernet/qlogic/qede/qede_ptp.h (revision 4b4193256c8d3bc3a5397b5cd9494c2ad386317d)
17268f33eSAlexander Lobakin /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
24c55215cSSudarsana Reddy Kalluru /* QLogic qede NIC Driver
34c55215cSSudarsana Reddy Kalluru  * Copyright (c) 2015-2017  QLogic Corporation
4*c4fad2a5SAlexander Lobakin  * Copyright (c) 2019-2020 Marvell International Ltd.
54c55215cSSudarsana Reddy Kalluru  */
67268f33eSAlexander Lobakin 
74c55215cSSudarsana Reddy Kalluru #ifndef _QEDE_PTP_H_
84c55215cSSudarsana Reddy Kalluru #define _QEDE_PTP_H_
94c55215cSSudarsana Reddy Kalluru 
104c55215cSSudarsana Reddy Kalluru #include <linux/ptp_clock_kernel.h>
114c55215cSSudarsana Reddy Kalluru #include <linux/net_tstamp.h>
124c55215cSSudarsana Reddy Kalluru #include <linux/timecounter.h>
134c55215cSSudarsana Reddy Kalluru #include "qede.h"
144c55215cSSudarsana Reddy Kalluru 
154c55215cSSudarsana Reddy Kalluru void qede_ptp_rx_ts(struct qede_dev *edev, struct sk_buff *skb);
164c55215cSSudarsana Reddy Kalluru void qede_ptp_tx_ts(struct qede_dev *edev, struct sk_buff *skb);
174c55215cSSudarsana Reddy Kalluru int qede_ptp_hw_ts(struct qede_dev *edev, struct ifreq *req);
1803574497Ssudarsana.kalluru@cavium.com void qede_ptp_disable(struct qede_dev *edev);
191c85f394SAlexander Lobakin int qede_ptp_enable(struct qede_dev *edev);
204c55215cSSudarsana Reddy Kalluru int qede_ptp_get_ts_info(struct qede_dev *edev, struct ethtool_ts_info *ts);
214c55215cSSudarsana Reddy Kalluru 
qede_ptp_record_rx_ts(struct qede_dev * edev,union eth_rx_cqe * cqe,struct sk_buff * skb)224c55215cSSudarsana Reddy Kalluru static inline void qede_ptp_record_rx_ts(struct qede_dev *edev,
234c55215cSSudarsana Reddy Kalluru 					 union eth_rx_cqe *cqe,
244c55215cSSudarsana Reddy Kalluru 					 struct sk_buff *skb)
254c55215cSSudarsana Reddy Kalluru {
264c55215cSSudarsana Reddy Kalluru 	/* Check if this packet was timestamped */
274c55215cSSudarsana Reddy Kalluru 	if (unlikely(le16_to_cpu(cqe->fast_path_regular.pars_flags.flags) &
284c55215cSSudarsana Reddy Kalluru 		     (1 << PARSING_AND_ERR_FLAGS_TIMESTAMPRECORDED_SHIFT))) {
294c55215cSSudarsana Reddy Kalluru 		if (likely(le16_to_cpu(cqe->fast_path_regular.pars_flags.flags)
304c55215cSSudarsana Reddy Kalluru 		    & (1 << PARSING_AND_ERR_FLAGS_TIMESYNCPKT_SHIFT))) {
314c55215cSSudarsana Reddy Kalluru 			qede_ptp_rx_ts(edev, skb);
324c55215cSSudarsana Reddy Kalluru 		} else {
334c55215cSSudarsana Reddy Kalluru 			DP_INFO(edev,
344c55215cSSudarsana Reddy Kalluru 				"Timestamp recorded for non PTP packets\n");
354c55215cSSudarsana Reddy Kalluru 		}
364c55215cSSudarsana Reddy Kalluru 	}
374c55215cSSudarsana Reddy Kalluru }
384c55215cSSudarsana Reddy Kalluru #endif /* _QEDE_PTP_H_ */
39