19043f48fSEdward Cree /* SPDX-License-Identifier: GPL-2.0-only */
29043f48fSEdward Cree /****************************************************************************
39043f48fSEdward Cree * Driver for Solarflare network controllers and boards
49043f48fSEdward Cree * Copyright 2005-2006 Fen Systems Ltd.
59043f48fSEdward Cree * Copyright 2006-2013 Solarflare Communications Inc.
69043f48fSEdward Cree * Copyright 2019-2020 Xilinx Inc.
79043f48fSEdward Cree */
89043f48fSEdward Cree
99043f48fSEdward Cree #ifndef EFX_PTP_H
109043f48fSEdward Cree #define EFX_PTP_H
119043f48fSEdward Cree
129043f48fSEdward Cree #include <linux/net_tstamp.h>
139043f48fSEdward Cree #include "net_driver.h"
149043f48fSEdward Cree
159043f48fSEdward Cree struct ethtool_ts_info;
169043f48fSEdward Cree int efx_ptp_probe(struct efx_nic *efx, struct efx_channel *channel);
179043f48fSEdward Cree void efx_ptp_defer_probe_with_channel(struct efx_nic *efx);
189043f48fSEdward Cree struct efx_channel *efx_ptp_channel(struct efx_nic *efx);
19*49e6123cSTaehee Yoo void efx_ptp_update_channel(struct efx_nic *efx, struct efx_channel *channel);
209043f48fSEdward Cree void efx_ptp_remove(struct efx_nic *efx);
219043f48fSEdward Cree int efx_ptp_set_ts_config(struct efx_nic *efx, struct ifreq *ifr);
229043f48fSEdward Cree int efx_ptp_get_ts_config(struct efx_nic *efx, struct ifreq *ifr);
239043f48fSEdward Cree void efx_ptp_get_ts_info(struct efx_nic *efx, struct ethtool_ts_info *ts_info);
249043f48fSEdward Cree bool efx_ptp_is_ptp_tx(struct efx_nic *efx, struct sk_buff *skb);
259043f48fSEdward Cree int efx_ptp_get_mode(struct efx_nic *efx);
269043f48fSEdward Cree int efx_ptp_change_mode(struct efx_nic *efx, bool enable_wanted,
279043f48fSEdward Cree unsigned int new_mode);
289043f48fSEdward Cree int efx_ptp_tx(struct efx_nic *efx, struct sk_buff *skb);
299043f48fSEdward Cree void efx_ptp_event(struct efx_nic *efx, efx_qword_t *ev);
309043f48fSEdward Cree size_t efx_ptp_describe_stats(struct efx_nic *efx, u8 *strings);
319043f48fSEdward Cree size_t efx_ptp_update_stats(struct efx_nic *efx, u64 *stats);
329043f48fSEdward Cree void efx_time_sync_event(struct efx_channel *channel, efx_qword_t *ev);
339043f48fSEdward Cree void __efx_rx_skb_attach_timestamp(struct efx_channel *channel,
349043f48fSEdward Cree struct sk_buff *skb);
efx_rx_skb_attach_timestamp(struct efx_channel * channel,struct sk_buff * skb)359043f48fSEdward Cree static inline void efx_rx_skb_attach_timestamp(struct efx_channel *channel,
369043f48fSEdward Cree struct sk_buff *skb)
379043f48fSEdward Cree {
389043f48fSEdward Cree if (channel->sync_events_state == SYNC_EVENTS_VALID)
399043f48fSEdward Cree __efx_rx_skb_attach_timestamp(channel, skb);
409043f48fSEdward Cree }
419043f48fSEdward Cree void efx_ptp_start_datapath(struct efx_nic *efx);
429043f48fSEdward Cree void efx_ptp_stop_datapath(struct efx_nic *efx);
439043f48fSEdward Cree bool efx_ptp_use_mac_tx_timestamps(struct efx_nic *efx);
449043f48fSEdward Cree ktime_t efx_ptp_nic_to_kernel_time(struct efx_tx_queue *tx_queue);
459043f48fSEdward Cree
469043f48fSEdward Cree #endif /* EFX_PTP_H */
47