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/if_vlan.h>
17 #include <linux/stmmac.h>
18 #include <linux/phylink.h>
19 #include <linux/pci.h>
21 #include <linux/ptp_clock_kernel.h>
22 #include <linux/net_tstamp.h>
23 #include <linux/reset.h>
24 #include <net/page_pool.h>
26 struct stmmac_resources {
34 struct stmmac_tx_info {
42 /* Frequently used values are kept adjacent for cache effect */
43 struct stmmac_tx_queue {
45 struct timer_list txtimer;
47 struct stmmac_priv *priv_data;
48 struct dma_extended_desc *dma_etx ____cacheline_aligned_in_smp;
49 struct dma_desc *dma_tx;
50 struct sk_buff **tx_skbuff;
51 struct stmmac_tx_info *tx_skbuff_dma;
53 unsigned int dirty_tx;
54 dma_addr_t dma_tx_phy;
59 struct stmmac_rx_buffer {
61 struct page *sec_page;
66 struct stmmac_rx_queue {
69 struct page_pool *page_pool;
70 struct stmmac_rx_buffer *buf_pool;
71 struct stmmac_priv *priv_data;
72 struct dma_extended_desc *dma_erx;
73 struct dma_desc *dma_rx ____cacheline_aligned_in_smp;
75 unsigned int dirty_rx;
77 dma_addr_t dma_rx_phy;
79 unsigned int state_saved;
87 struct stmmac_channel {
88 struct napi_struct rx_napi ____cacheline_aligned_in_smp;
89 struct napi_struct tx_napi ____cacheline_aligned_in_smp;
90 struct stmmac_priv *priv_data;
94 struct stmmac_tc_entry {
100 unsigned int table_pos;
118 #define STMMAC_PPS_MAX 4
119 struct stmmac_pps_cfg {
121 struct timespec64 start;
122 struct timespec64 period;
127 u8 key[STMMAC_RSS_HASH_KEY_SIZE];
128 u32 table[STMMAC_RSS_MAX_TABLE_SIZE];
131 #define STMMAC_FLOW_ACTION_DROP BIT(0)
132 struct stmmac_flow_entry {
133 unsigned long cookie;
134 unsigned long action;
142 /* Frequently used values are kept adjacent for cache effect */
149 bool tx_path_in_lpi_mode;
154 unsigned int dma_buf_sz;
155 unsigned int rx_copybreak;
159 void __iomem *ioaddr;
160 struct net_device *dev;
161 struct device *device;
162 struct mac_device_info *hw;
163 int (*hwif_quirks)(struct stmmac_priv *priv);
167 struct stmmac_rx_queue rx_queue[MTL_MAX_RX_QUEUES];
170 struct stmmac_tx_queue tx_queue[MTL_MAX_TX_QUEUES];
172 /* Generic channel for NAPI */
173 struct stmmac_channel channel[STMMAC_CH_MAX];
176 unsigned int flow_ctrl;
179 int mii_irq[PHY_MAX_ADDR];
181 struct phylink_config phylink_config;
182 struct phylink *phylink;
184 struct stmmac_extra_stats xstats ____cacheline_aligned_in_smp;
185 struct stmmac_safety_stats sstats;
186 struct plat_stmmacenet_data *plat;
187 struct dma_features dma_cap;
188 struct stmmac_counters mmc;
195 struct timer_list eee_ctrl_timer;
201 unsigned int chain_mode;
203 struct hwtstamp_config tstamp_config;
204 struct ptp_clock *ptp_clock;
205 struct ptp_clock_info ptp_clock_ops;
206 unsigned int default_addend;
213 void __iomem *mmcaddr;
214 void __iomem *ptpaddr;
215 unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
217 #ifdef CONFIG_DEBUG_FS
218 struct dentry *dbgfs_dir;
222 struct workqueue_struct *wq;
223 struct work_struct service_task;
226 unsigned int tc_entries_max;
227 unsigned int tc_off_max;
228 struct stmmac_tc_entry *tc_entries;
229 unsigned int flow_entries_max;
230 struct stmmac_flow_entry *flow_entries;
232 /* Pulse Per Second output */
233 struct stmmac_pps_cfg pps[STMMAC_PPS_MAX];
235 /* Receive Side Scaling */
236 struct stmmac_rss rss;
241 STMMAC_RESET_REQUESTED,
243 STMMAC_SERVICE_SCHED,
246 int stmmac_mdio_unregister(struct net_device *ndev);
247 int stmmac_mdio_register(struct net_device *ndev);
248 int stmmac_mdio_reset(struct mii_bus *mii);
249 void stmmac_set_ethtool_ops(struct net_device *netdev);
251 void stmmac_ptp_register(struct stmmac_priv *priv);
252 void stmmac_ptp_unregister(struct stmmac_priv *priv);
253 int stmmac_resume(struct device *dev);
254 int stmmac_suspend(struct device *dev);
255 int stmmac_dvr_remove(struct device *dev);
256 int stmmac_dvr_probe(struct device *device,
257 struct plat_stmmacenet_data *plat_dat,
258 struct stmmac_resources *res);
259 void stmmac_disable_eee_mode(struct stmmac_priv *priv);
260 bool stmmac_eee_init(struct stmmac_priv *priv);
262 #if IS_ENABLED(CONFIG_STMMAC_SELFTESTS)
263 void stmmac_selftest_run(struct net_device *dev,
264 struct ethtool_test *etest, u64 *buf);
265 void stmmac_selftest_get_strings(struct stmmac_priv *priv, u8 *data);
266 int stmmac_selftest_get_count(struct stmmac_priv *priv);
268 static inline void stmmac_selftest_run(struct net_device *dev,
269 struct ethtool_test *etest, u64 *buf)
273 static inline void stmmac_selftest_get_strings(struct stmmac_priv *priv,
278 static inline int stmmac_selftest_get_count(struct stmmac_priv *priv)
282 #endif /* CONFIG_STMMAC_SELFTESTS */
284 #endif /* __STMMAC_H__ */