1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
3 * Copyright 2013-2016 Freescale Semiconductor Inc.
4 * Copyright 2016-2017 NXP
15 * Data Path Network Interface API
16 * Contains initialization APIs and runtime control APIs for DPNI
19 /** General DPNI macros */
22 * Maximum number of traffic classes
26 * Maximum number of buffer pools per DPNI
28 #define DPNI_MAX_DPBP 8
30 * Maximum number of storage-profiles per DPNI
35 * All traffic classes considered; see dpni_set_queue()
37 #define DPNI_ALL_TCS (uint8_t)(-1)
39 * All flows within traffic class considered; see dpni_set_queue()
41 #define DPNI_ALL_TC_FLOWS (uint16_t)(-1)
44 * Tx traffic is always released to a buffer pool on transmit, there are no
45 * resources allocated to have the frames confirmed back to the source after
48 #define DPNI_OPT_TX_FRM_RELEASE 0x000001
50 * Disables support for MAC address filtering for addresses other than primary
51 * MAC address. This affects both unicast and multicast. Promiscuous mode can
52 * still be enabled/disabled for both unicast and multicast. If promiscuous mode
53 * is disabled, only traffic matching the primary MAC address will be accepted.
55 #define DPNI_OPT_NO_MAC_FILTER 0x000002
57 * Allocate policers for this DPNI. They can be used to rate-limit traffic per
58 * traffic class (TC) basis.
60 #define DPNI_OPT_HAS_POLICING 0x000004
62 * Congestion can be managed in several ways, allowing the buffer pool to
63 * deplete on ingress, taildrop on each queue or use congestion groups for sets
64 * of queues. If set, it configures a single congestion groups across all TCs.
65 * If reset, a congestion group is allocated for each TC. Only relevant if the
66 * DPNI has multiple traffic classes.
68 #define DPNI_OPT_SHARED_CONGESTION 0x000008
70 * Enables TCAM for Flow Steering and QoS look-ups. If not specified, all
71 * look-ups are exact match. Note that TCAM is not available on LS1088 and its
72 * variants. Setting this bit on these SoCs will trigger an error.
74 #define DPNI_OPT_HAS_KEY_MASKING 0x000010
76 * Disables the flow steering table.
78 #define DPNI_OPT_NO_FS 0x000020
80 int dpni_open(struct fsl_mc_io *mc_io,
85 int dpni_close(struct fsl_mc_io *mc_io,
90 * struct dpni_cfg - Structure representing DPNI configuration
91 * @mac_addr: Primary MAC address
92 * @adv: Advanced parameters; default is all zeros;
93 * use this structure to change default settings
97 * @options: Any combination of the following options:
98 * DPNI_OPT_TX_FRM_RELEASE
99 * DPNI_OPT_NO_MAC_FILTER
100 * DPNI_OPT_HAS_POLICING
101 * DPNI_OPT_SHARED_CONGESTION
102 * DPNI_OPT_HAS_KEY_MASKING
104 * @fs_entries: Number of entries in the flow steering table.
105 * This table is used to select the ingress queue for
106 * ingress traffic, targeting a GPP core or another.
107 * In addition it can be used to discard traffic that
108 * matches the set rule. It is either an exact match table
109 * or a TCAM table, depending on DPNI_OPT_ HAS_KEY_MASKING
110 * bit in OPTIONS field. This field is ignored if
111 * DPNI_OPT_NO_FS bit is set in OPTIONS field. Otherwise,
112 * value 0 defaults to 64. Maximum supported value is 1024.
113 * Note that the total number of entries is limited on the
114 * SoC to as low as 512 entries if TCAM is used.
115 * @vlan_filter_entries: Number of entries in the VLAN address filtering
116 * table. This is an exact match table used to filter
117 * ingress traffic based on VLAN IDs. Value 0 disables VLAN
118 * filtering. Maximum supported value is 16.
119 * @mac_filter_entries: Number of entries in the MAC address filtering
120 * table. This is an exact match table and allows both
121 * unicast and multicast entries. The primary MAC address
122 * of the network interface is not part of this table,
123 * this contains only entries in addition to it. This
124 * field is ignored if DPNI_OPT_ NO_MAC_FILTER is set in
125 * OPTIONS field. Otherwise, value 0 defaults to 80.
126 * Maximum supported value is 80.
127 * @num_queues: Number of Tx and Rx queues used for traffic
128 * distribution. This is orthogonal to QoS and is only
129 * used to distribute traffic to multiple GPP cores.
130 * This configuration affects the number of Tx queues
131 * (logical FQs, all associated with a single CEETM queue),
132 * Rx queues and Tx confirmation queues, if applicable.
133 * Value 0 defaults to one queue. Maximum supported value
135 * @num_tcs: Number of traffic classes (TCs), reserved for the DPNI.
136 * TCs can have different priority levels for the purpose
137 * of Tx scheduling (see DPNI_SET_TX_SELECTION), different
138 * BPs (DPNI_ SET_POOLS), policers. There are dedicated QM
139 * queues for traffic classes (including class queues on
140 * Tx). Value 0 defaults to one TC. Maximum supported value
142 * @qos_entries: Number of entries in the QoS classification table. This
143 * table is used to select the TC for ingress traffic. It
144 * is either an exact match or a TCAM table, depending on
145 * DPNI_OPT_ HAS_KEY_MASKING bit in OPTIONS field. This
146 * field is ignored if the DPNI has a single TC. Otherwise,
147 * a value of 0 defaults to 64. Maximum supported value
152 uint8_t vlan_filter_entries;
153 uint8_t mac_filter_entries;
159 int dpni_create(struct fsl_mc_io *mc_io,
162 const struct dpni_cfg *cfg,
165 int dpni_destroy(struct fsl_mc_io *mc_io,
171 * struct dpni_pools_cfg - Structure representing buffer pools configuration
172 * @num_dpbp: Number of DPBPs
173 * @pools: Array of buffer pools parameters; The number of valid entries
174 * must match 'num_dpbp' value
176 struct dpni_pools_cfg {
179 * struct pools - Buffer pools parameters
180 * @dpbp_id: DPBP object ID
181 * @priority: priority mask that indicates TC's used with this buffer.
182 * I set to 0x00 MC will assume value 0xff.
183 * @buffer_size: Buffer size
184 * @backup_pool: Backup pool
188 uint8_t priority_mask;
189 uint16_t buffer_size;
191 } pools[DPNI_MAX_DPBP];
194 int dpni_set_pools(struct fsl_mc_io *mc_io,
197 const struct dpni_pools_cfg *cfg);
199 int dpni_enable(struct fsl_mc_io *mc_io,
203 int dpni_disable(struct fsl_mc_io *mc_io,
207 int dpni_is_enabled(struct fsl_mc_io *mc_io,
212 int dpni_reset(struct fsl_mc_io *mc_io,
217 * DPNI IRQ Index and Events
223 #define DPNI_IRQ_INDEX 0
225 * IRQ event - indicates a change in link state
227 #define DPNI_IRQ_EVENT_LINK_CHANGED 0x00000001
229 int dpni_set_irq_enable(struct fsl_mc_io *mc_io,
235 int dpni_get_irq_enable(struct fsl_mc_io *mc_io,
241 int dpni_set_irq_mask(struct fsl_mc_io *mc_io,
247 int dpni_get_irq_mask(struct fsl_mc_io *mc_io,
253 int dpni_get_irq_status(struct fsl_mc_io *mc_io,
259 int dpni_clear_irq_status(struct fsl_mc_io *mc_io,
266 * struct dpni_attr - Structure representing DPNI attributes
267 * @options: Any combination of the following options:
268 * DPNI_OPT_TX_FRM_RELEASE
269 * DPNI_OPT_NO_MAC_FILTER
270 * DPNI_OPT_HAS_POLICING
271 * DPNI_OPT_SHARED_CONGESTION
272 * DPNI_OPT_HAS_KEY_MASKING
274 * @num_queues: Number of Tx and Rx queues used for traffic distribution.
275 * @num_rx_tcs: Number of RX traffic classes (TCs), reserved for the DPNI.
276 * @num_tx_tcs: Number of TX traffic classes (TCs), reserved for the DPNI.
277 * @mac_filter_entries: Number of entries in the MAC address filtering
279 * @vlan_filter_entries: Number of entries in the VLAN address filtering
281 * @qos_entries: Number of entries in the QoS classification table.
282 * @fs_entries: Number of entries in the flow steering table.
283 * @qos_key_size: Size, in bytes, of the QoS look-up key. Defining a key larger
284 * than this when adding QoS entries will result
286 * @fs_key_size: Size, in bytes, of the flow steering look-up key. Defining a
287 * key larger than this when composing the hash + FS key
288 * will result in an error.
289 * @wriop_version: Version of WRIOP HW block.
290 * The 3 version values are stored on 6, 5, 5 bits
293 * - 0x400 - WRIOP version 1.0.0, used on LS2080 and
295 * - 0x421 - WRIOP version 1.1.1, used on LS2088 and
297 * - 0x422 - WRIOP version 1.1.2, used on LS1088 and
305 uint8_t mac_filter_entries;
306 uint8_t vlan_filter_entries;
309 uint8_t qos_key_size;
311 uint16_t wriop_version;
314 int dpni_get_attributes(struct fsl_mc_io *mc_io,
317 struct dpni_attr *attr);
324 * Extract out of frame header error
326 #define DPNI_ERROR_EOFHE 0x00020000
330 #define DPNI_ERROR_FLE 0x00002000
332 * Frame physical error
334 #define DPNI_ERROR_FPE 0x00001000
336 * Parsing header error
338 #define DPNI_ERROR_PHE 0x00000020
340 * Parser L3 checksum error
342 #define DPNI_ERROR_L3CE 0x00000004
344 * Parser L3 checksum error
346 #define DPNI_ERROR_L4CE 0x00000001
349 * enum dpni_error_action - Defines DPNI behavior for errors
350 * @DPNI_ERROR_ACTION_DISCARD: Discard the frame
351 * @DPNI_ERROR_ACTION_CONTINUE: Continue with the normal flow
352 * @DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE: Send the frame to the error queue
354 enum dpni_error_action {
355 DPNI_ERROR_ACTION_DISCARD = 0,
356 DPNI_ERROR_ACTION_CONTINUE = 1,
357 DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE = 2
361 * struct dpni_error_cfg - Structure representing DPNI errors treatment
362 * @errors: Errors mask; use 'DPNI_ERROR__<X>
363 * @error_action: The desired action for the errors mask
364 * @set_frame_annotation: Set to '1' to mark the errors in frame
365 * annotation status (FAS); relevant only
366 * for the non-discard action
368 struct dpni_error_cfg {
370 enum dpni_error_action error_action;
371 int set_frame_annotation;
374 int dpni_set_errors_behavior(struct fsl_mc_io *mc_io,
377 struct dpni_error_cfg *cfg);
380 * DPNI buffer layout modification options
384 * Select to modify the time-stamp setting
386 #define DPNI_BUF_LAYOUT_OPT_TIMESTAMP 0x00000001
388 * Select to modify the parser-result setting; not applicable for Tx
390 #define DPNI_BUF_LAYOUT_OPT_PARSER_RESULT 0x00000002
392 * Select to modify the frame-status setting
394 #define DPNI_BUF_LAYOUT_OPT_FRAME_STATUS 0x00000004
396 * Select to modify the private-data-size setting
398 #define DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE 0x00000008
400 * Select to modify the data-alignment setting
402 #define DPNI_BUF_LAYOUT_OPT_DATA_ALIGN 0x00000010
404 * Select to modify the data-head-room setting
406 #define DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM 0x00000020
408 * Select to modify the data-tail-room setting
410 #define DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM 0x00000040
413 * struct dpni_buffer_layout - Structure representing DPNI buffer layout
414 * @options: Flags representing the suggested modifications to the
416 * Use any combination of 'DPNI_BUF_LAYOUT_OPT_<X>' flags
417 * @pass_timestamp: Pass timestamp value
418 * @pass_parser_result: Pass parser results
419 * @pass_frame_status: Pass frame status
420 * @private_data_size: Size kept for private data (in bytes)
421 * @data_align: Data alignment
422 * @data_head_room: Data head room
423 * @data_tail_room: Data tail room
425 struct dpni_buffer_layout {
428 int pass_parser_result;
429 int pass_frame_status;
430 uint16_t private_data_size;
432 uint16_t data_head_room;
433 uint16_t data_tail_room;
437 * enum dpni_queue_type - Identifies a type of queue targeted by the command
438 * @DPNI_QUEUE_RX: Rx queue
439 * @DPNI_QUEUE_TX: Tx queue
440 * @DPNI_QUEUE_TX_CONFIRM: Tx confirmation queue
441 * @DPNI_QUEUE_RX_ERR: Rx error queue
443 enum dpni_queue_type {
446 DPNI_QUEUE_TX_CONFIRM,
450 int dpni_get_buffer_layout(struct fsl_mc_io *mc_io,
453 enum dpni_queue_type qtype,
454 struct dpni_buffer_layout *layout);
456 int dpni_set_buffer_layout(struct fsl_mc_io *mc_io,
459 enum dpni_queue_type qtype,
460 const struct dpni_buffer_layout *layout);
463 * enum dpni_offload - Identifies a type of offload targeted by the command
464 * @DPNI_OFF_RX_L3_CSUM: Rx L3 checksum validation
465 * @DPNI_OFF_RX_L4_CSUM: Rx L4 checksum validation
466 * @DPNI_OFF_TX_L3_CSUM: Tx L3 checksum generation
467 * @DPNI_OFF_TX_L4_CSUM: Tx L4 checksum generation
468 * @DPNI_OPT_FLCTYPE_HASH: flow context will be generated by WRIOP for AIOP or
479 int dpni_set_offload(struct fsl_mc_io *mc_io,
482 enum dpni_offload type,
485 int dpni_get_offload(struct fsl_mc_io *mc_io,
488 enum dpni_offload type,
491 int dpni_get_qdid(struct fsl_mc_io *mc_io,
494 enum dpni_queue_type qtype,
497 int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io,
500 uint16_t *data_offset);
502 #define DPNI_STATISTICS_CNT 7
504 union dpni_statistics {
506 * struct page_0 - Page_0 statistics structure
507 * @ingress_all_frames: Ingress frame count
508 * @ingress_all_bytes: Ingress byte count
509 * @ingress_multicast_frames: Ingress multicast frame count
510 * @ingress_multicast_bytes: Ingress multicast byte count
511 * @ingress_broadcast_frames: Ingress broadcast frame count
512 * @ingress_broadcast_bytes: Ingress broadcast byte count
515 uint64_t ingress_all_frames;
516 uint64_t ingress_all_bytes;
517 uint64_t ingress_multicast_frames;
518 uint64_t ingress_multicast_bytes;
519 uint64_t ingress_broadcast_frames;
520 uint64_t ingress_broadcast_bytes;
523 * struct page_1 - Page_1 statistics structure
524 * @egress_all_frames: Egress frame count
525 * @egress_all_bytes: Egress byte count
526 * @egress_multicast_frames: Egress multicast frame count
527 * @egress_multicast_bytes: Egress multicast byte count
528 * @egress_broadcast_frames: Egress broadcast frame count
529 * @egress_broadcast_bytes: Egress broadcast byte count
532 uint64_t egress_all_frames;
533 uint64_t egress_all_bytes;
534 uint64_t egress_multicast_frames;
535 uint64_t egress_multicast_bytes;
536 uint64_t egress_broadcast_frames;
537 uint64_t egress_broadcast_bytes;
540 * struct page_2 - Page_2 statistics structure
541 * @ingress_filtered_frames: Ingress filtered frame count
542 * @ingress_discarded_frames: Ingress discarded frame count
543 * @ingress_nobuffer_discards: Ingress discarded frame count due to
545 * @egress_discarded_frames: Egress discarded frame count
546 * @egress_confirmed_frames: Egress confirmed frame count
549 uint64_t ingress_filtered_frames;
550 uint64_t ingress_discarded_frames;
551 uint64_t ingress_nobuffer_discards;
552 uint64_t egress_discarded_frames;
553 uint64_t egress_confirmed_frames;
556 * struct page_3 - Page_3 statistics structure with values for the
558 * @ceetm_dequeue_bytes: Cumulative count of the number of bytes
560 * @ceetm_dequeue_frames: Cumulative count of the number of frames
562 * @ceetm_reject_bytes: Cumulative count of the number of bytes in all
563 * frames whose enqueue was rejected
564 * @ceetm_reject_frames: Cumulative count of all frame enqueues rejected
567 uint64_t ceetm_dequeue_bytes;
568 uint64_t ceetm_dequeue_frames;
569 uint64_t ceetm_reject_bytes;
570 uint64_t ceetm_reject_frames;
573 * struct raw - raw statistics structure, used to index counters
576 uint64_t counter[DPNI_STATISTICS_CNT];
581 * Enable auto-negotiation
583 #define DPNI_LINK_OPT_AUTONEG 0x0000000000000001ULL
585 * Enable half-duplex mode
587 #define DPNI_LINK_OPT_HALF_DUPLEX 0x0000000000000002ULL
589 * Enable pause frames
591 #define DPNI_LINK_OPT_PAUSE 0x0000000000000004ULL
593 * Enable a-symmetric pause frames
595 #define DPNI_LINK_OPT_ASYM_PAUSE 0x0000000000000008ULL
597 * Enable priority flow control pause frames
599 #define DPNI_LINK_OPT_PFC_PAUSE 0x0000000000000010ULL
602 * struct - Structure representing DPNI link configuration
604 * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
606 struct dpni_link_cfg {
611 int dpni_set_link_cfg(struct fsl_mc_io *mc_io,
614 const struct dpni_link_cfg *cfg);
617 * struct dpni_link_state - Structure representing DPNI link state
619 * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
620 * @up: Link state; '0' for down, '1' for up
622 struct dpni_link_state {
628 int dpni_get_link_state(struct fsl_mc_io *mc_io,
631 struct dpni_link_state *state);
633 int dpni_set_max_frame_length(struct fsl_mc_io *mc_io,
636 uint16_t max_frame_length);
638 int dpni_get_max_frame_length(struct fsl_mc_io *mc_io,
641 uint16_t *max_frame_length);
643 int dpni_set_mtu(struct fsl_mc_io *mc_io,
648 int dpni_get_mtu(struct fsl_mc_io *mc_io,
653 int dpni_set_multicast_promisc(struct fsl_mc_io *mc_io,
658 int dpni_get_multicast_promisc(struct fsl_mc_io *mc_io,
663 int dpni_set_unicast_promisc(struct fsl_mc_io *mc_io,
668 int dpni_get_unicast_promisc(struct fsl_mc_io *mc_io,
673 int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
676 const uint8_t mac_addr[6]);
678 int dpni_get_primary_mac_addr(struct fsl_mc_io *mc_io,
681 uint8_t mac_addr[6]);
683 int dpni_add_mac_addr(struct fsl_mc_io *mc_io,
686 const uint8_t mac_addr[6]);
688 int dpni_remove_mac_addr(struct fsl_mc_io *mc_io,
691 const uint8_t mac_addr[6]);
693 int dpni_clear_mac_filters(struct fsl_mc_io *mc_io,
699 int dpni_get_port_mac_addr(struct fsl_mc_io *mc_io,
702 uint8_t mac_addr[6]);
704 int dpni_enable_vlan_filter(struct fsl_mc_io *mc_io,
709 int dpni_add_vlan_id(struct fsl_mc_io *mc_io,
714 int dpni_remove_vlan_id(struct fsl_mc_io *mc_io,
719 int dpni_clear_vlan_filters(struct fsl_mc_io *mc_io,
724 * enum dpni_dist_mode - DPNI distribution mode
725 * @DPNI_DIST_MODE_NONE: No distribution
726 * @DPNI_DIST_MODE_HASH: Use hash distribution; only relevant if
727 * the 'DPNI_OPT_DIST_HASH' option was set at DPNI creation
728 * @DPNI_DIST_MODE_FS: Use explicit flow steering; only relevant if
729 * the 'DPNI_OPT_DIST_FS' option was set at DPNI creation
731 enum dpni_dist_mode {
732 DPNI_DIST_MODE_NONE = 0,
733 DPNI_DIST_MODE_HASH = 1,
734 DPNI_DIST_MODE_FS = 2
738 * enum dpni_fs_miss_action - DPNI Flow Steering miss action
739 * @DPNI_FS_MISS_DROP: In case of no-match, drop the frame
740 * @DPNI_FS_MISS_EXPLICIT_FLOWID: In case of no-match, use explicit flow-id
741 * @DPNI_FS_MISS_HASH: In case of no-match, distribute using hash
743 enum dpni_fs_miss_action {
744 DPNI_FS_MISS_DROP = 0,
745 DPNI_FS_MISS_EXPLICIT_FLOWID = 1,
746 DPNI_FS_MISS_HASH = 2
750 * struct dpni_fs_tbl_cfg - Flow Steering table configuration
751 * @miss_action: Miss action selection
752 * @default_flow_id: Used when 'miss_action = DPNI_FS_MISS_EXPLICIT_FLOWID'
754 struct dpni_fs_tbl_cfg {
755 enum dpni_fs_miss_action miss_action;
756 uint16_t default_flow_id;
761 * struct dpni_rx_tc_dist_cfg - Rx traffic class distribution configuration
762 * @dist_size: Set the distribution size;
763 * supported values: 1,2,3,4,6,7,8,12,14,16,24,28,32,48,56,64,96,
764 * 112,128,192,224,256,384,448,512,768,896,1024
765 * @dist_mode: Distribution mode
766 * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
767 * the extractions to be used for the distribution key by calling
768 * dpkg_prepare_key_cfg() relevant only when
769 * 'dist_mode != DPNI_DIST_MODE_NONE', otherwise it can be '0'
770 * @fs_cfg: Flow Steering table configuration; only relevant if
771 * 'dist_mode = DPNI_DIST_MODE_FS'
773 struct dpni_rx_tc_dist_cfg {
775 enum dpni_dist_mode dist_mode;
776 uint64_t key_cfg_iova;
777 struct dpni_fs_tbl_cfg fs_cfg;
780 int dpni_set_rx_tc_dist(struct fsl_mc_io *mc_io,
784 const struct dpni_rx_tc_dist_cfg *cfg);
787 * enum dpni_congestion_unit - DPNI congestion units
788 * @DPNI_CONGESTION_UNIT_BYTES: bytes units
789 * @DPNI_CONGESTION_UNIT_FRAMES: frames units
791 enum dpni_congestion_unit {
792 DPNI_CONGESTION_UNIT_BYTES = 0,
793 DPNI_CONGESTION_UNIT_FRAMES
798 * enum dpni_dest - DPNI destination types
799 * @DPNI_DEST_NONE: Unassigned destination; The queue is set in parked mode and
800 * does not generate FQDAN notifications; user is expected to
801 * dequeue from the queue based on polling or other user-defined
803 * @DPNI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
804 * notifications to the specified DPIO; user is expected to dequeue
805 * from the queue only after notification is received
806 * @DPNI_DEST_DPCON: The queue is set in schedule mode and does not generate
807 * FQDAN notifications, but is connected to the specified DPCON
808 * object; user is expected to dequeue from the DPCON channel
817 * struct dpni_dest_cfg - Structure representing DPNI destination parameters
818 * @dest_type: Destination type
819 * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
820 * @priority: Priority selection within the DPIO or DPCON channel; valid values
821 * are 0-1 or 0-7, depending on the number of priorities in that
822 * channel; not relevant for 'DPNI_DEST_NONE' option
824 struct dpni_dest_cfg {
825 enum dpni_dest dest_type;
830 /* DPNI congestion options */
833 * CSCN message is written to message_iova once entering a
834 * congestion state (see 'threshold_entry')
836 #define DPNI_CONG_OPT_WRITE_MEM_ON_ENTER 0x00000001
838 * CSCN message is written to message_iova once exiting a
839 * congestion state (see 'threshold_exit')
841 #define DPNI_CONG_OPT_WRITE_MEM_ON_EXIT 0x00000002
843 * CSCN write will attempt to allocate into a cache (coherent write);
844 * valid only if 'DPNI_CONG_OPT_WRITE_MEM_<X>' is selected
846 #define DPNI_CONG_OPT_COHERENT_WRITE 0x00000004
848 * if 'dest_cfg.dest_type != DPNI_DEST_NONE' CSCN message is sent to
849 * DPIO/DPCON's WQ channel once entering a congestion state
850 * (see 'threshold_entry')
852 #define DPNI_CONG_OPT_NOTIFY_DEST_ON_ENTER 0x00000008
854 * if 'dest_cfg.dest_type != DPNI_DEST_NONE' CSCN message is sent to
855 * DPIO/DPCON's WQ channel once exiting a congestion state
856 * (see 'threshold_exit')
858 #define DPNI_CONG_OPT_NOTIFY_DEST_ON_EXIT 0x00000010
860 * if 'dest_cfg.dest_type != DPNI_DEST_NONE' when the CSCN is written to the
861 * sw-portal's DQRR, the DQRI interrupt is asserted immediately (if enabled)
863 #define DPNI_CONG_OPT_INTR_COALESCING_DISABLED 0x00000020
865 * This congestion will trigger flow control or priority flow control. This
866 * will have effect only if flow control is enabled with dpni_set_link_cfg()
868 #define DPNI_CONG_OPT_FLOW_CONTROL 0x00000040
871 * struct dpni_congestion_notification_cfg - congestion notification
874 * @threshold_entry: above this threshold we enter a congestion state.
875 * set it to '0' to disable it
876 * @threshold_exit: below this threshold we exit the congestion state.
877 * @message_ctx: The context that will be part of the CSCN message
878 * @message_iova: I/O virtual address (must be in DMA-able memory),
879 * must be 16B aligned; valid only if 'DPNI_CONG_OPT_WRITE_MEM_<X>' is
880 * contained in 'options'
881 * @dest_cfg: CSCN can be send to either DPIO or DPCON WQ channel
882 * @notification_mode: Mask of available options; use 'DPNI_CONG_OPT_<X>' values
885 struct dpni_congestion_notification_cfg {
886 enum dpni_congestion_unit units;
887 uint32_t threshold_entry;
888 uint32_t threshold_exit;
889 uint64_t message_ctx;
890 uint64_t message_iova;
891 struct dpni_dest_cfg dest_cfg;
892 uint16_t notification_mode;
895 int dpni_set_congestion_notification(struct fsl_mc_io *mc_io,
898 enum dpni_queue_type qtype,
900 const struct dpni_congestion_notification_cfg *cfg);
902 int dpni_get_congestion_notification(struct fsl_mc_io *mc_io,
905 enum dpni_queue_type qtype,
907 struct dpni_congestion_notification_cfg *cfg);
909 /* DPNI FLC stash options */
912 * stashes the whole annotation area (up to 192 bytes)
914 #define DPNI_FLC_STASH_FRAME_ANNOTATION 0x00000001
917 * struct dpni_queue - Queue structure
918 * @user_context: User data, presented to the user along with any frames
919 * from this queue. Not relevant for Tx queues.
923 * struct destination - Destination structure
924 * @id: ID of the destination, only relevant if DEST_TYPE is > 0.
925 * Identifies either a DPIO or a DPCON object.
926 * Not relevant for Tx queues.
927 * @type: May be one of the following:
928 * 0 - No destination, queue can be manually
929 * queried, but will not push traffic or
930 * notifications to a DPIO;
931 * 1 - The destination is a DPIO. When traffic
932 * becomes available in the queue a FQDAN
933 * (FQ data available notification) will be
934 * generated to selected DPIO;
935 * 2 - The destination is a DPCON. The queue is
936 * associated with a DPCON object for the
937 * purpose of scheduling between multiple
938 * queues. The DPCON may be independently
939 * configured to generate notifications.
940 * Not relevant for Tx queues.
941 * @hold_active: Hold active, maintains a queue scheduled for longer
942 * in a DPIO during dequeue to reduce spread of traffic.
943 * Only relevant if queues are
944 * not affined to a single DPIO.
952 uint64_t user_context;
954 * struct flc - FD FLow Context structure
955 * @value: Default FLC value for traffic dequeued from
956 * this queue. Please check description of FD
957 * structure for more information.
958 * Note that FLC values set using dpni_add_fs_entry,
959 * if any, take precedence over values per queue.
960 * @stash_control: Boolean, indicates whether the 6 lowest
961 * - significant bits are used for stash control.
962 * significant bits are used for stash control. If set, the 6
963 * least significant bits in value are interpreted as follows:
964 * - bits 0-1: indicates the number of 64 byte units of context
965 * that are stashed. FLC value is interpreted as a memory address
966 * in this case, excluding the 6 LS bits.
967 * - bits 2-3: indicates the number of 64 byte units of frame
968 * annotation to be stashed. Annotation is placed at FD[ADDR].
969 * - bits 4-5: indicates the number of 64 byte units of frame
970 * data to be stashed. Frame data is placed at FD[ADDR] +
972 * For more details check the Frame Descriptor section in the
973 * hardware documentation.
982 * struct dpni_queue_id - Queue identification, used for enqueue commands
984 * @fqid: FQID used for enqueueing to and/or configuration of this
986 * @qdbin: Queueing bin, used to enqueue using QDID, DQBIN, QPRI.
987 * Only relevant for Tx queues.
989 struct dpni_queue_id {
995 * enum dpni_confirmation_mode - Defines DPNI options supported for Tx
997 * @DPNI_CONF_AFFINE: For each Tx queue set associated with a sender there is
998 * an affine Tx Confirmation queue
999 * @DPNI_CONF_SINGLE: All Tx queues are associated with a single Tx
1000 * confirmation queue
1001 * @DPNI_CONF_DISABLE: Tx frames are not confirmed. This must be associated
1002 * with proper FD set-up to have buffers release to a Buffer Pool, otherwise
1003 * buffers will be leaked
1005 enum dpni_confirmation_mode {
1011 int dpni_set_tx_confirmation_mode(struct fsl_mc_io *mc_io,
1014 enum dpni_confirmation_mode mode);
1016 int dpni_get_tx_confirmation_mode(struct fsl_mc_io *mc_io,
1019 enum dpni_confirmation_mode *mode);
1021 int dpni_get_api_version(struct fsl_mc_io *mc_io,
1023 uint16_t *major_ver,
1024 uint16_t *minor_ver);
1029 #define DPNI_QUEUE_OPT_USER_CTX 0x00000001
1032 * Set queue destination configuration
1034 #define DPNI_QUEUE_OPT_DEST 0x00000002
1037 * Set FD[FLC] configuration for traffic on this queue. Note that FLC values
1038 * set with dpni_add_fs_entry, if any, take precedence over values per queue.
1040 #define DPNI_QUEUE_OPT_FLC 0x00000004
1043 * Set the queue to hold active mode. This prevents the queue from being
1044 * rescheduled between DPIOs while it carries traffic and is active on one
1045 * DPNI. Can help reduce reordering when servicing one queue on multiple
1046 * CPUs, but the queue is also less likely to push data to multiple CPUs
1047 * especially when congested.
1049 #define DPNI_QUEUE_OPT_HOLD_ACTIVE 0x00000008
1051 int dpni_set_queue(struct fsl_mc_io *mc_io,
1054 enum dpni_queue_type qtype,
1058 const struct dpni_queue *queue);
1060 int dpni_get_queue(struct fsl_mc_io *mc_io,
1063 enum dpni_queue_type qtype,
1066 struct dpni_queue *queue,
1067 struct dpni_queue_id *qid);
1069 int dpni_get_statistics(struct fsl_mc_io *mc_io,
1074 union dpni_statistics *stat);
1076 int dpni_reset_statistics(struct fsl_mc_io *mc_io,
1081 * enum dpni_congestion_point - Structure representing congestion point
1082 * @DPNI_CP_QUEUE: Set taildrop per queue, identified by QUEUE_TYPE, TC and
1084 * @DPNI_CP_GROUP: Set taildrop per queue group. Depending on options used
1085 * to define the DPNI this can be either per
1086 * TC (default) or per interface
1087 * (DPNI_OPT_SHARED_CONGESTION set at DPNI create).
1088 * QUEUE_INDEX is ignored if this type is used.
1090 enum dpni_congestion_point {
1096 * struct dpni_taildrop - Structure representing the taildrop
1097 * @enable: Indicates whether the taildrop is active or not.
1098 * @units: Indicates the unit of THRESHOLD. Queue taildrop only
1099 * supports byte units, this field is ignored and
1100 * assumed = 0 if CONGESTION_POINT is 0.
1101 * @threshold: Threshold value, in units identified by UNITS field. Value 0
1102 * cannot be used as a valid taildrop threshold,
1103 * THRESHOLD must be > 0 if the taildrop is
1105 * @oal : Overhead Accounting Length, a 12-bit, 2's complement value
1106 * with range (-2048 to +2047) representing a fixed per-frame
1107 * overhead to be added to the actual length of a frame when
1108 * performing WRED and tail drop calculations and threshold
1111 struct dpni_taildrop {
1113 enum dpni_congestion_unit units;
1118 int dpni_set_taildrop(struct fsl_mc_io *mc_io,
1121 enum dpni_congestion_point cg_point,
1122 enum dpni_queue_type q_type,
1125 struct dpni_taildrop *taildrop);
1127 int dpni_get_taildrop(struct fsl_mc_io *mc_io,
1130 enum dpni_congestion_point cg_point,
1131 enum dpni_queue_type q_type,
1134 struct dpni_taildrop *taildrop);
1135 #endif /* __FSL_DPNI_H */