1
2
3
4
5
6
7
8#ifndef __FSL_DPSW_H
9#define __FSL_DPSW_H
10
11
12
13
14
15struct fsl_mc_io;
16
17
18
19#define DPSW_MAX_PRIORITIES 8
20
21#define DPSW_MAX_IF 64
22
23int dpsw_open(struct fsl_mc_io *mc_io, u32 cmd_flags, int dpsw_id, u16 *token);
24
25int dpsw_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
26
27
28
29
30
31
32#define DPSW_OPT_FLOODING_DIS 0x0000000000000001ULL
33
34
35
36#define DPSW_OPT_MULTICAST_DIS 0x0000000000000004ULL
37
38
39
40#define DPSW_OPT_CTRL_IF_DIS 0x0000000000000010ULL
41
42
43
44
45
46
47
48
49
50
51enum dpsw_component_type {
52 DPSW_COMPONENT_TYPE_C_VLAN = 0,
53 DPSW_COMPONENT_TYPE_S_VLAN
54};
55
56
57
58
59
60
61
62
63
64
65
66
67enum dpsw_flooding_cfg {
68 DPSW_FLOODING_PER_VLAN = 0,
69 DPSW_FLOODING_PER_FDB,
70};
71
72
73
74
75
76
77
78
79
80enum dpsw_broadcast_cfg {
81 DPSW_BROADCAST_PER_OBJECT = 0,
82 DPSW_BROADCAST_PER_FDB,
83};
84
85int dpsw_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
86
87int dpsw_disable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
88
89int dpsw_reset(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
90
91
92
93#define DPSW_IRQ_INDEX_IF 0x0000
94#define DPSW_IRQ_INDEX_L2SW 0x0001
95
96
97
98
99#define DPSW_IRQ_EVENT_LINK_CHANGED 0x0001
100
101
102
103
104#define DPSW_IRQ_EVENT_ENDPOINT_CHANGED 0x0002
105
106
107
108
109
110
111
112struct dpsw_irq_cfg {
113 u64 addr;
114 u32 val;
115 int irq_num;
116};
117
118int dpsw_set_irq_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
119 u8 irq_index, u8 en);
120
121int dpsw_set_irq_mask(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
122 u8 irq_index, u32 mask);
123
124int dpsw_get_irq_status(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
125 u8 irq_index, u32 *status);
126
127int dpsw_clear_irq_status(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
128 u8 irq_index, u32 status);
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151struct dpsw_attr {
152 int id;
153 u64 options;
154 u16 max_vlans;
155 u8 max_meters_per_if;
156 u8 max_fdbs;
157 u16 max_fdb_entries;
158 u16 fdb_aging_time;
159 u16 max_fdb_mc_groups;
160 u16 num_ifs;
161 u16 mem_size;
162 u16 num_vlans;
163 u8 num_fdbs;
164 enum dpsw_component_type component_type;
165 enum dpsw_flooding_cfg flooding_cfg;
166 enum dpsw_broadcast_cfg broadcast_cfg;
167};
168
169int dpsw_get_attributes(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
170 struct dpsw_attr *attr);
171
172
173
174
175
176
177
178struct dpsw_ctrl_if_attr {
179 u32 rx_fqid;
180 u32 rx_err_fqid;
181 u32 tx_err_conf_fqid;
182};
183
184int dpsw_ctrl_if_get_attributes(struct fsl_mc_io *mc_io, u32 cmd_flags,
185 u16 token, struct dpsw_ctrl_if_attr *attr);
186
187enum dpsw_queue_type {
188 DPSW_QUEUE_RX,
189 DPSW_QUEUE_TX_ERR_CONF,
190 DPSW_QUEUE_RX_ERR,
191};
192
193#define DPSW_MAX_DPBP 8
194
195
196
197
198
199
200
201
202
203
204struct dpsw_ctrl_if_pools_cfg {
205 u8 num_dpbp;
206 struct {
207 int dpbp_id;
208 u16 buffer_size;
209 int backup_pool;
210 } pools[DPSW_MAX_DPBP];
211};
212
213int dpsw_ctrl_if_set_pools(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
214 const struct dpsw_ctrl_if_pools_cfg *cfg);
215
216#define DPSW_CTRL_IF_QUEUE_OPT_USER_CTX 0x00000001
217#define DPSW_CTRL_IF_QUEUE_OPT_DEST 0x00000002
218
219enum dpsw_ctrl_if_dest {
220 DPSW_CTRL_IF_DEST_NONE = 0,
221 DPSW_CTRL_IF_DEST_DPIO = 1,
222};
223
224struct dpsw_ctrl_if_dest_cfg {
225 enum dpsw_ctrl_if_dest dest_type;
226 int dest_id;
227 u8 priority;
228};
229
230struct dpsw_ctrl_if_queue_cfg {
231 u32 options;
232 u64 user_ctx;
233 struct dpsw_ctrl_if_dest_cfg dest_cfg;
234};
235
236int dpsw_ctrl_if_set_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
237 enum dpsw_queue_type qtype,
238 const struct dpsw_ctrl_if_queue_cfg *cfg);
239
240int dpsw_ctrl_if_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
241
242int dpsw_ctrl_if_disable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
243
244
245
246
247
248
249enum dpsw_action {
250 DPSW_ACTION_DROP = 0,
251 DPSW_ACTION_REDIRECT = 1
252};
253
254#define DPSW_LINK_OPT_AUTONEG 0x0000000000000001ULL
255#define DPSW_LINK_OPT_HALF_DUPLEX 0x0000000000000002ULL
256#define DPSW_LINK_OPT_PAUSE 0x0000000000000004ULL
257#define DPSW_LINK_OPT_ASYM_PAUSE 0x0000000000000008ULL
258
259
260
261
262
263
264struct dpsw_link_cfg {
265 u32 rate;
266 u64 options;
267};
268
269int dpsw_if_set_link_cfg(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u16 if_id,
270 struct dpsw_link_cfg *cfg);
271
272
273
274
275
276
277
278struct dpsw_link_state {
279 u32 rate;
280 u64 options;
281 u8 up;
282};
283
284int dpsw_if_get_link_state(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
285 u16 if_id, struct dpsw_link_state *state);
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300struct dpsw_tci_cfg {
301 u8 pcp;
302 u8 dei;
303 u16 vlan_id;
304};
305
306int dpsw_if_set_tci(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u16 if_id,
307 const struct dpsw_tci_cfg *cfg);
308
309int dpsw_if_get_tci(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u16 if_id,
310 struct dpsw_tci_cfg *cfg);
311
312
313
314
315
316
317
318
319
320
321enum dpsw_stp_state {
322 DPSW_STP_STATE_DISABLED = 0,
323 DPSW_STP_STATE_LISTENING = 1,
324 DPSW_STP_STATE_LEARNING = 2,
325 DPSW_STP_STATE_FORWARDING = 3,
326 DPSW_STP_STATE_BLOCKING = 0
327};
328
329
330
331
332
333
334struct dpsw_stp_cfg {
335 u16 vlan_id;
336 enum dpsw_stp_state state;
337};
338
339int dpsw_if_set_stp(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u16 if_id,
340 const struct dpsw_stp_cfg *cfg);
341
342
343
344
345
346
347
348
349
350enum dpsw_accepted_frames {
351 DPSW_ADMIT_ALL = 1,
352 DPSW_ADMIT_ONLY_VLAN_TAGGED = 3
353};
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371enum dpsw_counter {
372 DPSW_CNT_ING_FRAME = 0x0,
373 DPSW_CNT_ING_BYTE = 0x1,
374 DPSW_CNT_ING_FLTR_FRAME = 0x2,
375 DPSW_CNT_ING_FRAME_DISCARD = 0x3,
376 DPSW_CNT_ING_MCAST_FRAME = 0x4,
377 DPSW_CNT_ING_MCAST_BYTE = 0x5,
378 DPSW_CNT_ING_BCAST_FRAME = 0x6,
379 DPSW_CNT_ING_BCAST_BYTES = 0x7,
380 DPSW_CNT_EGR_FRAME = 0x8,
381 DPSW_CNT_EGR_BYTE = 0x9,
382 DPSW_CNT_EGR_FRAME_DISCARD = 0xa,
383 DPSW_CNT_EGR_STP_FRAME_DISCARD = 0xb,
384 DPSW_CNT_ING_NO_BUFF_DISCARD = 0xc,
385};
386
387int dpsw_if_get_counter(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
388 u16 if_id, enum dpsw_counter type, u64 *counter);
389
390int dpsw_if_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u16 if_id);
391
392int dpsw_if_disable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u16 if_id);
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409struct dpsw_if_attr {
410 u8 num_tcs;
411 u32 rate;
412 u32 options;
413 int enabled;
414 int accept_all_vlan;
415 enum dpsw_accepted_frames admit_untagged;
416 u16 qdid;
417};
418
419int dpsw_if_get_attributes(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
420 u16 if_id, struct dpsw_if_attr *attr);
421
422int dpsw_if_set_max_frame_length(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
423 u16 if_id, u16 frame_length);
424
425
426
427
428
429struct dpsw_vlan_cfg {
430 u16 fdb_id;
431};
432
433int dpsw_vlan_add(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
434 u16 vlan_id, const struct dpsw_vlan_cfg *cfg);
435
436#define DPSW_VLAN_ADD_IF_OPT_FDB_ID 0x0001
437
438
439
440
441
442
443
444
445
446
447
448
449struct dpsw_vlan_if_cfg {
450 u16 num_ifs;
451 u16 options;
452 u16 if_id[DPSW_MAX_IF];
453 u16 fdb_id;
454};
455
456int dpsw_vlan_add_if(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
457 u16 vlan_id, const struct dpsw_vlan_if_cfg *cfg);
458
459int dpsw_vlan_add_if_untagged(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
460 u16 vlan_id, const struct dpsw_vlan_if_cfg *cfg);
461
462int dpsw_vlan_remove_if(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
463 u16 vlan_id, const struct dpsw_vlan_if_cfg *cfg);
464
465int dpsw_vlan_remove_if_untagged(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
466 u16 vlan_id, const struct dpsw_vlan_if_cfg *cfg);
467
468int dpsw_vlan_remove(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
469 u16 vlan_id);
470
471
472
473
474
475
476enum dpsw_fdb_entry_type {
477 DPSW_FDB_ENTRY_STATIC = 0,
478 DPSW_FDB_ENTRY_DINAMIC = 1
479};
480
481
482
483
484
485
486
487struct dpsw_fdb_unicast_cfg {
488 enum dpsw_fdb_entry_type type;
489 u8 mac_addr[6];
490 u16 if_egress;
491};
492
493int dpsw_fdb_add_unicast(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
494 u16 fdb_id, const struct dpsw_fdb_unicast_cfg *cfg);
495
496int dpsw_fdb_remove_unicast(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
497 u16 fdb_id, const struct dpsw_fdb_unicast_cfg *cfg);
498
499#define DPSW_FDB_ENTRY_TYPE_DYNAMIC BIT(0)
500#define DPSW_FDB_ENTRY_TYPE_UNICAST BIT(1)
501
502
503
504
505
506
507
508
509struct fdb_dump_entry {
510 u8 mac_addr[6];
511 u8 type;
512 u8 if_info;
513 u8 if_mask[8];
514};
515
516int dpsw_fdb_dump(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u16 fdb_id,
517 u64 iova_addr, u32 iova_size, u16 *num_entries);
518
519
520
521
522
523
524
525
526struct dpsw_fdb_multicast_cfg {
527 enum dpsw_fdb_entry_type type;
528 u8 mac_addr[6];
529 u16 num_ifs;
530 u16 if_id[DPSW_MAX_IF];
531};
532
533int dpsw_fdb_add_multicast(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
534 u16 fdb_id, const struct dpsw_fdb_multicast_cfg *cfg);
535
536int dpsw_fdb_remove_multicast(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
537 u16 fdb_id, const struct dpsw_fdb_multicast_cfg *cfg);
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569enum dpsw_learning_mode {
570 DPSW_LEARNING_MODE_DIS = 0,
571 DPSW_LEARNING_MODE_HW = 1,
572 DPSW_LEARNING_MODE_NON_SECURE = 2,
573 DPSW_LEARNING_MODE_SECURE = 3
574};
575
576
577
578
579
580
581
582
583
584struct dpsw_fdb_attr {
585 u16 max_fdb_entries;
586 u16 fdb_ageing_time;
587 enum dpsw_learning_mode learning_mode;
588 u16 num_fdb_mc_groups;
589 u16 max_fdb_mc_groups;
590};
591
592int dpsw_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags,
593 u16 *major_ver, u16 *minor_ver);
594
595int dpsw_if_get_port_mac_addr(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
596 u16 if_id, u8 mac_addr[6]);
597
598
599
600
601
602
603struct dpsw_fdb_cfg {
604 u16 num_fdb_entries;
605 u16 fdb_ageing_time;
606};
607
608int dpsw_fdb_add(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u16 *fdb_id,
609 const struct dpsw_fdb_cfg *cfg);
610
611int dpsw_fdb_remove(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u16 fdb_id);
612
613
614
615
616
617
618enum dpsw_flood_type {
619 DPSW_BROADCAST = 0,
620 DPSW_FLOODING,
621};
622
623struct dpsw_egress_flood_cfg {
624 u16 fdb_id;
625 enum dpsw_flood_type flood_type;
626 u16 num_ifs;
627 u16 if_id[DPSW_MAX_IF];
628};
629
630int dpsw_set_egress_flood(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
631 const struct dpsw_egress_flood_cfg *cfg);
632
633int dpsw_if_set_learning_mode(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
634 u16 if_id, enum dpsw_learning_mode mode);
635
636
637
638
639
640struct dpsw_acl_cfg {
641 u16 max_entries;
642};
643
644int dpsw_acl_add(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u16 *acl_id,
645 const struct dpsw_acl_cfg *cfg);
646
647int dpsw_acl_remove(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
648 u16 acl_id);
649
650
651
652
653
654
655struct dpsw_acl_if_cfg {
656 u16 num_ifs;
657 u16 if_id[DPSW_MAX_IF];
658};
659
660int dpsw_acl_add_if(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
661 u16 acl_id, const struct dpsw_acl_if_cfg *cfg);
662
663int dpsw_acl_remove_if(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
664 u16 acl_id, const struct dpsw_acl_if_cfg *cfg);
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687struct dpsw_acl_fields {
688 u8 l2_dest_mac[6];
689 u8 l2_source_mac[6];
690 u16 l2_tpid;
691 u8 l2_pcp_dei;
692 u16 l2_vlan_id;
693 u16 l2_ether_type;
694 u8 l3_dscp;
695 u8 l3_protocol;
696 u32 l3_source_ip;
697 u32 l3_dest_ip;
698 u16 l4_source_port;
699 u16 l4_dest_port;
700};
701
702
703
704
705
706
707struct dpsw_acl_key {
708 struct dpsw_acl_fields match;
709 struct dpsw_acl_fields mask;
710};
711
712
713
714
715
716
717
718
719enum dpsw_acl_action {
720 DPSW_ACL_ACTION_DROP,
721 DPSW_ACL_ACTION_REDIRECT,
722 DPSW_ACL_ACTION_ACCEPT,
723 DPSW_ACL_ACTION_REDIRECT_TO_CTRL_IF
724};
725
726
727
728
729
730
731
732struct dpsw_acl_result {
733 enum dpsw_acl_action action;
734 u16 if_id;
735};
736
737
738
739
740
741
742
743
744
745
746struct dpsw_acl_entry_cfg {
747 u64 key_iova;
748 struct dpsw_acl_result result;
749 int precedence;
750};
751
752void dpsw_acl_prepare_entry_cfg(const struct dpsw_acl_key *key,
753 u8 *entry_cfg_buf);
754
755int dpsw_acl_add_entry(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
756 u16 acl_id, const struct dpsw_acl_entry_cfg *cfg);
757
758int dpsw_acl_remove_entry(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
759 u16 acl_id, const struct dpsw_acl_entry_cfg *cfg);
760
761
762
763
764
765
766
767
768enum dpsw_reflection_filter {
769 DPSW_REFLECTION_FILTER_INGRESS_ALL = 0,
770 DPSW_REFLECTION_FILTER_INGRESS_VLAN = 1
771};
772
773
774
775
776
777
778struct dpsw_reflection_cfg {
779 enum dpsw_reflection_filter filter;
780 u16 vlan_id;
781};
782
783int dpsw_set_reflection_if(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
784 u16 if_id);
785
786int dpsw_if_add_reflection(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
787 u16 if_id, const struct dpsw_reflection_cfg *cfg);
788
789int dpsw_if_remove_reflection(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
790 u16 if_id, const struct dpsw_reflection_cfg *cfg);
791#endif
792