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