WIP FPC-III support
[linux/fpc-iii.git] / drivers / net / ethernet / aquantia / atlantic / aq_ptp.h
blob28ccb7ca2df9e7d5b71b92c8dce9bea3b21d3a5e
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Atlantic Network Driver
4 * Copyright (C) 2014-2019 aQuantia Corporation
5 * Copyright (C) 2019-2020 Marvell International Ltd.
6 */
8 /* File aq_ptp.h: Declaration of PTP functions.
9 */
10 #ifndef AQ_PTP_H
11 #define AQ_PTP_H
13 #include <linux/net_tstamp.h>
15 #include "aq_ring.h"
17 #define PTP_8TC_RING_IDX 8
18 #define PTP_4TC_RING_IDX 16
19 #define PTP_HWST_RING_IDX 31
21 /* Index must to be 8 (8 TCs) or 16 (4 TCs).
22 * It depends from Traffic Class mode.
24 static inline unsigned int aq_ptp_ring_idx(const enum aq_tc_mode tc_mode)
26 if (tc_mode == AQ_TC_MODE_8TCS)
27 return PTP_8TC_RING_IDX;
29 return PTP_4TC_RING_IDX;
32 #if IS_REACHABLE(CONFIG_PTP_1588_CLOCK)
34 /* Common functions */
35 int aq_ptp_init(struct aq_nic_s *aq_nic, unsigned int idx_vec);
37 void aq_ptp_unregister(struct aq_nic_s *aq_nic);
38 void aq_ptp_free(struct aq_nic_s *aq_nic);
40 int aq_ptp_irq_alloc(struct aq_nic_s *aq_nic);
41 void aq_ptp_irq_free(struct aq_nic_s *aq_nic);
43 int aq_ptp_ring_alloc(struct aq_nic_s *aq_nic);
44 void aq_ptp_ring_free(struct aq_nic_s *aq_nic);
46 int aq_ptp_ring_init(struct aq_nic_s *aq_nic);
47 int aq_ptp_ring_start(struct aq_nic_s *aq_nic);
48 void aq_ptp_ring_stop(struct aq_nic_s *aq_nic);
49 void aq_ptp_ring_deinit(struct aq_nic_s *aq_nic);
51 void aq_ptp_service_task(struct aq_nic_s *aq_nic);
53 void aq_ptp_tm_offset_set(struct aq_nic_s *aq_nic, unsigned int mbps);
55 void aq_ptp_clock_init(struct aq_nic_s *aq_nic);
57 /* Traffic processing functions */
58 int aq_ptp_xmit(struct aq_nic_s *aq_nic, struct sk_buff *skb);
59 void aq_ptp_tx_hwtstamp(struct aq_nic_s *aq_nic, u64 timestamp);
61 /* Must be to check available of PTP before call */
62 void aq_ptp_hwtstamp_config_get(struct aq_ptp_s *aq_ptp,
63 struct hwtstamp_config *config);
64 int aq_ptp_hwtstamp_config_set(struct aq_ptp_s *aq_ptp,
65 struct hwtstamp_config *config);
67 /* Return either ring is belong to PTP or not*/
68 bool aq_ptp_ring(struct aq_nic_s *aq_nic, struct aq_ring_s *ring);
70 u16 aq_ptp_extract_ts(struct aq_nic_s *aq_nic, struct sk_buff *skb, u8 *p,
71 unsigned int len);
73 struct ptp_clock *aq_ptp_get_ptp_clock(struct aq_ptp_s *aq_ptp);
75 int aq_ptp_link_change(struct aq_nic_s *aq_nic);
77 /* PTP ring statistics */
78 int aq_ptp_get_ring_cnt(struct aq_nic_s *aq_nic, const enum atl_ring_type ring_type);
79 u64 *aq_ptp_get_stats(struct aq_nic_s *aq_nic, u64 *data);
81 #else
83 static inline int aq_ptp_init(struct aq_nic_s *aq_nic, unsigned int idx_vec)
85 return 0;
88 static inline void aq_ptp_unregister(struct aq_nic_s *aq_nic) {}
90 static inline void aq_ptp_free(struct aq_nic_s *aq_nic)
94 static inline int aq_ptp_irq_alloc(struct aq_nic_s *aq_nic)
96 return 0;
99 static inline void aq_ptp_irq_free(struct aq_nic_s *aq_nic)
103 static inline int aq_ptp_ring_alloc(struct aq_nic_s *aq_nic)
105 return 0;
108 static inline void aq_ptp_ring_free(struct aq_nic_s *aq_nic) {}
110 static inline int aq_ptp_ring_init(struct aq_nic_s *aq_nic)
112 return 0;
115 static inline int aq_ptp_ring_start(struct aq_nic_s *aq_nic)
117 return 0;
120 static inline void aq_ptp_ring_stop(struct aq_nic_s *aq_nic) {}
121 static inline void aq_ptp_ring_deinit(struct aq_nic_s *aq_nic) {}
122 static inline void aq_ptp_service_task(struct aq_nic_s *aq_nic) {}
123 static inline void aq_ptp_tm_offset_set(struct aq_nic_s *aq_nic,
124 unsigned int mbps) {}
125 static inline void aq_ptp_clock_init(struct aq_nic_s *aq_nic) {}
126 static inline int aq_ptp_xmit(struct aq_nic_s *aq_nic, struct sk_buff *skb)
128 return -EOPNOTSUPP;
131 static inline void aq_ptp_tx_hwtstamp(struct aq_nic_s *aq_nic, u64 timestamp) {}
132 static inline void aq_ptp_hwtstamp_config_get(struct aq_ptp_s *aq_ptp,
133 struct hwtstamp_config *config) {}
134 static inline int aq_ptp_hwtstamp_config_set(struct aq_ptp_s *aq_ptp,
135 struct hwtstamp_config *config)
137 return 0;
140 static inline bool aq_ptp_ring(struct aq_nic_s *aq_nic, struct aq_ring_s *ring)
142 return false;
145 static inline u16 aq_ptp_extract_ts(struct aq_nic_s *aq_nic,
146 struct sk_buff *skb, u8 *p,
147 unsigned int len)
149 return 0;
152 static inline struct ptp_clock *aq_ptp_get_ptp_clock(struct aq_ptp_s *aq_ptp)
154 return NULL;
157 static inline int aq_ptp_link_change(struct aq_nic_s *aq_nic)
159 return 0;
161 #endif
163 #endif /* AQ_PTP_H */