forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/drivers/net/ethernet/stmicro/stmmac/stmmac.h
....@@ -1,17 +1,7 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*******************************************************************************
23 Copyright (C) 2007-2009 STMicroelectronics Ltd
34
4
- This program is free software; you can redistribute it and/or modify it
5
- under the terms and conditions of the GNU General Public License,
6
- version 2, as published by the Free Software Foundation.
7
-
8
- This program is distributed in the hope it will be useful, but WITHOUT
9
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11
- more details.
12
-
13
- The full GNU General Public License is included in this distribution in
14
- the file called "COPYING".
155
166 Author: Giuseppe Cavallaro <peppe.cavallaro@st.com>
177 *******************************************************************************/
....@@ -23,13 +13,15 @@
2313 #define DRV_MODULE_VERSION "Jan_2016"
2414
2515 #include <linux/clk.h>
16
+#include <linux/if_vlan.h>
2617 #include <linux/stmmac.h>
27
-#include <linux/phy.h>
18
+#include <linux/phylink.h>
2819 #include <linux/pci.h>
2920 #include "common.h"
3021 #include <linux/ptp_clock_kernel.h>
3122 #include <linux/net_tstamp.h>
3223 #include <linux/reset.h>
24
+#include <net/page_pool.h>
3325
3426 struct stmmac_resources {
3527 void __iomem *addr;
....@@ -47,13 +39,18 @@
4739 bool is_jumbo;
4840 };
4941
42
+#define STMMAC_TBS_AVAIL BIT(0)
43
+#define STMMAC_TBS_EN BIT(1)
44
+
5045 /* Frequently used values are kept adjacent for cache effect */
5146 struct stmmac_tx_queue {
5247 u32 tx_count_frames;
48
+ int tbs;
5349 struct timer_list txtimer;
5450 u32 queue_index;
5551 struct stmmac_priv *priv_data;
5652 struct dma_extended_desc *dma_etx ____cacheline_aligned_in_smp;
53
+ struct dma_edesc *dma_entx;
5754 struct dma_desc *dma_tx;
5855 struct sk_buff **tx_skbuff;
5956 struct stmmac_tx_info *tx_skbuff_dma;
....@@ -64,26 +61,40 @@
6461 u32 mss;
6562 };
6663
64
+struct stmmac_rx_buffer {
65
+ struct page *page;
66
+ struct page *sec_page;
67
+ dma_addr_t addr;
68
+ dma_addr_t sec_addr;
69
+};
70
+
6771 struct stmmac_rx_queue {
72
+ u32 rx_count_frames;
6873 u32 queue_index;
74
+ struct page_pool *page_pool;
75
+ struct stmmac_rx_buffer *buf_pool;
6976 struct stmmac_priv *priv_data;
7077 struct dma_extended_desc *dma_erx;
7178 struct dma_desc *dma_rx ____cacheline_aligned_in_smp;
72
- struct sk_buff **rx_skbuff;
73
- dma_addr_t *rx_skbuff_dma;
7479 unsigned int cur_rx;
7580 unsigned int dirty_rx;
7681 u32 rx_zeroc_thresh;
7782 dma_addr_t dma_rx_phy;
7883 u32 rx_tail_addr;
84
+ unsigned int state_saved;
85
+ struct {
86
+ struct sk_buff *skb;
87
+ unsigned int len;
88
+ unsigned int error;
89
+ } state;
7990 };
8091
8192 struct stmmac_channel {
82
- struct napi_struct napi ____cacheline_aligned_in_smp;
93
+ struct napi_struct rx_napi ____cacheline_aligned_in_smp;
94
+ struct napi_struct tx_napi ____cacheline_aligned_in_smp;
8395 struct stmmac_priv *priv_data;
96
+ spinlock_t lock;
8497 u32 index;
85
- int has_rx;
86
- int has_tx;
8798 };
8899
89100 struct stmmac_tc_entry {
....@@ -117,15 +128,34 @@
117128 struct timespec64 period;
118129 };
119130
131
+struct stmmac_rss {
132
+ int enable;
133
+ u8 key[STMMAC_RSS_HASH_KEY_SIZE];
134
+ u32 table[STMMAC_RSS_MAX_TABLE_SIZE];
135
+};
136
+
137
+#define STMMAC_FLOW_ACTION_DROP BIT(0)
138
+struct stmmac_flow_entry {
139
+ unsigned long cookie;
140
+ unsigned long action;
141
+ u8 ip_proto;
142
+ int in_use;
143
+ int idx;
144
+ int is_l4;
145
+};
146
+
120147 struct stmmac_priv {
121148 /* Frequently used values are kept adjacent for cache effect */
122149 u32 tx_coal_frames;
123150 u32 tx_coal_timer;
151
+ u32 rx_coal_frames;
124152
125153 int tx_coalesce;
126154 int hwts_tx_en;
127155 bool tx_path_in_lpi_mode;
128156 bool tso;
157
+ int sph;
158
+ u32 sarc_type;
129159
130160 unsigned int dma_buf_sz;
131161 unsigned int rx_copybreak;
....@@ -141,20 +171,23 @@
141171
142172 /* RX Queue */
143173 struct stmmac_rx_queue rx_queue[MTL_MAX_RX_QUEUES];
174
+ unsigned int dma_rx_size;
144175
145176 /* TX Queue */
146177 struct stmmac_tx_queue tx_queue[MTL_MAX_TX_QUEUES];
178
+ unsigned int dma_tx_size;
147179
148180 /* Generic channel for NAPI */
149181 struct stmmac_channel channel[STMMAC_CH_MAX];
150182
151
- bool oldlink;
152183 int speed;
153
- int oldduplex;
154184 unsigned int flow_ctrl;
155185 unsigned int pause;
156186 struct mii_bus *mii;
157187 int mii_irq[PHY_MAX_ADDR];
188
+
189
+ struct phylink_config phylink_config;
190
+ struct phylink *phylink;
158191
159192 struct stmmac_extra_stats xstats ____cacheline_aligned_in_smp;
160193 struct stmmac_safety_stats sstats;
....@@ -172,6 +205,8 @@
172205 int eee_enabled;
173206 int eee_active;
174207 int tx_lpi_timer;
208
+ int tx_lpi_enabled;
209
+ int eee_tw_timer;
175210 unsigned int mode;
176211 unsigned int chain_mode;
177212 int extend_desc;
....@@ -187,11 +222,10 @@
187222 spinlock_t ptp_lock;
188223 void __iomem *mmcaddr;
189224 void __iomem *ptpaddr;
225
+ unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
190226
191227 #ifdef CONFIG_DEBUG_FS
192228 struct dentry *dbgfs_dir;
193
- struct dentry *dbgfs_rings_status;
194
- struct dentry *dbgfs_dma_cap;
195229 #endif
196230
197231 unsigned long state;
....@@ -202,9 +236,14 @@
202236 unsigned int tc_entries_max;
203237 unsigned int tc_off_max;
204238 struct stmmac_tc_entry *tc_entries;
239
+ unsigned int flow_entries_max;
240
+ struct stmmac_flow_entry *flow_entries;
205241
206242 /* Pulse Per Second output */
207243 struct stmmac_pps_cfg pps[STMMAC_PPS_MAX];
244
+
245
+ /* Receive Side Scaling */
246
+ struct stmmac_rss rss;
208247 };
209248
210249 enum stmmac_state {
....@@ -226,18 +265,9 @@
226265 }
227266 #endif
228267
229
-#ifdef CONFIG_STMMAC_PTP
268
+int stmmac_init_tstamp_counter(struct stmmac_priv *priv, u32 systime_flags);
230269 void stmmac_ptp_register(struct stmmac_priv *priv);
231270 void stmmac_ptp_unregister(struct stmmac_priv *priv);
232
-#else
233
-static inline void stmmac_ptp_register(struct stmmac_priv *priv)
234
-{
235
-}
236
-
237
-static inline void stmmac_ptp_unregister(struct stmmac_priv *priv)
238
-{
239
-}
240
-#endif
241271 int stmmac_resume(struct device *dev);
242272 int stmmac_suspend(struct device *dev);
243273 int stmmac_dvr_remove(struct device *dev);
....@@ -246,5 +276,30 @@
246276 struct stmmac_resources *res);
247277 void stmmac_disable_eee_mode(struct stmmac_priv *priv);
248278 bool stmmac_eee_init(struct stmmac_priv *priv);
279
+int stmmac_reinit_queues(struct net_device *dev, u32 rx_cnt, u32 tx_cnt);
280
+int stmmac_reinit_ringparam(struct net_device *dev, u32 rx_size, u32 tx_size);
281
+int stmmac_bus_clks_config(struct stmmac_priv *priv, bool enabled);
282
+
283
+#if IS_ENABLED(CONFIG_STMMAC_SELFTESTS)
284
+void stmmac_selftest_run(struct net_device *dev,
285
+ struct ethtool_test *etest, u64 *buf);
286
+void stmmac_selftest_get_strings(struct stmmac_priv *priv, u8 *data);
287
+int stmmac_selftest_get_count(struct stmmac_priv *priv);
288
+#else
289
+static inline void stmmac_selftest_run(struct net_device *dev,
290
+ struct ethtool_test *etest, u64 *buf)
291
+{
292
+ /* Not enabled */
293
+}
294
+static inline void stmmac_selftest_get_strings(struct stmmac_priv *priv,
295
+ u8 *data)
296
+{
297
+ /* Not enabled */
298
+}
299
+static inline int stmmac_selftest_get_count(struct stmmac_priv *priv)
300
+{
301
+ return -EOPNOTSUPP;
302
+}
303
+#endif /* CONFIG_STMMAC_SELFTESTS */
249304
250305 #endif /* __STMMAC_H__ */