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;
32be2a9d12SJacob Keller u32 flags;
33172db5f9SMaciej Machnikowski u64 period;
34172db5f9SMaciej Machnikowski u64 start_time;
35172db5f9SMaciej Machnikowski };
36172db5f9SMaciej Machnikowski
3700d3b4f5SMilena Olech struct ice_extts_channel {
3800d3b4f5SMilena Olech bool ena;
3900d3b4f5SMilena Olech u32 gpio_pin;
4000d3b4f5SMilena Olech u32 flags;
4100d3b4f5SMilena Olech };
4200d3b4f5SMilena Olech
43ea9b847cSJacob Keller /* The ice hardware captures Tx hardware timestamps in the PHY. The timestamp
44ea9b847cSJacob Keller * is stored in a buffer of registers. Depending on the specific hardware,
45ea9b847cSJacob Keller * this buffer might be shared across multiple PHY ports.
46ea9b847cSJacob Keller *
47ea9b847cSJacob Keller * On transmit of a packet to be timestamped, software is responsible for
48ea9b847cSJacob Keller * selecting an open index. Hardware makes no attempt to lock or prevent
49ea9b847cSJacob Keller * re-use of an index for multiple packets.
50ea9b847cSJacob Keller *
51ea9b847cSJacob Keller * To handle this, timestamp indexes must be tracked by software to ensure
52ea9b847cSJacob Keller * that an index is not re-used for multiple transmitted packets. The
53ea9b847cSJacob Keller * structures and functions declared in this file track the available Tx
54ea9b847cSJacob Keller * register indexes, as well as provide storage for the SKB pointers.
55ea9b847cSJacob Keller *
56ea9b847cSJacob Keller * To allow multiple ports to access the shared register block independently,
57ea9b847cSJacob Keller * the blocks are split up so that indexes are assigned to each port based on
58ea9b847cSJacob Keller * hardware logical port number.
5971a579f0SMichal Michalik *
6071a579f0SMichal Michalik * The timestamp blocks are handled differently for E810- and E822-based
6171a579f0SMichal Michalik * devices. In E810 devices, each port has its own block of timestamps, while in
6271a579f0SMichal Michalik * E822 there is a need to logically break the block of registers into smaller
6371a579f0SMichal Michalik * chunks based on the port number to avoid collisions.
6471a579f0SMichal Michalik *
6571a579f0SMichal Michalik * Example for port 5 in E810:
6671a579f0SMichal Michalik * +--------+--------+--------+--------+--------+--------+--------+--------+
6771a579f0SMichal Michalik * |register|register|register|register|register|register|register|register|
6871a579f0SMichal Michalik * | block | block | block | block | block | block | block | block |
6971a579f0SMichal Michalik * | for | for | for | for | for | for | for | for |
7071a579f0SMichal Michalik * | port 0 | port 1 | port 2 | port 3 | port 4 | port 5 | port 6 | port 7 |
7171a579f0SMichal Michalik * +--------+--------+--------+--------+--------+--------+--------+--------+
7271a579f0SMichal Michalik * ^^
7371a579f0SMichal Michalik * ||
7471a579f0SMichal Michalik * |--- quad offset is always 0
7571a579f0SMichal Michalik * ---- quad number
7671a579f0SMichal Michalik *
7771a579f0SMichal Michalik * Example for port 5 in E822:
7871a579f0SMichal Michalik * +-----------------------------+-----------------------------+
7971a579f0SMichal Michalik * | register block for quad 0 | register block for quad 1 |
8071a579f0SMichal Michalik * |+------+------+------+------+|+------+------+------+------+|
8171a579f0SMichal Michalik * ||port 0|port 1|port 2|port 3|||port 0|port 1|port 2|port 3||
8271a579f0SMichal Michalik * |+------+------+------+------+|+------+------+------+------+|
8371a579f0SMichal Michalik * +-----------------------------+-------^---------------------+
8471a579f0SMichal Michalik * ^ |
8571a579f0SMichal Michalik * | --- quad offset*
8671a579f0SMichal Michalik * ---- quad number
8771a579f0SMichal Michalik *
8871a579f0SMichal Michalik * * PHY port 5 is port 1 in quad 1
8971a579f0SMichal Michalik *
90ea9b847cSJacob Keller */
91ea9b847cSJacob Keller
92ea9b847cSJacob Keller /**
93ea9b847cSJacob Keller * struct ice_tx_tstamp - Tracking for a single Tx timestamp
94ea9b847cSJacob Keller * @skb: pointer to the SKB for this timestamp request
95ea9b847cSJacob Keller * @start: jiffies when the timestamp was first requested
9637e738b6SKarol Kolacinski * @cached_tstamp: last read timestamp
97ea9b847cSJacob Keller *
98ea9b847cSJacob Keller * This structure tracks a single timestamp request. The SKB pointer is
99ea9b847cSJacob Keller * provided when initiating a request. The start time is used to ensure that
100ea9b847cSJacob Keller * we discard old requests that were not fulfilled within a 2 second time
101ea9b847cSJacob Keller * window.
10237e738b6SKarol Kolacinski * Timestamp values in the PHY are read only and do not get cleared except at
10310e4b4a3SJacob Keller * hardware reset or when a new timestamp value is captured.
10410e4b4a3SJacob Keller *
10510e4b4a3SJacob Keller * Some PHY types do not provide a "ready" bitmap indicating which timestamp
10610e4b4a3SJacob Keller * indexes are valid. In these cases, we use a cached_tstamp to keep track of
10710e4b4a3SJacob Keller * the last timestamp we read for a given index. If the current timestamp
10810e4b4a3SJacob Keller * value is the same as the cached value, we assume a new timestamp hasn't
10910e4b4a3SJacob Keller * been captured. This avoids reporting stale timestamps to the stack. This is
1103f2216e8SJacob Keller * only done if the has_ready_bitmap flag is not set in ice_ptp_tx structure.
111ea9b847cSJacob Keller */
112ea9b847cSJacob Keller struct ice_tx_tstamp {
113ea9b847cSJacob Keller struct sk_buff *skb;
114ea9b847cSJacob Keller unsigned long start;
11537e738b6SKarol Kolacinski u64 cached_tstamp;
116ea9b847cSJacob Keller };
117ea9b847cSJacob Keller
118ea9b847cSJacob Keller /**
119ae39eb42SJacob Keller * enum ice_tx_tstamp_work - Status of Tx timestamp work function
120ae39eb42SJacob Keller * @ICE_TX_TSTAMP_WORK_DONE: Tx timestamp processing is complete
121ae39eb42SJacob Keller * @ICE_TX_TSTAMP_WORK_PENDING: More Tx timestamps are pending
122ae39eb42SJacob Keller */
123ae39eb42SJacob Keller enum ice_tx_tstamp_work {
124ae39eb42SJacob Keller ICE_TX_TSTAMP_WORK_DONE = 0,
125ae39eb42SJacob Keller ICE_TX_TSTAMP_WORK_PENDING,
126ae39eb42SJacob Keller };
127ae39eb42SJacob Keller
128ae39eb42SJacob Keller /**
129ea9b847cSJacob Keller * struct ice_ptp_tx - Tracking structure for all Tx timestamp requests on a port
1303ad5c10bSJacob Keller * @lock: lock to prevent concurrent access to fields of this struct
131ea9b847cSJacob Keller * @tstamps: array of len to store outstanding requests
132ea9b847cSJacob Keller * @in_use: bitmap of len to indicate which slots are in use
133d40fd600SJacob Keller * @stale: bitmap of len to indicate slots which have stale timestamps
1346b5cbc8cSSergey Temerkhanov * @block: which memory block (quad or port) the timestamps are captured in
1356b5cbc8cSSergey Temerkhanov * @offset: offset into timestamp block to get the real index
136ea9b847cSJacob Keller * @len: length of the tstamps and in_use fields.
137ea9b847cSJacob Keller * @init: if true, the tracker is initialized;
1383a749623SJacob Keller * @calibrating: if true, the PHY is calibrating the Tx offset. During this
1393a749623SJacob Keller * window, timestamps are temporarily disabled.
1403f2216e8SJacob Keller * @has_ready_bitmap: if true, the hardware has a valid Tx timestamp ready
1413f2216e8SJacob Keller * bitmap register. If false, fall back to verifying new
1423f2216e8SJacob Keller * timestamp values against previously cached copy.
14382e71b22SKarol Kolacinski * @last_ll_ts_idx_read: index of the last LL TS read by the FW
144ea9b847cSJacob Keller */
145ea9b847cSJacob Keller struct ice_ptp_tx {
146ea9b847cSJacob Keller spinlock_t lock; /* lock protecting in_use bitmap */
147ea9b847cSJacob Keller struct ice_tx_tstamp *tstamps;
148ea9b847cSJacob Keller unsigned long *in_use;
149d40fd600SJacob Keller unsigned long *stale;
1506b5cbc8cSSergey Temerkhanov u8 block;
1516b5cbc8cSSergey Temerkhanov u8 offset;
152ea9b847cSJacob Keller u8 len;
15310e4b4a3SJacob Keller u8 init : 1;
15410e4b4a3SJacob Keller u8 calibrating : 1;
1553f2216e8SJacob Keller u8 has_ready_bitmap : 1;
15682e71b22SKarol Kolacinski s8 last_ll_ts_idx_read;
157ea9b847cSJacob Keller };
158ea9b847cSJacob Keller
159ea9b847cSJacob Keller /* Quad and port information for initializing timestamp blocks */
160ea9b847cSJacob Keller #define INDEX_PER_QUAD 64
161a39dd252SKarol Kolacinski #define INDEX_PER_PORT_E82X 16
1626b5cbc8cSSergey Temerkhanov #define INDEX_PER_PORT_E810 64
163*7cab44f1SSergey Temerkhanov #define INDEX_PER_PORT_ETH56G 64
164ea9b847cSJacob Keller
165ea9b847cSJacob Keller /**
166ea9b847cSJacob Keller * struct ice_ptp_port - data used to initialize an external port for PTP
167ea9b847cSJacob Keller *
1683a749623SJacob Keller * This structure contains data indicating whether a single external port is
1693a749623SJacob Keller * ready for PTP functionality. It is used to track the port initialization
1703a749623SJacob Keller * and determine when the port's PHY offset is valid.
171ea9b847cSJacob Keller *
172d938a8ccSMichal Michalik * @list_member: list member structure of auxiliary device
173ea9b847cSJacob Keller * @tx: Tx timestamp tracking for this port
174d938a8ccSMichal Michalik * @aux_dev: auxiliary device associated with this port
175a69f1cb6SJacob Keller * @ov_work: delayed work task for tracking when PHY offset is valid
1763a749623SJacob Keller * @ps_lock: mutex used to protect the overall PTP PHY start procedure
1773a749623SJacob Keller * @link_up: indicates whether the link is up
178a69f1cb6SJacob Keller * @tx_fifo_busy_cnt: number of times the Tx FIFO was busy
1793a749623SJacob Keller * @port_num: the port number this structure represents
180ea9b847cSJacob Keller */
181ea9b847cSJacob Keller struct ice_ptp_port {
182d938a8ccSMichal Michalik struct list_head list_member;
183ea9b847cSJacob Keller struct ice_ptp_tx tx;
184d938a8ccSMichal Michalik struct auxiliary_device aux_dev;
185a69f1cb6SJacob Keller struct kthread_delayed_work ov_work;
1863a749623SJacob Keller struct mutex ps_lock; /* protects overall PTP PHY start procedure */
1873a749623SJacob Keller bool link_up;
188a69f1cb6SJacob Keller u8 tx_fifo_busy_cnt;
1893a749623SJacob Keller u8 port_num;
190ea9b847cSJacob Keller };
191ea9b847cSJacob Keller
192d938a8ccSMichal Michalik enum ice_ptp_tx_interrupt {
193d938a8ccSMichal Michalik ICE_PTP_TX_INTERRUPT_NONE = 0,
194d938a8ccSMichal Michalik ICE_PTP_TX_INTERRUPT_SELF,
195d938a8ccSMichal Michalik ICE_PTP_TX_INTERRUPT_ALL,
196d938a8ccSMichal Michalik };
197d938a8ccSMichal Michalik
198d938a8ccSMichal Michalik /**
199d938a8ccSMichal Michalik * struct ice_ptp_port_owner - data used to handle the PTP clock owner info
200d938a8ccSMichal Michalik *
201d938a8ccSMichal Michalik * This structure contains data necessary for the PTP clock owner to correctly
202d938a8ccSMichal Michalik * handle the timestamping feature for all attached ports.
203d938a8ccSMichal Michalik *
204d938a8ccSMichal Michalik * @aux_driver: the structure carring the auxiliary driver information
205d938a8ccSMichal Michalik * @ports: list of porst handled by this port owner
206d938a8ccSMichal Michalik * @lock: protect access to ports list
207d938a8ccSMichal Michalik */
208d938a8ccSMichal Michalik struct ice_ptp_port_owner {
209d938a8ccSMichal Michalik struct auxiliary_driver aux_driver;
210d938a8ccSMichal Michalik struct list_head ports;
211d938a8ccSMichal Michalik struct mutex lock;
212d938a8ccSMichal Michalik };
213d938a8ccSMichal Michalik
214172db5f9SMaciej Machnikowski #define GLTSYN_TGT_H_IDX_MAX 4
215172db5f9SMaciej Machnikowski
2168293e4cbSJacob Keller enum ice_ptp_state {
2178293e4cbSJacob Keller ICE_PTP_UNINIT = 0,
2188293e4cbSJacob Keller ICE_PTP_INITIALIZING,
2198293e4cbSJacob Keller ICE_PTP_READY,
2208293e4cbSJacob Keller ICE_PTP_RESETTING,
2218293e4cbSJacob Keller ICE_PTP_ERROR,
2228293e4cbSJacob Keller };
2238293e4cbSJacob Keller
22406c16d89SJacob Keller /**
22506c16d89SJacob Keller * struct ice_ptp - data used for integrating with CONFIG_PTP_1588_CLOCK
2268293e4cbSJacob Keller * @state: current state of PTP state machine
227d938a8ccSMichal Michalik * @tx_interrupt_mode: the TX interrupt mode for the PTP clock
228ea9b847cSJacob Keller * @port: data for the PHY port initialization procedure
229d938a8ccSMichal Michalik * @ports_owner: data for the auxiliary driver owner
23077a78115SJacob Keller * @work: delayed work function for periodic tasks
23177a78115SJacob Keller * @cached_phc_time: a cached copy of the PHC time for timestamp extension
232cd25507aSJacob Keller * @cached_phc_jiffies: jiffies when cached_phc_time was last updated
233172db5f9SMaciej Machnikowski * @ext_ts_chan: the external timestamp channel in use
234172db5f9SMaciej Machnikowski * @ext_ts_irq: the external timestamp IRQ in use
23577a78115SJacob Keller * @kworker: kwork thread for handling periodic work
236172db5f9SMaciej Machnikowski * @perout_channels: periodic output data
23700d3b4f5SMilena Olech * @extts_channels: channels for external timestamps
23806c16d89SJacob Keller * @info: structure defining PTP hardware capabilities
23906c16d89SJacob Keller * @clock: pointer to registered PTP clock device
24077a78115SJacob Keller * @tstamp_config: hardware timestamping configuration
24148096710SKarol Kolacinski * @reset_time: kernel time after clock stop on reset
242f020481bSJacob Keller * @tx_hwtstamp_skipped: number of Tx time stamp requests skipped
243f020481bSJacob Keller * @tx_hwtstamp_timeouts: number of Tx skbs discarded with no time stamp
244f020481bSJacob Keller * @tx_hwtstamp_flushed: number of Tx skbs flushed due to interface closed
245cd25507aSJacob Keller * @tx_hwtstamp_discarded: number of Tx skbs discarded due to cached PHC time
246cd25507aSJacob Keller * being too old to correctly extend timestamp
247cd25507aSJacob Keller * @late_cached_phc_updates: number of times cached PHC update is late
24806c16d89SJacob Keller */
24906c16d89SJacob Keller struct ice_ptp {
2508293e4cbSJacob Keller enum ice_ptp_state state;
251d938a8ccSMichal Michalik enum ice_ptp_tx_interrupt tx_interrupt_mode;
252ea9b847cSJacob Keller struct ice_ptp_port port;
253d938a8ccSMichal Michalik struct ice_ptp_port_owner ports_owner;
25477a78115SJacob Keller struct kthread_delayed_work work;
25577a78115SJacob Keller u64 cached_phc_time;
256cd25507aSJacob Keller unsigned long cached_phc_jiffies;
257172db5f9SMaciej Machnikowski u8 ext_ts_chan;
258172db5f9SMaciej Machnikowski u8 ext_ts_irq;
25977a78115SJacob Keller struct kthread_worker *kworker;
260172db5f9SMaciej Machnikowski struct ice_perout_channel perout_channels[GLTSYN_TGT_H_IDX_MAX];
26100d3b4f5SMilena Olech struct ice_extts_channel extts_channels[GLTSYN_TGT_H_IDX_MAX];
26206c16d89SJacob Keller struct ptp_clock_info info;
26306c16d89SJacob Keller struct ptp_clock *clock;
26477a78115SJacob Keller struct hwtstamp_config tstamp_config;
26548096710SKarol Kolacinski u64 reset_time;
266f020481bSJacob Keller u32 tx_hwtstamp_skipped;
267f020481bSJacob Keller u32 tx_hwtstamp_timeouts;
268f020481bSJacob Keller u32 tx_hwtstamp_flushed;
269cd25507aSJacob Keller u32 tx_hwtstamp_discarded;
270cd25507aSJacob Keller u32 late_cached_phc_updates;
27106c16d89SJacob Keller };
27206c16d89SJacob Keller
273ea9b847cSJacob Keller #define __ptp_port_to_ptp(p) \
274ea9b847cSJacob Keller container_of((p), struct ice_ptp, port)
275ea9b847cSJacob Keller #define ptp_port_to_pf(p) \
276ea9b847cSJacob Keller container_of(__ptp_port_to_ptp((p)), struct ice_pf, ptp)
277ea9b847cSJacob Keller
27806c16d89SJacob Keller #define __ptp_info_to_ptp(i) \
27906c16d89SJacob Keller container_of((i), struct ice_ptp, info)
28006c16d89SJacob Keller #define ptp_info_to_pf(i) \
28106c16d89SJacob Keller container_of(__ptp_info_to_ptp((i)), struct ice_pf, ptp)
28206c16d89SJacob Keller
2833a749623SJacob Keller #define PFTSYN_SEM_BYTES 4
28406c16d89SJacob Keller #define PTP_SHARED_CLK_IDX_VALID BIT(31)
2853a749623SJacob Keller #define TS_CMD_MASK 0xF
2863a749623SJacob Keller #define SYNC_EXEC_CMD 0x3
28777a78115SJacob Keller #define ICE_PTP_TS_VALID BIT(0)
28806c16d89SJacob Keller
2893a749623SJacob Keller #define FIFO_EMPTY BIT(2)
2903a749623SJacob Keller #define FIFO_OK 0xFF
2913a749623SJacob Keller #define ICE_PTP_FIFO_NUM_CHECKS 5
292172db5f9SMaciej Machnikowski /* Per-channel register definitions */
293172db5f9SMaciej Machnikowski #define GLTSYN_AUX_OUT(_chan, _idx) (GLTSYN_AUX_OUT_0(_idx) + ((_chan) * 8))
294172db5f9SMaciej Machnikowski #define GLTSYN_AUX_IN(_chan, _idx) (GLTSYN_AUX_IN_0(_idx) + ((_chan) * 8))
295172db5f9SMaciej Machnikowski #define GLTSYN_CLKO(_chan, _idx) (GLTSYN_CLKO_0(_idx) + ((_chan) * 8))
296172db5f9SMaciej Machnikowski #define GLTSYN_TGT_L(_chan, _idx) (GLTSYN_TGT_L_0(_idx) + ((_chan) * 16))
297172db5f9SMaciej Machnikowski #define GLTSYN_TGT_H(_chan, _idx) (GLTSYN_TGT_H_0(_idx) + ((_chan) * 16))
298172db5f9SMaciej Machnikowski #define GLTSYN_EVNT_L(_chan, _idx) (GLTSYN_EVNT_L_0(_idx) + ((_chan) * 16))
299172db5f9SMaciej Machnikowski #define GLTSYN_EVNT_H(_chan, _idx) (GLTSYN_EVNT_H_0(_idx) + ((_chan) * 16))
300172db5f9SMaciej Machnikowski #define GLTSYN_EVNT_H_IDX_MAX 3
301172db5f9SMaciej Machnikowski
302172db5f9SMaciej Machnikowski /* Pin definitions for PTP PPS out */
303172db5f9SMaciej Machnikowski #define PPS_CLK_GEN_CHAN 3
304172db5f9SMaciej Machnikowski #define PPS_CLK_SRC_CHAN 2
305172db5f9SMaciej Machnikowski #define PPS_PIN_INDEX 5
306172db5f9SMaciej Machnikowski #define TIME_SYNC_PIN_INDEX 4
307325b2064SMaciej Machnikowski #define N_EXT_TS_E810 3
308325b2064SMaciej Machnikowski #define N_PER_OUT_E810 4
309325b2064SMaciej Machnikowski #define N_PER_OUT_E810T 3
31043c4958aSArkadiusz Kubalewski #define N_PER_OUT_NO_SMA_E810T 2
31143c4958aSArkadiusz Kubalewski #define N_EXT_TS_NO_SMA_E810T 2
3123a749623SJacob Keller #define ETH_GLTSYN_ENA(_i) (0x03000348 + ((_i) * 4))
313172db5f9SMaciej Machnikowski
31406c16d89SJacob Keller #if IS_ENABLED(CONFIG_PTP_1588_CLOCK)
315fcd2c1e3SMichal Michalik int ice_ptp_clock_index(struct ice_pf *pf);
31606c16d89SJacob Keller struct ice_pf;
31777a78115SJacob Keller int ice_ptp_set_ts_config(struct ice_pf *pf, struct ifreq *ifr);
31877a78115SJacob Keller int ice_ptp_get_ts_config(struct ice_pf *pf, struct ifreq *ifr);
31977580179SJacob Keller void ice_ptp_restore_timestamp_mode(struct ice_pf *pf);
320ea9b847cSJacob Keller
3216e8b2c88SKarol Kolacinski void ice_ptp_extts_event(struct ice_pf *pf);
322ea9b847cSJacob Keller s8 ice_ptp_request_ts(struct ice_ptp_tx *tx, struct sk_buff *skb);
32382e71b22SKarol Kolacinski void ice_ptp_req_tx_single_tstamp(struct ice_ptp_tx *tx, u8 idx);
32482e71b22SKarol Kolacinski void ice_ptp_complete_tx_single_tstamp(struct ice_ptp_tx *tx);
325ae39eb42SJacob Keller enum ice_tx_tstamp_work ice_ptp_process_ts(struct ice_pf *pf);
326ea9b847cSJacob Keller
3273310aad2SLarysa Zaremba u64 ice_ptp_get_rx_hwts(const union ice_32b_rx_flex_desc *rx_desc,
3289031d5f4SLarysa Zaremba const struct ice_pkt_ctx *pkt_ctx);
329803bef81SJacob Keller void ice_ptp_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type);
330c75d5e67SJacob Keller void ice_ptp_prepare_for_reset(struct ice_pf *pf,
331c75d5e67SJacob Keller enum ice_reset_req reset_type);
33206c16d89SJacob Keller void ice_ptp_init(struct ice_pf *pf);
33306c16d89SJacob Keller void ice_ptp_release(struct ice_pf *pf);
3346b1ff5d3SJacob Keller void ice_ptp_link_change(struct ice_pf *pf, u8 port, bool linkup);
33506c16d89SJacob Keller #else /* IS_ENABLED(CONFIG_PTP_1588_CLOCK) */
ice_ptp_set_ts_config(struct ice_pf * pf,struct ifreq * ifr)33677a78115SJacob Keller static inline int ice_ptp_set_ts_config(struct ice_pf *pf, struct ifreq *ifr)
33777a78115SJacob Keller {
33877a78115SJacob Keller return -EOPNOTSUPP;
33977a78115SJacob Keller }
34077a78115SJacob Keller
ice_ptp_get_ts_config(struct ice_pf * pf,struct ifreq * ifr)34177a78115SJacob Keller static inline int ice_ptp_get_ts_config(struct ice_pf *pf, struct ifreq *ifr)
34277a78115SJacob Keller {
34377a78115SJacob Keller return -EOPNOTSUPP;
34477a78115SJacob Keller }
34577a78115SJacob Keller
ice_ptp_restore_timestamp_mode(struct ice_pf * pf)34677580179SJacob Keller static inline void ice_ptp_restore_timestamp_mode(struct ice_pf *pf) { }
ice_ptp_extts_event(struct ice_pf * pf)3476e8b2c88SKarol Kolacinski static inline void ice_ptp_extts_event(struct ice_pf *pf) { }
3484d7f75feSLorenzo Bianconi static inline s8
ice_ptp_request_ts(struct ice_ptp_tx * tx,struct sk_buff * skb)349ea9b847cSJacob Keller ice_ptp_request_ts(struct ice_ptp_tx *tx, struct sk_buff *skb)
350ea9b847cSJacob Keller {
351ea9b847cSJacob Keller return -1;
352ea9b847cSJacob Keller }
353ea9b847cSJacob Keller
ice_ptp_req_tx_single_tstamp(struct ice_ptp_tx * tx,u8 idx)35482e71b22SKarol Kolacinski static inline void ice_ptp_req_tx_single_tstamp(struct ice_ptp_tx *tx, u8 idx)
35582e71b22SKarol Kolacinski { }
35682e71b22SKarol Kolacinski
ice_ptp_complete_tx_single_tstamp(struct ice_ptp_tx * tx)35782e71b22SKarol Kolacinski static inline void ice_ptp_complete_tx_single_tstamp(struct ice_ptp_tx *tx) { }
35882e71b22SKarol Kolacinski
ice_ptp_process_ts(struct ice_pf * pf)3591229b339SKarol Kolacinski static inline bool ice_ptp_process_ts(struct ice_pf *pf)
3601229b339SKarol Kolacinski {
3611229b339SKarol Kolacinski return true;
3621229b339SKarol Kolacinski }
3633310aad2SLarysa Zaremba
3643310aad2SLarysa Zaremba static inline u64
ice_ptp_get_rx_hwts(const union ice_32b_rx_flex_desc * rx_desc,const struct ice_pkt_ctx * pkt_ctx)3653310aad2SLarysa Zaremba ice_ptp_get_rx_hwts(const union ice_32b_rx_flex_desc *rx_desc,
3669031d5f4SLarysa Zaremba const struct ice_pkt_ctx *pkt_ctx)
3673310aad2SLarysa Zaremba {
3683310aad2SLarysa Zaremba return 0;
3693310aad2SLarysa Zaremba }
3703310aad2SLarysa Zaremba
ice_ptp_rebuild(struct ice_pf * pf,enum ice_reset_req reset_type)371803bef81SJacob Keller static inline void ice_ptp_rebuild(struct ice_pf *pf,
372c75d5e67SJacob Keller enum ice_reset_req reset_type)
373c75d5e67SJacob Keller {
374c75d5e67SJacob Keller }
375c75d5e67SJacob Keller
ice_ptp_prepare_for_reset(struct ice_pf * pf,enum ice_reset_req reset_type)376c75d5e67SJacob Keller static inline void ice_ptp_prepare_for_reset(struct ice_pf *pf,
377c75d5e67SJacob Keller enum ice_reset_req reset_type)
378c75d5e67SJacob Keller {
379c75d5e67SJacob Keller }
ice_ptp_init(struct ice_pf * pf)38006c16d89SJacob Keller static inline void ice_ptp_init(struct ice_pf *pf) { }
ice_ptp_release(struct ice_pf * pf)38106c16d89SJacob Keller static inline void ice_ptp_release(struct ice_pf *pf) { }
ice_ptp_link_change(struct ice_pf * pf,u8 port,bool linkup)3826b1ff5d3SJacob Keller static inline void ice_ptp_link_change(struct ice_pf *pf, u8 port, bool linkup)
3836b1ff5d3SJacob Keller {
3846b1ff5d3SJacob Keller }
385fcd2c1e3SMichal Michalik
ice_ptp_clock_index(struct ice_pf * pf)386fcd2c1e3SMichal Michalik static inline int ice_ptp_clock_index(struct ice_pf *pf)
387fcd2c1e3SMichal Michalik {
388fcd2c1e3SMichal Michalik return -1;
389fcd2c1e3SMichal Michalik }
39006c16d89SJacob Keller #endif /* IS_ENABLED(CONFIG_PTP_1588_CLOCK) */
39106c16d89SJacob Keller #endif /* _ICE_PTP_H_ */
392