1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright 2014-2016 Freescale Semiconductor Inc.
4 * Copyright 2017-2021 NXP
11 /* Data Path L2-Switch API
12 * Contains API for handling DPSW topology and functionality
17 /* DPSW general definitions */
19 #define DPSW_MAX_PRIORITIES 8
21 #define DPSW_MAX_IF 64
23 int dpsw_open(struct fsl_mc_io *mc_io, u32 cmd_flags, int dpsw_id, u16 *token);
25 int dpsw_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
30 * DPSW_OPT_FLOODING_DIS - Flooding was disabled at device create
32 #define DPSW_OPT_FLOODING_DIS 0x0000000000000001ULL
34 * DPSW_OPT_MULTICAST_DIS - Multicast was disabled at device create
36 #define DPSW_OPT_MULTICAST_DIS 0x0000000000000004ULL
38 * DPSW_OPT_CTRL_IF_DIS - Control interface support is disabled
40 #define DPSW_OPT_CTRL_IF_DIS 0x0000000000000010ULL
43 * enum dpsw_component_type - component type of a bridge
44 * @DPSW_COMPONENT_TYPE_C_VLAN: A C-VLAN component of an
45 * enterprise VLAN bridge or of a Provider Bridge used
46 * to process C-tagged frames
47 * @DPSW_COMPONENT_TYPE_S_VLAN: An S-VLAN component of a
51 enum dpsw_component_type {
52 DPSW_COMPONENT_TYPE_C_VLAN = 0,
53 DPSW_COMPONENT_TYPE_S_VLAN
57 * enum dpsw_flooding_cfg - flooding configuration requested
58 * @DPSW_FLOODING_PER_VLAN: Flooding replicators are allocated per VLAN and
59 * interfaces present in each of them can be configured using
60 * dpsw_vlan_add_if_flooding()/dpsw_vlan_remove_if_flooding().
61 * This is the default configuration.
63 * @DPSW_FLOODING_PER_FDB: Flooding replicators are allocated per FDB and
64 * interfaces present in each of them can be configured using
65 * dpsw_set_egress_flood().
67 enum dpsw_flooding_cfg {
68 DPSW_FLOODING_PER_VLAN = 0,
69 DPSW_FLOODING_PER_FDB,
73 * enum dpsw_broadcast_cfg - broadcast configuration requested
74 * @DPSW_BROADCAST_PER_OBJECT: There is only one broadcast replicator per DPSW
75 * object. This is the default configuration.
76 * @DPSW_BROADCAST_PER_FDB: Broadcast replicators are allocated per FDB and
77 * interfaces present in each of them can be configured using
78 * dpsw_set_egress_flood().
80 enum dpsw_broadcast_cfg {
81 DPSW_BROADCAST_PER_OBJECT = 0,
82 DPSW_BROADCAST_PER_FDB,
85 int dpsw_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
87 int dpsw_disable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
89 int dpsw_reset(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
91 /* DPSW IRQ Index and Events */
93 #define DPSW_IRQ_INDEX_IF 0x0000
94 #define DPSW_IRQ_INDEX_L2SW 0x0001
97 * DPSW_IRQ_EVENT_LINK_CHANGED - Indicates that the link state changed
99 #define DPSW_IRQ_EVENT_LINK_CHANGED 0x0001
102 * DPSW_IRQ_EVENT_ENDPOINT_CHANGED - Indicates a change in endpoint
104 #define DPSW_IRQ_EVENT_ENDPOINT_CHANGED 0x0002
107 * struct dpsw_irq_cfg - IRQ configuration
108 * @addr: Address that must be written to signal a message-based interrupt
109 * @val: Value to write into irq_addr address
110 * @irq_num: A user defined number associated with this IRQ
112 struct dpsw_irq_cfg {
118 int dpsw_set_irq_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
119 u8 irq_index, u8 en);
121 int dpsw_set_irq_mask(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
122 u8 irq_index, u32 mask);
124 int dpsw_get_irq_status(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
125 u8 irq_index, u32 *status);
127 int dpsw_clear_irq_status(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
128 u8 irq_index, u32 status);
131 * struct dpsw_attr - Structure representing DPSW attributes
132 * @id: DPSW object ID
133 * @options: Enable/Disable DPSW features
134 * @max_vlans: Maximum Number of VLANs
135 * @max_meters_per_if: Number of meters per interface
136 * @max_fdbs: Maximum Number of FDBs
137 * @max_fdb_entries: Number of FDB entries for default FDB table;
138 * 0 - indicates default 1024 entries.
139 * @fdb_aging_time: Default FDB aging time for default FDB table;
140 * 0 - indicates default 300 seconds
141 * @max_fdb_mc_groups: Number of multicast groups in each FDB table;
142 * 0 - indicates default 32
143 * @mem_size: DPSW frame storage memory size
144 * @num_ifs: Number of interfaces
145 * @num_vlans: Current number of VLANs
146 * @num_fdbs: Current number of FDBs
147 * @component_type: Component type of this bridge
148 * @flooding_cfg: Flooding configuration (PER_VLAN - default, PER_FDB)
149 * @broadcast_cfg: Broadcast configuration (PER_OBJECT - default, PER_FDB)
155 u8 max_meters_per_if;
159 u16 max_fdb_mc_groups;
164 enum dpsw_component_type component_type;
165 enum dpsw_flooding_cfg flooding_cfg;
166 enum dpsw_broadcast_cfg broadcast_cfg;
169 int dpsw_get_attributes(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
170 struct dpsw_attr *attr);
173 * struct dpsw_ctrl_if_attr - Control interface attributes
174 * @rx_fqid: Receive FQID
175 * @rx_err_fqid: Receive error FQID
176 * @tx_err_conf_fqid: Transmit error and confirmation FQID
178 struct dpsw_ctrl_if_attr {
181 u32 tx_err_conf_fqid;
184 int dpsw_ctrl_if_get_attributes(struct fsl_mc_io *mc_io, u32 cmd_flags,
185 u16 token, struct dpsw_ctrl_if_attr *attr);
187 enum dpsw_queue_type {
189 DPSW_QUEUE_TX_ERR_CONF,
193 #define DPSW_MAX_DPBP 8
196 * struct dpsw_ctrl_if_pools_cfg - Control interface buffer pools configuration
197 * @num_dpbp: Number of DPBPs
198 * @pools: Array of buffer pools parameters; The number of valid entries
199 * must match 'num_dpbp' value
200 * @pools.dpbp_id: DPBP object ID
201 * @pools.buffer_size: Buffer size
202 * @pools.backup_pool: Backup pool
204 struct dpsw_ctrl_if_pools_cfg {
210 } pools[DPSW_MAX_DPBP];
213 int 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);
216 #define DPSW_CTRL_IF_QUEUE_OPT_USER_CTX 0x00000001
217 #define DPSW_CTRL_IF_QUEUE_OPT_DEST 0x00000002
219 enum dpsw_ctrl_if_dest {
220 DPSW_CTRL_IF_DEST_NONE = 0,
221 DPSW_CTRL_IF_DEST_DPIO = 1,
224 struct dpsw_ctrl_if_dest_cfg {
225 enum dpsw_ctrl_if_dest dest_type;
230 struct dpsw_ctrl_if_queue_cfg {
233 struct dpsw_ctrl_if_dest_cfg dest_cfg;
236 int 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);
240 int dpsw_ctrl_if_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
242 int dpsw_ctrl_if_disable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
245 * enum dpsw_action - Action selection for special/control frames
246 * @DPSW_ACTION_DROP: Drop frame
247 * @DPSW_ACTION_REDIRECT: Redirect frame to control port
250 DPSW_ACTION_DROP = 0,
251 DPSW_ACTION_REDIRECT = 1
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
260 * struct dpsw_link_cfg - Structure representing DPSW link configuration
262 * @options: Mask of available options; use 'DPSW_LINK_OPT_<X>' values
264 struct dpsw_link_cfg {
269 int 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);
273 * struct dpsw_link_state - Structure representing DPSW link state
275 * @options: Mask of available options; use 'DPSW_LINK_OPT_<X>' values
276 * @up: 0 - covers two cases: down and disconnected, 1 - up
278 struct dpsw_link_state {
284 int 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);
288 * struct dpsw_tci_cfg - Tag Control Information (TCI) configuration
289 * @pcp: Priority Code Point (PCP): a 3-bit field which refers
290 * to the IEEE 802.1p priority
291 * @dei: Drop Eligible Indicator (DEI): a 1-bit field. May be used
292 * separately or in conjunction with PCP to indicate frames
293 * eligible to be dropped in the presence of congestion
294 * @vlan_id: VLAN Identifier (VID): a 12-bit field specifying the VLAN
295 * to which the frame belongs. The hexadecimal values
296 * of 0x000 and 0xFFF are reserved;
297 * all other values may be used as VLAN identifiers,
298 * allowing up to 4,094 VLANs
300 struct dpsw_tci_cfg {
306 int 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);
309 int dpsw_if_get_tci(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u16 if_id,
310 struct dpsw_tci_cfg *cfg);
313 * enum dpsw_stp_state - Spanning Tree Protocol (STP) states
314 * @DPSW_STP_STATE_DISABLED: Disabled state
315 * @DPSW_STP_STATE_LISTENING: Listening state
316 * @DPSW_STP_STATE_LEARNING: Learning state
317 * @DPSW_STP_STATE_FORWARDING: Forwarding state
318 * @DPSW_STP_STATE_BLOCKING: Blocking state
321 enum 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
330 * struct dpsw_stp_cfg - Spanning Tree Protocol (STP) Configuration
331 * @vlan_id: VLAN ID STP state
334 struct dpsw_stp_cfg {
336 enum dpsw_stp_state state;
339 int 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);
343 * enum dpsw_accepted_frames - Types of frames to accept
344 * @DPSW_ADMIT_ALL: The device accepts VLAN tagged, untagged and
345 * priority tagged frames
346 * @DPSW_ADMIT_ONLY_VLAN_TAGGED: The device discards untagged frames or
347 * Priority-Tagged frames received on this interface.
350 enum dpsw_accepted_frames {
352 DPSW_ADMIT_ONLY_VLAN_TAGGED = 3
356 * enum dpsw_counter - Counters types
357 * @DPSW_CNT_ING_FRAME: Counts ingress frames
358 * @DPSW_CNT_ING_BYTE: Counts ingress bytes
359 * @DPSW_CNT_ING_FLTR_FRAME: Counts filtered ingress frames
360 * @DPSW_CNT_ING_FRAME_DISCARD: Counts discarded ingress frame
361 * @DPSW_CNT_ING_MCAST_FRAME: Counts ingress multicast frames
362 * @DPSW_CNT_ING_MCAST_BYTE: Counts ingress multicast bytes
363 * @DPSW_CNT_ING_BCAST_FRAME: Counts ingress broadcast frames
364 * @DPSW_CNT_ING_BCAST_BYTES: Counts ingress broadcast bytes
365 * @DPSW_CNT_EGR_FRAME: Counts egress frames
366 * @DPSW_CNT_EGR_BYTE: Counts egress bytes
367 * @DPSW_CNT_EGR_FRAME_DISCARD: Counts discarded egress frames
368 * @DPSW_CNT_EGR_STP_FRAME_DISCARD: Counts egress STP discarded frames
369 * @DPSW_CNT_ING_NO_BUFF_DISCARD: Counts ingress no buffer discarded frames
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,
387 int 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);
390 int dpsw_if_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u16 if_id);
392 int dpsw_if_disable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u16 if_id);
395 * struct dpsw_if_attr - Structure representing DPSW interface attributes
396 * @num_tcs: Number of traffic classes
397 * @rate: Transmit rate in bits per second
398 * @options: Interface configuration options (bitmap)
399 * @enabled: Indicates if interface is enabled
400 * @accept_all_vlan: The device discards/accepts incoming frames
401 * for VLANs that do not include this interface
402 * @admit_untagged: When set to 'DPSW_ADMIT_ONLY_VLAN_TAGGED', the device
403 * discards untagged frames or priority-tagged frames received on
405 * When set to 'DPSW_ADMIT_ALL', untagged frames or priority-
406 * tagged frames received on this interface are accepted
407 * @qdid: control frames transmit qdid
409 struct dpsw_if_attr {
415 enum dpsw_accepted_frames admit_untagged;
419 int dpsw_if_get_attributes(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
420 u16 if_id, struct dpsw_if_attr *attr);
422 int dpsw_if_set_max_frame_length(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
423 u16 if_id, u16 frame_length);
426 * struct dpsw_vlan_cfg - VLAN Configuration
427 * @fdb_id: Forwarding Data Base
429 struct dpsw_vlan_cfg {
433 int dpsw_vlan_add(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
434 u16 vlan_id, const struct dpsw_vlan_cfg *cfg);
436 #define DPSW_VLAN_ADD_IF_OPT_FDB_ID 0x0001
439 * struct dpsw_vlan_if_cfg - Set of VLAN Interfaces
440 * @num_ifs: The number of interfaces that are assigned to the egress
442 * @if_id: The set of interfaces that are
443 * assigned to the egress list for this VLAN
444 * @options: Options map for this command (DPSW_VLAN_ADD_IF_OPT_FDB_ID)
445 * @fdb_id: FDB id to be used by this VLAN on these specific interfaces
446 * (taken into account only if the DPSW_VLAN_ADD_IF_OPT_FDB_ID is
447 * specified in the options field)
449 struct dpsw_vlan_if_cfg {
452 u16 if_id[DPSW_MAX_IF];
456 int 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);
459 int 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);
462 int 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);
465 int 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);
468 int dpsw_vlan_remove(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
472 * enum dpsw_fdb_entry_type - FDB Entry type - Static/Dynamic
473 * @DPSW_FDB_ENTRY_STATIC: Static entry
474 * @DPSW_FDB_ENTRY_DINAMIC: Dynamic entry
476 enum dpsw_fdb_entry_type {
477 DPSW_FDB_ENTRY_STATIC = 0,
478 DPSW_FDB_ENTRY_DINAMIC = 1
482 * struct dpsw_fdb_unicast_cfg - Unicast entry configuration
483 * @type: Select static or dynamic entry
484 * @mac_addr: MAC address
485 * @if_egress: Egress interface ID
487 struct dpsw_fdb_unicast_cfg {
488 enum dpsw_fdb_entry_type type;
493 int 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);
496 int 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);
499 #define DPSW_FDB_ENTRY_TYPE_DYNAMIC BIT(0)
500 #define DPSW_FDB_ENTRY_TYPE_UNICAST BIT(1)
503 * struct fdb_dump_entry - fdb snapshot entry
504 * @mac_addr: MAC address
505 * @type: bit0 - DINAMIC(1)/STATIC(0), bit1 - UNICAST(1)/MULTICAST(0)
506 * @if_info: unicast - egress interface, multicast - number of egress interfaces
507 * @if_mask: multicast - egress interface mask
509 struct fdb_dump_entry {
516 int 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);
520 * struct dpsw_fdb_multicast_cfg - Multi-cast entry configuration
521 * @type: Select static or dynamic entry
522 * @mac_addr: MAC address
523 * @num_ifs: Number of external and internal interfaces
524 * @if_id: Egress interface IDs
526 struct dpsw_fdb_multicast_cfg {
527 enum dpsw_fdb_entry_type type;
530 u16 if_id[DPSW_MAX_IF];
533 int 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);
536 int 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);
540 * enum dpsw_learning_mode - Auto-learning modes
541 * @DPSW_LEARNING_MODE_DIS: Disable Auto-learning
542 * @DPSW_LEARNING_MODE_HW: Enable HW auto-Learning
543 * @DPSW_LEARNING_MODE_NON_SECURE: Enable None secure learning by CPU
544 * @DPSW_LEARNING_MODE_SECURE: Enable secure learning by CPU
546 * NONE - SECURE LEARNING
547 * SMAC found DMAC found CTLU Action
548 * v v Forward frame to
549 * 1. DMAC destination
550 * - v Forward frame to
551 * 1. DMAC destination
552 * 2. Control interface
553 * v - Forward frame to
554 * 1. Flooding list of interfaces
555 * - - Forward frame to
556 * 1. Flooding list of interfaces
557 * 2. Control interface
559 * SMAC found DMAC found CTLU Action
560 * v v Forward frame to
561 * 1. DMAC destination
562 * - v Forward frame to
563 * 1. Control interface
564 * v - Forward frame to
565 * 1. Flooding list of interfaces
566 * - - Forward frame to
567 * 1. Control interface
569 enum 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
577 * struct dpsw_fdb_attr - FDB Attributes
578 * @max_fdb_entries: Number of FDB entries
579 * @fdb_ageing_time: Ageing time in seconds
580 * @learning_mode: Learning mode
581 * @num_fdb_mc_groups: Current number of multicast groups
582 * @max_fdb_mc_groups: Maximum number of multicast groups
584 struct dpsw_fdb_attr {
587 enum dpsw_learning_mode learning_mode;
588 u16 num_fdb_mc_groups;
589 u16 max_fdb_mc_groups;
592 int dpsw_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags,
593 u16 *major_ver, u16 *minor_ver);
595 int 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]);
599 * struct dpsw_fdb_cfg - FDB Configuration
600 * @num_fdb_entries: Number of FDB entries
601 * @fdb_ageing_time: Ageing time in seconds
603 struct dpsw_fdb_cfg {
608 int dpsw_fdb_add(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u16 *fdb_id,
609 const struct dpsw_fdb_cfg *cfg);
611 int dpsw_fdb_remove(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u16 fdb_id);
614 * enum dpsw_flood_type - Define the flood type of a DPSW object
615 * @DPSW_BROADCAST: Broadcast flooding
616 * @DPSW_FLOODING: Unknown flooding
618 enum dpsw_flood_type {
623 struct dpsw_egress_flood_cfg {
625 enum dpsw_flood_type flood_type;
627 u16 if_id[DPSW_MAX_IF];
630 int dpsw_set_egress_flood(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
631 const struct dpsw_egress_flood_cfg *cfg);
633 int 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);
637 * struct dpsw_acl_cfg - ACL Configuration
638 * @max_entries: Number of ACL rules
640 struct dpsw_acl_cfg {
644 int dpsw_acl_add(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u16 *acl_id,
645 const struct dpsw_acl_cfg *cfg);
647 int dpsw_acl_remove(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
651 * struct dpsw_acl_if_cfg - List of interfaces to associate with an ACL table
652 * @num_ifs: Number of interfaces
653 * @if_id: List of interfaces
655 struct dpsw_acl_if_cfg {
657 u16 if_id[DPSW_MAX_IF];
660 int 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);
663 int 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);
667 * struct dpsw_acl_fields - ACL fields.
668 * @l2_dest_mac: Destination MAC address: BPDU, Multicast, Broadcast, Unicast,
669 * slow protocols, MVRP, STP
670 * @l2_source_mac: Source MAC address
671 * @l2_tpid: Layer 2 (Ethernet) protocol type, used to identify the following
672 * protocols: MPLS, PTP, PFC, ARP, Jumbo frames, LLDP, IEEE802.1ae,
673 * Q-in-Q, IPv4, IPv6, PPPoE
674 * @l2_pcp_dei: indicate which protocol is encapsulated in the payload
675 * @l2_vlan_id: layer 2 VLAN ID
676 * @l2_ether_type: layer 2 Ethernet type
677 * @l3_dscp: Layer 3 differentiated services code point
678 * @l3_protocol: Tells the Network layer at the destination host, to which
679 * Protocol this packet belongs to. The following protocol are
680 * supported: ICMP, IGMP, IPv4 (encapsulation), TCP, IPv6
681 * (encapsulation), GRE, PTP
682 * @l3_source_ip: Source IPv4 IP
683 * @l3_dest_ip: Destination IPv4 IP
684 * @l4_source_port: Source TCP/UDP Port
685 * @l4_dest_port: Destination TCP/UDP Port
687 struct dpsw_acl_fields {
703 * struct dpsw_acl_key - ACL key
704 * @match: Match fields
705 * @mask: Mask: b'1 - valid, b'0 don't care
707 struct dpsw_acl_key {
708 struct dpsw_acl_fields match;
709 struct dpsw_acl_fields mask;
713 * enum dpsw_acl_action - action to be run on the ACL rule match
714 * @DPSW_ACL_ACTION_DROP: Drop frame
715 * @DPSW_ACL_ACTION_REDIRECT: Redirect to certain port
716 * @DPSW_ACL_ACTION_ACCEPT: Accept frame
717 * @DPSW_ACL_ACTION_REDIRECT_TO_CTRL_IF: Redirect to control interface
719 enum 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
727 * struct dpsw_acl_result - ACL action
728 * @action: Action should be taken when ACL entry hit
729 * @if_id: Interface IDs to redirect frame. Valid only if redirect selected for
732 struct dpsw_acl_result {
733 enum dpsw_acl_action action;
738 * struct dpsw_acl_entry_cfg - ACL entry
739 * @key_iova: I/O virtual address of DMA-able memory filled with key after call
740 * to dpsw_acl_prepare_entry_cfg()
741 * @result: Required action when entry hit occurs
742 * @precedence: Precedence inside ACL 0 is lowest; This priority can not change
743 * during the lifetime of a Policy. It is user responsibility to
744 * space the priorities according to consequent rule additions.
746 struct dpsw_acl_entry_cfg {
748 struct dpsw_acl_result result;
752 void dpsw_acl_prepare_entry_cfg(const struct dpsw_acl_key *key,
755 int 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);
758 int 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);
762 * enum dpsw_reflection_filter - Filter type for frames to be reflected
763 * @DPSW_REFLECTION_FILTER_INGRESS_ALL: Reflect all frames
764 * @DPSW_REFLECTION_FILTER_INGRESS_VLAN: Reflect only frames that belong to
765 * the particular VLAN defined by vid parameter
768 enum dpsw_reflection_filter {
769 DPSW_REFLECTION_FILTER_INGRESS_ALL = 0,
770 DPSW_REFLECTION_FILTER_INGRESS_VLAN = 1
774 * struct dpsw_reflection_cfg - Structure representing the mirroring config
775 * @filter: Filter type for frames to be mirrored
776 * @vlan_id: VLAN ID to mirror; valid only when the type is DPSW_INGRESS_VLAN
778 struct dpsw_reflection_cfg {
779 enum dpsw_reflection_filter filter;
783 int dpsw_set_reflection_if(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
786 int 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);
789 int 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 /* __FSL_DPSW_H */