xref: /linux/drivers/net/ethernet/sfc/siena/ptp.h (revision a1ff5a7d78a036d6c2178ee5acd6ba4946243800)
1d48523cbSMartin Habets /* SPDX-License-Identifier: GPL-2.0-only */
2d48523cbSMartin Habets /****************************************************************************
3d48523cbSMartin Habets  * Driver for Solarflare network controllers and boards
4d48523cbSMartin Habets  * Copyright 2005-2006 Fen Systems Ltd.
5d48523cbSMartin Habets  * Copyright 2006-2013 Solarflare Communications Inc.
6d48523cbSMartin Habets  * Copyright 2019-2020 Xilinx Inc.
7d48523cbSMartin Habets  */
8d48523cbSMartin Habets 
9d48523cbSMartin Habets #ifndef EFX_PTP_H
10d48523cbSMartin Habets #define EFX_PTP_H
11d48523cbSMartin Habets 
12d48523cbSMartin Habets #include <linux/net_tstamp.h>
13d48523cbSMartin Habets #include "net_driver.h"
14d48523cbSMartin Habets 
15*2111375bSKory Maincent struct kernel_ethtool_ts_info;
1695e96f77SMartin Habets void efx_siena_ptp_defer_probe_with_channel(struct efx_nic *efx);
1795e96f77SMartin Habets struct efx_channel *efx_siena_ptp_channel(struct efx_nic *efx);
18d82afc80SAlex Austin int efx_siena_ptp_set_ts_config(struct efx_nic *efx,
19d82afc80SAlex Austin 				struct kernel_hwtstamp_config *config,
20d82afc80SAlex Austin 				struct netlink_ext_ack *extack);
21d82afc80SAlex Austin int efx_siena_ptp_get_ts_config(struct efx_nic *efx,
22d82afc80SAlex Austin 				struct kernel_hwtstamp_config *config);
2395e96f77SMartin Habets void efx_siena_ptp_get_ts_info(struct efx_nic *efx,
24*2111375bSKory Maincent 			       struct kernel_ethtool_ts_info *ts_info);
2595e96f77SMartin Habets bool efx_siena_ptp_is_ptp_tx(struct efx_nic *efx, struct sk_buff *skb);
2695e96f77SMartin Habets int efx_siena_ptp_get_mode(struct efx_nic *efx);
2795e96f77SMartin Habets int efx_siena_ptp_change_mode(struct efx_nic *efx, bool enable_wanted,
28d48523cbSMartin Habets 			      unsigned int new_mode);
2995e96f77SMartin Habets int efx_siena_ptp_tx(struct efx_nic *efx, struct sk_buff *skb);
3095e96f77SMartin Habets void efx_siena_ptp_event(struct efx_nic *efx, efx_qword_t *ev);
3195e96f77SMartin Habets size_t efx_siena_ptp_describe_stats(struct efx_nic *efx, u8 *strings);
3295e96f77SMartin Habets size_t efx_siena_ptp_update_stats(struct efx_nic *efx, u64 *stats);
3395e96f77SMartin Habets void efx_siena_time_sync_event(struct efx_channel *channel, efx_qword_t *ev);
3495e96f77SMartin Habets void __efx_siena_rx_skb_attach_timestamp(struct efx_channel *channel,
35d48523cbSMartin Habets 					 struct sk_buff *skb);
efx_rx_skb_attach_timestamp(struct efx_channel * channel,struct sk_buff * skb)36d48523cbSMartin Habets static inline void efx_rx_skb_attach_timestamp(struct efx_channel *channel,
37d48523cbSMartin Habets 					       struct sk_buff *skb)
38d48523cbSMartin Habets {
39d48523cbSMartin Habets 	if (channel->sync_events_state == SYNC_EVENTS_VALID)
4095e96f77SMartin Habets 		__efx_siena_rx_skb_attach_timestamp(channel, skb);
41d48523cbSMartin Habets }
4295e96f77SMartin Habets 
4395e96f77SMartin Habets void efx_siena_ptp_start_datapath(struct efx_nic *efx);
4495e96f77SMartin Habets void efx_siena_ptp_stop_datapath(struct efx_nic *efx);
4595e96f77SMartin Habets bool efx_siena_ptp_use_mac_tx_timestamps(struct efx_nic *efx);
4695e96f77SMartin Habets ktime_t efx_siena_ptp_nic_to_kernel_time(struct efx_tx_queue *tx_queue);
47d48523cbSMartin Habets 
48d48523cbSMartin Habets #endif /* EFX_PTP_H */
49