1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
3 * Copyright 2013-2016 Freescale Semiconductor Inc.
4 * Copyright 2018-2021 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 * @default_if: Default interface number (different from uplink,
83 maximum value num_ifs)
84 * @adv: Advanced parameters; default is all zeros;
85 * use this structure to change default settings
86 * @adv.options: DPDMUX options - combination of 'DPDMUX_OPT_<X>' flags.
87 * @adv.max_dmat_entries: Maximum entries in DPDMUX address table
88 * 0 - indicates default: 64 entries per interface.
89 * @adv.max_mc_groups: Number of multicast groups in DPDMUX table
90 * 0 - indicates default: 32 multicast groups.
91 * @adv.max_vlan_ids: Maximum vlan ids allowed in the system -
92 * relevant only case of working in mac+vlan method.
93 * 0 - indicates default 16 vlan ids.
94 * @adv.mem_size: Size of the memory used for internal buffers expressed as
95 * number of 256byte buffers.
98 enum dpdmux_method method;
99 enum dpdmux_manip manip;
104 uint16_t max_dmat_entries;
105 uint16_t max_mc_groups;
106 uint16_t max_vlan_ids;
111 int dpdmux_create(struct fsl_mc_io *mc_io,
114 const struct dpdmux_cfg *cfg,
117 int dpdmux_destroy(struct fsl_mc_io *mc_io,
122 int dpdmux_enable(struct fsl_mc_io *mc_io,
126 int dpdmux_disable(struct fsl_mc_io *mc_io,
130 int dpdmux_is_enabled(struct fsl_mc_io *mc_io,
135 int dpdmux_reset(struct fsl_mc_io *mc_io,
140 *Setting 1 DPDMUX_RESET will not reset default interface
142 #define DPDMUX_SKIP_DEFAULT_INTERFACE 0x01
144 *Setting 1 DPDMUX_RESET will not reset unicast rules
146 #define DPDMUX_SKIP_UNICAST_RULES 0x02
148 *Setting 1 DPDMUX_RESET will not reset multicast rules
150 #define DPDMUX_SKIP_MULTICAST_RULES 0x04
152 int dpdmux_set_resetable(struct fsl_mc_io *mc_io,
155 uint8_t skip_reset_flags);
157 int dpdmux_get_resetable(struct fsl_mc_io *mc_io,
160 uint8_t *skip_reset_flags);
163 * struct dpdmux_attr - Structure representing DPDMUX attributes
164 * @id: DPDMUX object ID
165 * @options: Configuration options (bitmap)
166 * @method: DPDMUX address table method
167 * @manip: DPDMUX manipulation type
168 * @num_ifs: Number of interfaces (excluding the uplink interface)
169 * @mem_size: DPDMUX frame storage memory size
170 * @default_if: Default interface number (different from uplink,
171 maximum value num_ifs)
176 enum dpdmux_method method;
177 enum dpdmux_manip manip;
183 int dpdmux_get_attributes(struct fsl_mc_io *mc_io,
186 struct dpdmux_attr *attr);
188 int dpdmux_set_max_frame_length(struct fsl_mc_io *mc_io,
191 uint16_t max_frame_length);
194 * enum dpdmux_counter_type - Counter types
195 * @DPDMUX_CNT_ING_FRAME: Counts ingress frames
196 * @DPDMUX_CNT_ING_BYTE: Counts ingress bytes
197 * @DPDMUX_CNT_ING_FLTR_FRAME: Counts filtered ingress frames
198 * @DPDMUX_CNT_ING_FRAME_DISCARD: Counts discarded ingress frames
199 * @DPDMUX_CNT_ING_MCAST_FRAME: Counts ingress multicast frames
200 * @DPDMUX_CNT_ING_MCAST_BYTE: Counts ingress multicast bytes
201 * @DPDMUX_CNT_ING_BCAST_FRAME: Counts ingress broadcast frames
202 * @DPDMUX_CNT_ING_BCAST_BYTES: Counts ingress broadcast bytes
203 * @DPDMUX_CNT_EGR_FRAME: Counts egress frames
204 * @DPDMUX_CNT_EGR_BYTE: Counts egress bytes
205 * @DPDMUX_CNT_EGR_FRAME_DISCARD: Counts discarded egress frames
207 enum dpdmux_counter_type {
208 DPDMUX_CNT_ING_FRAME = 0x0,
209 DPDMUX_CNT_ING_BYTE = 0x1,
210 DPDMUX_CNT_ING_FLTR_FRAME = 0x2,
211 DPDMUX_CNT_ING_FRAME_DISCARD = 0x3,
212 DPDMUX_CNT_ING_MCAST_FRAME = 0x4,
213 DPDMUX_CNT_ING_MCAST_BYTE = 0x5,
214 DPDMUX_CNT_ING_BCAST_FRAME = 0x6,
215 DPDMUX_CNT_ING_BCAST_BYTES = 0x7,
216 DPDMUX_CNT_EGR_FRAME = 0x8,
217 DPDMUX_CNT_EGR_BYTE = 0x9,
218 DPDMUX_CNT_EGR_FRAME_DISCARD = 0xa
222 * enum dpdmux_accepted_frames_type - DPDMUX frame types
223 * @DPDMUX_ADMIT_ALL: The device accepts VLAN tagged, untagged and
224 * priority-tagged frames
225 * @DPDMUX_ADMIT_ONLY_VLAN_TAGGED: The device discards untagged frames or
226 * priority-tagged frames that are received on this
228 * @DPDMUX_ADMIT_ONLY_UNTAGGED: Untagged frames or priority-tagged frames
229 * received on this interface are accepted
231 enum dpdmux_accepted_frames_type {
232 DPDMUX_ADMIT_ALL = 0,
233 DPDMUX_ADMIT_ONLY_VLAN_TAGGED = 1,
234 DPDMUX_ADMIT_ONLY_UNTAGGED = 2
238 * enum dpdmux_action - DPDMUX action for un-accepted frames
239 * @DPDMUX_ACTION_DROP: Drop un-accepted frames
240 * @DPDMUX_ACTION_REDIRECT_TO_CTRL: Redirect un-accepted frames to the
244 DPDMUX_ACTION_DROP = 0,
245 DPDMUX_ACTION_REDIRECT_TO_CTRL = 1
249 * struct dpdmux_accepted_frames - Frame types configuration
250 * @type: Defines ingress accepted frames
251 * @unaccept_act: Defines action on frames not accepted
253 struct dpdmux_accepted_frames {
254 enum dpdmux_accepted_frames_type type;
255 enum dpdmux_action unaccept_act;
258 int dpdmux_if_set_accepted_frames(struct fsl_mc_io *mc_io,
262 const struct dpdmux_accepted_frames *cfg);
265 * struct dpdmux_if_attr - Structure representing frame types configuration
266 * @rate: Configured interface rate (in bits per second)
267 * @enabled: Indicates if interface is enabled
268 * @accept_frame_type: Indicates type of accepted frames for the interface
270 struct dpdmux_if_attr {
274 enum dpdmux_accepted_frames_type accept_frame_type;
277 int dpdmux_if_get_attributes(struct fsl_mc_io *mc_io,
281 struct dpdmux_if_attr *attr);
283 int dpdmux_if_enable(struct fsl_mc_io *mc_io,
288 int dpdmux_if_disable(struct fsl_mc_io *mc_io,
294 * struct dpdmux_l2_rule - Structure representing L2 rule
295 * @mac_addr: MAC address
298 struct dpdmux_l2_rule {
303 int dpdmux_if_remove_l2_rule(struct fsl_mc_io *mc_io,
307 const struct dpdmux_l2_rule *rule);
309 int dpdmux_if_add_l2_rule(struct fsl_mc_io *mc_io,
313 const struct dpdmux_l2_rule *rule);
315 int dpdmux_if_get_counter(struct fsl_mc_io *mc_io,
319 enum dpdmux_counter_type counter_type,
322 int dpdmux_ul_reset_counters(struct fsl_mc_io *mc_io,
327 * Enable auto-negotiation
329 #define DPDMUX_LINK_OPT_AUTONEG 0x0000000000000001ULL
331 * Enable half-duplex mode
333 #define DPDMUX_LINK_OPT_HALF_DUPLEX 0x0000000000000002ULL
335 * Enable pause frames
337 #define DPDMUX_LINK_OPT_PAUSE 0x0000000000000004ULL
339 * Enable a-symmetric pause frames
341 #define DPDMUX_LINK_OPT_ASYM_PAUSE 0x0000000000000008ULL
344 * struct dpdmux_link_cfg - Structure representing DPDMUX link configuration
346 * @options: Mask of available options; use 'DPDMUX_LINK_OPT_<X>' values
348 struct dpdmux_link_cfg {
351 uint64_t advertising;
354 int dpdmux_if_set_link_cfg(struct fsl_mc_io *mc_io,
358 struct dpdmux_link_cfg *cfg);
360 * struct dpdmux_link_state - Structure representing DPDMUX link state
362 * @options: Mask of available options; use 'DPDMUX_LINK_OPT_<X>' values
363 * @up: 0 - down, 1 - up
364 * @state_valid: Ignore/Update the state of the link
365 * @supported: Speeds capability of the phy (bitmap)
366 * @advertising: Speeds that are advertised for autoneg (bitmap)
368 struct dpdmux_link_state {
374 uint64_t advertising;
377 int dpdmux_if_get_link_state(struct fsl_mc_io *mc_io,
381 struct dpdmux_link_state *state);
383 int dpdmux_if_set_default(struct fsl_mc_io *mc_io,
388 int dpdmux_if_get_default(struct fsl_mc_io *mc_io,
393 int dpdmux_set_custom_key(struct fsl_mc_io *mc_io,
396 uint64_t key_cfg_iova);
399 * struct dpdmux_rule_cfg - Custom classification rule.
401 * @key_iova: DMA address of buffer storing the look-up value
402 * @mask_iova: DMA address of the mask used for TCAM classification. This
403 * parameter is used only if dpdmux was created using option
404 * DPDMUX_OPT_CLS_MASK_SUPPORT.
405 * @key_size: size, in bytes, of the look-up value. This must match the size
406 * of the look-up key defined using dpdmux_set_custom_key, otherwise the
407 * entry will never be hit
408 * @entry_index: rule index into the table. This parameter is used only when
409 * dpdmux object was created using option DPDMUX_OPT_CLS_MASK_SUPPORT. In
410 * this case the rule is masking and the current frame may be a hit for
411 * multiple rules. This parameter determines the order in which the rules
412 * will be checked (smaller entry_index first).
414 struct dpdmux_rule_cfg {
418 uint16_t entry_index;
422 * struct dpdmux_cls_action - Action to execute for frames matching the
423 * classification entry
425 * @dest_if: Interface to forward the frames to. Port numbering is similar to
426 * the one used to connect interfaces:
427 * - 0 is the uplink port,
428 * - all others are downlink ports.
430 struct dpdmux_cls_action {
434 int dpdmux_add_custom_cls_entry(struct fsl_mc_io *mc_io,
437 struct dpdmux_rule_cfg *rule,
438 struct dpdmux_cls_action *action);
440 int dpdmux_remove_custom_cls_entry(struct fsl_mc_io *mc_io,
443 struct dpdmux_rule_cfg *rule);
445 int dpdmux_get_api_version(struct fsl_mc_io *mc_io,
448 uint16_t *minor_ver);
450 #endif /* __FSL_DPDMUX_H */