Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
0002 // Copyright (c) 2018 Synopsys, Inc. and/or its affiliates.
0003 // stmmac HW Interface Callbacks
0004 
0005 #ifndef __STMMAC_HWIF_H__
0006 #define __STMMAC_HWIF_H__
0007 
0008 #include <linux/netdevice.h>
0009 #include <linux/stmmac.h>
0010 
0011 #define stmmac_do_void_callback(__priv, __module, __cname,  __arg0, __args...) \
0012 ({ \
0013     int __result = -EINVAL; \
0014     if ((__priv)->hw->__module && (__priv)->hw->__module->__cname) { \
0015         (__priv)->hw->__module->__cname((__arg0), ##__args); \
0016         __result = 0; \
0017     } \
0018     __result; \
0019 })
0020 #define stmmac_do_callback(__priv, __module, __cname,  __arg0, __args...) \
0021 ({ \
0022     int __result = -EINVAL; \
0023     if ((__priv)->hw->__module && (__priv)->hw->__module->__cname) \
0024         __result = (__priv)->hw->__module->__cname((__arg0), ##__args); \
0025     __result; \
0026 })
0027 
0028 struct stmmac_extra_stats;
0029 struct stmmac_safety_stats;
0030 struct dma_desc;
0031 struct dma_extended_desc;
0032 struct dma_edesc;
0033 
0034 /* Descriptors helpers */
0035 struct stmmac_desc_ops {
0036     /* DMA RX descriptor ring initialization */
0037     void (*init_rx_desc)(struct dma_desc *p, int disable_rx_ic, int mode,
0038             int end, int bfsize);
0039     /* DMA TX descriptor ring initialization */
0040     void (*init_tx_desc)(struct dma_desc *p, int mode, int end);
0041     /* Invoked by the xmit function to prepare the tx descriptor */
0042     void (*prepare_tx_desc)(struct dma_desc *p, int is_fs, int len,
0043             bool csum_flag, int mode, bool tx_own, bool ls,
0044             unsigned int tot_pkt_len);
0045     void (*prepare_tso_tx_desc)(struct dma_desc *p, int is_fs, int len1,
0046             int len2, bool tx_own, bool ls, unsigned int tcphdrlen,
0047             unsigned int tcppayloadlen);
0048     /* Set/get the owner of the descriptor */
0049     void (*set_tx_owner)(struct dma_desc *p);
0050     int (*get_tx_owner)(struct dma_desc *p);
0051     /* Clean the tx descriptor as soon as the tx irq is received */
0052     void (*release_tx_desc)(struct dma_desc *p, int mode);
0053     /* Clear interrupt on tx frame completion. When this bit is
0054      * set an interrupt happens as soon as the frame is transmitted */
0055     void (*set_tx_ic)(struct dma_desc *p);
0056     /* Last tx segment reports the transmit status */
0057     int (*get_tx_ls)(struct dma_desc *p);
0058     /* Return the transmit status looking at the TDES1 */
0059     int (*tx_status)(void *data, struct stmmac_extra_stats *x,
0060             struct dma_desc *p, void __iomem *ioaddr);
0061     /* Get the buffer size from the descriptor */
0062     int (*get_tx_len)(struct dma_desc *p);
0063     /* Handle extra events on specific interrupts hw dependent */
0064     void (*set_rx_owner)(struct dma_desc *p, int disable_rx_ic);
0065     /* Get the receive frame size */
0066     int (*get_rx_frame_len)(struct dma_desc *p, int rx_coe_type);
0067     /* Return the reception status looking at the RDES1 */
0068     int (*rx_status)(void *data, struct stmmac_extra_stats *x,
0069             struct dma_desc *p);
0070     void (*rx_extended_status)(void *data, struct stmmac_extra_stats *x,
0071             struct dma_extended_desc *p);
0072     /* Set tx timestamp enable bit */
0073     void (*enable_tx_timestamp) (struct dma_desc *p);
0074     /* get tx timestamp status */
0075     int (*get_tx_timestamp_status) (struct dma_desc *p);
0076     /* get timestamp value */
0077     void (*get_timestamp)(void *desc, u32 ats, u64 *ts);
0078     /* get rx timestamp status */
0079     int (*get_rx_timestamp_status)(void *desc, void *next_desc, u32 ats);
0080     /* Display ring */
0081     void (*display_ring)(void *head, unsigned int size, bool rx,
0082                  dma_addr_t dma_rx_phy, unsigned int desc_size);
0083     /* set MSS via context descriptor */
0084     void (*set_mss)(struct dma_desc *p, unsigned int mss);
0085     /* set descriptor skbuff address */
0086     void (*set_addr)(struct dma_desc *p, dma_addr_t addr);
0087     /* clear descriptor */
0088     void (*clear)(struct dma_desc *p);
0089     /* RSS */
0090     int (*get_rx_hash)(struct dma_desc *p, u32 *hash,
0091                enum pkt_hash_types *type);
0092     void (*get_rx_header_len)(struct dma_desc *p, unsigned int *len);
0093     void (*set_sec_addr)(struct dma_desc *p, dma_addr_t addr, bool buf2_valid);
0094     void (*set_sarc)(struct dma_desc *p, u32 sarc_type);
0095     void (*set_vlan_tag)(struct dma_desc *p, u16 tag, u16 inner_tag,
0096                  u32 inner_type);
0097     void (*set_vlan)(struct dma_desc *p, u32 type);
0098     void (*set_tbs)(struct dma_edesc *p, u32 sec, u32 nsec);
0099 };
0100 
0101 #define stmmac_init_rx_desc(__priv, __args...) \
0102     stmmac_do_void_callback(__priv, desc, init_rx_desc, __args)
0103 #define stmmac_init_tx_desc(__priv, __args...) \
0104     stmmac_do_void_callback(__priv, desc, init_tx_desc, __args)
0105 #define stmmac_prepare_tx_desc(__priv, __args...) \
0106     stmmac_do_void_callback(__priv, desc, prepare_tx_desc, __args)
0107 #define stmmac_prepare_tso_tx_desc(__priv, __args...) \
0108     stmmac_do_void_callback(__priv, desc, prepare_tso_tx_desc, __args)
0109 #define stmmac_set_tx_owner(__priv, __args...) \
0110     stmmac_do_void_callback(__priv, desc, set_tx_owner, __args)
0111 #define stmmac_get_tx_owner(__priv, __args...) \
0112     stmmac_do_callback(__priv, desc, get_tx_owner, __args)
0113 #define stmmac_release_tx_desc(__priv, __args...) \
0114     stmmac_do_void_callback(__priv, desc, release_tx_desc, __args)
0115 #define stmmac_set_tx_ic(__priv, __args...) \
0116     stmmac_do_void_callback(__priv, desc, set_tx_ic, __args)
0117 #define stmmac_get_tx_ls(__priv, __args...) \
0118     stmmac_do_callback(__priv, desc, get_tx_ls, __args)
0119 #define stmmac_tx_status(__priv, __args...) \
0120     stmmac_do_callback(__priv, desc, tx_status, __args)
0121 #define stmmac_get_tx_len(__priv, __args...) \
0122     stmmac_do_callback(__priv, desc, get_tx_len, __args)
0123 #define stmmac_set_rx_owner(__priv, __args...) \
0124     stmmac_do_void_callback(__priv, desc, set_rx_owner, __args)
0125 #define stmmac_get_rx_frame_len(__priv, __args...) \
0126     stmmac_do_callback(__priv, desc, get_rx_frame_len, __args)
0127 #define stmmac_rx_status(__priv, __args...) \
0128     stmmac_do_callback(__priv, desc, rx_status, __args)
0129 #define stmmac_rx_extended_status(__priv, __args...) \
0130     stmmac_do_void_callback(__priv, desc, rx_extended_status, __args)
0131 #define stmmac_enable_tx_timestamp(__priv, __args...) \
0132     stmmac_do_void_callback(__priv, desc, enable_tx_timestamp, __args)
0133 #define stmmac_get_tx_timestamp_status(__priv, __args...) \
0134     stmmac_do_callback(__priv, desc, get_tx_timestamp_status, __args)
0135 #define stmmac_get_timestamp(__priv, __args...) \
0136     stmmac_do_void_callback(__priv, desc, get_timestamp, __args)
0137 #define stmmac_get_rx_timestamp_status(__priv, __args...) \
0138     stmmac_do_callback(__priv, desc, get_rx_timestamp_status, __args)
0139 #define stmmac_display_ring(__priv, __args...) \
0140     stmmac_do_void_callback(__priv, desc, display_ring, __args)
0141 #define stmmac_set_mss(__priv, __args...) \
0142     stmmac_do_void_callback(__priv, desc, set_mss, __args)
0143 #define stmmac_set_desc_addr(__priv, __args...) \
0144     stmmac_do_void_callback(__priv, desc, set_addr, __args)
0145 #define stmmac_clear_desc(__priv, __args...) \
0146     stmmac_do_void_callback(__priv, desc, clear, __args)
0147 #define stmmac_get_rx_hash(__priv, __args...) \
0148     stmmac_do_callback(__priv, desc, get_rx_hash, __args)
0149 #define stmmac_get_rx_header_len(__priv, __args...) \
0150     stmmac_do_void_callback(__priv, desc, get_rx_header_len, __args)
0151 #define stmmac_set_desc_sec_addr(__priv, __args...) \
0152     stmmac_do_void_callback(__priv, desc, set_sec_addr, __args)
0153 #define stmmac_set_desc_sarc(__priv, __args...) \
0154     stmmac_do_void_callback(__priv, desc, set_sarc, __args)
0155 #define stmmac_set_desc_vlan_tag(__priv, __args...) \
0156     stmmac_do_void_callback(__priv, desc, set_vlan_tag, __args)
0157 #define stmmac_set_desc_vlan(__priv, __args...) \
0158     stmmac_do_void_callback(__priv, desc, set_vlan, __args)
0159 #define stmmac_set_desc_tbs(__priv, __args...) \
0160     stmmac_do_void_callback(__priv, desc, set_tbs, __args)
0161 
0162 struct stmmac_dma_cfg;
0163 struct dma_features;
0164 
0165 /* Specific DMA helpers */
0166 struct stmmac_dma_ops {
0167     /* DMA core initialization */
0168     int (*reset)(void __iomem *ioaddr);
0169     void (*init)(void __iomem *ioaddr, struct stmmac_dma_cfg *dma_cfg,
0170              int atds);
0171     void (*init_chan)(void __iomem *ioaddr,
0172               struct stmmac_dma_cfg *dma_cfg, u32 chan);
0173     void (*init_rx_chan)(void __iomem *ioaddr,
0174                  struct stmmac_dma_cfg *dma_cfg,
0175                  dma_addr_t phy, u32 chan);
0176     void (*init_tx_chan)(void __iomem *ioaddr,
0177                  struct stmmac_dma_cfg *dma_cfg,
0178                  dma_addr_t phy, u32 chan);
0179     /* Configure the AXI Bus Mode Register */
0180     void (*axi)(void __iomem *ioaddr, struct stmmac_axi *axi);
0181     /* Dump DMA registers */
0182     void (*dump_regs)(void __iomem *ioaddr, u32 *reg_space);
0183     void (*dma_rx_mode)(void __iomem *ioaddr, int mode, u32 channel,
0184                 int fifosz, u8 qmode);
0185     void (*dma_tx_mode)(void __iomem *ioaddr, int mode, u32 channel,
0186                 int fifosz, u8 qmode);
0187     /* To track extra statistic (if supported) */
0188     void (*dma_diagnostic_fr) (void *data, struct stmmac_extra_stats *x,
0189                    void __iomem *ioaddr);
0190     void (*enable_dma_transmission) (void __iomem *ioaddr);
0191     void (*enable_dma_irq)(void __iomem *ioaddr, u32 chan,
0192                    bool rx, bool tx);
0193     void (*disable_dma_irq)(void __iomem *ioaddr, u32 chan,
0194                 bool rx, bool tx);
0195     void (*start_tx)(void __iomem *ioaddr, u32 chan);
0196     void (*stop_tx)(void __iomem *ioaddr, u32 chan);
0197     void (*start_rx)(void __iomem *ioaddr, u32 chan);
0198     void (*stop_rx)(void __iomem *ioaddr, u32 chan);
0199     int (*dma_interrupt) (void __iomem *ioaddr,
0200                   struct stmmac_extra_stats *x, u32 chan, u32 dir);
0201     /* If supported then get the optional core features */
0202     int (*get_hw_feature)(void __iomem *ioaddr,
0203                   struct dma_features *dma_cap);
0204     /* Program the HW RX Watchdog */
0205     void (*rx_watchdog)(void __iomem *ioaddr, u32 riwt, u32 queue);
0206     void (*set_tx_ring_len)(void __iomem *ioaddr, u32 len, u32 chan);
0207     void (*set_rx_ring_len)(void __iomem *ioaddr, u32 len, u32 chan);
0208     void (*set_rx_tail_ptr)(void __iomem *ioaddr, u32 tail_ptr, u32 chan);
0209     void (*set_tx_tail_ptr)(void __iomem *ioaddr, u32 tail_ptr, u32 chan);
0210     void (*enable_tso)(void __iomem *ioaddr, bool en, u32 chan);
0211     void (*qmode)(void __iomem *ioaddr, u32 channel, u8 qmode);
0212     void (*set_bfsize)(void __iomem *ioaddr, int bfsize, u32 chan);
0213     void (*enable_sph)(void __iomem *ioaddr, bool en, u32 chan);
0214     int (*enable_tbs)(void __iomem *ioaddr, bool en, u32 chan);
0215 };
0216 
0217 #define stmmac_reset(__priv, __args...) \
0218     stmmac_do_callback(__priv, dma, reset, __args)
0219 #define stmmac_dma_init(__priv, __args...) \
0220     stmmac_do_void_callback(__priv, dma, init, __args)
0221 #define stmmac_init_chan(__priv, __args...) \
0222     stmmac_do_void_callback(__priv, dma, init_chan, __args)
0223 #define stmmac_init_rx_chan(__priv, __args...) \
0224     stmmac_do_void_callback(__priv, dma, init_rx_chan, __args)
0225 #define stmmac_init_tx_chan(__priv, __args...) \
0226     stmmac_do_void_callback(__priv, dma, init_tx_chan, __args)
0227 #define stmmac_axi(__priv, __args...) \
0228     stmmac_do_void_callback(__priv, dma, axi, __args)
0229 #define stmmac_dump_dma_regs(__priv, __args...) \
0230     stmmac_do_void_callback(__priv, dma, dump_regs, __args)
0231 #define stmmac_dma_rx_mode(__priv, __args...) \
0232     stmmac_do_void_callback(__priv, dma, dma_rx_mode, __args)
0233 #define stmmac_dma_tx_mode(__priv, __args...) \
0234     stmmac_do_void_callback(__priv, dma, dma_tx_mode, __args)
0235 #define stmmac_dma_diagnostic_fr(__priv, __args...) \
0236     stmmac_do_void_callback(__priv, dma, dma_diagnostic_fr, __args)
0237 #define stmmac_enable_dma_transmission(__priv, __args...) \
0238     stmmac_do_void_callback(__priv, dma, enable_dma_transmission, __args)
0239 #define stmmac_enable_dma_irq(__priv, __args...) \
0240     stmmac_do_void_callback(__priv, dma, enable_dma_irq, __args)
0241 #define stmmac_disable_dma_irq(__priv, __args...) \
0242     stmmac_do_void_callback(__priv, dma, disable_dma_irq, __args)
0243 #define stmmac_start_tx(__priv, __args...) \
0244     stmmac_do_void_callback(__priv, dma, start_tx, __args)
0245 #define stmmac_stop_tx(__priv, __args...) \
0246     stmmac_do_void_callback(__priv, dma, stop_tx, __args)
0247 #define stmmac_start_rx(__priv, __args...) \
0248     stmmac_do_void_callback(__priv, dma, start_rx, __args)
0249 #define stmmac_stop_rx(__priv, __args...) \
0250     stmmac_do_void_callback(__priv, dma, stop_rx, __args)
0251 #define stmmac_dma_interrupt_status(__priv, __args...) \
0252     stmmac_do_callback(__priv, dma, dma_interrupt, __args)
0253 #define stmmac_get_hw_feature(__priv, __args...) \
0254     stmmac_do_callback(__priv, dma, get_hw_feature, __args)
0255 #define stmmac_rx_watchdog(__priv, __args...) \
0256     stmmac_do_void_callback(__priv, dma, rx_watchdog, __args)
0257 #define stmmac_set_tx_ring_len(__priv, __args...) \
0258     stmmac_do_void_callback(__priv, dma, set_tx_ring_len, __args)
0259 #define stmmac_set_rx_ring_len(__priv, __args...) \
0260     stmmac_do_void_callback(__priv, dma, set_rx_ring_len, __args)
0261 #define stmmac_set_rx_tail_ptr(__priv, __args...) \
0262     stmmac_do_void_callback(__priv, dma, set_rx_tail_ptr, __args)
0263 #define stmmac_set_tx_tail_ptr(__priv, __args...) \
0264     stmmac_do_void_callback(__priv, dma, set_tx_tail_ptr, __args)
0265 #define stmmac_enable_tso(__priv, __args...) \
0266     stmmac_do_void_callback(__priv, dma, enable_tso, __args)
0267 #define stmmac_dma_qmode(__priv, __args...) \
0268     stmmac_do_void_callback(__priv, dma, qmode, __args)
0269 #define stmmac_set_dma_bfsize(__priv, __args...) \
0270     stmmac_do_void_callback(__priv, dma, set_bfsize, __args)
0271 #define stmmac_enable_sph(__priv, __args...) \
0272     stmmac_do_void_callback(__priv, dma, enable_sph, __args)
0273 #define stmmac_enable_tbs(__priv, __args...) \
0274     stmmac_do_callback(__priv, dma, enable_tbs, __args)
0275 
0276 struct mac_device_info;
0277 struct net_device;
0278 struct rgmii_adv;
0279 struct stmmac_tc_entry;
0280 struct stmmac_pps_cfg;
0281 struct stmmac_rss;
0282 struct stmmac_est;
0283 
0284 /* Helpers to program the MAC core */
0285 struct stmmac_ops {
0286     /* MAC core initialization */
0287     void (*core_init)(struct mac_device_info *hw, struct net_device *dev);
0288     /* Enable the MAC RX/TX */
0289     void (*set_mac)(void __iomem *ioaddr, bool enable);
0290     /* Enable and verify that the IPC module is supported */
0291     int (*rx_ipc)(struct mac_device_info *hw);
0292     /* Enable RX Queues */
0293     void (*rx_queue_enable)(struct mac_device_info *hw, u8 mode, u32 queue);
0294     /* RX Queues Priority */
0295     void (*rx_queue_prio)(struct mac_device_info *hw, u32 prio, u32 queue);
0296     /* TX Queues Priority */
0297     void (*tx_queue_prio)(struct mac_device_info *hw, u32 prio, u32 queue);
0298     /* RX Queues Routing */
0299     void (*rx_queue_routing)(struct mac_device_info *hw, u8 packet,
0300                  u32 queue);
0301     /* Program RX Algorithms */
0302     void (*prog_mtl_rx_algorithms)(struct mac_device_info *hw, u32 rx_alg);
0303     /* Program TX Algorithms */
0304     void (*prog_mtl_tx_algorithms)(struct mac_device_info *hw, u32 tx_alg);
0305     /* Set MTL TX queues weight */
0306     void (*set_mtl_tx_queue_weight)(struct mac_device_info *hw,
0307                     u32 weight, u32 queue);
0308     /* RX MTL queue to RX dma mapping */
0309     void (*map_mtl_to_dma)(struct mac_device_info *hw, u32 queue, u32 chan);
0310     /* Configure AV Algorithm */
0311     void (*config_cbs)(struct mac_device_info *hw, u32 send_slope,
0312                u32 idle_slope, u32 high_credit, u32 low_credit,
0313                u32 queue);
0314     /* Dump MAC registers */
0315     void (*dump_regs)(struct mac_device_info *hw, u32 *reg_space);
0316     /* Handle extra events on specific interrupts hw dependent */
0317     int (*host_irq_status)(struct mac_device_info *hw,
0318                    struct stmmac_extra_stats *x);
0319     /* Handle MTL interrupts */
0320     int (*host_mtl_irq_status)(struct mac_device_info *hw, u32 chan);
0321     /* Multicast filter setting */
0322     void (*set_filter)(struct mac_device_info *hw, struct net_device *dev);
0323     /* Flow control setting */
0324     void (*flow_ctrl)(struct mac_device_info *hw, unsigned int duplex,
0325               unsigned int fc, unsigned int pause_time, u32 tx_cnt);
0326     /* Set power management mode (e.g. magic frame) */
0327     void (*pmt)(struct mac_device_info *hw, unsigned long mode);
0328     /* Set/Get Unicast MAC addresses */
0329     void (*set_umac_addr)(struct mac_device_info *hw,
0330                   const unsigned char *addr,
0331                   unsigned int reg_n);
0332     void (*get_umac_addr)(struct mac_device_info *hw, unsigned char *addr,
0333                   unsigned int reg_n);
0334     void (*set_eee_mode)(struct mac_device_info *hw,
0335                  bool en_tx_lpi_clockgating);
0336     void (*reset_eee_mode)(struct mac_device_info *hw);
0337     void (*set_eee_lpi_entry_timer)(struct mac_device_info *hw, int et);
0338     void (*set_eee_timer)(struct mac_device_info *hw, int ls, int tw);
0339     void (*set_eee_pls)(struct mac_device_info *hw, int link);
0340     void (*debug)(void __iomem *ioaddr, struct stmmac_extra_stats *x,
0341               u32 rx_queues, u32 tx_queues);
0342     /* PCS calls */
0343     void (*pcs_ctrl_ane)(void __iomem *ioaddr, bool ane, bool srgmi_ral,
0344                  bool loopback);
0345     void (*pcs_rane)(void __iomem *ioaddr, bool restart);
0346     void (*pcs_get_adv_lp)(void __iomem *ioaddr, struct rgmii_adv *adv);
0347     /* Safety Features */
0348     int (*safety_feat_config)(void __iomem *ioaddr, unsigned int asp,
0349                   struct stmmac_safety_feature_cfg *safety_cfg);
0350     int (*safety_feat_irq_status)(struct net_device *ndev,
0351             void __iomem *ioaddr, unsigned int asp,
0352             struct stmmac_safety_stats *stats);
0353     int (*safety_feat_dump)(struct stmmac_safety_stats *stats,
0354             int index, unsigned long *count, const char **desc);
0355     /* Flexible RX Parser */
0356     int (*rxp_config)(void __iomem *ioaddr, struct stmmac_tc_entry *entries,
0357               unsigned int count);
0358     /* Flexible PPS */
0359     int (*flex_pps_config)(void __iomem *ioaddr, int index,
0360                    struct stmmac_pps_cfg *cfg, bool enable,
0361                    u32 sub_second_inc, u32 systime_flags);
0362     /* Loopback for selftests */
0363     void (*set_mac_loopback)(void __iomem *ioaddr, bool enable);
0364     /* RSS */
0365     int (*rss_configure)(struct mac_device_info *hw,
0366                  struct stmmac_rss *cfg, u32 num_rxq);
0367     /* VLAN */
0368     void (*update_vlan_hash)(struct mac_device_info *hw, u32 hash,
0369                  __le16 perfect_match, bool is_double);
0370     void (*enable_vlan)(struct mac_device_info *hw, u32 type);
0371     int (*add_hw_vlan_rx_fltr)(struct net_device *dev,
0372                    struct mac_device_info *hw,
0373                    __be16 proto, u16 vid);
0374     int (*del_hw_vlan_rx_fltr)(struct net_device *dev,
0375                    struct mac_device_info *hw,
0376                    __be16 proto, u16 vid);
0377     void (*restore_hw_vlan_rx_fltr)(struct net_device *dev,
0378                     struct mac_device_info *hw);
0379     /* TX Timestamp */
0380     int (*get_mac_tx_timestamp)(struct mac_device_info *hw, u64 *ts);
0381     /* Source Address Insertion / Replacement */
0382     void (*sarc_configure)(void __iomem *ioaddr, int val);
0383     /* Filtering */
0384     int (*config_l3_filter)(struct mac_device_info *hw, u32 filter_no,
0385                 bool en, bool ipv6, bool sa, bool inv,
0386                 u32 match);
0387     int (*config_l4_filter)(struct mac_device_info *hw, u32 filter_no,
0388                 bool en, bool udp, bool sa, bool inv,
0389                 u32 match);
0390     void (*set_arp_offload)(struct mac_device_info *hw, bool en, u32 addr);
0391     int (*est_configure)(void __iomem *ioaddr, struct stmmac_est *cfg,
0392                  unsigned int ptp_rate);
0393     void (*est_irq_status)(void __iomem *ioaddr, struct net_device *dev,
0394                    struct stmmac_extra_stats *x, u32 txqcnt);
0395     void (*fpe_configure)(void __iomem *ioaddr, u32 num_txq, u32 num_rxq,
0396                   bool enable);
0397     void (*fpe_send_mpacket)(void __iomem *ioaddr,
0398                  enum stmmac_mpacket_type type);
0399     int (*fpe_irq_status)(void __iomem *ioaddr, struct net_device *dev);
0400 };
0401 
0402 #define stmmac_core_init(__priv, __args...) \
0403     stmmac_do_void_callback(__priv, mac, core_init, __args)
0404 #define stmmac_mac_set(__priv, __args...) \
0405     stmmac_do_void_callback(__priv, mac, set_mac, __args)
0406 #define stmmac_rx_ipc(__priv, __args...) \
0407     stmmac_do_callback(__priv, mac, rx_ipc, __args)
0408 #define stmmac_rx_queue_enable(__priv, __args...) \
0409     stmmac_do_void_callback(__priv, mac, rx_queue_enable, __args)
0410 #define stmmac_rx_queue_prio(__priv, __args...) \
0411     stmmac_do_void_callback(__priv, mac, rx_queue_prio, __args)
0412 #define stmmac_tx_queue_prio(__priv, __args...) \
0413     stmmac_do_void_callback(__priv, mac, tx_queue_prio, __args)
0414 #define stmmac_rx_queue_routing(__priv, __args...) \
0415     stmmac_do_void_callback(__priv, mac, rx_queue_routing, __args)
0416 #define stmmac_prog_mtl_rx_algorithms(__priv, __args...) \
0417     stmmac_do_void_callback(__priv, mac, prog_mtl_rx_algorithms, __args)
0418 #define stmmac_prog_mtl_tx_algorithms(__priv, __args...) \
0419     stmmac_do_void_callback(__priv, mac, prog_mtl_tx_algorithms, __args)
0420 #define stmmac_set_mtl_tx_queue_weight(__priv, __args...) \
0421     stmmac_do_void_callback(__priv, mac, set_mtl_tx_queue_weight, __args)
0422 #define stmmac_map_mtl_to_dma(__priv, __args...) \
0423     stmmac_do_void_callback(__priv, mac, map_mtl_to_dma, __args)
0424 #define stmmac_config_cbs(__priv, __args...) \
0425     stmmac_do_void_callback(__priv, mac, config_cbs, __args)
0426 #define stmmac_dump_mac_regs(__priv, __args...) \
0427     stmmac_do_void_callback(__priv, mac, dump_regs, __args)
0428 #define stmmac_host_irq_status(__priv, __args...) \
0429     stmmac_do_callback(__priv, mac, host_irq_status, __args)
0430 #define stmmac_host_mtl_irq_status(__priv, __args...) \
0431     stmmac_do_callback(__priv, mac, host_mtl_irq_status, __args)
0432 #define stmmac_set_filter(__priv, __args...) \
0433     stmmac_do_void_callback(__priv, mac, set_filter, __args)
0434 #define stmmac_flow_ctrl(__priv, __args...) \
0435     stmmac_do_void_callback(__priv, mac, flow_ctrl, __args)
0436 #define stmmac_pmt(__priv, __args...) \
0437     stmmac_do_void_callback(__priv, mac, pmt, __args)
0438 #define stmmac_set_umac_addr(__priv, __args...) \
0439     stmmac_do_void_callback(__priv, mac, set_umac_addr, __args)
0440 #define stmmac_get_umac_addr(__priv, __args...) \
0441     stmmac_do_void_callback(__priv, mac, get_umac_addr, __args)
0442 #define stmmac_set_eee_mode(__priv, __args...) \
0443     stmmac_do_void_callback(__priv, mac, set_eee_mode, __args)
0444 #define stmmac_reset_eee_mode(__priv, __args...) \
0445     stmmac_do_void_callback(__priv, mac, reset_eee_mode, __args)
0446 #define stmmac_set_eee_lpi_timer(__priv, __args...) \
0447     stmmac_do_void_callback(__priv, mac, set_eee_lpi_entry_timer, __args)
0448 #define stmmac_set_eee_timer(__priv, __args...) \
0449     stmmac_do_void_callback(__priv, mac, set_eee_timer, __args)
0450 #define stmmac_set_eee_pls(__priv, __args...) \
0451     stmmac_do_void_callback(__priv, mac, set_eee_pls, __args)
0452 #define stmmac_mac_debug(__priv, __args...) \
0453     stmmac_do_void_callback(__priv, mac, debug, __args)
0454 #define stmmac_pcs_ctrl_ane(__priv, __args...) \
0455     stmmac_do_void_callback(__priv, mac, pcs_ctrl_ane, __args)
0456 #define stmmac_pcs_rane(__priv, __args...) \
0457     stmmac_do_void_callback(__priv, mac, pcs_rane, __args)
0458 #define stmmac_pcs_get_adv_lp(__priv, __args...) \
0459     stmmac_do_void_callback(__priv, mac, pcs_get_adv_lp, __args)
0460 #define stmmac_safety_feat_config(__priv, __args...) \
0461     stmmac_do_callback(__priv, mac, safety_feat_config, __args)
0462 #define stmmac_safety_feat_irq_status(__priv, __args...) \
0463     stmmac_do_callback(__priv, mac, safety_feat_irq_status, __args)
0464 #define stmmac_safety_feat_dump(__priv, __args...) \
0465     stmmac_do_callback(__priv, mac, safety_feat_dump, __args)
0466 #define stmmac_rxp_config(__priv, __args...) \
0467     stmmac_do_callback(__priv, mac, rxp_config, __args)
0468 #define stmmac_flex_pps_config(__priv, __args...) \
0469     stmmac_do_callback(__priv, mac, flex_pps_config, __args)
0470 #define stmmac_set_mac_loopback(__priv, __args...) \
0471     stmmac_do_void_callback(__priv, mac, set_mac_loopback, __args)
0472 #define stmmac_rss_configure(__priv, __args...) \
0473     stmmac_do_callback(__priv, mac, rss_configure, __args)
0474 #define stmmac_update_vlan_hash(__priv, __args...) \
0475     stmmac_do_void_callback(__priv, mac, update_vlan_hash, __args)
0476 #define stmmac_enable_vlan(__priv, __args...) \
0477     stmmac_do_void_callback(__priv, mac, enable_vlan, __args)
0478 #define stmmac_add_hw_vlan_rx_fltr(__priv, __args...) \
0479     stmmac_do_callback(__priv, mac, add_hw_vlan_rx_fltr, __args)
0480 #define stmmac_del_hw_vlan_rx_fltr(__priv, __args...) \
0481     stmmac_do_callback(__priv, mac, del_hw_vlan_rx_fltr, __args)
0482 #define stmmac_restore_hw_vlan_rx_fltr(__priv, __args...) \
0483     stmmac_do_void_callback(__priv, mac, restore_hw_vlan_rx_fltr, __args)
0484 #define stmmac_get_mac_tx_timestamp(__priv, __args...) \
0485     stmmac_do_callback(__priv, mac, get_mac_tx_timestamp, __args)
0486 #define stmmac_sarc_configure(__priv, __args...) \
0487     stmmac_do_void_callback(__priv, mac, sarc_configure, __args)
0488 #define stmmac_config_l3_filter(__priv, __args...) \
0489     stmmac_do_callback(__priv, mac, config_l3_filter, __args)
0490 #define stmmac_config_l4_filter(__priv, __args...) \
0491     stmmac_do_callback(__priv, mac, config_l4_filter, __args)
0492 #define stmmac_set_arp_offload(__priv, __args...) \
0493     stmmac_do_void_callback(__priv, mac, set_arp_offload, __args)
0494 #define stmmac_est_configure(__priv, __args...) \
0495     stmmac_do_callback(__priv, mac, est_configure, __args)
0496 #define stmmac_est_irq_status(__priv, __args...) \
0497     stmmac_do_void_callback(__priv, mac, est_irq_status, __args)
0498 #define stmmac_fpe_configure(__priv, __args...) \
0499     stmmac_do_void_callback(__priv, mac, fpe_configure, __args)
0500 #define stmmac_fpe_send_mpacket(__priv, __args...) \
0501     stmmac_do_void_callback(__priv, mac, fpe_send_mpacket, __args)
0502 #define stmmac_fpe_irq_status(__priv, __args...) \
0503     stmmac_do_callback(__priv, mac, fpe_irq_status, __args)
0504 
0505 struct stmmac_priv;
0506 
0507 /* PTP and HW Timer helpers */
0508 struct stmmac_hwtimestamp {
0509     void (*config_hw_tstamping) (void __iomem *ioaddr, u32 data);
0510     void (*config_sub_second_increment)(void __iomem *ioaddr, u32 ptp_clock,
0511                        int gmac4, u32 *ssinc);
0512     int (*init_systime) (void __iomem *ioaddr, u32 sec, u32 nsec);
0513     int (*config_addend) (void __iomem *ioaddr, u32 addend);
0514     int (*adjust_systime) (void __iomem *ioaddr, u32 sec, u32 nsec,
0515                    int add_sub, int gmac4);
0516     void (*get_systime) (void __iomem *ioaddr, u64 *systime);
0517     void (*get_ptptime)(void __iomem *ioaddr, u64 *ptp_time);
0518     void (*timestamp_interrupt)(struct stmmac_priv *priv);
0519 };
0520 
0521 #define stmmac_config_hw_tstamping(__priv, __args...) \
0522     stmmac_do_void_callback(__priv, ptp, config_hw_tstamping, __args)
0523 #define stmmac_config_sub_second_increment(__priv, __args...) \
0524     stmmac_do_void_callback(__priv, ptp, config_sub_second_increment, __args)
0525 #define stmmac_init_systime(__priv, __args...) \
0526     stmmac_do_callback(__priv, ptp, init_systime, __args)
0527 #define stmmac_config_addend(__priv, __args...) \
0528     stmmac_do_callback(__priv, ptp, config_addend, __args)
0529 #define stmmac_adjust_systime(__priv, __args...) \
0530     stmmac_do_callback(__priv, ptp, adjust_systime, __args)
0531 #define stmmac_get_systime(__priv, __args...) \
0532     stmmac_do_void_callback(__priv, ptp, get_systime, __args)
0533 #define stmmac_get_ptptime(__priv, __args...) \
0534     stmmac_do_void_callback(__priv, ptp, get_ptptime, __args)
0535 #define stmmac_timestamp_interrupt(__priv, __args...) \
0536     stmmac_do_void_callback(__priv, ptp, timestamp_interrupt, __args)
0537 
0538 /* Helpers to manage the descriptors for chain and ring modes */
0539 struct stmmac_mode_ops {
0540     void (*init) (void *des, dma_addr_t phy_addr, unsigned int size,
0541               unsigned int extend_desc);
0542     unsigned int (*is_jumbo_frm) (int len, int ehn_desc);
0543     int (*jumbo_frm)(void *priv, struct sk_buff *skb, int csum);
0544     int (*set_16kib_bfsize)(int mtu);
0545     void (*init_desc3)(struct dma_desc *p);
0546     void (*refill_desc3) (void *priv, struct dma_desc *p);
0547     void (*clean_desc3) (void *priv, struct dma_desc *p);
0548 };
0549 
0550 #define stmmac_mode_init(__priv, __args...) \
0551     stmmac_do_void_callback(__priv, mode, init, __args)
0552 #define stmmac_is_jumbo_frm(__priv, __args...) \
0553     stmmac_do_callback(__priv, mode, is_jumbo_frm, __args)
0554 #define stmmac_jumbo_frm(__priv, __args...) \
0555     stmmac_do_callback(__priv, mode, jumbo_frm, __args)
0556 #define stmmac_set_16kib_bfsize(__priv, __args...) \
0557     stmmac_do_callback(__priv, mode, set_16kib_bfsize, __args)
0558 #define stmmac_init_desc3(__priv, __args...) \
0559     stmmac_do_void_callback(__priv, mode, init_desc3, __args)
0560 #define stmmac_refill_desc3(__priv, __args...) \
0561     stmmac_do_void_callback(__priv, mode, refill_desc3, __args)
0562 #define stmmac_clean_desc3(__priv, __args...) \
0563     stmmac_do_void_callback(__priv, mode, clean_desc3, __args)
0564 
0565 struct tc_cls_u32_offload;
0566 struct tc_cbs_qopt_offload;
0567 struct flow_cls_offload;
0568 struct tc_taprio_qopt_offload;
0569 struct tc_etf_qopt_offload;
0570 
0571 struct stmmac_tc_ops {
0572     int (*init)(struct stmmac_priv *priv);
0573     int (*setup_cls_u32)(struct stmmac_priv *priv,
0574                  struct tc_cls_u32_offload *cls);
0575     int (*setup_cbs)(struct stmmac_priv *priv,
0576              struct tc_cbs_qopt_offload *qopt);
0577     int (*setup_cls)(struct stmmac_priv *priv,
0578              struct flow_cls_offload *cls);
0579     int (*setup_taprio)(struct stmmac_priv *priv,
0580                 struct tc_taprio_qopt_offload *qopt);
0581     int (*setup_etf)(struct stmmac_priv *priv,
0582              struct tc_etf_qopt_offload *qopt);
0583 };
0584 
0585 #define stmmac_tc_init(__priv, __args...) \
0586     stmmac_do_callback(__priv, tc, init, __args)
0587 #define stmmac_tc_setup_cls_u32(__priv, __args...) \
0588     stmmac_do_callback(__priv, tc, setup_cls_u32, __args)
0589 #define stmmac_tc_setup_cbs(__priv, __args...) \
0590     stmmac_do_callback(__priv, tc, setup_cbs, __args)
0591 #define stmmac_tc_setup_cls(__priv, __args...) \
0592     stmmac_do_callback(__priv, tc, setup_cls, __args)
0593 #define stmmac_tc_setup_taprio(__priv, __args...) \
0594     stmmac_do_callback(__priv, tc, setup_taprio, __args)
0595 #define stmmac_tc_setup_etf(__priv, __args...) \
0596     stmmac_do_callback(__priv, tc, setup_etf, __args)
0597 
0598 struct stmmac_counters;
0599 
0600 struct stmmac_mmc_ops {
0601     void (*ctrl)(void __iomem *ioaddr, unsigned int mode);
0602     void (*intr_all_mask)(void __iomem *ioaddr);
0603     void (*read)(void __iomem *ioaddr, struct stmmac_counters *mmc);
0604 };
0605 
0606 #define stmmac_mmc_ctrl(__priv, __args...) \
0607     stmmac_do_void_callback(__priv, mmc, ctrl, __args)
0608 #define stmmac_mmc_intr_all_mask(__priv, __args...) \
0609     stmmac_do_void_callback(__priv, mmc, intr_all_mask, __args)
0610 #define stmmac_mmc_read(__priv, __args...) \
0611     stmmac_do_void_callback(__priv, mmc, read, __args)
0612 
0613 struct stmmac_regs_off {
0614     u32 ptp_off;
0615     u32 mmc_off;
0616 };
0617 
0618 extern const struct stmmac_ops dwmac100_ops;
0619 extern const struct stmmac_dma_ops dwmac100_dma_ops;
0620 extern const struct stmmac_ops dwmac1000_ops;
0621 extern const struct stmmac_dma_ops dwmac1000_dma_ops;
0622 extern const struct stmmac_ops dwmac4_ops;
0623 extern const struct stmmac_dma_ops dwmac4_dma_ops;
0624 extern const struct stmmac_ops dwmac410_ops;
0625 extern const struct stmmac_dma_ops dwmac410_dma_ops;
0626 extern const struct stmmac_ops dwmac510_ops;
0627 extern const struct stmmac_tc_ops dwmac510_tc_ops;
0628 extern const struct stmmac_ops dwxgmac210_ops;
0629 extern const struct stmmac_ops dwxlgmac2_ops;
0630 extern const struct stmmac_dma_ops dwxgmac210_dma_ops;
0631 extern const struct stmmac_desc_ops dwxgmac210_desc_ops;
0632 extern const struct stmmac_mmc_ops dwmac_mmc_ops;
0633 extern const struct stmmac_mmc_ops dwxgmac_mmc_ops;
0634 
0635 #define GMAC_VERSION        0x00000020  /* GMAC CORE Version */
0636 #define GMAC4_VERSION       0x00000110  /* GMAC4+ CORE Version */
0637 
0638 int stmmac_hwif_init(struct stmmac_priv *priv);
0639 
0640 #endif /* __STMMAC_HWIF_H__ */