Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : *
3 : : * Copyright 2017,2020 NXP
4 : : *
5 : : */
6 : :
7 : : #include <sys/types.h>
8 : : #include <sys/ioctl.h>
9 : : #include <ifaddrs.h>
10 : : #include <fman.h>
11 : : /* This header declares things about Fman hardware itself (the format of status
12 : : * words and an inline implementation of CRC64). We include it only in order to
13 : : * instantiate the one global variable it depends on.
14 : : */
15 : : #include <fsl_fman.h>
16 : : #include <fsl_fman_crc64.h>
17 : : #include <fsl_bman.h>
18 : :
19 : : #define FMAN_SP_SG_DISABLE 0x80000000
20 : : #define FMAN_SP_EXT_BUF_MARG_START_SHIFT 16
21 : :
22 : : /* Instantiate the global variable that the inline CRC64 implementation (in
23 : : * <fsl_fman.h>) depends on.
24 : : */
25 : : DECLARE_FMAN_CRC64_TABLE();
26 : :
27 : : #define ETH_ADDR_TO_UINT64(eth_addr) \
28 : : (uint64_t)(((uint64_t)(eth_addr)[0] << 40) | \
29 : : ((uint64_t)(eth_addr)[1] << 32) | \
30 : : ((uint64_t)(eth_addr)[2] << 24) | \
31 : : ((uint64_t)(eth_addr)[3] << 16) | \
32 : : ((uint64_t)(eth_addr)[4] << 8) | \
33 : : ((uint64_t)(eth_addr)[5]))
34 : :
35 : : void
36 : 0 : fman_if_set_mcast_filter_table(struct fman_if *p)
37 : : {
38 : : struct __fman_if *__if = container_of(p, struct __fman_if, __if);
39 : : void *hashtable_ctrl;
40 : : uint32_t i;
41 : :
42 : 0 : hashtable_ctrl = &((struct memac_regs *)__if->ccsr_map)->hashtable_ctrl;
43 [ # # ]: 0 : for (i = 0; i < 64; i++)
44 [ # # ]: 0 : out_be32(hashtable_ctrl, i|HASH_CTRL_MCAST_EN);
45 : 0 : }
46 : :
47 : : void
48 : 0 : fman_if_reset_mcast_filter_table(struct fman_if *p)
49 : : {
50 : : struct __fman_if *__if = container_of(p, struct __fman_if, __if);
51 : : void *hashtable_ctrl;
52 : : uint32_t i;
53 : :
54 : 0 : hashtable_ctrl = &((struct memac_regs *)__if->ccsr_map)->hashtable_ctrl;
55 [ # # ]: 0 : for (i = 0; i < 64; i++)
56 [ # # ]: 0 : out_be32(hashtable_ctrl, i & ~HASH_CTRL_MCAST_EN);
57 : 0 : }
58 : :
59 : : static
60 : : uint32_t get_mac_hash_code(uint64_t eth_addr)
61 : : {
62 : : uint64_t mask1, mask2;
63 : : uint32_t xorVal = 0;
64 : : uint8_t i, j;
65 : :
66 [ # # ]: 0 : for (i = 0; i < 6; i++) {
67 : 0 : mask1 = eth_addr & (uint64_t)0x01;
68 : 0 : eth_addr >>= 1;
69 : :
70 [ # # ]: 0 : for (j = 0; j < 7; j++) {
71 : 0 : mask2 = eth_addr & (uint64_t)0x01;
72 : 0 : mask1 ^= mask2;
73 : 0 : eth_addr >>= 1;
74 : : }
75 : :
76 : 0 : xorVal |= (mask1 << (5 - i));
77 : : }
78 : :
79 : : return xorVal;
80 : : }
81 : :
82 : : int
83 : 0 : fman_if_add_hash_mac_addr(struct fman_if *p, uint8_t *eth)
84 : : {
85 : : uint64_t eth_addr;
86 : : void *hashtable_ctrl;
87 : : uint32_t hash;
88 : :
89 : : struct __fman_if *__if = container_of(p, struct __fman_if, __if);
90 : :
91 : 0 : eth_addr = ETH_ADDR_TO_UINT64(eth);
92 : :
93 [ # # ]: 0 : if (!(eth_addr & GROUP_ADDRESS))
94 : : return -1;
95 : :
96 : 0 : hash = get_mac_hash_code(eth_addr) & HASH_CTRL_ADDR_MASK;
97 : 0 : hash = hash | HASH_CTRL_MCAST_EN;
98 : :
99 [ # # ]: 0 : hashtable_ctrl = &((struct memac_regs *)__if->ccsr_map)->hashtable_ctrl;
100 : : out_be32(hashtable_ctrl, hash);
101 : :
102 : 0 : return 0;
103 : : }
104 : :
105 : : int
106 : 0 : fman_if_get_primary_mac_addr(struct fman_if *p, uint8_t *eth)
107 : : {
108 : : struct __fman_if *__if = container_of(p, struct __fman_if, __if);
109 : : void *mac_reg =
110 : 0 : &((struct memac_regs *)__if->ccsr_map)->mac_addr0.mac_addr_l;
111 : : u32 val = in_be32(mac_reg);
112 : :
113 : 0 : eth[0] = (val & 0x000000ff) >> 0;
114 : 0 : eth[1] = (val & 0x0000ff00) >> 8;
115 : 0 : eth[2] = (val & 0x00ff0000) >> 16;
116 : 0 : eth[3] = (val & 0xff000000) >> 24;
117 : :
118 : 0 : mac_reg = &((struct memac_regs *)__if->ccsr_map)->mac_addr0.mac_addr_u;
119 : : val = in_be32(mac_reg);
120 : :
121 : 0 : eth[4] = (val & 0x000000ff) >> 0;
122 : 0 : eth[5] = (val & 0x0000ff00) >> 8;
123 : :
124 : 0 : return 0;
125 : : }
126 : :
127 : : void
128 : 0 : fman_if_clear_mac_addr(struct fman_if *p, uint8_t addr_num)
129 : : {
130 : : struct __fman_if *m = container_of(p, struct __fman_if, __if);
131 : : void *reg;
132 : :
133 [ # # ]: 0 : if (addr_num) {
134 : 0 : reg = &((struct memac_regs *)m->ccsr_map)->
135 : 0 : mac_addr[addr_num-1].mac_addr_l;
136 : : out_be32(reg, 0x0);
137 : : reg = &((struct memac_regs *)m->ccsr_map)->
138 : : mac_addr[addr_num-1].mac_addr_u;
139 : : out_be32(reg, 0x0);
140 : : } else {
141 : 0 : reg = &((struct memac_regs *)m->ccsr_map)->mac_addr0.mac_addr_l;
142 : : out_be32(reg, 0x0);
143 : : reg = &((struct memac_regs *)m->ccsr_map)->mac_addr0.mac_addr_u;
144 : : out_be32(reg, 0x0);
145 : : }
146 : 0 : }
147 : :
148 : : int
149 : 0 : fman_if_add_mac_addr(struct fman_if *p, uint8_t *eth, uint8_t addr_num)
150 : : {
151 : : struct __fman_if *m = container_of(p, struct __fman_if, __if);
152 : :
153 : : void *reg;
154 : : u32 val;
155 : :
156 [ # # ]: 0 : memcpy(&m->__if.mac_addr, eth, ETHER_ADDR_LEN);
157 : :
158 [ # # ]: 0 : if (addr_num)
159 : 0 : reg = &((struct memac_regs *)m->ccsr_map)->
160 : 0 : mac_addr[addr_num-1].mac_addr_l;
161 : : else
162 : 0 : reg = &((struct memac_regs *)m->ccsr_map)->mac_addr0.mac_addr_l;
163 : :
164 : 0 : val = (m->__if.mac_addr.addr_bytes[0] |
165 : 0 : (m->__if.mac_addr.addr_bytes[1] << 8) |
166 : 0 : (m->__if.mac_addr.addr_bytes[2] << 16) |
167 [ # # ]: 0 : (m->__if.mac_addr.addr_bytes[3] << 24));
168 : : out_be32(reg, val);
169 : :
170 [ # # ]: 0 : if (addr_num)
171 : 0 : reg = &((struct memac_regs *)m->ccsr_map)->
172 : 0 : mac_addr[addr_num-1].mac_addr_u;
173 : : else
174 : 0 : reg = &((struct memac_regs *)m->ccsr_map)->mac_addr0.mac_addr_u;
175 : :
176 : 0 : val = ((m->__if.mac_addr.addr_bytes[4] << 0) |
177 [ # # ]: 0 : (m->__if.mac_addr.addr_bytes[5] << 8));
178 : : out_be32(reg, val);
179 : :
180 : 0 : return 0;
181 : : }
182 : :
183 : : void
184 : 0 : fman_if_set_rx_ignore_pause_frames(struct fman_if *p, bool enable)
185 : : {
186 : : struct __fman_if *__if = container_of(p, struct __fman_if, __if);
187 : : u32 value = 0;
188 : : void *cmdcfg;
189 : :
190 [ # # ]: 0 : assert(fman_ccsr_map_fd != -1);
191 : :
192 : : /* Set Rx Ignore Pause Frames */
193 : 0 : cmdcfg = &((struct memac_regs *)__if->ccsr_map)->command_config;
194 [ # # ]: 0 : if (enable)
195 : 0 : value = in_be32(cmdcfg) | CMD_CFG_PAUSE_IGNORE;
196 : : else
197 : 0 : value = in_be32(cmdcfg) & ~CMD_CFG_PAUSE_IGNORE;
198 : :
199 : : out_be32(cmdcfg, value);
200 : 0 : }
201 : :
202 : : void
203 : 0 : fman_if_conf_max_frame_len(struct fman_if *p, unsigned int max_frame_len)
204 : : {
205 : : struct __fman_if *__if = container_of(p, struct __fman_if, __if);
206 : : unsigned int *maxfrm;
207 : :
208 [ # # ]: 0 : assert(fman_ccsr_map_fd != -1);
209 : :
210 : : /* Set Max frame length */
211 : 0 : maxfrm = &((struct memac_regs *)__if->ccsr_map)->maxfrm;
212 [ # # ]: 0 : out_be32(maxfrm, (MAXFRM_RX_MASK & max_frame_len));
213 : 0 : }
214 : :
215 : : void
216 : 0 : fman_if_stats_get(struct fman_if *p, struct rte_eth_stats *stats)
217 : : {
218 : : struct __fman_if *m = container_of(p, struct __fman_if, __if);
219 : 0 : struct memac_regs *regs = m->ccsr_map;
220 : :
221 : : /* read recved packet count */
222 : 0 : stats->ipackets = (u64)in_be32(®s->rfrm_l) |
223 : 0 : ((u64)in_be32(®s->rfrm_u)) << 32;
224 : 0 : stats->ibytes = (u64)in_be32(®s->roct_l) |
225 : 0 : ((u64)in_be32(®s->roct_u)) << 32;
226 : 0 : stats->ierrors = (u64)in_be32(®s->rerr_l) |
227 : 0 : ((u64)in_be32(®s->rerr_u)) << 32;
228 : :
229 : : /* read xmited packet count */
230 : 0 : stats->opackets = (u64)in_be32(®s->tfrm_l) |
231 : 0 : ((u64)in_be32(®s->tfrm_u)) << 32;
232 : 0 : stats->obytes = (u64)in_be32(®s->toct_l) |
233 : 0 : ((u64)in_be32(®s->toct_u)) << 32;
234 : 0 : stats->oerrors = (u64)in_be32(®s->terr_l) |
235 : 0 : ((u64)in_be32(®s->terr_u)) << 32;
236 : 0 : }
237 : :
238 : : void
239 : 0 : fman_if_stats_get_all(struct fman_if *p, uint64_t *value, int n)
240 : : {
241 : : struct __fman_if *m = container_of(p, struct __fman_if, __if);
242 : 0 : struct memac_regs *regs = m->ccsr_map;
243 : : int i;
244 : : uint64_t base_offset = offsetof(struct memac_regs, reoct_l);
245 : :
246 [ # # ]: 0 : for (i = 0; i < n; i++)
247 : 0 : value[i] = (((u64)in_be32((char *)regs + base_offset + 8 * i) |
248 : 0 : (u64)in_be32((char *)regs + base_offset +
249 : 0 : 8 * i + 4)) << 32);
250 : 0 : }
251 : :
252 : : void
253 : 0 : fman_if_stats_reset(struct fman_if *p)
254 : : {
255 : : struct __fman_if *m = container_of(p, struct __fman_if, __if);
256 : 0 : struct memac_regs *regs = m->ccsr_map;
257 : : uint32_t tmp;
258 : :
259 : : tmp = in_be32(®s->statn_config);
260 : :
261 [ # # ]: 0 : tmp |= STATS_CFG_CLR;
262 : :
263 : : out_be32(®s->statn_config, tmp);
264 : :
265 [ # # ]: 0 : while (in_be32(®s->statn_config) & STATS_CFG_CLR)
266 : : ;
267 : 0 : }
268 : :
269 : : void
270 : 0 : fman_if_promiscuous_enable(struct fman_if *p)
271 : : {
272 : : struct __fman_if *__if = container_of(p, struct __fman_if, __if);
273 : : void *cmdcfg;
274 : :
275 [ # # ]: 0 : assert(fman_ccsr_map_fd != -1);
276 : :
277 : : /* Enable Rx promiscuous mode */
278 : 0 : cmdcfg = &((struct memac_regs *)__if->ccsr_map)->command_config;
279 [ # # ]: 0 : out_be32(cmdcfg, in_be32(cmdcfg) | CMD_CFG_PROMIS_EN);
280 : 0 : }
281 : :
282 : : void
283 : 0 : fman_if_promiscuous_disable(struct fman_if *p)
284 : : {
285 : : struct __fman_if *__if = container_of(p, struct __fman_if, __if);
286 : : void *cmdcfg;
287 : :
288 [ # # ]: 0 : assert(fman_ccsr_map_fd != -1);
289 : :
290 : : /* Disable Rx promiscuous mode */
291 : 0 : cmdcfg = &((struct memac_regs *)__if->ccsr_map)->command_config;
292 [ # # ]: 0 : out_be32(cmdcfg, in_be32(cmdcfg) & (~CMD_CFG_PROMIS_EN));
293 : 0 : }
294 : :
295 : : void
296 : 0 : fman_if_enable_rx(struct fman_if *p)
297 : : {
298 : : struct __fman_if *__if = container_of(p, struct __fman_if, __if);
299 : :
300 [ # # ]: 0 : assert(fman_ccsr_map_fd != -1);
301 : :
302 : : /* enable Rx and Tx */
303 [ # # ]: 0 : out_be32(__if->ccsr_map + 8, in_be32(__if->ccsr_map + 8) | 3);
304 : 0 : }
305 : :
306 : : void
307 : 0 : fman_if_disable_rx(struct fman_if *p)
308 : : {
309 : : struct __fman_if *__if = container_of(p, struct __fman_if, __if);
310 : :
311 [ # # ]: 0 : assert(fman_ccsr_map_fd != -1);
312 : :
313 : : /* only disable Rx, not Tx */
314 [ # # ]: 0 : out_be32(__if->ccsr_map + 8, in_be32(__if->ccsr_map + 8) & ~(u32)2);
315 : 0 : }
316 : :
317 : : int
318 : 0 : fman_if_get_rx_status(struct fman_if *p)
319 : : {
320 : : struct __fman_if *__if = container_of(p, struct __fman_if, __if);
321 : :
322 [ # # ]: 0 : assert(fman_ccsr_map_fd != -1);
323 : :
324 : : /* return true if RX bit is set */
325 : 0 : return !!(in_be32(__if->ccsr_map + 8) & (u32)2);
326 : : }
327 : :
328 : : void
329 : 0 : fman_if_loopback_enable(struct fman_if *p)
330 : : {
331 : : struct __fman_if *__if = container_of(p, struct __fman_if, __if);
332 : :
333 [ # # ]: 0 : assert(fman_ccsr_map_fd != -1);
334 : :
335 : : /* Enable loopback mode */
336 [ # # # # ]: 0 : if ((__if->__if.is_memac) && (__if->__if.is_rgmii)) {
337 : : unsigned int *ifmode =
338 : 0 : &((struct memac_regs *)__if->ccsr_map)->if_mode;
339 [ # # ]: 0 : out_be32(ifmode, in_be32(ifmode) | IF_MODE_RLP);
340 : : } else{
341 : : unsigned int *cmdcfg =
342 : 0 : &((struct memac_regs *)__if->ccsr_map)->command_config;
343 [ # # ]: 0 : out_be32(cmdcfg, in_be32(cmdcfg) | CMD_CFG_LOOPBACK_EN);
344 : : }
345 : 0 : }
346 : :
347 : : void
348 : 0 : fman_if_loopback_disable(struct fman_if *p)
349 : : {
350 : : struct __fman_if *__if = container_of(p, struct __fman_if, __if);
351 : :
352 [ # # ]: 0 : assert(fman_ccsr_map_fd != -1);
353 : : /* Disable loopback mode */
354 [ # # # # ]: 0 : if ((__if->__if.is_memac) && (__if->__if.is_rgmii)) {
355 : : unsigned int *ifmode =
356 : 0 : &((struct memac_regs *)__if->ccsr_map)->if_mode;
357 [ # # ]: 0 : out_be32(ifmode, in_be32(ifmode) & ~IF_MODE_RLP);
358 : : } else {
359 : : unsigned int *cmdcfg =
360 : 0 : &((struct memac_regs *)__if->ccsr_map)->command_config;
361 [ # # ]: 0 : out_be32(cmdcfg, in_be32(cmdcfg) & ~CMD_CFG_LOOPBACK_EN);
362 : : }
363 : 0 : }
364 : :
365 : : void
366 : 0 : fman_if_set_bp(struct fman_if *fm_if, unsigned num __always_unused,
367 : : int bpid, size_t bufsize)
368 : : {
369 : : u32 fmbm_ebmpi;
370 : : u32 ebmpi_val_ace = 0xc0000000;
371 : : u32 ebmpi_mask = 0xffc00000;
372 : :
373 : : struct __fman_if *__if = container_of(fm_if, struct __fman_if, __if);
374 : :
375 [ # # ]: 0 : assert(fman_ccsr_map_fd != -1);
376 : :
377 : : fmbm_ebmpi =
378 : 0 : in_be32(&((struct rx_bmi_regs *)__if->bmi_map)->fmbm_ebmpi[0]);
379 [ # # ]: 0 : fmbm_ebmpi = ebmpi_val_ace | (fmbm_ebmpi & ebmpi_mask) | (bpid << 16) |
380 : : (bufsize);
381 : :
382 : : out_be32(&((struct rx_bmi_regs *)__if->bmi_map)->fmbm_ebmpi[0],
383 : : fmbm_ebmpi);
384 : 0 : }
385 : :
386 : : int
387 : 0 : fman_if_get_fc_threshold(struct fman_if *fm_if)
388 : : {
389 : : struct __fman_if *__if = container_of(fm_if, struct __fman_if, __if);
390 : : unsigned int *fmbm_mpd;
391 : :
392 [ # # ]: 0 : assert(fman_ccsr_map_fd != -1);
393 : :
394 : 0 : fmbm_mpd = &((struct rx_bmi_regs *)__if->bmi_map)->fmbm_mpd;
395 : 0 : return in_be32(fmbm_mpd);
396 : : }
397 : :
398 : : int
399 : 0 : fman_if_set_fc_threshold(struct fman_if *fm_if, u32 high_water,
400 : : u32 low_water, u32 bpid)
401 : : {
402 : : struct __fman_if *__if = container_of(fm_if, struct __fman_if, __if);
403 : : unsigned int *fmbm_mpd;
404 : :
405 [ # # ]: 0 : assert(fman_ccsr_map_fd != -1);
406 : :
407 : 0 : fmbm_mpd = &((struct rx_bmi_regs *)__if->bmi_map)->fmbm_mpd;
408 : : out_be32(fmbm_mpd, FMAN_ENABLE_BPOOL_DEPLETION);
409 : 0 : return bm_pool_set_hw_threshold(bpid, low_water, high_water);
410 : :
411 : : }
412 : :
413 : : int
414 : 0 : fman_if_get_fc_quanta(struct fman_if *fm_if)
415 : : {
416 : : struct __fman_if *__if = container_of(fm_if, struct __fman_if, __if);
417 : :
418 [ # # ]: 0 : assert(fman_ccsr_map_fd != -1);
419 : :
420 : 0 : return in_be32(&((struct memac_regs *)__if->ccsr_map)->pause_quanta[0]);
421 : : }
422 : :
423 : : int
424 : 0 : fman_if_set_fc_quanta(struct fman_if *fm_if, u16 pause_quanta)
425 : : {
426 : : struct __fman_if *__if = container_of(fm_if, struct __fman_if, __if);
427 : :
428 [ # # ]: 0 : assert(fman_ccsr_map_fd != -1);
429 : :
430 [ # # ]: 0 : out_be32(&((struct memac_regs *)__if->ccsr_map)->pause_quanta[0],
431 : : pause_quanta);
432 : 0 : return 0;
433 : : }
434 : :
435 : : int
436 : 0 : fman_if_get_fdoff(struct fman_if *fm_if)
437 : : {
438 : : u32 fmbm_rebm;
439 : : int fdoff;
440 : :
441 : : struct __fman_if *__if = container_of(fm_if, struct __fman_if, __if);
442 : :
443 [ # # ]: 0 : assert(fman_ccsr_map_fd != -1);
444 : :
445 : 0 : fmbm_rebm = in_be32(&((struct rx_bmi_regs *)__if->bmi_map)->fmbm_rebm);
446 : :
447 : 0 : fdoff = (fmbm_rebm >> FMAN_SP_EXT_BUF_MARG_START_SHIFT) & 0x1ff;
448 : :
449 : 0 : return fdoff;
450 : : }
451 : :
452 : : void
453 : 0 : fman_if_set_err_fqid(struct fman_if *fm_if, uint32_t err_fqid)
454 : : {
455 : : struct __fman_if *__if = container_of(fm_if, struct __fman_if, __if);
456 : :
457 [ # # ]: 0 : assert(fman_ccsr_map_fd != -1);
458 : :
459 : : unsigned int *fmbm_refqid =
460 [ # # ]: 0 : &((struct rx_bmi_regs *)__if->bmi_map)->fmbm_refqid;
461 : : out_be32(fmbm_refqid, err_fqid);
462 : 0 : }
463 : :
464 : : int
465 : 0 : fman_if_get_ic_params(struct fman_if *fm_if, struct fman_if_ic_params *icp)
466 : : {
467 : : struct __fman_if *__if = container_of(fm_if, struct __fman_if, __if);
468 : : int val = 0;
469 : : int iceof_mask = 0x001f0000;
470 : : int icsz_mask = 0x0000001f;
471 : : int iciof_mask = 0x00000f00;
472 : :
473 [ # # ]: 0 : assert(fman_ccsr_map_fd != -1);
474 : :
475 : : unsigned int *fmbm_ricp =
476 : 0 : &((struct rx_bmi_regs *)__if->bmi_map)->fmbm_ricp;
477 : 0 : val = in_be32(fmbm_ricp);
478 : :
479 : 0 : icp->iceof = (val & iceof_mask) >> 12;
480 : 0 : icp->iciof = (val & iciof_mask) >> 4;
481 : 0 : icp->icsz = (val & icsz_mask) << 4;
482 : :
483 : 0 : return 0;
484 : : }
485 : :
486 : : int
487 : 0 : fman_if_set_ic_params(struct fman_if *fm_if,
488 : : const struct fman_if_ic_params *icp)
489 : : {
490 : : struct __fman_if *__if = container_of(fm_if, struct __fman_if, __if);
491 : : int val = 0;
492 : : int iceof_mask = 0x001f0000;
493 : : int icsz_mask = 0x0000001f;
494 : : int iciof_mask = 0x00000f00;
495 : :
496 [ # # ]: 0 : assert(fman_ccsr_map_fd != -1);
497 : :
498 : 0 : val |= (icp->iceof << 12) & iceof_mask;
499 : 0 : val |= (icp->iciof << 4) & iciof_mask;
500 : 0 : val |= (icp->icsz >> 4) & icsz_mask;
501 : :
502 : : unsigned int *fmbm_ricp =
503 : 0 : &((struct rx_bmi_regs *)__if->bmi_map)->fmbm_ricp;
504 [ # # ]: 0 : out_be32(fmbm_ricp, val);
505 : :
506 : 0 : return 0;
507 : : }
508 : :
509 : : void
510 : 0 : fman_if_set_fdoff(struct fman_if *fm_if, uint32_t fd_offset)
511 : : {
512 : : struct __fman_if *__if = container_of(fm_if, struct __fman_if, __if);
513 : : unsigned int *fmbm_rebm;
514 : : int val = 0;
515 : : int fmbm_mask = 0x01ff0000;
516 : :
517 : 0 : val = fd_offset << FMAN_SP_EXT_BUF_MARG_START_SHIFT;
518 : :
519 [ # # ]: 0 : assert(fman_ccsr_map_fd != -1);
520 : :
521 : 0 : fmbm_rebm = &((struct rx_bmi_regs *)__if->bmi_map)->fmbm_rebm;
522 : :
523 [ # # ]: 0 : out_be32(fmbm_rebm, (in_be32(fmbm_rebm) & ~fmbm_mask) | val);
524 : 0 : }
525 : :
526 : : void
527 : 0 : fman_if_set_maxfrm(struct fman_if *fm_if, uint16_t max_frm)
528 : : {
529 : : struct __fman_if *__if = container_of(fm_if, struct __fman_if, __if);
530 : : unsigned int *reg_maxfrm;
531 : :
532 [ # # ]: 0 : assert(fman_ccsr_map_fd != -1);
533 : :
534 : 0 : reg_maxfrm = &((struct memac_regs *)__if->ccsr_map)->maxfrm;
535 : :
536 [ # # ]: 0 : out_be32(reg_maxfrm, (in_be32(reg_maxfrm) & 0xFFFF0000) | max_frm);
537 : 0 : }
538 : :
539 : : uint16_t
540 : 0 : fman_if_get_maxfrm(struct fman_if *fm_if)
541 : : {
542 : : struct __fman_if *__if = container_of(fm_if, struct __fman_if, __if);
543 : : unsigned int *reg_maxfrm;
544 : :
545 [ # # ]: 0 : assert(fman_ccsr_map_fd != -1);
546 : :
547 : 0 : reg_maxfrm = &((struct memac_regs *)__if->ccsr_map)->maxfrm;
548 : :
549 : 0 : return (in_be32(reg_maxfrm) | 0x0000FFFF);
550 : : }
551 : :
552 : : /* MSB in fmbm_rebm register
553 : : * 0 - If BMI cannot store the frame in a single buffer it may select a buffer
554 : : * of smaller size and store the frame in scatter gather (S/G) buffers
555 : : * 1 - Scatter gather format is not enabled for frame storage. If BMI cannot
556 : : * store the frame in a single buffer, the frame is discarded.
557 : : */
558 : :
559 : : int
560 : 0 : fman_if_get_sg_enable(struct fman_if *fm_if)
561 : : {
562 : : u32 fmbm_rebm;
563 : :
564 : : struct __fman_if *__if = container_of(fm_if, struct __fman_if, __if);
565 : :
566 [ # # ]: 0 : assert(fman_ccsr_map_fd != -1);
567 : :
568 : 0 : fmbm_rebm = in_be32(&((struct rx_bmi_regs *)__if->bmi_map)->fmbm_rebm);
569 : :
570 : 0 : return (fmbm_rebm & FMAN_SP_SG_DISABLE) ? 0 : 1;
571 : : }
572 : :
573 : : void
574 : 0 : fman_if_set_sg(struct fman_if *fm_if, int enable)
575 : : {
576 : : struct __fman_if *__if = container_of(fm_if, struct __fman_if, __if);
577 : : unsigned int *fmbm_rebm;
578 : : int val;
579 : : int fmbm_mask = FMAN_SP_SG_DISABLE;
580 : :
581 [ # # ]: 0 : if (enable)
582 : : val = 0;
583 : : else
584 : : val = FMAN_SP_SG_DISABLE;
585 : :
586 [ # # ]: 0 : assert(fman_ccsr_map_fd != -1);
587 : :
588 : 0 : fmbm_rebm = &((struct rx_bmi_regs *)__if->bmi_map)->fmbm_rebm;
589 : :
590 [ # # ]: 0 : out_be32(fmbm_rebm, (in_be32(fmbm_rebm) & ~fmbm_mask) | val);
591 : 0 : }
592 : :
593 : : void
594 : 0 : fman_if_set_dnia(struct fman_if *fm_if, uint32_t nia)
595 : : {
596 : : struct __fman_if *__if = container_of(fm_if, struct __fman_if, __if);
597 : : unsigned int *fmqm_pndn;
598 : :
599 [ # # ]: 0 : assert(fman_ccsr_map_fd != -1);
600 : :
601 [ # # ]: 0 : fmqm_pndn = &((struct fman_port_qmi_regs *)__if->qmi_map)->fmqm_pndn;
602 : :
603 : : out_be32(fmqm_pndn, nia);
604 : 0 : }
605 : :
606 : : void
607 : 0 : fman_if_discard_rx_errors(struct fman_if *fm_if)
608 : : {
609 : : struct __fman_if *__if = container_of(fm_if, struct __fman_if, __if);
610 : : unsigned int *fmbm_rfsdm, *fmbm_rfsem;
611 : :
612 : 0 : fmbm_rfsem = &((struct rx_bmi_regs *)__if->bmi_map)->fmbm_rfsem;
613 : : out_be32(fmbm_rfsem, 0);
614 : :
615 : : /* Configure the discard mask to discard the error packets which have
616 : : * DMA errors, Frame size error, Header error etc. The mask 0x010EE3F0
617 : : * is to configured discard all the errors which come in the FD[STATUS]
618 : : */
619 : : fmbm_rfsdm = &((struct rx_bmi_regs *)__if->bmi_map)->fmbm_rfsdm;
620 : : out_be32(fmbm_rfsdm, 0x010EE3F0);
621 : 0 : }
622 : :
623 : : void
624 : 0 : fman_if_receive_rx_errors(struct fman_if *fm_if,
625 : : unsigned int err_eq)
626 : : {
627 : : struct __fman_if *__if = container_of(fm_if, struct __fman_if, __if);
628 : : unsigned int *fmbm_rcfg, *fmbm_rfsdm, *fmbm_rfsem;
629 : : unsigned int val;
630 : :
631 : 0 : fmbm_rcfg = &((struct rx_bmi_regs *)__if->bmi_map)->fmbm_rcfg;
632 : : fmbm_rfsdm = &((struct rx_bmi_regs *)__if->bmi_map)->fmbm_rfsdm;
633 : : fmbm_rfsem = &((struct rx_bmi_regs *)__if->bmi_map)->fmbm_rfsem;
634 : :
635 : : val = in_be32(fmbm_rcfg);
636 [ # # ]: 0 : out_be32(fmbm_rcfg, val | BMI_PORT_CFG_FDOVR);
637 : :
638 : : out_be32(fmbm_rfsdm, 0);
639 : : out_be32(fmbm_rfsem, err_eq);
640 : 0 : }
|