1
2
3
4
5
6
7
8 #ifndef __FSL_DPSW_H
9 #define __FSL_DPSW_H
10
11
12
13
14
15 struct fsl_mc_io;
16
17
18
19
20
21
22
23
24 #define DPSW_MAX_PRIORITIES 8
25
26
27
28 #define DPSW_MAX_IF 64
29
30 int dpsw_open(struct fsl_mc_io *mc_io,
31 u32 cmd_flags,
32 int dpsw_id,
33 u16 *token);
34
35 int dpsw_close(struct fsl_mc_io *mc_io,
36 u32 cmd_flags,
37 u16 token);
38
39
40
41
42
43
44
45
46 #define DPSW_OPT_FLOODING_DIS 0x0000000000000001ULL
47
48
49
50 #define DPSW_OPT_MULTICAST_DIS 0x0000000000000004ULL
51
52
53
54 #define DPSW_OPT_CTRL_IF_DIS 0x0000000000000010ULL
55
56
57
58 #define DPSW_OPT_FLOODING_METERING_DIS 0x0000000000000020ULL
59
60
61
62 #define DPSW_OPT_METERING_EN 0x0000000000000040ULL
63
64
65
66
67
68
69
70
71
72
73 enum dpsw_component_type {
74 DPSW_COMPONENT_TYPE_C_VLAN = 0,
75 DPSW_COMPONENT_TYPE_S_VLAN
76 };
77
78 int dpsw_enable(struct fsl_mc_io *mc_io,
79 u32 cmd_flags,
80 u16 token);
81
82 int dpsw_disable(struct fsl_mc_io *mc_io,
83 u32 cmd_flags,
84 u16 token);
85
86 int dpsw_reset(struct fsl_mc_io *mc_io,
87 u32 cmd_flags,
88 u16 token);
89
90
91
92
93
94 #define DPSW_IRQ_INDEX_IF 0x0000
95 #define DPSW_IRQ_INDEX_L2SW 0x0001
96
97
98
99
100 #define DPSW_IRQ_EVENT_LINK_CHANGED 0x0001
101
102
103
104
105
106
107
108 struct dpsw_irq_cfg {
109 u64 addr;
110 u32 val;
111 int irq_num;
112 };
113
114 int dpsw_set_irq_enable(struct fsl_mc_io *mc_io,
115 u32 cmd_flags,
116 u16 token,
117 u8 irq_index,
118 u8 en);
119
120 int dpsw_set_irq_mask(struct fsl_mc_io *mc_io,
121 u32 cmd_flags,
122 u16 token,
123 u8 irq_index,
124 u32 mask);
125
126 int dpsw_get_irq_status(struct fsl_mc_io *mc_io,
127 u32 cmd_flags,
128 u16 token,
129 u8 irq_index,
130 u32 *status);
131
132 int dpsw_clear_irq_status(struct fsl_mc_io *mc_io,
133 u32 cmd_flags,
134 u16 token,
135 u8 irq_index,
136 u32 status);
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157 struct dpsw_attr {
158 int id;
159 u64 options;
160 u16 max_vlans;
161 u8 max_meters_per_if;
162 u8 max_fdbs;
163 u16 max_fdb_entries;
164 u16 fdb_aging_time;
165 u16 max_fdb_mc_groups;
166 u16 num_ifs;
167 u16 mem_size;
168 u16 num_vlans;
169 u8 num_fdbs;
170 enum dpsw_component_type component_type;
171 };
172
173 int dpsw_get_attributes(struct fsl_mc_io *mc_io,
174 u32 cmd_flags,
175 u16 token,
176 struct dpsw_attr *attr);
177
178
179
180
181
182
183 enum dpsw_action {
184 DPSW_ACTION_DROP = 0,
185 DPSW_ACTION_REDIRECT = 1
186 };
187
188
189
190
191 #define DPSW_LINK_OPT_AUTONEG 0x0000000000000001ULL
192
193
194
195 #define DPSW_LINK_OPT_HALF_DUPLEX 0x0000000000000002ULL
196
197
198
199 #define DPSW_LINK_OPT_PAUSE 0x0000000000000004ULL
200
201
202
203 #define DPSW_LINK_OPT_ASYM_PAUSE 0x0000000000000008ULL
204
205
206
207
208
209
210 struct dpsw_link_cfg {
211 u32 rate;
212 u64 options;
213 };
214
215 int dpsw_if_set_link_cfg(struct fsl_mc_io *mc_io,
216 u32 cmd_flags,
217 u16 token,
218 u16 if_id,
219 struct dpsw_link_cfg *cfg);
220
221
222
223
224
225
226 struct dpsw_link_state {
227 u32 rate;
228 u64 options;
229 u8 up;
230 };
231
232 int dpsw_if_get_link_state(struct fsl_mc_io *mc_io,
233 u32 cmd_flags,
234 u16 token,
235 u16 if_id,
236 struct dpsw_link_state *state);
237
238 int dpsw_if_set_flooding(struct fsl_mc_io *mc_io,
239 u32 cmd_flags,
240 u16 token,
241 u16 if_id,
242 u8 en);
243
244 int dpsw_if_set_broadcast(struct fsl_mc_io *mc_io,
245 u32 cmd_flags,
246 u16 token,
247 u16 if_id,
248 u8 en);
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263 struct dpsw_tci_cfg {
264 u8 pcp;
265 u8 dei;
266 u16 vlan_id;
267 };
268
269 int dpsw_if_set_tci(struct fsl_mc_io *mc_io,
270 u32 cmd_flags,
271 u16 token,
272 u16 if_id,
273 const struct dpsw_tci_cfg *cfg);
274
275 int dpsw_if_get_tci(struct fsl_mc_io *mc_io,
276 u32 cmd_flags,
277 u16 token,
278 u16 if_id,
279 struct dpsw_tci_cfg *cfg);
280
281
282
283
284
285
286
287
288
289 enum dpsw_stp_state {
290 DPSW_STP_STATE_DISABLED = 0,
291 DPSW_STP_STATE_LISTENING = 1,
292 DPSW_STP_STATE_LEARNING = 2,
293 DPSW_STP_STATE_FORWARDING = 3,
294 DPSW_STP_STATE_BLOCKING = 0
295 };
296
297
298
299
300
301
302 struct dpsw_stp_cfg {
303 u16 vlan_id;
304 enum dpsw_stp_state state;
305 };
306
307 int dpsw_if_set_stp(struct fsl_mc_io *mc_io,
308 u32 cmd_flags,
309 u16 token,
310 u16 if_id,
311 const struct dpsw_stp_cfg *cfg);
312
313
314
315
316
317
318
319
320
321 enum dpsw_accepted_frames {
322 DPSW_ADMIT_ALL = 1,
323 DPSW_ADMIT_ONLY_VLAN_TAGGED = 3
324 };
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341 enum dpsw_counter {
342 DPSW_CNT_ING_FRAME = 0x0,
343 DPSW_CNT_ING_BYTE = 0x1,
344 DPSW_CNT_ING_FLTR_FRAME = 0x2,
345 DPSW_CNT_ING_FRAME_DISCARD = 0x3,
346 DPSW_CNT_ING_MCAST_FRAME = 0x4,
347 DPSW_CNT_ING_MCAST_BYTE = 0x5,
348 DPSW_CNT_ING_BCAST_FRAME = 0x6,
349 DPSW_CNT_ING_BCAST_BYTES = 0x7,
350 DPSW_CNT_EGR_FRAME = 0x8,
351 DPSW_CNT_EGR_BYTE = 0x9,
352 DPSW_CNT_EGR_FRAME_DISCARD = 0xa,
353 DPSW_CNT_EGR_STP_FRAME_DISCARD = 0xb
354 };
355
356 int dpsw_if_get_counter(struct fsl_mc_io *mc_io,
357 u32 cmd_flags,
358 u16 token,
359 u16 if_id,
360 enum dpsw_counter type,
361 u64 *counter);
362
363 int dpsw_if_enable(struct fsl_mc_io *mc_io,
364 u32 cmd_flags,
365 u16 token,
366 u16 if_id);
367
368 int dpsw_if_disable(struct fsl_mc_io *mc_io,
369 u32 cmd_flags,
370 u16 token,
371 u16 if_id);
372
373 int dpsw_if_set_max_frame_length(struct fsl_mc_io *mc_io,
374 u32 cmd_flags,
375 u16 token,
376 u16 if_id,
377 u16 frame_length);
378
379
380
381
382
383 struct dpsw_vlan_cfg {
384 u16 fdb_id;
385 };
386
387 int dpsw_vlan_add(struct fsl_mc_io *mc_io,
388 u32 cmd_flags,
389 u16 token,
390 u16 vlan_id,
391 const struct dpsw_vlan_cfg *cfg);
392
393
394
395
396
397
398
399
400 struct dpsw_vlan_if_cfg {
401 u16 num_ifs;
402 u16 if_id[DPSW_MAX_IF];
403 };
404
405 int dpsw_vlan_add_if(struct fsl_mc_io *mc_io,
406 u32 cmd_flags,
407 u16 token,
408 u16 vlan_id,
409 const struct dpsw_vlan_if_cfg *cfg);
410
411 int dpsw_vlan_add_if_untagged(struct fsl_mc_io *mc_io,
412 u32 cmd_flags,
413 u16 token,
414 u16 vlan_id,
415 const struct dpsw_vlan_if_cfg *cfg);
416
417 int dpsw_vlan_remove_if(struct fsl_mc_io *mc_io,
418 u32 cmd_flags,
419 u16 token,
420 u16 vlan_id,
421 const struct dpsw_vlan_if_cfg *cfg);
422
423 int dpsw_vlan_remove_if_untagged(struct fsl_mc_io *mc_io,
424 u32 cmd_flags,
425 u16 token,
426 u16 vlan_id,
427 const struct dpsw_vlan_if_cfg *cfg);
428
429 int dpsw_vlan_remove(struct fsl_mc_io *mc_io,
430 u32 cmd_flags,
431 u16 token,
432 u16 vlan_id);
433
434
435
436
437
438
439 enum dpsw_fdb_entry_type {
440 DPSW_FDB_ENTRY_STATIC = 0,
441 DPSW_FDB_ENTRY_DINAMIC = 1
442 };
443
444
445
446
447
448
449
450 struct dpsw_fdb_unicast_cfg {
451 enum dpsw_fdb_entry_type type;
452 u8 mac_addr[6];
453 u16 if_egress;
454 };
455
456 int dpsw_fdb_add_unicast(struct fsl_mc_io *mc_io,
457 u32 cmd_flags,
458 u16 token,
459 u16 fdb_id,
460 const struct dpsw_fdb_unicast_cfg *cfg);
461
462 int dpsw_fdb_remove_unicast(struct fsl_mc_io *mc_io,
463 u32 cmd_flags,
464 u16 token,
465 u16 fdb_id,
466 const struct dpsw_fdb_unicast_cfg *cfg);
467
468 #define DPSW_FDB_ENTRY_TYPE_DYNAMIC BIT(0)
469 #define DPSW_FDB_ENTRY_TYPE_UNICAST BIT(1)
470
471
472
473
474
475
476
477
478 struct fdb_dump_entry {
479 u8 mac_addr[6];
480 u8 type;
481 u8 if_info;
482 u8 if_mask[8];
483 };
484
485 int dpsw_fdb_dump(struct fsl_mc_io *mc_io,
486 u32 cmd_flags,
487 u16 token,
488 u16 fdb_id,
489 u64 iova_addr,
490 u32 iova_size,
491 u16 *num_entries);
492
493
494
495
496
497
498
499
500 struct dpsw_fdb_multicast_cfg {
501 enum dpsw_fdb_entry_type type;
502 u8 mac_addr[6];
503 u16 num_ifs;
504 u16 if_id[DPSW_MAX_IF];
505 };
506
507 int dpsw_fdb_add_multicast(struct fsl_mc_io *mc_io,
508 u32 cmd_flags,
509 u16 token,
510 u16 fdb_id,
511 const struct dpsw_fdb_multicast_cfg *cfg);
512
513 int dpsw_fdb_remove_multicast(struct fsl_mc_io *mc_io,
514 u32 cmd_flags,
515 u16 token,
516 u16 fdb_id,
517 const struct dpsw_fdb_multicast_cfg *cfg);
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549 enum dpsw_fdb_learning_mode {
550 DPSW_FDB_LEARNING_MODE_DIS = 0,
551 DPSW_FDB_LEARNING_MODE_HW = 1,
552 DPSW_FDB_LEARNING_MODE_NON_SECURE = 2,
553 DPSW_FDB_LEARNING_MODE_SECURE = 3
554 };
555
556 int dpsw_fdb_set_learning_mode(struct fsl_mc_io *mc_io,
557 u32 cmd_flags,
558 u16 token,
559 u16 fdb_id,
560 enum dpsw_fdb_learning_mode mode);
561
562
563
564
565
566
567
568
569
570 struct dpsw_fdb_attr {
571 u16 max_fdb_entries;
572 u16 fdb_aging_time;
573 enum dpsw_fdb_learning_mode learning_mode;
574 u16 num_fdb_mc_groups;
575 u16 max_fdb_mc_groups;
576 };
577
578 int dpsw_get_api_version(struct fsl_mc_io *mc_io,
579 u32 cmd_flags,
580 u16 *major_ver,
581 u16 *minor_ver);
582
583 #endif