14fa9c49fSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 27ac6653aSJeff Kirsher /******************************************************************************* 37ac6653aSJeff Kirsher Copyright (C) 2007-2009 STMicroelectronics Ltd 47ac6653aSJeff Kirsher 57ac6653aSJeff Kirsher 67ac6653aSJeff Kirsher Author: Giuseppe Cavallaro <peppe.cavallaro@st.com> 77ac6653aSJeff Kirsher *******************************************************************************/ 87ac6653aSJeff Kirsher 9bd4242dfSRayagond Kokatanur #ifndef __STMMAC_H__ 10bd4242dfSRayagond Kokatanur #define __STMMAC_H__ 11bd4242dfSRayagond Kokatanur 12bfab27a1SGiuseppe CAVALLARO #define STMMAC_RESOURCE_NAME "stmmaceth" 13ba1377ffSGiuseppe CAVALLARO 14ba1377ffSGiuseppe CAVALLARO #include <linux/clk.h> 15d5a05e69SVincent Whitchurch #include <linux/hrtimer.h> 163cd1cfcbSJose Abreu #include <linux/if_vlan.h> 177ac6653aSJeff Kirsher #include <linux/stmmac.h> 18eeef2f6bSJose Abreu #include <linux/phylink.h> 1933d5e332SGiuseppe CAVALLARO #include <linux/pci.h> 207ac6653aSJeff Kirsher #include "common.h" 2192ba6888SRayagond Kokatanur #include <linux/ptp_clock_kernel.h> 22d6228b7cSArtem Panfilov #include <linux/net_tstamp.h> 23c5e4ddbdSChen-Yu Tsai #include <linux/reset.h> 242af6106aSJose Abreu #include <net/page_pool.h> 25*92272ec4SJakub Kicinski #include <net/xdp.h> 263b80b73aSJakub Kicinski #include <uapi/linux/bpf.h> 277ac6653aSJeff Kirsher 28e56788cfSJoachim Eastwood struct stmmac_resources { 29e56788cfSJoachim Eastwood void __iomem *addr; 3083216e39SMichael Walle u8 mac[ETH_ALEN]; 31e56788cfSJoachim Eastwood int wol_irq; 32e56788cfSJoachim Eastwood int lpi_irq; 33e56788cfSJoachim Eastwood int irq; 348532f613SOng Boon Leong int sfty_ce_irq; 358532f613SOng Boon Leong int sfty_ue_irq; 368532f613SOng Boon Leong int rx_irq[MTL_MAX_RX_QUEUES]; 378532f613SOng Boon Leong int tx_irq[MTL_MAX_TX_QUEUES]; 38e56788cfSJoachim Eastwood }; 39e56788cfSJoachim Eastwood 40be8b38a7SOng Boon Leong enum stmmac_txbuf_type { 41be8b38a7SOng Boon Leong STMMAC_TXBUF_T_SKB, 42be8b38a7SOng Boon Leong STMMAC_TXBUF_T_XDP_TX, 438b278a5bSOng Boon Leong STMMAC_TXBUF_T_XDP_NDO, 44132c32eeSOng Boon Leong STMMAC_TXBUF_T_XSK_TX, 45be8b38a7SOng Boon Leong }; 46be8b38a7SOng Boon Leong 47362b37beSGiuseppe CAVALLARO struct stmmac_tx_info { 48362b37beSGiuseppe CAVALLARO dma_addr_t buf; 49362b37beSGiuseppe CAVALLARO bool map_as_page; 50553e2ab3SGiuseppe Cavallaro unsigned len; 512a6d8e17SGiuseppe Cavallaro bool last_segment; 5296951366SGiuseppe Cavallaro bool is_jumbo; 53be8b38a7SOng Boon Leong enum stmmac_txbuf_type buf_type; 54362b37beSGiuseppe CAVALLARO }; 55362b37beSGiuseppe CAVALLARO 56579a25a8SJose Abreu #define STMMAC_TBS_AVAIL BIT(0) 57579a25a8SJose Abreu #define STMMAC_TBS_EN BIT(1) 58579a25a8SJose Abreu 59ce736788SJoao Pinto /* Frequently used values are kept adjacent for cache effect */ 60ce736788SJoao Pinto struct stmmac_tx_queue { 618fce3331SJose Abreu u32 tx_count_frames; 62579a25a8SJose Abreu int tbs; 63d5a05e69SVincent Whitchurch struct hrtimer txtimer; 64ce736788SJoao Pinto u32 queue_index; 65ce736788SJoao Pinto struct stmmac_priv *priv_data; 66ce736788SJoao Pinto struct dma_extended_desc *dma_etx ____cacheline_aligned_in_smp; 67579a25a8SJose Abreu struct dma_edesc *dma_entx; 68ce736788SJoao Pinto struct dma_desc *dma_tx; 69be8b38a7SOng Boon Leong union { 70ce736788SJoao Pinto struct sk_buff **tx_skbuff; 71be8b38a7SOng Boon Leong struct xdp_frame **xdpf; 72be8b38a7SOng Boon Leong }; 73ce736788SJoao Pinto struct stmmac_tx_info *tx_skbuff_dma; 74132c32eeSOng Boon Leong struct xsk_buff_pool *xsk_pool; 75132c32eeSOng Boon Leong u32 xsk_frames_done; 76ce736788SJoao Pinto unsigned int cur_tx; 77ce736788SJoao Pinto unsigned int dirty_tx; 78ce736788SJoao Pinto dma_addr_t dma_tx_phy; 7952e597d3SWong Vee Khee dma_addr_t tx_tail_addr; 808d212a9eSNiklas Cassel u32 mss; 81133466c3SJisheng Zhang struct stmmac_txq_stats txq_stats; 82ce736788SJoao Pinto }; 83ce736788SJoao Pinto 842af6106aSJose Abreu struct stmmac_rx_buffer { 85bba2556eSOng Boon Leong union { 86bba2556eSOng Boon Leong struct { 872af6106aSJose Abreu struct page *page; 882af6106aSJose Abreu dma_addr_t addr; 895fabb012SOng Boon Leong __u32 page_offset; 90bba2556eSOng Boon Leong }; 91bba2556eSOng Boon Leong struct xdp_buff *xdp; 92bba2556eSOng Boon Leong }; 935fabb012SOng Boon Leong struct page *sec_page; 9467afd6d1SJose Abreu dma_addr_t sec_addr; 952af6106aSJose Abreu }; 962af6106aSJose Abreu 975b24324aSSong Yoong Siang struct stmmac_xdp_buff { 985b24324aSSong Yoong Siang struct xdp_buff xdp; 99e3f9c3e3SSong Yoong Siang struct stmmac_priv *priv; 100e3f9c3e3SSong Yoong Siang struct dma_desc *desc; 101e3f9c3e3SSong Yoong Siang struct dma_desc *ndesc; 1025b24324aSSong Yoong Siang }; 1035b24324aSSong Yoong Siang 10454139cf3SJoao Pinto struct stmmac_rx_queue { 105d429b66eSJose Abreu u32 rx_count_frames; 10654139cf3SJoao Pinto u32 queue_index; 107be8b38a7SOng Boon Leong struct xdp_rxq_info xdp_rxq; 108bba2556eSOng Boon Leong struct xsk_buff_pool *xsk_pool; 1092af6106aSJose Abreu struct page_pool *page_pool; 1102af6106aSJose Abreu struct stmmac_rx_buffer *buf_pool; 11154139cf3SJoao Pinto struct stmmac_priv *priv_data; 11254139cf3SJoao Pinto struct dma_extended_desc *dma_erx; 11354139cf3SJoao Pinto struct dma_desc *dma_rx ____cacheline_aligned_in_smp; 11454139cf3SJoao Pinto unsigned int cur_rx; 11554139cf3SJoao Pinto unsigned int dirty_rx; 116bba2556eSOng Boon Leong unsigned int buf_alloc_num; 11754139cf3SJoao Pinto u32 rx_zeroc_thresh; 11854139cf3SJoao Pinto dma_addr_t dma_rx_phy; 11954139cf3SJoao Pinto u32 rx_tail_addr; 120ec222003SJose Abreu unsigned int state_saved; 121ec222003SJose Abreu struct { 122ec222003SJose Abreu struct sk_buff *skb; 123ec222003SJose Abreu unsigned int len; 124ec222003SJose Abreu unsigned int error; 125ec222003SJose Abreu } state; 126133466c3SJisheng Zhang struct stmmac_rxq_stats rxq_stats; 1278fce3331SJose Abreu }; 1288fce3331SJose Abreu 1298fce3331SJose Abreu struct stmmac_channel { 1304ccb4585SJose Abreu struct napi_struct rx_napi ____cacheline_aligned_in_smp; 1314ccb4585SJose Abreu struct napi_struct tx_napi ____cacheline_aligned_in_smp; 132132c32eeSOng Boon Leong struct napi_struct rxtx_napi ____cacheline_aligned_in_smp; 1338fce3331SJose Abreu struct stmmac_priv *priv_data; 134021bd5e3SJose Abreu spinlock_t lock; 1358fce3331SJose Abreu u32 index; 13654139cf3SJoao Pinto }; 13754139cf3SJoao Pinto 1384dbbe8ddSJose Abreu struct stmmac_tc_entry { 1394dbbe8ddSJose Abreu bool in_use; 1404dbbe8ddSJose Abreu bool in_hw; 1414dbbe8ddSJose Abreu bool is_last; 1424dbbe8ddSJose Abreu bool is_frag; 1434dbbe8ddSJose Abreu void *frag_ptr; 1444dbbe8ddSJose Abreu unsigned int table_pos; 1454dbbe8ddSJose Abreu u32 handle; 1464dbbe8ddSJose Abreu u32 prio; 1474dbbe8ddSJose Abreu struct { 1484dbbe8ddSJose Abreu u32 match_data; 1494dbbe8ddSJose Abreu u32 match_en; 1504dbbe8ddSJose Abreu u8 af:1; 1514dbbe8ddSJose Abreu u8 rf:1; 1524dbbe8ddSJose Abreu u8 im:1; 1534dbbe8ddSJose Abreu u8 nc:1; 1544dbbe8ddSJose Abreu u8 res1:4; 1554dbbe8ddSJose Abreu u8 frame_offset; 1564dbbe8ddSJose Abreu u8 ok_index; 1574dbbe8ddSJose Abreu u8 dma_ch_no; 1584dbbe8ddSJose Abreu u32 res2; 1594dbbe8ddSJose Abreu } __packed val; 1604dbbe8ddSJose Abreu }; 1614dbbe8ddSJose Abreu 1629a8a02c9SJose Abreu #define STMMAC_PPS_MAX 4 1639a8a02c9SJose Abreu struct stmmac_pps_cfg { 1649a8a02c9SJose Abreu bool available; 1659a8a02c9SJose Abreu struct timespec64 start; 1669a8a02c9SJose Abreu struct timespec64 period; 1679a8a02c9SJose Abreu }; 1689a8a02c9SJose Abreu 16976067459SJose Abreu struct stmmac_rss { 17076067459SJose Abreu int enable; 17176067459SJose Abreu u8 key[STMMAC_RSS_HASH_KEY_SIZE]; 17276067459SJose Abreu u32 table[STMMAC_RSS_MAX_TABLE_SIZE]; 17376067459SJose Abreu }; 17476067459SJose Abreu 175425eabddSJose Abreu #define STMMAC_FLOW_ACTION_DROP BIT(0) 176425eabddSJose Abreu struct stmmac_flow_entry { 177425eabddSJose Abreu unsigned long cookie; 178425eabddSJose Abreu unsigned long action; 179425eabddSJose Abreu u8 ip_proto; 180425eabddSJose Abreu int in_use; 181425eabddSJose Abreu int idx; 182425eabddSJose Abreu int is_l4; 183425eabddSJose Abreu }; 184425eabddSJose Abreu 185aeb7c75cSOng Boon Leong /* Rx Frame Steering */ 186aeb7c75cSOng Boon Leong enum stmmac_rfs_type { 187aeb7c75cSOng Boon Leong STMMAC_RFS_T_VLAN, 188e48cb313SOng Boon Leong STMMAC_RFS_T_LLDP, 189e48cb313SOng Boon Leong STMMAC_RFS_T_1588, 190aeb7c75cSOng Boon Leong STMMAC_RFS_T_MAX, 191aeb7c75cSOng Boon Leong }; 192aeb7c75cSOng Boon Leong 193aeb7c75cSOng Boon Leong struct stmmac_rfs_entry { 194aeb7c75cSOng Boon Leong unsigned long cookie; 195e48cb313SOng Boon Leong u16 etype; 196aeb7c75cSOng Boon Leong int in_use; 197aeb7c75cSOng Boon Leong int type; 198aeb7c75cSOng Boon Leong int tc; 199aeb7c75cSOng Boon Leong }; 200aeb7c75cSOng Boon Leong 2018531c808SChristian Marangi struct stmmac_dma_conf { 2028531c808SChristian Marangi unsigned int dma_buf_sz; 2038531c808SChristian Marangi 2048531c808SChristian Marangi /* RX Queue */ 2058531c808SChristian Marangi struct stmmac_rx_queue rx_queue[MTL_MAX_RX_QUEUES]; 2068531c808SChristian Marangi unsigned int dma_rx_size; 2078531c808SChristian Marangi 2088531c808SChristian Marangi /* TX Queue */ 2098531c808SChristian Marangi struct stmmac_tx_queue tx_queue[MTL_MAX_TX_QUEUES]; 2108531c808SChristian Marangi unsigned int dma_tx_size; 2118531c808SChristian Marangi }; 2128531c808SChristian Marangi 2137ac6653aSJeff Kirsher struct stmmac_priv { 2147ac6653aSJeff Kirsher /* Frequently used values are kept adjacent for cache effect */ 215db2f2842SOng Boon Leong u32 tx_coal_frames[MTL_MAX_TX_QUEUES]; 216db2f2842SOng Boon Leong u32 tx_coal_timer[MTL_MAX_TX_QUEUES]; 217db2f2842SOng Boon Leong u32 rx_coal_frames[MTL_MAX_TX_QUEUES]; 218ce736788SJoao Pinto 2191bb6dea8SGiuseppe CAVALLARO int hwts_tx_en; 2201bb6dea8SGiuseppe CAVALLARO bool tx_path_in_lpi_mode; 221f748be53SAlexandre TORGUE bool tso; 22267afd6d1SJose Abreu int sph; 223d08d32d1SOng Boon Leong int sph_cap; 2248000ddc0SJose Abreu u32 sarc_type; 2257ac6653aSJeff Kirsher 22622ad3838SGiuseppe Cavallaro unsigned int rx_copybreak; 227db2f2842SOng Boon Leong u32 rx_riwt[MTL_MAX_TX_QUEUES]; 2281bb6dea8SGiuseppe CAVALLARO int hwts_rx_en; 2295bacd778SLABBE Corentin 2301bb6dea8SGiuseppe CAVALLARO void __iomem *ioaddr; 2311bb6dea8SGiuseppe CAVALLARO struct net_device *dev; 2327ac6653aSJeff Kirsher struct device *device; 2337ac6653aSJeff Kirsher struct mac_device_info *hw; 2347cfde0afSJose Abreu int (*hwif_quirks)(struct stmmac_priv *priv); 23529555fa3SThierry Reding struct mutex lock; 2367ac6653aSJeff Kirsher 2378531c808SChristian Marangi struct stmmac_dma_conf dma_conf; 238ce736788SJoao Pinto 2398fce3331SJose Abreu /* Generic channel for NAPI */ 2408fce3331SJose Abreu struct stmmac_channel channel[STMMAC_CH_MAX]; 2418fce3331SJose Abreu 2427ac6653aSJeff Kirsher int speed; 2437ac6653aSJeff Kirsher unsigned int flow_ctrl; 2447ac6653aSJeff Kirsher unsigned int pause; 2457ac6653aSJeff Kirsher struct mii_bus *mii; 2467ac6653aSJeff Kirsher 247eeef2f6bSJose Abreu struct phylink_config phylink_config; 248eeef2f6bSJose Abreu struct phylink *phylink; 249eeef2f6bSJose Abreu 2501bb6dea8SGiuseppe CAVALLARO struct stmmac_extra_stats xstats ____cacheline_aligned_in_smp; 2518bf993a5SJose Abreu struct stmmac_safety_stats sstats; 2521bb6dea8SGiuseppe CAVALLARO struct plat_stmmacenet_data *plat; 2531bb6dea8SGiuseppe CAVALLARO struct dma_features dma_cap; 2541bb6dea8SGiuseppe CAVALLARO struct stmmac_counters mmc; 2551bb6dea8SGiuseppe CAVALLARO int hw_cap_support; 2561bb6dea8SGiuseppe CAVALLARO int synopsys_id; 2577ac6653aSJeff Kirsher u32 msg_enable; 2587ac6653aSJeff Kirsher int wolopts; 2593172d3afSDeepak Sikri int wol_irq; 260cd7201f4SGiuseppe CAVALLARO int clk_csr; 261d765955dSGiuseppe CAVALLARO struct timer_list eee_ctrl_timer; 262d765955dSGiuseppe CAVALLARO int lpi_irq; 263d765955dSGiuseppe CAVALLARO int eee_enabled; 264d765955dSGiuseppe CAVALLARO int eee_active; 265d765955dSGiuseppe CAVALLARO int tx_lpi_timer; 266388e201dSVineetha G. Jaya Kumaran int tx_lpi_enabled; 267388e201dSVineetha G. Jaya Kumaran int eee_tw_timer; 268be1c7eaeSVineetha G. Jaya Kumaran bool eee_sw_timer_en; 2694a7d666aSGiuseppe CAVALLARO unsigned int mode; 2705f0456b4SJose Abreu unsigned int chain_mode; 271c24602efSGiuseppe CAVALLARO int extend_desc; 272d6228b7cSArtem Panfilov struct hwtstamp_config tstamp_config; 27392ba6888SRayagond Kokatanur struct ptp_clock *ptp_clock; 27492ba6888SRayagond Kokatanur struct ptp_clock_info ptp_clock_ops; 2751bb6dea8SGiuseppe CAVALLARO unsigned int default_addend; 2769a8a02c9SJose Abreu u32 sub_second_inc; 2779a8a02c9SJose Abreu u32 systime_flags; 2781bb6dea8SGiuseppe CAVALLARO u32 adv_ts; 2791bb6dea8SGiuseppe CAVALLARO int use_riwt; 28089f7f2cfSSrinivas Kandagatla int irq_wake; 281642436a1SYannick Vignon rwlock_t ptp_lock; 282f4da5652STan Tee Min /* Protects auxiliary snapshot registers from concurrent access. */ 283f4da5652STan Tee Min struct mutex aux_ts_lock; 28476c16d3eSWong Vee Khee wait_queue_head_t tstamp_busy_wait; 285f4da5652STan Tee Min 28636ff7c1eSAlexandre TORGUE void __iomem *mmcaddr; 287ba1ffd74SGiuseppe CAVALLARO void __iomem *ptpaddr; 2883cd1cfcbSJose Abreu unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; 2898532f613SOng Boon Leong int sfty_ce_irq; 2908532f613SOng Boon Leong int sfty_ue_irq; 2918532f613SOng Boon Leong int rx_irq[MTL_MAX_RX_QUEUES]; 2928532f613SOng Boon Leong int tx_irq[MTL_MAX_TX_QUEUES]; 2938532f613SOng Boon Leong /*irq name */ 2948532f613SOng Boon Leong char int_name_mac[IFNAMSIZ + 9]; 2958532f613SOng Boon Leong char int_name_wol[IFNAMSIZ + 9]; 2968532f613SOng Boon Leong char int_name_lpi[IFNAMSIZ + 9]; 2978532f613SOng Boon Leong char int_name_sfty_ce[IFNAMSIZ + 10]; 2988532f613SOng Boon Leong char int_name_sfty_ue[IFNAMSIZ + 10]; 2998532f613SOng Boon Leong char int_name_rx_irq[MTL_MAX_TX_QUEUES][IFNAMSIZ + 14]; 3008532f613SOng Boon Leong char int_name_tx_irq[MTL_MAX_TX_QUEUES][IFNAMSIZ + 18]; 301466c5ac8SMathieu Olivari 302466c5ac8SMathieu Olivari #ifdef CONFIG_DEBUG_FS 303466c5ac8SMathieu Olivari struct dentry *dbgfs_dir; 304466c5ac8SMathieu Olivari #endif 30534877a15SJose Abreu 30634877a15SJose Abreu unsigned long state; 30734877a15SJose Abreu struct workqueue_struct *wq; 30834877a15SJose Abreu struct work_struct service_task; 3094dbbe8ddSJose Abreu 3105a558611SOng Boon Leong /* Workqueue for handling FPE hand-shaking */ 3115a558611SOng Boon Leong unsigned long fpe_task_state; 3125a558611SOng Boon Leong struct workqueue_struct *fpe_wq; 3135a558611SOng Boon Leong struct work_struct fpe_task; 3145a558611SOng Boon Leong char wq_name[IFNAMSIZ + 4]; 3155a558611SOng Boon Leong 3164dbbe8ddSJose Abreu /* TC Handling */ 3174dbbe8ddSJose Abreu unsigned int tc_entries_max; 3184dbbe8ddSJose Abreu unsigned int tc_off_max; 3194dbbe8ddSJose Abreu struct stmmac_tc_entry *tc_entries; 320425eabddSJose Abreu unsigned int flow_entries_max; 321425eabddSJose Abreu struct stmmac_flow_entry *flow_entries; 322aeb7c75cSOng Boon Leong unsigned int rfs_entries_max[STMMAC_RFS_T_MAX]; 323aeb7c75cSOng Boon Leong unsigned int rfs_entries_cnt[STMMAC_RFS_T_MAX]; 324aeb7c75cSOng Boon Leong unsigned int rfs_entries_total; 325aeb7c75cSOng Boon Leong struct stmmac_rfs_entry *rfs_entries; 3269a8a02c9SJose Abreu 3279a8a02c9SJose Abreu /* Pulse Per Second output */ 3289a8a02c9SJose Abreu struct stmmac_pps_cfg pps[STMMAC_PPS_MAX]; 32976067459SJose Abreu 33076067459SJose Abreu /* Receive Side Scaling */ 33176067459SJose Abreu struct stmmac_rss rss; 3325fabb012SOng Boon Leong 3335fabb012SOng Boon Leong /* XDP BPF Program */ 334bba2556eSOng Boon Leong unsigned long *af_xdp_zc_qps; 3355fabb012SOng Boon Leong struct bpf_prog *xdp_prog; 33634877a15SJose Abreu }; 33734877a15SJose Abreu 33834877a15SJose Abreu enum stmmac_state { 33934877a15SJose Abreu STMMAC_DOWN, 34034877a15SJose Abreu STMMAC_RESET_REQUESTED, 34134877a15SJose Abreu STMMAC_RESETING, 34234877a15SJose Abreu STMMAC_SERVICE_SCHED, 3437ac6653aSJeff Kirsher }; 3447ac6653aSJeff Kirsher 345d6cc64efSJoe Perches int stmmac_mdio_unregister(struct net_device *ndev); 346d6cc64efSJoe Perches int stmmac_mdio_register(struct net_device *ndev); 347073752aaSSrinivas Kandagatla int stmmac_mdio_reset(struct mii_bus *mii); 348597a68ceSVoon Weifeng int stmmac_xpcs_setup(struct mii_bus *mii); 349d6cc64efSJoe Perches void stmmac_set_ethtool_ops(struct net_device *netdev); 350915af656SAndy Shevchenko 351a6da2bbbSHolger Assmann int stmmac_init_tstamp_counter(struct stmmac_priv *priv, u32 systime_flags); 352c30a70d3SGiuseppe CAVALLARO void stmmac_ptp_register(struct stmmac_priv *priv); 353d6cc64efSJoe Perches void stmmac_ptp_unregister(struct stmmac_priv *priv); 354ac746c85SOng Boon Leong int stmmac_xdp_open(struct net_device *dev); 355ac746c85SOng Boon Leong void stmmac_xdp_release(struct net_device *dev); 356f4e7bd81SJoachim Eastwood int stmmac_resume(struct device *dev); 357f4e7bd81SJoachim Eastwood int stmmac_suspend(struct device *dev); 358ff0011cfSUwe Kleine-König void stmmac_dvr_remove(struct device *dev); 35915ffac73SJoachim Eastwood int stmmac_dvr_probe(struct device *device, 360cf3f047bSGiuseppe CAVALLARO struct plat_stmmacenet_data *plat_dat, 361e56788cfSJoachim Eastwood struct stmmac_resources *res); 362d765955dSGiuseppe CAVALLARO void stmmac_disable_eee_mode(struct stmmac_priv *priv); 363d765955dSGiuseppe CAVALLARO bool stmmac_eee_init(struct stmmac_priv *priv); 3640366f7e0SOng Boon Leong int stmmac_reinit_queues(struct net_device *dev, u32 rx_cnt, u32 tx_cnt); 365aa042f60SSong, Yoong Siang int stmmac_reinit_ringparam(struct net_device *dev, u32 rx_size, u32 tx_size); 3665ec55823SJoakim Zhang int stmmac_bus_clks_config(struct stmmac_priv *priv, bool enabled); 3675a558611SOng Boon Leong void stmmac_fpe_handshake(struct stmmac_priv *priv, bool enable); 368ba1377ffSGiuseppe CAVALLARO 3695fabb012SOng Boon Leong static inline bool stmmac_xdp_is_enabled(struct stmmac_priv *priv) 3705fabb012SOng Boon Leong { 3715fabb012SOng Boon Leong return !!priv->xdp_prog; 3725fabb012SOng Boon Leong } 3735fabb012SOng Boon Leong 3745fabb012SOng Boon Leong static inline unsigned int stmmac_rx_offset(struct stmmac_priv *priv) 3755fabb012SOng Boon Leong { 3765fabb012SOng Boon Leong if (stmmac_xdp_is_enabled(priv)) 37712d125b4SMarc Zyngier return XDP_PACKET_HEADROOM; 3785fabb012SOng Boon Leong 37912d125b4SMarc Zyngier return 0; 3805fabb012SOng Boon Leong } 3815fabb012SOng Boon Leong 382bba2556eSOng Boon Leong void stmmac_disable_rx_queue(struct stmmac_priv *priv, u32 queue); 383bba2556eSOng Boon Leong void stmmac_enable_rx_queue(struct stmmac_priv *priv, u32 queue); 384132c32eeSOng Boon Leong void stmmac_disable_tx_queue(struct stmmac_priv *priv, u32 queue); 385132c32eeSOng Boon Leong void stmmac_enable_tx_queue(struct stmmac_priv *priv, u32 queue); 386bba2556eSOng Boon Leong int stmmac_xsk_wakeup(struct net_device *dev, u32 queue, u32 flags); 38781c52c42SXiaoliang Yang struct timespec64 stmmac_calc_tas_basetime(ktime_t old_base_time, 38881c52c42SXiaoliang Yang ktime_t current_time, 38981c52c42SXiaoliang Yang u64 cycle_time); 390bba2556eSOng Boon Leong 391091810dbSJose Abreu #if IS_ENABLED(CONFIG_STMMAC_SELFTESTS) 392091810dbSJose Abreu void stmmac_selftest_run(struct net_device *dev, 393091810dbSJose Abreu struct ethtool_test *etest, u64 *buf); 394091810dbSJose Abreu void stmmac_selftest_get_strings(struct stmmac_priv *priv, u8 *data); 395091810dbSJose Abreu int stmmac_selftest_get_count(struct stmmac_priv *priv); 396091810dbSJose Abreu #else 397091810dbSJose Abreu static inline void stmmac_selftest_run(struct net_device *dev, 398091810dbSJose Abreu struct ethtool_test *etest, u64 *buf) 399091810dbSJose Abreu { 400091810dbSJose Abreu /* Not enabled */ 401091810dbSJose Abreu } 402091810dbSJose Abreu static inline void stmmac_selftest_get_strings(struct stmmac_priv *priv, 403091810dbSJose Abreu u8 *data) 404091810dbSJose Abreu { 405091810dbSJose Abreu /* Not enabled */ 406091810dbSJose Abreu } 407091810dbSJose Abreu static inline int stmmac_selftest_get_count(struct stmmac_priv *priv) 408091810dbSJose Abreu { 409091810dbSJose Abreu return -EOPNOTSUPP; 410091810dbSJose Abreu } 411091810dbSJose Abreu #endif /* CONFIG_STMMAC_SELFTESTS */ 412091810dbSJose Abreu 413bd4242dfSRayagond Kokatanur #endif /* __STMMAC_H__ */ 414