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 * DPNI IRQ Index and Events
256 #define DPNI_IRQ_INDEX 0
258 * IRQ event - indicates a change in link state
260 #define DPNI_IRQ_EVENT_LINK_CHANGED 0x00000001
262 int dpni_set_irq_enable(struct fsl_mc_io *mc_io,
268 int dpni_get_irq_enable(struct fsl_mc_io *mc_io,
274 int dpni_set_irq_mask(struct fsl_mc_io *mc_io,
280 int dpni_get_irq_mask(struct fsl_mc_io *mc_io,
286 int dpni_get_irq_status(struct fsl_mc_io *mc_io,
292 int dpni_clear_irq_status(struct fsl_mc_io *mc_io,
299 * struct dpni_attr - Structure representing DPNI attributes
300 * @options: Any combination of the following options:
301 * DPNI_OPT_TX_FRM_RELEASE
302 * DPNI_OPT_NO_MAC_FILTER
303 * DPNI_OPT_HAS_POLICING
304 * DPNI_OPT_SHARED_CONGESTION
305 * DPNI_OPT_HAS_KEY_MASKING
307 * @num_queues: Number of Tx and Rx queues used for traffic distribution.
308 * @num_rx_tcs: Number of RX traffic classes (TCs), reserved for the DPNI.
309 * @num_tx_tcs: Number of TX traffic classes (TCs), reserved for the DPNI.
310 * @mac_filter_entries: Number of entries in the MAC address filtering
312 * @vlan_filter_entries: Number of entries in the VLAN address filtering
314 * @qos_entries: Number of entries in the QoS classification table.
315 * @fs_entries: Number of entries in the flow steering table.
316 * @qos_key_size: Size, in bytes, of the QoS look-up key. Defining a key larger
317 * than this when adding QoS entries will result
319 * @fs_key_size: Size, in bytes, of the flow steering look-up key. Defining a
320 * key larger than this when composing the hash + FS key
321 * will result in an error.
322 * @wriop_version: Version of WRIOP HW block.
323 * The 3 version values are stored on 6, 5, 5 bits
326 * - 0x400 - WRIOP version 1.0.0, used on LS2080 and
328 * - 0x421 - WRIOP version 1.1.1, used on LS2088 and
330 * - 0x422 - WRIOP version 1.1.2, used on LS1088 and
338 uint8_t mac_filter_entries;
339 uint8_t vlan_filter_entries;
342 uint8_t qos_key_size;
344 uint16_t wriop_version;
347 int dpni_get_attributes(struct fsl_mc_io *mc_io,
350 struct dpni_attr *attr);
357 * Extract out of frame header error
359 #define DPNI_ERROR_EOFHE 0x00020000
363 #define DPNI_ERROR_FLE 0x00002000
365 * Frame physical error
367 #define DPNI_ERROR_FPE 0x00001000
369 * Parsing header error
371 #define DPNI_ERROR_PHE 0x00000020
373 * Parser L3 checksum error
375 #define DPNI_ERROR_L3CE 0x00000004
377 * Parser L3 checksum error
379 #define DPNI_ERROR_L4CE 0x00000001
382 * enum dpni_error_action - Defines DPNI behavior for errors
383 * @DPNI_ERROR_ACTION_DISCARD: Discard the frame
384 * @DPNI_ERROR_ACTION_CONTINUE: Continue with the normal flow
385 * @DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE: Send the frame to the error queue
387 enum dpni_error_action {
388 DPNI_ERROR_ACTION_DISCARD = 0,
389 DPNI_ERROR_ACTION_CONTINUE = 1,
390 DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE = 2
394 * struct dpni_error_cfg - Structure representing DPNI errors treatment
395 * @errors: Errors mask; use 'DPNI_ERROR__<X>
396 * @error_action: The desired action for the errors mask
397 * @set_frame_annotation: Set to '1' to mark the errors in frame
398 * annotation status (FAS); relevant only
399 * for the non-discard action
401 struct dpni_error_cfg {
403 enum dpni_error_action error_action;
404 int set_frame_annotation;
407 int dpni_set_errors_behavior(struct fsl_mc_io *mc_io,
410 struct dpni_error_cfg *cfg);
413 * DPNI buffer layout modification options
417 * Select to modify the time-stamp setting
419 #define DPNI_BUF_LAYOUT_OPT_TIMESTAMP 0x00000001
421 * Select to modify the parser-result setting; not applicable for Tx
423 #define DPNI_BUF_LAYOUT_OPT_PARSER_RESULT 0x00000002
425 * Select to modify the frame-status setting
427 #define DPNI_BUF_LAYOUT_OPT_FRAME_STATUS 0x00000004
429 * Select to modify the private-data-size setting
431 #define DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE 0x00000008
433 * Select to modify the data-alignment setting
435 #define DPNI_BUF_LAYOUT_OPT_DATA_ALIGN 0x00000010
437 * Select to modify the data-head-room setting
439 #define DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM 0x00000020
441 * Select to modify the data-tail-room setting
443 #define DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM 0x00000040
446 * struct dpni_buffer_layout - Structure representing DPNI buffer layout
447 * @options: Flags representing the suggested modifications to the
449 * Use any combination of 'DPNI_BUF_LAYOUT_OPT_<X>' flags
450 * @pass_timestamp: Pass timestamp value
451 * @pass_parser_result: Pass parser results
452 * @pass_frame_status: Pass frame status
453 * @private_data_size: Size kept for private data (in bytes)
454 * @data_align: Data alignment
455 * @data_head_room: Data head room
456 * @data_tail_room: Data tail room
458 struct dpni_buffer_layout {
461 int pass_parser_result;
462 int pass_frame_status;
463 uint16_t private_data_size;
465 uint16_t data_head_room;
466 uint16_t data_tail_room;
470 * enum dpni_queue_type - Identifies a type of queue targeted by the command
471 * @DPNI_QUEUE_RX: Rx queue
472 * @DPNI_QUEUE_TX: Tx queue
473 * @DPNI_QUEUE_TX_CONFIRM: Tx confirmation queue
474 * @DPNI_QUEUE_RX_ERR: Rx error queue
476 enum dpni_queue_type {
479 DPNI_QUEUE_TX_CONFIRM,
483 int dpni_get_buffer_layout(struct fsl_mc_io *mc_io,
486 enum dpni_queue_type qtype,
487 struct dpni_buffer_layout *layout);
489 int dpni_set_buffer_layout(struct fsl_mc_io *mc_io,
492 enum dpni_queue_type qtype,
493 const struct dpni_buffer_layout *layout);
496 * enum dpni_offload - Identifies a type of offload targeted by the command
497 * @DPNI_OFF_RX_L3_CSUM: Rx L3 checksum validation
498 * @DPNI_OFF_RX_L4_CSUM: Rx L4 checksum validation
499 * @DPNI_OFF_TX_L3_CSUM: Tx L3 checksum generation
500 * @DPNI_OFF_TX_L4_CSUM: Tx L4 checksum generation
501 * @DPNI_OPT_FLCTYPE_HASH: flow context will be generated by WRIOP for AIOP or
512 int dpni_set_offload(struct fsl_mc_io *mc_io,
515 enum dpni_offload type,
518 int dpni_get_offload(struct fsl_mc_io *mc_io,
521 enum dpni_offload type,
524 int dpni_get_qdid(struct fsl_mc_io *mc_io,
527 enum dpni_queue_type qtype,
530 int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io,
533 uint16_t *data_offset);
535 #define DPNI_STATISTICS_CNT 7
537 union dpni_statistics {
539 * struct page_0 - Page_0 statistics structure
540 * @ingress_all_frames: Ingress frame count
541 * @ingress_all_bytes: Ingress byte count
542 * @ingress_multicast_frames: Ingress multicast frame count
543 * @ingress_multicast_bytes: Ingress multicast byte count
544 * @ingress_broadcast_frames: Ingress broadcast frame count
545 * @ingress_broadcast_bytes: Ingress broadcast byte count
548 uint64_t ingress_all_frames;
549 uint64_t ingress_all_bytes;
550 uint64_t ingress_multicast_frames;
551 uint64_t ingress_multicast_bytes;
552 uint64_t ingress_broadcast_frames;
553 uint64_t ingress_broadcast_bytes;
556 * struct page_1 - Page_1 statistics structure
557 * @egress_all_frames: Egress frame count
558 * @egress_all_bytes: Egress byte count
559 * @egress_multicast_frames: Egress multicast frame count
560 * @egress_multicast_bytes: Egress multicast byte count
561 * @egress_broadcast_frames: Egress broadcast frame count
562 * @egress_broadcast_bytes: Egress broadcast byte count
565 uint64_t egress_all_frames;
566 uint64_t egress_all_bytes;
567 uint64_t egress_multicast_frames;
568 uint64_t egress_multicast_bytes;
569 uint64_t egress_broadcast_frames;
570 uint64_t egress_broadcast_bytes;
573 * struct page_2 - Page_2 statistics structure
574 * @ingress_filtered_frames: Ingress filtered frame count
575 * @ingress_discarded_frames: Ingress discarded frame count
576 * @ingress_nobuffer_discards: Ingress discarded frame count due to
578 * @egress_discarded_frames: Egress discarded frame count
579 * @egress_confirmed_frames: Egress confirmed frame count
582 uint64_t ingress_filtered_frames;
583 uint64_t ingress_discarded_frames;
584 uint64_t ingress_nobuffer_discards;
585 uint64_t egress_discarded_frames;
586 uint64_t egress_confirmed_frames;
589 * struct page_3 - Page_3 statistics structure with values for the
591 * @ceetm_dequeue_bytes: Cumulative count of the number of bytes
593 * @ceetm_dequeue_frames: Cumulative count of the number of frames
595 * @ceetm_reject_bytes: Cumulative count of the number of bytes in all
596 * frames whose enqueue was rejected
597 * @ceetm_reject_frames: Cumulative count of all frame enqueues rejected
600 uint64_t ceetm_dequeue_bytes;
601 uint64_t ceetm_dequeue_frames;
602 uint64_t ceetm_reject_bytes;
603 uint64_t ceetm_reject_frames;
606 * struct raw - raw statistics structure, used to index counters
609 uint64_t counter[DPNI_STATISTICS_CNT];
614 * Enable auto-negotiation
616 #define DPNI_LINK_OPT_AUTONEG 0x0000000000000001ULL
618 * Enable half-duplex mode
620 #define DPNI_LINK_OPT_HALF_DUPLEX 0x0000000000000002ULL
622 * Enable pause frames
624 #define DPNI_LINK_OPT_PAUSE 0x0000000000000004ULL
626 * Enable a-symmetric pause frames
628 #define DPNI_LINK_OPT_ASYM_PAUSE 0x0000000000000008ULL
630 * Enable priority flow control pause frames
632 #define DPNI_LINK_OPT_PFC_PAUSE 0x0000000000000010ULL
635 * struct - Structure representing DPNI link configuration
637 * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
639 struct dpni_link_cfg {
644 int dpni_set_link_cfg(struct fsl_mc_io *mc_io,
647 const struct dpni_link_cfg *cfg);
650 * struct dpni_link_state - Structure representing DPNI link state
652 * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
653 * @up: Link state; '0' for down, '1' for up
655 struct dpni_link_state {
661 int dpni_get_link_state(struct fsl_mc_io *mc_io,
664 struct dpni_link_state *state);
666 int dpni_set_max_frame_length(struct fsl_mc_io *mc_io,
669 uint16_t max_frame_length);
671 int dpni_get_max_frame_length(struct fsl_mc_io *mc_io,
674 uint16_t *max_frame_length);
676 int dpni_set_mtu(struct fsl_mc_io *mc_io,
681 int dpni_get_mtu(struct fsl_mc_io *mc_io,
686 int dpni_set_multicast_promisc(struct fsl_mc_io *mc_io,
691 int dpni_get_multicast_promisc(struct fsl_mc_io *mc_io,
696 int dpni_set_unicast_promisc(struct fsl_mc_io *mc_io,
701 int dpni_get_unicast_promisc(struct fsl_mc_io *mc_io,
706 int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
709 const uint8_t mac_addr[6]);
711 int dpni_get_primary_mac_addr(struct fsl_mc_io *mc_io,
714 uint8_t mac_addr[6]);
716 int dpni_add_mac_addr(struct fsl_mc_io *mc_io,
719 const uint8_t mac_addr[6]);
721 int dpni_remove_mac_addr(struct fsl_mc_io *mc_io,
724 const uint8_t mac_addr[6]);
726 int dpni_clear_mac_filters(struct fsl_mc_io *mc_io,
732 int dpni_get_port_mac_addr(struct fsl_mc_io *mc_io,
735 uint8_t mac_addr[6]);
737 int dpni_enable_vlan_filter(struct fsl_mc_io *mc_io,
742 int dpni_add_vlan_id(struct fsl_mc_io *mc_io,
747 int dpni_remove_vlan_id(struct fsl_mc_io *mc_io,
752 int dpni_clear_vlan_filters(struct fsl_mc_io *mc_io,
757 * enum dpni_dist_mode - DPNI distribution mode
758 * @DPNI_DIST_MODE_NONE: No distribution
759 * @DPNI_DIST_MODE_HASH: Use hash distribution; only relevant if
760 * the 'DPNI_OPT_DIST_HASH' option was set at DPNI creation
761 * @DPNI_DIST_MODE_FS: Use explicit flow steering; only relevant if
762 * the 'DPNI_OPT_DIST_FS' option was set at DPNI creation
764 enum dpni_dist_mode {
765 DPNI_DIST_MODE_NONE = 0,
766 DPNI_DIST_MODE_HASH = 1,
767 DPNI_DIST_MODE_FS = 2
771 * enum dpni_fs_miss_action - DPNI Flow Steering miss action
772 * @DPNI_FS_MISS_DROP: In case of no-match, drop the frame
773 * @DPNI_FS_MISS_EXPLICIT_FLOWID: In case of no-match, use explicit flow-id
774 * @DPNI_FS_MISS_HASH: In case of no-match, distribute using hash
776 enum dpni_fs_miss_action {
777 DPNI_FS_MISS_DROP = 0,
778 DPNI_FS_MISS_EXPLICIT_FLOWID = 1,
779 DPNI_FS_MISS_HASH = 2
783 * struct dpni_fs_tbl_cfg - Flow Steering table configuration
784 * @miss_action: Miss action selection
785 * @default_flow_id: Used when 'miss_action = DPNI_FS_MISS_EXPLICIT_FLOWID'
787 struct dpni_fs_tbl_cfg {
788 enum dpni_fs_miss_action miss_action;
789 uint16_t default_flow_id;
794 * struct dpni_rx_tc_dist_cfg - Rx traffic class distribution configuration
795 * @dist_size: Set the distribution size;
796 * supported values: 1,2,3,4,6,7,8,12,14,16,24,28,32,48,56,64,96,
797 * 112,128,192,224,256,384,448,512,768,896,1024
798 * @dist_mode: Distribution mode
799 * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
800 * the extractions to be used for the distribution key by calling
801 * dpkg_prepare_key_cfg() relevant only when
802 * 'dist_mode != DPNI_DIST_MODE_NONE', otherwise it can be '0'
803 * @fs_cfg: Flow Steering table configuration; only relevant if
804 * 'dist_mode = DPNI_DIST_MODE_FS'
806 struct dpni_rx_tc_dist_cfg {
808 enum dpni_dist_mode dist_mode;
809 uint64_t key_cfg_iova;
810 struct dpni_fs_tbl_cfg fs_cfg;
813 int dpni_set_rx_tc_dist(struct fsl_mc_io *mc_io,
817 const struct dpni_rx_tc_dist_cfg *cfg);
820 * enum dpni_congestion_unit - DPNI congestion units
821 * @DPNI_CONGESTION_UNIT_BYTES: bytes units
822 * @DPNI_CONGESTION_UNIT_FRAMES: frames units
824 enum dpni_congestion_unit {
825 DPNI_CONGESTION_UNIT_BYTES = 0,
826 DPNI_CONGESTION_UNIT_FRAMES
831 * enum dpni_dest - DPNI destination types
832 * @DPNI_DEST_NONE: Unassigned destination; The queue is set in parked mode and
833 * does not generate FQDAN notifications; user is expected to
834 * dequeue from the queue based on polling or other user-defined
836 * @DPNI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
837 * notifications to the specified DPIO; user is expected to dequeue
838 * from the queue only after notification is received
839 * @DPNI_DEST_DPCON: The queue is set in schedule mode and does not generate
840 * FQDAN notifications, but is connected to the specified DPCON
841 * object; user is expected to dequeue from the DPCON channel
850 * struct dpni_dest_cfg - Structure representing DPNI destination parameters
851 * @dest_type: Destination type
852 * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
853 * @priority: Priority selection within the DPIO or DPCON channel; valid values
854 * are 0-1 or 0-7, depending on the number of priorities in that
855 * channel; not relevant for 'DPNI_DEST_NONE' option
857 struct dpni_dest_cfg {
858 enum dpni_dest dest_type;
863 /* DPNI congestion options */
866 * CSCN message is written to message_iova once entering a
867 * congestion state (see 'threshold_entry')
869 #define DPNI_CONG_OPT_WRITE_MEM_ON_ENTER 0x00000001
871 * CSCN message is written to message_iova once exiting a
872 * congestion state (see 'threshold_exit')
874 #define DPNI_CONG_OPT_WRITE_MEM_ON_EXIT 0x00000002
876 * CSCN write will attempt to allocate into a cache (coherent write);
877 * valid only if 'DPNI_CONG_OPT_WRITE_MEM_<X>' is selected
879 #define DPNI_CONG_OPT_COHERENT_WRITE 0x00000004
881 * if 'dest_cfg.dest_type != DPNI_DEST_NONE' CSCN message is sent to
882 * DPIO/DPCON's WQ channel once entering a congestion state
883 * (see 'threshold_entry')
885 #define DPNI_CONG_OPT_NOTIFY_DEST_ON_ENTER 0x00000008
887 * if 'dest_cfg.dest_type != DPNI_DEST_NONE' CSCN message is sent to
888 * DPIO/DPCON's WQ channel once exiting a congestion state
889 * (see 'threshold_exit')
891 #define DPNI_CONG_OPT_NOTIFY_DEST_ON_EXIT 0x00000010
893 * if 'dest_cfg.dest_type != DPNI_DEST_NONE' when the CSCN is written to the
894 * sw-portal's DQRR, the DQRI interrupt is asserted immediately (if enabled)
896 #define DPNI_CONG_OPT_INTR_COALESCING_DISABLED 0x00000020
898 * This congestion will trigger flow control or priority flow control. This
899 * will have effect only if flow control is enabled with dpni_set_link_cfg()
901 #define DPNI_CONG_OPT_FLOW_CONTROL 0x00000040
904 * struct dpni_congestion_notification_cfg - congestion notification
907 * @threshold_entry: above this threshold we enter a congestion state.
908 * set it to '0' to disable it
909 * @threshold_exit: below this threshold we exit the congestion state.
910 * @message_ctx: The context that will be part of the CSCN message
911 * @message_iova: I/O virtual address (must be in DMA-able memory),
912 * must be 16B aligned; valid only if 'DPNI_CONG_OPT_WRITE_MEM_<X>' is
913 * contained in 'options'
914 * @dest_cfg: CSCN can be send to either DPIO or DPCON WQ channel
915 * @notification_mode: Mask of available options; use 'DPNI_CONG_OPT_<X>' values
918 struct dpni_congestion_notification_cfg {
919 enum dpni_congestion_unit units;
920 uint32_t threshold_entry;
921 uint32_t threshold_exit;
922 uint64_t message_ctx;
923 uint64_t message_iova;
924 struct dpni_dest_cfg dest_cfg;
925 uint16_t notification_mode;
928 int dpni_set_congestion_notification(struct fsl_mc_io *mc_io,
931 enum dpni_queue_type qtype,
933 const struct dpni_congestion_notification_cfg *cfg);
935 int dpni_get_congestion_notification(struct fsl_mc_io *mc_io,
938 enum dpni_queue_type qtype,
940 struct dpni_congestion_notification_cfg *cfg);
942 /* DPNI FLC stash options */
945 * stashes the whole annotation area (up to 192 bytes)
947 #define DPNI_FLC_STASH_FRAME_ANNOTATION 0x00000001
950 * struct dpni_queue - Queue structure
951 * @user_context: User data, presented to the user along with any frames
952 * from this queue. Not relevant for Tx queues.
956 * struct destination - Destination structure
957 * @id: ID of the destination, only relevant if DEST_TYPE is > 0.
958 * Identifies either a DPIO or a DPCON object.
959 * Not relevant for Tx queues.
960 * @type: May be one of the following:
961 * 0 - No destination, queue can be manually
962 * queried, but will not push traffic or
963 * notifications to a DPIO;
964 * 1 - The destination is a DPIO. When traffic
965 * becomes available in the queue a FQDAN
966 * (FQ data available notification) will be
967 * generated to selected DPIO;
968 * 2 - The destination is a DPCON. The queue is
969 * associated with a DPCON object for the
970 * purpose of scheduling between multiple
971 * queues. The DPCON may be independently
972 * configured to generate notifications.
973 * Not relevant for Tx queues.
974 * @hold_active: Hold active, maintains a queue scheduled for longer
975 * in a DPIO during dequeue to reduce spread of traffic.
976 * Only relevant if queues are
977 * not affined to a single DPIO.
985 uint64_t user_context;
987 * struct flc - FD FLow Context structure
988 * @value: Default FLC value for traffic dequeued from
989 * this queue. Please check description of FD
990 * structure for more information.
991 * Note that FLC values set using dpni_add_fs_entry,
992 * if any, take precedence over values per queue.
993 * @stash_control: Boolean, indicates whether the 6 lowest
994 * - significant bits are used for stash control.
995 * significant bits are used for stash control. If set, the 6
996 * least significant bits in value are interpreted as follows:
997 * - bits 0-1: indicates the number of 64 byte units of context
998 * that are stashed. FLC value is interpreted as a memory address
999 * in this case, excluding the 6 LS bits.
1000 * - bits 2-3: indicates the number of 64 byte units of frame
1001 * annotation to be stashed. Annotation is placed at FD[ADDR].
1002 * - bits 4-5: indicates the number of 64 byte units of frame
1003 * data to be stashed. Frame data is placed at FD[ADDR] +
1005 * For more details check the Frame Descriptor section in the
1006 * hardware documentation.
1015 * struct dpni_queue_id - Queue identification, used for enqueue commands
1017 * @fqid: FQID used for enqueueing to and/or configuration of this
1019 * @qdbin: Queueing bin, used to enqueue using QDID, DQBIN, QPRI.
1020 * Only relevant for Tx queues.
1022 struct dpni_queue_id {
1028 * enum dpni_confirmation_mode - Defines DPNI options supported for Tx
1030 * @DPNI_CONF_AFFINE: For each Tx queue set associated with a sender there is
1031 * an affine Tx Confirmation queue
1032 * @DPNI_CONF_SINGLE: All Tx queues are associated with a single Tx
1033 * confirmation queue
1034 * @DPNI_CONF_DISABLE: Tx frames are not confirmed. This must be associated
1035 * with proper FD set-up to have buffers release to a Buffer Pool, otherwise
1036 * buffers will be leaked
1038 enum dpni_confirmation_mode {
1044 int dpni_set_tx_confirmation_mode(struct fsl_mc_io *mc_io,
1047 enum dpni_confirmation_mode mode);
1049 int dpni_get_tx_confirmation_mode(struct fsl_mc_io *mc_io,
1052 enum dpni_confirmation_mode *mode);
1054 int dpni_get_api_version(struct fsl_mc_io *mc_io,
1056 uint16_t *major_ver,
1057 uint16_t *minor_ver);
1062 #define DPNI_QUEUE_OPT_USER_CTX 0x00000001
1065 * Set queue destination configuration
1067 #define DPNI_QUEUE_OPT_DEST 0x00000002
1070 * Set FD[FLC] configuration for traffic on this queue. Note that FLC values
1071 * set with dpni_add_fs_entry, if any, take precedence over values per queue.
1073 #define DPNI_QUEUE_OPT_FLC 0x00000004
1076 * Set the queue to hold active mode. This prevents the queue from being
1077 * rescheduled between DPIOs while it carries traffic and is active on one
1078 * DPNI. Can help reduce reordering when servicing one queue on multiple
1079 * CPUs, but the queue is also less likely to push data to multiple CPUs
1080 * especially when congested.
1082 #define DPNI_QUEUE_OPT_HOLD_ACTIVE 0x00000008
1084 int dpni_set_queue(struct fsl_mc_io *mc_io,
1087 enum dpni_queue_type qtype,
1091 const struct dpni_queue *queue);
1093 int dpni_get_queue(struct fsl_mc_io *mc_io,
1096 enum dpni_queue_type qtype,
1099 struct dpni_queue *queue,
1100 struct dpni_queue_id *qid);
1102 int dpni_get_statistics(struct fsl_mc_io *mc_io,
1107 union dpni_statistics *stat);
1109 int dpni_reset_statistics(struct fsl_mc_io *mc_io,
1114 * enum dpni_congestion_point - Structure representing congestion point
1115 * @DPNI_CP_QUEUE: Set taildrop per queue, identified by QUEUE_TYPE, TC and
1117 * @DPNI_CP_GROUP: Set taildrop per queue group. Depending on options used
1118 * to define the DPNI this can be either per
1119 * TC (default) or per interface
1120 * (DPNI_OPT_SHARED_CONGESTION set at DPNI create).
1121 * QUEUE_INDEX is ignored if this type is used.
1123 enum dpni_congestion_point {
1129 * struct dpni_taildrop - Structure representing the taildrop
1130 * @enable: Indicates whether the taildrop is active or not.
1131 * @units: Indicates the unit of THRESHOLD. Queue taildrop only
1132 * supports byte units, this field is ignored and
1133 * assumed = 0 if CONGESTION_POINT is 0.
1134 * @threshold: Threshold value, in units identified by UNITS field. Value 0
1135 * cannot be used as a valid taildrop threshold,
1136 * THRESHOLD must be > 0 if the taildrop is
1138 * @oal : Overhead Accounting Length, a 12-bit, 2's complement value
1139 * with range (-2048 to +2047) representing a fixed per-frame
1140 * overhead to be added to the actual length of a frame when
1141 * performing WRED and tail drop calculations and threshold
1144 struct dpni_taildrop {
1146 enum dpni_congestion_unit units;
1151 int dpni_set_taildrop(struct fsl_mc_io *mc_io,
1154 enum dpni_congestion_point cg_point,
1155 enum dpni_queue_type q_type,
1158 struct dpni_taildrop *taildrop);
1160 int dpni_get_taildrop(struct fsl_mc_io *mc_io,
1163 enum dpni_congestion_point cg_point,
1164 enum dpni_queue_type q_type,
1167 struct dpni_taildrop *taildrop);
1168 #endif /* __FSL_DPNI_H */