Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Copyright 2014-2016 Freescale Semiconductor Inc.
0004  * Copyright 2017-2021 NXP
0005  *
0006  */
0007 
0008 #ifndef __FSL_DPSW_H
0009 #define __FSL_DPSW_H
0010 
0011 /* Data Path L2-Switch API
0012  * Contains API for handling DPSW topology and functionality
0013  */
0014 
0015 struct fsl_mc_io;
0016 
0017 /* DPSW general definitions */
0018 
0019 #define DPSW_MAX_PRIORITIES 8
0020 
0021 #define DPSW_MAX_IF     64
0022 
0023 int dpsw_open(struct fsl_mc_io *mc_io, u32 cmd_flags, int dpsw_id, u16 *token);
0024 
0025 int dpsw_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
0026 
0027 /* DPSW options */
0028 
0029 /**
0030  * DPSW_OPT_FLOODING_DIS - Flooding was disabled at device create
0031  */
0032 #define DPSW_OPT_FLOODING_DIS       0x0000000000000001ULL
0033 /**
0034  * DPSW_OPT_MULTICAST_DIS - Multicast was disabled at device create
0035  */
0036 #define DPSW_OPT_MULTICAST_DIS      0x0000000000000004ULL
0037 /**
0038  * DPSW_OPT_CTRL_IF_DIS - Control interface support is disabled
0039  */
0040 #define DPSW_OPT_CTRL_IF_DIS        0x0000000000000010ULL
0041 
0042 /**
0043  * enum dpsw_component_type - component type of a bridge
0044  * @DPSW_COMPONENT_TYPE_C_VLAN: A C-VLAN component of an
0045  *   enterprise VLAN bridge or of a Provider Bridge used
0046  *   to process C-tagged frames
0047  * @DPSW_COMPONENT_TYPE_S_VLAN: An S-VLAN component of a
0048  *   Provider Bridge
0049  *
0050  */
0051 enum dpsw_component_type {
0052     DPSW_COMPONENT_TYPE_C_VLAN = 0,
0053     DPSW_COMPONENT_TYPE_S_VLAN
0054 };
0055 
0056 /**
0057  *  enum dpsw_flooding_cfg - flooding configuration requested
0058  * @DPSW_FLOODING_PER_VLAN: Flooding replicators are allocated per VLAN and
0059  * interfaces present in each of them can be configured using
0060  * dpsw_vlan_add_if_flooding()/dpsw_vlan_remove_if_flooding().
0061  * This is the default configuration.
0062  *
0063  * @DPSW_FLOODING_PER_FDB: Flooding replicators are allocated per FDB and
0064  * interfaces present in each of them can be configured using
0065  * dpsw_set_egress_flood().
0066  */
0067 enum dpsw_flooding_cfg {
0068     DPSW_FLOODING_PER_VLAN = 0,
0069     DPSW_FLOODING_PER_FDB,
0070 };
0071 
0072 /**
0073  * enum dpsw_broadcast_cfg - broadcast configuration requested
0074  * @DPSW_BROADCAST_PER_OBJECT: There is only one broadcast replicator per DPSW
0075  * object. This is the default configuration.
0076  * @DPSW_BROADCAST_PER_FDB: Broadcast replicators are allocated per FDB and
0077  * interfaces present in each of them can be configured using
0078  * dpsw_set_egress_flood().
0079  */
0080 enum dpsw_broadcast_cfg {
0081     DPSW_BROADCAST_PER_OBJECT = 0,
0082     DPSW_BROADCAST_PER_FDB,
0083 };
0084 
0085 int dpsw_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
0086 
0087 int dpsw_disable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
0088 
0089 int dpsw_reset(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
0090 
0091 /* DPSW IRQ Index and Events */
0092 
0093 #define DPSW_IRQ_INDEX_IF       0x0000
0094 #define DPSW_IRQ_INDEX_L2SW     0x0001
0095 
0096 /**
0097  * DPSW_IRQ_EVENT_LINK_CHANGED - Indicates that the link state changed
0098  */
0099 #define DPSW_IRQ_EVENT_LINK_CHANGED 0x0001
0100 
0101 /**
0102  * DPSW_IRQ_EVENT_ENDPOINT_CHANGED - Indicates a change in endpoint
0103  */
0104 #define DPSW_IRQ_EVENT_ENDPOINT_CHANGED 0x0002
0105 
0106 /**
0107  * struct dpsw_irq_cfg - IRQ configuration
0108  * @addr:   Address that must be written to signal a message-based interrupt
0109  * @val:    Value to write into irq_addr address
0110  * @irq_num: A user defined number associated with this IRQ
0111  */
0112 struct dpsw_irq_cfg {
0113     u64 addr;
0114     u32 val;
0115     int irq_num;
0116 };
0117 
0118 int dpsw_set_irq_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0119             u8 irq_index, u8 en);
0120 
0121 int dpsw_set_irq_mask(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0122               u8 irq_index, u32 mask);
0123 
0124 int dpsw_get_irq_status(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0125             u8 irq_index, u32 *status);
0126 
0127 int dpsw_clear_irq_status(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0128               u8 irq_index, u32 status);
0129 
0130 /**
0131  * struct dpsw_attr - Structure representing DPSW attributes
0132  * @id: DPSW object ID
0133  * @options: Enable/Disable DPSW features
0134  * @max_vlans: Maximum Number of VLANs
0135  * @max_meters_per_if:  Number of meters per interface
0136  * @max_fdbs: Maximum Number of FDBs
0137  * @max_fdb_entries: Number of FDB entries for default FDB table;
0138  *          0 - indicates default 1024 entries.
0139  * @fdb_aging_time: Default FDB aging time for default FDB table;
0140  *          0 - indicates default 300 seconds
0141  * @max_fdb_mc_groups: Number of multicast groups in each FDB table;
0142  *          0 - indicates default 32
0143  * @mem_size: DPSW frame storage memory size
0144  * @num_ifs: Number of interfaces
0145  * @num_vlans: Current number of VLANs
0146  * @num_fdbs: Current number of FDBs
0147  * @component_type: Component type of this bridge
0148  * @flooding_cfg: Flooding configuration (PER_VLAN - default, PER_FDB)
0149  * @broadcast_cfg: Broadcast configuration (PER_OBJECT - default, PER_FDB)
0150  */
0151 struct dpsw_attr {
0152     int id;
0153     u64 options;
0154     u16 max_vlans;
0155     u8 max_meters_per_if;
0156     u8 max_fdbs;
0157     u16 max_fdb_entries;
0158     u16 fdb_aging_time;
0159     u16 max_fdb_mc_groups;
0160     u16 num_ifs;
0161     u16 mem_size;
0162     u16 num_vlans;
0163     u8 num_fdbs;
0164     enum dpsw_component_type component_type;
0165     enum dpsw_flooding_cfg flooding_cfg;
0166     enum dpsw_broadcast_cfg broadcast_cfg;
0167 };
0168 
0169 int dpsw_get_attributes(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0170             struct dpsw_attr *attr);
0171 
0172 /**
0173  * struct dpsw_ctrl_if_attr - Control interface attributes
0174  * @rx_fqid:        Receive FQID
0175  * @rx_err_fqid:    Receive error FQID
0176  * @tx_err_conf_fqid:   Transmit error and confirmation FQID
0177  */
0178 struct dpsw_ctrl_if_attr {
0179     u32 rx_fqid;
0180     u32 rx_err_fqid;
0181     u32 tx_err_conf_fqid;
0182 };
0183 
0184 int dpsw_ctrl_if_get_attributes(struct fsl_mc_io *mc_io, u32 cmd_flags,
0185                 u16 token, struct dpsw_ctrl_if_attr *attr);
0186 
0187 enum dpsw_queue_type {
0188     DPSW_QUEUE_RX,
0189     DPSW_QUEUE_TX_ERR_CONF,
0190     DPSW_QUEUE_RX_ERR,
0191 };
0192 
0193 #define DPSW_MAX_DPBP     8
0194 
0195 /**
0196  * struct dpsw_ctrl_if_pools_cfg - Control interface buffer pools configuration
0197  * @num_dpbp: Number of DPBPs
0198  * @pools: Array of buffer pools parameters; The number of valid entries
0199  *  must match 'num_dpbp' value
0200  * @pools.dpbp_id: DPBP object ID
0201  * @pools.buffer_size: Buffer size
0202  * @pools.backup_pool: Backup pool
0203  */
0204 struct dpsw_ctrl_if_pools_cfg {
0205     u8 num_dpbp;
0206     struct {
0207         int dpbp_id;
0208         u16 buffer_size;
0209         int backup_pool;
0210     } pools[DPSW_MAX_DPBP];
0211 };
0212 
0213 int dpsw_ctrl_if_set_pools(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0214                const struct dpsw_ctrl_if_pools_cfg *cfg);
0215 
0216 #define DPSW_CTRL_IF_QUEUE_OPT_USER_CTX     0x00000001
0217 #define DPSW_CTRL_IF_QUEUE_OPT_DEST     0x00000002
0218 
0219 enum dpsw_ctrl_if_dest {
0220     DPSW_CTRL_IF_DEST_NONE = 0,
0221     DPSW_CTRL_IF_DEST_DPIO = 1,
0222 };
0223 
0224 struct dpsw_ctrl_if_dest_cfg {
0225     enum dpsw_ctrl_if_dest dest_type;
0226     int dest_id;
0227     u8 priority;
0228 };
0229 
0230 struct dpsw_ctrl_if_queue_cfg {
0231     u32 options;
0232     u64 user_ctx;
0233     struct dpsw_ctrl_if_dest_cfg dest_cfg;
0234 };
0235 
0236 int dpsw_ctrl_if_set_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0237                enum dpsw_queue_type qtype,
0238                const struct dpsw_ctrl_if_queue_cfg *cfg);
0239 
0240 int dpsw_ctrl_if_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
0241 
0242 int dpsw_ctrl_if_disable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
0243 
0244 /**
0245  * enum dpsw_action - Action selection for special/control frames
0246  * @DPSW_ACTION_DROP: Drop frame
0247  * @DPSW_ACTION_REDIRECT: Redirect frame to control port
0248  */
0249 enum dpsw_action {
0250     DPSW_ACTION_DROP = 0,
0251     DPSW_ACTION_REDIRECT = 1
0252 };
0253 
0254 #define DPSW_LINK_OPT_AUTONEG       0x0000000000000001ULL
0255 #define DPSW_LINK_OPT_HALF_DUPLEX   0x0000000000000002ULL
0256 #define DPSW_LINK_OPT_PAUSE     0x0000000000000004ULL
0257 #define DPSW_LINK_OPT_ASYM_PAUSE    0x0000000000000008ULL
0258 
0259 /**
0260  * struct dpsw_link_cfg - Structure representing DPSW link configuration
0261  * @rate: Rate
0262  * @options: Mask of available options; use 'DPSW_LINK_OPT_<X>' values
0263  */
0264 struct dpsw_link_cfg {
0265     u32 rate;
0266     u64 options;
0267 };
0268 
0269 int dpsw_if_set_link_cfg(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u16 if_id,
0270              struct dpsw_link_cfg *cfg);
0271 
0272 /**
0273  * struct dpsw_link_state - Structure representing DPSW link state
0274  * @rate: Rate
0275  * @options: Mask of available options; use 'DPSW_LINK_OPT_<X>' values
0276  * @up: 0 - covers two cases: down and disconnected, 1 - up
0277  */
0278 struct dpsw_link_state {
0279     u32 rate;
0280     u64 options;
0281     u8 up;
0282 };
0283 
0284 int dpsw_if_get_link_state(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0285                u16 if_id, struct dpsw_link_state *state);
0286 
0287 /**
0288  * struct dpsw_tci_cfg - Tag Control Information (TCI) configuration
0289  * @pcp: Priority Code Point (PCP): a 3-bit field which refers
0290  *       to the IEEE 802.1p priority
0291  * @dei: Drop Eligible Indicator (DEI): a 1-bit field. May be used
0292  *       separately or in conjunction with PCP to indicate frames
0293  *       eligible to be dropped in the presence of congestion
0294  * @vlan_id: VLAN Identifier (VID): a 12-bit field specifying the VLAN
0295  *          to which the frame belongs. The hexadecimal values
0296  *          of 0x000 and 0xFFF are reserved;
0297  *          all other values may be used as VLAN identifiers,
0298  *          allowing up to 4,094 VLANs
0299  */
0300 struct dpsw_tci_cfg {
0301     u8 pcp;
0302     u8 dei;
0303     u16 vlan_id;
0304 };
0305 
0306 int dpsw_if_set_tci(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u16 if_id,
0307             const struct dpsw_tci_cfg *cfg);
0308 
0309 int dpsw_if_get_tci(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u16 if_id,
0310             struct dpsw_tci_cfg *cfg);
0311 
0312 /**
0313  * enum dpsw_stp_state - Spanning Tree Protocol (STP) states
0314  * @DPSW_STP_STATE_DISABLED: Disabled state
0315  * @DPSW_STP_STATE_LISTENING: Listening state
0316  * @DPSW_STP_STATE_LEARNING: Learning state
0317  * @DPSW_STP_STATE_FORWARDING: Forwarding state
0318  * @DPSW_STP_STATE_BLOCKING: Blocking state
0319  *
0320  */
0321 enum dpsw_stp_state {
0322     DPSW_STP_STATE_DISABLED = 0,
0323     DPSW_STP_STATE_LISTENING = 1,
0324     DPSW_STP_STATE_LEARNING = 2,
0325     DPSW_STP_STATE_FORWARDING = 3,
0326     DPSW_STP_STATE_BLOCKING = 0
0327 };
0328 
0329 /**
0330  * struct dpsw_stp_cfg - Spanning Tree Protocol (STP) Configuration
0331  * @vlan_id: VLAN ID STP state
0332  * @state: STP state
0333  */
0334 struct dpsw_stp_cfg {
0335     u16 vlan_id;
0336     enum dpsw_stp_state state;
0337 };
0338 
0339 int dpsw_if_set_stp(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u16 if_id,
0340             const struct dpsw_stp_cfg *cfg);
0341 
0342 /**
0343  * enum dpsw_accepted_frames - Types of frames to accept
0344  * @DPSW_ADMIT_ALL: The device accepts VLAN tagged, untagged and
0345  *          priority tagged frames
0346  * @DPSW_ADMIT_ONLY_VLAN_TAGGED: The device discards untagged frames or
0347  *          Priority-Tagged frames received on this interface.
0348  *
0349  */
0350 enum dpsw_accepted_frames {
0351     DPSW_ADMIT_ALL = 1,
0352     DPSW_ADMIT_ONLY_VLAN_TAGGED = 3
0353 };
0354 
0355 /**
0356  * enum dpsw_counter  - Counters types
0357  * @DPSW_CNT_ING_FRAME: Counts ingress frames
0358  * @DPSW_CNT_ING_BYTE: Counts ingress bytes
0359  * @DPSW_CNT_ING_FLTR_FRAME: Counts filtered ingress frames
0360  * @DPSW_CNT_ING_FRAME_DISCARD: Counts discarded ingress frame
0361  * @DPSW_CNT_ING_MCAST_FRAME: Counts ingress multicast frames
0362  * @DPSW_CNT_ING_MCAST_BYTE: Counts ingress multicast bytes
0363  * @DPSW_CNT_ING_BCAST_FRAME: Counts ingress broadcast frames
0364  * @DPSW_CNT_ING_BCAST_BYTES: Counts ingress broadcast bytes
0365  * @DPSW_CNT_EGR_FRAME: Counts egress frames
0366  * @DPSW_CNT_EGR_BYTE: Counts egress bytes
0367  * @DPSW_CNT_EGR_FRAME_DISCARD: Counts discarded egress frames
0368  * @DPSW_CNT_EGR_STP_FRAME_DISCARD: Counts egress STP discarded frames
0369  * @DPSW_CNT_ING_NO_BUFF_DISCARD: Counts ingress no buffer discarded frames
0370  */
0371 enum dpsw_counter {
0372     DPSW_CNT_ING_FRAME = 0x0,
0373     DPSW_CNT_ING_BYTE = 0x1,
0374     DPSW_CNT_ING_FLTR_FRAME = 0x2,
0375     DPSW_CNT_ING_FRAME_DISCARD = 0x3,
0376     DPSW_CNT_ING_MCAST_FRAME = 0x4,
0377     DPSW_CNT_ING_MCAST_BYTE = 0x5,
0378     DPSW_CNT_ING_BCAST_FRAME = 0x6,
0379     DPSW_CNT_ING_BCAST_BYTES = 0x7,
0380     DPSW_CNT_EGR_FRAME = 0x8,
0381     DPSW_CNT_EGR_BYTE = 0x9,
0382     DPSW_CNT_EGR_FRAME_DISCARD = 0xa,
0383     DPSW_CNT_EGR_STP_FRAME_DISCARD = 0xb,
0384     DPSW_CNT_ING_NO_BUFF_DISCARD = 0xc,
0385 };
0386 
0387 int dpsw_if_get_counter(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0388             u16 if_id, enum dpsw_counter type, u64 *counter);
0389 
0390 int dpsw_if_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u16 if_id);
0391 
0392 int dpsw_if_disable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u16 if_id);
0393 
0394 /**
0395  * struct dpsw_if_attr - Structure representing DPSW interface attributes
0396  * @num_tcs: Number of traffic classes
0397  * @rate: Transmit rate in bits per second
0398  * @options: Interface configuration options (bitmap)
0399  * @enabled: Indicates if interface is enabled
0400  * @accept_all_vlan: The device discards/accepts incoming frames
0401  *      for VLANs that do not include this interface
0402  * @admit_untagged: When set to 'DPSW_ADMIT_ONLY_VLAN_TAGGED', the device
0403  *      discards untagged frames or priority-tagged frames received on
0404  *      this interface;
0405  *      When set to 'DPSW_ADMIT_ALL', untagged frames or priority-
0406  *      tagged frames received on this interface are accepted
0407  * @qdid: control frames transmit qdid
0408  */
0409 struct dpsw_if_attr {
0410     u8 num_tcs;
0411     u32 rate;
0412     u32 options;
0413     int enabled;
0414     int accept_all_vlan;
0415     enum dpsw_accepted_frames admit_untagged;
0416     u16 qdid;
0417 };
0418 
0419 int dpsw_if_get_attributes(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0420                u16 if_id, struct dpsw_if_attr *attr);
0421 
0422 int dpsw_if_set_max_frame_length(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0423                  u16 if_id, u16 frame_length);
0424 
0425 /**
0426  * struct dpsw_vlan_cfg - VLAN Configuration
0427  * @fdb_id: Forwarding Data Base
0428  */
0429 struct dpsw_vlan_cfg {
0430     u16 fdb_id;
0431 };
0432 
0433 int dpsw_vlan_add(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0434           u16 vlan_id, const struct dpsw_vlan_cfg *cfg);
0435 
0436 #define DPSW_VLAN_ADD_IF_OPT_FDB_ID            0x0001
0437 
0438 /**
0439  * struct dpsw_vlan_if_cfg - Set of VLAN Interfaces
0440  * @num_ifs: The number of interfaces that are assigned to the egress
0441  *      list for this VLAN
0442  * @if_id: The set of interfaces that are
0443  *      assigned to the egress list for this VLAN
0444  * @options: Options map for this command (DPSW_VLAN_ADD_IF_OPT_FDB_ID)
0445  * @fdb_id: FDB id to be used by this VLAN on these specific interfaces
0446  *      (taken into account only if the DPSW_VLAN_ADD_IF_OPT_FDB_ID is
0447  *      specified in the options field)
0448  */
0449 struct dpsw_vlan_if_cfg {
0450     u16 num_ifs;
0451     u16 options;
0452     u16 if_id[DPSW_MAX_IF];
0453     u16 fdb_id;
0454 };
0455 
0456 int dpsw_vlan_add_if(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0457              u16 vlan_id, const struct dpsw_vlan_if_cfg *cfg);
0458 
0459 int dpsw_vlan_add_if_untagged(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0460                   u16 vlan_id, const struct dpsw_vlan_if_cfg *cfg);
0461 
0462 int dpsw_vlan_remove_if(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0463             u16 vlan_id, const struct dpsw_vlan_if_cfg *cfg);
0464 
0465 int dpsw_vlan_remove_if_untagged(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0466                  u16 vlan_id, const struct dpsw_vlan_if_cfg *cfg);
0467 
0468 int dpsw_vlan_remove(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0469              u16 vlan_id);
0470 
0471 /**
0472  * enum dpsw_fdb_entry_type - FDB Entry type - Static/Dynamic
0473  * @DPSW_FDB_ENTRY_STATIC: Static entry
0474  * @DPSW_FDB_ENTRY_DINAMIC: Dynamic entry
0475  */
0476 enum dpsw_fdb_entry_type {
0477     DPSW_FDB_ENTRY_STATIC = 0,
0478     DPSW_FDB_ENTRY_DINAMIC = 1
0479 };
0480 
0481 /**
0482  * struct dpsw_fdb_unicast_cfg - Unicast entry configuration
0483  * @type: Select static or dynamic entry
0484  * @mac_addr: MAC address
0485  * @if_egress: Egress interface ID
0486  */
0487 struct dpsw_fdb_unicast_cfg {
0488     enum dpsw_fdb_entry_type type;
0489     u8 mac_addr[6];
0490     u16 if_egress;
0491 };
0492 
0493 int dpsw_fdb_add_unicast(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0494              u16 fdb_id, const struct dpsw_fdb_unicast_cfg *cfg);
0495 
0496 int dpsw_fdb_remove_unicast(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0497                 u16 fdb_id, const struct dpsw_fdb_unicast_cfg *cfg);
0498 
0499 #define DPSW_FDB_ENTRY_TYPE_DYNAMIC  BIT(0)
0500 #define DPSW_FDB_ENTRY_TYPE_UNICAST  BIT(1)
0501 
0502 /**
0503  * struct fdb_dump_entry - fdb snapshot entry
0504  * @mac_addr: MAC address
0505  * @type: bit0 - DINAMIC(1)/STATIC(0), bit1 - UNICAST(1)/MULTICAST(0)
0506  * @if_info: unicast - egress interface, multicast - number of egress interfaces
0507  * @if_mask: multicast - egress interface mask
0508  */
0509 struct fdb_dump_entry {
0510     u8 mac_addr[6];
0511     u8 type;
0512     u8 if_info;
0513     u8 if_mask[8];
0514 };
0515 
0516 int dpsw_fdb_dump(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u16 fdb_id,
0517           u64 iova_addr, u32 iova_size, u16 *num_entries);
0518 
0519 /**
0520  * struct dpsw_fdb_multicast_cfg - Multi-cast entry configuration
0521  * @type: Select static or dynamic entry
0522  * @mac_addr: MAC address
0523  * @num_ifs: Number of external and internal interfaces
0524  * @if_id: Egress interface IDs
0525  */
0526 struct dpsw_fdb_multicast_cfg {
0527     enum dpsw_fdb_entry_type type;
0528     u8 mac_addr[6];
0529     u16 num_ifs;
0530     u16 if_id[DPSW_MAX_IF];
0531 };
0532 
0533 int dpsw_fdb_add_multicast(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0534                u16 fdb_id, const struct dpsw_fdb_multicast_cfg *cfg);
0535 
0536 int dpsw_fdb_remove_multicast(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0537                   u16 fdb_id, const struct dpsw_fdb_multicast_cfg *cfg);
0538 
0539 /**
0540  * enum dpsw_learning_mode - Auto-learning modes
0541  * @DPSW_LEARNING_MODE_DIS: Disable Auto-learning
0542  * @DPSW_LEARNING_MODE_HW: Enable HW auto-Learning
0543  * @DPSW_LEARNING_MODE_NON_SECURE: Enable None secure learning by CPU
0544  * @DPSW_LEARNING_MODE_SECURE: Enable secure learning by CPU
0545  *
0546  *  NONE - SECURE LEARNING
0547  *  SMAC found  DMAC found  CTLU Action
0548  *  v       v   Forward frame to
0549  *                      1.  DMAC destination
0550  *  -       v   Forward frame to
0551  *                      1.  DMAC destination
0552  *                      2.  Control interface
0553  *  v       -   Forward frame to
0554  *                      1.  Flooding list of interfaces
0555  *  -       -   Forward frame to
0556  *                      1.  Flooding list of interfaces
0557  *                      2.  Control interface
0558  *  SECURE LEARING
0559  *  SMAC found  DMAC found  CTLU Action
0560  *  v       v       Forward frame to
0561  *                      1.  DMAC destination
0562  *  -       v       Forward frame to
0563  *                      1.  Control interface
0564  *  v       -       Forward frame to
0565  *                      1.  Flooding list of interfaces
0566  *  -       -       Forward frame to
0567  *                      1.  Control interface
0568  */
0569 enum dpsw_learning_mode {
0570     DPSW_LEARNING_MODE_DIS = 0,
0571     DPSW_LEARNING_MODE_HW = 1,
0572     DPSW_LEARNING_MODE_NON_SECURE = 2,
0573     DPSW_LEARNING_MODE_SECURE = 3
0574 };
0575 
0576 /**
0577  * struct dpsw_fdb_attr - FDB Attributes
0578  * @max_fdb_entries: Number of FDB entries
0579  * @fdb_ageing_time: Ageing time in seconds
0580  * @learning_mode: Learning mode
0581  * @num_fdb_mc_groups: Current number of multicast groups
0582  * @max_fdb_mc_groups: Maximum number of multicast groups
0583  */
0584 struct dpsw_fdb_attr {
0585     u16 max_fdb_entries;
0586     u16 fdb_ageing_time;
0587     enum dpsw_learning_mode learning_mode;
0588     u16 num_fdb_mc_groups;
0589     u16 max_fdb_mc_groups;
0590 };
0591 
0592 int dpsw_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags,
0593              u16 *major_ver, u16 *minor_ver);
0594 
0595 int dpsw_if_get_port_mac_addr(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0596                   u16 if_id, u8 mac_addr[6]);
0597 
0598 /**
0599  * struct dpsw_fdb_cfg  - FDB Configuration
0600  * @num_fdb_entries: Number of FDB entries
0601  * @fdb_ageing_time: Ageing time in seconds
0602  */
0603 struct dpsw_fdb_cfg {
0604     u16 num_fdb_entries;
0605     u16 fdb_ageing_time;
0606 };
0607 
0608 int dpsw_fdb_add(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u16 *fdb_id,
0609          const struct dpsw_fdb_cfg *cfg);
0610 
0611 int dpsw_fdb_remove(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u16 fdb_id);
0612 
0613 /**
0614  * enum dpsw_flood_type - Define the flood type of a DPSW object
0615  * @DPSW_BROADCAST: Broadcast flooding
0616  * @DPSW_FLOODING: Unknown flooding
0617  */
0618 enum dpsw_flood_type {
0619     DPSW_BROADCAST = 0,
0620     DPSW_FLOODING,
0621 };
0622 
0623 struct dpsw_egress_flood_cfg {
0624     u16 fdb_id;
0625     enum dpsw_flood_type flood_type;
0626     u16 num_ifs;
0627     u16 if_id[DPSW_MAX_IF];
0628 };
0629 
0630 int dpsw_set_egress_flood(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0631               const struct dpsw_egress_flood_cfg *cfg);
0632 
0633 int dpsw_if_set_learning_mode(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0634                   u16 if_id, enum dpsw_learning_mode mode);
0635 
0636 /**
0637  * struct dpsw_acl_cfg - ACL Configuration
0638  * @max_entries: Number of ACL rules
0639  */
0640 struct dpsw_acl_cfg {
0641     u16 max_entries;
0642 };
0643 
0644 int dpsw_acl_add(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, u16 *acl_id,
0645          const struct dpsw_acl_cfg *cfg);
0646 
0647 int dpsw_acl_remove(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0648             u16 acl_id);
0649 
0650 /**
0651  * struct dpsw_acl_if_cfg - List of interfaces to associate with an ACL table
0652  * @num_ifs: Number of interfaces
0653  * @if_id: List of interfaces
0654  */
0655 struct dpsw_acl_if_cfg {
0656     u16 num_ifs;
0657     u16 if_id[DPSW_MAX_IF];
0658 };
0659 
0660 int dpsw_acl_add_if(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0661             u16 acl_id, const struct dpsw_acl_if_cfg *cfg);
0662 
0663 int dpsw_acl_remove_if(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0664                u16 acl_id, const struct dpsw_acl_if_cfg *cfg);
0665 
0666 /**
0667  * struct dpsw_acl_fields - ACL fields.
0668  * @l2_dest_mac: Destination MAC address: BPDU, Multicast, Broadcast, Unicast,
0669  *          slow protocols, MVRP, STP
0670  * @l2_source_mac: Source MAC address
0671  * @l2_tpid: Layer 2 (Ethernet) protocol type, used to identify the following
0672  *      protocols: MPLS, PTP, PFC, ARP, Jumbo frames, LLDP, IEEE802.1ae,
0673  *      Q-in-Q, IPv4, IPv6, PPPoE
0674  * @l2_pcp_dei: indicate which protocol is encapsulated in the payload
0675  * @l2_vlan_id: layer 2 VLAN ID
0676  * @l2_ether_type: layer 2 Ethernet type
0677  * @l3_dscp: Layer 3 differentiated services code point
0678  * @l3_protocol: Tells the Network layer at the destination host, to which
0679  *      Protocol this packet belongs to. The following protocol are
0680  *      supported: ICMP, IGMP, IPv4 (encapsulation), TCP, IPv6
0681  *      (encapsulation), GRE, PTP
0682  * @l3_source_ip: Source IPv4 IP
0683  * @l3_dest_ip: Destination IPv4 IP
0684  * @l4_source_port: Source TCP/UDP Port
0685  * @l4_dest_port: Destination TCP/UDP Port
0686  */
0687 struct dpsw_acl_fields {
0688     u8 l2_dest_mac[6];
0689     u8 l2_source_mac[6];
0690     u16 l2_tpid;
0691     u8 l2_pcp_dei;
0692     u16 l2_vlan_id;
0693     u16 l2_ether_type;
0694     u8 l3_dscp;
0695     u8 l3_protocol;
0696     u32 l3_source_ip;
0697     u32 l3_dest_ip;
0698     u16 l4_source_port;
0699     u16 l4_dest_port;
0700 };
0701 
0702 /**
0703  * struct dpsw_acl_key - ACL key
0704  * @match: Match fields
0705  * @mask: Mask: b'1 - valid, b'0 don't care
0706  */
0707 struct dpsw_acl_key {
0708     struct dpsw_acl_fields match;
0709     struct dpsw_acl_fields mask;
0710 };
0711 
0712 /**
0713  * enum dpsw_acl_action - action to be run on the ACL rule match
0714  * @DPSW_ACL_ACTION_DROP: Drop frame
0715  * @DPSW_ACL_ACTION_REDIRECT: Redirect to certain port
0716  * @DPSW_ACL_ACTION_ACCEPT: Accept frame
0717  * @DPSW_ACL_ACTION_REDIRECT_TO_CTRL_IF: Redirect to control interface
0718  */
0719 enum dpsw_acl_action {
0720     DPSW_ACL_ACTION_DROP,
0721     DPSW_ACL_ACTION_REDIRECT,
0722     DPSW_ACL_ACTION_ACCEPT,
0723     DPSW_ACL_ACTION_REDIRECT_TO_CTRL_IF
0724 };
0725 
0726 /**
0727  * struct dpsw_acl_result - ACL action
0728  * @action: Action should be taken when ACL entry hit
0729  * @if_id:  Interface IDs to redirect frame. Valid only if redirect selected for
0730  *       action
0731  */
0732 struct dpsw_acl_result {
0733     enum dpsw_acl_action action;
0734     u16 if_id;
0735 };
0736 
0737 /**
0738  * struct dpsw_acl_entry_cfg - ACL entry
0739  * @key_iova: I/O virtual address of DMA-able memory filled with key after call
0740  *              to dpsw_acl_prepare_entry_cfg()
0741  * @result: Required action when entry hit occurs
0742  * @precedence: Precedence inside ACL 0 is lowest; This priority can not change
0743  *      during the lifetime of a Policy. It is user responsibility to
0744  *      space the priorities according to consequent rule additions.
0745  */
0746 struct dpsw_acl_entry_cfg {
0747     u64 key_iova;
0748     struct dpsw_acl_result result;
0749     int precedence;
0750 };
0751 
0752 void dpsw_acl_prepare_entry_cfg(const struct dpsw_acl_key *key,
0753                 u8 *entry_cfg_buf);
0754 
0755 int dpsw_acl_add_entry(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0756                u16 acl_id, const struct dpsw_acl_entry_cfg *cfg);
0757 
0758 int dpsw_acl_remove_entry(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0759               u16 acl_id, const struct dpsw_acl_entry_cfg *cfg);
0760 
0761 /**
0762  * enum dpsw_reflection_filter - Filter type for frames to be reflected
0763  * @DPSW_REFLECTION_FILTER_INGRESS_ALL: Reflect all frames
0764  * @DPSW_REFLECTION_FILTER_INGRESS_VLAN: Reflect only frames that belong to
0765  *  the particular VLAN defined by vid parameter
0766  *
0767  */
0768 enum dpsw_reflection_filter {
0769     DPSW_REFLECTION_FILTER_INGRESS_ALL = 0,
0770     DPSW_REFLECTION_FILTER_INGRESS_VLAN = 1
0771 };
0772 
0773 /**
0774  * struct dpsw_reflection_cfg - Structure representing the mirroring config
0775  * @filter: Filter type for frames to be mirrored
0776  * @vlan_id: VLAN ID to mirror; valid only when the type is DPSW_INGRESS_VLAN
0777  */
0778 struct dpsw_reflection_cfg {
0779     enum dpsw_reflection_filter filter;
0780     u16 vlan_id;
0781 };
0782 
0783 int dpsw_set_reflection_if(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0784                u16 if_id);
0785 
0786 int dpsw_if_add_reflection(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0787                u16 if_id, const struct dpsw_reflection_cfg *cfg);
0788 
0789 int dpsw_if_remove_reflection(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
0790                   u16 if_id, const struct dpsw_reflection_cfg *cfg);
0791 #endif /* __FSL_DPSW_H */