This source file includes following definitions.
- dequeue_addr_from_hash_entry
- free_hash_table
- alloc_hash_table
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 #ifndef __FM_MAC_H
35 #define __FM_MAC_H
36
37 #include "fman.h"
38
39 #include <linux/slab.h>
40 #include <linux/phy.h>
41 #include <linux/if_ether.h>
42
43 struct fman_mac;
44
45
46 typedef u8 enet_addr_t[ETH_ALEN];
47
48 #define ENET_ADDR_TO_UINT64(_enet_addr) \
49 (u64)(((u64)(_enet_addr)[0] << 40) | \
50 ((u64)(_enet_addr)[1] << 32) | \
51 ((u64)(_enet_addr)[2] << 24) | \
52 ((u64)(_enet_addr)[3] << 16) | \
53 ((u64)(_enet_addr)[4] << 8) | \
54 ((u64)(_enet_addr)[5]))
55
56 #define MAKE_ENET_ADDR_FROM_UINT64(_addr64, _enet_addr) \
57 do { \
58 int i; \
59 for (i = 0; i < ETH_ALEN; i++) \
60 (_enet_addr)[i] = \
61 (u8)((_addr64) >> ((5 - i) * 8)); \
62 } while (0)
63
64
65 #define DEFAULT_RESET_ON_INIT false
66
67
68 #define FSL_FM_PAUSE_TIME_ENABLE 0xf000
69 #define FSL_FM_PAUSE_TIME_DISABLE 0
70 #define FSL_FM_PAUSE_THRESH_DEFAULT 0
71
72 #define FM_MAC_NO_PFC 0xff
73
74
75 #define ETH_HASH_ENTRY_OBJ(ptr) \
76 hlist_entry_safe(ptr, struct eth_hash_entry, node)
77
78
79
80
81 enum comm_mode {
82 COMM_MODE_NONE = 0,
83 COMM_MODE_RX = 1,
84 COMM_MODE_TX = 2,
85 COMM_MODE_RX_AND_TX = 3
86 };
87
88
89 enum fman_mac_exceptions {
90 FM_MAC_EX_10G_MDIO_SCAN_EVENT = 0
91
92 , FM_MAC_EX_10G_MDIO_CMD_CMPL
93
94 , FM_MAC_EX_10G_REM_FAULT
95
96 , FM_MAC_EX_10G_LOC_FAULT
97
98 , FM_MAC_EX_10G_TX_ECC_ER
99
100 , FM_MAC_EX_10G_TX_FIFO_UNFL
101
102 , FM_MAC_EX_10G_TX_FIFO_OVFL
103
104 , FM_MAC_EX_10G_TX_ER
105
106 , FM_MAC_EX_10G_RX_FIFO_OVFL
107
108 , FM_MAC_EX_10G_RX_ECC_ER
109
110 , FM_MAC_EX_10G_RX_JAB_FRM
111
112 , FM_MAC_EX_10G_RX_OVRSZ_FRM
113
114 , FM_MAC_EX_10G_RX_RUNT_FRM
115
116 , FM_MAC_EX_10G_RX_FRAG_FRM
117
118 , FM_MAC_EX_10G_RX_LEN_ER
119
120 , FM_MAC_EX_10G_RX_CRC_ER
121
122 , FM_MAC_EX_10G_RX_ALIGN_ER
123
124 , FM_MAC_EX_1G_BAB_RX
125
126 , FM_MAC_EX_1G_RX_CTL
127
128 , FM_MAC_EX_1G_GRATEFUL_TX_STP_COMPLET
129
130 , FM_MAC_EX_1G_BAB_TX
131
132 , FM_MAC_EX_1G_TX_CTL
133
134 , FM_MAC_EX_1G_TX_ERR
135
136 , FM_MAC_EX_1G_LATE_COL
137
138 , FM_MAC_EX_1G_COL_RET_LMT
139
140 , FM_MAC_EX_1G_TX_FIFO_UNDRN
141
142 , FM_MAC_EX_1G_MAG_PCKT
143
144 , FM_MAC_EX_1G_MII_MNG_RD_COMPLET
145
146 , FM_MAC_EX_1G_MII_MNG_WR_COMPLET
147
148 , FM_MAC_EX_1G_GRATEFUL_RX_STP_COMPLET
149
150 , FM_MAC_EX_1G_DATA_ERR
151
152 , FM_MAC_1G_RX_DATA_ERR
153
154 , FM_MAC_EX_1G_1588_TS_RX_ERR
155
156 , FM_MAC_EX_1G_RX_MIB_CNT_OVFL
157
158 , FM_MAC_EX_TS_FIFO_ECC_ERR
159
160
161
162 , FM_MAC_EX_MAGIC_PACKET_INDICATION = FM_MAC_EX_1G_MAG_PCKT
163
164 };
165
166 struct eth_hash_entry {
167 u64 addr;
168 struct list_head node;
169 };
170
171 typedef void (fman_mac_exception_cb)(void *dev_id,
172 enum fman_mac_exceptions exceptions);
173
174
175 struct fman_mac_params {
176
177 void __iomem *base_addr;
178
179 enet_addr_t addr;
180
181
182
183
184
185 u8 mac_id;
186
187 phy_interface_t phy_if;
188
189
190
191 u16 max_speed;
192
193 void *fm;
194 void *dev_id;
195 fman_mac_exception_cb *event_cb;
196 fman_mac_exception_cb *exception_cb;
197
198
199
200
201
202 bool basex_if;
203
204 struct device_node *internal_phy_node;
205 };
206
207 struct eth_hash_t {
208 u16 size;
209 struct list_head *lsts;
210 };
211
212 static inline struct eth_hash_entry
213 *dequeue_addr_from_hash_entry(struct list_head *addr_lst)
214 {
215 struct eth_hash_entry *hash_entry = NULL;
216
217 if (!list_empty(addr_lst)) {
218 hash_entry = ETH_HASH_ENTRY_OBJ(addr_lst->next);
219 list_del_init(&hash_entry->node);
220 }
221 return hash_entry;
222 }
223
224 static inline void free_hash_table(struct eth_hash_t *hash)
225 {
226 struct eth_hash_entry *hash_entry;
227 int i = 0;
228
229 if (hash) {
230 if (hash->lsts) {
231 for (i = 0; i < hash->size; i++) {
232 hash_entry =
233 dequeue_addr_from_hash_entry(&hash->lsts[i]);
234 while (hash_entry) {
235 kfree(hash_entry);
236 hash_entry =
237 dequeue_addr_from_hash_entry(&hash->
238 lsts[i]);
239 }
240 }
241
242 kfree(hash->lsts);
243 }
244
245 kfree(hash);
246 }
247 }
248
249 static inline struct eth_hash_t *alloc_hash_table(u16 size)
250 {
251 u32 i;
252 struct eth_hash_t *hash;
253
254
255 hash = kmalloc_array(size, sizeof(struct eth_hash_t *), GFP_KERNEL);
256 if (!hash)
257 return NULL;
258
259 hash->size = size;
260
261 hash->lsts = kmalloc_array(hash->size, sizeof(struct list_head),
262 GFP_KERNEL);
263 if (!hash->lsts) {
264 kfree(hash);
265 return NULL;
266 }
267
268 for (i = 0; i < hash->size; i++)
269 INIT_LIST_HEAD(&hash->lsts[i]);
270
271 return hash;
272 }
273
274 #endif