1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-only */
2*4882a593Smuzhiyun /****************************************************************************
3*4882a593Smuzhiyun * Driver for Solarflare network controllers and boards
4*4882a593Smuzhiyun * Copyright 2005-2006 Fen Systems Ltd.
5*4882a593Smuzhiyun * Copyright 2006-2013 Solarflare Communications Inc.
6*4882a593Smuzhiyun * Copyright 2019-2020 Xilinx Inc.
7*4882a593Smuzhiyun */
8*4882a593Smuzhiyun
9*4882a593Smuzhiyun #ifndef EFX_PTP_H
10*4882a593Smuzhiyun #define EFX_PTP_H
11*4882a593Smuzhiyun
12*4882a593Smuzhiyun #include <linux/net_tstamp.h>
13*4882a593Smuzhiyun #include "net_driver.h"
14*4882a593Smuzhiyun
15*4882a593Smuzhiyun struct ethtool_ts_info;
16*4882a593Smuzhiyun int efx_ptp_probe(struct efx_nic *efx, struct efx_channel *channel);
17*4882a593Smuzhiyun void efx_ptp_defer_probe_with_channel(struct efx_nic *efx);
18*4882a593Smuzhiyun struct efx_channel *efx_ptp_channel(struct efx_nic *efx);
19*4882a593Smuzhiyun void efx_ptp_update_channel(struct efx_nic *efx, struct efx_channel *channel);
20*4882a593Smuzhiyun void efx_ptp_remove(struct efx_nic *efx);
21*4882a593Smuzhiyun int efx_ptp_set_ts_config(struct efx_nic *efx, struct ifreq *ifr);
22*4882a593Smuzhiyun int efx_ptp_get_ts_config(struct efx_nic *efx, struct ifreq *ifr);
23*4882a593Smuzhiyun void efx_ptp_get_ts_info(struct efx_nic *efx, struct ethtool_ts_info *ts_info);
24*4882a593Smuzhiyun bool efx_ptp_is_ptp_tx(struct efx_nic *efx, struct sk_buff *skb);
25*4882a593Smuzhiyun int efx_ptp_get_mode(struct efx_nic *efx);
26*4882a593Smuzhiyun int efx_ptp_change_mode(struct efx_nic *efx, bool enable_wanted,
27*4882a593Smuzhiyun unsigned int new_mode);
28*4882a593Smuzhiyun int efx_ptp_tx(struct efx_nic *efx, struct sk_buff *skb);
29*4882a593Smuzhiyun void efx_ptp_event(struct efx_nic *efx, efx_qword_t *ev);
30*4882a593Smuzhiyun size_t efx_ptp_describe_stats(struct efx_nic *efx, u8 *strings);
31*4882a593Smuzhiyun size_t efx_ptp_update_stats(struct efx_nic *efx, u64 *stats);
32*4882a593Smuzhiyun void efx_time_sync_event(struct efx_channel *channel, efx_qword_t *ev);
33*4882a593Smuzhiyun void __efx_rx_skb_attach_timestamp(struct efx_channel *channel,
34*4882a593Smuzhiyun struct sk_buff *skb);
efx_rx_skb_attach_timestamp(struct efx_channel * channel,struct sk_buff * skb)35*4882a593Smuzhiyun static inline void efx_rx_skb_attach_timestamp(struct efx_channel *channel,
36*4882a593Smuzhiyun struct sk_buff *skb)
37*4882a593Smuzhiyun {
38*4882a593Smuzhiyun if (channel->sync_events_state == SYNC_EVENTS_VALID)
39*4882a593Smuzhiyun __efx_rx_skb_attach_timestamp(channel, skb);
40*4882a593Smuzhiyun }
41*4882a593Smuzhiyun void efx_ptp_start_datapath(struct efx_nic *efx);
42*4882a593Smuzhiyun void efx_ptp_stop_datapath(struct efx_nic *efx);
43*4882a593Smuzhiyun bool efx_ptp_use_mac_tx_timestamps(struct efx_nic *efx);
44*4882a593Smuzhiyun ktime_t efx_ptp_nic_to_kernel_time(struct efx_tx_queue *tx_queue);
45*4882a593Smuzhiyun
46*4882a593Smuzhiyun #endif /* EFX_PTP_H */
47