1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
3 * Copyright 2013-2016 Freescale Semiconductor Inc.
4 * Copyright 2018-2019 NXP
14 /** @addtogroup dpdmux Data Path Demux API
15 * Contains API for handling DPDMUX topology and functionality
19 int dpdmux_open(struct fsl_mc_io *mc_io,
24 int dpdmux_close(struct fsl_mc_io *mc_io,
29 * DPDMUX general options
33 * Enable bridging between internal interfaces
35 #define DPDMUX_OPT_BRIDGE_EN 0x0000000000000002ULL
38 * Mask support for classification
40 #define DPDMUX_OPT_CLS_MASK_SUPPORT 0x0000000000000020ULL
42 #define DPDMUX_IRQ_INDEX_IF 0x0000
43 #define DPDMUX_IRQ_INDEX 0x0001
46 * IRQ event - Indicates that the link state changed
48 #define DPDMUX_IRQ_EVENT_LINK_CHANGED 0x0001
51 * enum dpdmux_manip - DPDMUX manipulation operations
52 * @DPDMUX_MANIP_NONE: No manipulation on frames
53 * @DPDMUX_MANIP_ADD_REMOVE_S_VLAN: Add S-VLAN on egress, remove it on ingress
56 DPDMUX_MANIP_NONE = 0x0,
57 DPDMUX_MANIP_ADD_REMOVE_S_VLAN = 0x1
61 * enum dpdmux_method - DPDMUX method options
62 * @DPDMUX_METHOD_NONE: no DPDMUX method
63 * @DPDMUX_METHOD_C_VLAN_MAC: DPDMUX based on C-VLAN and MAC address
64 * @DPDMUX_METHOD_MAC: DPDMUX based on MAC address
65 * @DPDMUX_METHOD_C_VLAN: DPDMUX based on C-VLAN
66 * @DPDMUX_METHOD_S_VLAN: DPDMUX based on S-VLAN
69 DPDMUX_METHOD_NONE = 0x0,
70 DPDMUX_METHOD_C_VLAN_MAC = 0x1,
71 DPDMUX_METHOD_MAC = 0x2,
72 DPDMUX_METHOD_C_VLAN = 0x3,
73 DPDMUX_METHOD_S_VLAN = 0x4,
74 DPDMUX_METHOD_CUSTOM = 0x5,
78 * struct dpdmux_cfg - DPDMUX configuration parameters
79 * @method: Defines the operation method for the DPDMUX address table
80 * @manip: Required manipulation operation
81 * @num_ifs: Number of interfaces (excluding the uplink interface)
82 * @adv: Advanced parameters; default is all zeros;
83 * use this structure to change default settings
84 * @adv.options: DPDMUX options - combination of 'DPDMUX_OPT_<X>' flags.
85 * @adv.max_dmat_entries: Maximum entries in DPDMUX address table
86 * 0 - indicates default: 64 entries per interface.
87 * @adv.max_mc_groups: Number of multicast groups in DPDMUX table
88 * 0 - indicates default: 32 multicast groups.
89 * @adv.max_vlan_ids: Maximum vlan ids allowed in the system -
90 * relevant only case of working in mac+vlan method.
91 * 0 - indicates default 16 vlan ids.
94 enum dpdmux_method method;
95 enum dpdmux_manip manip;
99 uint16_t max_dmat_entries;
100 uint16_t max_mc_groups;
101 uint16_t max_vlan_ids;
105 int dpdmux_create(struct fsl_mc_io *mc_io,
108 const struct dpdmux_cfg *cfg,
111 int dpdmux_destroy(struct fsl_mc_io *mc_io,
116 int dpdmux_enable(struct fsl_mc_io *mc_io,
120 int dpdmux_disable(struct fsl_mc_io *mc_io,
124 int dpdmux_is_enabled(struct fsl_mc_io *mc_io,
129 int dpdmux_reset(struct fsl_mc_io *mc_io,
134 * struct dpdmux_attr - Structure representing DPDMUX attributes
135 * @id: DPDMUX object ID
136 * @options: Configuration options (bitmap)
137 * @method: DPDMUX address table method
138 * @manip: DPDMUX manipulation type
139 * @num_ifs: Number of interfaces (excluding the uplink interface)
140 * @mem_size: DPDMUX frame storage memory size
145 enum dpdmux_method method;
146 enum dpdmux_manip manip;
151 int dpdmux_get_attributes(struct fsl_mc_io *mc_io,
154 struct dpdmux_attr *attr);
156 int dpdmux_set_max_frame_length(struct fsl_mc_io *mc_io,
159 uint16_t max_frame_length);
162 * enum dpdmux_counter_type - Counter types
163 * @DPDMUX_CNT_ING_FRAME: Counts ingress frames
164 * @DPDMUX_CNT_ING_BYTE: Counts ingress bytes
165 * @DPDMUX_CNT_ING_FLTR_FRAME: Counts filtered ingress frames
166 * @DPDMUX_CNT_ING_FRAME_DISCARD: Counts discarded ingress frames
167 * @DPDMUX_CNT_ING_MCAST_FRAME: Counts ingress multicast frames
168 * @DPDMUX_CNT_ING_MCAST_BYTE: Counts ingress multicast bytes
169 * @DPDMUX_CNT_ING_BCAST_FRAME: Counts ingress broadcast frames
170 * @DPDMUX_CNT_ING_BCAST_BYTES: Counts ingress broadcast bytes
171 * @DPDMUX_CNT_EGR_FRAME: Counts egress frames
172 * @DPDMUX_CNT_EGR_BYTE: Counts egress bytes
173 * @DPDMUX_CNT_EGR_FRAME_DISCARD: Counts discarded egress frames
175 enum dpdmux_counter_type {
176 DPDMUX_CNT_ING_FRAME = 0x0,
177 DPDMUX_CNT_ING_BYTE = 0x1,
178 DPDMUX_CNT_ING_FLTR_FRAME = 0x2,
179 DPDMUX_CNT_ING_FRAME_DISCARD = 0x3,
180 DPDMUX_CNT_ING_MCAST_FRAME = 0x4,
181 DPDMUX_CNT_ING_MCAST_BYTE = 0x5,
182 DPDMUX_CNT_ING_BCAST_FRAME = 0x6,
183 DPDMUX_CNT_ING_BCAST_BYTES = 0x7,
184 DPDMUX_CNT_EGR_FRAME = 0x8,
185 DPDMUX_CNT_EGR_BYTE = 0x9,
186 DPDMUX_CNT_EGR_FRAME_DISCARD = 0xa
190 * enum dpdmux_accepted_frames_type - DPDMUX frame types
191 * @DPDMUX_ADMIT_ALL: The device accepts VLAN tagged, untagged and
192 * priority-tagged frames
193 * @DPDMUX_ADMIT_ONLY_VLAN_TAGGED: The device discards untagged frames or
194 * priority-tagged frames that are received on this
196 * @DPDMUX_ADMIT_ONLY_UNTAGGED: Untagged frames or priority-tagged frames
197 * received on this interface are accepted
199 enum dpdmux_accepted_frames_type {
200 DPDMUX_ADMIT_ALL = 0,
201 DPDMUX_ADMIT_ONLY_VLAN_TAGGED = 1,
202 DPDMUX_ADMIT_ONLY_UNTAGGED = 2
206 * enum dpdmux_action - DPDMUX action for un-accepted frames
207 * @DPDMUX_ACTION_DROP: Drop un-accepted frames
208 * @DPDMUX_ACTION_REDIRECT_TO_CTRL: Redirect un-accepted frames to the
212 DPDMUX_ACTION_DROP = 0,
213 DPDMUX_ACTION_REDIRECT_TO_CTRL = 1
217 * struct dpdmux_accepted_frames - Frame types configuration
218 * @type: Defines ingress accepted frames
219 * @unaccept_act: Defines action on frames not accepted
221 struct dpdmux_accepted_frames {
222 enum dpdmux_accepted_frames_type type;
223 enum dpdmux_action unaccept_act;
226 int dpdmux_if_set_accepted_frames(struct fsl_mc_io *mc_io,
230 const struct dpdmux_accepted_frames *cfg);
233 * struct dpdmux_if_attr - Structure representing frame types configuration
234 * @rate: Configured interface rate (in bits per second)
235 * @enabled: Indicates if interface is enabled
236 * @accept_frame_type: Indicates type of accepted frames for the interface
238 struct dpdmux_if_attr {
242 enum dpdmux_accepted_frames_type accept_frame_type;
245 int dpdmux_if_get_attributes(struct fsl_mc_io *mc_io,
249 struct dpdmux_if_attr *attr);
251 int dpdmux_if_enable(struct fsl_mc_io *mc_io,
256 int dpdmux_if_disable(struct fsl_mc_io *mc_io,
262 * struct dpdmux_l2_rule - Structure representing L2 rule
263 * @mac_addr: MAC address
266 struct dpdmux_l2_rule {
271 int dpdmux_if_remove_l2_rule(struct fsl_mc_io *mc_io,
275 const struct dpdmux_l2_rule *rule);
277 int dpdmux_if_add_l2_rule(struct fsl_mc_io *mc_io,
281 const struct dpdmux_l2_rule *rule);
283 int dpdmux_if_get_counter(struct fsl_mc_io *mc_io,
287 enum dpdmux_counter_type counter_type,
290 int dpdmux_ul_reset_counters(struct fsl_mc_io *mc_io,
295 * Enable auto-negotiation
297 #define DPDMUX_LINK_OPT_AUTONEG 0x0000000000000001ULL
299 * Enable half-duplex mode
301 #define DPDMUX_LINK_OPT_HALF_DUPLEX 0x0000000000000002ULL
303 * Enable pause frames
305 #define DPDMUX_LINK_OPT_PAUSE 0x0000000000000004ULL
307 * Enable a-symmetric pause frames
309 #define DPDMUX_LINK_OPT_ASYM_PAUSE 0x0000000000000008ULL
312 * struct dpdmux_link_cfg - Structure representing DPDMUX link configuration
314 * @options: Mask of available options; use 'DPDMUX_LINK_OPT_<X>' values
316 struct dpdmux_link_cfg {
319 uint64_t advertising;
322 int dpdmux_if_set_link_cfg(struct fsl_mc_io *mc_io,
326 struct dpdmux_link_cfg *cfg);
328 * struct dpdmux_link_state - Structure representing DPDMUX link state
330 * @options: Mask of available options; use 'DPDMUX_LINK_OPT_<X>' values
331 * @up: 0 - down, 1 - up
332 * @state_valid: Ignore/Update the state of the link
333 * @supported: Speeds capability of the phy (bitmap)
334 * @advertising: Speeds that are advertised for autoneg (bitmap)
336 struct dpdmux_link_state {
342 uint64_t advertising;
345 int dpdmux_if_get_link_state(struct fsl_mc_io *mc_io,
349 struct dpdmux_link_state *state);
351 int dpdmux_if_set_default(struct fsl_mc_io *mc_io,
356 int dpdmux_if_get_default(struct fsl_mc_io *mc_io,
361 int dpdmux_set_custom_key(struct fsl_mc_io *mc_io,
364 uint64_t key_cfg_iova);
367 * struct dpdmux_rule_cfg - Custom classification rule.
369 * @key_iova: DMA address of buffer storing the look-up value
370 * @mask_iova: DMA address of the mask used for TCAM classification
371 * @key_size: size, in bytes, of the look-up value. This must match the size
372 * of the look-up key defined using dpdmux_set_custom_key, otherwise the
373 * entry will never be hit
375 struct dpdmux_rule_cfg {
382 * struct dpdmux_cls_action - Action to execute for frames matching the
383 * classification entry
385 * @dest_if: Interface to forward the frames to. Port numbering is similar to
386 * the one used to connect interfaces:
387 * - 0 is the uplink port,
388 * - all others are downlink ports.
390 struct dpdmux_cls_action {
394 int dpdmux_add_custom_cls_entry(struct fsl_mc_io *mc_io,
397 struct dpdmux_rule_cfg *rule,
398 struct dpdmux_cls_action *action);
400 int dpdmux_remove_custom_cls_entry(struct fsl_mc_io *mc_io,
403 struct dpdmux_rule_cfg *rule);
405 int dpdmux_get_api_version(struct fsl_mc_io *mc_io,
408 uint16_t *minor_ver);
410 #endif /* __FSL_DPDMUX_H */