2 * This file is provided under a dual BSD/GPLv2 license. When using or
3 * redistributing this file, you may do so under either license.
7 * Copyright 2013-2016 Freescale Semiconductor Inc.
8 * Copyright (c) 2016 NXP.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met:
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * * Neither the name of the above-listed copyright holders nor the
18 * names of any contributors may be used to endorse or promote products
19 * derived from this software without specific prior written permission.
23 * ALTERNATIVELY, this software may be distributed under the terms of the
24 * GNU General Public License ("GPL") as published by the Free Software
25 * Foundation, either version 2 of that License or (at your option) any
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
32 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 * POSSIBILITY OF SUCH DAMAGE.
48 * Data Path Network Interface API
49 * Contains initialization APIs and runtime control APIs for DPNI
52 /** General DPNI macros */
55 * Maximum number of traffic classes
59 * Maximum number of buffer pools per DPNI
61 #define DPNI_MAX_DPBP 8
63 * Maximum number of storage-profiles per DPNI
68 * All traffic classes considered; see dpni_set_queue()
70 #define DPNI_ALL_TCS (uint8_t)(-1)
72 * All flows within traffic class considered; see dpni_set_queue()
74 #define DPNI_ALL_TC_FLOWS (uint16_t)(-1)
76 * Generate new flow ID; see dpni_set_queue()
78 #define DPNI_NEW_FLOW_ID (uint16_t)(-1)
80 * Tx traffic is always released to a buffer pool on transmit, there are no
81 * resources allocated to have the frames confirmed back to the source after
84 #define DPNI_OPT_TX_FRM_RELEASE 0x000001
86 * Disables support for MAC address filtering for addresses other than primary
87 * MAC address. This affects both unicast and multicast. Promiscuous mode can
88 * still be enabled/disabled for both unicast and multicast. If promiscuous mode
89 * is disabled, only traffic matching the primary MAC address will be accepted.
91 #define DPNI_OPT_NO_MAC_FILTER 0x000002
93 * Allocate policers for this DPNI. They can be used to rate-limit traffic per
94 * traffic class (TC) basis.
96 #define DPNI_OPT_HAS_POLICING 0x000004
98 * Congestion can be managed in several ways, allowing the buffer pool to
99 * deplete on ingress, taildrop on each queue or use congestion groups for sets
100 * of queues. If set, it configures a single congestion groups across all TCs.
101 * If reset, a congestion group is allocated for each TC. Only relevant if the
102 * DPNI has multiple traffic classes.
104 #define DPNI_OPT_SHARED_CONGESTION 0x000008
106 * Enables TCAM for Flow Steering and QoS look-ups. If not specified, all
107 * look-ups are exact match. Note that TCAM is not available on LS1088 and its
108 * variants. Setting this bit on these SoCs will trigger an error.
110 #define DPNI_OPT_HAS_KEY_MASKING 0x000010
112 * Disables the flow steering table.
114 #define DPNI_OPT_NO_FS 0x000020
117 * dpni_open() - Open a control session for the specified object
118 * @mc_io: Pointer to MC portal's I/O object
119 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
120 * @dpni_id: DPNI unique ID
121 * @token: Returned token; use in subsequent API calls
123 * This function can be used to open a control session for an
124 * already created object; an object may have been declared in
125 * the DPL or by calling the dpni_create() function.
126 * This function returns a unique authentication token,
127 * associated with the specific object ID and the specific MC
128 * portal; this token must be used in all subsequent commands for
129 * this specific object.
131 * Return: '0' on Success; Error code otherwise.
133 int dpni_open(struct fsl_mc_io *mc_io,
139 * dpni_close() - Close the control session of the object
140 * @mc_io: Pointer to MC portal's I/O object
141 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
142 * @token: Token of DPNI object
144 * After this function is called, no further operations are
145 * allowed on the object without opening a new control session.
147 * Return: '0' on Success; Error code otherwise.
149 int dpni_close(struct fsl_mc_io *mc_io,
154 * struct dpni_cfg - Structure representing DPNI configuration
155 * @mac_addr: Primary MAC address
156 * @adv: Advanced parameters; default is all zeros;
157 * use this structure to change default settings
161 * @options: Any combination of the following options:
162 * DPNI_OPT_TX_FRM_RELEASE
163 * DPNI_OPT_NO_MAC_FILTER
164 * DPNI_OPT_HAS_POLICING
165 * DPNI_OPT_SHARED_CONGESTION
166 * DPNI_OPT_HAS_KEY_MASKING
168 * @fs_entries: Number of entries in the flow steering table.
169 * This table is used to select the ingress queue for
170 * ingress traffic, targeting a GPP core or another.
171 * In addition it can be used to discard traffic that
172 * matches the set rule. It is either an exact match table
173 * or a TCAM table, depending on DPNI_OPT_ HAS_KEY_MASKING
174 * bit in OPTIONS field. This field is ignored if
175 * DPNI_OPT_NO_FS bit is set in OPTIONS field. Otherwise,
176 * value 0 defaults to 64. Maximum supported value is 1024.
177 * Note that the total number of entries is limited on the
178 * SoC to as low as 512 entries if TCAM is used.
179 * @vlan_filter_entries: Number of entries in the VLAN address filtering
180 * table. This is an exact match table used to filter
181 * ingress traffic based on VLAN IDs. Value 0 disables VLAN
182 * filtering. Maximum supported value is 16.
183 * @mac_filter_entries: Number of entries in the MAC address filtering
184 * table. This is an exact match table and allows both
185 * unicast and multicast entries. The primary MAC address
186 * of the network interface is not part of this table,
187 * this contains only entries in addition to it. This
188 * field is ignored if DPNI_OPT_ NO_MAC_FILTER is set in
189 * OPTIONS field. Otherwise, value 0 defaults to 80.
190 * Maximum supported value is 80.
191 * @num_queues: Number of Tx and Rx queues used for traffic
192 * distribution. This is orthogonal to QoS and is only
193 * used to distribute traffic to multiple GPP cores.
194 * This configuration affects the number of Tx queues
195 * (logical FQs, all associated with a single CEETM queue),
196 * Rx queues and Tx confirmation queues, if applicable.
197 * Value 0 defaults to one queue. Maximum supported value
199 * @num_tcs: Number of traffic classes (TCs), reserved for the DPNI.
200 * TCs can have different priority levels for the purpose
201 * of Tx scheduling (see DPNI_SET_TX_SELECTION), different
202 * BPs (DPNI_ SET_POOLS), policers. There are dedicated QM
203 * queues for traffic classes (including class queues on
204 * Tx). Value 0 defaults to one TC. Maximum supported value
206 * @qos_entries: Number of entries in the QoS classification table. This
207 * table is used to select the TC for ingress traffic. It
208 * is either an exact match or a TCAM table, depending on
209 * DPNI_OPT_ HAS_KEY_MASKING bit in OPTIONS field. This
210 * field is ignored if the DPNI has a single TC. Otherwise,
211 * a value of 0 defaults to 64. Maximum supported value
216 uint8_t vlan_filter_entries;
217 uint8_t mac_filter_entries;
224 * dpni_create() - Create the DPNI object
225 * @mc_io: Pointer to MC portal's I/O object
226 * @dprc_token: Parent container token; '0' for default container
227 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
228 * @cfg: Configuration structure
229 * @obj_id: returned object id
231 * Create the DPNI object, allocate required resources and
232 * perform required initialization.
234 * The object can be created either by declaring it in the
235 * DPL file, or by calling this function.
237 * The function accepts an authentication token of a parent
238 * container that this object should be assigned to. The token
239 * can be '0' so the object will be assigned to the default container.
240 * The newly created object can be opened with the returned
241 * object id and using the container's associated tokens and MC portals.
243 * Return: '0' on Success; Error code otherwise.
245 int dpni_create(struct fsl_mc_io *mc_io,
248 const struct dpni_cfg *cfg,
252 * dpni_destroy() - Destroy the DPNI object and release all its resources.
253 * @mc_io: Pointer to MC portal's I/O object
254 * @dprc_token: Parent container token; '0' for default container
255 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
256 * @object_id: The object id; it must be a valid id within the container that
257 * created this object;
259 * The function accepts the authentication token of the parent container that
260 * created the object (not the one that currently owns the object). The object
261 * is searched within parent using the provided 'object_id'.
262 * All tokens to the object must be closed before calling destroy.
264 * Return: '0' on Success; error code otherwise.
266 int dpni_destroy(struct fsl_mc_io *mc_io,
272 * struct dpni_pools_cfg - Structure representing buffer pools configuration
273 * @num_dpbp: Number of DPBPs
274 * @pools: Array of buffer pools parameters; The number of valid entries
275 * must match 'num_dpbp' value
277 struct dpni_pools_cfg {
280 * struct pools - Buffer pools parameters
281 * @dpbp_id: DPBP object ID
282 * @buffer_size: Buffer size
283 * @backup_pool: Backup pool
287 uint16_t buffer_size;
289 } pools[DPNI_MAX_DPBP];
293 * dpni_set_pools() - Set buffer pools configuration
294 * @mc_io: Pointer to MC portal's I/O object
295 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
296 * @token: Token of DPNI object
297 * @cfg: Buffer pools configuration
299 * mandatory for DPNI operation
300 * warning:Allowed only when DPNI is disabled
302 * Return: '0' on Success; Error code otherwise.
304 int dpni_set_pools(struct fsl_mc_io *mc_io,
307 const struct dpni_pools_cfg *cfg);
310 * dpni_enable() - Enable the DPNI, allow sending and receiving frames.
311 * @mc_io: Pointer to MC portal's I/O object
312 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
313 * @token: Token of DPNI object
315 * Return: '0' on Success; Error code otherwise.
317 int dpni_enable(struct fsl_mc_io *mc_io,
322 * dpni_disable() - Disable the DPNI, stop sending and receiving frames.
323 * @mc_io: Pointer to MC portal's I/O object
324 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
325 * @token: Token of DPNI object
327 * Return: '0' on Success; Error code otherwise.
329 int dpni_disable(struct fsl_mc_io *mc_io,
334 * dpni_is_enabled() - Check if the DPNI is enabled.
335 * @mc_io: Pointer to MC portal's I/O object
336 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
337 * @token: Token of DPNI object
338 * @en: Returns '1' if object is enabled; '0' otherwise
340 * Return: '0' on Success; Error code otherwise.
342 int dpni_is_enabled(struct fsl_mc_io *mc_io,
348 * dpni_reset() - Reset the DPNI, returns the object to initial state.
349 * @mc_io: Pointer to MC portal's I/O object
350 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
351 * @token: Token of DPNI object
353 * Return: '0' on Success; Error code otherwise.
355 int dpni_reset(struct fsl_mc_io *mc_io,
360 * struct dpni_attr - Structure representing DPNI attributes
361 * @options: Any combination of the following options:
362 * DPNI_OPT_TX_FRM_RELEASE
363 * DPNI_OPT_NO_MAC_FILTER
364 * DPNI_OPT_HAS_POLICING
365 * DPNI_OPT_SHARED_CONGESTION
366 * DPNI_OPT_HAS_KEY_MASKING
368 * @num_queues: Number of Tx and Rx queues used for traffic distribution.
369 * @num_tcs: Number of traffic classes (TCs), reserved for the DPNI.
370 * @mac_filter_entries: Number of entries in the MAC address filtering
372 * @vlan_filter_entries: Number of entries in the VLAN address filtering
374 * @qos_entries: Number of entries in the QoS classification table.
375 * @fs_entries: Number of entries in the flow steering table.
376 * @qos_key_size: Size, in bytes, of the QoS look-up key. Defining a key larger
377 * than this when adding QoS entries will result
379 * @fs_key_size: Size, in bytes, of the flow steering look-up key. Defining a
380 * key larger than this when composing the hash + FS key
381 * will result in an error.
382 * @wriop_version: Version of WRIOP HW block.
383 * The 3 version values are stored on 6, 5, 5 bits
386 * - 0x400 - WRIOP version 1.0.0, used on LS2080 and
388 * - 0x421 - WRIOP version 1.1.1, used on LS2088 and
390 * - 0x422 - WRIOP version 1.1.2, used on LS1088 and
397 uint8_t mac_filter_entries;
398 uint8_t vlan_filter_entries;
401 uint8_t qos_key_size;
403 uint16_t wriop_version;
407 * dpni_get_attributes() - Retrieve DPNI attributes.
408 * @mc_io: Pointer to MC portal's I/O object
409 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
410 * @token: Token of DPNI object
411 * @attr: Object's attributes
413 * Return: '0' on Success; Error code otherwise.
415 int dpni_get_attributes(struct fsl_mc_io *mc_io,
418 struct dpni_attr *attr);
425 * Extract out of frame header error
427 #define DPNI_ERROR_EOFHE 0x00020000
431 #define DPNI_ERROR_FLE 0x00002000
433 * Frame physical error
435 #define DPNI_ERROR_FPE 0x00001000
437 * Parsing header error
439 #define DPNI_ERROR_PHE 0x00000020
441 * Parser L3 checksum error
443 #define DPNI_ERROR_L3CE 0x00000004
445 * Parser L3 checksum error
447 #define DPNI_ERROR_L4CE 0x00000001
450 * enum dpni_error_action - Defines DPNI behavior for errors
451 * @DPNI_ERROR_ACTION_DISCARD: Discard the frame
452 * @DPNI_ERROR_ACTION_CONTINUE: Continue with the normal flow
453 * @DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE: Send the frame to the error queue
455 enum dpni_error_action {
456 DPNI_ERROR_ACTION_DISCARD = 0,
457 DPNI_ERROR_ACTION_CONTINUE = 1,
458 DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE = 2
462 * struct dpni_error_cfg - Structure representing DPNI errors treatment
463 * @errors: Errors mask; use 'DPNI_ERROR__<X>
464 * @error_action: The desired action for the errors mask
465 * @set_frame_annotation: Set to '1' to mark the errors in frame annotation
466 * status (FAS); relevant only for the non-discard action
468 struct dpni_error_cfg {
470 enum dpni_error_action error_action;
471 int set_frame_annotation;
475 * dpni_set_errors_behavior() - Set errors behavior
476 * @mc_io: Pointer to MC portal's I/O object
477 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
478 * @token: Token of DPNI object
479 * @cfg: Errors configuration
481 * this function may be called numerous times with different
484 * Return: '0' on Success; Error code otherwise.
486 int dpni_set_errors_behavior(struct fsl_mc_io *mc_io,
489 struct dpni_error_cfg *cfg);
492 * DPNI buffer layout modification options
496 * Select to modify the time-stamp setting
498 #define DPNI_BUF_LAYOUT_OPT_TIMESTAMP 0x00000001
500 * Select to modify the parser-result setting; not applicable for Tx
502 #define DPNI_BUF_LAYOUT_OPT_PARSER_RESULT 0x00000002
504 * Select to modify the frame-status setting
506 #define DPNI_BUF_LAYOUT_OPT_FRAME_STATUS 0x00000004
508 * Select to modify the private-data-size setting
510 #define DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE 0x00000008
512 * Select to modify the data-alignment setting
514 #define DPNI_BUF_LAYOUT_OPT_DATA_ALIGN 0x00000010
516 * Select to modify the data-head-room setting
518 #define DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM 0x00000020
520 * Select to modify the data-tail-room setting
522 #define DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM 0x00000040
525 * struct dpni_buffer_layout - Structure representing DPNI buffer layout
526 * @options: Flags representing the suggested modifications to the buffer
527 * layout; Use any combination of 'DPNI_BUF_LAYOUT_OPT_<X>' flags
528 * @pass_timestamp: Pass timestamp value
529 * @pass_parser_result: Pass parser results
530 * @pass_frame_status: Pass frame status
531 * @private_data_size: Size kept for private data (in bytes)
532 * @data_align: Data alignment
533 * @data_head_room: Data head room
534 * @data_tail_room: Data tail room
536 struct dpni_buffer_layout {
539 int pass_parser_result;
540 int pass_frame_status;
541 uint16_t private_data_size;
543 uint16_t data_head_room;
544 uint16_t data_tail_room;
548 * enum dpni_queue_type - Identifies a type of queue targeted by the command
549 * @DPNI_QUEUE_RX: Rx queue
550 * @DPNI_QUEUE_TX: Tx queue
551 * @DPNI_QUEUE_TX_CONFIRM: Tx confirmation queue
552 * @DPNI_QUEUE_RX_ERR: Rx error queue
553 */enum dpni_queue_type {
556 DPNI_QUEUE_TX_CONFIRM,
561 * dpni_get_buffer_layout() - Retrieve buffer layout attributes.
562 * @mc_io: Pointer to MC portal's I/O object
563 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
564 * @token: Token of DPNI object
565 * @qtype: Type of queue to get the layout from
566 * @layout: Returns buffer layout attributes
568 * Return: '0' on Success; Error code otherwise.
570 int dpni_get_buffer_layout(struct fsl_mc_io *mc_io,
573 enum dpni_queue_type qtype,
574 struct dpni_buffer_layout *layout);
577 * dpni_set_buffer_layout() - Set buffer layout configuration.
578 * @mc_io: Pointer to MC portal's I/O object
579 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
580 * @token: Token of DPNI object
581 * @qtype: Type of queue to set layout on
582 * @layout: Buffer layout configuration
584 * Return: '0' on Success; Error code otherwise.
586 * @warning Allowed only when DPNI is disabled
588 int dpni_set_buffer_layout(struct fsl_mc_io *mc_io,
591 enum dpni_queue_type qtype,
592 const struct dpni_buffer_layout *layout);
595 * enum dpni_offload - Identifies a type of offload targeted by the command
596 * @DPNI_OFF_RX_L3_CSUM: Rx L3 checksum validation
597 * @DPNI_OFF_RX_L4_CSUM: Rx L4 checksum validation
598 * @DPNI_OFF_TX_L3_CSUM: Tx L3 checksum generation
599 * @DPNI_OFF_TX_L4_CSUM: Tx L4 checksum generation
609 * dpni_set_offload() - Set DPNI offload configuration.
610 * @mc_io: Pointer to MC portal's I/O object
611 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
612 * @token: Token of DPNI object
613 * @type: Type of DPNI offload
614 * @config: Offload configuration.
615 * For checksum offloads, non-zero value enables
618 * Return: '0' on Success; Error code otherwise.
620 * @warning Allowed only when DPNI is disabled
622 int dpni_set_offload(struct fsl_mc_io *mc_io,
625 enum dpni_offload type,
629 * dpni_get_offload() - Get DPNI offload configuration.
630 * @mc_io: Pointer to MC portal's I/O object
631 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
632 * @token: Token of DPNI object
633 * @type: Type of DPNI offload
634 * @config: Offload configuration.
635 * For checksum offloads, a value of 1 indicates that the
636 * offload is enabled.
638 * Return: '0' on Success; Error code otherwise.
640 * @warning Allowed only when DPNI is disabled
642 int dpni_get_offload(struct fsl_mc_io *mc_io,
645 enum dpni_offload type,
649 * dpni_get_qdid() - Get the Queuing Destination ID (QDID) that should be used
650 * for enqueue operations
651 * @mc_io: Pointer to MC portal's I/O object
652 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
653 * @token: Token of DPNI object
654 * @qtype: Type of queue to get QDID for. For applications lookig to
655 * transmit traffic this should be set to DPNI_QUEUE_TX
656 * @qdid: Returned virtual QDID value that should be used as an argument
657 * in all enqueue operations
659 * Return: '0' on Success; Error code otherwise.
661 int dpni_get_qdid(struct fsl_mc_io *mc_io,
664 enum dpni_queue_type qtype,
667 #define DPNI_STATISTICS_CNT 7
669 union dpni_statistics {
671 * struct page_0 - Page_0 statistics structure
672 * @ingress_all_frames: Ingress frame count
673 * @ingress_all_bytes: Ingress byte count
674 * @ingress_multicast_frames: Ingress multicast frame count
675 * @ingress_multicast_bytes: Ingress multicast byte count
676 * @ingress_broadcast_frames: Ingress broadcast frame count
677 * @ingress_broadcast_bytes: Ingress broadcast byte count
680 uint64_t ingress_all_frames;
681 uint64_t ingress_all_bytes;
682 uint64_t ingress_multicast_frames;
683 uint64_t ingress_multicast_bytes;
684 uint64_t ingress_broadcast_frames;
685 uint64_t ingress_broadcast_bytes;
688 * struct page_1 - Page_1 statistics structure
689 * @egress_all_frames: Egress frame count
690 * @egress_all_bytes: Egress byte count
691 * @egress_multicast_frames: Egress multicast frame count
692 * @egress_multicast_bytes: Egress multicast byte count
693 * @egress_broadcast_frames: Egress broadcast frame count
694 * @egress_broadcast_bytes: Egress broadcast byte count
697 uint64_t egress_all_frames;
698 uint64_t egress_all_bytes;
699 uint64_t egress_multicast_frames;
700 uint64_t egress_multicast_bytes;
701 uint64_t egress_broadcast_frames;
702 uint64_t egress_broadcast_bytes;
705 * struct page_2 - Page_2 statistics structure
706 * @ingress_filtered_frames: Ingress filtered frame count
707 * @ingress_discarded_frames: Ingress discarded frame count
708 * @ingress_nobuffer_discards: Ingress discarded frame count due to
710 * @egress_discarded_frames: Egress discarded frame count
711 * @egress_confirmed_frames: Egress confirmed frame count
714 uint64_t ingress_filtered_frames;
715 uint64_t ingress_discarded_frames;
716 uint64_t ingress_nobuffer_discards;
717 uint64_t egress_discarded_frames;
718 uint64_t egress_confirmed_frames;
721 * struct raw - raw statistics structure, used to index counters
724 uint64_t counter[DPNI_STATISTICS_CNT];
729 * Enable auto-negotiation
731 #define DPNI_LINK_OPT_AUTONEG 0x0000000000000001ULL
733 * Enable half-duplex mode
735 #define DPNI_LINK_OPT_HALF_DUPLEX 0x0000000000000002ULL
737 * Enable pause frames
739 #define DPNI_LINK_OPT_PAUSE 0x0000000000000004ULL
741 * Enable a-symmetric pause frames
743 #define DPNI_LINK_OPT_ASYM_PAUSE 0x0000000000000008ULL
746 * struct dpni_link_state - Structure representing DPNI link state
748 * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
749 * @up: Link state; '0' for down, '1' for up
751 struct dpni_link_state {
758 * dpni_get_link_state() - Return the link state (either up or down)
759 * @mc_io: Pointer to MC portal's I/O object
760 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
761 * @token: Token of DPNI object
762 * @state: Returned link state;
764 * Return: '0' on Success; Error code otherwise.
766 int dpni_get_link_state(struct fsl_mc_io *mc_io,
769 struct dpni_link_state *state);
772 * dpni_set_max_frame_length() - Set the maximum received frame length.
773 * @mc_io: Pointer to MC portal's I/O object
774 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
775 * @token: Token of DPNI object
776 * @max_frame_length: Maximum received frame length (in
777 * bytes); frame is discarded if its
778 * length exceeds this value
780 * Return: '0' on Success; Error code otherwise.
782 int dpni_set_max_frame_length(struct fsl_mc_io *mc_io,
785 uint16_t max_frame_length);
788 * dpni_get_max_frame_length() - Get the maximum received frame length.
789 * @mc_io: Pointer to MC portal's I/O object
790 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
791 * @token: Token of DPNI object
792 * @max_frame_length: Maximum received frame length (in
793 * bytes); frame is discarded if its
794 * length exceeds this value
796 * Return: '0' on Success; Error code otherwise.
798 int dpni_get_max_frame_length(struct fsl_mc_io *mc_io,
801 uint16_t *max_frame_length);
805 * dpni_set_unicast_promisc() - Enable/disable unicast promiscuous mode
806 * @mc_io: Pointer to MC portal's I/O object
807 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
808 * @token: Token of DPNI object
809 * @en: Set to '1' to enable; '0' to disable
811 * Return: '0' on Success; Error code otherwise.
813 int dpni_set_unicast_promisc(struct fsl_mc_io *mc_io,
819 * dpni_get_unicast_promisc() - Get unicast promiscuous mode
820 * @mc_io: Pointer to MC portal's I/O object
821 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
822 * @token: Token of DPNI object
823 * @en: Returns '1' if enabled; '0' otherwise
825 * Return: '0' on Success; Error code otherwise.
827 int dpni_get_unicast_promisc(struct fsl_mc_io *mc_io,
833 * dpni_set_primary_mac_addr() - Set the primary MAC address
834 * @mc_io: Pointer to MC portal's I/O object
835 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
836 * @token: Token of DPNI object
837 * @mac_addr: MAC address to set as primary address
839 * Return: '0' on Success; Error code otherwise.
841 int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
844 const uint8_t mac_addr[6]);
847 * dpni_get_primary_mac_addr() - Get the primary MAC address
848 * @mc_io: Pointer to MC portal's I/O object
849 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
850 * @token: Token of DPNI object
851 * @mac_addr: Returned MAC address
853 * Return: '0' on Success; Error code otherwise.
855 int dpni_get_primary_mac_addr(struct fsl_mc_io *mc_io,
858 uint8_t mac_addr[6]);
862 * dpni_get_port_mac_addr() - Retrieve MAC address associated to the physical
863 * port the DPNI is attached to
864 * @mc_io: Pointer to MC portal's I/O object
865 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
866 * @token: Token of DPNI object
867 * @mac_addr: MAC address of the physical port, if any, otherwise 0
869 * The primary MAC address is not modified by this operation.
871 * Return: '0' on Success; Error code otherwise.
873 int dpni_get_port_mac_addr(struct fsl_mc_io *mc_io,
876 uint8_t mac_addr[6]);
879 * enum dpni_dist_mode - DPNI distribution mode
880 * @DPNI_DIST_MODE_NONE: No distribution
881 * @DPNI_DIST_MODE_HASH: Use hash distribution; only relevant if
882 * the 'DPNI_OPT_DIST_HASH' option was set at DPNI creation
883 * @DPNI_DIST_MODE_FS: Use explicit flow steering; only relevant if
884 * the 'DPNI_OPT_DIST_FS' option was set at DPNI creation
886 enum dpni_dist_mode {
887 DPNI_DIST_MODE_NONE = 0,
888 DPNI_DIST_MODE_HASH = 1,
889 DPNI_DIST_MODE_FS = 2
893 * enum dpni_fs_miss_action - DPNI Flow Steering miss action
894 * @DPNI_FS_MISS_DROP: In case of no-match, drop the frame
895 * @DPNI_FS_MISS_EXPLICIT_FLOWID: In case of no-match, use explicit flow-id
896 * @DPNI_FS_MISS_HASH: In case of no-match, distribute using hash
898 enum dpni_fs_miss_action {
899 DPNI_FS_MISS_DROP = 0,
900 DPNI_FS_MISS_EXPLICIT_FLOWID = 1,
901 DPNI_FS_MISS_HASH = 2
905 * struct dpni_fs_tbl_cfg - Flow Steering table configuration
906 * @miss_action: Miss action selection
907 * @default_flow_id: Used when 'miss_action = DPNI_FS_MISS_EXPLICIT_FLOWID'
909 struct dpni_fs_tbl_cfg {
910 enum dpni_fs_miss_action miss_action;
911 uint16_t default_flow_id;
915 * dpni_prepare_key_cfg() - function prepare extract parameters
916 * @cfg: defining a full Key Generation profile (rule)
917 * @key_cfg_buf: Zeroed 256 bytes of memory before mapping it to DMA
919 * This function has to be called before the following functions:
920 * - dpni_set_rx_tc_dist()
921 * - dpni_set_qos_table()
923 int dpni_prepare_key_cfg(const struct dpkg_profile_cfg *cfg,
924 uint8_t *key_cfg_buf);
927 * struct dpni_rx_tc_dist_cfg - Rx traffic class distribution configuration
928 * @dist_size: Set the distribution size;
929 * supported values: 1,2,3,4,6,7,8,12,14,16,24,28,32,48,56,64,96,
930 * 112,128,192,224,256,384,448,512,768,896,1024
931 * @dist_mode: Distribution mode
932 * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
933 * the extractions to be used for the distribution key by calling
934 * dpni_prepare_key_cfg() relevant only when
935 * 'dist_mode != DPNI_DIST_MODE_NONE', otherwise it can be '0'
936 * @fs_cfg: Flow Steering table configuration; only relevant if
937 * 'dist_mode = DPNI_DIST_MODE_FS'
939 struct dpni_rx_tc_dist_cfg {
941 enum dpni_dist_mode dist_mode;
942 uint64_t key_cfg_iova;
943 struct dpni_fs_tbl_cfg fs_cfg;
947 * dpni_set_rx_tc_dist() - Set Rx traffic class distribution configuration
948 * @mc_io: Pointer to MC portal's I/O object
949 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
950 * @token: Token of DPNI object
951 * @tc_id: Traffic class selection (0-7)
952 * @cfg: Traffic class distribution configuration
954 * warning: if 'dist_mode != DPNI_DIST_MODE_NONE', call dpni_prepare_key_cfg()
955 * first to prepare the key_cfg_iova parameter
957 * Return: '0' on Success; error code otherwise.
959 int dpni_set_rx_tc_dist(struct fsl_mc_io *mc_io,
963 const struct dpni_rx_tc_dist_cfg *cfg);
966 * enum dpni_dest - DPNI destination types
967 * @DPNI_DEST_NONE: Unassigned destination; The queue is set in parked mode and
968 * does not generate FQDAN notifications; user is expected to
969 * dequeue from the queue based on polling or other user-defined
971 * @DPNI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
972 * notifications to the specified DPIO; user is expected to dequeue
973 * from the queue only after notification is received
974 * @DPNI_DEST_DPCON: The queue is set in schedule mode and does not generate
975 * FQDAN notifications, but is connected to the specified DPCON
976 * object; user is expected to dequeue from the DPCON channel
986 * struct dpni_queue - Queue structure
987 * @user_context: User data, presented to the user along with any frames
988 * from this queue. Not relevant for Tx queues.
992 * struct destination - Destination structure
993 * @id: ID of the destination, only relevant if DEST_TYPE is > 0.
994 * Identifies either a DPIO or a DPCON object.
995 * Not relevant for Tx queues.
996 * @type: May be one of the following:
997 * 0 - No destination, queue can be manually
998 * queried, but will not push traffic or
999 * notifications to a DPIO;
1000 * 1 - The destination is a DPIO. When traffic
1001 * becomes available in the queue a FQDAN
1002 * (FQ data available notification) will be
1003 * generated to selected DPIO;
1004 * 2 - The destination is a DPCON. The queue is
1005 * associated with a DPCON object for the
1006 * purpose of scheduling between multiple
1007 * queues. The DPCON may be independently
1008 * configured to generate notifications.
1009 * Not relevant for Tx queues.
1010 * @hold_active: Hold active, maintains a queue scheduled for longer
1011 * in a DPIO during dequeue to reduce spread of traffic.
1012 * Only relevant if queues are
1013 * not affined to a single DPIO.
1017 enum dpni_dest type;
1021 uint64_t user_context;
1023 * struct flc - FD FLow Context structure
1024 * @value: FLC value to set
1025 * @stash_control: Boolean, indicates whether the 6 lowest
1026 * significant bits are used for stash control.
1035 * struct dpni_queue_id - Queue identification, used for enqueue commands
1037 * @fqid: FQID used for enqueueing to and/or configuration of this
1039 * @qdbin: Queueing bin, used to enqueue using QDID, DQBIN, QPRI.
1040 * Only relevant for Tx queues.
1042 struct dpni_queue_id {
1048 * enum dpni_confirmation_mode - Defines DPNI options supported for Tx
1050 * @DPNI_CONF_AFFINE: For each Tx queue set associated with a sender there is
1051 * an affine Tx Confirmation queue
1052 * @DPNI_CONF_SINGLE: All Tx queues are associated with a single Tx
1053 * confirmation queue
1054 * @DPNI_CONF_DISABLE: Tx frames are not confirmed. This must be associated
1055 * with proper FD set-up to have buffers release to a Buffer Pool, otherwise
1056 * buffers will be leaked
1058 enum dpni_confirmation_mode {
1065 * dpni_set_tx_confirmation_mode() - Tx confirmation mode
1066 * @mc_io: Pointer to MC portal's I/O object
1067 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1068 * @token: Token of DPNI object
1069 * @mode: Tx confirmation mode
1071 * This function is useful only when 'DPNI_OPT_TX_CONF_DISABLED' is not
1072 * selected at DPNI creation.
1073 * Calling this function with 'mode' set to DPNI_CONF_DISABLE disables all
1074 * transmit confirmation (including the private confirmation queues), regardless
1075 * of previous settings; Note that in this case, Tx error frames are still
1076 * enqueued to the general transmit errors queue.
1077 * Calling this function with 'mode' set to DPNI_CONF_SINGLE switches all
1078 * Tx confirmations to a shared Tx conf queue. The ID of the queue when
1079 * calling dpni_set/get_queue is -1.
1081 * Return: '0' on Success; Error code otherwise.
1083 int dpni_set_tx_confirmation_mode(struct fsl_mc_io *mc_io,
1086 enum dpni_confirmation_mode mode);
1089 * dpni_get_api_version() - Get Data Path Network Interface API version
1090 * @mc_io: Pointer to MC portal's I/O object
1091 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1092 * @major_ver: Major version of data path network interface API
1093 * @minor_ver: Minor version of data path network interface API
1095 * Return: '0' on Success; Error code otherwise.
1097 int dpni_get_api_version(struct fsl_mc_io *mc_io,
1099 uint16_t *major_ver,
1100 uint16_t *minor_ver);
1105 #define DPNI_QUEUE_OPT_USER_CTX 0x00000001
1108 * Set queue destination configuration
1110 #define DPNI_QUEUE_OPT_DEST 0x00000002
1113 * Set FD[FLC] configuration for traffic on this queue. Note that FLC values
1114 * set with dpni_add_fs_entry, if any, take precedence over values per queue.
1116 #define DPNI_QUEUE_OPT_FLC 0x00000004
1119 * Set the queue to hold active mode. This prevents the queue from being
1120 * rescheduled between DPIOs while it carries traffic and is active on one
1121 * DPNI. Can help reduce reordering when servicing one queue on multiple
1122 * CPUs, but the queue is also less likely to push data to multiple CPUs
1123 * especially when congested.
1125 #define DPNI_QUEUE_OPT_HOLD_ACTIVE 0x00000008
1128 * dpni_set_queue() - Set queue parameters
1129 * @mc_io: Pointer to MC portal's I/O object
1130 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1131 * @token: Token of DPNI object
1132 * @qtype: Type of queue - all queue types are supported, although
1133 * the command is ignored for Tx
1134 * @tc: Traffic class, in range 0 to NUM_TCS - 1
1135 * @index: Selects the specific queue out of the set
1136 * allocated for the same TC.Value must be in
1137 * range 0 to NUM_QUEUES - 1
1138 * @options: A combination of DPNI_QUEUE_OPT_ values that control
1139 * what configuration options are set on the queue
1140 * @queue: Queue configuration structure
1142 * Return: '0' on Success; Error code otherwise.
1144 int dpni_set_queue(struct fsl_mc_io *mc_io,
1147 enum dpni_queue_type qtype,
1151 const struct dpni_queue *queue);
1154 * dpni_get_queue() - Get queue parameters
1155 * @mc_io: Pointer to MC portal's I/O object
1156 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1157 * @token: Token of DPNI object
1158 * @qtype: Type of queue - all queue types are supported
1159 * @tc: Traffic class, in range 0 to NUM_TCS - 1
1160 * @index: Selects the specific queue out of the set allocated
1161 * for the same TC. Value must be in range 0 to
1163 * @queue: Queue configuration structure
1164 * @qid: Queue identification
1166 * This function returns current queue configuration which can be changed by
1167 * calling dpni_set_queue, and queue identification information.
1168 * Returned qid.fqid and/or qid.qdbin values can be used to:
1169 * - enqueue traffic for Tx queues,
1170 * - perform volatile dequeue for Rx and, if applicable, Tx confirmation
1172 * - retrieve queue state.
1174 * All these operations are supported through the DPIO run-time API.
1176 * Return: '0' on Success; Error code otherwise.
1178 int dpni_get_queue(struct fsl_mc_io *mc_io,
1181 enum dpni_queue_type qtype,
1184 struct dpni_queue *queue,
1185 struct dpni_queue_id *qid);
1188 * dpni_get_statistics() - Get DPNI statistics
1189 * @mc_io: Pointer to MC portal's I/O object
1190 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1191 * @token: Token of DPNI object
1192 * @page: Selects the statistics page to retrieve, see
1193 * DPNI_GET_STATISTICS output.
1194 * Pages are numbered 0 to 2.
1195 * @stat: Structure containing the statistics
1197 * Return: '0' on Success; Error code otherwise.
1199 int dpni_get_statistics(struct fsl_mc_io *mc_io,
1203 union dpni_statistics *stat);
1206 * dpni_reset_statistics() - Clears DPNI statistics
1207 * @mc_io: Pointer to MC portal's I/O object
1208 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1209 * @token: Token of DPNI object
1211 * Return: '0' on Success; Error code otherwise.
1213 int dpni_reset_statistics(struct fsl_mc_io *mc_io,
1217 #endif /* __FSL_DPNI_H */