1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
3 * Copyright 2013-2016 Freescale Semiconductor Inc.
4 * Copyright 2016-2017 NXP
11 #include <fsl_dpopr.h>
16 * Data Path Network Interface API
17 * Contains initialization APIs and runtime control APIs for DPNI
20 /** General DPNI macros */
23 * Maximum number of traffic classes
27 * Maximum number of buffer pools per DPNI
29 #define DPNI_MAX_DPBP 8
31 * Maximum number of storage-profiles per DPNI
36 * All traffic classes considered; see dpni_set_queue()
38 #define DPNI_ALL_TCS (uint8_t)(-1)
40 * All flows within traffic class considered; see dpni_set_queue()
42 #define DPNI_ALL_TC_FLOWS (uint16_t)(-1)
45 * Tx traffic is always released to a buffer pool on transmit, there are no
46 * resources allocated to have the frames confirmed back to the source after
49 #define DPNI_OPT_TX_FRM_RELEASE 0x000001
51 * Disables support for MAC address filtering for addresses other than primary
52 * MAC address. This affects both unicast and multicast. Promiscuous mode can
53 * still be enabled/disabled for both unicast and multicast. If promiscuous mode
54 * is disabled, only traffic matching the primary MAC address will be accepted.
56 #define DPNI_OPT_NO_MAC_FILTER 0x000002
58 * Allocate policers for this DPNI. They can be used to rate-limit traffic per
59 * traffic class (TC) basis.
61 #define DPNI_OPT_HAS_POLICING 0x000004
63 * Congestion can be managed in several ways, allowing the buffer pool to
64 * deplete on ingress, taildrop on each queue or use congestion groups for sets
65 * of queues. If set, it configures a single congestion groups across all TCs.
66 * If reset, a congestion group is allocated for each TC. Only relevant if the
67 * DPNI has multiple traffic classes.
69 #define DPNI_OPT_SHARED_CONGESTION 0x000008
71 * Enables TCAM for Flow Steering and QoS look-ups. If not specified, all
72 * look-ups are exact match. Note that TCAM is not available on LS1088 and its
73 * variants. Setting this bit on these SoCs will trigger an error.
75 #define DPNI_OPT_HAS_KEY_MASKING 0x000010
77 * Disables the flow steering table.
79 #define DPNI_OPT_NO_FS 0x000020
82 * Enable the Order Restoration support
84 #define DPNI_OPT_HAS_OPR 0x000040
87 * Order Point Records are shared for the entire TC
89 #define DPNI_OPT_OPR_PER_TC 0x000080
91 * All Tx traffic classes will use a single sender (ignore num_queueus for tx)
93 #define DPNI_OPT_SINGLE_SENDER 0x000100
95 int dpni_open(struct fsl_mc_io *mc_io,
100 int dpni_close(struct fsl_mc_io *mc_io,
105 * struct dpni_cfg - Structure representing DPNI configuration
106 * @options: Any combination of the following options:
107 * DPNI_OPT_TX_FRM_RELEASE
108 * DPNI_OPT_NO_MAC_FILTER
109 * DPNI_OPT_HAS_POLICING
110 * DPNI_OPT_SHARED_CONGESTION
111 * DPNI_OPT_HAS_KEY_MASKING
113 * DPNI_OPT_SINGLE_SENDER
114 * @fs_entries: Number of entries in the flow steering table.
115 * This table is used to select the ingress queue for
116 * ingress traffic, targeting a GPP core or another.
117 * In addition it can be used to discard traffic that
118 * matches the set rule. It is either an exact match table
119 * or a TCAM table, depending on DPNI_OPT_ HAS_KEY_MASKING
120 * bit in OPTIONS field. This field is ignored if
121 * DPNI_OPT_NO_FS bit is set in OPTIONS field. Otherwise,
122 * value 0 defaults to 64. Maximum supported value is 1024.
123 * Note that the total number of entries is limited on the
124 * SoC to as low as 512 entries if TCAM is used.
125 * @vlan_filter_entries: Number of entries in the VLAN address filtering
126 * table. This is an exact match table used to filter
127 * ingress traffic based on VLAN IDs. Value 0 disables VLAN
128 * filtering. Maximum supported value is 16.
129 * @mac_filter_entries: Number of entries in the MAC address filtering
130 * table. This is an exact match table and allows both
131 * unicast and multicast entries. The primary MAC address
132 * of the network interface is not part of this table,
133 * this contains only entries in addition to it. This
134 * field is ignored if DPNI_OPT_ NO_MAC_FILTER is set in
135 * OPTIONS field. Otherwise, value 0 defaults to 80.
136 * Maximum supported value is 80.
137 * @num_queues: Number of Tx and Rx queues used for traffic
138 * distribution. This is orthogonal to QoS and is only
139 * used to distribute traffic to multiple GPP cores.
140 * This configuration affects the number of Tx queues
141 * (logical FQs, all associated with a single CEETM queue),
142 * Rx queues and Tx confirmation queues, if applicable.
143 * Value 0 defaults to one queue. Maximum supported value
145 * @num_tcs: Number of traffic classes (TCs), reserved for the DPNI.
146 * TCs can have different priority levels for the purpose
147 * of Tx scheduling (see DPNI_SET_TX_PRIORITIES), different
148 * BPs (DPNI_ SET_POOLS), policers. There are dedicated QM
149 * queues for traffic classes (including class queues on
150 * Tx). Value 0 defaults to one TC. Maximum supported value
151 * is 16. There are maximum 16 TCs for Tx and 8 TCs for Rx.
152 * When num_tcs>8 Tx will use this value but Rx will have
153 * only 8 traffic classes.
154 * @num_rx_tcs: if set to other value than zero represents number
155 * of TCs used for Rx. Maximum value is 8. If set to zero the
156 * number of Rx TCs will be initialized with the value provided
157 * in num_tcs parameter.
158 * @qos_entries: Number of entries in the QoS classification table. This
159 * table is used to select the TC for ingress traffic. It
160 * is either an exact match or a TCAM table, depending on
161 * DPNI_OPT_ HAS_KEY_MASKING bit in OPTIONS field. This
162 * field is ignored if the DPNI has a single TC. Otherwise,
163 * a value of 0 defaults to 64. Maximum supported value
169 uint8_t vlan_filter_entries;
170 uint8_t mac_filter_entries;
177 int dpni_create(struct fsl_mc_io *mc_io,
180 const struct dpni_cfg *cfg,
183 int dpni_destroy(struct fsl_mc_io *mc_io,
189 * struct dpni_pools_cfg - Structure representing buffer pools configuration
190 * @num_dpbp: Number of DPBPs
191 * @pools: Array of buffer pools parameters; The number of valid entries
192 * must match 'num_dpbp' value
193 * @pools.dpbp_id: DPBP object ID
194 * @pools.priority: Priority mask that indicates TC's used with this buffer.
195 * I set to 0x00 MC will assume value 0xff.
196 * @pools.buffer_size: Buffer size
197 * @pools.backup_pool: Backup pool
199 struct dpni_pools_cfg {
203 uint8_t priority_mask;
204 uint16_t buffer_size;
206 } pools[DPNI_MAX_DPBP];
209 int dpni_set_pools(struct fsl_mc_io *mc_io,
212 const struct dpni_pools_cfg *cfg);
214 int dpni_enable(struct fsl_mc_io *mc_io,
218 int dpni_disable(struct fsl_mc_io *mc_io,
222 int dpni_is_enabled(struct fsl_mc_io *mc_io,
227 int dpni_reset(struct fsl_mc_io *mc_io,
232 * DPNI IRQ Index and Events
238 #define DPNI_IRQ_INDEX 0
240 * IRQ event - indicates a change in link state
242 #define DPNI_IRQ_EVENT_LINK_CHANGED 0x00000001
244 int dpni_set_irq_enable(struct fsl_mc_io *mc_io,
250 int dpni_get_irq_enable(struct fsl_mc_io *mc_io,
256 int dpni_set_irq_mask(struct fsl_mc_io *mc_io,
262 int dpni_get_irq_mask(struct fsl_mc_io *mc_io,
268 int dpni_get_irq_status(struct fsl_mc_io *mc_io,
274 int dpni_clear_irq_status(struct fsl_mc_io *mc_io,
281 * struct dpni_attr - Structure representing DPNI attributes
282 * @options: Any combination of the following options:
283 * DPNI_OPT_TX_FRM_RELEASE
284 * DPNI_OPT_NO_MAC_FILTER
285 * DPNI_OPT_HAS_POLICING
286 * DPNI_OPT_SHARED_CONGESTION
287 * DPNI_OPT_HAS_KEY_MASKING
289 * @num_queues: Number of Tx and Rx queues used for traffic distribution.
290 * @num_rx_tcs: Number of RX traffic classes (TCs), reserved for the DPNI.
291 * @num_tx_tcs: Number of TX traffic classes (TCs), reserved for the DPNI.
292 * @mac_filter_entries: Number of entries in the MAC address filtering
294 * @vlan_filter_entries: Number of entries in the VLAN address filtering
296 * @qos_entries: Number of entries in the QoS classification table.
297 * @fs_entries: Number of entries in the flow steering table.
298 * @qos_key_size: Size, in bytes, of the QoS look-up key. Defining a key larger
299 * than this when adding QoS entries will result
301 * @fs_key_size: Size, in bytes, of the flow steering look-up key. Defining a
302 * key larger than this when composing the hash + FS key
303 * will result in an error.
304 * @wriop_version: Version of WRIOP HW block.
305 * The 3 version values are stored on 6, 5, 5 bits
308 * - 0x400 - WRIOP version 1.0.0, used on LS2080 and
310 * - 0x421 - WRIOP version 1.1.1, used on LS2088 and
312 * - 0x422 - WRIOP version 1.1.2, used on LS1088 and
314 * - 0xC00 - WRIOP version 3.0.0, used on LX2160 and
322 uint8_t mac_filter_entries;
323 uint8_t vlan_filter_entries;
326 uint8_t qos_key_size;
328 uint16_t wriop_version;
331 int dpni_get_attributes(struct fsl_mc_io *mc_io,
334 struct dpni_attr *attr);
341 * Discard error. When set all discarded frames in wriop will be enqueued to
342 * error queue. To be used in dpni_set_errors_behavior() only if error_action
343 * parameter is set to DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE.
345 #define DPNI_ERROR_DISC 0x80000000
348 * Extract out of frame header error
350 #define DPNI_ERROR_EOFHE 0x00020000
354 #define DPNI_ERROR_FLE 0x00002000
356 * Frame physical error
358 #define DPNI_ERROR_FPE 0x00001000
360 * Parsing header error
362 #define DPNI_ERROR_PHE 0x00000020
364 * Parser L3 checksum error
366 #define DPNI_ERROR_L3CE 0x00000004
368 * Parser L3 checksum error
370 #define DPNI_ERROR_L4CE 0x00000001
373 * enum dpni_error_action - Defines DPNI behavior for errors
374 * @DPNI_ERROR_ACTION_DISCARD: Discard the frame
375 * @DPNI_ERROR_ACTION_CONTINUE: Continue with the normal flow
376 * @DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE: Send the frame to the error queue
378 enum dpni_error_action {
379 DPNI_ERROR_ACTION_DISCARD = 0,
380 DPNI_ERROR_ACTION_CONTINUE = 1,
381 DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE = 2
385 * struct dpni_error_cfg - Structure representing DPNI errors treatment
386 * @errors: Errors mask; use 'DPNI_ERROR__<X>
387 * @error_action: The desired action for the errors mask
388 * @set_frame_annotation: Set to '1' to mark the errors in frame
389 * annotation status (FAS); relevant only
390 * for the non-discard action
392 struct dpni_error_cfg {
394 enum dpni_error_action error_action;
395 int set_frame_annotation;
398 int dpni_set_errors_behavior(struct fsl_mc_io *mc_io,
401 struct dpni_error_cfg *cfg);
404 * DPNI buffer layout modification options
408 * Select to modify the time-stamp setting
410 #define DPNI_BUF_LAYOUT_OPT_TIMESTAMP 0x00000001
412 * Select to modify the parser-result setting; not applicable for Tx
414 #define DPNI_BUF_LAYOUT_OPT_PARSER_RESULT 0x00000002
416 * Select to modify the frame-status setting
418 #define DPNI_BUF_LAYOUT_OPT_FRAME_STATUS 0x00000004
420 * Select to modify the private-data-size setting
422 #define DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE 0x00000008
424 * Select to modify the data-alignment setting
426 #define DPNI_BUF_LAYOUT_OPT_DATA_ALIGN 0x00000010
428 * Select to modify the data-head-room setting
430 #define DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM 0x00000020
432 * Select to modify the data-tail-room setting
434 #define DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM 0x00000040
436 * Select to modify the sw-opaque value setting
438 #define DPNI_BUF_LAYOUT_OPT_SW_OPAQUE 0x00000080
441 * struct dpni_buffer_layout - Structure representing DPNI buffer layout
442 * @options: Flags representing the suggested modifications to the
444 * Use any combination of 'DPNI_BUF_LAYOUT_OPT_<X>' flags
445 * @pass_timestamp: Pass timestamp value
446 * @pass_parser_result: Pass parser results
447 * @pass_frame_status: Pass frame status
448 * @private_data_size: Size kept for private data (in bytes)
449 * @data_align: Data alignment
450 * @data_head_room: Data head room
451 * @data_tail_room: Data tail room
453 struct dpni_buffer_layout {
456 int pass_parser_result;
457 int pass_frame_status;
459 uint16_t private_data_size;
461 uint16_t data_head_room;
462 uint16_t data_tail_room;
466 * enum dpni_queue_type - Identifies a type of queue targeted by the command
467 * @DPNI_QUEUE_RX: Rx queue
468 * @DPNI_QUEUE_TX: Tx queue
469 * @DPNI_QUEUE_TX_CONFIRM: Tx confirmation queue
470 * @DPNI_QUEUE_RX_ERR: Rx error queue
472 enum dpni_queue_type {
475 DPNI_QUEUE_TX_CONFIRM,
479 int dpni_get_buffer_layout(struct fsl_mc_io *mc_io,
482 enum dpni_queue_type qtype,
483 struct dpni_buffer_layout *layout);
485 int dpni_set_buffer_layout(struct fsl_mc_io *mc_io,
488 enum dpni_queue_type qtype,
489 const struct dpni_buffer_layout *layout);
492 * enum dpni_offload - Identifies a type of offload targeted by the command
493 * @DPNI_OFF_RX_L3_CSUM: Rx L3 checksum validation
494 * @DPNI_OFF_RX_L4_CSUM: Rx L4 checksum validation
495 * @DPNI_OFF_TX_L3_CSUM: Tx L3 checksum generation
496 * @DPNI_OFF_TX_L4_CSUM: Tx L4 checksum generation
497 * @DPNI_OPT_FLCTYPE_HASH: flow context will be generated by WRIOP for AIOP or
508 int dpni_set_offload(struct fsl_mc_io *mc_io,
511 enum dpni_offload type,
514 int dpni_get_offload(struct fsl_mc_io *mc_io,
517 enum dpni_offload type,
520 int dpni_get_qdid(struct fsl_mc_io *mc_io,
523 enum dpni_queue_type qtype,
526 int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io,
529 uint16_t *data_offset);
531 #define DPNI_STATISTICS_CNT 7
534 * union dpni_statistics - Union describing the DPNI statistics
535 * @page_0: Page_0 statistics structure
536 * @page_0.ingress_all_frames: Ingress frame count
537 * @page_0.ingress_all_bytes: Ingress byte count
538 * @page_0.ingress_multicast_frames: Ingress multicast frame count
539 * @page_0.ingress_multicast_bytes: Ingress multicast byte count
540 * @page_0.ingress_broadcast_frames: Ingress broadcast frame count
541 * @page_0.ingress_broadcast_bytes: Ingress broadcast byte count
542 * @page_1: Page_1 statistics structure
543 * @page_1.egress_all_frames: Egress frame count
544 * @page_1.egress_all_bytes: Egress byte count
545 * @page_1.egress_multicast_frames: Egress multicast frame count
546 * @page_1.egress_multicast_bytes: Egress multicast byte count
547 * @page_1.egress_broadcast_frames: Egress broadcast frame count
548 * @page_1.egress_broadcast_bytes: Egress broadcast byte count
549 * @page_2: Page_2 statistics structure
550 * @page_2.ingress_filtered_frames: Ingress filtered frame count
551 * @page_2.ingress_discarded_frames: Ingress discarded frame count
552 * @page_2.ingress_nobuffer_discards: Ingress discarded frame count due to
554 * @page_2.egress_discarded_frames: Egress discarded frame count
555 * @page_2.egress_confirmed_frames: Egress confirmed frame count
556 * @page_3: Page_3 statistics structure with values for the selected TC
557 * @page_3.ceetm_dequeue_bytes: Cumulative count of the number of bytes dequeued
558 * @page_3.ceetm_dequeue_frames: Cumulative count of the number of frames
560 * @page_3.ceetm_reject_bytes: Cumulative count of the number of bytes in all
561 * frames whose enqueue was rejected
562 * @page_3.ceetm_reject_frames: Cumulative count of all frame enqueues rejected
563 * @page_4: congestion point drops for seleted TC
564 * @page_4.cgr_reject_frames: number of rejected frames due to congestion point
565 * @page_4.cgr_reject_bytes: number of rejected bytes due to congestion point
566 * @page_5: policer statistics per TC
567 * @page_5.policer_cnt_red: NUmber of red colored frames
568 * @page_5.policer_cnt_yellow: number of yellow colored frames
569 * @page_5.policer_cnt_green: number of green colored frames
570 * @page_5.policer_cnt_re_red: number of recolored red frames
571 * @page_5.policer_cnt_re_yellow: number of recolored yellow frames
572 * @raw: raw statistics structure, used to index counters
574 union dpni_statistics {
576 uint64_t ingress_all_frames;
577 uint64_t ingress_all_bytes;
578 uint64_t ingress_multicast_frames;
579 uint64_t ingress_multicast_bytes;
580 uint64_t ingress_broadcast_frames;
581 uint64_t ingress_broadcast_bytes;
584 uint64_t egress_all_frames;
585 uint64_t egress_all_bytes;
586 uint64_t egress_multicast_frames;
587 uint64_t egress_multicast_bytes;
588 uint64_t egress_broadcast_frames;
589 uint64_t egress_broadcast_bytes;
592 uint64_t ingress_filtered_frames;
593 uint64_t ingress_discarded_frames;
594 uint64_t ingress_nobuffer_discards;
595 uint64_t egress_discarded_frames;
596 uint64_t egress_confirmed_frames;
599 uint64_t ceetm_dequeue_bytes;
600 uint64_t ceetm_dequeue_frames;
601 uint64_t ceetm_reject_bytes;
602 uint64_t ceetm_reject_frames;
605 uint64_t cgr_reject_frames;
606 uint64_t cgr_reject_bytes;
609 uint64_t policer_cnt_red;
610 uint64_t policer_cnt_yellow;
611 uint64_t policer_cnt_green;
612 uint64_t policer_cnt_re_red;
613 uint64_t policer_cnt_re_yellow;
616 uint64_t counter[DPNI_STATISTICS_CNT];
621 * Enable auto-negotiation
623 #define DPNI_LINK_OPT_AUTONEG 0x0000000000000001ULL
625 * Enable half-duplex mode
627 #define DPNI_LINK_OPT_HALF_DUPLEX 0x0000000000000002ULL
629 * Enable pause frames
631 #define DPNI_LINK_OPT_PAUSE 0x0000000000000004ULL
633 * Enable a-symmetric pause frames
635 #define DPNI_LINK_OPT_ASYM_PAUSE 0x0000000000000008ULL
637 * Enable priority flow control pause frames
639 #define DPNI_LINK_OPT_PFC_PAUSE 0x0000000000000010ULL
642 * struct - Structure representing DPNI link configuration
644 * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
645 * @advertising: Speeds that are advertised for autoneg (bitmap)
647 struct dpni_link_cfg {
650 uint64_t advertising;
653 int dpni_set_link_cfg(struct fsl_mc_io *mc_io,
656 const struct dpni_link_cfg *cfg);
659 * struct dpni_link_state - Structure representing DPNI link state
661 * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
662 * @up: Link state; '0' for down, '1' for up
663 * @state_valid: Ignore/Update the state of the link
664 * @supported: Speeds capability of the phy (bitmap)
665 * @advertising: Speeds that are advertised for autoneg (bitmap)
667 struct dpni_link_state {
673 uint64_t advertising;
676 int dpni_get_link_state(struct fsl_mc_io *mc_io,
679 struct dpni_link_state *state);
681 int dpni_set_max_frame_length(struct fsl_mc_io *mc_io,
684 uint16_t max_frame_length);
686 int dpni_get_max_frame_length(struct fsl_mc_io *mc_io,
689 uint16_t *max_frame_length);
691 int dpni_set_mtu(struct fsl_mc_io *mc_io,
696 int dpni_get_mtu(struct fsl_mc_io *mc_io,
701 int dpni_set_multicast_promisc(struct fsl_mc_io *mc_io,
706 int dpni_get_multicast_promisc(struct fsl_mc_io *mc_io,
711 int dpni_set_unicast_promisc(struct fsl_mc_io *mc_io,
716 int dpni_get_unicast_promisc(struct fsl_mc_io *mc_io,
721 int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
724 const uint8_t mac_addr[6]);
726 int dpni_get_primary_mac_addr(struct fsl_mc_io *mc_io,
729 uint8_t mac_addr[6]);
731 int dpni_add_mac_addr(struct fsl_mc_io *mc_io,
734 const uint8_t mac_addr[6]);
736 int dpni_remove_mac_addr(struct fsl_mc_io *mc_io,
739 const uint8_t mac_addr[6]);
741 int dpni_clear_mac_filters(struct fsl_mc_io *mc_io,
747 int dpni_get_port_mac_addr(struct fsl_mc_io *mc_io,
750 uint8_t mac_addr[6]);
752 int dpni_enable_vlan_filter(struct fsl_mc_io *mc_io,
757 int dpni_add_vlan_id(struct fsl_mc_io *mc_io,
762 int dpni_remove_vlan_id(struct fsl_mc_io *mc_io,
767 int dpni_clear_vlan_filters(struct fsl_mc_io *mc_io,
772 * enum dpni_dist_mode - DPNI distribution mode
773 * @DPNI_DIST_MODE_NONE: No distribution
774 * @DPNI_DIST_MODE_HASH: Use hash distribution; only relevant if
775 * the 'DPNI_OPT_DIST_HASH' option was set at DPNI creation
776 * @DPNI_DIST_MODE_FS: Use explicit flow steering; only relevant if
777 * the 'DPNI_OPT_DIST_FS' option was set at DPNI creation
779 enum dpni_dist_mode {
780 DPNI_DIST_MODE_NONE = 0,
781 DPNI_DIST_MODE_HASH = 1,
782 DPNI_DIST_MODE_FS = 2
786 * enum dpni_fs_miss_action - DPNI Flow Steering miss action
787 * @DPNI_FS_MISS_DROP: In case of no-match, drop the frame
788 * @DPNI_FS_MISS_EXPLICIT_FLOWID: In case of no-match, use explicit flow-id
789 * @DPNI_FS_MISS_HASH: In case of no-match, distribute using hash
791 enum dpni_fs_miss_action {
792 DPNI_FS_MISS_DROP = 0,
793 DPNI_FS_MISS_EXPLICIT_FLOWID = 1,
794 DPNI_FS_MISS_HASH = 2
798 * struct dpni_fs_tbl_cfg - Flow Steering table configuration
799 * @miss_action: Miss action selection
800 * @default_flow_id: Used when 'miss_action = DPNI_FS_MISS_EXPLICIT_FLOWID'
801 * @keep_hash_key: used only when miss_action is set to DPNI_FS_MISS_HASH. When
802 * set to one unclassified frames will be distributed according to previous
803 * used hash key. If set to zero hash key will be replaced with the key
804 * provided for flow steering.
805 * @keep_entries: if set to one command will not delete the entries that already
806 * exist into FS table. Use this option with caution: if the table
807 * entries are not compatible with the distribution key the packets
808 * will not be classified properly.
810 struct dpni_fs_tbl_cfg {
811 enum dpni_fs_miss_action miss_action;
812 uint16_t default_flow_id;
814 uint8_t keep_entries;
818 * struct dpni_rx_tc_dist_cfg - Rx traffic class distribution configuration
819 * @dist_size: Set the distribution size;
820 * supported values: 1,2,3,4,6,7,8,12,14,16,24,28,32,48,56,64,96,
821 * 112,128,192,224,256,384,448,512,768,896,1024
822 * @dist_mode: Distribution mode
823 * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
824 * the extractions to be used for the distribution key by calling
825 * dpkg_prepare_key_cfg() relevant only when
826 * 'dist_mode != DPNI_DIST_MODE_NONE', otherwise it can be '0'
827 * @fs_cfg: Flow Steering table configuration; only relevant if
828 * 'dist_mode = DPNI_DIST_MODE_FS'
830 struct dpni_rx_tc_dist_cfg {
832 enum dpni_dist_mode dist_mode;
833 uint64_t key_cfg_iova;
834 struct dpni_fs_tbl_cfg fs_cfg;
837 int dpni_set_rx_tc_dist(struct fsl_mc_io *mc_io,
841 const struct dpni_rx_tc_dist_cfg *cfg);
844 * enum dpni_congestion_unit - DPNI congestion units
845 * @DPNI_CONGESTION_UNIT_BYTES: bytes units
846 * @DPNI_CONGESTION_UNIT_FRAMES: frames units
848 enum dpni_congestion_unit {
849 DPNI_CONGESTION_UNIT_BYTES = 0,
850 DPNI_CONGESTION_UNIT_FRAMES
855 * enum dpni_dest - DPNI destination types
856 * @DPNI_DEST_NONE: Unassigned destination; The queue is set in parked mode and
857 * does not generate FQDAN notifications; user is expected to
858 * dequeue from the queue based on polling or other user-defined
860 * @DPNI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
861 * notifications to the specified DPIO; user is expected to dequeue
862 * from the queue only after notification is received
863 * @DPNI_DEST_DPCON: The queue is set in schedule mode and does not generate
864 * FQDAN notifications, but is connected to the specified DPCON
865 * object; user is expected to dequeue from the DPCON channel
874 * struct dpni_dest_cfg - Structure representing DPNI destination parameters
875 * @dest_type: Destination type
876 * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
877 * @priority: Priority selection within the DPIO or DPCON channel; valid values
878 * are 0-1 or 0-7, depending on the number of priorities in that
879 * channel; not relevant for 'DPNI_DEST_NONE' option
881 struct dpni_dest_cfg {
882 enum dpni_dest dest_type;
887 /* DPNI congestion options */
890 * CSCN message is written to message_iova once entering a
891 * congestion state (see 'threshold_entry')
893 #define DPNI_CONG_OPT_WRITE_MEM_ON_ENTER 0x00000001
895 * CSCN message is written to message_iova once exiting a
896 * congestion state (see 'threshold_exit')
898 #define DPNI_CONG_OPT_WRITE_MEM_ON_EXIT 0x00000002
900 * CSCN write will attempt to allocate into a cache (coherent write);
901 * valid only if 'DPNI_CONG_OPT_WRITE_MEM_<X>' is selected
903 #define DPNI_CONG_OPT_COHERENT_WRITE 0x00000004
905 * if 'dest_cfg.dest_type != DPNI_DEST_NONE' CSCN message is sent to
906 * DPIO/DPCON's WQ channel once entering a congestion state
907 * (see 'threshold_entry')
909 #define DPNI_CONG_OPT_NOTIFY_DEST_ON_ENTER 0x00000008
911 * if 'dest_cfg.dest_type != DPNI_DEST_NONE' CSCN message is sent to
912 * DPIO/DPCON's WQ channel once exiting a congestion state
913 * (see 'threshold_exit')
915 #define DPNI_CONG_OPT_NOTIFY_DEST_ON_EXIT 0x00000010
917 * if 'dest_cfg.dest_type != DPNI_DEST_NONE' when the CSCN is written to the
918 * sw-portal's DQRR, the DQRI interrupt is asserted immediately (if enabled)
920 #define DPNI_CONG_OPT_INTR_COALESCING_DISABLED 0x00000020
922 * This congestion will trigger flow control or priority flow control. This
923 * will have effect only if flow control is enabled with dpni_set_link_cfg()
925 #define DPNI_CONG_OPT_FLOW_CONTROL 0x00000040
928 * struct dpni_congestion_notification_cfg - congestion notification
931 * @threshold_entry: above this threshold we enter a congestion state.
932 * set it to '0' to disable it
933 * @threshold_exit: below this threshold we exit the congestion state.
934 * @message_ctx: The context that will be part of the CSCN message
935 * @message_iova: I/O virtual address (must be in DMA-able memory),
936 * must be 16B aligned; valid only if 'DPNI_CONG_OPT_WRITE_MEM_<X>' is
937 * contained in 'options'
938 * @dest_cfg: CSCN can be send to either DPIO or DPCON WQ channel
939 * @notification_mode: Mask of available options; use 'DPNI_CONG_OPT_<X>' values
942 struct dpni_congestion_notification_cfg {
943 enum dpni_congestion_unit units;
944 uint32_t threshold_entry;
945 uint32_t threshold_exit;
946 uint64_t message_ctx;
947 uint64_t message_iova;
948 struct dpni_dest_cfg dest_cfg;
949 uint16_t notification_mode;
952 int dpni_set_congestion_notification(struct fsl_mc_io *mc_io,
955 enum dpni_queue_type qtype,
957 const struct dpni_congestion_notification_cfg *cfg);
959 int dpni_get_congestion_notification(struct fsl_mc_io *mc_io,
962 enum dpni_queue_type qtype,
964 struct dpni_congestion_notification_cfg *cfg);
966 /* DPNI FLC stash options */
969 * stashes the whole annotation area (up to 192 bytes)
971 #define DPNI_FLC_STASH_FRAME_ANNOTATION 0x00000001
974 * struct dpni_queue - Queue structure
975 * @destination - Destination structure
976 * @destination.id: ID of the destination, only relevant if DEST_TYPE is > 0.
977 * Identifies either a DPIO or a DPCON object.
978 * Not relevant for Tx queues.
979 * @destination.type: May be one of the following:
980 * 0 - No destination, queue can be manually
981 * queried, but will not push traffic or
982 * notifications to a DPIO;
983 * 1 - The destination is a DPIO. When traffic
984 * becomes available in the queue a FQDAN
985 * (FQ data available notification) will be
986 * generated to selected DPIO;
987 * 2 - The destination is a DPCON. The queue is
988 * associated with a DPCON object for the
989 * purpose of scheduling between multiple
990 * queues. The DPCON may be independently
991 * configured to generate notifications.
992 * Not relevant for Tx queues.
993 * @destination.hold_active: Hold active, maintains a queue scheduled for longer
994 * in a DPIO during dequeue to reduce spread of traffic.
995 * Only relevant if queues are
996 * not affined to a single DPIO.
997 * @user_context: User data, presented to the user along with any frames
998 * from this queue. Not relevant for Tx queues.
999 * @flc: FD FLow Context structure
1000 * @flc.value: Default FLC value for traffic dequeued from
1001 * this queue. Please check description of FD
1002 * structure for more information.
1003 * Note that FLC values set using dpni_add_fs_entry,
1004 * if any, take precedence over values per queue.
1005 * @flc.stash_control: Boolean, indicates whether the 6 lowest
1006 * - significant bits are used for stash control.
1007 * significant bits are used for stash control. If set, the 6
1008 * least significant bits in value are interpreted as follows:
1009 * - bits 0-1: indicates the number of 64 byte units of context
1010 * that are stashed. FLC value is interpreted as a memory address
1011 * in this case, excluding the 6 LS bits.
1012 * - bits 2-3: indicates the number of 64 byte units of frame
1013 * annotation to be stashed. Annotation is placed at FD[ADDR].
1014 * - bits 4-5: indicates the number of 64 byte units of frame
1015 * data to be stashed. Frame data is placed at FD[ADDR] +
1017 * For more details check the Frame Descriptor section in the
1018 * hardware documentation.
1023 enum dpni_dest type;
1027 uint64_t user_context;
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 {
1064 int dpni_set_tx_confirmation_mode(struct fsl_mc_io *mc_io,
1067 enum dpni_confirmation_mode mode);
1069 int dpni_get_tx_confirmation_mode(struct fsl_mc_io *mc_io,
1072 enum dpni_confirmation_mode *mode);
1074 int dpni_get_api_version(struct fsl_mc_io *mc_io,
1076 uint16_t *major_ver,
1077 uint16_t *minor_ver);
1082 #define DPNI_QUEUE_OPT_USER_CTX 0x00000001
1085 * Set queue destination configuration
1087 #define DPNI_QUEUE_OPT_DEST 0x00000002
1090 * Set FD[FLC] configuration for traffic on this queue. Note that FLC values
1091 * set with dpni_add_fs_entry, if any, take precedence over values per queue.
1093 #define DPNI_QUEUE_OPT_FLC 0x00000004
1096 * Set the queue to hold active mode. This prevents the queue from being
1097 * rescheduled between DPIOs while it carries traffic and is active on one
1098 * DPNI. Can help reduce reordering when servicing one queue on multiple
1099 * CPUs, but the queue is also less likely to push data to multiple CPUs
1100 * especially when congested.
1102 #define DPNI_QUEUE_OPT_HOLD_ACTIVE 0x00000008
1104 int dpni_set_queue(struct fsl_mc_io *mc_io,
1107 enum dpni_queue_type qtype,
1111 const struct dpni_queue *queue);
1113 int dpni_get_queue(struct fsl_mc_io *mc_io,
1116 enum dpni_queue_type qtype,
1119 struct dpni_queue *queue,
1120 struct dpni_queue_id *qid);
1122 int dpni_get_statistics(struct fsl_mc_io *mc_io,
1127 union dpni_statistics *stat);
1129 int dpni_reset_statistics(struct fsl_mc_io *mc_io,
1134 * enum dpni_congestion_point - Structure representing congestion point
1135 * @DPNI_CP_QUEUE: Set taildrop per queue, identified by QUEUE_TYPE, TC and
1137 * @DPNI_CP_GROUP: Set taildrop per queue group. Depending on options used
1138 * to define the DPNI this can be either per
1139 * TC (default) or per interface
1140 * (DPNI_OPT_SHARED_CONGESTION set at DPNI create).
1141 * QUEUE_INDEX is ignored if this type is used.
1143 enum dpni_congestion_point {
1149 * struct dpni_taildrop - Structure representing the taildrop
1150 * @enable: Indicates whether the taildrop is active or not.
1151 * @units: Indicates the unit of THRESHOLD. Queue taildrop only
1152 * supports byte units, this field is ignored and
1153 * assumed = 0 if CONGESTION_POINT is 0.
1154 * @threshold: Threshold value, in units identified by UNITS field. Value 0
1155 * cannot be used as a valid taildrop threshold,
1156 * THRESHOLD must be > 0 if the taildrop is
1158 * @oal : Overhead Accounting Length, a 12-bit, 2's complement value
1159 * with range (-2048 to +2047) representing a fixed per-frame
1160 * overhead to be added to the actual length of a frame when
1161 * performing WRED and tail drop calculations and threshold
1164 struct dpni_taildrop {
1166 enum dpni_congestion_unit units;
1171 int dpni_set_taildrop(struct fsl_mc_io *mc_io,
1174 enum dpni_congestion_point cg_point,
1175 enum dpni_queue_type q_type,
1178 struct dpni_taildrop *taildrop);
1180 int dpni_get_taildrop(struct fsl_mc_io *mc_io,
1183 enum dpni_congestion_point cg_point,
1184 enum dpni_queue_type q_type,
1187 struct dpni_taildrop *taildrop);
1189 int dpni_set_opr(struct fsl_mc_io *mc_io,
1195 struct opr_cfg *cfg);
1197 int dpni_get_opr(struct fsl_mc_io *mc_io,
1202 struct opr_cfg *cfg,
1203 struct opr_qry *qry);
1205 int dpni_add_custom_tpid(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
1206 uint16_t token, uint16_t tpid);
1208 int dpni_remove_custom_tpid(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
1209 uint16_t token, uint16_t tpid);
1212 * struct dpni_custom_tpid_cfg - custom TPID configuration. Contains custom TPID
1213 * values used in current dpni object to detect 802.1q frames.
1214 * @tpid1: first tag. Not used if zero.
1215 * @tpid2: second tag. Not used if zero.
1217 struct dpni_custom_tpid_cfg {
1222 int dpni_get_custom_tpid(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
1223 uint16_t token, struct dpni_custom_tpid_cfg *tpid);
1225 #endif /* __FSL_DPNI_H */