1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*******************************************************************************
3 Copyright (C) 2007-2009 STMicroelectronics Ltd
6 Author: Giuseppe Cavallaro <peppe.cavallaro@st.com>
7 *******************************************************************************/
12 #define STMMAC_RESOURCE_NAME "stmmaceth"
13 #define DRV_MODULE_VERSION "Jan_2016"
15 #include <linux/clk.h>
16 #include <linux/hrtimer.h>
17 #include <linux/if_vlan.h>
18 #include <linux/stmmac.h>
19 #include <linux/phylink.h>
20 #include <linux/pci.h>
22 #include <linux/ptp_clock_kernel.h>
23 #include <linux/net_tstamp.h>
24 #include <linux/reset.h>
25 #include <net/page_pool.h>
27 struct stmmac_resources
{
35 struct stmmac_tx_info
{
43 #define STMMAC_TBS_AVAIL BIT(0)
44 #define STMMAC_TBS_EN BIT(1)
46 /* Frequently used values are kept adjacent for cache effect */
47 struct stmmac_tx_queue
{
50 struct hrtimer txtimer
;
52 struct stmmac_priv
*priv_data
;
53 struct dma_extended_desc
*dma_etx ____cacheline_aligned_in_smp
;
54 struct dma_edesc
*dma_entx
;
55 struct dma_desc
*dma_tx
;
56 struct sk_buff
**tx_skbuff
;
57 struct stmmac_tx_info
*tx_skbuff_dma
;
59 unsigned int dirty_tx
;
60 dma_addr_t dma_tx_phy
;
65 struct stmmac_rx_buffer
{
67 struct page
*sec_page
;
72 struct stmmac_rx_queue
{
75 struct page_pool
*page_pool
;
76 struct stmmac_rx_buffer
*buf_pool
;
77 struct stmmac_priv
*priv_data
;
78 struct dma_extended_desc
*dma_erx
;
79 struct dma_desc
*dma_rx ____cacheline_aligned_in_smp
;
81 unsigned int dirty_rx
;
83 dma_addr_t dma_rx_phy
;
85 unsigned int state_saved
;
93 struct stmmac_channel
{
94 struct napi_struct rx_napi ____cacheline_aligned_in_smp
;
95 struct napi_struct tx_napi ____cacheline_aligned_in_smp
;
96 struct stmmac_priv
*priv_data
;
101 struct stmmac_tc_entry
{
107 unsigned int table_pos
;
125 #define STMMAC_PPS_MAX 4
126 struct stmmac_pps_cfg
{
128 struct timespec64 start
;
129 struct timespec64 period
;
134 u8 key
[STMMAC_RSS_HASH_KEY_SIZE
];
135 u32 table
[STMMAC_RSS_MAX_TABLE_SIZE
];
138 #define STMMAC_FLOW_ACTION_DROP BIT(0)
139 struct stmmac_flow_entry
{
140 unsigned long cookie
;
141 unsigned long action
;
149 /* Frequently used values are kept adjacent for cache effect */
156 bool tx_path_in_lpi_mode
;
161 unsigned int dma_buf_sz
;
162 unsigned int rx_copybreak
;
166 void __iomem
*ioaddr
;
167 struct net_device
*dev
;
168 struct device
*device
;
169 struct mac_device_info
*hw
;
170 int (*hwif_quirks
)(struct stmmac_priv
*priv
);
174 struct stmmac_rx_queue rx_queue
[MTL_MAX_RX_QUEUES
];
175 unsigned int dma_rx_size
;
178 struct stmmac_tx_queue tx_queue
[MTL_MAX_TX_QUEUES
];
179 unsigned int dma_tx_size
;
181 /* Generic channel for NAPI */
182 struct stmmac_channel channel
[STMMAC_CH_MAX
];
185 unsigned int flow_ctrl
;
188 int mii_irq
[PHY_MAX_ADDR
];
190 struct phylink_config phylink_config
;
191 struct phylink
*phylink
;
193 struct stmmac_extra_stats xstats ____cacheline_aligned_in_smp
;
194 struct stmmac_safety_stats sstats
;
195 struct plat_stmmacenet_data
*plat
;
196 struct dma_features dma_cap
;
197 struct stmmac_counters mmc
;
204 struct timer_list eee_ctrl_timer
;
211 bool eee_sw_timer_en
;
213 unsigned int chain_mode
;
215 struct hwtstamp_config tstamp_config
;
216 struct ptp_clock
*ptp_clock
;
217 struct ptp_clock_info ptp_clock_ops
;
218 unsigned int default_addend
;
225 void __iomem
*mmcaddr
;
226 void __iomem
*ptpaddr
;
227 unsigned long active_vlans
[BITS_TO_LONGS(VLAN_N_VID
)];
229 #ifdef CONFIG_DEBUG_FS
230 struct dentry
*dbgfs_dir
;
234 struct workqueue_struct
*wq
;
235 struct work_struct service_task
;
238 unsigned int tc_entries_max
;
239 unsigned int tc_off_max
;
240 struct stmmac_tc_entry
*tc_entries
;
241 unsigned int flow_entries_max
;
242 struct stmmac_flow_entry
*flow_entries
;
244 /* Pulse Per Second output */
245 struct stmmac_pps_cfg pps
[STMMAC_PPS_MAX
];
247 /* Receive Side Scaling */
248 struct stmmac_rss rss
;
253 STMMAC_RESET_REQUESTED
,
255 STMMAC_SERVICE_SCHED
,
258 int stmmac_mdio_unregister(struct net_device
*ndev
);
259 int stmmac_mdio_register(struct net_device
*ndev
);
260 int stmmac_mdio_reset(struct mii_bus
*mii
);
261 void stmmac_set_ethtool_ops(struct net_device
*netdev
);
263 void stmmac_ptp_register(struct stmmac_priv
*priv
);
264 void stmmac_ptp_unregister(struct stmmac_priv
*priv
);
265 int stmmac_resume(struct device
*dev
);
266 int stmmac_suspend(struct device
*dev
);
267 int stmmac_dvr_remove(struct device
*dev
);
268 int stmmac_dvr_probe(struct device
*device
,
269 struct plat_stmmacenet_data
*plat_dat
,
270 struct stmmac_resources
*res
);
271 void stmmac_disable_eee_mode(struct stmmac_priv
*priv
);
272 bool stmmac_eee_init(struct stmmac_priv
*priv
);
273 int stmmac_reinit_queues(struct net_device
*dev
, u32 rx_cnt
, u32 tx_cnt
);
274 int stmmac_reinit_ringparam(struct net_device
*dev
, u32 rx_size
, u32 tx_size
);
276 #if IS_ENABLED(CONFIG_STMMAC_SELFTESTS)
277 void stmmac_selftest_run(struct net_device
*dev
,
278 struct ethtool_test
*etest
, u64
*buf
);
279 void stmmac_selftest_get_strings(struct stmmac_priv
*priv
, u8
*data
);
280 int stmmac_selftest_get_count(struct stmmac_priv
*priv
);
282 static inline void stmmac_selftest_run(struct net_device
*dev
,
283 struct ethtool_test
*etest
, u64
*buf
)
287 static inline void stmmac_selftest_get_strings(struct stmmac_priv
*priv
,
292 static inline int stmmac_selftest_get_count(struct stmmac_priv
*priv
)
296 #endif /* CONFIG_STMMAC_SELFTESTS */
298 #endif /* __STMMAC_H__ */