xref: /openbmc/linux/drivers/net/ethernet/stmicro/stmmac/stmmac.h (revision 5b24324a907c996faf47ea3969499e04beea9c4f)
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>
253b80b73aSJakub Kicinski #include <uapi/linux/bpf.h>
267ac6653aSJeff Kirsher 
27e56788cfSJoachim Eastwood struct stmmac_resources {
28e56788cfSJoachim Eastwood 	void __iomem *addr;
2983216e39SMichael Walle 	u8 mac[ETH_ALEN];
30e56788cfSJoachim Eastwood 	int wol_irq;
31e56788cfSJoachim Eastwood 	int lpi_irq;
32e56788cfSJoachim Eastwood 	int irq;
338532f613SOng Boon Leong 	int sfty_ce_irq;
348532f613SOng Boon Leong 	int sfty_ue_irq;
358532f613SOng Boon Leong 	int rx_irq[MTL_MAX_RX_QUEUES];
368532f613SOng Boon Leong 	int tx_irq[MTL_MAX_TX_QUEUES];
37e56788cfSJoachim Eastwood };
38e56788cfSJoachim Eastwood 
39be8b38a7SOng Boon Leong enum stmmac_txbuf_type {
40be8b38a7SOng Boon Leong 	STMMAC_TXBUF_T_SKB,
41be8b38a7SOng Boon Leong 	STMMAC_TXBUF_T_XDP_TX,
428b278a5bSOng Boon Leong 	STMMAC_TXBUF_T_XDP_NDO,
43132c32eeSOng Boon Leong 	STMMAC_TXBUF_T_XSK_TX,
44be8b38a7SOng Boon Leong };
45be8b38a7SOng Boon Leong 
46362b37beSGiuseppe CAVALLARO struct stmmac_tx_info {
47362b37beSGiuseppe CAVALLARO 	dma_addr_t buf;
48362b37beSGiuseppe CAVALLARO 	bool map_as_page;
49553e2ab3SGiuseppe Cavallaro 	unsigned len;
502a6d8e17SGiuseppe Cavallaro 	bool last_segment;
5196951366SGiuseppe Cavallaro 	bool is_jumbo;
52be8b38a7SOng Boon Leong 	enum stmmac_txbuf_type buf_type;
53362b37beSGiuseppe CAVALLARO };
54362b37beSGiuseppe CAVALLARO 
55579a25a8SJose Abreu #define STMMAC_TBS_AVAIL	BIT(0)
56579a25a8SJose Abreu #define STMMAC_TBS_EN		BIT(1)
57579a25a8SJose Abreu 
58ce736788SJoao Pinto /* Frequently used values are kept adjacent for cache effect */
59ce736788SJoao Pinto struct stmmac_tx_queue {
608fce3331SJose Abreu 	u32 tx_count_frames;
61579a25a8SJose Abreu 	int tbs;
62d5a05e69SVincent Whitchurch 	struct hrtimer txtimer;
63ce736788SJoao Pinto 	u32 queue_index;
64ce736788SJoao Pinto 	struct stmmac_priv *priv_data;
65ce736788SJoao Pinto 	struct dma_extended_desc *dma_etx ____cacheline_aligned_in_smp;
66579a25a8SJose Abreu 	struct dma_edesc *dma_entx;
67ce736788SJoao Pinto 	struct dma_desc *dma_tx;
68be8b38a7SOng Boon Leong 	union {
69ce736788SJoao Pinto 		struct sk_buff **tx_skbuff;
70be8b38a7SOng Boon Leong 		struct xdp_frame **xdpf;
71be8b38a7SOng Boon Leong 	};
72ce736788SJoao Pinto 	struct stmmac_tx_info *tx_skbuff_dma;
73132c32eeSOng Boon Leong 	struct xsk_buff_pool *xsk_pool;
74132c32eeSOng Boon Leong 	u32 xsk_frames_done;
75ce736788SJoao Pinto 	unsigned int cur_tx;
76ce736788SJoao Pinto 	unsigned int dirty_tx;
77ce736788SJoao Pinto 	dma_addr_t dma_tx_phy;
7852e597d3SWong Vee Khee 	dma_addr_t tx_tail_addr;
798d212a9eSNiklas Cassel 	u32 mss;
80ce736788SJoao Pinto };
81ce736788SJoao Pinto 
822af6106aSJose Abreu struct stmmac_rx_buffer {
83bba2556eSOng Boon Leong 	union {
84bba2556eSOng Boon Leong 		struct {
852af6106aSJose Abreu 			struct page *page;
862af6106aSJose Abreu 			dma_addr_t addr;
875fabb012SOng Boon Leong 			__u32 page_offset;
88bba2556eSOng Boon Leong 		};
89bba2556eSOng Boon Leong 		struct xdp_buff *xdp;
90bba2556eSOng Boon Leong 	};
915fabb012SOng Boon Leong 	struct page *sec_page;
9267afd6d1SJose Abreu 	dma_addr_t sec_addr;
932af6106aSJose Abreu };
942af6106aSJose Abreu 
95*5b24324aSSong Yoong Siang struct stmmac_xdp_buff {
96*5b24324aSSong Yoong Siang 	struct xdp_buff xdp;
97*5b24324aSSong Yoong Siang };
98*5b24324aSSong Yoong Siang 
9954139cf3SJoao Pinto struct stmmac_rx_queue {
100d429b66eSJose Abreu 	u32 rx_count_frames;
10154139cf3SJoao Pinto 	u32 queue_index;
102be8b38a7SOng Boon Leong 	struct xdp_rxq_info xdp_rxq;
103bba2556eSOng Boon Leong 	struct xsk_buff_pool *xsk_pool;
1042af6106aSJose Abreu 	struct page_pool *page_pool;
1052af6106aSJose Abreu 	struct stmmac_rx_buffer *buf_pool;
10654139cf3SJoao Pinto 	struct stmmac_priv *priv_data;
10754139cf3SJoao Pinto 	struct dma_extended_desc *dma_erx;
10854139cf3SJoao Pinto 	struct dma_desc *dma_rx ____cacheline_aligned_in_smp;
10954139cf3SJoao Pinto 	unsigned int cur_rx;
11054139cf3SJoao Pinto 	unsigned int dirty_rx;
111bba2556eSOng Boon Leong 	unsigned int buf_alloc_num;
11254139cf3SJoao Pinto 	u32 rx_zeroc_thresh;
11354139cf3SJoao Pinto 	dma_addr_t dma_rx_phy;
11454139cf3SJoao Pinto 	u32 rx_tail_addr;
115ec222003SJose Abreu 	unsigned int state_saved;
116ec222003SJose Abreu 	struct {
117ec222003SJose Abreu 		struct sk_buff *skb;
118ec222003SJose Abreu 		unsigned int len;
119ec222003SJose Abreu 		unsigned int error;
120ec222003SJose Abreu 	} state;
1218fce3331SJose Abreu };
1228fce3331SJose Abreu 
1238fce3331SJose Abreu struct stmmac_channel {
1244ccb4585SJose Abreu 	struct napi_struct rx_napi ____cacheline_aligned_in_smp;
1254ccb4585SJose Abreu 	struct napi_struct tx_napi ____cacheline_aligned_in_smp;
126132c32eeSOng Boon Leong 	struct napi_struct rxtx_napi ____cacheline_aligned_in_smp;
1278fce3331SJose Abreu 	struct stmmac_priv *priv_data;
128021bd5e3SJose Abreu 	spinlock_t lock;
1298fce3331SJose Abreu 	u32 index;
13054139cf3SJoao Pinto };
13154139cf3SJoao Pinto 
1324dbbe8ddSJose Abreu struct stmmac_tc_entry {
1334dbbe8ddSJose Abreu 	bool in_use;
1344dbbe8ddSJose Abreu 	bool in_hw;
1354dbbe8ddSJose Abreu 	bool is_last;
1364dbbe8ddSJose Abreu 	bool is_frag;
1374dbbe8ddSJose Abreu 	void *frag_ptr;
1384dbbe8ddSJose Abreu 	unsigned int table_pos;
1394dbbe8ddSJose Abreu 	u32 handle;
1404dbbe8ddSJose Abreu 	u32 prio;
1414dbbe8ddSJose Abreu 	struct {
1424dbbe8ddSJose Abreu 		u32 match_data;
1434dbbe8ddSJose Abreu 		u32 match_en;
1444dbbe8ddSJose Abreu 		u8 af:1;
1454dbbe8ddSJose Abreu 		u8 rf:1;
1464dbbe8ddSJose Abreu 		u8 im:1;
1474dbbe8ddSJose Abreu 		u8 nc:1;
1484dbbe8ddSJose Abreu 		u8 res1:4;
1494dbbe8ddSJose Abreu 		u8 frame_offset;
1504dbbe8ddSJose Abreu 		u8 ok_index;
1514dbbe8ddSJose Abreu 		u8 dma_ch_no;
1524dbbe8ddSJose Abreu 		u32 res2;
1534dbbe8ddSJose Abreu 	} __packed val;
1544dbbe8ddSJose Abreu };
1554dbbe8ddSJose Abreu 
1569a8a02c9SJose Abreu #define STMMAC_PPS_MAX		4
1579a8a02c9SJose Abreu struct stmmac_pps_cfg {
1589a8a02c9SJose Abreu 	bool available;
1599a8a02c9SJose Abreu 	struct timespec64 start;
1609a8a02c9SJose Abreu 	struct timespec64 period;
1619a8a02c9SJose Abreu };
1629a8a02c9SJose Abreu 
16376067459SJose Abreu struct stmmac_rss {
16476067459SJose Abreu 	int enable;
16576067459SJose Abreu 	u8 key[STMMAC_RSS_HASH_KEY_SIZE];
16676067459SJose Abreu 	u32 table[STMMAC_RSS_MAX_TABLE_SIZE];
16776067459SJose Abreu };
16876067459SJose Abreu 
169425eabddSJose Abreu #define STMMAC_FLOW_ACTION_DROP		BIT(0)
170425eabddSJose Abreu struct stmmac_flow_entry {
171425eabddSJose Abreu 	unsigned long cookie;
172425eabddSJose Abreu 	unsigned long action;
173425eabddSJose Abreu 	u8 ip_proto;
174425eabddSJose Abreu 	int in_use;
175425eabddSJose Abreu 	int idx;
176425eabddSJose Abreu 	int is_l4;
177425eabddSJose Abreu };
178425eabddSJose Abreu 
179aeb7c75cSOng Boon Leong /* Rx Frame Steering */
180aeb7c75cSOng Boon Leong enum stmmac_rfs_type {
181aeb7c75cSOng Boon Leong 	STMMAC_RFS_T_VLAN,
182e48cb313SOng Boon Leong 	STMMAC_RFS_T_LLDP,
183e48cb313SOng Boon Leong 	STMMAC_RFS_T_1588,
184aeb7c75cSOng Boon Leong 	STMMAC_RFS_T_MAX,
185aeb7c75cSOng Boon Leong };
186aeb7c75cSOng Boon Leong 
187aeb7c75cSOng Boon Leong struct stmmac_rfs_entry {
188aeb7c75cSOng Boon Leong 	unsigned long cookie;
189e48cb313SOng Boon Leong 	u16 etype;
190aeb7c75cSOng Boon Leong 	int in_use;
191aeb7c75cSOng Boon Leong 	int type;
192aeb7c75cSOng Boon Leong 	int tc;
193aeb7c75cSOng Boon Leong };
194aeb7c75cSOng Boon Leong 
1958531c808SChristian Marangi struct stmmac_dma_conf {
1968531c808SChristian Marangi 	unsigned int dma_buf_sz;
1978531c808SChristian Marangi 
1988531c808SChristian Marangi 	/* RX Queue */
1998531c808SChristian Marangi 	struct stmmac_rx_queue rx_queue[MTL_MAX_RX_QUEUES];
2008531c808SChristian Marangi 	unsigned int dma_rx_size;
2018531c808SChristian Marangi 
2028531c808SChristian Marangi 	/* TX Queue */
2038531c808SChristian Marangi 	struct stmmac_tx_queue tx_queue[MTL_MAX_TX_QUEUES];
2048531c808SChristian Marangi 	unsigned int dma_tx_size;
2058531c808SChristian Marangi };
2068531c808SChristian Marangi 
2077ac6653aSJeff Kirsher struct stmmac_priv {
2087ac6653aSJeff Kirsher 	/* Frequently used values are kept adjacent for cache effect */
209db2f2842SOng Boon Leong 	u32 tx_coal_frames[MTL_MAX_TX_QUEUES];
210db2f2842SOng Boon Leong 	u32 tx_coal_timer[MTL_MAX_TX_QUEUES];
211db2f2842SOng Boon Leong 	u32 rx_coal_frames[MTL_MAX_TX_QUEUES];
212ce736788SJoao Pinto 
2131bb6dea8SGiuseppe CAVALLARO 	int hwts_tx_en;
2141bb6dea8SGiuseppe CAVALLARO 	bool tx_path_in_lpi_mode;
215f748be53SAlexandre TORGUE 	bool tso;
21667afd6d1SJose Abreu 	int sph;
217d08d32d1SOng Boon Leong 	int sph_cap;
2188000ddc0SJose Abreu 	u32 sarc_type;
2197ac6653aSJeff Kirsher 
22022ad3838SGiuseppe Cavallaro 	unsigned int rx_copybreak;
221db2f2842SOng Boon Leong 	u32 rx_riwt[MTL_MAX_TX_QUEUES];
2221bb6dea8SGiuseppe CAVALLARO 	int hwts_rx_en;
2235bacd778SLABBE Corentin 
2241bb6dea8SGiuseppe CAVALLARO 	void __iomem *ioaddr;
2251bb6dea8SGiuseppe CAVALLARO 	struct net_device *dev;
2267ac6653aSJeff Kirsher 	struct device *device;
2277ac6653aSJeff Kirsher 	struct mac_device_info *hw;
2287cfde0afSJose Abreu 	int (*hwif_quirks)(struct stmmac_priv *priv);
22929555fa3SThierry Reding 	struct mutex lock;
2307ac6653aSJeff Kirsher 
2318531c808SChristian Marangi 	struct stmmac_dma_conf dma_conf;
232ce736788SJoao Pinto 
2338fce3331SJose Abreu 	/* Generic channel for NAPI */
2348fce3331SJose Abreu 	struct stmmac_channel channel[STMMAC_CH_MAX];
2358fce3331SJose Abreu 
2367ac6653aSJeff Kirsher 	int speed;
2377ac6653aSJeff Kirsher 	unsigned int flow_ctrl;
2387ac6653aSJeff Kirsher 	unsigned int pause;
2397ac6653aSJeff Kirsher 	struct mii_bus *mii;
2407ac6653aSJeff Kirsher 
241eeef2f6bSJose Abreu 	struct phylink_config phylink_config;
242eeef2f6bSJose Abreu 	struct phylink *phylink;
243eeef2f6bSJose Abreu 
2441bb6dea8SGiuseppe CAVALLARO 	struct stmmac_extra_stats xstats ____cacheline_aligned_in_smp;
2458bf993a5SJose Abreu 	struct stmmac_safety_stats sstats;
2461bb6dea8SGiuseppe CAVALLARO 	struct plat_stmmacenet_data *plat;
2471bb6dea8SGiuseppe CAVALLARO 	struct dma_features dma_cap;
2481bb6dea8SGiuseppe CAVALLARO 	struct stmmac_counters mmc;
2491bb6dea8SGiuseppe CAVALLARO 	int hw_cap_support;
2501bb6dea8SGiuseppe CAVALLARO 	int synopsys_id;
2517ac6653aSJeff Kirsher 	u32 msg_enable;
2527ac6653aSJeff Kirsher 	int wolopts;
2533172d3afSDeepak Sikri 	int wol_irq;
254cd7201f4SGiuseppe CAVALLARO 	int clk_csr;
255d765955dSGiuseppe CAVALLARO 	struct timer_list eee_ctrl_timer;
256d765955dSGiuseppe CAVALLARO 	int lpi_irq;
257d765955dSGiuseppe CAVALLARO 	int eee_enabled;
258d765955dSGiuseppe CAVALLARO 	int eee_active;
259d765955dSGiuseppe CAVALLARO 	int tx_lpi_timer;
260388e201dSVineetha G. Jaya Kumaran 	int tx_lpi_enabled;
261388e201dSVineetha G. Jaya Kumaran 	int eee_tw_timer;
262be1c7eaeSVineetha G. Jaya Kumaran 	bool eee_sw_timer_en;
2634a7d666aSGiuseppe CAVALLARO 	unsigned int mode;
2645f0456b4SJose Abreu 	unsigned int chain_mode;
265c24602efSGiuseppe CAVALLARO 	int extend_desc;
266d6228b7cSArtem Panfilov 	struct hwtstamp_config tstamp_config;
26792ba6888SRayagond Kokatanur 	struct ptp_clock *ptp_clock;
26892ba6888SRayagond Kokatanur 	struct ptp_clock_info ptp_clock_ops;
2691bb6dea8SGiuseppe CAVALLARO 	unsigned int default_addend;
2709a8a02c9SJose Abreu 	u32 sub_second_inc;
2719a8a02c9SJose Abreu 	u32 systime_flags;
2721bb6dea8SGiuseppe CAVALLARO 	u32 adv_ts;
2731bb6dea8SGiuseppe CAVALLARO 	int use_riwt;
27489f7f2cfSSrinivas Kandagatla 	int irq_wake;
275642436a1SYannick Vignon 	rwlock_t ptp_lock;
276f4da5652STan Tee Min 	/* Protects auxiliary snapshot registers from concurrent access. */
277f4da5652STan Tee Min 	struct mutex aux_ts_lock;
27876c16d3eSWong Vee Khee 	wait_queue_head_t tstamp_busy_wait;
279f4da5652STan Tee Min 
28036ff7c1eSAlexandre TORGUE 	void __iomem *mmcaddr;
281ba1ffd74SGiuseppe CAVALLARO 	void __iomem *ptpaddr;
2823cd1cfcbSJose Abreu 	unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
2838532f613SOng Boon Leong 	int sfty_ce_irq;
2848532f613SOng Boon Leong 	int sfty_ue_irq;
2858532f613SOng Boon Leong 	int rx_irq[MTL_MAX_RX_QUEUES];
2868532f613SOng Boon Leong 	int tx_irq[MTL_MAX_TX_QUEUES];
2878532f613SOng Boon Leong 	/*irq name */
2888532f613SOng Boon Leong 	char int_name_mac[IFNAMSIZ + 9];
2898532f613SOng Boon Leong 	char int_name_wol[IFNAMSIZ + 9];
2908532f613SOng Boon Leong 	char int_name_lpi[IFNAMSIZ + 9];
2918532f613SOng Boon Leong 	char int_name_sfty_ce[IFNAMSIZ + 10];
2928532f613SOng Boon Leong 	char int_name_sfty_ue[IFNAMSIZ + 10];
2938532f613SOng Boon Leong 	char int_name_rx_irq[MTL_MAX_TX_QUEUES][IFNAMSIZ + 14];
2948532f613SOng Boon Leong 	char int_name_tx_irq[MTL_MAX_TX_QUEUES][IFNAMSIZ + 18];
295466c5ac8SMathieu Olivari 
296466c5ac8SMathieu Olivari #ifdef CONFIG_DEBUG_FS
297466c5ac8SMathieu Olivari 	struct dentry *dbgfs_dir;
298466c5ac8SMathieu Olivari #endif
29934877a15SJose Abreu 
30034877a15SJose Abreu 	unsigned long state;
30134877a15SJose Abreu 	struct workqueue_struct *wq;
30234877a15SJose Abreu 	struct work_struct service_task;
3034dbbe8ddSJose Abreu 
3045a558611SOng Boon Leong 	/* Workqueue for handling FPE hand-shaking */
3055a558611SOng Boon Leong 	unsigned long fpe_task_state;
3065a558611SOng Boon Leong 	struct workqueue_struct *fpe_wq;
3075a558611SOng Boon Leong 	struct work_struct fpe_task;
3085a558611SOng Boon Leong 	char wq_name[IFNAMSIZ + 4];
3095a558611SOng Boon Leong 
3104dbbe8ddSJose Abreu 	/* TC Handling */
3114dbbe8ddSJose Abreu 	unsigned int tc_entries_max;
3124dbbe8ddSJose Abreu 	unsigned int tc_off_max;
3134dbbe8ddSJose Abreu 	struct stmmac_tc_entry *tc_entries;
314425eabddSJose Abreu 	unsigned int flow_entries_max;
315425eabddSJose Abreu 	struct stmmac_flow_entry *flow_entries;
316aeb7c75cSOng Boon Leong 	unsigned int rfs_entries_max[STMMAC_RFS_T_MAX];
317aeb7c75cSOng Boon Leong 	unsigned int rfs_entries_cnt[STMMAC_RFS_T_MAX];
318aeb7c75cSOng Boon Leong 	unsigned int rfs_entries_total;
319aeb7c75cSOng Boon Leong 	struct stmmac_rfs_entry *rfs_entries;
3209a8a02c9SJose Abreu 
3219a8a02c9SJose Abreu 	/* Pulse Per Second output */
3229a8a02c9SJose Abreu 	struct stmmac_pps_cfg pps[STMMAC_PPS_MAX];
32376067459SJose Abreu 
32476067459SJose Abreu 	/* Receive Side Scaling */
32576067459SJose Abreu 	struct stmmac_rss rss;
3265fabb012SOng Boon Leong 
3275fabb012SOng Boon Leong 	/* XDP BPF Program */
328bba2556eSOng Boon Leong 	unsigned long *af_xdp_zc_qps;
3295fabb012SOng Boon Leong 	struct bpf_prog *xdp_prog;
33034877a15SJose Abreu };
33134877a15SJose Abreu 
33234877a15SJose Abreu enum stmmac_state {
33334877a15SJose Abreu 	STMMAC_DOWN,
33434877a15SJose Abreu 	STMMAC_RESET_REQUESTED,
33534877a15SJose Abreu 	STMMAC_RESETING,
33634877a15SJose Abreu 	STMMAC_SERVICE_SCHED,
3377ac6653aSJeff Kirsher };
3387ac6653aSJeff Kirsher 
339d6cc64efSJoe Perches int stmmac_mdio_unregister(struct net_device *ndev);
340d6cc64efSJoe Perches int stmmac_mdio_register(struct net_device *ndev);
341073752aaSSrinivas Kandagatla int stmmac_mdio_reset(struct mii_bus *mii);
342597a68ceSVoon Weifeng int stmmac_xpcs_setup(struct mii_bus *mii);
343d6cc64efSJoe Perches void stmmac_set_ethtool_ops(struct net_device *netdev);
344915af656SAndy Shevchenko 
345a6da2bbbSHolger Assmann int stmmac_init_tstamp_counter(struct stmmac_priv *priv, u32 systime_flags);
346c30a70d3SGiuseppe CAVALLARO void stmmac_ptp_register(struct stmmac_priv *priv);
347d6cc64efSJoe Perches void stmmac_ptp_unregister(struct stmmac_priv *priv);
348ac746c85SOng Boon Leong int stmmac_xdp_open(struct net_device *dev);
349ac746c85SOng Boon Leong void stmmac_xdp_release(struct net_device *dev);
350f4e7bd81SJoachim Eastwood int stmmac_resume(struct device *dev);
351f4e7bd81SJoachim Eastwood int stmmac_suspend(struct device *dev);
352ff0011cfSUwe Kleine-König void stmmac_dvr_remove(struct device *dev);
35315ffac73SJoachim Eastwood int stmmac_dvr_probe(struct device *device,
354cf3f047bSGiuseppe CAVALLARO 		     struct plat_stmmacenet_data *plat_dat,
355e56788cfSJoachim Eastwood 		     struct stmmac_resources *res);
356d765955dSGiuseppe CAVALLARO void stmmac_disable_eee_mode(struct stmmac_priv *priv);
357d765955dSGiuseppe CAVALLARO bool stmmac_eee_init(struct stmmac_priv *priv);
3580366f7e0SOng Boon Leong int stmmac_reinit_queues(struct net_device *dev, u32 rx_cnt, u32 tx_cnt);
359aa042f60SSong, Yoong Siang int stmmac_reinit_ringparam(struct net_device *dev, u32 rx_size, u32 tx_size);
3605ec55823SJoakim Zhang int stmmac_bus_clks_config(struct stmmac_priv *priv, bool enabled);
3615a558611SOng Boon Leong void stmmac_fpe_handshake(struct stmmac_priv *priv, bool enable);
362ba1377ffSGiuseppe CAVALLARO 
3635fabb012SOng Boon Leong static inline bool stmmac_xdp_is_enabled(struct stmmac_priv *priv)
3645fabb012SOng Boon Leong {
3655fabb012SOng Boon Leong 	return !!priv->xdp_prog;
3665fabb012SOng Boon Leong }
3675fabb012SOng Boon Leong 
3685fabb012SOng Boon Leong static inline unsigned int stmmac_rx_offset(struct stmmac_priv *priv)
3695fabb012SOng Boon Leong {
3705fabb012SOng Boon Leong 	if (stmmac_xdp_is_enabled(priv))
37112d125b4SMarc Zyngier 		return XDP_PACKET_HEADROOM;
3725fabb012SOng Boon Leong 
37312d125b4SMarc Zyngier 	return 0;
3745fabb012SOng Boon Leong }
3755fabb012SOng Boon Leong 
376bba2556eSOng Boon Leong void stmmac_disable_rx_queue(struct stmmac_priv *priv, u32 queue);
377bba2556eSOng Boon Leong void stmmac_enable_rx_queue(struct stmmac_priv *priv, u32 queue);
378132c32eeSOng Boon Leong void stmmac_disable_tx_queue(struct stmmac_priv *priv, u32 queue);
379132c32eeSOng Boon Leong void stmmac_enable_tx_queue(struct stmmac_priv *priv, u32 queue);
380bba2556eSOng Boon Leong int stmmac_xsk_wakeup(struct net_device *dev, u32 queue, u32 flags);
38181c52c42SXiaoliang Yang struct timespec64 stmmac_calc_tas_basetime(ktime_t old_base_time,
38281c52c42SXiaoliang Yang 					   ktime_t current_time,
38381c52c42SXiaoliang Yang 					   u64 cycle_time);
384bba2556eSOng Boon Leong 
385091810dbSJose Abreu #if IS_ENABLED(CONFIG_STMMAC_SELFTESTS)
386091810dbSJose Abreu void stmmac_selftest_run(struct net_device *dev,
387091810dbSJose Abreu 			 struct ethtool_test *etest, u64 *buf);
388091810dbSJose Abreu void stmmac_selftest_get_strings(struct stmmac_priv *priv, u8 *data);
389091810dbSJose Abreu int stmmac_selftest_get_count(struct stmmac_priv *priv);
390091810dbSJose Abreu #else
391091810dbSJose Abreu static inline void stmmac_selftest_run(struct net_device *dev,
392091810dbSJose Abreu 				       struct ethtool_test *etest, u64 *buf)
393091810dbSJose Abreu {
394091810dbSJose Abreu 	/* Not enabled */
395091810dbSJose Abreu }
396091810dbSJose Abreu static inline void stmmac_selftest_get_strings(struct stmmac_priv *priv,
397091810dbSJose Abreu 					       u8 *data)
398091810dbSJose Abreu {
399091810dbSJose Abreu 	/* Not enabled */
400091810dbSJose Abreu }
401091810dbSJose Abreu static inline int stmmac_selftest_get_count(struct stmmac_priv *priv)
402091810dbSJose Abreu {
403091810dbSJose Abreu 	return -EOPNOTSUPP;
404091810dbSJose Abreu }
405091810dbSJose Abreu #endif /* CONFIG_STMMAC_SELFTESTS */
406091810dbSJose Abreu 
407bd4242dfSRayagond Kokatanur #endif /* __STMMAC_H__ */
408