1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
3 * Copyright 2013-2016 Freescale Semiconductor Inc.
4 * Copyright 2016-2020 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 * Define a custom number of congestion groups
97 #define DPNI_OPT_CUSTOM_CG 0x000200
101 * Software sequence maximum layout size
103 #define DPNI_SW_SEQUENCE_LAYOUT_SIZE 33
105 int dpni_open(struct fsl_mc_io *mc_io,
110 int dpni_close(struct fsl_mc_io *mc_io,
115 * struct dpni_cfg - Structure representing DPNI configuration
116 * @options: Any combination of the following options:
117 * DPNI_OPT_TX_FRM_RELEASE
118 * DPNI_OPT_NO_MAC_FILTER
119 * DPNI_OPT_HAS_POLICING
120 * DPNI_OPT_SHARED_CONGESTION
121 * DPNI_OPT_HAS_KEY_MASKING
123 * DPNI_OPT_SINGLE_SENDER
124 * @fs_entries: Number of entries in the flow steering table.
125 * This table is used to select the ingress queue for
126 * ingress traffic, targeting a GPP core or another.
127 * In addition it can be used to discard traffic that
128 * matches the set rule. It is either an exact match table
129 * or a TCAM table, depending on DPNI_OPT_ HAS_KEY_MASKING
130 * bit in OPTIONS field. This field is ignored if
131 * DPNI_OPT_NO_FS bit is set in OPTIONS field. Otherwise,
132 * value 0 defaults to 64. Maximum supported value is 1024.
133 * Note that the total number of entries is limited on the
134 * SoC to as low as 512 entries if TCAM is used.
135 * @vlan_filter_entries: Number of entries in the VLAN address filtering
136 * table. This is an exact match table used to filter
137 * ingress traffic based on VLAN IDs. Value 0 disables VLAN
138 * filtering. Maximum supported value is 16.
139 * @mac_filter_entries: Number of entries in the MAC address filtering
140 * table. This is an exact match table and allows both
141 * unicast and multicast entries. The primary MAC address
142 * of the network interface is not part of this table,
143 * this contains only entries in addition to it. This
144 * field is ignored if DPNI_OPT_ NO_MAC_FILTER is set in
145 * OPTIONS field. Otherwise, value 0 defaults to 80.
146 * Maximum supported value is 80.
147 * @num_queues: Number of Tx and Rx queues used for traffic
148 * distribution. This is orthogonal to QoS and is only
149 * used to distribute traffic to multiple GPP cores.
150 * This configuration affects the number of Tx queues
151 * (logical FQs, all associated with a single CEETM queue),
152 * Rx queues and Tx confirmation queues, if applicable.
153 * Value 0 defaults to one queue. Maximum supported value
155 * @num_tcs: Number of traffic classes (TCs), reserved for the DPNI.
156 * TCs can have different priority levels for the purpose
157 * of Tx scheduling (see DPNI_SET_TX_PRIORITIES), different
158 * BPs (DPNI_ SET_POOLS), policers. There are dedicated QM
159 * queues for traffic classes (including class queues on
160 * Tx). Value 0 defaults to one TC. Maximum supported value
161 * is 16. There are maximum 16 TCs for Tx and 8 TCs for Rx.
162 * When num_tcs>8 Tx will use this value but Rx will have
163 * only 8 traffic classes.
164 * @num_rx_tcs: if set to other value than zero represents number
165 * of TCs used for Rx. Maximum value is 8. If set to zero the
166 * number of Rx TCs will be initialized with the value provided
167 * in num_tcs parameter.
168 * @qos_entries: Number of entries in the QoS classification table. This
169 * table is used to select the TC for ingress traffic. It
170 * is either an exact match or a TCAM table, depending on
171 * DPNI_OPT_ HAS_KEY_MASKING bit in OPTIONS field. This
172 * field is ignored if the DPNI has a single TC. Otherwise,
173 * a value of 0 defaults to 64. Maximum supported value
179 uint8_t vlan_filter_entries;
180 uint8_t mac_filter_entries;
188 int dpni_create(struct fsl_mc_io *mc_io,
191 const struct dpni_cfg *cfg,
194 int dpni_destroy(struct fsl_mc_io *mc_io,
200 * struct dpni_pools_cfg - Structure representing buffer pools configuration
201 * @num_dpbp: Number of DPBPs
202 * @pool_options: Buffer assignment options
203 * This field is a combination of DPNI_POOL_ASSOC_flags
204 * @pools: Array of buffer pools parameters; The number of valid entries
205 * must match 'num_dpbp' value
206 * @pools.dpbp_id: DPBP object ID
207 * @pools.priority: Priority mask that indicates TC's used with this buffer.
208 * I set to 0x00 MC will assume value 0xff.
209 * @pools.buffer_size: Buffer size
210 * @pools.backup_pool: Backup pool
213 #define DPNI_POOL_ASSOC_QPRI 0
214 #define DPNI_POOL_ASSOC_QDBIN 1
216 struct dpni_pools_cfg {
218 uint8_t pool_options;
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
332 * - 0xC00 - WRIOP version 3.0.0, used on LX2160 and
340 uint8_t mac_filter_entries;
341 uint8_t vlan_filter_entries;
344 uint8_t qos_key_size;
346 uint16_t wriop_version;
350 int dpni_get_attributes(struct fsl_mc_io *mc_io,
353 struct dpni_attr *attr);
360 * Discard error. When set all discarded frames in wriop will be enqueued to
361 * error queue. To be used in dpni_set_errors_behavior() only if error_action
362 * parameter is set to DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE.
364 #define DPNI_ERROR_DISC 0x80000000
367 * Extract out of frame header error
369 #define DPNI_ERROR_EOFHE 0x00020000
373 #define DPNI_ERROR_FLE 0x00002000
375 * Frame physical error
377 #define DPNI_ERROR_FPE 0x00001000
379 * Parsing header error
381 #define DPNI_ERROR_PHE 0x00000020
383 * Parser L3 checksum error
385 #define DPNI_ERROR_L3CE 0x00000004
387 * Parser L3 checksum error
389 #define DPNI_ERROR_L4CE 0x00000001
392 * enum dpni_error_action - Defines DPNI behavior for errors
393 * @DPNI_ERROR_ACTION_DISCARD: Discard the frame
394 * @DPNI_ERROR_ACTION_CONTINUE: Continue with the normal flow
395 * @DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE: Send the frame to the error queue
397 enum dpni_error_action {
398 DPNI_ERROR_ACTION_DISCARD = 0,
399 DPNI_ERROR_ACTION_CONTINUE = 1,
400 DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE = 2
404 * struct dpni_error_cfg - Structure representing DPNI errors treatment
405 * @errors: Errors mask; use 'DPNI_ERROR__<X>
406 * @error_action: The desired action for the errors mask
407 * @set_frame_annotation: Set to '1' to mark the errors in frame
408 * annotation status (FAS); relevant only
409 * for the non-discard action
411 struct dpni_error_cfg {
413 enum dpni_error_action error_action;
414 int set_frame_annotation;
417 int dpni_set_errors_behavior(struct fsl_mc_io *mc_io,
420 struct dpni_error_cfg *cfg);
423 * DPNI buffer layout modification options
427 * Select to modify the time-stamp setting
429 #define DPNI_BUF_LAYOUT_OPT_TIMESTAMP 0x00000001
431 * Select to modify the parser-result setting; not applicable for Tx
433 #define DPNI_BUF_LAYOUT_OPT_PARSER_RESULT 0x00000002
435 * Select to modify the frame-status setting
437 #define DPNI_BUF_LAYOUT_OPT_FRAME_STATUS 0x00000004
439 * Select to modify the private-data-size setting
441 #define DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE 0x00000008
443 * Select to modify the data-alignment setting
445 #define DPNI_BUF_LAYOUT_OPT_DATA_ALIGN 0x00000010
447 * Select to modify the data-head-room setting
449 #define DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM 0x00000020
451 * Select to modify the data-tail-room setting
453 #define DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM 0x00000040
455 * Select to modify the sw-opaque value setting
457 #define DPNI_BUF_LAYOUT_OPT_SW_OPAQUE 0x00000080
460 * struct dpni_buffer_layout - Structure representing DPNI buffer layout
461 * @options: Flags representing the suggested modifications to the
463 * Use any combination of 'DPNI_BUF_LAYOUT_OPT_<X>' flags
464 * @pass_timestamp: Pass timestamp value
465 * @pass_parser_result: Pass parser results
466 * @pass_frame_status: Pass frame status
467 * @private_data_size: Size kept for private data (in bytes)
468 * @data_align: Data alignment
469 * @data_head_room: Data head room
470 * @data_tail_room: Data tail room
472 struct dpni_buffer_layout {
475 int pass_parser_result;
476 int pass_frame_status;
478 uint16_t private_data_size;
480 uint16_t data_head_room;
481 uint16_t data_tail_room;
485 * enum dpni_queue_type - Identifies a type of queue targeted by the command
486 * @DPNI_QUEUE_RX: Rx queue
487 * @DPNI_QUEUE_TX: Tx queue
488 * @DPNI_QUEUE_TX_CONFIRM: Tx confirmation queue
489 * @DPNI_QUEUE_RX_ERR: Rx error queue
491 enum dpni_queue_type {
494 DPNI_QUEUE_TX_CONFIRM,
498 int dpni_get_buffer_layout(struct fsl_mc_io *mc_io,
501 enum dpni_queue_type qtype,
502 struct dpni_buffer_layout *layout);
504 int dpni_set_buffer_layout(struct fsl_mc_io *mc_io,
507 enum dpni_queue_type qtype,
508 const struct dpni_buffer_layout *layout);
511 * enum dpni_offload - Identifies a type of offload targeted by the command
512 * @DPNI_OFF_RX_L3_CSUM: Rx L3 checksum validation
513 * @DPNI_OFF_RX_L4_CSUM: Rx L4 checksum validation
514 * @DPNI_OFF_TX_L3_CSUM: Tx L3 checksum generation
515 * @DPNI_OFF_TX_L4_CSUM: Tx L4 checksum generation
516 * @DPNI_OPT_FLCTYPE_HASH: flow context will be generated by WRIOP for AIOP or
527 int dpni_set_offload(struct fsl_mc_io *mc_io,
530 enum dpni_offload type,
533 int dpni_get_offload(struct fsl_mc_io *mc_io,
536 enum dpni_offload type,
539 int dpni_get_qdid(struct fsl_mc_io *mc_io,
542 enum dpni_queue_type qtype,
545 int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io,
548 uint16_t *data_offset);
550 #define DPNI_STATISTICS_CNT 7
553 * union dpni_statistics - Union describing the DPNI statistics
554 * @page_0: Page_0 statistics structure
555 * @page_0.ingress_all_frames: Ingress frame count
556 * @page_0.ingress_all_bytes: Ingress byte count
557 * @page_0.ingress_multicast_frames: Ingress multicast frame count
558 * @page_0.ingress_multicast_bytes: Ingress multicast byte count
559 * @page_0.ingress_broadcast_frames: Ingress broadcast frame count
560 * @page_0.ingress_broadcast_bytes: Ingress broadcast byte count
561 * @page_1: Page_1 statistics structure
562 * @page_1.egress_all_frames: Egress frame count
563 * @page_1.egress_all_bytes: Egress byte count
564 * @page_1.egress_multicast_frames: Egress multicast frame count
565 * @page_1.egress_multicast_bytes: Egress multicast byte count
566 * @page_1.egress_broadcast_frames: Egress broadcast frame count
567 * @page_1.egress_broadcast_bytes: Egress broadcast byte count
568 * @page_2: Page_2 statistics structure
569 * @page_2.ingress_filtered_frames: Ingress filtered frame count
570 * @page_2.ingress_discarded_frames: Ingress discarded frame count
571 * @page_2.ingress_nobuffer_discards: Ingress discarded frame count due to
573 * @page_2.egress_discarded_frames: Egress discarded frame count
574 * @page_2.egress_confirmed_frames: Egress confirmed frame count
575 * @page_3: Page_3 statistics structure with values for the selected TC
576 * @page_3.ceetm_dequeue_bytes: Cumulative count of the number of bytes dequeued
577 * @page_3.ceetm_dequeue_frames: Cumulative count of the number of frames
579 * @page_3.ceetm_reject_bytes: Cumulative count of the number of bytes in all
580 * frames whose enqueue was rejected
581 * @page_3.ceetm_reject_frames: Cumulative count of all frame enqueues rejected
582 * @page_4: congestion point drops for seleted TC
583 * @page_4.cgr_reject_frames: number of rejected frames due to congestion point
584 * @page_4.cgr_reject_bytes: number of rejected bytes due to congestion point
585 * @page_5: policer statistics per TC
586 * @page_5.policer_cnt_red: NUmber of red colored frames
587 * @page_5.policer_cnt_yellow: number of yellow colored frames
588 * @page_5.policer_cnt_green: number of green colored frames
589 * @page_5.policer_cnt_re_red: number of recolored red frames
590 * @page_5.policer_cnt_re_yellow: number of recolored yellow frames
591 * @page_6.tx_pending_frames_cnt: total number of frames pending in Tx queues
592 * @raw: raw statistics structure, used to index counters
594 union dpni_statistics {
596 uint64_t ingress_all_frames;
597 uint64_t ingress_all_bytes;
598 uint64_t ingress_multicast_frames;
599 uint64_t ingress_multicast_bytes;
600 uint64_t ingress_broadcast_frames;
601 uint64_t ingress_broadcast_bytes;
604 uint64_t egress_all_frames;
605 uint64_t egress_all_bytes;
606 uint64_t egress_multicast_frames;
607 uint64_t egress_multicast_bytes;
608 uint64_t egress_broadcast_frames;
609 uint64_t egress_broadcast_bytes;
612 uint64_t ingress_filtered_frames;
613 uint64_t ingress_discarded_frames;
614 uint64_t ingress_nobuffer_discards;
615 uint64_t egress_discarded_frames;
616 uint64_t egress_confirmed_frames;
619 uint64_t ceetm_dequeue_bytes;
620 uint64_t ceetm_dequeue_frames;
621 uint64_t ceetm_reject_bytes;
622 uint64_t ceetm_reject_frames;
625 uint64_t cgr_reject_frames;
626 uint64_t cgr_reject_bytes;
629 uint64_t policer_cnt_red;
630 uint64_t policer_cnt_yellow;
631 uint64_t policer_cnt_green;
632 uint64_t policer_cnt_re_red;
633 uint64_t policer_cnt_re_yellow;
636 uint64_t tx_pending_frames_cnt;
639 uint64_t counter[DPNI_STATISTICS_CNT];
644 * Enable auto-negotiation
646 #define DPNI_LINK_OPT_AUTONEG 0x0000000000000001ULL
648 * Enable half-duplex mode
650 #define DPNI_LINK_OPT_HALF_DUPLEX 0x0000000000000002ULL
652 * Enable pause frames
654 #define DPNI_LINK_OPT_PAUSE 0x0000000000000004ULL
656 * Enable a-symmetric pause frames
658 #define DPNI_LINK_OPT_ASYM_PAUSE 0x0000000000000008ULL
660 * Enable priority flow control pause frames
662 #define DPNI_LINK_OPT_PFC_PAUSE 0x0000000000000010ULL
665 * Advertise 10MB full duplex
667 #define DPNI_ADVERTISED_10BASET_FULL 0x0000000000000001ULL
669 * Advertise 100MB full duplex
671 #define DPNI_ADVERTISED_100BASET_FULL 0x0000000000000002ULL
673 * Advertise 1GB full duplex
675 #define DPNI_ADVERTISED_1000BASET_FULL 0x0000000000000004ULL
677 * Advertise auto-negotiation enable
679 #define DPNI_ADVERTISED_AUTONEG 0x0000000000000008ULL
681 * Advertise 10GB full duplex
683 #define DPNI_ADVERTISED_10000BASET_FULL 0x0000000000000010ULL
685 * Advertise 2.5GB full duplex
687 #define DPNI_ADVERTISED_2500BASEX_FULL 0x0000000000000020ULL
689 * Advertise 5GB full duplex
691 #define DPNI_ADVERTISED_5000BASET_FULL 0x0000000000000040ULL
695 * struct - Structure representing DPNI link configuration
697 * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
698 * @advertising: Speeds that are advertised for autoneg (bitmap)
700 struct dpni_link_cfg {
703 uint64_t advertising;
706 int dpni_set_link_cfg(struct fsl_mc_io *mc_io,
709 const struct dpni_link_cfg *cfg);
712 * struct dpni_link_state - Structure representing DPNI link state
714 * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
715 * @up: Link state; '0' for down, '1' for up
716 * @state_valid: Ignore/Update the state of the link
717 * @supported: Speeds capability of the phy (bitmap)
718 * @advertising: Speeds that are advertised for autoneg (bitmap)
720 struct dpni_link_state {
726 uint64_t advertising;
729 int dpni_get_link_state(struct fsl_mc_io *mc_io,
732 struct dpni_link_state *state);
735 * struct dpni_tx_shaping - Structure representing DPNI tx shaping configuration
736 * @rate_limit: Rate in Mbps
737 * @max_burst_size: Burst size in bytes (up to 64KB)
739 struct dpni_tx_shaping_cfg {
741 uint16_t max_burst_size;
744 int dpni_set_tx_shaping(struct fsl_mc_io *mc_io,
747 const struct dpni_tx_shaping_cfg *tx_cr_shaper,
748 const struct dpni_tx_shaping_cfg *tx_er_shaper,
751 int dpni_set_max_frame_length(struct fsl_mc_io *mc_io,
754 uint16_t max_frame_length);
756 int dpni_get_max_frame_length(struct fsl_mc_io *mc_io,
759 uint16_t *max_frame_length);
761 int dpni_set_mtu(struct fsl_mc_io *mc_io,
766 int dpni_get_mtu(struct fsl_mc_io *mc_io,
771 int dpni_set_multicast_promisc(struct fsl_mc_io *mc_io,
776 int dpni_get_multicast_promisc(struct fsl_mc_io *mc_io,
781 int dpni_set_unicast_promisc(struct fsl_mc_io *mc_io,
786 int dpni_get_unicast_promisc(struct fsl_mc_io *mc_io,
791 int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
794 const uint8_t mac_addr[6]);
796 int dpni_get_primary_mac_addr(struct fsl_mc_io *mc_io,
799 uint8_t mac_addr[6]);
801 int dpni_add_mac_addr(struct fsl_mc_io *mc_io,
804 const uint8_t mac_addr[6],
809 int dpni_remove_mac_addr(struct fsl_mc_io *mc_io,
812 const uint8_t mac_addr[6]);
814 int dpni_clear_mac_filters(struct fsl_mc_io *mc_io,
820 int dpni_get_port_mac_addr(struct fsl_mc_io *mc_io,
823 uint8_t mac_addr[6]);
825 int dpni_enable_vlan_filter(struct fsl_mc_io *mc_io,
831 * Set vlan filter queue action
833 #define DPNI_VLAN_SET_QUEUE_ACTION 1
835 int dpni_add_vlan_id(struct fsl_mc_io *mc_io,
843 int dpni_remove_vlan_id(struct fsl_mc_io *mc_io,
848 int dpni_clear_vlan_filters(struct fsl_mc_io *mc_io,
853 * enum dpni_tx_schedule_mode - DPNI Tx scheduling mode
854 * @DPNI_TX_SCHED_STRICT_PRIORITY: strict priority
855 * @DPNI_TX_SCHED_WEIGHTED_A: weighted based scheduling in group A
856 * @DPNI_TX_SCHED_WEIGHTED_B: weighted based scheduling in group B
858 enum dpni_tx_schedule_mode {
859 DPNI_TX_SCHED_STRICT_PRIORITY = 0,
860 DPNI_TX_SCHED_WEIGHTED_A,
861 DPNI_TX_SCHED_WEIGHTED_B,
865 * struct dpni_tx_schedule_cfg - Structure representing Tx scheduling conf
866 * @mode: Scheduling mode
867 * @delta_bandwidth: Bandwidth represented in weights from 100 to 10000;
868 * not applicable for 'strict-priority' mode;
870 struct dpni_tx_schedule_cfg {
871 enum dpni_tx_schedule_mode mode;
872 uint16_t delta_bandwidth;
876 * struct dpni_tx_priorities_cfg - Structure representing transmission
877 * priorities for DPNI TCs
878 * @tc_sched: An array of traffic-classes
879 * @prio_group_A: Priority of group A
880 * @prio_group_B: Priority of group B
881 * @separate_groups: Treat A and B groups as separate
883 struct dpni_tx_priorities_cfg {
884 struct dpni_tx_schedule_cfg tc_sched[DPNI_MAX_TC];
885 uint32_t prio_group_A;
886 uint32_t prio_group_B;
887 uint8_t separate_groups;
890 int dpni_set_tx_priorities(struct fsl_mc_io *mc_io,
893 const struct dpni_tx_priorities_cfg *cfg);
896 * enum dpni_dist_mode - DPNI distribution mode
897 * @DPNI_DIST_MODE_NONE: No distribution
898 * @DPNI_DIST_MODE_HASH: Use hash distribution; only relevant if
899 * the 'DPNI_OPT_DIST_HASH' option was set at DPNI creation
900 * @DPNI_DIST_MODE_FS: Use explicit flow steering; only relevant if
901 * the 'DPNI_OPT_DIST_FS' option was set at DPNI creation
903 enum dpni_dist_mode {
904 DPNI_DIST_MODE_NONE = 0,
905 DPNI_DIST_MODE_HASH = 1,
906 DPNI_DIST_MODE_FS = 2
910 * enum dpni_fs_miss_action - DPNI Flow Steering miss action
911 * @DPNI_FS_MISS_DROP: In case of no-match, drop the frame
912 * @DPNI_FS_MISS_EXPLICIT_FLOWID: In case of no-match, use explicit flow-id
913 * @DPNI_FS_MISS_HASH: In case of no-match, distribute using hash
915 enum dpni_fs_miss_action {
916 DPNI_FS_MISS_DROP = 0,
917 DPNI_FS_MISS_EXPLICIT_FLOWID = 1,
918 DPNI_FS_MISS_HASH = 2
922 * struct dpni_fs_tbl_cfg - Flow Steering table configuration
923 * @miss_action: Miss action selection
924 * @default_flow_id: Used when 'miss_action = DPNI_FS_MISS_EXPLICIT_FLOWID'
925 * @keep_hash_key: used only when miss_action is set to DPNI_FS_MISS_HASH. When
926 * set to one unclassified frames will be distributed according to previous
927 * used hash key. If set to zero hash key will be replaced with the key
928 * provided for flow steering.
929 * @keep_entries: if set to one command will not delete the entries that already
930 * exist into FS table. Use this option with caution: if the table
931 * entries are not compatible with the distribution key the packets
932 * will not be classified properly.
934 struct dpni_fs_tbl_cfg {
935 enum dpni_fs_miss_action miss_action;
936 uint16_t default_flow_id;
938 uint8_t keep_entries;
942 * struct dpni_rx_tc_dist_cfg - Rx traffic class distribution configuration
943 * @dist_size: Set the distribution size;
944 * supported values: 1,2,3,4,6,7,8,12,14,16,24,28,32,48,56,64,96,
945 * 112,128,192,224,256,384,448,512,768,896,1024
946 * @dist_mode: Distribution mode
947 * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
948 * the extractions to be used for the distribution key by calling
949 * dpkg_prepare_key_cfg() relevant only when
950 * 'dist_mode != DPNI_DIST_MODE_NONE', otherwise it can be '0'
951 * @fs_cfg: Flow Steering table configuration; only relevant if
952 * 'dist_mode = DPNI_DIST_MODE_FS'
954 struct dpni_rx_tc_dist_cfg {
956 enum dpni_dist_mode dist_mode;
957 uint64_t key_cfg_iova;
958 struct dpni_fs_tbl_cfg fs_cfg;
961 int dpni_set_rx_tc_dist(struct fsl_mc_io *mc_io,
965 const struct dpni_rx_tc_dist_cfg *cfg);
968 * Set to select color aware mode (otherwise - color blind)
970 #define DPNI_POLICER_OPT_COLOR_AWARE 0x00000001
972 * Set to discard frame with RED color
974 #define DPNI_POLICER_OPT_DISCARD_RED 0x00000002
977 * enum dpni_policer_mode - selecting the policer mode
978 * @DPNI_POLICER_MODE_NONE: Policer is disabled
979 * @DPNI_POLICER_MODE_PASS_THROUGH: Policer pass through
980 * @DPNI_POLICER_MODE_RFC_2698: Policer algorithm RFC 2698
981 * @DPNI_POLICER_MODE_RFC_4115: Policer algorithm RFC 4115
983 enum dpni_policer_mode {
984 DPNI_POLICER_MODE_NONE = 0,
985 DPNI_POLICER_MODE_PASS_THROUGH,
986 DPNI_POLICER_MODE_RFC_2698,
987 DPNI_POLICER_MODE_RFC_4115
991 * enum dpni_policer_unit - DPNI policer units
992 * @DPNI_POLICER_UNIT_BYTES: bytes units
993 * @DPNI_POLICER_UNIT_FRAMES: frames units
995 enum dpni_policer_unit {
996 DPNI_POLICER_UNIT_BYTES = 0,
997 DPNI_POLICER_UNIT_FRAMES
1001 * enum dpni_policer_color - selecting the policer color
1002 * @DPNI_POLICER_COLOR_GREEN: Green color
1003 * @DPNI_POLICER_COLOR_YELLOW: Yellow color
1004 * @DPNI_POLICER_COLOR_RED: Red color
1006 enum dpni_policer_color {
1007 DPNI_POLICER_COLOR_GREEN = 0,
1008 DPNI_POLICER_COLOR_YELLOW,
1009 DPNI_POLICER_COLOR_RED
1013 * struct dpni_rx_tc_policing_cfg - Policer configuration
1014 * @options: Mask of available options; use 'DPNI_POLICER_OPT_<X>' values
1015 * @mode: policer mode
1016 * @default_color: For pass-through mode the policer re-colors with this
1017 * color any incoming packets. For Color aware non-pass-through mode:
1018 * policer re-colors with this color all packets with FD[DROPP]>2.
1019 * @units: Bytes or Packets
1020 * @cir: Committed information rate (CIR) in Kbps or packets/second
1021 * @cbs: Committed burst size (CBS) in bytes or packets
1022 * @eir: Peak information rate (PIR, rfc2698) in Kbps or packets/second
1023 * Excess information rate (EIR, rfc4115) in Kbps or packets/second
1024 * @ebs: Peak burst size (PBS, rfc2698) in bytes or packets
1025 * Excess burst size (EBS, rfc4115) in bytes or packets
1027 struct dpni_rx_tc_policing_cfg {
1029 enum dpni_policer_mode mode;
1030 enum dpni_policer_unit units;
1031 enum dpni_policer_color default_color;
1039 int dpni_set_rx_tc_policing(struct fsl_mc_io *mc_io,
1043 const struct dpni_rx_tc_policing_cfg *cfg);
1045 int dpni_get_rx_tc_policing(struct fsl_mc_io *mc_io,
1049 struct dpni_rx_tc_policing_cfg *cfg);
1052 * enum dpni_congestion_unit - DPNI congestion units
1053 * @DPNI_CONGESTION_UNIT_BYTES: bytes units
1054 * @DPNI_CONGESTION_UNIT_FRAMES: frames units
1056 enum dpni_congestion_unit {
1057 DPNI_CONGESTION_UNIT_BYTES = 0,
1058 DPNI_CONGESTION_UNIT_FRAMES
1062 * enum dpni_early_drop_mode - DPNI early drop mode
1063 * @DPNI_EARLY_DROP_MODE_NONE: early drop is disabled
1064 * @DPNI_EARLY_DROP_MODE_TAIL: early drop in taildrop mode
1065 * @DPNI_EARLY_DROP_MODE_WRED: early drop in WRED mode
1067 enum dpni_early_drop_mode {
1068 DPNI_EARLY_DROP_MODE_NONE = 0,
1069 DPNI_EARLY_DROP_MODE_TAIL,
1070 DPNI_EARLY_DROP_MODE_WRED
1074 * struct dpni_wred_cfg - WRED configuration
1075 * @max_threshold: maximum threshold that packets may be discarded. Above this
1076 * threshold all packets are discarded; must be less than 2^39;
1077 * approximated to be expressed as (x+256)*2^(y-1) due to HW
1079 * @min_threshold: minimum threshold that packets may be discarded at
1080 * @drop_probability: probability that a packet will be discarded (1-100,
1081 * associated with the max_threshold).
1083 struct dpni_wred_cfg {
1084 uint64_t max_threshold;
1085 uint64_t min_threshold;
1086 uint8_t drop_probability;
1090 * struct dpni_early_drop_cfg - early-drop configuration
1091 * @enable: drop enable
1092 * @units: units type
1093 * @green: WRED - 'green' configuration
1094 * @yellow: WRED - 'yellow' configuration
1095 * @red: WRED - 'red' configuration
1097 struct dpni_early_drop_cfg {
1099 enum dpni_congestion_unit units;
1100 struct dpni_wred_cfg green;
1101 struct dpni_wred_cfg yellow;
1102 struct dpni_wred_cfg red;
1105 void dpni_prepare_early_drop(const struct dpni_early_drop_cfg *cfg,
1106 uint8_t *early_drop_buf);
1108 void dpni_extract_early_drop(struct dpni_early_drop_cfg *cfg,
1109 const uint8_t *early_drop_buf);
1111 int dpni_set_early_drop(struct fsl_mc_io *mc_io,
1114 enum dpni_queue_type qtype,
1116 uint64_t early_drop_iova);
1118 int dpni_get_early_drop(struct fsl_mc_io *mc_io,
1121 enum dpni_queue_type qtype,
1123 uint64_t early_drop_iova);
1126 * enum dpni_dest - DPNI destination types
1127 * @DPNI_DEST_NONE: Unassigned destination; The queue is set in parked mode and
1128 * does not generate FQDAN notifications; user is expected to
1129 * dequeue from the queue based on polling or other user-defined
1131 * @DPNI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
1132 * notifications to the specified DPIO; user is expected to dequeue
1133 * from the queue only after notification is received
1134 * @DPNI_DEST_DPCON: The queue is set in schedule mode and does not generate
1135 * FQDAN notifications, but is connected to the specified DPCON
1136 * object; user is expected to dequeue from the DPCON channel
1145 * struct dpni_dest_cfg - Structure representing DPNI destination parameters
1146 * @dest_type: Destination type
1147 * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
1148 * @priority: Priority selection within the DPIO or DPCON channel; valid values
1149 * are 0-1 or 0-7, depending on the number of priorities in that
1150 * channel; not relevant for 'DPNI_DEST_NONE' option
1152 struct dpni_dest_cfg {
1153 enum dpni_dest dest_type;
1158 /* DPNI congestion options */
1161 * CSCN message is written to message_iova once entering a
1162 * congestion state (see 'threshold_entry')
1164 #define DPNI_CONG_OPT_WRITE_MEM_ON_ENTER 0x00000001
1166 * CSCN message is written to message_iova once exiting a
1167 * congestion state (see 'threshold_exit')
1169 #define DPNI_CONG_OPT_WRITE_MEM_ON_EXIT 0x00000002
1171 * CSCN write will attempt to allocate into a cache (coherent write);
1172 * valid only if 'DPNI_CONG_OPT_WRITE_MEM_<X>' is selected
1174 #define DPNI_CONG_OPT_COHERENT_WRITE 0x00000004
1176 * if 'dest_cfg.dest_type != DPNI_DEST_NONE' CSCN message is sent to
1177 * DPIO/DPCON's WQ channel once entering a congestion state
1178 * (see 'threshold_entry')
1180 #define DPNI_CONG_OPT_NOTIFY_DEST_ON_ENTER 0x00000008
1182 * if 'dest_cfg.dest_type != DPNI_DEST_NONE' CSCN message is sent to
1183 * DPIO/DPCON's WQ channel once exiting a congestion state
1184 * (see 'threshold_exit')
1186 #define DPNI_CONG_OPT_NOTIFY_DEST_ON_EXIT 0x00000010
1188 * if 'dest_cfg.dest_type != DPNI_DEST_NONE' when the CSCN is written to the
1189 * sw-portal's DQRR, the DQRI interrupt is asserted immediately (if enabled)
1191 #define DPNI_CONG_OPT_INTR_COALESCING_DISABLED 0x00000020
1193 * This congestion will trigger flow control or priority flow control. This
1194 * will have effect only if flow control is enabled with dpni_set_link_cfg()
1196 #define DPNI_CONG_OPT_FLOW_CONTROL 0x00000040
1199 * enum dpni_congestion_point - Structure representing congestion point
1200 * @DPNI_CP_QUEUE: Set congestion per queue, identified by QUEUE_TYPE, TC
1202 * @DPNI_CP_GROUP: Set congestion per queue group. Depending on options
1203 * used to define the DPNI this can be either per
1204 * TC (default) or per interface
1205 * (DPNI_OPT_SHARED_CONGESTION set at DPNI create).
1206 * QUEUE_INDEX is ignored if this type is used.
1207 * @DPNI_CP_CONGESTION_GROUP: Set per congestion group id. This will work
1208 * only if the DPNI is created with DPNI_OPT_CUSTOM_CG option
1211 enum dpni_congestion_point {
1214 DPNI_CP_CONGESTION_GROUP,
1218 * struct dpni_congestion_notification_cfg - congestion notification
1220 * @units: units type
1221 * @threshold_entry: above this threshold we enter a congestion state.
1222 * set it to '0' to disable it
1223 * @threshold_exit: below this threshold we exit the congestion state.
1224 * @message_ctx: The context that will be part of the CSCN message
1225 * @message_iova: I/O virtual address (must be in DMA-able memory),
1226 * must be 16B aligned; valid only if 'DPNI_CONG_OPT_WRITE_MEM_<X>' is
1227 * contained in 'options'
1228 * @dest_cfg: CSCN can be send to either DPIO or DPCON WQ channel
1229 * @notification_mode: Mask of available options; use 'DPNI_CONG_OPT_<X>' values
1230 * @cg_point: Congestion point settings
1231 * @cgid: id of the congestion group. The index is relative to dpni.
1234 struct dpni_congestion_notification_cfg {
1235 enum dpni_congestion_unit units;
1236 uint32_t threshold_entry;
1237 uint32_t threshold_exit;
1238 uint64_t message_ctx;
1239 uint64_t message_iova;
1240 struct dpni_dest_cfg dest_cfg;
1241 uint16_t notification_mode;
1242 enum dpni_congestion_point cg_point;
1246 int dpni_set_congestion_notification(struct fsl_mc_io *mc_io,
1249 enum dpni_queue_type qtype,
1251 const struct dpni_congestion_notification_cfg *cfg);
1253 int dpni_get_congestion_notification(struct fsl_mc_io *mc_io,
1256 enum dpni_queue_type qtype,
1258 struct dpni_congestion_notification_cfg *cfg);
1260 /* DPNI FLC stash options */
1263 * stashes the whole annotation area (up to 192 bytes)
1265 #define DPNI_FLC_STASH_FRAME_ANNOTATION 0x00000001
1268 * struct dpni_queue - Queue structure
1269 * @destination - Destination structure
1270 * @destination.id: ID of the destination, only relevant if DEST_TYPE is > 0.
1271 * Identifies either a DPIO or a DPCON object.
1272 * Not relevant for Tx queues.
1273 * @destination.type: May be one of the following:
1274 * 0 - No destination, queue can be manually
1275 * queried, but will not push traffic or
1276 * notifications to a DPIO;
1277 * 1 - The destination is a DPIO. When traffic
1278 * becomes available in the queue a FQDAN
1279 * (FQ data available notification) will be
1280 * generated to selected DPIO;
1281 * 2 - The destination is a DPCON. The queue is
1282 * associated with a DPCON object for the
1283 * purpose of scheduling between multiple
1284 * queues. The DPCON may be independently
1285 * configured to generate notifications.
1286 * Not relevant for Tx queues.
1287 * @destination.hold_active: Hold active, maintains a queue scheduled for longer
1288 * in a DPIO during dequeue to reduce spread of traffic.
1289 * Only relevant if queues are
1290 * not affined to a single DPIO.
1291 * @user_context: User data, presented to the user along with any frames
1292 * from this queue. Not relevant for Tx queues.
1293 * @flc: FD FLow Context structure
1294 * @flc.value: Default FLC value for traffic dequeued from
1295 * this queue. Please check description of FD
1296 * structure for more information.
1297 * Note that FLC values set using dpni_add_fs_entry,
1298 * if any, take precedence over values per queue.
1299 * @flc.stash_control: Boolean, indicates whether the 6 lowest
1300 * - significant bits are used for stash control.
1301 * significant bits are used for stash control. If set, the 6
1302 * least significant bits in value are interpreted as follows:
1303 * - bits 0-1: indicates the number of 64 byte units of context
1304 * that are stashed. FLC value is interpreted as a memory address
1305 * in this case, excluding the 6 LS bits.
1306 * - bits 2-3: indicates the number of 64 byte units of frame
1307 * annotation to be stashed. Annotation is placed at FD[ADDR].
1308 * - bits 4-5: indicates the number of 64 byte units of frame
1309 * data to be stashed. Frame data is placed at FD[ADDR] +
1311 * For more details check the Frame Descriptor section in the
1312 * hardware documentation.
1313 *@cgid :indicate the cgid to set relative to dpni
1318 enum dpni_dest type;
1322 uint64_t user_context;
1331 * struct dpni_queue_id - Queue identification, used for enqueue commands
1333 * @fqid: FQID used for enqueueing to and/or configuration of this
1335 * @qdbin: Queueing bin, used to enqueue using QDID, DQBIN, QPRI.
1336 * Only relevant for Tx queues.
1338 struct dpni_queue_id {
1344 * enum dpni_confirmation_mode - Defines DPNI options supported for Tx
1346 * @DPNI_CONF_AFFINE: For each Tx queue set associated with a sender there is
1347 * an affine Tx Confirmation queue
1348 * @DPNI_CONF_SINGLE: All Tx queues are associated with a single Tx
1349 * confirmation queue
1350 * @DPNI_CONF_DISABLE: Tx frames are not confirmed. This must be associated
1351 * with proper FD set-up to have buffers release to a Buffer Pool, otherwise
1352 * buffers will be leaked
1354 enum dpni_confirmation_mode {
1360 int dpni_set_tx_confirmation_mode(struct fsl_mc_io *mc_io,
1363 enum dpni_confirmation_mode mode);
1365 int dpni_get_tx_confirmation_mode(struct fsl_mc_io *mc_io,
1368 enum dpni_confirmation_mode *mode);
1371 * struct dpni_qos_tbl_cfg - Structure representing QOS table configuration
1372 * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
1373 * key extractions to be used as the QoS criteria by calling
1374 * dpkg_prepare_key_cfg()
1375 * @discard_on_miss: Set to '1' to discard frames in case of no match (miss);
1376 * '0' to use the 'default_tc' in such cases
1377 * @keep_entries: if set to one will not delele existing table entries. This
1378 * option will work properly only for dpni objects created with
1379 * DPNI_OPT_HAS_KEY_MASKING option. All previous QoS entries must
1380 * be compatible with new key composition rule.
1381 * It is the caller's job to delete incompatible entries before
1382 * executing this function.
1383 * @default_tc: Used in case of no-match and 'discard_on_miss'= 0
1385 struct dpni_qos_tbl_cfg {
1386 uint64_t key_cfg_iova;
1387 int discard_on_miss;
1392 int dpni_set_qos_table(struct fsl_mc_io *mc_io,
1395 const struct dpni_qos_tbl_cfg *cfg);
1398 * struct dpni_rule_cfg - Rule configuration for table lookup
1399 * @key_iova: I/O virtual address of the key (must be in DMA-able memory)
1400 * @mask_iova: I/O virtual address of the mask (must be in DMA-able memory)
1401 * @key_size: key and mask size (in bytes)
1403 struct dpni_rule_cfg {
1409 int dpni_add_qos_entry(struct fsl_mc_io *mc_io,
1412 const struct dpni_rule_cfg *cfg,
1418 int dpni_remove_qos_entry(struct fsl_mc_io *mc_io,
1421 const struct dpni_rule_cfg *cfg);
1423 int dpni_clear_qos_table(struct fsl_mc_io *mc_io,
1428 * Discard matching traffic. If set, this takes precedence over any other
1429 * configuration and matching traffic is always discarded.
1431 #define DPNI_FS_OPT_DISCARD 0x1
1434 * Set FLC value. If set, flc member of truct dpni_fs_action_cfg is used to
1435 * override the FLC value set per queue.
1436 * For more details check the Frame Descriptor section in the hardware
1439 #define DPNI_FS_OPT_SET_FLC 0x2
1442 * Indicates whether the 6 lowest significant bits of FLC are used for stash
1443 * control. If set, the 6 least significant bits in value are interpreted as
1445 * - bits 0-1: indicates the number of 64 byte units of context that are
1446 * stashed. FLC value is interpreted as a memory address in this case,
1447 * excluding the 6 LS bits.
1448 * - bits 2-3: indicates the number of 64 byte units of frame annotation
1449 * to be stashed. Annotation is placed at FD[ADDR].
1450 * - bits 4-5: indicates the number of 64 byte units of frame data to be
1451 * stashed. Frame data is placed at FD[ADDR] + FD[OFFSET].
1452 * This flag is ignored if DPNI_FS_OPT_SET_FLC is not specified.
1454 #define DPNI_FS_OPT_SET_STASH_CONTROL 0x4
1457 * struct dpni_fs_action_cfg - Action configuration for table look-up
1458 * @flc: FLC value for traffic matching this rule. Please check the Frame
1459 * Descriptor section in the hardware documentation for more information.
1460 * @flow_id: Identifies the Rx queue used for matching traffic. Supported
1461 * values are in range 0 to num_queue-1.
1462 * @options: Any combination of DPNI_FS_OPT_ values.
1464 struct dpni_fs_action_cfg {
1470 int dpni_add_fs_entry(struct fsl_mc_io *mc_io,
1475 const struct dpni_rule_cfg *cfg,
1476 const struct dpni_fs_action_cfg *action);
1478 int dpni_remove_fs_entry(struct fsl_mc_io *mc_io,
1482 const struct dpni_rule_cfg *cfg);
1484 int dpni_clear_fs_entries(struct fsl_mc_io *mc_io,
1489 int dpni_get_api_version(struct fsl_mc_io *mc_io,
1491 uint16_t *major_ver,
1492 uint16_t *minor_ver);
1497 #define DPNI_QUEUE_OPT_USER_CTX 0x00000001
1500 * Set queue destination configuration
1502 #define DPNI_QUEUE_OPT_DEST 0x00000002
1505 * Set FD[FLC] configuration for traffic on this queue. Note that FLC values
1506 * set with dpni_add_fs_entry, if any, take precedence over values per queue.
1508 #define DPNI_QUEUE_OPT_FLC 0x00000004
1511 * Set the queue to hold active mode. This prevents the queue from being
1512 * rescheduled between DPIOs while it carries traffic and is active on one
1513 * DPNI. Can help reduce reordering when servicing one queue on multiple
1514 * CPUs, but the queue is also less likely to push data to multiple CPUs
1515 * especially when congested.
1517 #define DPNI_QUEUE_OPT_HOLD_ACTIVE 0x00000008
1519 #define DPNI_QUEUE_OPT_SET_CGID 0x00000040
1520 #define DPNI_QUEUE_OPT_CLEAR_CGID 0x00000080
1522 int dpni_set_queue(struct fsl_mc_io *mc_io,
1525 enum dpni_queue_type qtype,
1529 const struct dpni_queue *queue);
1531 int dpni_get_queue(struct fsl_mc_io *mc_io,
1534 enum dpni_queue_type qtype,
1537 struct dpni_queue *queue,
1538 struct dpni_queue_id *qid);
1540 int dpni_get_statistics(struct fsl_mc_io *mc_io,
1545 union dpni_statistics *stat);
1547 int dpni_reset_statistics(struct fsl_mc_io *mc_io,
1552 * struct dpni_taildrop - Structure representing the taildrop
1553 * @enable: Indicates whether the taildrop is active or not.
1554 * @units: Indicates the unit of THRESHOLD. Queue taildrop only
1555 * supports byte units, this field is ignored and
1556 * assumed = 0 if CONGESTION_POINT is 0.
1557 * @threshold: Threshold value, in units identified by UNITS field. Value 0
1558 * cannot be used as a valid taildrop threshold,
1559 * THRESHOLD must be > 0 if the taildrop is
1561 * @oal : Overhead Accounting Length, a 12-bit, 2's complement value
1562 * with range (-2048 to +2047) representing a fixed per-frame
1563 * overhead to be added to the actual length of a frame when
1564 * performing WRED and tail drop calculations and threshold
1567 struct dpni_taildrop {
1569 enum dpni_congestion_unit units;
1574 int dpni_set_taildrop(struct fsl_mc_io *mc_io,
1577 enum dpni_congestion_point cg_point,
1578 enum dpni_queue_type q_type,
1581 struct dpni_taildrop *taildrop);
1583 int dpni_get_taildrop(struct fsl_mc_io *mc_io,
1586 enum dpni_congestion_point cg_point,
1587 enum dpni_queue_type q_type,
1590 struct dpni_taildrop *taildrop);
1592 int dpni_set_opr(struct fsl_mc_io *mc_io,
1598 struct opr_cfg *cfg);
1600 int dpni_get_opr(struct fsl_mc_io *mc_io,
1605 struct opr_cfg *cfg,
1606 struct opr_qry *qry);
1609 * When used for queue_idx in function dpni_set_rx_dist_default_queue will
1610 * signal to dpni to drop all unclassified frames
1612 #define DPNI_FS_MISS_DROP ((uint16_t)-1)
1615 * struct dpni_rx_dist_cfg - distribution configuration
1616 * @dist_size: distribution size; supported values: 1,2,3,4,6,7,8,
1617 * 12,14,16,24,28,32,48,56,64,96,112,128,192,224,256,384,448,
1619 * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
1620 * the extractions to be used for the distribution key by calling
1621 * dpkg_prepare_key_cfg() relevant only when enable!=0 otherwise
1623 * @enable: enable/disable the distribution.
1624 * @tc: TC id for which distribution is set
1625 * @fs_miss_flow_id: when packet misses all rules from flow steering table and
1626 * hash is disabled it will be put into this queue id; use
1627 * DPNI_FS_MISS_DROP to drop frames. The value of this field is
1628 * used only when flow steering distribution is enabled and hash
1629 * distribution is disabled
1631 struct dpni_rx_dist_cfg {
1633 uint64_t key_cfg_iova;
1636 uint16_t fs_miss_flow_id;
1639 int dpni_set_rx_fs_dist(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
1640 uint16_t token, const struct dpni_rx_dist_cfg *cfg);
1642 int dpni_set_rx_hash_dist(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
1643 uint16_t token, const struct dpni_rx_dist_cfg *cfg);
1645 int dpni_add_custom_tpid(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
1646 uint16_t token, uint16_t tpid);
1648 int dpni_remove_custom_tpid(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
1649 uint16_t token, uint16_t tpid);
1652 * struct dpni_custom_tpid_cfg - custom TPID configuration. Contains custom TPID
1653 * values used in current dpni object to detect 802.1q frames.
1654 * @tpid1: first tag. Not used if zero.
1655 * @tpid2: second tag. Not used if zero.
1657 struct dpni_custom_tpid_cfg {
1662 int dpni_get_custom_tpid(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
1663 uint16_t token, struct dpni_custom_tpid_cfg *tpid);
1666 * enum dpni_soft_sequence_dest - Enumeration of WRIOP software sequence
1668 * @DPNI_SS_INGRESS: Ingress parser
1669 * @DPNI_SS_EGRESS: Egress parser
1671 enum dpni_soft_sequence_dest {
1672 DPNI_SS_INGRESS = 0,
1677 * struct dpni_load_ss_cfg - Structure for Software Sequence load configuration
1678 * @dest: Destination of the Software Sequence: ingress or egress parser
1679 * @ss_size: Size of the Software Sequence
1680 * @ss_offset: The offset where to load the Software Sequence (0x20-0x7FD)
1681 * @ss_iova: I/O virtual address of the Software Sequence
1683 struct dpni_load_ss_cfg {
1684 enum dpni_soft_sequence_dest dest;
1691 * struct dpni_enable_ss_cfg - Structure for software sequence enable
1693 * @dest: Destination of the Software Sequence: ingress or egress parser
1694 * @hxs: HXS to attach the software sequence to
1695 * @set_start: If the Software Sequence or HDR it is attached to is set as
1697 * If hxs=DUMMY_LAST_HXS the ss_offset is set directly as parser
1698 * start else the hdr index code is set as parser start
1699 * @ss_offset: The offset of the Software Sequence to enable or set as parse
1701 * @param_size: Size of the software sequence parameters
1702 * @param_offset: Offset in the parameter zone for the software sequence
1704 * @param_iova: I/O virtual address of the parameters
1706 struct dpni_enable_ss_cfg {
1707 enum dpni_soft_sequence_dest dest;
1712 uint8_t param_offset;
1713 uint64_t param_iova;
1717 * dpni_load_sw_sequence() - Loads a software sequence in parser memory.
1718 * @mc_io: Pointer to MC portal's I/O object
1719 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1720 * @token: Token of DPNI object
1721 * @cfg: Software sequence load configuration
1722 * Return: '0' on Success; Error code otherwise.
1724 int dpni_load_sw_sequence(struct fsl_mc_io *mc_io,
1727 struct dpni_load_ss_cfg *cfg);
1730 * dpni_eanble_sw_sequence() - Enables a software sequence in the parser
1732 * corresponding to the ingress or egress of the DPNI.
1733 * @mc_io: Pointer to MC portal's I/O object
1734 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1735 * @token: Token of DPNI object
1736 * @cfg: Software sequence enable configuration
1737 * Return: '0' on Success; Error code otherwise.
1739 int dpni_enable_sw_sequence(struct fsl_mc_io *mc_io,
1742 struct dpni_enable_ss_cfg *cfg);
1745 * struct dpni_sw_sequence_layout - Structure for software sequence enable
1747 * @num_ss: Number of software sequences returned
1748 * @ss: Array of software sequence entries. The number of valid entries
1749 * must match 'num_ss' value
1751 struct dpni_sw_sequence_layout {
1756 uint8_t param_offset;
1758 } ss[DPNI_SW_SEQUENCE_LAYOUT_SIZE];
1762 * dpni_get_sw_sequence_layout() - Get the soft sequence layout
1763 * @mc_io: Pointer to MC portal's I/O object
1764 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1765 * @token: Token of DPNI object
1766 * @src: Source of the layout (WRIOP Rx or Tx)
1767 * @ss_layout_iova: I/O virtual address of 264 bytes DMA-able memory
1769 * warning: After calling this function, call dpni_extract_sw_sequence_layout()
1772 * Return: '0' on Success; error code otherwise.
1774 int dpni_get_sw_sequence_layout(struct fsl_mc_io *mc_io,
1777 enum dpni_soft_sequence_dest src,
1778 uint64_t ss_layout_iova);
1781 * dpni_extract_sw_sequence_layout() - extract the software sequence layout
1782 * @layout: software sequence layout
1783 * @sw_sequence_layout_buf: Zeroed 264 bytes of memory before mapping it
1786 * This function has to be called after dpni_get_sw_sequence_layout
1789 void dpni_extract_sw_sequence_layout(struct dpni_sw_sequence_layout *layout,
1790 const uint8_t *sw_sequence_layout_buf);
1792 #endif /* __FSL_DPNI_H */