xref: /openbmc/linux/drivers/net/ethernet/stmicro/stmmac/stmmac.h (revision fac59652993f075d57860769c99045b3ca18780d)
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>
24a9ca9f9cSYunsheng Lin #include <net/page_pool/types.h>
2592272ec4SJakub 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;
81ce736788SJoao Pinto };
82ce736788SJoao Pinto 
832af6106aSJose Abreu struct stmmac_rx_buffer {
84bba2556eSOng Boon Leong 	union {
85bba2556eSOng Boon Leong 		struct {
862af6106aSJose Abreu 			struct page *page;
872af6106aSJose Abreu 			dma_addr_t addr;
885fabb012SOng Boon Leong 			__u32 page_offset;
89bba2556eSOng Boon Leong 		};
90bba2556eSOng Boon Leong 		struct xdp_buff *xdp;
91bba2556eSOng Boon Leong 	};
925fabb012SOng Boon Leong 	struct page *sec_page;
9367afd6d1SJose Abreu 	dma_addr_t sec_addr;
942af6106aSJose Abreu };
952af6106aSJose Abreu 
965b24324aSSong Yoong Siang struct stmmac_xdp_buff {
975b24324aSSong Yoong Siang 	struct xdp_buff xdp;
98e3f9c3e3SSong Yoong Siang 	struct stmmac_priv *priv;
99e3f9c3e3SSong Yoong Siang 	struct dma_desc *desc;
100e3f9c3e3SSong Yoong Siang 	struct dma_desc *ndesc;
1015b24324aSSong Yoong Siang };
1025b24324aSSong Yoong Siang 
10354139cf3SJoao Pinto struct stmmac_rx_queue {
104d429b66eSJose Abreu 	u32 rx_count_frames;
10554139cf3SJoao Pinto 	u32 queue_index;
106be8b38a7SOng Boon Leong 	struct xdp_rxq_info xdp_rxq;
107bba2556eSOng Boon Leong 	struct xsk_buff_pool *xsk_pool;
1082af6106aSJose Abreu 	struct page_pool *page_pool;
1092af6106aSJose Abreu 	struct stmmac_rx_buffer *buf_pool;
11054139cf3SJoao Pinto 	struct stmmac_priv *priv_data;
11154139cf3SJoao Pinto 	struct dma_extended_desc *dma_erx;
11254139cf3SJoao Pinto 	struct dma_desc *dma_rx ____cacheline_aligned_in_smp;
11354139cf3SJoao Pinto 	unsigned int cur_rx;
11454139cf3SJoao Pinto 	unsigned int dirty_rx;
115bba2556eSOng Boon Leong 	unsigned int buf_alloc_num;
11654139cf3SJoao Pinto 	u32 rx_zeroc_thresh;
11754139cf3SJoao Pinto 	dma_addr_t dma_rx_phy;
11854139cf3SJoao Pinto 	u32 rx_tail_addr;
119ec222003SJose Abreu 	unsigned int state_saved;
120ec222003SJose Abreu 	struct {
121ec222003SJose Abreu 		struct sk_buff *skb;
122ec222003SJose Abreu 		unsigned int len;
123ec222003SJose Abreu 		unsigned int error;
124ec222003SJose Abreu 	} state;
1258fce3331SJose Abreu };
1268fce3331SJose Abreu 
1278fce3331SJose Abreu struct stmmac_channel {
1284ccb4585SJose Abreu 	struct napi_struct rx_napi ____cacheline_aligned_in_smp;
1294ccb4585SJose Abreu 	struct napi_struct tx_napi ____cacheline_aligned_in_smp;
130132c32eeSOng Boon Leong 	struct napi_struct rxtx_napi ____cacheline_aligned_in_smp;
1318fce3331SJose Abreu 	struct stmmac_priv *priv_data;
132021bd5e3SJose Abreu 	spinlock_t lock;
1338fce3331SJose Abreu 	u32 index;
13454139cf3SJoao Pinto };
13554139cf3SJoao Pinto 
1364dbbe8ddSJose Abreu struct stmmac_tc_entry {
1374dbbe8ddSJose Abreu 	bool in_use;
1384dbbe8ddSJose Abreu 	bool in_hw;
1394dbbe8ddSJose Abreu 	bool is_last;
1404dbbe8ddSJose Abreu 	bool is_frag;
1414dbbe8ddSJose Abreu 	void *frag_ptr;
1424dbbe8ddSJose Abreu 	unsigned int table_pos;
1434dbbe8ddSJose Abreu 	u32 handle;
1444dbbe8ddSJose Abreu 	u32 prio;
1454dbbe8ddSJose Abreu 	struct {
1464dbbe8ddSJose Abreu 		u32 match_data;
1474dbbe8ddSJose Abreu 		u32 match_en;
1484dbbe8ddSJose Abreu 		u8 af:1;
1494dbbe8ddSJose Abreu 		u8 rf:1;
1504dbbe8ddSJose Abreu 		u8 im:1;
1514dbbe8ddSJose Abreu 		u8 nc:1;
1524dbbe8ddSJose Abreu 		u8 res1:4;
1534dbbe8ddSJose Abreu 		u8 frame_offset;
1544dbbe8ddSJose Abreu 		u8 ok_index;
1554dbbe8ddSJose Abreu 		u8 dma_ch_no;
1564dbbe8ddSJose Abreu 		u32 res2;
1574dbbe8ddSJose Abreu 	} __packed val;
1584dbbe8ddSJose Abreu };
1594dbbe8ddSJose Abreu 
1609a8a02c9SJose Abreu #define STMMAC_PPS_MAX		4
1619a8a02c9SJose Abreu struct stmmac_pps_cfg {
1629a8a02c9SJose Abreu 	bool available;
1639a8a02c9SJose Abreu 	struct timespec64 start;
1649a8a02c9SJose Abreu 	struct timespec64 period;
1659a8a02c9SJose Abreu };
1669a8a02c9SJose Abreu 
16776067459SJose Abreu struct stmmac_rss {
16876067459SJose Abreu 	int enable;
16976067459SJose Abreu 	u8 key[STMMAC_RSS_HASH_KEY_SIZE];
17076067459SJose Abreu 	u32 table[STMMAC_RSS_MAX_TABLE_SIZE];
17176067459SJose Abreu };
17276067459SJose Abreu 
173425eabddSJose Abreu #define STMMAC_FLOW_ACTION_DROP		BIT(0)
174425eabddSJose Abreu struct stmmac_flow_entry {
175425eabddSJose Abreu 	unsigned long cookie;
176425eabddSJose Abreu 	unsigned long action;
177425eabddSJose Abreu 	u8 ip_proto;
178425eabddSJose Abreu 	int in_use;
179425eabddSJose Abreu 	int idx;
180425eabddSJose Abreu 	int is_l4;
181425eabddSJose Abreu };
182425eabddSJose Abreu 
183aeb7c75cSOng Boon Leong /* Rx Frame Steering */
184aeb7c75cSOng Boon Leong enum stmmac_rfs_type {
185aeb7c75cSOng Boon Leong 	STMMAC_RFS_T_VLAN,
186e48cb313SOng Boon Leong 	STMMAC_RFS_T_LLDP,
187e48cb313SOng Boon Leong 	STMMAC_RFS_T_1588,
188aeb7c75cSOng Boon Leong 	STMMAC_RFS_T_MAX,
189aeb7c75cSOng Boon Leong };
190aeb7c75cSOng Boon Leong 
191aeb7c75cSOng Boon Leong struct stmmac_rfs_entry {
192aeb7c75cSOng Boon Leong 	unsigned long cookie;
193e48cb313SOng Boon Leong 	u16 etype;
194aeb7c75cSOng Boon Leong 	int in_use;
195aeb7c75cSOng Boon Leong 	int type;
196aeb7c75cSOng Boon Leong 	int tc;
197aeb7c75cSOng Boon Leong };
198aeb7c75cSOng Boon Leong 
1998531c808SChristian Marangi struct stmmac_dma_conf {
2008531c808SChristian Marangi 	unsigned int dma_buf_sz;
2018531c808SChristian Marangi 
2028531c808SChristian Marangi 	/* RX Queue */
2038531c808SChristian Marangi 	struct stmmac_rx_queue rx_queue[MTL_MAX_RX_QUEUES];
2048531c808SChristian Marangi 	unsigned int dma_rx_size;
2058531c808SChristian Marangi 
2068531c808SChristian Marangi 	/* TX Queue */
2078531c808SChristian Marangi 	struct stmmac_tx_queue tx_queue[MTL_MAX_TX_QUEUES];
2088531c808SChristian Marangi 	unsigned int dma_tx_size;
2098531c808SChristian Marangi };
2108531c808SChristian Marangi 
2117ac6653aSJeff Kirsher struct stmmac_priv {
2127ac6653aSJeff Kirsher 	/* Frequently used values are kept adjacent for cache effect */
213db2f2842SOng Boon Leong 	u32 tx_coal_frames[MTL_MAX_TX_QUEUES];
214db2f2842SOng Boon Leong 	u32 tx_coal_timer[MTL_MAX_TX_QUEUES];
215db2f2842SOng Boon Leong 	u32 rx_coal_frames[MTL_MAX_TX_QUEUES];
216ce736788SJoao Pinto 
2171bb6dea8SGiuseppe CAVALLARO 	int hwts_tx_en;
2181bb6dea8SGiuseppe CAVALLARO 	bool tx_path_in_lpi_mode;
219f748be53SAlexandre TORGUE 	bool tso;
22067afd6d1SJose Abreu 	int sph;
221d08d32d1SOng Boon Leong 	int sph_cap;
2228000ddc0SJose Abreu 	u32 sarc_type;
2237ac6653aSJeff Kirsher 
22422ad3838SGiuseppe Cavallaro 	unsigned int rx_copybreak;
225db2f2842SOng Boon Leong 	u32 rx_riwt[MTL_MAX_TX_QUEUES];
2261bb6dea8SGiuseppe CAVALLARO 	int hwts_rx_en;
2275bacd778SLABBE Corentin 
2281bb6dea8SGiuseppe CAVALLARO 	void __iomem *ioaddr;
2291bb6dea8SGiuseppe CAVALLARO 	struct net_device *dev;
2307ac6653aSJeff Kirsher 	struct device *device;
2317ac6653aSJeff Kirsher 	struct mac_device_info *hw;
2327cfde0afSJose Abreu 	int (*hwif_quirks)(struct stmmac_priv *priv);
23329555fa3SThierry Reding 	struct mutex lock;
2347ac6653aSJeff Kirsher 
2358531c808SChristian Marangi 	struct stmmac_dma_conf dma_conf;
236ce736788SJoao Pinto 
2378fce3331SJose Abreu 	/* Generic channel for NAPI */
2388fce3331SJose Abreu 	struct stmmac_channel channel[STMMAC_CH_MAX];
2398fce3331SJose Abreu 
2407ac6653aSJeff Kirsher 	int speed;
2417ac6653aSJeff Kirsher 	unsigned int flow_ctrl;
2427ac6653aSJeff Kirsher 	unsigned int pause;
2437ac6653aSJeff Kirsher 	struct mii_bus *mii;
2447ac6653aSJeff Kirsher 
245eeef2f6bSJose Abreu 	struct phylink_config phylink_config;
246eeef2f6bSJose Abreu 	struct phylink *phylink;
247eeef2f6bSJose Abreu 
2481bb6dea8SGiuseppe CAVALLARO 	struct stmmac_extra_stats xstats ____cacheline_aligned_in_smp;
2498bf993a5SJose Abreu 	struct stmmac_safety_stats sstats;
2501bb6dea8SGiuseppe CAVALLARO 	struct plat_stmmacenet_data *plat;
251*b538fefeSXiaolei Wang 	/* Protect est parameters */
252*b538fefeSXiaolei Wang 	struct mutex est_lock;
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;
260fed034d2SQiang Ma 	bool wol_irq_disabled;
261cd7201f4SGiuseppe CAVALLARO 	int clk_csr;
262d765955dSGiuseppe CAVALLARO 	struct timer_list eee_ctrl_timer;
263d765955dSGiuseppe CAVALLARO 	int lpi_irq;
264d765955dSGiuseppe CAVALLARO 	int eee_enabled;
265d765955dSGiuseppe CAVALLARO 	int eee_active;
266d765955dSGiuseppe CAVALLARO 	int tx_lpi_timer;
267388e201dSVineetha G. Jaya Kumaran 	int tx_lpi_enabled;
268388e201dSVineetha G. Jaya Kumaran 	int eee_tw_timer;
269be1c7eaeSVineetha G. Jaya Kumaran 	bool eee_sw_timer_en;
2704a7d666aSGiuseppe CAVALLARO 	unsigned int mode;
2715f0456b4SJose Abreu 	unsigned int chain_mode;
272c24602efSGiuseppe CAVALLARO 	int extend_desc;
273d6228b7cSArtem Panfilov 	struct hwtstamp_config tstamp_config;
27492ba6888SRayagond Kokatanur 	struct ptp_clock *ptp_clock;
27592ba6888SRayagond Kokatanur 	struct ptp_clock_info ptp_clock_ops;
2761bb6dea8SGiuseppe CAVALLARO 	unsigned int default_addend;
2779a8a02c9SJose Abreu 	u32 sub_second_inc;
2789a8a02c9SJose Abreu 	u32 systime_flags;
2791bb6dea8SGiuseppe CAVALLARO 	u32 adv_ts;
2801bb6dea8SGiuseppe CAVALLARO 	int use_riwt;
28189f7f2cfSSrinivas Kandagatla 	int irq_wake;
282642436a1SYannick Vignon 	rwlock_t ptp_lock;
283f4da5652STan Tee Min 	/* Protects auxiliary snapshot registers from concurrent access. */
284f4da5652STan Tee Min 	struct mutex aux_ts_lock;
28576c16d3eSWong Vee Khee 	wait_queue_head_t tstamp_busy_wait;
286f4da5652STan Tee Min 
28736ff7c1eSAlexandre TORGUE 	void __iomem *mmcaddr;
288ba1ffd74SGiuseppe CAVALLARO 	void __iomem *ptpaddr;
2893cd1cfcbSJose Abreu 	unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
2908532f613SOng Boon Leong 	int sfty_ce_irq;
2918532f613SOng Boon Leong 	int sfty_ue_irq;
2928532f613SOng Boon Leong 	int rx_irq[MTL_MAX_RX_QUEUES];
2938532f613SOng Boon Leong 	int tx_irq[MTL_MAX_TX_QUEUES];
2948532f613SOng Boon Leong 	/*irq name */
2958532f613SOng Boon Leong 	char int_name_mac[IFNAMSIZ + 9];
2968532f613SOng Boon Leong 	char int_name_wol[IFNAMSIZ + 9];
2978532f613SOng Boon Leong 	char int_name_lpi[IFNAMSIZ + 9];
2988532f613SOng Boon Leong 	char int_name_sfty_ce[IFNAMSIZ + 10];
2998532f613SOng Boon Leong 	char int_name_sfty_ue[IFNAMSIZ + 10];
3008532f613SOng Boon Leong 	char int_name_rx_irq[MTL_MAX_TX_QUEUES][IFNAMSIZ + 14];
3018532f613SOng Boon Leong 	char int_name_tx_irq[MTL_MAX_TX_QUEUES][IFNAMSIZ + 18];
302466c5ac8SMathieu Olivari 
303466c5ac8SMathieu Olivari #ifdef CONFIG_DEBUG_FS
304466c5ac8SMathieu Olivari 	struct dentry *dbgfs_dir;
305466c5ac8SMathieu Olivari #endif
30634877a15SJose Abreu 
30734877a15SJose Abreu 	unsigned long state;
30834877a15SJose Abreu 	struct workqueue_struct *wq;
30934877a15SJose Abreu 	struct work_struct service_task;
3104dbbe8ddSJose Abreu 
3115a558611SOng Boon Leong 	/* Workqueue for handling FPE hand-shaking */
3125a558611SOng Boon Leong 	unsigned long fpe_task_state;
3135a558611SOng Boon Leong 	struct workqueue_struct *fpe_wq;
3145a558611SOng Boon Leong 	struct work_struct fpe_task;
3155a558611SOng Boon Leong 	char wq_name[IFNAMSIZ + 4];
3165a558611SOng Boon Leong 
3174dbbe8ddSJose Abreu 	/* TC Handling */
3184dbbe8ddSJose Abreu 	unsigned int tc_entries_max;
3194dbbe8ddSJose Abreu 	unsigned int tc_off_max;
3204dbbe8ddSJose Abreu 	struct stmmac_tc_entry *tc_entries;
321425eabddSJose Abreu 	unsigned int flow_entries_max;
322425eabddSJose Abreu 	struct stmmac_flow_entry *flow_entries;
323aeb7c75cSOng Boon Leong 	unsigned int rfs_entries_max[STMMAC_RFS_T_MAX];
324aeb7c75cSOng Boon Leong 	unsigned int rfs_entries_cnt[STMMAC_RFS_T_MAX];
325aeb7c75cSOng Boon Leong 	unsigned int rfs_entries_total;
326aeb7c75cSOng Boon Leong 	struct stmmac_rfs_entry *rfs_entries;
3279a8a02c9SJose Abreu 
3289a8a02c9SJose Abreu 	/* Pulse Per Second output */
3299a8a02c9SJose Abreu 	struct stmmac_pps_cfg pps[STMMAC_PPS_MAX];
33076067459SJose Abreu 
33176067459SJose Abreu 	/* Receive Side Scaling */
33276067459SJose Abreu 	struct stmmac_rss rss;
3335fabb012SOng Boon Leong 
3345fabb012SOng Boon Leong 	/* XDP BPF Program */
335bba2556eSOng Boon Leong 	unsigned long *af_xdp_zc_qps;
3365fabb012SOng Boon Leong 	struct bpf_prog *xdp_prog;
33734877a15SJose Abreu };
33834877a15SJose Abreu 
33934877a15SJose Abreu enum stmmac_state {
34034877a15SJose Abreu 	STMMAC_DOWN,
34134877a15SJose Abreu 	STMMAC_RESET_REQUESTED,
34234877a15SJose Abreu 	STMMAC_RESETING,
34334877a15SJose Abreu 	STMMAC_SERVICE_SCHED,
3447ac6653aSJeff Kirsher };
3457ac6653aSJeff Kirsher 
346d6cc64efSJoe Perches int stmmac_mdio_unregister(struct net_device *ndev);
347d6cc64efSJoe Perches int stmmac_mdio_register(struct net_device *ndev);
348073752aaSSrinivas Kandagatla int stmmac_mdio_reset(struct mii_bus *mii);
349597a68ceSVoon Weifeng int stmmac_xpcs_setup(struct mii_bus *mii);
350d6cc64efSJoe Perches void stmmac_set_ethtool_ops(struct net_device *netdev);
351915af656SAndy Shevchenko 
352a6da2bbbSHolger Assmann int stmmac_init_tstamp_counter(struct stmmac_priv *priv, u32 systime_flags);
353c30a70d3SGiuseppe CAVALLARO void stmmac_ptp_register(struct stmmac_priv *priv);
354d6cc64efSJoe Perches void stmmac_ptp_unregister(struct stmmac_priv *priv);
355ac746c85SOng Boon Leong int stmmac_xdp_open(struct net_device *dev);
356ac746c85SOng Boon Leong void stmmac_xdp_release(struct net_device *dev);
357f4e7bd81SJoachim Eastwood int stmmac_resume(struct device *dev);
358f4e7bd81SJoachim Eastwood int stmmac_suspend(struct device *dev);
359ff0011cfSUwe Kleine-König void stmmac_dvr_remove(struct device *dev);
36015ffac73SJoachim Eastwood int stmmac_dvr_probe(struct device *device,
361cf3f047bSGiuseppe CAVALLARO 		     struct plat_stmmacenet_data *plat_dat,
362e56788cfSJoachim Eastwood 		     struct stmmac_resources *res);
363d765955dSGiuseppe CAVALLARO void stmmac_disable_eee_mode(struct stmmac_priv *priv);
364d765955dSGiuseppe CAVALLARO bool stmmac_eee_init(struct stmmac_priv *priv);
3650366f7e0SOng Boon Leong int stmmac_reinit_queues(struct net_device *dev, u32 rx_cnt, u32 tx_cnt);
366aa042f60SSong, Yoong Siang int stmmac_reinit_ringparam(struct net_device *dev, u32 rx_size, u32 tx_size);
3675ec55823SJoakim Zhang int stmmac_bus_clks_config(struct stmmac_priv *priv, bool enabled);
3685a558611SOng Boon Leong void stmmac_fpe_handshake(struct stmmac_priv *priv, bool enable);
369ba1377ffSGiuseppe CAVALLARO 
stmmac_xdp_is_enabled(struct stmmac_priv * priv)3705fabb012SOng Boon Leong static inline bool stmmac_xdp_is_enabled(struct stmmac_priv *priv)
3715fabb012SOng Boon Leong {
3725fabb012SOng Boon Leong 	return !!priv->xdp_prog;
3735fabb012SOng Boon Leong }
3745fabb012SOng Boon Leong 
stmmac_rx_offset(struct stmmac_priv * priv)3755fabb012SOng Boon Leong static inline unsigned int stmmac_rx_offset(struct stmmac_priv *priv)
3765fabb012SOng Boon Leong {
3775fabb012SOng Boon Leong 	if (stmmac_xdp_is_enabled(priv))
37812d125b4SMarc Zyngier 		return XDP_PACKET_HEADROOM;
3795fabb012SOng Boon Leong 
38012d125b4SMarc Zyngier 	return 0;
3815fabb012SOng Boon Leong }
3825fabb012SOng Boon Leong 
383bba2556eSOng Boon Leong void stmmac_disable_rx_queue(struct stmmac_priv *priv, u32 queue);
384bba2556eSOng Boon Leong void stmmac_enable_rx_queue(struct stmmac_priv *priv, u32 queue);
385132c32eeSOng Boon Leong void stmmac_disable_tx_queue(struct stmmac_priv *priv, u32 queue);
386132c32eeSOng Boon Leong void stmmac_enable_tx_queue(struct stmmac_priv *priv, u32 queue);
387bba2556eSOng Boon Leong int stmmac_xsk_wakeup(struct net_device *dev, u32 queue, u32 flags);
38881c52c42SXiaoliang Yang struct timespec64 stmmac_calc_tas_basetime(ktime_t old_base_time,
38981c52c42SXiaoliang Yang 					   ktime_t current_time,
39081c52c42SXiaoliang Yang 					   u64 cycle_time);
391bba2556eSOng Boon Leong 
392091810dbSJose Abreu #if IS_ENABLED(CONFIG_STMMAC_SELFTESTS)
393091810dbSJose Abreu void stmmac_selftest_run(struct net_device *dev,
394091810dbSJose Abreu 			 struct ethtool_test *etest, u64 *buf);
395091810dbSJose Abreu void stmmac_selftest_get_strings(struct stmmac_priv *priv, u8 *data);
396091810dbSJose Abreu int stmmac_selftest_get_count(struct stmmac_priv *priv);
397091810dbSJose Abreu #else
stmmac_selftest_run(struct net_device * dev,struct ethtool_test * etest,u64 * buf)398091810dbSJose Abreu static inline void stmmac_selftest_run(struct net_device *dev,
399091810dbSJose Abreu 				       struct ethtool_test *etest, u64 *buf)
400091810dbSJose Abreu {
401091810dbSJose Abreu 	/* Not enabled */
402091810dbSJose Abreu }
stmmac_selftest_get_strings(struct stmmac_priv * priv,u8 * data)403091810dbSJose Abreu static inline void stmmac_selftest_get_strings(struct stmmac_priv *priv,
404091810dbSJose Abreu 					       u8 *data)
405091810dbSJose Abreu {
406091810dbSJose Abreu 	/* Not enabled */
407091810dbSJose Abreu }
stmmac_selftest_get_count(struct stmmac_priv * priv)408091810dbSJose Abreu static inline int stmmac_selftest_get_count(struct stmmac_priv *priv)
409091810dbSJose Abreu {
410091810dbSJose Abreu 	return -EOPNOTSUPP;
411091810dbSJose Abreu }
412091810dbSJose Abreu #endif /* CONFIG_STMMAC_SELFTESTS */
413091810dbSJose Abreu 
414bd4242dfSRayagond Kokatanur #endif /* __STMMAC_H__ */
415