xref: /linux/drivers/net/ethernet/intel/ice/ice_ptp.h (revision 803bef817807d2d36c930dada20c96fffae0dd19)
106c16d89SJacob Keller /* SPDX-License-Identifier: GPL-2.0 */
206c16d89SJacob Keller /* Copyright (C) 2021, Intel Corporation. */
306c16d89SJacob Keller 
406c16d89SJacob Keller #ifndef _ICE_PTP_H_
506c16d89SJacob Keller #define _ICE_PTP_H_
606c16d89SJacob Keller 
706c16d89SJacob Keller #include <linux/ptp_clock_kernel.h>
877a78115SJacob Keller #include <linux/kthread.h>
906c16d89SJacob Keller 
1006c16d89SJacob Keller #include "ice_ptp_hw.h"
1106c16d89SJacob Keller 
12325b2064SMaciej Machnikowski enum ice_ptp_pin_e810 {
13172db5f9SMaciej Machnikowski 	GPIO_20 = 0,
14172db5f9SMaciej Machnikowski 	GPIO_21,
15172db5f9SMaciej Machnikowski 	GPIO_22,
16172db5f9SMaciej Machnikowski 	GPIO_23,
17325b2064SMaciej Machnikowski 	NUM_PTP_PIN_E810
18325b2064SMaciej Machnikowski };
19325b2064SMaciej Machnikowski 
20325b2064SMaciej Machnikowski enum ice_ptp_pin_e810t {
21325b2064SMaciej Machnikowski 	GNSS = 0,
22325b2064SMaciej Machnikowski 	SMA1,
23325b2064SMaciej Machnikowski 	UFL1,
24325b2064SMaciej Machnikowski 	SMA2,
25325b2064SMaciej Machnikowski 	UFL2,
26325b2064SMaciej Machnikowski 	NUM_PTP_PINS_E810T
27172db5f9SMaciej Machnikowski };
28172db5f9SMaciej Machnikowski 
29172db5f9SMaciej Machnikowski struct ice_perout_channel {
30172db5f9SMaciej Machnikowski 	bool ena;
31172db5f9SMaciej Machnikowski 	u32 gpio_pin;
32172db5f9SMaciej Machnikowski 	u64 period;
33172db5f9SMaciej Machnikowski 	u64 start_time;
34172db5f9SMaciej Machnikowski };
35172db5f9SMaciej Machnikowski 
36ea9b847cSJacob Keller /* The ice hardware captures Tx hardware timestamps in the PHY. The timestamp
37ea9b847cSJacob Keller  * is stored in a buffer of registers. Depending on the specific hardware,
38ea9b847cSJacob Keller  * this buffer might be shared across multiple PHY ports.
39ea9b847cSJacob Keller  *
40ea9b847cSJacob Keller  * On transmit of a packet to be timestamped, software is responsible for
41ea9b847cSJacob Keller  * selecting an open index. Hardware makes no attempt to lock or prevent
42ea9b847cSJacob Keller  * re-use of an index for multiple packets.
43ea9b847cSJacob Keller  *
44ea9b847cSJacob Keller  * To handle this, timestamp indexes must be tracked by software to ensure
45ea9b847cSJacob Keller  * that an index is not re-used for multiple transmitted packets. The
46ea9b847cSJacob Keller  * structures and functions declared in this file track the available Tx
47ea9b847cSJacob Keller  * register indexes, as well as provide storage for the SKB pointers.
48ea9b847cSJacob Keller  *
49ea9b847cSJacob Keller  * To allow multiple ports to access the shared register block independently,
50ea9b847cSJacob Keller  * the blocks are split up so that indexes are assigned to each port based on
51ea9b847cSJacob Keller  * hardware logical port number.
5271a579f0SMichal Michalik  *
5371a579f0SMichal Michalik  * The timestamp blocks are handled differently for E810- and E822-based
5471a579f0SMichal Michalik  * devices. In E810 devices, each port has its own block of timestamps, while in
5571a579f0SMichal Michalik  * E822 there is a need to logically break the block of registers into smaller
5671a579f0SMichal Michalik  * chunks based on the port number to avoid collisions.
5771a579f0SMichal Michalik  *
5871a579f0SMichal Michalik  * Example for port 5 in E810:
5971a579f0SMichal Michalik  *  +--------+--------+--------+--------+--------+--------+--------+--------+
6071a579f0SMichal Michalik  *  |register|register|register|register|register|register|register|register|
6171a579f0SMichal Michalik  *  | block  | block  | block  | block  | block  | block  | block  | block  |
6271a579f0SMichal Michalik  *  |  for   |  for   |  for   |  for   |  for   |  for   |  for   |  for   |
6371a579f0SMichal Michalik  *  | port 0 | port 1 | port 2 | port 3 | port 4 | port 5 | port 6 | port 7 |
6471a579f0SMichal Michalik  *  +--------+--------+--------+--------+--------+--------+--------+--------+
6571a579f0SMichal Michalik  *                                               ^^
6671a579f0SMichal Michalik  *                                               ||
6771a579f0SMichal Michalik  *                                               |---  quad offset is always 0
6871a579f0SMichal Michalik  *                                               ---- quad number
6971a579f0SMichal Michalik  *
7071a579f0SMichal Michalik  * Example for port 5 in E822:
7171a579f0SMichal Michalik  * +-----------------------------+-----------------------------+
7271a579f0SMichal Michalik  * |  register block for quad 0  |  register block for quad 1  |
7371a579f0SMichal Michalik  * |+------+------+------+------+|+------+------+------+------+|
7471a579f0SMichal Michalik  * ||port 0|port 1|port 2|port 3|||port 0|port 1|port 2|port 3||
7571a579f0SMichal Michalik  * |+------+------+------+------+|+------+------+------+------+|
7671a579f0SMichal Michalik  * +-----------------------------+-------^---------------------+
7771a579f0SMichal Michalik  *                                ^      |
7871a579f0SMichal Michalik  *                                |      --- quad offset*
7971a579f0SMichal Michalik  *                                ---- quad number
8071a579f0SMichal Michalik  *
8171a579f0SMichal Michalik  *   * PHY port 5 is port 1 in quad 1
8271a579f0SMichal Michalik  *
83ea9b847cSJacob Keller  */
84ea9b847cSJacob Keller 
85ea9b847cSJacob Keller /**
86ea9b847cSJacob Keller  * struct ice_tx_tstamp - Tracking for a single Tx timestamp
87ea9b847cSJacob Keller  * @skb: pointer to the SKB for this timestamp request
88ea9b847cSJacob Keller  * @start: jiffies when the timestamp was first requested
8937e738b6SKarol Kolacinski  * @cached_tstamp: last read timestamp
90ea9b847cSJacob Keller  *
91ea9b847cSJacob Keller  * This structure tracks a single timestamp request. The SKB pointer is
92ea9b847cSJacob Keller  * provided when initiating a request. The start time is used to ensure that
93ea9b847cSJacob Keller  * we discard old requests that were not fulfilled within a 2 second time
94ea9b847cSJacob Keller  * window.
9537e738b6SKarol Kolacinski  * Timestamp values in the PHY are read only and do not get cleared except at
9610e4b4a3SJacob Keller  * hardware reset or when a new timestamp value is captured.
9710e4b4a3SJacob Keller  *
9810e4b4a3SJacob Keller  * Some PHY types do not provide a "ready" bitmap indicating which timestamp
9910e4b4a3SJacob Keller  * indexes are valid. In these cases, we use a cached_tstamp to keep track of
10010e4b4a3SJacob Keller  * the last timestamp we read for a given index. If the current timestamp
10110e4b4a3SJacob Keller  * value is the same as the cached value, we assume a new timestamp hasn't
10210e4b4a3SJacob Keller  * been captured. This avoids reporting stale timestamps to the stack. This is
1033f2216e8SJacob Keller  * only done if the has_ready_bitmap flag is not set in ice_ptp_tx structure.
104ea9b847cSJacob Keller  */
105ea9b847cSJacob Keller struct ice_tx_tstamp {
106ea9b847cSJacob Keller 	struct sk_buff *skb;
107ea9b847cSJacob Keller 	unsigned long start;
10837e738b6SKarol Kolacinski 	u64 cached_tstamp;
109ea9b847cSJacob Keller };
110ea9b847cSJacob Keller 
111ea9b847cSJacob Keller /**
112ae39eb42SJacob Keller  * enum ice_tx_tstamp_work - Status of Tx timestamp work function
113ae39eb42SJacob Keller  * @ICE_TX_TSTAMP_WORK_DONE: Tx timestamp processing is complete
114ae39eb42SJacob Keller  * @ICE_TX_TSTAMP_WORK_PENDING: More Tx timestamps are pending
115ae39eb42SJacob Keller  */
116ae39eb42SJacob Keller enum ice_tx_tstamp_work {
117ae39eb42SJacob Keller 	ICE_TX_TSTAMP_WORK_DONE = 0,
118ae39eb42SJacob Keller 	ICE_TX_TSTAMP_WORK_PENDING,
119ae39eb42SJacob Keller };
120ae39eb42SJacob Keller 
121ae39eb42SJacob Keller /**
122ea9b847cSJacob Keller  * struct ice_ptp_tx - Tracking structure for all Tx timestamp requests on a port
1233ad5c10bSJacob Keller  * @lock: lock to prevent concurrent access to fields of this struct
124ea9b847cSJacob Keller  * @tstamps: array of len to store outstanding requests
125ea9b847cSJacob Keller  * @in_use: bitmap of len to indicate which slots are in use
126d40fd600SJacob Keller  * @stale: bitmap of len to indicate slots which have stale timestamps
1276b5cbc8cSSergey Temerkhanov  * @block: which memory block (quad or port) the timestamps are captured in
1286b5cbc8cSSergey Temerkhanov  * @offset: offset into timestamp block to get the real index
129ea9b847cSJacob Keller  * @len: length of the tstamps and in_use fields.
130ea9b847cSJacob Keller  * @init: if true, the tracker is initialized;
1313a749623SJacob Keller  * @calibrating: if true, the PHY is calibrating the Tx offset. During this
1323a749623SJacob Keller  *               window, timestamps are temporarily disabled.
1333f2216e8SJacob Keller  * @has_ready_bitmap: if true, the hardware has a valid Tx timestamp ready
1343f2216e8SJacob Keller  *                    bitmap register. If false, fall back to verifying new
1353f2216e8SJacob Keller  *                    timestamp values against previously cached copy.
13682e71b22SKarol Kolacinski  * @last_ll_ts_idx_read: index of the last LL TS read by the FW
137ea9b847cSJacob Keller  */
138ea9b847cSJacob Keller struct ice_ptp_tx {
139ea9b847cSJacob Keller 	spinlock_t lock; /* lock protecting in_use bitmap */
140ea9b847cSJacob Keller 	struct ice_tx_tstamp *tstamps;
141ea9b847cSJacob Keller 	unsigned long *in_use;
142d40fd600SJacob Keller 	unsigned long *stale;
1436b5cbc8cSSergey Temerkhanov 	u8 block;
1446b5cbc8cSSergey Temerkhanov 	u8 offset;
145ea9b847cSJacob Keller 	u8 len;
14610e4b4a3SJacob Keller 	u8 init : 1;
14710e4b4a3SJacob Keller 	u8 calibrating : 1;
1483f2216e8SJacob Keller 	u8 has_ready_bitmap : 1;
14982e71b22SKarol Kolacinski 	s8 last_ll_ts_idx_read;
150ea9b847cSJacob Keller };
151ea9b847cSJacob Keller 
152ea9b847cSJacob Keller /* Quad and port information for initializing timestamp blocks */
153ea9b847cSJacob Keller #define INDEX_PER_QUAD			64
154a39dd252SKarol Kolacinski #define INDEX_PER_PORT_E82X		16
1556b5cbc8cSSergey Temerkhanov #define INDEX_PER_PORT_E810		64
156ea9b847cSJacob Keller 
157ea9b847cSJacob Keller /**
158ea9b847cSJacob Keller  * struct ice_ptp_port - data used to initialize an external port for PTP
159ea9b847cSJacob Keller  *
1603a749623SJacob Keller  * This structure contains data indicating whether a single external port is
1613a749623SJacob Keller  * ready for PTP functionality. It is used to track the port initialization
1623a749623SJacob Keller  * and determine when the port's PHY offset is valid.
163ea9b847cSJacob Keller  *
164d938a8ccSMichal Michalik  * @list_member: list member structure of auxiliary device
165ea9b847cSJacob Keller  * @tx: Tx timestamp tracking for this port
166d938a8ccSMichal Michalik  * @aux_dev: auxiliary device associated with this port
167a69f1cb6SJacob Keller  * @ov_work: delayed work task for tracking when PHY offset is valid
1683a749623SJacob Keller  * @ps_lock: mutex used to protect the overall PTP PHY start procedure
1693a749623SJacob Keller  * @link_up: indicates whether the link is up
170a69f1cb6SJacob Keller  * @tx_fifo_busy_cnt: number of times the Tx FIFO was busy
1713a749623SJacob Keller  * @port_num: the port number this structure represents
172ea9b847cSJacob Keller  */
173ea9b847cSJacob Keller struct ice_ptp_port {
174d938a8ccSMichal Michalik 	struct list_head list_member;
175ea9b847cSJacob Keller 	struct ice_ptp_tx tx;
176d938a8ccSMichal Michalik 	struct auxiliary_device aux_dev;
177a69f1cb6SJacob Keller 	struct kthread_delayed_work ov_work;
1783a749623SJacob Keller 	struct mutex ps_lock; /* protects overall PTP PHY start procedure */
1793a749623SJacob Keller 	bool link_up;
180a69f1cb6SJacob Keller 	u8 tx_fifo_busy_cnt;
1813a749623SJacob Keller 	u8 port_num;
182ea9b847cSJacob Keller };
183ea9b847cSJacob Keller 
184d938a8ccSMichal Michalik enum ice_ptp_tx_interrupt {
185d938a8ccSMichal Michalik 	ICE_PTP_TX_INTERRUPT_NONE = 0,
186d938a8ccSMichal Michalik 	ICE_PTP_TX_INTERRUPT_SELF,
187d938a8ccSMichal Michalik 	ICE_PTP_TX_INTERRUPT_ALL,
188d938a8ccSMichal Michalik };
189d938a8ccSMichal Michalik 
190d938a8ccSMichal Michalik /**
191d938a8ccSMichal Michalik  * struct ice_ptp_port_owner - data used to handle the PTP clock owner info
192d938a8ccSMichal Michalik  *
193d938a8ccSMichal Michalik  * This structure contains data necessary for the PTP clock owner to correctly
194d938a8ccSMichal Michalik  * handle the timestamping feature for all attached ports.
195d938a8ccSMichal Michalik  *
196d938a8ccSMichal Michalik  * @aux_driver: the structure carring the auxiliary driver information
197d938a8ccSMichal Michalik  * @ports: list of porst handled by this port owner
198d938a8ccSMichal Michalik  * @lock: protect access to ports list
199d938a8ccSMichal Michalik  */
200d938a8ccSMichal Michalik struct ice_ptp_port_owner {
201d938a8ccSMichal Michalik 	struct auxiliary_driver aux_driver;
202d938a8ccSMichal Michalik 	struct list_head ports;
203d938a8ccSMichal Michalik 	struct mutex lock;
204d938a8ccSMichal Michalik };
205d938a8ccSMichal Michalik 
206172db5f9SMaciej Machnikowski #define GLTSYN_TGT_H_IDX_MAX		4
207172db5f9SMaciej Machnikowski 
2088293e4cbSJacob Keller enum ice_ptp_state {
2098293e4cbSJacob Keller 	ICE_PTP_UNINIT = 0,
2108293e4cbSJacob Keller 	ICE_PTP_INITIALIZING,
2118293e4cbSJacob Keller 	ICE_PTP_READY,
2128293e4cbSJacob Keller 	ICE_PTP_RESETTING,
2138293e4cbSJacob Keller 	ICE_PTP_ERROR,
2148293e4cbSJacob Keller };
2158293e4cbSJacob Keller 
21606c16d89SJacob Keller /**
21706c16d89SJacob Keller  * struct ice_ptp - data used for integrating with CONFIG_PTP_1588_CLOCK
2188293e4cbSJacob Keller  * @state: current state of PTP state machine
219d938a8ccSMichal Michalik  * @tx_interrupt_mode: the TX interrupt mode for the PTP clock
220ea9b847cSJacob Keller  * @port: data for the PHY port initialization procedure
221d938a8ccSMichal Michalik  * @ports_owner: data for the auxiliary driver owner
22277a78115SJacob Keller  * @work: delayed work function for periodic tasks
22377a78115SJacob Keller  * @cached_phc_time: a cached copy of the PHC time for timestamp extension
224cd25507aSJacob Keller  * @cached_phc_jiffies: jiffies when cached_phc_time was last updated
225172db5f9SMaciej Machnikowski  * @ext_ts_chan: the external timestamp channel in use
226172db5f9SMaciej Machnikowski  * @ext_ts_irq: the external timestamp IRQ in use
22777a78115SJacob Keller  * @kworker: kwork thread for handling periodic work
228172db5f9SMaciej Machnikowski  * @perout_channels: periodic output data
22906c16d89SJacob Keller  * @info: structure defining PTP hardware capabilities
23006c16d89SJacob Keller  * @clock: pointer to registered PTP clock device
23177a78115SJacob Keller  * @tstamp_config: hardware timestamping configuration
23248096710SKarol Kolacinski  * @reset_time: kernel time after clock stop on reset
233f020481bSJacob Keller  * @tx_hwtstamp_skipped: number of Tx time stamp requests skipped
234f020481bSJacob Keller  * @tx_hwtstamp_timeouts: number of Tx skbs discarded with no time stamp
235f020481bSJacob Keller  * @tx_hwtstamp_flushed: number of Tx skbs flushed due to interface closed
236cd25507aSJacob Keller  * @tx_hwtstamp_discarded: number of Tx skbs discarded due to cached PHC time
237cd25507aSJacob Keller  *                         being too old to correctly extend timestamp
238cd25507aSJacob Keller  * @late_cached_phc_updates: number of times cached PHC update is late
23906c16d89SJacob Keller  */
24006c16d89SJacob Keller struct ice_ptp {
2418293e4cbSJacob Keller 	enum ice_ptp_state state;
242d938a8ccSMichal Michalik 	enum ice_ptp_tx_interrupt tx_interrupt_mode;
243ea9b847cSJacob Keller 	struct ice_ptp_port port;
244d938a8ccSMichal Michalik 	struct ice_ptp_port_owner ports_owner;
24577a78115SJacob Keller 	struct kthread_delayed_work work;
24677a78115SJacob Keller 	u64 cached_phc_time;
247cd25507aSJacob Keller 	unsigned long cached_phc_jiffies;
248172db5f9SMaciej Machnikowski 	u8 ext_ts_chan;
249172db5f9SMaciej Machnikowski 	u8 ext_ts_irq;
25077a78115SJacob Keller 	struct kthread_worker *kworker;
251172db5f9SMaciej Machnikowski 	struct ice_perout_channel perout_channels[GLTSYN_TGT_H_IDX_MAX];
25206c16d89SJacob Keller 	struct ptp_clock_info info;
25306c16d89SJacob Keller 	struct ptp_clock *clock;
25477a78115SJacob Keller 	struct hwtstamp_config tstamp_config;
25548096710SKarol Kolacinski 	u64 reset_time;
256f020481bSJacob Keller 	u32 tx_hwtstamp_skipped;
257f020481bSJacob Keller 	u32 tx_hwtstamp_timeouts;
258f020481bSJacob Keller 	u32 tx_hwtstamp_flushed;
259cd25507aSJacob Keller 	u32 tx_hwtstamp_discarded;
260cd25507aSJacob Keller 	u32 late_cached_phc_updates;
26106c16d89SJacob Keller };
26206c16d89SJacob Keller 
263ea9b847cSJacob Keller #define __ptp_port_to_ptp(p) \
264ea9b847cSJacob Keller 	container_of((p), struct ice_ptp, port)
265ea9b847cSJacob Keller #define ptp_port_to_pf(p) \
266ea9b847cSJacob Keller 	container_of(__ptp_port_to_ptp((p)), struct ice_pf, ptp)
267ea9b847cSJacob Keller 
26806c16d89SJacob Keller #define __ptp_info_to_ptp(i) \
26906c16d89SJacob Keller 	container_of((i), struct ice_ptp, info)
27006c16d89SJacob Keller #define ptp_info_to_pf(i) \
27106c16d89SJacob Keller 	container_of(__ptp_info_to_ptp((i)), struct ice_pf, ptp)
27206c16d89SJacob Keller 
2733a749623SJacob Keller #define PFTSYN_SEM_BYTES		4
27406c16d89SJacob Keller #define PTP_SHARED_CLK_IDX_VALID	BIT(31)
2753a749623SJacob Keller #define TS_CMD_MASK			0xF
2763a749623SJacob Keller #define SYNC_EXEC_CMD			0x3
27777a78115SJacob Keller #define ICE_PTP_TS_VALID		BIT(0)
27806c16d89SJacob Keller 
2793a749623SJacob Keller #define FIFO_EMPTY			BIT(2)
2803a749623SJacob Keller #define FIFO_OK				0xFF
2813a749623SJacob Keller #define ICE_PTP_FIFO_NUM_CHECKS		5
282172db5f9SMaciej Machnikowski /* Per-channel register definitions */
283172db5f9SMaciej Machnikowski #define GLTSYN_AUX_OUT(_chan, _idx)	(GLTSYN_AUX_OUT_0(_idx) + ((_chan) * 8))
284172db5f9SMaciej Machnikowski #define GLTSYN_AUX_IN(_chan, _idx)	(GLTSYN_AUX_IN_0(_idx) + ((_chan) * 8))
285172db5f9SMaciej Machnikowski #define GLTSYN_CLKO(_chan, _idx)	(GLTSYN_CLKO_0(_idx) + ((_chan) * 8))
286172db5f9SMaciej Machnikowski #define GLTSYN_TGT_L(_chan, _idx)	(GLTSYN_TGT_L_0(_idx) + ((_chan) * 16))
287172db5f9SMaciej Machnikowski #define GLTSYN_TGT_H(_chan, _idx)	(GLTSYN_TGT_H_0(_idx) + ((_chan) * 16))
288172db5f9SMaciej Machnikowski #define GLTSYN_EVNT_L(_chan, _idx)	(GLTSYN_EVNT_L_0(_idx) + ((_chan) * 16))
289172db5f9SMaciej Machnikowski #define GLTSYN_EVNT_H(_chan, _idx)	(GLTSYN_EVNT_H_0(_idx) + ((_chan) * 16))
290172db5f9SMaciej Machnikowski #define GLTSYN_EVNT_H_IDX_MAX		3
291172db5f9SMaciej Machnikowski 
292172db5f9SMaciej Machnikowski /* Pin definitions for PTP PPS out */
293172db5f9SMaciej Machnikowski #define PPS_CLK_GEN_CHAN		3
294172db5f9SMaciej Machnikowski #define PPS_CLK_SRC_CHAN		2
295172db5f9SMaciej Machnikowski #define PPS_PIN_INDEX			5
296172db5f9SMaciej Machnikowski #define TIME_SYNC_PIN_INDEX		4
297325b2064SMaciej Machnikowski #define N_EXT_TS_E810			3
298325b2064SMaciej Machnikowski #define N_PER_OUT_E810			4
299325b2064SMaciej Machnikowski #define N_PER_OUT_E810T			3
30043c4958aSArkadiusz Kubalewski #define N_PER_OUT_NO_SMA_E810T		2
30143c4958aSArkadiusz Kubalewski #define N_EXT_TS_NO_SMA_E810T		2
3023a749623SJacob Keller #define ETH_GLTSYN_ENA(_i)		(0x03000348 + ((_i) * 4))
303172db5f9SMaciej Machnikowski 
30406c16d89SJacob Keller #if IS_ENABLED(CONFIG_PTP_1588_CLOCK)
305fcd2c1e3SMichal Michalik int ice_ptp_clock_index(struct ice_pf *pf);
30606c16d89SJacob Keller struct ice_pf;
30777a78115SJacob Keller int ice_ptp_set_ts_config(struct ice_pf *pf, struct ifreq *ifr);
30877a78115SJacob Keller int ice_ptp_get_ts_config(struct ice_pf *pf, struct ifreq *ifr);
30977580179SJacob Keller void ice_ptp_restore_timestamp_mode(struct ice_pf *pf);
310ea9b847cSJacob Keller 
3116e8b2c88SKarol Kolacinski void ice_ptp_extts_event(struct ice_pf *pf);
312ea9b847cSJacob Keller s8 ice_ptp_request_ts(struct ice_ptp_tx *tx, struct sk_buff *skb);
31382e71b22SKarol Kolacinski void ice_ptp_req_tx_single_tstamp(struct ice_ptp_tx *tx, u8 idx);
31482e71b22SKarol Kolacinski void ice_ptp_complete_tx_single_tstamp(struct ice_ptp_tx *tx);
315ae39eb42SJacob Keller enum ice_tx_tstamp_work ice_ptp_process_ts(struct ice_pf *pf);
316ea9b847cSJacob Keller 
3173310aad2SLarysa Zaremba u64 ice_ptp_get_rx_hwts(const union ice_32b_rx_flex_desc *rx_desc,
3189031d5f4SLarysa Zaremba 			const struct ice_pkt_ctx *pkt_ctx);
319*803bef81SJacob Keller void ice_ptp_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type);
320c75d5e67SJacob Keller void ice_ptp_prepare_for_reset(struct ice_pf *pf,
321c75d5e67SJacob Keller 			       enum ice_reset_req reset_type);
32206c16d89SJacob Keller void ice_ptp_init(struct ice_pf *pf);
32306c16d89SJacob Keller void ice_ptp_release(struct ice_pf *pf);
3246b1ff5d3SJacob Keller void ice_ptp_link_change(struct ice_pf *pf, u8 port, bool linkup);
32506c16d89SJacob Keller #else /* IS_ENABLED(CONFIG_PTP_1588_CLOCK) */
32677a78115SJacob Keller static inline int ice_ptp_set_ts_config(struct ice_pf *pf, struct ifreq *ifr)
32777a78115SJacob Keller {
32877a78115SJacob Keller 	return -EOPNOTSUPP;
32977a78115SJacob Keller }
33077a78115SJacob Keller 
33177a78115SJacob Keller static inline int ice_ptp_get_ts_config(struct ice_pf *pf, struct ifreq *ifr)
33277a78115SJacob Keller {
33377a78115SJacob Keller 	return -EOPNOTSUPP;
33477a78115SJacob Keller }
33577a78115SJacob Keller 
33677580179SJacob Keller static inline void ice_ptp_restore_timestamp_mode(struct ice_pf *pf) { }
3376e8b2c88SKarol Kolacinski static inline void ice_ptp_extts_event(struct ice_pf *pf) { }
3384d7f75feSLorenzo Bianconi static inline s8
339ea9b847cSJacob Keller ice_ptp_request_ts(struct ice_ptp_tx *tx, struct sk_buff *skb)
340ea9b847cSJacob Keller {
341ea9b847cSJacob Keller 	return -1;
342ea9b847cSJacob Keller }
343ea9b847cSJacob Keller 
34482e71b22SKarol Kolacinski static inline void ice_ptp_req_tx_single_tstamp(struct ice_ptp_tx *tx, u8 idx)
34582e71b22SKarol Kolacinski { }
34682e71b22SKarol Kolacinski 
34782e71b22SKarol Kolacinski static inline void ice_ptp_complete_tx_single_tstamp(struct ice_ptp_tx *tx) { }
34882e71b22SKarol Kolacinski 
3491229b339SKarol Kolacinski static inline bool ice_ptp_process_ts(struct ice_pf *pf)
3501229b339SKarol Kolacinski {
3511229b339SKarol Kolacinski 	return true;
3521229b339SKarol Kolacinski }
3533310aad2SLarysa Zaremba 
3543310aad2SLarysa Zaremba static inline u64
3553310aad2SLarysa Zaremba ice_ptp_get_rx_hwts(const union ice_32b_rx_flex_desc *rx_desc,
3569031d5f4SLarysa Zaremba 		    const struct ice_pkt_ctx *pkt_ctx)
3573310aad2SLarysa Zaremba {
3583310aad2SLarysa Zaremba 	return 0;
3593310aad2SLarysa Zaremba }
3603310aad2SLarysa Zaremba 
361*803bef81SJacob Keller static inline void ice_ptp_rebuild(struct ice_pf *pf,
362c75d5e67SJacob Keller 				   enum ice_reset_req reset_type)
363c75d5e67SJacob Keller {
364c75d5e67SJacob Keller }
365c75d5e67SJacob Keller 
366c75d5e67SJacob Keller static inline void ice_ptp_prepare_for_reset(struct ice_pf *pf,
367c75d5e67SJacob Keller 					     enum ice_reset_req reset_type)
368c75d5e67SJacob Keller {
369c75d5e67SJacob Keller }
37006c16d89SJacob Keller static inline void ice_ptp_init(struct ice_pf *pf) { }
37106c16d89SJacob Keller static inline void ice_ptp_release(struct ice_pf *pf) { }
3726b1ff5d3SJacob Keller static inline void ice_ptp_link_change(struct ice_pf *pf, u8 port, bool linkup)
3736b1ff5d3SJacob Keller {
3746b1ff5d3SJacob Keller }
375fcd2c1e3SMichal Michalik 
376fcd2c1e3SMichal Michalik static inline int ice_ptp_clock_index(struct ice_pf *pf)
377fcd2c1e3SMichal Michalik {
378fcd2c1e3SMichal Michalik 	return -1;
379fcd2c1e3SMichal Michalik }
38006c16d89SJacob Keller #endif /* IS_ENABLED(CONFIG_PTP_1588_CLOCK) */
38106c16d89SJacob Keller #endif /* _ICE_PTP_H_ */
382