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