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 2016-2017 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)
77 * Tx traffic is always released to a buffer pool on transmit, there are no
78 * resources allocated to have the frames confirmed back to the source after
81 #define DPNI_OPT_TX_FRM_RELEASE 0x000001
83 * Disables support for MAC address filtering for addresses other than primary
84 * MAC address. This affects both unicast and multicast. Promiscuous mode can
85 * still be enabled/disabled for both unicast and multicast. If promiscuous mode
86 * is disabled, only traffic matching the primary MAC address will be accepted.
88 #define DPNI_OPT_NO_MAC_FILTER 0x000002
90 * Allocate policers for this DPNI. They can be used to rate-limit traffic per
91 * traffic class (TC) basis.
93 #define DPNI_OPT_HAS_POLICING 0x000004
95 * Congestion can be managed in several ways, allowing the buffer pool to
96 * deplete on ingress, taildrop on each queue or use congestion groups for sets
97 * of queues. If set, it configures a single congestion groups across all TCs.
98 * If reset, a congestion group is allocated for each TC. Only relevant if the
99 * DPNI has multiple traffic classes.
101 #define DPNI_OPT_SHARED_CONGESTION 0x000008
103 * Enables TCAM for Flow Steering and QoS look-ups. If not specified, all
104 * look-ups are exact match. Note that TCAM is not available on LS1088 and its
105 * variants. Setting this bit on these SoCs will trigger an error.
107 #define DPNI_OPT_HAS_KEY_MASKING 0x000010
109 * Disables the flow steering table.
111 #define DPNI_OPT_NO_FS 0x000020
113 int dpni_open(struct fsl_mc_io *mc_io,
118 int dpni_close(struct fsl_mc_io *mc_io,
123 * struct dpni_cfg - Structure representing DPNI configuration
124 * @mac_addr: Primary MAC address
125 * @adv: Advanced parameters; default is all zeros;
126 * use this structure to change default settings
130 * @options: Any combination of the following options:
131 * DPNI_OPT_TX_FRM_RELEASE
132 * DPNI_OPT_NO_MAC_FILTER
133 * DPNI_OPT_HAS_POLICING
134 * DPNI_OPT_SHARED_CONGESTION
135 * DPNI_OPT_HAS_KEY_MASKING
137 * @fs_entries: Number of entries in the flow steering table.
138 * This table is used to select the ingress queue for
139 * ingress traffic, targeting a GPP core or another.
140 * In addition it can be used to discard traffic that
141 * matches the set rule. It is either an exact match table
142 * or a TCAM table, depending on DPNI_OPT_ HAS_KEY_MASKING
143 * bit in OPTIONS field. This field is ignored if
144 * DPNI_OPT_NO_FS bit is set in OPTIONS field. Otherwise,
145 * value 0 defaults to 64. Maximum supported value is 1024.
146 * Note that the total number of entries is limited on the
147 * SoC to as low as 512 entries if TCAM is used.
148 * @vlan_filter_entries: Number of entries in the VLAN address filtering
149 * table. This is an exact match table used to filter
150 * ingress traffic based on VLAN IDs. Value 0 disables VLAN
151 * filtering. Maximum supported value is 16.
152 * @mac_filter_entries: Number of entries in the MAC address filtering
153 * table. This is an exact match table and allows both
154 * unicast and multicast entries. The primary MAC address
155 * of the network interface is not part of this table,
156 * this contains only entries in addition to it. This
157 * field is ignored if DPNI_OPT_ NO_MAC_FILTER is set in
158 * OPTIONS field. Otherwise, value 0 defaults to 80.
159 * Maximum supported value is 80.
160 * @num_queues: Number of Tx and Rx queues used for traffic
161 * distribution. This is orthogonal to QoS and is only
162 * used to distribute traffic to multiple GPP cores.
163 * This configuration affects the number of Tx queues
164 * (logical FQs, all associated with a single CEETM queue),
165 * Rx queues and Tx confirmation queues, if applicable.
166 * Value 0 defaults to one queue. Maximum supported value
168 * @num_tcs: Number of traffic classes (TCs), reserved for the DPNI.
169 * TCs can have different priority levels for the purpose
170 * of Tx scheduling (see DPNI_SET_TX_SELECTION), different
171 * BPs (DPNI_ SET_POOLS), policers. There are dedicated QM
172 * queues for traffic classes (including class queues on
173 * Tx). Value 0 defaults to one TC. Maximum supported value
175 * @qos_entries: Number of entries in the QoS classification table. This
176 * table is used to select the TC for ingress traffic. It
177 * is either an exact match or a TCAM table, depending on
178 * DPNI_OPT_ HAS_KEY_MASKING bit in OPTIONS field. This
179 * field is ignored if the DPNI has a single TC. Otherwise,
180 * a value of 0 defaults to 64. Maximum supported value
185 uint8_t vlan_filter_entries;
186 uint8_t mac_filter_entries;
192 int dpni_create(struct fsl_mc_io *mc_io,
195 const struct dpni_cfg *cfg,
198 int dpni_destroy(struct fsl_mc_io *mc_io,
204 * struct dpni_pools_cfg - Structure representing buffer pools configuration
205 * @num_dpbp: Number of DPBPs
206 * @pools: Array of buffer pools parameters; The number of valid entries
207 * must match 'num_dpbp' value
209 struct dpni_pools_cfg {
212 * struct pools - Buffer pools parameters
213 * @dpbp_id: DPBP object ID
214 * @priority: priority mask that indicates TC's used with this buffer.
215 * I set to 0x00 MC will assume value 0xff.
216 * @buffer_size: Buffer size
217 * @backup_pool: Backup pool
221 uint8_t priority_mask;
222 uint16_t buffer_size;
224 } pools[DPNI_MAX_DPBP];
227 int dpni_set_pools(struct fsl_mc_io *mc_io,
230 const struct dpni_pools_cfg *cfg);
232 int dpni_enable(struct fsl_mc_io *mc_io,
236 int dpni_disable(struct fsl_mc_io *mc_io,
240 int dpni_is_enabled(struct fsl_mc_io *mc_io,
245 int dpni_reset(struct fsl_mc_io *mc_io,
250 * struct dpni_attr - Structure representing DPNI attributes
251 * @options: Any combination of the following options:
252 * DPNI_OPT_TX_FRM_RELEASE
253 * DPNI_OPT_NO_MAC_FILTER
254 * DPNI_OPT_HAS_POLICING
255 * DPNI_OPT_SHARED_CONGESTION
256 * DPNI_OPT_HAS_KEY_MASKING
258 * @num_queues: Number of Tx and Rx queues used for traffic distribution.
259 * @num_rx_tcs: Number of RX traffic classes (TCs), reserved for the DPNI.
260 * @num_tx_tcs: Number of TX traffic classes (TCs), reserved for the DPNI.
261 * @mac_filter_entries: Number of entries in the MAC address filtering
263 * @vlan_filter_entries: Number of entries in the VLAN address filtering
265 * @qos_entries: Number of entries in the QoS classification table.
266 * @fs_entries: Number of entries in the flow steering table.
267 * @qos_key_size: Size, in bytes, of the QoS look-up key. Defining a key larger
268 * than this when adding QoS entries will result
270 * @fs_key_size: Size, in bytes, of the flow steering look-up key. Defining a
271 * key larger than this when composing the hash + FS key
272 * will result in an error.
273 * @wriop_version: Version of WRIOP HW block.
274 * The 3 version values are stored on 6, 5, 5 bits
277 * - 0x400 - WRIOP version 1.0.0, used on LS2080 and
279 * - 0x421 - WRIOP version 1.1.1, used on LS2088 and
281 * - 0x422 - WRIOP version 1.1.2, used on LS1088 and
289 uint8_t mac_filter_entries;
290 uint8_t vlan_filter_entries;
293 uint8_t qos_key_size;
295 uint16_t wriop_version;
298 int dpni_get_attributes(struct fsl_mc_io *mc_io,
301 struct dpni_attr *attr);
308 * Extract out of frame header error
310 #define DPNI_ERROR_EOFHE 0x00020000
314 #define DPNI_ERROR_FLE 0x00002000
316 * Frame physical error
318 #define DPNI_ERROR_FPE 0x00001000
320 * Parsing header error
322 #define DPNI_ERROR_PHE 0x00000020
324 * Parser L3 checksum error
326 #define DPNI_ERROR_L3CE 0x00000004
328 * Parser L3 checksum error
330 #define DPNI_ERROR_L4CE 0x00000001
333 * enum dpni_error_action - Defines DPNI behavior for errors
334 * @DPNI_ERROR_ACTION_DISCARD: Discard the frame
335 * @DPNI_ERROR_ACTION_CONTINUE: Continue with the normal flow
336 * @DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE: Send the frame to the error queue
338 enum dpni_error_action {
339 DPNI_ERROR_ACTION_DISCARD = 0,
340 DPNI_ERROR_ACTION_CONTINUE = 1,
341 DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE = 2
345 * struct dpni_error_cfg - Structure representing DPNI errors treatment
346 * @errors: Errors mask; use 'DPNI_ERROR__<X>
347 * @error_action: The desired action for the errors mask
348 * @set_frame_annotation: Set to '1' to mark the errors in frame
349 * annotation status (FAS); relevant only
350 * for the non-discard action
352 struct dpni_error_cfg {
354 enum dpni_error_action error_action;
355 int set_frame_annotation;
358 int dpni_set_errors_behavior(struct fsl_mc_io *mc_io,
361 struct dpni_error_cfg *cfg);
364 * DPNI buffer layout modification options
368 * Select to modify the time-stamp setting
370 #define DPNI_BUF_LAYOUT_OPT_TIMESTAMP 0x00000001
372 * Select to modify the parser-result setting; not applicable for Tx
374 #define DPNI_BUF_LAYOUT_OPT_PARSER_RESULT 0x00000002
376 * Select to modify the frame-status setting
378 #define DPNI_BUF_LAYOUT_OPT_FRAME_STATUS 0x00000004
380 * Select to modify the private-data-size setting
382 #define DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE 0x00000008
384 * Select to modify the data-alignment setting
386 #define DPNI_BUF_LAYOUT_OPT_DATA_ALIGN 0x00000010
388 * Select to modify the data-head-room setting
390 #define DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM 0x00000020
392 * Select to modify the data-tail-room setting
394 #define DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM 0x00000040
397 * struct dpni_buffer_layout - Structure representing DPNI buffer layout
398 * @options: Flags representing the suggested modifications to the
400 * Use any combination of 'DPNI_BUF_LAYOUT_OPT_<X>' flags
401 * @pass_timestamp: Pass timestamp value
402 * @pass_parser_result: Pass parser results
403 * @pass_frame_status: Pass frame status
404 * @private_data_size: Size kept for private data (in bytes)
405 * @data_align: Data alignment
406 * @data_head_room: Data head room
407 * @data_tail_room: Data tail room
409 struct dpni_buffer_layout {
412 int pass_parser_result;
413 int pass_frame_status;
414 uint16_t private_data_size;
416 uint16_t data_head_room;
417 uint16_t data_tail_room;
421 * enum dpni_queue_type - Identifies a type of queue targeted by the command
422 * @DPNI_QUEUE_RX: Rx queue
423 * @DPNI_QUEUE_TX: Tx queue
424 * @DPNI_QUEUE_TX_CONFIRM: Tx confirmation queue
425 * @DPNI_QUEUE_RX_ERR: Rx error queue
427 enum dpni_queue_type {
430 DPNI_QUEUE_TX_CONFIRM,
434 int dpni_get_buffer_layout(struct fsl_mc_io *mc_io,
437 enum dpni_queue_type qtype,
438 struct dpni_buffer_layout *layout);
440 int dpni_set_buffer_layout(struct fsl_mc_io *mc_io,
443 enum dpni_queue_type qtype,
444 const struct dpni_buffer_layout *layout);
447 * enum dpni_offload - Identifies a type of offload targeted by the command
448 * @DPNI_OFF_RX_L3_CSUM: Rx L3 checksum validation
449 * @DPNI_OFF_RX_L4_CSUM: Rx L4 checksum validation
450 * @DPNI_OFF_TX_L3_CSUM: Tx L3 checksum generation
451 * @DPNI_OFF_TX_L4_CSUM: Tx L4 checksum generation
452 * @DPNI_OPT_FLCTYPE_HASH: flow context will be generated by WRIOP for AIOP or
463 int dpni_set_offload(struct fsl_mc_io *mc_io,
466 enum dpni_offload type,
469 int dpni_get_offload(struct fsl_mc_io *mc_io,
472 enum dpni_offload type,
475 int dpni_get_qdid(struct fsl_mc_io *mc_io,
478 enum dpni_queue_type qtype,
481 int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io,
484 uint16_t *data_offset);
486 #define DPNI_STATISTICS_CNT 7
488 union dpni_statistics {
490 * struct page_0 - Page_0 statistics structure
491 * @ingress_all_frames: Ingress frame count
492 * @ingress_all_bytes: Ingress byte count
493 * @ingress_multicast_frames: Ingress multicast frame count
494 * @ingress_multicast_bytes: Ingress multicast byte count
495 * @ingress_broadcast_frames: Ingress broadcast frame count
496 * @ingress_broadcast_bytes: Ingress broadcast byte count
499 uint64_t ingress_all_frames;
500 uint64_t ingress_all_bytes;
501 uint64_t ingress_multicast_frames;
502 uint64_t ingress_multicast_bytes;
503 uint64_t ingress_broadcast_frames;
504 uint64_t ingress_broadcast_bytes;
507 * struct page_1 - Page_1 statistics structure
508 * @egress_all_frames: Egress frame count
509 * @egress_all_bytes: Egress byte count
510 * @egress_multicast_frames: Egress multicast frame count
511 * @egress_multicast_bytes: Egress multicast byte count
512 * @egress_broadcast_frames: Egress broadcast frame count
513 * @egress_broadcast_bytes: Egress broadcast byte count
516 uint64_t egress_all_frames;
517 uint64_t egress_all_bytes;
518 uint64_t egress_multicast_frames;
519 uint64_t egress_multicast_bytes;
520 uint64_t egress_broadcast_frames;
521 uint64_t egress_broadcast_bytes;
524 * struct page_2 - Page_2 statistics structure
525 * @ingress_filtered_frames: Ingress filtered frame count
526 * @ingress_discarded_frames: Ingress discarded frame count
527 * @ingress_nobuffer_discards: Ingress discarded frame count due to
529 * @egress_discarded_frames: Egress discarded frame count
530 * @egress_confirmed_frames: Egress confirmed frame count
533 uint64_t ingress_filtered_frames;
534 uint64_t ingress_discarded_frames;
535 uint64_t ingress_nobuffer_discards;
536 uint64_t egress_discarded_frames;
537 uint64_t egress_confirmed_frames;
540 * struct page_3 - Page_3 statistics structure with values for the
542 * @ceetm_dequeue_bytes: Cumulative count of the number of bytes
544 * @ceetm_dequeue_frames: Cumulative count of the number of frames
546 * @ceetm_reject_bytes: Cumulative count of the number of bytes in all
547 * frames whose enqueue was rejected
548 * @ceetm_reject_frames: Cumulative count of all frame enqueues rejected
551 uint64_t ceetm_dequeue_bytes;
552 uint64_t ceetm_dequeue_frames;
553 uint64_t ceetm_reject_bytes;
554 uint64_t ceetm_reject_frames;
557 * struct raw - raw statistics structure, used to index counters
560 uint64_t counter[DPNI_STATISTICS_CNT];
565 * Enable auto-negotiation
567 #define DPNI_LINK_OPT_AUTONEG 0x0000000000000001ULL
569 * Enable half-duplex mode
571 #define DPNI_LINK_OPT_HALF_DUPLEX 0x0000000000000002ULL
573 * Enable pause frames
575 #define DPNI_LINK_OPT_PAUSE 0x0000000000000004ULL
577 * Enable a-symmetric pause frames
579 #define DPNI_LINK_OPT_ASYM_PAUSE 0x0000000000000008ULL
581 * Enable priority flow control pause frames
583 #define DPNI_LINK_OPT_PFC_PAUSE 0x0000000000000010ULL
586 * struct - Structure representing DPNI link configuration
588 * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
590 struct dpni_link_cfg {
595 int dpni_set_link_cfg(struct fsl_mc_io *mc_io,
598 const struct dpni_link_cfg *cfg);
601 * struct dpni_link_state - Structure representing DPNI link state
603 * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
604 * @up: Link state; '0' for down, '1' for up
606 struct dpni_link_state {
612 int dpni_get_link_state(struct fsl_mc_io *mc_io,
615 struct dpni_link_state *state);
617 int dpni_set_max_frame_length(struct fsl_mc_io *mc_io,
620 uint16_t max_frame_length);
622 int dpni_get_max_frame_length(struct fsl_mc_io *mc_io,
625 uint16_t *max_frame_length);
627 int dpni_set_mtu(struct fsl_mc_io *mc_io,
632 int dpni_get_mtu(struct fsl_mc_io *mc_io,
637 int dpni_set_multicast_promisc(struct fsl_mc_io *mc_io,
642 int dpni_get_multicast_promisc(struct fsl_mc_io *mc_io,
647 int dpni_set_unicast_promisc(struct fsl_mc_io *mc_io,
652 int dpni_get_unicast_promisc(struct fsl_mc_io *mc_io,
657 int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
660 const uint8_t mac_addr[6]);
662 int dpni_get_primary_mac_addr(struct fsl_mc_io *mc_io,
665 uint8_t mac_addr[6]);
667 int dpni_add_mac_addr(struct fsl_mc_io *mc_io,
670 const uint8_t mac_addr[6]);
672 int dpni_remove_mac_addr(struct fsl_mc_io *mc_io,
675 const uint8_t mac_addr[6]);
677 int dpni_clear_mac_filters(struct fsl_mc_io *mc_io,
683 int dpni_get_port_mac_addr(struct fsl_mc_io *mc_io,
686 uint8_t mac_addr[6]);
688 int dpni_enable_vlan_filter(struct fsl_mc_io *mc_io,
693 int dpni_add_vlan_id(struct fsl_mc_io *mc_io,
698 int dpni_remove_vlan_id(struct fsl_mc_io *mc_io,
703 int dpni_clear_vlan_filters(struct fsl_mc_io *mc_io,
708 * enum dpni_dist_mode - DPNI distribution mode
709 * @DPNI_DIST_MODE_NONE: No distribution
710 * @DPNI_DIST_MODE_HASH: Use hash distribution; only relevant if
711 * the 'DPNI_OPT_DIST_HASH' option was set at DPNI creation
712 * @DPNI_DIST_MODE_FS: Use explicit flow steering; only relevant if
713 * the 'DPNI_OPT_DIST_FS' option was set at DPNI creation
715 enum dpni_dist_mode {
716 DPNI_DIST_MODE_NONE = 0,
717 DPNI_DIST_MODE_HASH = 1,
718 DPNI_DIST_MODE_FS = 2
722 * enum dpni_fs_miss_action - DPNI Flow Steering miss action
723 * @DPNI_FS_MISS_DROP: In case of no-match, drop the frame
724 * @DPNI_FS_MISS_EXPLICIT_FLOWID: In case of no-match, use explicit flow-id
725 * @DPNI_FS_MISS_HASH: In case of no-match, distribute using hash
727 enum dpni_fs_miss_action {
728 DPNI_FS_MISS_DROP = 0,
729 DPNI_FS_MISS_EXPLICIT_FLOWID = 1,
730 DPNI_FS_MISS_HASH = 2
734 * struct dpni_fs_tbl_cfg - Flow Steering table configuration
735 * @miss_action: Miss action selection
736 * @default_flow_id: Used when 'miss_action = DPNI_FS_MISS_EXPLICIT_FLOWID'
738 struct dpni_fs_tbl_cfg {
739 enum dpni_fs_miss_action miss_action;
740 uint16_t default_flow_id;
745 * struct dpni_rx_tc_dist_cfg - Rx traffic class distribution configuration
746 * @dist_size: Set the distribution size;
747 * supported values: 1,2,3,4,6,7,8,12,14,16,24,28,32,48,56,64,96,
748 * 112,128,192,224,256,384,448,512,768,896,1024
749 * @dist_mode: Distribution mode
750 * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
751 * the extractions to be used for the distribution key by calling
752 * dpkg_prepare_key_cfg() relevant only when
753 * 'dist_mode != DPNI_DIST_MODE_NONE', otherwise it can be '0'
754 * @fs_cfg: Flow Steering table configuration; only relevant if
755 * 'dist_mode = DPNI_DIST_MODE_FS'
757 struct dpni_rx_tc_dist_cfg {
759 enum dpni_dist_mode dist_mode;
760 uint64_t key_cfg_iova;
761 struct dpni_fs_tbl_cfg fs_cfg;
764 int dpni_set_rx_tc_dist(struct fsl_mc_io *mc_io,
768 const struct dpni_rx_tc_dist_cfg *cfg);
771 * enum dpni_congestion_unit - DPNI congestion units
772 * @DPNI_CONGESTION_UNIT_BYTES: bytes units
773 * @DPNI_CONGESTION_UNIT_FRAMES: frames units
775 enum dpni_congestion_unit {
776 DPNI_CONGESTION_UNIT_BYTES = 0,
777 DPNI_CONGESTION_UNIT_FRAMES
782 * enum dpni_dest - DPNI destination types
783 * @DPNI_DEST_NONE: Unassigned destination; The queue is set in parked mode and
784 * does not generate FQDAN notifications; user is expected to
785 * dequeue from the queue based on polling or other user-defined
787 * @DPNI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
788 * notifications to the specified DPIO; user is expected to dequeue
789 * from the queue only after notification is received
790 * @DPNI_DEST_DPCON: The queue is set in schedule mode and does not generate
791 * FQDAN notifications, but is connected to the specified DPCON
792 * object; user is expected to dequeue from the DPCON channel
801 * struct dpni_dest_cfg - Structure representing DPNI destination parameters
802 * @dest_type: Destination type
803 * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
804 * @priority: Priority selection within the DPIO or DPCON channel; valid values
805 * are 0-1 or 0-7, depending on the number of priorities in that
806 * channel; not relevant for 'DPNI_DEST_NONE' option
808 struct dpni_dest_cfg {
809 enum dpni_dest dest_type;
814 /* DPNI congestion options */
817 * CSCN message is written to message_iova once entering a
818 * congestion state (see 'threshold_entry')
820 #define DPNI_CONG_OPT_WRITE_MEM_ON_ENTER 0x00000001
822 * CSCN message is written to message_iova once exiting a
823 * congestion state (see 'threshold_exit')
825 #define DPNI_CONG_OPT_WRITE_MEM_ON_EXIT 0x00000002
827 * CSCN write will attempt to allocate into a cache (coherent write);
828 * valid only if 'DPNI_CONG_OPT_WRITE_MEM_<X>' is selected
830 #define DPNI_CONG_OPT_COHERENT_WRITE 0x00000004
832 * if 'dest_cfg.dest_type != DPNI_DEST_NONE' CSCN message is sent to
833 * DPIO/DPCON's WQ channel once entering a congestion state
834 * (see 'threshold_entry')
836 #define DPNI_CONG_OPT_NOTIFY_DEST_ON_ENTER 0x00000008
838 * if 'dest_cfg.dest_type != DPNI_DEST_NONE' CSCN message is sent to
839 * DPIO/DPCON's WQ channel once exiting a congestion state
840 * (see 'threshold_exit')
842 #define DPNI_CONG_OPT_NOTIFY_DEST_ON_EXIT 0x00000010
844 * if 'dest_cfg.dest_type != DPNI_DEST_NONE' when the CSCN is written to the
845 * sw-portal's DQRR, the DQRI interrupt is asserted immediately (if enabled)
847 #define DPNI_CONG_OPT_INTR_COALESCING_DISABLED 0x00000020
849 * This congestion will trigger flow control or priority flow control. This
850 * will have effect only if flow control is enabled with dpni_set_link_cfg()
852 #define DPNI_CONG_OPT_FLOW_CONTROL 0x00000040
855 * struct dpni_congestion_notification_cfg - congestion notification
858 * @threshold_entry: above this threshold we enter a congestion state.
859 * set it to '0' to disable it
860 * @threshold_exit: below this threshold we exit the congestion state.
861 * @message_ctx: The context that will be part of the CSCN message
862 * @message_iova: I/O virtual address (must be in DMA-able memory),
863 * must be 16B aligned; valid only if 'DPNI_CONG_OPT_WRITE_MEM_<X>' is
864 * contained in 'options'
865 * @dest_cfg: CSCN can be send to either DPIO or DPCON WQ channel
866 * @notification_mode: Mask of available options; use 'DPNI_CONG_OPT_<X>' values
869 struct dpni_congestion_notification_cfg {
870 enum dpni_congestion_unit units;
871 uint32_t threshold_entry;
872 uint32_t threshold_exit;
873 uint64_t message_ctx;
874 uint64_t message_iova;
875 struct dpni_dest_cfg dest_cfg;
876 uint16_t notification_mode;
879 int dpni_set_congestion_notification(struct fsl_mc_io *mc_io,
882 enum dpni_queue_type qtype,
884 const struct dpni_congestion_notification_cfg *cfg);
886 int dpni_get_congestion_notification(struct fsl_mc_io *mc_io,
889 enum dpni_queue_type qtype,
891 struct dpni_congestion_notification_cfg *cfg);
893 /* DPNI FLC stash options */
896 * stashes the whole annotation area (up to 192 bytes)
898 #define DPNI_FLC_STASH_FRAME_ANNOTATION 0x00000001
901 * struct dpni_queue - Queue structure
902 * @user_context: User data, presented to the user along with any frames
903 * from this queue. Not relevant for Tx queues.
907 * struct destination - Destination structure
908 * @id: ID of the destination, only relevant if DEST_TYPE is > 0.
909 * Identifies either a DPIO or a DPCON object.
910 * Not relevant for Tx queues.
911 * @type: May be one of the following:
912 * 0 - No destination, queue can be manually
913 * queried, but will not push traffic or
914 * notifications to a DPIO;
915 * 1 - The destination is a DPIO. When traffic
916 * becomes available in the queue a FQDAN
917 * (FQ data available notification) will be
918 * generated to selected DPIO;
919 * 2 - The destination is a DPCON. The queue is
920 * associated with a DPCON object for the
921 * purpose of scheduling between multiple
922 * queues. The DPCON may be independently
923 * configured to generate notifications.
924 * Not relevant for Tx queues.
925 * @hold_active: Hold active, maintains a queue scheduled for longer
926 * in a DPIO during dequeue to reduce spread of traffic.
927 * Only relevant if queues are
928 * not affined to a single DPIO.
936 uint64_t user_context;
938 * struct flc - FD FLow Context structure
939 * @value: Default FLC value for traffic dequeued from
940 * this queue. Please check description of FD
941 * structure for more information.
942 * Note that FLC values set using dpni_add_fs_entry,
943 * if any, take precedence over values per queue.
944 * @stash_control: Boolean, indicates whether the 6 lowest
945 * - significant bits are used for stash control.
946 * significant bits are used for stash control. If set, the 6
947 * least significant bits in value are interpreted as follows:
948 * - bits 0-1: indicates the number of 64 byte units of context
949 * that are stashed. FLC value is interpreted as a memory address
950 * in this case, excluding the 6 LS bits.
951 * - bits 2-3: indicates the number of 64 byte units of frame
952 * annotation to be stashed. Annotation is placed at FD[ADDR].
953 * - bits 4-5: indicates the number of 64 byte units of frame
954 * data to be stashed. Frame data is placed at FD[ADDR] +
956 * For more details check the Frame Descriptor section in the
957 * hardware documentation.
966 * struct dpni_queue_id - Queue identification, used for enqueue commands
968 * @fqid: FQID used for enqueueing to and/or configuration of this
970 * @qdbin: Queueing bin, used to enqueue using QDID, DQBIN, QPRI.
971 * Only relevant for Tx queues.
973 struct dpni_queue_id {
979 * enum dpni_confirmation_mode - Defines DPNI options supported for Tx
981 * @DPNI_CONF_AFFINE: For each Tx queue set associated with a sender there is
982 * an affine Tx Confirmation queue
983 * @DPNI_CONF_SINGLE: All Tx queues are associated with a single Tx
985 * @DPNI_CONF_DISABLE: Tx frames are not confirmed. This must be associated
986 * with proper FD set-up to have buffers release to a Buffer Pool, otherwise
987 * buffers will be leaked
989 enum dpni_confirmation_mode {
995 int dpni_set_tx_confirmation_mode(struct fsl_mc_io *mc_io,
998 enum dpni_confirmation_mode mode);
1000 int dpni_get_tx_confirmation_mode(struct fsl_mc_io *mc_io,
1003 enum dpni_confirmation_mode *mode);
1005 int dpni_get_api_version(struct fsl_mc_io *mc_io,
1007 uint16_t *major_ver,
1008 uint16_t *minor_ver);
1013 #define DPNI_QUEUE_OPT_USER_CTX 0x00000001
1016 * Set queue destination configuration
1018 #define DPNI_QUEUE_OPT_DEST 0x00000002
1021 * Set FD[FLC] configuration for traffic on this queue. Note that FLC values
1022 * set with dpni_add_fs_entry, if any, take precedence over values per queue.
1024 #define DPNI_QUEUE_OPT_FLC 0x00000004
1027 * Set the queue to hold active mode. This prevents the queue from being
1028 * rescheduled between DPIOs while it carries traffic and is active on one
1029 * DPNI. Can help reduce reordering when servicing one queue on multiple
1030 * CPUs, but the queue is also less likely to push data to multiple CPUs
1031 * especially when congested.
1033 #define DPNI_QUEUE_OPT_HOLD_ACTIVE 0x00000008
1035 int dpni_set_queue(struct fsl_mc_io *mc_io,
1038 enum dpni_queue_type qtype,
1042 const struct dpni_queue *queue);
1044 int dpni_get_queue(struct fsl_mc_io *mc_io,
1047 enum dpni_queue_type qtype,
1050 struct dpni_queue *queue,
1051 struct dpni_queue_id *qid);
1053 int dpni_get_statistics(struct fsl_mc_io *mc_io,
1058 union dpni_statistics *stat);
1060 int dpni_reset_statistics(struct fsl_mc_io *mc_io,
1065 * enum dpni_congestion_point - Structure representing congestion point
1066 * @DPNI_CP_QUEUE: Set taildrop per queue, identified by QUEUE_TYPE, TC and
1068 * @DPNI_CP_GROUP: Set taildrop per queue group. Depending on options used
1069 * to define the DPNI this can be either per
1070 * TC (default) or per interface
1071 * (DPNI_OPT_SHARED_CONGESTION set at DPNI create).
1072 * QUEUE_INDEX is ignored if this type is used.
1074 enum dpni_congestion_point {
1080 * struct dpni_taildrop - Structure representing the taildrop
1081 * @enable: Indicates whether the taildrop is active or not.
1082 * @units: Indicates the unit of THRESHOLD. Queue taildrop only
1083 * supports byte units, this field is ignored and
1084 * assumed = 0 if CONGESTION_POINT is 0.
1085 * @threshold: Threshold value, in units identified by UNITS field. Value 0
1086 * cannot be used as a valid taildrop threshold,
1087 * THRESHOLD must be > 0 if the taildrop is
1089 * @oal : Overhead Accounting Length, a 12-bit, 2's complement value
1090 * with range (-2048 to +2047) representing a fixed per-frame
1091 * overhead to be added to the actual length of a frame when
1092 * performing WRED and tail drop calculations and threshold
1095 struct dpni_taildrop {
1097 enum dpni_congestion_unit units;
1102 int dpni_set_taildrop(struct fsl_mc_io *mc_io,
1105 enum dpni_congestion_point cg_point,
1106 enum dpni_queue_type q_type,
1109 struct dpni_taildrop *taildrop);
1111 int dpni_get_taildrop(struct fsl_mc_io *mc_io,
1114 enum dpni_congestion_point cg_point,
1115 enum dpni_queue_type q_type,
1118 struct dpni_taildrop *taildrop);
1119 #endif /* __FSL_DPNI_H */