staging: dpaa2-switch: properly setup switching domains
[linux-2.6-microblaze.git] / drivers / staging / fsl-dpaa2 / ethsw / dpsw.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright 2014-2016 Freescale Semiconductor Inc.
4  * Copyright 2017-2021 NXP
5  *
6  */
7
8 #ifndef __FSL_DPSW_H
9 #define __FSL_DPSW_H
10
11 /* Data Path L2-Switch API
12  * Contains API for handling DPSW topology and functionality
13  */
14
15 struct fsl_mc_io;
16
17 /**
18  * DPSW general definitions
19  */
20
21 /**
22  * Maximum number of traffic class priorities
23  */
24 #define DPSW_MAX_PRIORITIES     8
25 /**
26  * Maximum number of interfaces
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  * DPSW options
41  */
42
43 /**
44  * Disable flooding
45  */
46 #define DPSW_OPT_FLOODING_DIS           0x0000000000000001ULL
47 /**
48  * Disable Multicast
49  */
50 #define DPSW_OPT_MULTICAST_DIS          0x0000000000000004ULL
51 /**
52  * Support control interface
53  */
54 #define DPSW_OPT_CTRL_IF_DIS            0x0000000000000010ULL
55 /**
56  * Disable flooding metering
57  */
58 #define DPSW_OPT_FLOODING_METERING_DIS  0x0000000000000020ULL
59 /**
60  * Enable metering
61  */
62 #define DPSW_OPT_METERING_EN            0x0000000000000040ULL
63
64 /**
65  * enum dpsw_component_type - component type of a bridge
66  * @DPSW_COMPONENT_TYPE_C_VLAN: A C-VLAN component of an
67  *   enterprise VLAN bridge or of a Provider Bridge used
68  *   to process C-tagged frames
69  * @DPSW_COMPONENT_TYPE_S_VLAN: An S-VLAN component of a
70  *   Provider Bridge
71  *
72  */
73 enum dpsw_component_type {
74         DPSW_COMPONENT_TYPE_C_VLAN = 0,
75         DPSW_COMPONENT_TYPE_S_VLAN
76 };
77
78 /**
79  *  enum dpsw_flooding_cfg - flooding configuration requested
80  * @DPSW_FLOODING_PER_VLAN: Flooding replicators are allocated per VLAN and
81  * interfaces present in each of them can be configured using
82  * dpsw_vlan_add_if_flooding()/dpsw_vlan_remove_if_flooding().
83  * This is the default configuration.
84  *
85  * @DPSW_FLOODING_PER_FDB: Flooding replicators are allocated per FDB and
86  * interfaces present in each of them can be configured using
87  * dpsw_set_egress_flood().
88  */
89 enum dpsw_flooding_cfg {
90         DPSW_FLOODING_PER_VLAN = 0,
91         DPSW_FLOODING_PER_FDB,
92 };
93
94 /**
95  * enum dpsw_broadcast_cfg - broadcast configuration requested
96  * @DPSW_BROADCAST_PER_OBJECT: There is only one broadcast replicator per DPSW
97  * object. This is the default configuration.
98  * @DPSW_BROADCAST_PER_FDB: Broadcast replicators are allocated per FDB and
99  * interfaces present in each of them can be configured using
100  * dpsw_set_egress_flood().
101  */
102 enum dpsw_broadcast_cfg {
103         DPSW_BROADCAST_PER_OBJECT = 0,
104         DPSW_BROADCAST_PER_FDB,
105 };
106
107 int dpsw_enable(struct fsl_mc_io *mc_io,
108                 u32 cmd_flags,
109                 u16 token);
110
111 int dpsw_disable(struct fsl_mc_io *mc_io,
112                  u32 cmd_flags,
113                  u16 token);
114
115 int dpsw_reset(struct fsl_mc_io *mc_io,
116                u32 cmd_flags,
117                u16 token);
118
119 /**
120  * DPSW IRQ Index and Events
121  */
122
123 #define DPSW_IRQ_INDEX_IF               0x0000
124 #define DPSW_IRQ_INDEX_L2SW             0x0001
125
126 /**
127  * IRQ event - Indicates that the link state changed
128  */
129 #define DPSW_IRQ_EVENT_LINK_CHANGED     0x0001
130
131 /**
132  * struct dpsw_irq_cfg - IRQ configuration
133  * @addr:       Address that must be written to signal a message-based interrupt
134  * @val:        Value to write into irq_addr address
135  * @irq_num: A user defined number associated with this IRQ
136  */
137 struct dpsw_irq_cfg {
138         u64 addr;
139         u32 val;
140         int irq_num;
141 };
142
143 int dpsw_set_irq_enable(struct fsl_mc_io *mc_io,
144                         u32 cmd_flags,
145                         u16 token,
146                         u8 irq_index,
147                         u8 en);
148
149 int dpsw_set_irq_mask(struct fsl_mc_io *mc_io,
150                       u32 cmd_flags,
151                       u16 token,
152                       u8 irq_index,
153                       u32 mask);
154
155 int dpsw_get_irq_status(struct fsl_mc_io *mc_io,
156                         u32 cmd_flags,
157                         u16 token,
158                         u8 irq_index,
159                         u32 *status);
160
161 int dpsw_clear_irq_status(struct fsl_mc_io *mc_io,
162                           u32 cmd_flags,
163                           u16 token,
164                           u8 irq_index,
165                           u32 status);
166
167 /**
168  * struct dpsw_attr - Structure representing DPSW attributes
169  * @id: DPSW object ID
170  * @options: Enable/Disable DPSW features
171  * @max_vlans: Maximum Number of VLANs
172  * @max_meters_per_if:  Number of meters per interface
173  * @max_fdbs: Maximum Number of FDBs
174  * @max_fdb_entries: Number of FDB entries for default FDB table;
175  *                      0 - indicates default 1024 entries.
176  * @fdb_aging_time: Default FDB aging time for default FDB table;
177  *                      0 - indicates default 300 seconds
178  * @max_fdb_mc_groups: Number of multicast groups in each FDB table;
179  *                      0 - indicates default 32
180  * @mem_size: DPSW frame storage memory size
181  * @num_ifs: Number of interfaces
182  * @num_vlans: Current number of VLANs
183  * @num_fdbs: Current number of FDBs
184  * @component_type: Component type of this bridge
185  * @flooding_cfg: Flooding configuration (PER_VLAN - default, PER_FDB)
186  * @broadcast_cfg: Broadcast configuration (PER_OBJECT - default, PER_FDB)
187  */
188 struct dpsw_attr {
189         int id;
190         u64 options;
191         u16 max_vlans;
192         u8 max_meters_per_if;
193         u8 max_fdbs;
194         u16 max_fdb_entries;
195         u16 fdb_aging_time;
196         u16 max_fdb_mc_groups;
197         u16 num_ifs;
198         u16 mem_size;
199         u16 num_vlans;
200         u8 num_fdbs;
201         enum dpsw_component_type component_type;
202         enum dpsw_flooding_cfg flooding_cfg;
203         enum dpsw_broadcast_cfg broadcast_cfg;
204 };
205
206 int dpsw_get_attributes(struct fsl_mc_io *mc_io,
207                         u32 cmd_flags,
208                         u16 token,
209                         struct dpsw_attr *attr);
210
211 /**
212  * struct dpsw_ctrl_if_attr - Control interface attributes
213  * @rx_fqid:            Receive FQID
214  * @rx_err_fqid:        Receive error FQID
215  * @tx_err_conf_fqid:   Transmit error and confirmation FQID
216  */
217 struct dpsw_ctrl_if_attr {
218         u32 rx_fqid;
219         u32 rx_err_fqid;
220         u32 tx_err_conf_fqid;
221 };
222
223 int dpsw_ctrl_if_get_attributes(struct fsl_mc_io *mc_io, u32 cmd_flags,
224                                 u16 token, struct dpsw_ctrl_if_attr *attr);
225
226 enum dpsw_queue_type {
227         DPSW_QUEUE_RX,
228         DPSW_QUEUE_TX_ERR_CONF,
229         DPSW_QUEUE_RX_ERR,
230 };
231
232 /**
233  * Maximum number of DPBP
234  */
235 #define DPSW_MAX_DPBP     8
236
237 /**
238  * struct dpsw_ctrl_if_pools_cfg - Control interface buffer pools configuration
239  * @num_dpbp: Number of DPBPs
240  * @pools: Array of buffer pools parameters; The number of valid entries
241  *      must match 'num_dpbp' value
242  * @pools.dpbp_id: DPBP object ID
243  * @pools.buffer_size: Buffer size
244  * @pools.backup_pool: Backup pool
245  */
246 struct dpsw_ctrl_if_pools_cfg {
247         u8 num_dpbp;
248         struct {
249                 int dpbp_id;
250                 u16 buffer_size;
251                 int backup_pool;
252         } pools[DPSW_MAX_DPBP];
253 };
254
255 int dpsw_ctrl_if_set_pools(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
256                            const struct dpsw_ctrl_if_pools_cfg *cfg);
257
258 #define DPSW_CTRL_IF_QUEUE_OPT_USER_CTX         0x00000001
259 #define DPSW_CTRL_IF_QUEUE_OPT_DEST             0x00000002
260
261 enum dpsw_ctrl_if_dest {
262         DPSW_CTRL_IF_DEST_NONE = 0,
263         DPSW_CTRL_IF_DEST_DPIO = 1,
264 };
265
266 struct dpsw_ctrl_if_dest_cfg {
267         enum dpsw_ctrl_if_dest dest_type;
268         int dest_id;
269         u8 priority;
270 };
271
272 struct dpsw_ctrl_if_queue_cfg {
273         u32 options;
274         u64 user_ctx;
275         struct dpsw_ctrl_if_dest_cfg dest_cfg;
276 };
277
278 int dpsw_ctrl_if_set_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
279                            enum dpsw_queue_type qtype,
280                            const struct dpsw_ctrl_if_queue_cfg *cfg);
281
282 int dpsw_ctrl_if_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
283
284 int dpsw_ctrl_if_disable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
285
286 /**
287  * enum dpsw_action - Action selection for special/control frames
288  * @DPSW_ACTION_DROP: Drop frame
289  * @DPSW_ACTION_REDIRECT: Redirect frame to control port
290  */
291 enum dpsw_action {
292         DPSW_ACTION_DROP = 0,
293         DPSW_ACTION_REDIRECT = 1
294 };
295
296 /**
297  * Enable auto-negotiation
298  */
299 #define DPSW_LINK_OPT_AUTONEG           0x0000000000000001ULL
300 /**
301  * Enable half-duplex mode
302  */
303 #define DPSW_LINK_OPT_HALF_DUPLEX       0x0000000000000002ULL
304 /**
305  * Enable pause frames
306  */
307 #define DPSW_LINK_OPT_PAUSE             0x0000000000000004ULL
308 /**
309  * Enable a-symmetric pause frames
310  */
311 #define DPSW_LINK_OPT_ASYM_PAUSE        0x0000000000000008ULL
312
313 /**
314  * struct dpsw_link_cfg - Structure representing DPSW link configuration
315  * @rate: Rate
316  * @options: Mask of available options; use 'DPSW_LINK_OPT_<X>' values
317  */
318 struct dpsw_link_cfg {
319         u32 rate;
320         u64 options;
321 };
322
323 int dpsw_if_set_link_cfg(struct fsl_mc_io *mc_io,
324                          u32 cmd_flags,
325                          u16 token,
326                          u16 if_id,
327                          struct dpsw_link_cfg *cfg);
328 /**
329  * struct dpsw_link_state - Structure representing DPSW link state
330  * @rate: Rate
331  * @options: Mask of available options; use 'DPSW_LINK_OPT_<X>' values
332  * @up: 0 - covers two cases: down and disconnected, 1 - up
333  */
334 struct dpsw_link_state {
335         u32 rate;
336         u64 options;
337         u8 up;
338 };
339
340 int dpsw_if_get_link_state(struct fsl_mc_io *mc_io,
341                            u32 cmd_flags,
342                            u16 token,
343                            u16 if_id,
344                            struct dpsw_link_state *state);
345
346 /**
347  * struct dpsw_tci_cfg - Tag Control Information (TCI) configuration
348  * @pcp: Priority Code Point (PCP): a 3-bit field which refers
349  *               to the IEEE 802.1p priority
350  * @dei: Drop Eligible Indicator (DEI): a 1-bit field. May be used
351  *               separately or in conjunction with PCP to indicate frames
352  *               eligible to be dropped in the presence of congestion
353  * @vlan_id: VLAN Identifier (VID): a 12-bit field specifying the VLAN
354  *                      to which the frame belongs. The hexadecimal values
355  *                      of 0x000 and 0xFFF are reserved;
356  *                      all other values may be used as VLAN identifiers,
357  *                      allowing up to 4,094 VLANs
358  */
359 struct dpsw_tci_cfg {
360         u8 pcp;
361         u8 dei;
362         u16 vlan_id;
363 };
364
365 int dpsw_if_set_tci(struct fsl_mc_io *mc_io,
366                     u32 cmd_flags,
367                     u16 token,
368                     u16 if_id,
369                     const struct dpsw_tci_cfg *cfg);
370
371 int dpsw_if_get_tci(struct fsl_mc_io *mc_io,
372                     u32 cmd_flags,
373                     u16 token,
374                     u16 if_id,
375                     struct dpsw_tci_cfg *cfg);
376
377 /**
378  * enum dpsw_stp_state - Spanning Tree Protocol (STP) states
379  * @DPSW_STP_STATE_BLOCKING: Blocking state
380  * @DPSW_STP_STATE_LISTENING: Listening state
381  * @DPSW_STP_STATE_LEARNING: Learning state
382  * @DPSW_STP_STATE_FORWARDING: Forwarding state
383  *
384  */
385 enum dpsw_stp_state {
386         DPSW_STP_STATE_DISABLED = 0,
387         DPSW_STP_STATE_LISTENING = 1,
388         DPSW_STP_STATE_LEARNING = 2,
389         DPSW_STP_STATE_FORWARDING = 3,
390         DPSW_STP_STATE_BLOCKING = 0
391 };
392
393 /**
394  * struct dpsw_stp_cfg - Spanning Tree Protocol (STP) Configuration
395  * @vlan_id: VLAN ID STP state
396  * @state: STP state
397  */
398 struct dpsw_stp_cfg {
399         u16 vlan_id;
400         enum dpsw_stp_state state;
401 };
402
403 int dpsw_if_set_stp(struct fsl_mc_io *mc_io,
404                     u32 cmd_flags,
405                     u16 token,
406                     u16 if_id,
407                     const struct dpsw_stp_cfg *cfg);
408
409 /**
410  * enum dpsw_accepted_frames - Types of frames to accept
411  * @DPSW_ADMIT_ALL: The device accepts VLAN tagged, untagged and
412  *                      priority tagged frames
413  * @DPSW_ADMIT_ONLY_VLAN_TAGGED: The device discards untagged frames or
414  *                      Priority-Tagged frames received on this interface.
415  *
416  */
417 enum dpsw_accepted_frames {
418         DPSW_ADMIT_ALL = 1,
419         DPSW_ADMIT_ONLY_VLAN_TAGGED = 3
420 };
421
422 /**
423  * enum dpsw_counter  - Counters types
424  * @DPSW_CNT_ING_FRAME: Counts ingress frames
425  * @DPSW_CNT_ING_BYTE: Counts ingress bytes
426  * @DPSW_CNT_ING_FLTR_FRAME: Counts filtered ingress frames
427  * @DPSW_CNT_ING_FRAME_DISCARD: Counts discarded ingress frame
428  * @DPSW_CNT_ING_MCAST_FRAME: Counts ingress multicast frames
429  * @DPSW_CNT_ING_MCAST_BYTE: Counts ingress multicast bytes
430  * @DPSW_CNT_ING_BCAST_FRAME: Counts ingress broadcast frames
431  * @DPSW_CNT_ING_BCAST_BYTES: Counts ingress broadcast bytes
432  * @DPSW_CNT_EGR_FRAME: Counts egress frames
433  * @DPSW_CNT_EGR_BYTE: Counts egress bytes
434  * @DPSW_CNT_EGR_FRAME_DISCARD: Counts discarded egress frames
435  * @DPSW_CNT_EGR_STP_FRAME_DISCARD: Counts egress STP discarded frames
436  * @DPSW_CNT_ING_NO_BUFF_DISCARD: Counts ingress no buffer discarded frames
437  */
438 enum dpsw_counter {
439         DPSW_CNT_ING_FRAME = 0x0,
440         DPSW_CNT_ING_BYTE = 0x1,
441         DPSW_CNT_ING_FLTR_FRAME = 0x2,
442         DPSW_CNT_ING_FRAME_DISCARD = 0x3,
443         DPSW_CNT_ING_MCAST_FRAME = 0x4,
444         DPSW_CNT_ING_MCAST_BYTE = 0x5,
445         DPSW_CNT_ING_BCAST_FRAME = 0x6,
446         DPSW_CNT_ING_BCAST_BYTES = 0x7,
447         DPSW_CNT_EGR_FRAME = 0x8,
448         DPSW_CNT_EGR_BYTE = 0x9,
449         DPSW_CNT_EGR_FRAME_DISCARD = 0xa,
450         DPSW_CNT_EGR_STP_FRAME_DISCARD = 0xb,
451         DPSW_CNT_ING_NO_BUFF_DISCARD = 0xc,
452 };
453
454 int dpsw_if_get_counter(struct fsl_mc_io *mc_io,
455                         u32 cmd_flags,
456                         u16 token,
457                         u16 if_id,
458                         enum dpsw_counter type,
459                         u64 *counter);
460
461 int dpsw_if_enable(struct fsl_mc_io *mc_io,
462                    u32 cmd_flags,
463                    u16 token,
464                    u16 if_id);
465
466 int dpsw_if_disable(struct fsl_mc_io *mc_io,
467                     u32 cmd_flags,
468                     u16 token,
469                     u16 if_id);
470
471 /**
472  * struct dpsw_if_attr - Structure representing DPSW interface attributes
473  * @num_tcs: Number of traffic classes
474  * @rate: Transmit rate in bits per second
475  * @options: Interface configuration options (bitmap)
476  * @enabled: Indicates if interface is enabled
477  * @accept_all_vlan: The device discards/accepts incoming frames
478  *              for VLANs that do not include this interface
479  * @admit_untagged: When set to 'DPSW_ADMIT_ONLY_VLAN_TAGGED', the device
480  *              discards untagged frames or priority-tagged frames received on
481  *              this interface;
482  *              When set to 'DPSW_ADMIT_ALL', untagged frames or priority-
483  *              tagged frames received on this interface are accepted
484  * @qdid: control frames transmit qdid
485  */
486 struct dpsw_if_attr {
487         u8 num_tcs;
488         u32 rate;
489         u32 options;
490         int enabled;
491         int accept_all_vlan;
492         enum dpsw_accepted_frames admit_untagged;
493         u16 qdid;
494 };
495
496 int dpsw_if_get_attributes(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
497                            u16 if_id, struct dpsw_if_attr *attr);
498
499 int dpsw_if_set_max_frame_length(struct fsl_mc_io *mc_io,
500                                  u32 cmd_flags,
501                                  u16 token,
502                                  u16 if_id,
503                                  u16 frame_length);
504
505 /**
506  * struct dpsw_vlan_cfg - VLAN Configuration
507  * @fdb_id: Forwarding Data Base
508  */
509 struct dpsw_vlan_cfg {
510         u16 fdb_id;
511 };
512
513 int dpsw_vlan_add(struct fsl_mc_io *mc_io,
514                   u32 cmd_flags,
515                   u16 token,
516                   u16 vlan_id,
517                   const struct dpsw_vlan_cfg *cfg);
518
519 #define DPSW_VLAN_ADD_IF_OPT_FDB_ID            0x0001
520
521 /**
522  * struct dpsw_vlan_if_cfg - Set of VLAN Interfaces
523  * @num_ifs: The number of interfaces that are assigned to the egress
524  *              list for this VLAN
525  * @if_id: The set of interfaces that are
526  *              assigned to the egress list for this VLAN
527  */
528 struct dpsw_vlan_if_cfg {
529         u16 num_ifs;
530         u16 options;
531         u16 if_id[DPSW_MAX_IF];
532         u16 fdb_id;
533 };
534
535 int dpsw_vlan_add_if(struct fsl_mc_io *mc_io,
536                      u32 cmd_flags,
537                      u16 token,
538                      u16 vlan_id,
539                      const struct dpsw_vlan_if_cfg *cfg);
540
541 int dpsw_vlan_add_if_untagged(struct fsl_mc_io *mc_io,
542                               u32 cmd_flags,
543                               u16 token,
544                               u16 vlan_id,
545                               const struct dpsw_vlan_if_cfg *cfg);
546
547 int dpsw_vlan_remove_if(struct fsl_mc_io *mc_io,
548                         u32 cmd_flags,
549                         u16 token,
550                         u16 vlan_id,
551                         const struct dpsw_vlan_if_cfg *cfg);
552
553 int dpsw_vlan_remove_if_untagged(struct fsl_mc_io *mc_io,
554                                  u32 cmd_flags,
555                                  u16 token,
556                                  u16 vlan_id,
557                                  const struct dpsw_vlan_if_cfg *cfg);
558
559 int dpsw_vlan_remove(struct fsl_mc_io *mc_io,
560                      u32 cmd_flags,
561                      u16 token,
562                      u16 vlan_id);
563
564 /**
565  * enum dpsw_fdb_entry_type - FDB Entry type - Static/Dynamic
566  * @DPSW_FDB_ENTRY_STATIC: Static entry
567  * @DPSW_FDB_ENTRY_DINAMIC: Dynamic entry
568  */
569 enum dpsw_fdb_entry_type {
570         DPSW_FDB_ENTRY_STATIC = 0,
571         DPSW_FDB_ENTRY_DINAMIC = 1
572 };
573
574 /**
575  * struct dpsw_fdb_unicast_cfg - Unicast entry configuration
576  * @type: Select static or dynamic entry
577  * @mac_addr: MAC address
578  * @if_egress: Egress interface ID
579  */
580 struct dpsw_fdb_unicast_cfg {
581         enum dpsw_fdb_entry_type type;
582         u8 mac_addr[6];
583         u16 if_egress;
584 };
585
586 int dpsw_fdb_add_unicast(struct fsl_mc_io *mc_io,
587                          u32 cmd_flags,
588                          u16 token,
589                          u16 fdb_id,
590                          const struct dpsw_fdb_unicast_cfg *cfg);
591
592 int dpsw_fdb_remove_unicast(struct fsl_mc_io *mc_io,
593                             u32 cmd_flags,
594                             u16 token,
595                             u16 fdb_id,
596                             const struct dpsw_fdb_unicast_cfg *cfg);
597
598 #define DPSW_FDB_ENTRY_TYPE_DYNAMIC  BIT(0)
599 #define DPSW_FDB_ENTRY_TYPE_UNICAST  BIT(1)
600
601 /**
602  * struct fdb_dump_entry - fdb snapshot entry
603  * @mac_addr: MAC address
604  * @type: bit0 - DINAMIC(1)/STATIC(0), bit1 - UNICAST(1)/MULTICAST(0)
605  * @if_info: unicast - egress interface, multicast - number of egress interfaces
606  * @if_mask: multicast - egress interface mask
607  */
608 struct fdb_dump_entry {
609         u8 mac_addr[6];
610         u8 type;
611         u8 if_info;
612         u8 if_mask[8];
613 };
614
615 int dpsw_fdb_dump(struct fsl_mc_io *mc_io,
616                   u32 cmd_flags,
617                   u16 token,
618                   u16 fdb_id,
619                   u64 iova_addr,
620                   u32 iova_size,
621                   u16 *num_entries);
622
623 /**
624  * struct dpsw_fdb_multicast_cfg - Multi-cast entry configuration
625  * @type: Select static or dynamic entry
626  * @mac_addr: MAC address
627  * @num_ifs: Number of external and internal interfaces
628  * @if_id: Egress interface IDs
629  */
630 struct dpsw_fdb_multicast_cfg {
631         enum dpsw_fdb_entry_type type;
632         u8 mac_addr[6];
633         u16 num_ifs;
634         u16 if_id[DPSW_MAX_IF];
635 };
636
637 int dpsw_fdb_add_multicast(struct fsl_mc_io *mc_io,
638                            u32 cmd_flags,
639                            u16 token,
640                            u16 fdb_id,
641                            const struct dpsw_fdb_multicast_cfg *cfg);
642
643 int dpsw_fdb_remove_multicast(struct fsl_mc_io *mc_io,
644                               u32 cmd_flags,
645                               u16 token,
646                               u16 fdb_id,
647                               const struct dpsw_fdb_multicast_cfg *cfg);
648
649 /**
650  * enum dpsw_fdb_learning_mode - Auto-learning modes
651  * @DPSW_FDB_LEARNING_MODE_DIS: Disable Auto-learning
652  * @DPSW_FDB_LEARNING_MODE_HW: Enable HW auto-Learning
653  * @DPSW_FDB_LEARNING_MODE_NON_SECURE: Enable None secure learning by CPU
654  * @DPSW_FDB_LEARNING_MODE_SECURE: Enable secure learning by CPU
655  *
656  *      NONE - SECURE LEARNING
657  *      SMAC found      DMAC found      CTLU Action
658  *      v               v       Forward frame to
659  *                                              1.  DMAC destination
660  *      -               v       Forward frame to
661  *                                              1.  DMAC destination
662  *                                              2.  Control interface
663  *      v               -       Forward frame to
664  *                                              1.  Flooding list of interfaces
665  *      -               -       Forward frame to
666  *                                              1.  Flooding list of interfaces
667  *                                              2.  Control interface
668  *      SECURE LEARING
669  *      SMAC found      DMAC found      CTLU Action
670  *      v               v               Forward frame to
671  *                                              1.  DMAC destination
672  *      -               v               Forward frame to
673  *                                              1.  Control interface
674  *      v               -               Forward frame to
675  *                                              1.  Flooding list of interfaces
676  *      -               -               Forward frame to
677  *                                              1.  Control interface
678  */
679 enum dpsw_fdb_learning_mode {
680         DPSW_FDB_LEARNING_MODE_DIS = 0,
681         DPSW_FDB_LEARNING_MODE_HW = 1,
682         DPSW_FDB_LEARNING_MODE_NON_SECURE = 2,
683         DPSW_FDB_LEARNING_MODE_SECURE = 3
684 };
685
686 /**
687  * struct dpsw_fdb_attr - FDB Attributes
688  * @max_fdb_entries: Number of FDB entries
689  * @fdb_ageing_time: Ageing time in seconds
690  * @learning_mode: Learning mode
691  * @num_fdb_mc_groups: Current number of multicast groups
692  * @max_fdb_mc_groups: Maximum number of multicast groups
693  */
694 struct dpsw_fdb_attr {
695         u16 max_fdb_entries;
696         u16 fdb_ageing_time;
697         enum dpsw_fdb_learning_mode learning_mode;
698         u16 num_fdb_mc_groups;
699         u16 max_fdb_mc_groups;
700 };
701
702 int dpsw_get_api_version(struct fsl_mc_io *mc_io,
703                          u32 cmd_flags,
704                          u16 *major_ver,
705                          u16 *minor_ver);
706
707 int dpsw_if_get_port_mac_addr(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
708                               u16 if_id, u8 mac_addr[6]);
709
710 int dpsw_if_get_primary_mac_addr(struct fsl_mc_io *mc_io, u32 cmd_flags,
711                                  u16 token, u16 if_id, u8 mac_addr[6]);
712
713 int dpsw_if_set_primary_mac_addr(struct fsl_mc_io *mc_io, u32 cmd_flags,
714                                  u16 token, u16 if_id, u8 mac_addr[6]);
715
716 /**
717  * struct dpsw_fdb_cfg  - FDB Configuration
718  * @num_fdb_entries: Number of FDB entries
719  * @fdb_ageing_time: Ageing time in seconds
720  */
721 struct dpsw_fdb_cfg {
722         u16 num_fdb_entries;
723         u16 fdb_ageing_time;
724 };
725
726 int dpsw_fdb_add(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u16 *fdb_id,
727                  const struct dpsw_fdb_cfg *cfg);
728
729 int dpsw_fdb_remove(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u16 fdb_id);
730
731 /**
732  * enum dpsw_flood_type - Define the flood type of a DPSW object
733  * @DPSW_BROADCAST: Broadcast flooding
734  * @DPSW_FLOODING: Unknown flooding
735  */
736 enum dpsw_flood_type {
737         DPSW_BROADCAST = 0,
738         DPSW_FLOODING,
739 };
740
741 struct dpsw_egress_flood_cfg {
742         u16 fdb_id;
743         enum dpsw_flood_type flood_type;
744         u16 num_ifs;
745         u16 if_id[DPSW_MAX_IF];
746 };
747
748 int dpsw_set_egress_flood(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
749                           const struct dpsw_egress_flood_cfg *cfg);
750
751 #endif /* __FSL_DPSW_H */