| 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_hwtstamp_get(struct net_device *netdev, |
| 18 |
struct kernel_hwtstamp_config *config); |
| 19 |
int qede_hwtstamp_set(struct net_device *netdev, |
| 20 |
struct kernel_hwtstamp_config *config, |
| 21 |
struct netlink_ext_ack *extack); |
| 22 |
void qede_ptp_disable(struct qede_dev *edev); |
| 23 |
int qede_ptp_enable(struct qede_dev *edev); |
| 24 |
int qede_ptp_get_ts_info(struct qede_dev *edev, struct kernel_ethtool_ts_info *ts); |
| 25 |
|
| 26 |
static inline void qede_ptp_record_rx_ts(struct qede_dev *edev, |
| 27 |
union eth_rx_cqe *cqe, |
| 28 |
struct sk_buff *skb) |
| 29 |
{ |
| 30 |
/* Check if this packet was timestamped */ |
| 31 |
if (unlikely(le16_to_cpu(cqe->fast_path_regular.pars_flags.flags) & |
| 32 |
(1 << PARSING_AND_ERR_FLAGS_TIMESTAMPRECORDED_SHIFT))) { |
| 33 |
if (likely(le16_to_cpu(cqe->fast_path_regular.pars_flags.flags) |
| 34 |
& (1 << PARSING_AND_ERR_FLAGS_TIMESYNCPKT_SHIFT))) { |
| 35 |
qede_ptp_rx_ts(edev, skb); |
| 36 |
} else { |
| 37 |
DP_INFO(edev, |
| 38 |
"Timestamp recorded for non PTP packets\n"); |
| 39 |
} |
| 40 |
} |
| 41 |
} |
| 42 |
#endif /* _QEDE_PTP_H_ */ |