1 | /* SPDX-License-Identifier: (GPL-2.0 OR MIT) */ |
2 | // Copyright (c) 2018 Synopsys, Inc. and/or its affiliates. |
3 | // stmmac HW Interface Callbacks |
4 | |
5 | #ifndef __STMMAC_HWIF_H__ |
6 | #define __STMMAC_HWIF_H__ |
7 | |
8 | #include <linux/netdevice.h> |
9 | #include <linux/stmmac.h> |
10 | #include <net/pkt_cls.h> |
11 | |
12 | #define stmmac_do_void_callback(__priv, __module, __cname, __arg0, __args...) \ |
13 | ({ \ |
14 | int __result = -EINVAL; \ |
15 | if ((__priv)->hw->__module && (__priv)->hw->__module->__cname) { \ |
16 | (__priv)->hw->__module->__cname((__arg0), ##__args); \ |
17 | __result = 0; \ |
18 | } \ |
19 | __result; \ |
20 | }) |
21 | #define stmmac_do_callback(__priv, __module, __cname, __arg0, __args...) \ |
22 | ({ \ |
23 | int __result = -EINVAL; \ |
24 | if ((__priv)->hw->__module && (__priv)->hw->__module->__cname) \ |
25 | __result = (__priv)->hw->__module->__cname((__arg0), ##__args); \ |
26 | __result; \ |
27 | }) |
28 | |
29 | struct ; |
30 | struct stmmac_priv; |
31 | struct stmmac_safety_stats; |
32 | struct stmmac_fpe_cfg; |
33 | enum stmmac_mpacket_type; |
34 | struct dma_desc; |
35 | struct dma_extended_desc; |
36 | struct dma_edesc; |
37 | |
38 | /* Descriptors helpers */ |
39 | struct stmmac_desc_ops { |
40 | /* DMA RX descriptor ring initialization */ |
41 | void (*init_rx_desc)(struct dma_desc *p, int disable_rx_ic, int mode, |
42 | int end, int bfsize); |
43 | /* DMA TX descriptor ring initialization */ |
44 | void (*init_tx_desc)(struct dma_desc *p, int mode, int end); |
45 | /* Invoked by the xmit function to prepare the tx descriptor */ |
46 | void (*prepare_tx_desc)(struct dma_desc *p, int is_fs, int len, |
47 | bool csum_flag, int mode, bool tx_own, bool ls, |
48 | unsigned int tot_pkt_len); |
49 | void (*prepare_tso_tx_desc)(struct dma_desc *p, int is_fs, int len1, |
50 | int len2, bool tx_own, bool ls, unsigned int tcphdrlen, |
51 | unsigned int tcppayloadlen); |
52 | /* Set/get the owner of the descriptor */ |
53 | void (*set_tx_owner)(struct dma_desc *p); |
54 | int (*get_tx_owner)(struct dma_desc *p); |
55 | /* Clean the tx descriptor as soon as the tx irq is received */ |
56 | void (*release_tx_desc)(struct dma_desc *p, int mode); |
57 | /* Clear interrupt on tx frame completion. When this bit is |
58 | * set an interrupt happens as soon as the frame is transmitted */ |
59 | void (*set_tx_ic)(struct dma_desc *p); |
60 | /* Last tx segment reports the transmit status */ |
61 | int (*get_tx_ls)(struct dma_desc *p); |
62 | /* Get the tag of the descriptor */ |
63 | u16 (*get_rx_vlan_tci)(struct dma_desc *p); |
64 | /* Get the valid status of descriptor */ |
65 | bool (*get_rx_vlan_valid)(struct dma_desc *p); |
66 | /* Return the transmit status looking at the TDES1 */ |
67 | int (*tx_status)(struct stmmac_extra_stats *x, |
68 | struct dma_desc *p, void __iomem *ioaddr); |
69 | /* Get the buffer size from the descriptor */ |
70 | int (*get_tx_len)(struct dma_desc *p); |
71 | /* Handle extra events on specific interrupts hw dependent */ |
72 | void (*set_rx_owner)(struct dma_desc *p, int disable_rx_ic); |
73 | /* Get the receive frame size */ |
74 | int (*get_rx_frame_len)(struct dma_desc *p, int rx_coe_type); |
75 | /* Return the reception status looking at the RDES1 */ |
76 | int (*rx_status)(struct stmmac_extra_stats *x, |
77 | struct dma_desc *p); |
78 | void (*rx_extended_status)(struct stmmac_extra_stats *x, |
79 | struct dma_extended_desc *p); |
80 | /* Set tx timestamp enable bit */ |
81 | void (*enable_tx_timestamp) (struct dma_desc *p); |
82 | /* get tx timestamp status */ |
83 | int (*get_tx_timestamp_status) (struct dma_desc *p); |
84 | /* get timestamp value */ |
85 | void (*get_timestamp)(void *desc, u32 ats, u64 *ts); |
86 | /* get rx timestamp status */ |
87 | int (*get_rx_timestamp_status)(void *desc, void *next_desc, u32 ats); |
88 | /* Display ring */ |
89 | void (*display_ring)(void *head, unsigned int size, bool rx, |
90 | dma_addr_t dma_rx_phy, unsigned int desc_size); |
91 | /* set MSS via context descriptor */ |
92 | void (*set_mss)(struct dma_desc *p, unsigned int mss); |
93 | /* set descriptor skbuff address */ |
94 | void (*set_addr)(struct dma_desc *p, dma_addr_t addr); |
95 | /* clear descriptor */ |
96 | void (*clear)(struct dma_desc *p); |
97 | /* RSS */ |
98 | int (*get_rx_hash)(struct dma_desc *p, u32 *hash, |
99 | enum pkt_hash_types *type); |
100 | void (*)(struct dma_desc *p, unsigned int *len); |
101 | void (*set_sec_addr)(struct dma_desc *p, dma_addr_t addr, bool buf2_valid); |
102 | void (*set_sarc)(struct dma_desc *p, u32 sarc_type); |
103 | void (*set_vlan_tag)(struct dma_desc *p, u16 tag, u16 inner_tag, |
104 | u32 inner_type); |
105 | void (*set_vlan)(struct dma_desc *p, u32 type); |
106 | void (*set_tbs)(struct dma_edesc *p, u32 sec, u32 nsec); |
107 | }; |
108 | |
109 | #define stmmac_init_rx_desc(__priv, __args...) \ |
110 | stmmac_do_void_callback(__priv, desc, init_rx_desc, __args) |
111 | #define stmmac_init_tx_desc(__priv, __args...) \ |
112 | stmmac_do_void_callback(__priv, desc, init_tx_desc, __args) |
113 | #define stmmac_prepare_tx_desc(__priv, __args...) \ |
114 | stmmac_do_void_callback(__priv, desc, prepare_tx_desc, __args) |
115 | #define stmmac_prepare_tso_tx_desc(__priv, __args...) \ |
116 | stmmac_do_void_callback(__priv, desc, prepare_tso_tx_desc, __args) |
117 | #define stmmac_set_tx_owner(__priv, __args...) \ |
118 | stmmac_do_void_callback(__priv, desc, set_tx_owner, __args) |
119 | #define stmmac_get_tx_owner(__priv, __args...) \ |
120 | stmmac_do_callback(__priv, desc, get_tx_owner, __args) |
121 | #define stmmac_release_tx_desc(__priv, __args...) \ |
122 | stmmac_do_void_callback(__priv, desc, release_tx_desc, __args) |
123 | #define stmmac_set_tx_ic(__priv, __args...) \ |
124 | stmmac_do_void_callback(__priv, desc, set_tx_ic, __args) |
125 | #define stmmac_get_tx_ls(__priv, __args...) \ |
126 | stmmac_do_callback(__priv, desc, get_tx_ls, __args) |
127 | #define stmmac_get_rx_vlan_tci(__priv, __args...) \ |
128 | stmmac_do_callback(__priv, desc, get_rx_vlan_tci, __args) |
129 | #define stmmac_get_rx_vlan_valid(__priv, __args...) \ |
130 | stmmac_do_callback(__priv, desc, get_rx_vlan_valid, __args) |
131 | #define stmmac_tx_status(__priv, __args...) \ |
132 | stmmac_do_callback(__priv, desc, tx_status, __args) |
133 | #define stmmac_get_tx_len(__priv, __args...) \ |
134 | stmmac_do_callback(__priv, desc, get_tx_len, __args) |
135 | #define stmmac_set_rx_owner(__priv, __args...) \ |
136 | stmmac_do_void_callback(__priv, desc, set_rx_owner, __args) |
137 | #define stmmac_get_rx_frame_len(__priv, __args...) \ |
138 | stmmac_do_callback(__priv, desc, get_rx_frame_len, __args) |
139 | #define stmmac_rx_status(__priv, __args...) \ |
140 | stmmac_do_callback(__priv, desc, rx_status, __args) |
141 | #define stmmac_rx_extended_status(__priv, __args...) \ |
142 | stmmac_do_void_callback(__priv, desc, rx_extended_status, __args) |
143 | #define stmmac_enable_tx_timestamp(__priv, __args...) \ |
144 | stmmac_do_void_callback(__priv, desc, enable_tx_timestamp, __args) |
145 | #define stmmac_get_tx_timestamp_status(__priv, __args...) \ |
146 | stmmac_do_callback(__priv, desc, get_tx_timestamp_status, __args) |
147 | #define stmmac_get_timestamp(__priv, __args...) \ |
148 | stmmac_do_void_callback(__priv, desc, get_timestamp, __args) |
149 | #define stmmac_get_rx_timestamp_status(__priv, __args...) \ |
150 | stmmac_do_callback(__priv, desc, get_rx_timestamp_status, __args) |
151 | #define stmmac_display_ring(__priv, __args...) \ |
152 | stmmac_do_void_callback(__priv, desc, display_ring, __args) |
153 | #define stmmac_set_mss(__priv, __args...) \ |
154 | stmmac_do_void_callback(__priv, desc, set_mss, __args) |
155 | #define stmmac_set_desc_addr(__priv, __args...) \ |
156 | stmmac_do_void_callback(__priv, desc, set_addr, __args) |
157 | #define stmmac_clear_desc(__priv, __args...) \ |
158 | stmmac_do_void_callback(__priv, desc, clear, __args) |
159 | #define stmmac_get_rx_hash(__priv, __args...) \ |
160 | stmmac_do_callback(__priv, desc, get_rx_hash, __args) |
161 | #define (__priv, __args...) \ |
162 | stmmac_do_void_callback(__priv, desc, get_rx_header_len, __args) |
163 | #define stmmac_set_desc_sec_addr(__priv, __args...) \ |
164 | stmmac_do_void_callback(__priv, desc, set_sec_addr, __args) |
165 | #define stmmac_set_desc_sarc(__priv, __args...) \ |
166 | stmmac_do_void_callback(__priv, desc, set_sarc, __args) |
167 | #define stmmac_set_desc_vlan_tag(__priv, __args...) \ |
168 | stmmac_do_void_callback(__priv, desc, set_vlan_tag, __args) |
169 | #define stmmac_set_desc_vlan(__priv, __args...) \ |
170 | stmmac_do_void_callback(__priv, desc, set_vlan, __args) |
171 | #define stmmac_set_desc_tbs(__priv, __args...) \ |
172 | stmmac_do_void_callback(__priv, desc, set_tbs, __args) |
173 | |
174 | struct stmmac_dma_cfg; |
175 | struct dma_features; |
176 | |
177 | /* Specific DMA helpers */ |
178 | struct stmmac_dma_ops { |
179 | /* DMA core initialization */ |
180 | int (*reset)(void __iomem *ioaddr); |
181 | void (*init)(void __iomem *ioaddr, struct stmmac_dma_cfg *dma_cfg); |
182 | void (*init_chan)(struct stmmac_priv *priv, void __iomem *ioaddr, |
183 | struct stmmac_dma_cfg *dma_cfg, u32 chan); |
184 | void (*init_rx_chan)(struct stmmac_priv *priv, void __iomem *ioaddr, |
185 | struct stmmac_dma_cfg *dma_cfg, |
186 | dma_addr_t phy, u32 chan); |
187 | void (*init_tx_chan)(struct stmmac_priv *priv, void __iomem *ioaddr, |
188 | struct stmmac_dma_cfg *dma_cfg, |
189 | dma_addr_t phy, u32 chan); |
190 | /* Configure the AXI Bus Mode Register */ |
191 | void (*axi)(void __iomem *ioaddr, struct stmmac_axi *axi); |
192 | /* Dump DMA registers */ |
193 | void (*dump_regs)(struct stmmac_priv *priv, void __iomem *ioaddr, |
194 | u32 *reg_space); |
195 | void (*dma_rx_mode)(struct stmmac_priv *priv, void __iomem *ioaddr, |
196 | int mode, u32 channel, |
197 | int fifosz, u8 qmode); |
198 | void (*dma_tx_mode)(struct stmmac_priv *priv, void __iomem *ioaddr, |
199 | int mode, u32 channel, int fifosz, u8 qmode); |
200 | /* To track extra statistic (if supported) */ |
201 | void (*dma_diagnostic_fr)(struct stmmac_extra_stats *x, |
202 | void __iomem *ioaddr); |
203 | void (*enable_dma_transmission)(void __iomem *ioaddr, u32 chan); |
204 | void (*enable_dma_irq)(struct stmmac_priv *priv, void __iomem *ioaddr, |
205 | u32 chan, bool rx, bool tx); |
206 | void (*disable_dma_irq)(struct stmmac_priv *priv, void __iomem *ioaddr, |
207 | u32 chan, bool rx, bool tx); |
208 | void (*start_tx)(struct stmmac_priv *priv, void __iomem *ioaddr, |
209 | u32 chan); |
210 | void (*stop_tx)(struct stmmac_priv *priv, void __iomem *ioaddr, |
211 | u32 chan); |
212 | void (*start_rx)(struct stmmac_priv *priv, void __iomem *ioaddr, |
213 | u32 chan); |
214 | void (*stop_rx)(struct stmmac_priv *priv, void __iomem *ioaddr, |
215 | u32 chan); |
216 | int (*dma_interrupt)(struct stmmac_priv *priv, void __iomem *ioaddr, |
217 | struct stmmac_extra_stats *x, u32 chan, u32 dir); |
218 | /* If supported then get the optional core features */ |
219 | int (*get_hw_feature)(void __iomem *ioaddr, |
220 | struct dma_features *dma_cap); |
221 | /* Program the HW RX Watchdog */ |
222 | void (*rx_watchdog)(struct stmmac_priv *priv, void __iomem *ioaddr, |
223 | u32 riwt, u32 queue); |
224 | void (*set_tx_ring_len)(struct stmmac_priv *priv, void __iomem *ioaddr, |
225 | u32 len, u32 chan); |
226 | void (*set_rx_ring_len)(struct stmmac_priv *priv, void __iomem *ioaddr, |
227 | u32 len, u32 chan); |
228 | void (*set_rx_tail_ptr)(struct stmmac_priv *priv, void __iomem *ioaddr, |
229 | u32 tail_ptr, u32 chan); |
230 | void (*set_tx_tail_ptr)(struct stmmac_priv *priv, void __iomem *ioaddr, |
231 | u32 tail_ptr, u32 chan); |
232 | void (*enable_tso)(struct stmmac_priv *priv, void __iomem *ioaddr, |
233 | bool en, u32 chan); |
234 | void (*qmode)(struct stmmac_priv *priv, void __iomem *ioaddr, |
235 | u32 channel, u8 qmode); |
236 | void (*set_bfsize)(struct stmmac_priv *priv, void __iomem *ioaddr, |
237 | int bfsize, u32 chan); |
238 | void (*enable_sph)(struct stmmac_priv *priv, void __iomem *ioaddr, |
239 | bool en, u32 chan); |
240 | int (*enable_tbs)(struct stmmac_priv *priv, void __iomem *ioaddr, |
241 | bool en, u32 chan); |
242 | }; |
243 | |
244 | #define stmmac_dma_init(__priv, __args...) \ |
245 | stmmac_do_void_callback(__priv, dma, init, __args) |
246 | #define stmmac_init_chan(__priv, __args...) \ |
247 | stmmac_do_void_callback(__priv, dma, init_chan, __priv, __args) |
248 | #define stmmac_init_rx_chan(__priv, __args...) \ |
249 | stmmac_do_void_callback(__priv, dma, init_rx_chan, __priv, __args) |
250 | #define stmmac_init_tx_chan(__priv, __args...) \ |
251 | stmmac_do_void_callback(__priv, dma, init_tx_chan, __priv, __args) |
252 | #define stmmac_axi(__priv, __args...) \ |
253 | stmmac_do_void_callback(__priv, dma, axi, __args) |
254 | #define stmmac_dump_dma_regs(__priv, __args...) \ |
255 | stmmac_do_void_callback(__priv, dma, dump_regs, __priv, __args) |
256 | #define stmmac_dma_rx_mode(__priv, __args...) \ |
257 | stmmac_do_void_callback(__priv, dma, dma_rx_mode, __priv, __args) |
258 | #define stmmac_dma_tx_mode(__priv, __args...) \ |
259 | stmmac_do_void_callback(__priv, dma, dma_tx_mode, __priv, __args) |
260 | #define stmmac_dma_diagnostic_fr(__priv, __args...) \ |
261 | stmmac_do_void_callback(__priv, dma, dma_diagnostic_fr, __args) |
262 | #define stmmac_enable_dma_transmission(__priv, __args...) \ |
263 | stmmac_do_void_callback(__priv, dma, enable_dma_transmission, __args) |
264 | #define stmmac_enable_dma_irq(__priv, __args...) \ |
265 | stmmac_do_void_callback(__priv, dma, enable_dma_irq, __priv, __args) |
266 | #define stmmac_disable_dma_irq(__priv, __args...) \ |
267 | stmmac_do_void_callback(__priv, dma, disable_dma_irq, __priv, __args) |
268 | #define stmmac_start_tx(__priv, __args...) \ |
269 | stmmac_do_void_callback(__priv, dma, start_tx, __priv, __args) |
270 | #define stmmac_stop_tx(__priv, __args...) \ |
271 | stmmac_do_void_callback(__priv, dma, stop_tx, __priv, __args) |
272 | #define stmmac_start_rx(__priv, __args...) \ |
273 | stmmac_do_void_callback(__priv, dma, start_rx, __priv, __args) |
274 | #define stmmac_stop_rx(__priv, __args...) \ |
275 | stmmac_do_void_callback(__priv, dma, stop_rx, __priv, __args) |
276 | #define stmmac_dma_interrupt_status(__priv, __args...) \ |
277 | stmmac_do_callback(__priv, dma, dma_interrupt, __priv, __args) |
278 | #define stmmac_get_hw_feature(__priv, __args...) \ |
279 | stmmac_do_callback(__priv, dma, get_hw_feature, __args) |
280 | #define stmmac_rx_watchdog(__priv, __args...) \ |
281 | stmmac_do_void_callback(__priv, dma, rx_watchdog, __priv, __args) |
282 | #define stmmac_set_tx_ring_len(__priv, __args...) \ |
283 | stmmac_do_void_callback(__priv, dma, set_tx_ring_len, __priv, __args) |
284 | #define stmmac_set_rx_ring_len(__priv, __args...) \ |
285 | stmmac_do_void_callback(__priv, dma, set_rx_ring_len, __priv, __args) |
286 | #define stmmac_set_rx_tail_ptr(__priv, __args...) \ |
287 | stmmac_do_void_callback(__priv, dma, set_rx_tail_ptr, __priv, __args) |
288 | #define stmmac_set_tx_tail_ptr(__priv, __args...) \ |
289 | stmmac_do_void_callback(__priv, dma, set_tx_tail_ptr, __priv, __args) |
290 | #define stmmac_enable_tso(__priv, __args...) \ |
291 | stmmac_do_void_callback(__priv, dma, enable_tso, __priv, __args) |
292 | #define stmmac_dma_qmode(__priv, __args...) \ |
293 | stmmac_do_void_callback(__priv, dma, qmode, __priv, __args) |
294 | #define stmmac_set_dma_bfsize(__priv, __args...) \ |
295 | stmmac_do_void_callback(__priv, dma, set_bfsize, __priv, __args) |
296 | #define stmmac_enable_sph(__priv, __args...) \ |
297 | stmmac_do_void_callback(__priv, dma, enable_sph, __priv, __args) |
298 | #define stmmac_enable_tbs(__priv, __args...) \ |
299 | stmmac_do_callback(__priv, dma, enable_tbs, __priv, __args) |
300 | |
301 | struct mac_device_info; |
302 | struct net_device; |
303 | struct rgmii_adv; |
304 | struct stmmac_tc_entry; |
305 | struct stmmac_pps_cfg; |
306 | struct ; |
307 | struct stmmac_est; |
308 | |
309 | enum stmmac_lpi_mode { |
310 | STMMAC_LPI_DISABLE, |
311 | STMMAC_LPI_FORCED, |
312 | STMMAC_LPI_TIMER, |
313 | }; |
314 | |
315 | /* Helpers to program the MAC core */ |
316 | struct stmmac_ops { |
317 | /* MAC core initialization */ |
318 | void (*core_init)(struct mac_device_info *hw, struct net_device *dev); |
319 | /* Update MAC capabilities */ |
320 | void (*update_caps)(struct stmmac_priv *priv); |
321 | /* Enable the MAC RX/TX */ |
322 | void (*set_mac)(void __iomem *ioaddr, bool enable); |
323 | /* Enable and verify that the IPC module is supported */ |
324 | int (*rx_ipc)(struct mac_device_info *hw); |
325 | /* Enable RX Queues */ |
326 | void (*rx_queue_enable)(struct mac_device_info *hw, u8 mode, u32 queue); |
327 | /* RX Queues Priority */ |
328 | void (*rx_queue_prio)(struct mac_device_info *hw, u32 prio, u32 queue); |
329 | /* TX Queues Priority */ |
330 | void (*tx_queue_prio)(struct mac_device_info *hw, u32 prio, u32 queue); |
331 | /* RX Queues Routing */ |
332 | void (*rx_queue_routing)(struct mac_device_info *hw, u8 packet, |
333 | u32 queue); |
334 | /* Program RX Algorithms */ |
335 | void (*prog_mtl_rx_algorithms)(struct mac_device_info *hw, u32 rx_alg); |
336 | /* Program TX Algorithms */ |
337 | void (*prog_mtl_tx_algorithms)(struct mac_device_info *hw, u32 tx_alg); |
338 | /* Set MTL TX queues weight */ |
339 | void (*set_mtl_tx_queue_weight)(struct stmmac_priv *priv, |
340 | struct mac_device_info *hw, |
341 | u32 weight, u32 queue); |
342 | /* RX MTL queue to RX dma mapping */ |
343 | void (*map_mtl_to_dma)(struct mac_device_info *hw, u32 queue, u32 chan); |
344 | /* Configure AV Algorithm */ |
345 | void (*config_cbs)(struct stmmac_priv *priv, struct mac_device_info *hw, |
346 | u32 send_slope, u32 idle_slope, u32 high_credit, |
347 | u32 low_credit, u32 queue); |
348 | /* Dump MAC registers */ |
349 | void (*dump_regs)(struct mac_device_info *hw, u32 *reg_space); |
350 | /* Handle extra events on specific interrupts hw dependent */ |
351 | int (*host_irq_status)(struct mac_device_info *hw, |
352 | struct stmmac_extra_stats *x); |
353 | /* Handle MTL interrupts */ |
354 | int (*host_mtl_irq_status)(struct stmmac_priv *priv, |
355 | struct mac_device_info *hw, u32 chan); |
356 | /* Multicast filter setting */ |
357 | void (*set_filter)(struct mac_device_info *hw, struct net_device *dev); |
358 | /* Flow control setting */ |
359 | void (*flow_ctrl)(struct mac_device_info *hw, unsigned int duplex, |
360 | unsigned int fc, unsigned int pause_time, u32 tx_cnt); |
361 | /* Set power management mode (e.g. magic frame) */ |
362 | void (*pmt)(struct mac_device_info *hw, unsigned long mode); |
363 | /* Set/Get Unicast MAC addresses */ |
364 | void (*set_umac_addr)(struct mac_device_info *hw, |
365 | const unsigned char *addr, |
366 | unsigned int reg_n); |
367 | void (*get_umac_addr)(struct mac_device_info *hw, unsigned char *addr, |
368 | unsigned int reg_n); |
369 | int (*set_lpi_mode)(struct mac_device_info *hw, |
370 | enum stmmac_lpi_mode mode, |
371 | bool en_tx_lpi_clockgating, u32 et); |
372 | void (*set_eee_timer)(struct mac_device_info *hw, int ls, int tw); |
373 | void (*set_eee_pls)(struct mac_device_info *hw, int link); |
374 | void (*debug)(struct stmmac_priv *priv, void __iomem *ioaddr, |
375 | struct stmmac_extra_stats *x, u32 rx_queues, |
376 | u32 tx_queues); |
377 | /* PCS calls */ |
378 | void (*pcs_ctrl_ane)(void __iomem *ioaddr, bool ane, bool srgmi_ral, |
379 | bool loopback); |
380 | void (*pcs_get_adv_lp)(void __iomem *ioaddr, struct rgmii_adv *adv); |
381 | /* Safety Features */ |
382 | int (*safety_feat_config)(void __iomem *ioaddr, unsigned int asp, |
383 | struct stmmac_safety_feature_cfg *safety_cfg); |
384 | int (*safety_feat_irq_status)(struct net_device *ndev, |
385 | void __iomem *ioaddr, unsigned int asp, |
386 | struct stmmac_safety_stats *stats); |
387 | int (*safety_feat_dump)(struct stmmac_safety_stats *stats, |
388 | int index, unsigned long *count, const char **desc); |
389 | /* Flexible RX Parser */ |
390 | int (*rxp_config)(void __iomem *ioaddr, struct stmmac_tc_entry *entries, |
391 | unsigned int count); |
392 | /* Flexible PPS */ |
393 | int (*flex_pps_config)(void __iomem *ioaddr, int index, |
394 | struct stmmac_pps_cfg *cfg, bool enable, |
395 | u32 sub_second_inc, u32 systime_flags); |
396 | /* Loopback for selftests */ |
397 | void (*set_mac_loopback)(void __iomem *ioaddr, bool enable); |
398 | /* RSS */ |
399 | int (*)(struct mac_device_info *hw, |
400 | struct stmmac_rss *cfg, u32 num_rxq); |
401 | /* TX Timestamp */ |
402 | int (*get_mac_tx_timestamp)(struct mac_device_info *hw, u64 *ts); |
403 | /* Source Address Insertion / Replacement */ |
404 | void (*sarc_configure)(void __iomem *ioaddr, int val); |
405 | /* Filtering */ |
406 | int (*config_l3_filter)(struct mac_device_info *hw, u32 filter_no, |
407 | bool en, bool ipv6, bool sa, bool inv, |
408 | u32 match); |
409 | int (*config_l4_filter)(struct mac_device_info *hw, u32 filter_no, |
410 | bool en, bool udp, bool sa, bool inv, |
411 | u32 match); |
412 | void (*set_arp_offload)(struct mac_device_info *hw, bool en, u32 addr); |
413 | int (*fpe_map_preemption_class)(struct net_device *ndev, |
414 | struct netlink_ext_ack *extack, |
415 | u32 pclass); |
416 | }; |
417 | |
418 | #define stmmac_core_init(__priv, __args...) \ |
419 | stmmac_do_void_callback(__priv, mac, core_init, __args) |
420 | #define stmmac_mac_update_caps(__priv) \ |
421 | stmmac_do_void_callback(__priv, mac, update_caps, __priv) |
422 | #define stmmac_mac_set(__priv, __args...) \ |
423 | stmmac_do_void_callback(__priv, mac, set_mac, __args) |
424 | #define stmmac_rx_ipc(__priv, __args...) \ |
425 | stmmac_do_callback(__priv, mac, rx_ipc, __args) |
426 | #define stmmac_rx_queue_enable(__priv, __args...) \ |
427 | stmmac_do_void_callback(__priv, mac, rx_queue_enable, __args) |
428 | #define stmmac_rx_queue_prio(__priv, __args...) \ |
429 | stmmac_do_void_callback(__priv, mac, rx_queue_prio, __args) |
430 | #define stmmac_tx_queue_prio(__priv, __args...) \ |
431 | stmmac_do_void_callback(__priv, mac, tx_queue_prio, __args) |
432 | #define stmmac_rx_queue_routing(__priv, __args...) \ |
433 | stmmac_do_void_callback(__priv, mac, rx_queue_routing, __args) |
434 | #define stmmac_prog_mtl_rx_algorithms(__priv, __args...) \ |
435 | stmmac_do_void_callback(__priv, mac, prog_mtl_rx_algorithms, __args) |
436 | #define stmmac_prog_mtl_tx_algorithms(__priv, __args...) \ |
437 | stmmac_do_void_callback(__priv, mac, prog_mtl_tx_algorithms, __args) |
438 | #define stmmac_set_mtl_tx_queue_weight(__priv, __args...) \ |
439 | stmmac_do_void_callback(__priv, mac, set_mtl_tx_queue_weight, __priv, __args) |
440 | #define stmmac_map_mtl_to_dma(__priv, __args...) \ |
441 | stmmac_do_void_callback(__priv, mac, map_mtl_to_dma, __args) |
442 | #define stmmac_config_cbs(__priv, __args...) \ |
443 | stmmac_do_void_callback(__priv, mac, config_cbs, __priv, __args) |
444 | #define stmmac_dump_mac_regs(__priv, __args...) \ |
445 | stmmac_do_void_callback(__priv, mac, dump_regs, __args) |
446 | #define stmmac_host_irq_status(__priv, __args...) \ |
447 | stmmac_do_callback(__priv, mac, host_irq_status, __args) |
448 | #define stmmac_host_mtl_irq_status(__priv, __args...) \ |
449 | stmmac_do_callback(__priv, mac, host_mtl_irq_status, __priv, __args) |
450 | #define stmmac_set_filter(__priv, __args...) \ |
451 | stmmac_do_void_callback(__priv, mac, set_filter, __args) |
452 | #define stmmac_flow_ctrl(__priv, __args...) \ |
453 | stmmac_do_void_callback(__priv, mac, flow_ctrl, __args) |
454 | #define stmmac_pmt(__priv, __args...) \ |
455 | stmmac_do_void_callback(__priv, mac, pmt, __args) |
456 | #define stmmac_set_umac_addr(__priv, __args...) \ |
457 | stmmac_do_void_callback(__priv, mac, set_umac_addr, __args) |
458 | #define stmmac_get_umac_addr(__priv, __args...) \ |
459 | stmmac_do_void_callback(__priv, mac, get_umac_addr, __args) |
460 | #define stmmac_set_lpi_mode(__priv, __args...) \ |
461 | stmmac_do_callback(__priv, mac, set_lpi_mode, __args) |
462 | #define stmmac_set_eee_timer(__priv, __args...) \ |
463 | stmmac_do_void_callback(__priv, mac, set_eee_timer, __args) |
464 | #define stmmac_set_eee_pls(__priv, __args...) \ |
465 | stmmac_do_void_callback(__priv, mac, set_eee_pls, __args) |
466 | #define stmmac_mac_debug(__priv, __args...) \ |
467 | stmmac_do_void_callback(__priv, mac, debug, __priv, __args) |
468 | #define stmmac_pcs_ctrl_ane(__priv, __args...) \ |
469 | stmmac_do_void_callback(__priv, mac, pcs_ctrl_ane, __args) |
470 | #define stmmac_pcs_get_adv_lp(__priv, __args...) \ |
471 | stmmac_do_void_callback(__priv, mac, pcs_get_adv_lp, __args) |
472 | #define stmmac_safety_feat_config(__priv, __args...) \ |
473 | stmmac_do_callback(__priv, mac, safety_feat_config, __args) |
474 | #define stmmac_safety_feat_irq_status(__priv, __args...) \ |
475 | stmmac_do_callback(__priv, mac, safety_feat_irq_status, __args) |
476 | #define stmmac_safety_feat_dump(__priv, __args...) \ |
477 | stmmac_do_callback(__priv, mac, safety_feat_dump, __args) |
478 | #define stmmac_rxp_config(__priv, __args...) \ |
479 | stmmac_do_callback(__priv, mac, rxp_config, __args) |
480 | #define stmmac_flex_pps_config(__priv, __args...) \ |
481 | stmmac_do_callback(__priv, mac, flex_pps_config, __args) |
482 | #define stmmac_set_mac_loopback(__priv, __args...) \ |
483 | stmmac_do_void_callback(__priv, mac, set_mac_loopback, __args) |
484 | #define (__priv, __args...) \ |
485 | stmmac_do_callback(__priv, mac, rss_configure, __args) |
486 | #define stmmac_get_mac_tx_timestamp(__priv, __args...) \ |
487 | stmmac_do_callback(__priv, mac, get_mac_tx_timestamp, __args) |
488 | #define stmmac_sarc_configure(__priv, __args...) \ |
489 | stmmac_do_void_callback(__priv, mac, sarc_configure, __args) |
490 | #define stmmac_config_l3_filter(__priv, __args...) \ |
491 | stmmac_do_callback(__priv, mac, config_l3_filter, __args) |
492 | #define stmmac_config_l4_filter(__priv, __args...) \ |
493 | stmmac_do_callback(__priv, mac, config_l4_filter, __args) |
494 | #define stmmac_set_arp_offload(__priv, __args...) \ |
495 | stmmac_do_void_callback(__priv, mac, set_arp_offload, __args) |
496 | #define stmmac_fpe_map_preemption_class(__priv, __args...) \ |
497 | stmmac_do_void_callback(__priv, mac, fpe_map_preemption_class, __args) |
498 | |
499 | /* PTP and HW Timer helpers */ |
500 | struct stmmac_hwtimestamp { |
501 | void (*config_hw_tstamping) (void __iomem *ioaddr, u32 data); |
502 | void (*config_sub_second_increment)(void __iomem *ioaddr, u32 ptp_clock, |
503 | int gmac4, u32 *ssinc); |
504 | int (*init_systime) (void __iomem *ioaddr, u32 sec, u32 nsec); |
505 | int (*config_addend) (void __iomem *ioaddr, u32 addend); |
506 | int (*adjust_systime) (void __iomem *ioaddr, u32 sec, u32 nsec, |
507 | int add_sub, int gmac4); |
508 | void (*get_systime) (void __iomem *ioaddr, u64 *systime); |
509 | void (*get_ptptime)(void __iomem *ioaddr, u64 *ptp_time); |
510 | void (*timestamp_interrupt)(struct stmmac_priv *priv); |
511 | void (*hwtstamp_correct_latency)(struct stmmac_priv *priv); |
512 | }; |
513 | |
514 | #define stmmac_config_hw_tstamping(__priv, __args...) \ |
515 | stmmac_do_void_callback(__priv, ptp, config_hw_tstamping, __args) |
516 | #define stmmac_config_sub_second_increment(__priv, __args...) \ |
517 | stmmac_do_void_callback(__priv, ptp, config_sub_second_increment, __args) |
518 | #define stmmac_init_systime(__priv, __args...) \ |
519 | stmmac_do_callback(__priv, ptp, init_systime, __args) |
520 | #define stmmac_config_addend(__priv, __args...) \ |
521 | stmmac_do_callback(__priv, ptp, config_addend, __args) |
522 | #define stmmac_adjust_systime(__priv, __args...) \ |
523 | stmmac_do_callback(__priv, ptp, adjust_systime, __args) |
524 | #define stmmac_get_systime(__priv, __args...) \ |
525 | stmmac_do_void_callback(__priv, ptp, get_systime, __args) |
526 | #define stmmac_get_ptptime(__priv, __args...) \ |
527 | stmmac_do_void_callback(__priv, ptp, get_ptptime, __args) |
528 | #define stmmac_timestamp_interrupt(__priv, __args...) \ |
529 | stmmac_do_void_callback(__priv, ptp, timestamp_interrupt, __args) |
530 | #define stmmac_hwtstamp_correct_latency(__priv, __args...) \ |
531 | stmmac_do_void_callback(__priv, ptp, hwtstamp_correct_latency, __args) |
532 | |
533 | struct stmmac_tx_queue; |
534 | struct stmmac_rx_queue; |
535 | |
536 | /* Helpers to manage the descriptors for chain and ring modes */ |
537 | struct stmmac_mode_ops { |
538 | void (*init) (void *des, dma_addr_t phy_addr, unsigned int size, |
539 | unsigned int extend_desc); |
540 | unsigned int (*is_jumbo_frm) (int len, int ehn_desc); |
541 | int (*jumbo_frm)(struct stmmac_tx_queue *tx_q, struct sk_buff *skb, |
542 | int csum); |
543 | int (*set_16kib_bfsize)(int mtu); |
544 | void (*init_desc3)(struct dma_desc *p); |
545 | void (*refill_desc3)(struct stmmac_rx_queue *rx_q, struct dma_desc *p); |
546 | void (*clean_desc3)(struct stmmac_tx_queue *tx_q, struct dma_desc *p); |
547 | }; |
548 | |
549 | #define stmmac_mode_init(__priv, __args...) \ |
550 | stmmac_do_void_callback(__priv, mode, init, __args) |
551 | #define stmmac_is_jumbo_frm(__priv, __args...) \ |
552 | stmmac_do_callback(__priv, mode, is_jumbo_frm, __args) |
553 | #define stmmac_jumbo_frm(__priv, __args...) \ |
554 | stmmac_do_callback(__priv, mode, jumbo_frm, __args) |
555 | #define stmmac_set_16kib_bfsize(__priv, __args...) \ |
556 | stmmac_do_callback(__priv, mode, set_16kib_bfsize, __args) |
557 | #define stmmac_init_desc3(__priv, __args...) \ |
558 | stmmac_do_void_callback(__priv, mode, init_desc3, __args) |
559 | #define stmmac_refill_desc3(__priv, __args...) \ |
560 | stmmac_do_void_callback(__priv, mode, refill_desc3, __args) |
561 | #define stmmac_clean_desc3(__priv, __args...) \ |
562 | stmmac_do_void_callback(__priv, mode, clean_desc3, __args) |
563 | |
564 | struct tc_cls_u32_offload; |
565 | struct tc_cbs_qopt_offload; |
566 | struct flow_cls_offload; |
567 | struct tc_taprio_qopt_offload; |
568 | struct tc_etf_qopt_offload; |
569 | struct tc_query_caps_base; |
570 | |
571 | struct stmmac_tc_ops { |
572 | int (*init)(struct stmmac_priv *priv); |
573 | int (*setup_cls_u32)(struct stmmac_priv *priv, |
574 | struct tc_cls_u32_offload *cls); |
575 | int (*setup_cbs)(struct stmmac_priv *priv, |
576 | struct tc_cbs_qopt_offload *qopt); |
577 | int (*setup_cls)(struct stmmac_priv *priv, |
578 | struct flow_cls_offload *cls); |
579 | int (*setup_taprio)(struct stmmac_priv *priv, |
580 | struct tc_taprio_qopt_offload *qopt); |
581 | int (*setup_etf)(struct stmmac_priv *priv, |
582 | struct tc_etf_qopt_offload *qopt); |
583 | int (*query_caps)(struct stmmac_priv *priv, |
584 | struct tc_query_caps_base *base); |
585 | int (*setup_mqprio)(struct stmmac_priv *priv, |
586 | struct tc_mqprio_qopt_offload *qopt); |
587 | }; |
588 | |
589 | #define stmmac_tc_init(__priv, __args...) \ |
590 | stmmac_do_callback(__priv, tc, init, __args) |
591 | #define stmmac_tc_setup_cls_u32(__priv, __args...) \ |
592 | stmmac_do_callback(__priv, tc, setup_cls_u32, __args) |
593 | #define stmmac_tc_setup_cbs(__priv, __args...) \ |
594 | stmmac_do_callback(__priv, tc, setup_cbs, __args) |
595 | #define stmmac_tc_setup_cls(__priv, __args...) \ |
596 | stmmac_do_callback(__priv, tc, setup_cls, __args) |
597 | #define stmmac_tc_setup_taprio(__priv, __args...) \ |
598 | stmmac_do_callback(__priv, tc, setup_taprio, __args) |
599 | #define stmmac_tc_setup_etf(__priv, __args...) \ |
600 | stmmac_do_callback(__priv, tc, setup_etf, __args) |
601 | #define stmmac_tc_query_caps(__priv, __args...) \ |
602 | stmmac_do_callback(__priv, tc, query_caps, __args) |
603 | #define stmmac_tc_setup_mqprio(__priv, __args...) \ |
604 | stmmac_do_callback(__priv, tc, setup_mqprio, __args) |
605 | |
606 | struct stmmac_counters; |
607 | |
608 | struct stmmac_mmc_ops { |
609 | void (*ctrl)(void __iomem *ioaddr, unsigned int mode); |
610 | void (*intr_all_mask)(void __iomem *ioaddr); |
611 | void (*read)(void __iomem *ioaddr, struct stmmac_counters *mmc); |
612 | }; |
613 | |
614 | #define stmmac_mmc_ctrl(__priv, __args...) \ |
615 | stmmac_do_void_callback(__priv, mmc, ctrl, __args) |
616 | #define stmmac_mmc_intr_all_mask(__priv, __args...) \ |
617 | stmmac_do_void_callback(__priv, mmc, intr_all_mask, __args) |
618 | #define stmmac_mmc_read(__priv, __args...) \ |
619 | stmmac_do_void_callback(__priv, mmc, read, __args) |
620 | |
621 | struct stmmac_est_ops { |
622 | int (*configure)(struct stmmac_priv *priv, struct stmmac_est *cfg, |
623 | unsigned int ptp_rate); |
624 | void (*irq_status)(struct stmmac_priv *priv, struct net_device *dev, |
625 | struct stmmac_extra_stats *x, u32 txqcnt); |
626 | }; |
627 | |
628 | #define stmmac_est_configure(__priv, __args...) \ |
629 | stmmac_do_callback(__priv, est, configure, __args) |
630 | #define stmmac_est_irq_status(__priv, __args...) \ |
631 | stmmac_do_void_callback(__priv, est, irq_status, __args) |
632 | |
633 | struct stmmac_vlan_ops { |
634 | /* VLAN */ |
635 | void (*update_vlan_hash)(struct mac_device_info *hw, u32 hash, |
636 | u16 perfect_match, bool is_double); |
637 | void (*enable_vlan)(struct mac_device_info *hw, u32 type); |
638 | void (*rx_hw_vlan)(struct mac_device_info *hw, struct dma_desc *rx_desc, |
639 | struct sk_buff *skb); |
640 | void (*set_hw_vlan_mode)(struct mac_device_info *hw); |
641 | int (*add_hw_vlan_rx_fltr)(struct net_device *dev, |
642 | struct mac_device_info *hw, |
643 | __be16 proto, u16 vid); |
644 | int (*del_hw_vlan_rx_fltr)(struct net_device *dev, |
645 | struct mac_device_info *hw, |
646 | __be16 proto, u16 vid); |
647 | void (*restore_hw_vlan_rx_fltr)(struct net_device *dev, |
648 | struct mac_device_info *hw); |
649 | }; |
650 | |
651 | #define stmmac_update_vlan_hash(__priv, __args...) \ |
652 | stmmac_do_void_callback(__priv, vlan, update_vlan_hash, __args) |
653 | #define stmmac_enable_vlan(__priv, __args...) \ |
654 | stmmac_do_void_callback(__priv, vlan, enable_vlan, __args) |
655 | #define stmmac_rx_hw_vlan(__priv, __args...) \ |
656 | stmmac_do_void_callback(__priv, vlan, rx_hw_vlan, __args) |
657 | #define stmmac_set_hw_vlan_mode(__priv, __args...) \ |
658 | stmmac_do_void_callback(__priv, vlan, set_hw_vlan_mode, __args) |
659 | #define stmmac_add_hw_vlan_rx_fltr(__priv, __args...) \ |
660 | stmmac_do_callback(__priv, vlan, add_hw_vlan_rx_fltr, __args) |
661 | #define stmmac_del_hw_vlan_rx_fltr(__priv, __args...) \ |
662 | stmmac_do_callback(__priv, vlan, del_hw_vlan_rx_fltr, __args) |
663 | #define stmmac_restore_hw_vlan_rx_fltr(__priv, __args...) \ |
664 | stmmac_do_void_callback(__priv, vlan, restore_hw_vlan_rx_fltr, __args) |
665 | |
666 | struct stmmac_regs_off { |
667 | const struct stmmac_fpe_reg *fpe_reg; |
668 | u32 ptp_off; |
669 | u32 mmc_off; |
670 | u32 est_off; |
671 | }; |
672 | |
673 | extern const struct stmmac_desc_ops enh_desc_ops; |
674 | extern const struct stmmac_desc_ops ndesc_ops; |
675 | |
676 | extern const struct stmmac_hwtimestamp stmmac_ptp; |
677 | extern const struct stmmac_hwtimestamp dwmac1000_ptp; |
678 | |
679 | extern const struct stmmac_mode_ops ring_mode_ops; |
680 | extern const struct stmmac_mode_ops chain_mode_ops; |
681 | |
682 | extern const struct stmmac_ops dwmac100_ops; |
683 | extern const struct stmmac_dma_ops dwmac100_dma_ops; |
684 | extern const struct stmmac_ops dwmac1000_ops; |
685 | extern const struct stmmac_dma_ops dwmac1000_dma_ops; |
686 | extern const struct stmmac_ops dwmac4_ops; |
687 | extern const struct stmmac_dma_ops dwmac4_dma_ops; |
688 | extern const struct stmmac_ops dwmac410_ops; |
689 | extern const struct stmmac_dma_ops dwmac410_dma_ops; |
690 | extern const struct stmmac_ops dwmac510_ops; |
691 | extern const struct stmmac_tc_ops dwmac4_tc_ops; |
692 | extern const struct stmmac_tc_ops dwmac510_tc_ops; |
693 | |
694 | #define GMAC_VERSION 0x00000020 /* GMAC CORE Version */ |
695 | #define GMAC4_VERSION 0x00000110 /* GMAC4+ CORE Version */ |
696 | |
697 | int stmmac_reset(struct stmmac_priv *priv, void __iomem *ioaddr); |
698 | int stmmac_hwif_init(struct stmmac_priv *priv); |
699 | |
700 | #endif /* __STMMAC_HWIF_H__ */ |
701 | |