]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - drivers/net/ethernet/stmicro/stmmac/stmmac.h
Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[mirror_ubuntu-jammy-kernel.git] / drivers / net / ethernet / stmicro / stmmac / stmmac.h
CommitLineData
4fa9c49f 1/* SPDX-License-Identifier: GPL-2.0-only */
47dd7a54
GC
2/*******************************************************************************
3 Copyright (C) 2007-2009 STMicroelectronics Ltd
4
47dd7a54
GC
5
6 Author: Giuseppe Cavallaro <peppe.cavallaro@st.com>
7*******************************************************************************/
8
bd4242df
RK
9#ifndef __STMMAC_H__
10#define __STMMAC_H__
11
bfab27a1 12#define STMMAC_RESOURCE_NAME "stmmaceth"
06bce7dd 13#define DRV_MODULE_VERSION "Jan_2016"
ba1377ff
GC
14
15#include <linux/clk.h>
ee7946a7 16#include <linux/stmmac.h>
286a8372 17#include <linux/phy.h>
33d5e332 18#include <linux/pci.h>
47dd7a54 19#include "common.h"
92ba6888 20#include <linux/ptp_clock_kernel.h>
d6228b7c 21#include <linux/net_tstamp.h>
c5e4ddbd 22#include <linux/reset.h>
47dd7a54 23
e56788cf
JE
24struct stmmac_resources {
25 void __iomem *addr;
26 const char *mac;
27 int wol_irq;
28 int lpi_irq;
29 int irq;
30};
31
362b37be
GC
32struct stmmac_tx_info {
33 dma_addr_t buf;
34 bool map_as_page;
553e2ab3 35 unsigned len;
2a6d8e17 36 bool last_segment;
96951366 37 bool is_jumbo;
362b37be
GC
38};
39
ce736788
JP
40/* Frequently used values are kept adjacent for cache effect */
41struct stmmac_tx_queue {
8fce3331
JA
42 u32 tx_count_frames;
43 struct timer_list txtimer;
ce736788
JP
44 u32 queue_index;
45 struct stmmac_priv *priv_data;
46 struct dma_extended_desc *dma_etx ____cacheline_aligned_in_smp;
47 struct dma_desc *dma_tx;
48 struct sk_buff **tx_skbuff;
49 struct stmmac_tx_info *tx_skbuff_dma;
50 unsigned int cur_tx;
51 unsigned int dirty_tx;
52 dma_addr_t dma_tx_phy;
53 u32 tx_tail_addr;
8d212a9e 54 u32 mss;
ce736788
JP
55};
56
54139cf3
JP
57struct stmmac_rx_queue {
58 u32 queue_index;
59 struct stmmac_priv *priv_data;
60 struct dma_extended_desc *dma_erx;
61 struct dma_desc *dma_rx ____cacheline_aligned_in_smp;
62 struct sk_buff **rx_skbuff;
63 dma_addr_t *rx_skbuff_dma;
64 unsigned int cur_rx;
65 unsigned int dirty_rx;
66 u32 rx_zeroc_thresh;
67 dma_addr_t dma_rx_phy;
68 u32 rx_tail_addr;
8fce3331
JA
69};
70
71struct stmmac_channel {
4ccb4585
JA
72 struct napi_struct rx_napi ____cacheline_aligned_in_smp;
73 struct napi_struct tx_napi ____cacheline_aligned_in_smp;
8fce3331
JA
74 struct stmmac_priv *priv_data;
75 u32 index;
54139cf3
JP
76};
77
4dbbe8dd
JA
78struct stmmac_tc_entry {
79 bool in_use;
80 bool in_hw;
81 bool is_last;
82 bool is_frag;
83 void *frag_ptr;
84 unsigned int table_pos;
85 u32 handle;
86 u32 prio;
87 struct {
88 u32 match_data;
89 u32 match_en;
90 u8 af:1;
91 u8 rf:1;
92 u8 im:1;
93 u8 nc:1;
94 u8 res1:4;
95 u8 frame_offset;
96 u8 ok_index;
97 u8 dma_ch_no;
98 u32 res2;
99 } __packed val;
100};
101
9a8a02c9
JA
102#define STMMAC_PPS_MAX 4
103struct stmmac_pps_cfg {
104 bool available;
105 struct timespec64 start;
106 struct timespec64 period;
107};
108
47dd7a54
GC
109struct stmmac_priv {
110 /* Frequently used values are kept adjacent for cache effect */
1bb6dea8
GC
111 u32 tx_coal_frames;
112 u32 tx_coal_timer;
ce736788 113
47dd7a54 114 int tx_coalesce;
1bb6dea8 115 int hwts_tx_en;
1bb6dea8 116 bool tx_path_in_lpi_mode;
f748be53 117 bool tso;
47dd7a54 118
1bb6dea8 119 unsigned int dma_buf_sz;
22ad3838 120 unsigned int rx_copybreak;
1bb6dea8
GC
121 u32 rx_riwt;
122 int hwts_rx_en;
5bacd778 123
1bb6dea8 124 void __iomem *ioaddr;
47dd7a54 125 struct net_device *dev;
47dd7a54 126 struct device *device;
db98a0b0 127 struct mac_device_info *hw;
7cfde0af 128 int (*hwif_quirks)(struct stmmac_priv *priv);
29555fa3 129 struct mutex lock;
47dd7a54 130
54139cf3
JP
131 /* RX Queue */
132 struct stmmac_rx_queue rx_queue[MTL_MAX_RX_QUEUES];
133
ce736788
JP
134 /* TX Queue */
135 struct stmmac_tx_queue tx_queue[MTL_MAX_TX_QUEUES];
136
8fce3331
JA
137 /* Generic channel for NAPI */
138 struct stmmac_channel channel[STMMAC_CH_MAX];
139
4d869b03 140 bool oldlink;
47dd7a54
GC
141 int speed;
142 int oldduplex;
143 unsigned int flow_ctrl;
144 unsigned int pause;
145 struct mii_bus *mii;
36bcfe7d 146 int mii_irq[PHY_MAX_ADDR];
47dd7a54 147
1bb6dea8 148 struct stmmac_extra_stats xstats ____cacheline_aligned_in_smp;
8bf993a5 149 struct stmmac_safety_stats sstats;
9dfeb4d9 150 struct plat_stmmacenet_data *plat;
e7434821 151 struct dma_features dma_cap;
1bb6dea8 152 struct stmmac_counters mmc;
19e30c14 153 int hw_cap_support;
1bb6dea8
GC
154 int synopsys_id;
155 u32 msg_enable;
156 int wolopts;
157 int wol_irq;
cd7201f4 158 int clk_csr;
d765955d 159 struct timer_list eee_ctrl_timer;
d765955d
GC
160 int lpi_irq;
161 int eee_enabled;
162 int eee_active;
163 int tx_lpi_timer;
4a7d666a 164 unsigned int mode;
5f0456b4 165 unsigned int chain_mode;
c24602ef 166 int extend_desc;
d6228b7c 167 struct hwtstamp_config tstamp_config;
92ba6888
RK
168 struct ptp_clock *ptp_clock;
169 struct ptp_clock_info ptp_clock_ops;
1bb6dea8 170 unsigned int default_addend;
9a8a02c9
JA
171 u32 sub_second_inc;
172 u32 systime_flags;
1bb6dea8
GC
173 u32 adv_ts;
174 int use_riwt;
89f7f2cf 175 int irq_wake;
92ba6888 176 spinlock_t ptp_lock;
36ff7c1e 177 void __iomem *mmcaddr;
ba1ffd74 178 void __iomem *ptpaddr;
466c5ac8
MO
179
180#ifdef CONFIG_DEBUG_FS
181 struct dentry *dbgfs_dir;
182 struct dentry *dbgfs_rings_status;
183 struct dentry *dbgfs_dma_cap;
184#endif
34877a15
JA
185
186 unsigned long state;
187 struct workqueue_struct *wq;
188 struct work_struct service_task;
4dbbe8dd
JA
189
190 /* TC Handling */
191 unsigned int tc_entries_max;
192 unsigned int tc_off_max;
193 struct stmmac_tc_entry *tc_entries;
9a8a02c9
JA
194
195 /* Pulse Per Second output */
196 struct stmmac_pps_cfg pps[STMMAC_PPS_MAX];
34877a15
JA
197};
198
199enum stmmac_state {
200 STMMAC_DOWN,
201 STMMAC_RESET_REQUESTED,
202 STMMAC_RESETING,
203 STMMAC_SERVICE_SCHED,
47dd7a54
GC
204};
205
d6cc64ef
JP
206int stmmac_mdio_unregister(struct net_device *ndev);
207int stmmac_mdio_register(struct net_device *ndev);
073752aa 208int stmmac_mdio_reset(struct mii_bus *mii);
d6cc64ef 209void stmmac_set_ethtool_ops(struct net_device *netdev);
915af656 210
c30a70d3 211void stmmac_ptp_register(struct stmmac_priv *priv);
d6cc64ef 212void stmmac_ptp_unregister(struct stmmac_priv *priv);
f4e7bd81
JE
213int stmmac_resume(struct device *dev);
214int stmmac_suspend(struct device *dev);
215int stmmac_dvr_remove(struct device *dev);
15ffac73
JE
216int stmmac_dvr_probe(struct device *device,
217 struct plat_stmmacenet_data *plat_dat,
218 struct stmmac_resources *res);
d765955d
GC
219void stmmac_disable_eee_mode(struct stmmac_priv *priv);
220bool stmmac_eee_init(struct stmmac_priv *priv);
ba1377ff 221
bd4242df 222#endif /* __STMMAC_H__ */