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 * Define a custom number of congestion groups
97 #define DPNI_OPT_CUSTOM_CG 0x000200
99 int dpni_open(struct fsl_mc_io *mc_io,
104 int dpni_close(struct fsl_mc_io *mc_io,
109 * struct dpni_cfg - Structure representing DPNI configuration
110 * @options: Any combination of the following options:
111 * DPNI_OPT_TX_FRM_RELEASE
112 * DPNI_OPT_NO_MAC_FILTER
113 * DPNI_OPT_HAS_POLICING
114 * DPNI_OPT_SHARED_CONGESTION
115 * DPNI_OPT_HAS_KEY_MASKING
117 * DPNI_OPT_SINGLE_SENDER
118 * @fs_entries: Number of entries in the flow steering table.
119 * This table is used to select the ingress queue for
120 * ingress traffic, targeting a GPP core or another.
121 * In addition it can be used to discard traffic that
122 * matches the set rule. It is either an exact match table
123 * or a TCAM table, depending on DPNI_OPT_ HAS_KEY_MASKING
124 * bit in OPTIONS field. This field is ignored if
125 * DPNI_OPT_NO_FS bit is set in OPTIONS field. Otherwise,
126 * value 0 defaults to 64. Maximum supported value is 1024.
127 * Note that the total number of entries is limited on the
128 * SoC to as low as 512 entries if TCAM is used.
129 * @vlan_filter_entries: Number of entries in the VLAN address filtering
130 * table. This is an exact match table used to filter
131 * ingress traffic based on VLAN IDs. Value 0 disables VLAN
132 * filtering. Maximum supported value is 16.
133 * @mac_filter_entries: Number of entries in the MAC address filtering
134 * table. This is an exact match table and allows both
135 * unicast and multicast entries. The primary MAC address
136 * of the network interface is not part of this table,
137 * this contains only entries in addition to it. This
138 * field is ignored if DPNI_OPT_ NO_MAC_FILTER is set in
139 * OPTIONS field. Otherwise, value 0 defaults to 80.
140 * Maximum supported value is 80.
141 * @num_queues: Number of Tx and Rx queues used for traffic
142 * distribution. This is orthogonal to QoS and is only
143 * used to distribute traffic to multiple GPP cores.
144 * This configuration affects the number of Tx queues
145 * (logical FQs, all associated with a single CEETM queue),
146 * Rx queues and Tx confirmation queues, if applicable.
147 * Value 0 defaults to one queue. Maximum supported value
149 * @num_tcs: Number of traffic classes (TCs), reserved for the DPNI.
150 * TCs can have different priority levels for the purpose
151 * of Tx scheduling (see DPNI_SET_TX_PRIORITIES), different
152 * BPs (DPNI_ SET_POOLS), policers. There are dedicated QM
153 * queues for traffic classes (including class queues on
154 * Tx). Value 0 defaults to one TC. Maximum supported value
155 * is 16. There are maximum 16 TCs for Tx and 8 TCs for Rx.
156 * When num_tcs>8 Tx will use this value but Rx will have
157 * only 8 traffic classes.
158 * @num_rx_tcs: if set to other value than zero represents number
159 * of TCs used for Rx. Maximum value is 8. If set to zero the
160 * number of Rx TCs will be initialized with the value provided
161 * in num_tcs parameter.
162 * @qos_entries: Number of entries in the QoS classification table. This
163 * table is used to select the TC for ingress traffic. It
164 * is either an exact match or a TCAM table, depending on
165 * DPNI_OPT_ HAS_KEY_MASKING bit in OPTIONS field. This
166 * field is ignored if the DPNI has a single TC. Otherwise,
167 * a value of 0 defaults to 64. Maximum supported value
173 uint8_t vlan_filter_entries;
174 uint8_t mac_filter_entries;
182 int dpni_create(struct fsl_mc_io *mc_io,
185 const struct dpni_cfg *cfg,
188 int dpni_destroy(struct fsl_mc_io *mc_io,
194 * struct dpni_pools_cfg - Structure representing buffer pools configuration
195 * @num_dpbp: Number of DPBPs
196 * @pools: Array of buffer pools parameters; The number of valid entries
197 * must match 'num_dpbp' value
198 * @pools.dpbp_id: DPBP object ID
199 * @pools.priority: Priority mask that indicates TC's used with this buffer.
200 * I set to 0x00 MC will assume value 0xff.
201 * @pools.buffer_size: Buffer size
202 * @pools.backup_pool: Backup pool
204 struct dpni_pools_cfg {
208 uint8_t priority_mask;
209 uint16_t buffer_size;
211 } pools[DPNI_MAX_DPBP];
214 int dpni_set_pools(struct fsl_mc_io *mc_io,
217 const struct dpni_pools_cfg *cfg);
219 int dpni_enable(struct fsl_mc_io *mc_io,
223 int dpni_disable(struct fsl_mc_io *mc_io,
227 int dpni_is_enabled(struct fsl_mc_io *mc_io,
232 int dpni_reset(struct fsl_mc_io *mc_io,
237 * DPNI IRQ Index and Events
243 #define DPNI_IRQ_INDEX 0
245 * IRQ event - indicates a change in link state
247 #define DPNI_IRQ_EVENT_LINK_CHANGED 0x00000001
249 int dpni_set_irq_enable(struct fsl_mc_io *mc_io,
255 int dpni_get_irq_enable(struct fsl_mc_io *mc_io,
261 int dpni_set_irq_mask(struct fsl_mc_io *mc_io,
267 int dpni_get_irq_mask(struct fsl_mc_io *mc_io,
273 int dpni_get_irq_status(struct fsl_mc_io *mc_io,
279 int dpni_clear_irq_status(struct fsl_mc_io *mc_io,
286 * struct dpni_attr - Structure representing DPNI attributes
287 * @options: Any combination of the following options:
288 * DPNI_OPT_TX_FRM_RELEASE
289 * DPNI_OPT_NO_MAC_FILTER
290 * DPNI_OPT_HAS_POLICING
291 * DPNI_OPT_SHARED_CONGESTION
292 * DPNI_OPT_HAS_KEY_MASKING
294 * @num_queues: Number of Tx and Rx queues used for traffic distribution.
295 * @num_rx_tcs: Number of RX traffic classes (TCs), reserved for the DPNI.
296 * @num_tx_tcs: Number of TX traffic classes (TCs), reserved for the DPNI.
297 * @mac_filter_entries: Number of entries in the MAC address filtering
299 * @vlan_filter_entries: Number of entries in the VLAN address filtering
301 * @qos_entries: Number of entries in the QoS classification table.
302 * @fs_entries: Number of entries in the flow steering table.
303 * @qos_key_size: Size, in bytes, of the QoS look-up key. Defining a key larger
304 * than this when adding QoS entries will result
306 * @fs_key_size: Size, in bytes, of the flow steering look-up key. Defining a
307 * key larger than this when composing the hash + FS key
308 * will result in an error.
309 * @wriop_version: Version of WRIOP HW block.
310 * The 3 version values are stored on 6, 5, 5 bits
313 * - 0x400 - WRIOP version 1.0.0, used on LS2080 and
315 * - 0x421 - WRIOP version 1.1.1, used on LS2088 and
317 * - 0x422 - WRIOP version 1.1.2, used on LS1088 and
319 * - 0xC00 - WRIOP version 3.0.0, used on LX2160 and
327 uint8_t mac_filter_entries;
328 uint8_t vlan_filter_entries;
331 uint8_t qos_key_size;
333 uint16_t wriop_version;
337 int dpni_get_attributes(struct fsl_mc_io *mc_io,
340 struct dpni_attr *attr);
347 * Discard error. When set all discarded frames in wriop will be enqueued to
348 * error queue. To be used in dpni_set_errors_behavior() only if error_action
349 * parameter is set to DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE.
351 #define DPNI_ERROR_DISC 0x80000000
354 * Extract out of frame header error
356 #define DPNI_ERROR_EOFHE 0x00020000
360 #define DPNI_ERROR_FLE 0x00002000
362 * Frame physical error
364 #define DPNI_ERROR_FPE 0x00001000
366 * Parsing header error
368 #define DPNI_ERROR_PHE 0x00000020
370 * Parser L3 checksum error
372 #define DPNI_ERROR_L3CE 0x00000004
374 * Parser L3 checksum error
376 #define DPNI_ERROR_L4CE 0x00000001
379 * enum dpni_error_action - Defines DPNI behavior for errors
380 * @DPNI_ERROR_ACTION_DISCARD: Discard the frame
381 * @DPNI_ERROR_ACTION_CONTINUE: Continue with the normal flow
382 * @DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE: Send the frame to the error queue
384 enum dpni_error_action {
385 DPNI_ERROR_ACTION_DISCARD = 0,
386 DPNI_ERROR_ACTION_CONTINUE = 1,
387 DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE = 2
391 * struct dpni_error_cfg - Structure representing DPNI errors treatment
392 * @errors: Errors mask; use 'DPNI_ERROR__<X>
393 * @error_action: The desired action for the errors mask
394 * @set_frame_annotation: Set to '1' to mark the errors in frame
395 * annotation status (FAS); relevant only
396 * for the non-discard action
398 struct dpni_error_cfg {
400 enum dpni_error_action error_action;
401 int set_frame_annotation;
404 int dpni_set_errors_behavior(struct fsl_mc_io *mc_io,
407 struct dpni_error_cfg *cfg);
410 * DPNI buffer layout modification options
414 * Select to modify the time-stamp setting
416 #define DPNI_BUF_LAYOUT_OPT_TIMESTAMP 0x00000001
418 * Select to modify the parser-result setting; not applicable for Tx
420 #define DPNI_BUF_LAYOUT_OPT_PARSER_RESULT 0x00000002
422 * Select to modify the frame-status setting
424 #define DPNI_BUF_LAYOUT_OPT_FRAME_STATUS 0x00000004
426 * Select to modify the private-data-size setting
428 #define DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE 0x00000008
430 * Select to modify the data-alignment setting
432 #define DPNI_BUF_LAYOUT_OPT_DATA_ALIGN 0x00000010
434 * Select to modify the data-head-room setting
436 #define DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM 0x00000020
438 * Select to modify the data-tail-room setting
440 #define DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM 0x00000040
442 * Select to modify the sw-opaque value setting
444 #define DPNI_BUF_LAYOUT_OPT_SW_OPAQUE 0x00000080
447 * struct dpni_buffer_layout - Structure representing DPNI buffer layout
448 * @options: Flags representing the suggested modifications to the
450 * Use any combination of 'DPNI_BUF_LAYOUT_OPT_<X>' flags
451 * @pass_timestamp: Pass timestamp value
452 * @pass_parser_result: Pass parser results
453 * @pass_frame_status: Pass frame status
454 * @private_data_size: Size kept for private data (in bytes)
455 * @data_align: Data alignment
456 * @data_head_room: Data head room
457 * @data_tail_room: Data tail room
459 struct dpni_buffer_layout {
462 int pass_parser_result;
463 int pass_frame_status;
465 uint16_t private_data_size;
467 uint16_t data_head_room;
468 uint16_t data_tail_room;
472 * enum dpni_queue_type - Identifies a type of queue targeted by the command
473 * @DPNI_QUEUE_RX: Rx queue
474 * @DPNI_QUEUE_TX: Tx queue
475 * @DPNI_QUEUE_TX_CONFIRM: Tx confirmation queue
476 * @DPNI_QUEUE_RX_ERR: Rx error queue
478 enum dpni_queue_type {
481 DPNI_QUEUE_TX_CONFIRM,
485 int dpni_get_buffer_layout(struct fsl_mc_io *mc_io,
488 enum dpni_queue_type qtype,
489 struct dpni_buffer_layout *layout);
491 int dpni_set_buffer_layout(struct fsl_mc_io *mc_io,
494 enum dpni_queue_type qtype,
495 const struct dpni_buffer_layout *layout);
498 * enum dpni_offload - Identifies a type of offload targeted by the command
499 * @DPNI_OFF_RX_L3_CSUM: Rx L3 checksum validation
500 * @DPNI_OFF_RX_L4_CSUM: Rx L4 checksum validation
501 * @DPNI_OFF_TX_L3_CSUM: Tx L3 checksum generation
502 * @DPNI_OFF_TX_L4_CSUM: Tx L4 checksum generation
503 * @DPNI_OPT_FLCTYPE_HASH: flow context will be generated by WRIOP for AIOP or
514 int dpni_set_offload(struct fsl_mc_io *mc_io,
517 enum dpni_offload type,
520 int dpni_get_offload(struct fsl_mc_io *mc_io,
523 enum dpni_offload type,
526 int dpni_get_qdid(struct fsl_mc_io *mc_io,
529 enum dpni_queue_type qtype,
532 int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io,
535 uint16_t *data_offset);
537 #define DPNI_STATISTICS_CNT 7
540 * union dpni_statistics - Union describing the DPNI statistics
541 * @page_0: Page_0 statistics structure
542 * @page_0.ingress_all_frames: Ingress frame count
543 * @page_0.ingress_all_bytes: Ingress byte count
544 * @page_0.ingress_multicast_frames: Ingress multicast frame count
545 * @page_0.ingress_multicast_bytes: Ingress multicast byte count
546 * @page_0.ingress_broadcast_frames: Ingress broadcast frame count
547 * @page_0.ingress_broadcast_bytes: Ingress broadcast byte count
548 * @page_1: Page_1 statistics structure
549 * @page_1.egress_all_frames: Egress frame count
550 * @page_1.egress_all_bytes: Egress byte count
551 * @page_1.egress_multicast_frames: Egress multicast frame count
552 * @page_1.egress_multicast_bytes: Egress multicast byte count
553 * @page_1.egress_broadcast_frames: Egress broadcast frame count
554 * @page_1.egress_broadcast_bytes: Egress broadcast byte count
555 * @page_2: Page_2 statistics structure
556 * @page_2.ingress_filtered_frames: Ingress filtered frame count
557 * @page_2.ingress_discarded_frames: Ingress discarded frame count
558 * @page_2.ingress_nobuffer_discards: Ingress discarded frame count due to
560 * @page_2.egress_discarded_frames: Egress discarded frame count
561 * @page_2.egress_confirmed_frames: Egress confirmed frame count
562 * @page_3: Page_3 statistics structure with values for the selected TC
563 * @page_3.ceetm_dequeue_bytes: Cumulative count of the number of bytes dequeued
564 * @page_3.ceetm_dequeue_frames: Cumulative count of the number of frames
566 * @page_3.ceetm_reject_bytes: Cumulative count of the number of bytes in all
567 * frames whose enqueue was rejected
568 * @page_3.ceetm_reject_frames: Cumulative count of all frame enqueues rejected
569 * @page_4: congestion point drops for seleted TC
570 * @page_4.cgr_reject_frames: number of rejected frames due to congestion point
571 * @page_4.cgr_reject_bytes: number of rejected bytes due to congestion point
572 * @page_5: policer statistics per TC
573 * @page_5.policer_cnt_red: NUmber of red colored frames
574 * @page_5.policer_cnt_yellow: number of yellow colored frames
575 * @page_5.policer_cnt_green: number of green colored frames
576 * @page_5.policer_cnt_re_red: number of recolored red frames
577 * @page_5.policer_cnt_re_yellow: number of recolored yellow frames
578 * @raw: raw statistics structure, used to index counters
580 union dpni_statistics {
582 uint64_t ingress_all_frames;
583 uint64_t ingress_all_bytes;
584 uint64_t ingress_multicast_frames;
585 uint64_t ingress_multicast_bytes;
586 uint64_t ingress_broadcast_frames;
587 uint64_t ingress_broadcast_bytes;
590 uint64_t egress_all_frames;
591 uint64_t egress_all_bytes;
592 uint64_t egress_multicast_frames;
593 uint64_t egress_multicast_bytes;
594 uint64_t egress_broadcast_frames;
595 uint64_t egress_broadcast_bytes;
598 uint64_t ingress_filtered_frames;
599 uint64_t ingress_discarded_frames;
600 uint64_t ingress_nobuffer_discards;
601 uint64_t egress_discarded_frames;
602 uint64_t egress_confirmed_frames;
605 uint64_t ceetm_dequeue_bytes;
606 uint64_t ceetm_dequeue_frames;
607 uint64_t ceetm_reject_bytes;
608 uint64_t ceetm_reject_frames;
611 uint64_t cgr_reject_frames;
612 uint64_t cgr_reject_bytes;
615 uint64_t policer_cnt_red;
616 uint64_t policer_cnt_yellow;
617 uint64_t policer_cnt_green;
618 uint64_t policer_cnt_re_red;
619 uint64_t policer_cnt_re_yellow;
622 uint64_t counter[DPNI_STATISTICS_CNT];
627 * Enable auto-negotiation
629 #define DPNI_LINK_OPT_AUTONEG 0x0000000000000001ULL
631 * Enable half-duplex mode
633 #define DPNI_LINK_OPT_HALF_DUPLEX 0x0000000000000002ULL
635 * Enable pause frames
637 #define DPNI_LINK_OPT_PAUSE 0x0000000000000004ULL
639 * Enable a-symmetric pause frames
641 #define DPNI_LINK_OPT_ASYM_PAUSE 0x0000000000000008ULL
643 * Enable priority flow control pause frames
645 #define DPNI_LINK_OPT_PFC_PAUSE 0x0000000000000010ULL
648 * Advertise 10MB full duplex
650 #define DPNI_ADVERTISED_10BASET_FULL 0x0000000000000001ULL
652 * Advertise 100MB full duplex
654 #define DPNI_ADVERTISED_100BASET_FULL 0x0000000000000002ULL
656 * Advertise 1GB full duplex
658 #define DPNI_ADVERTISED_1000BASET_FULL 0x0000000000000004ULL
660 * Advertise auto-negotiation enable
662 #define DPNI_ADVERTISED_AUTONEG 0x0000000000000008ULL
664 * Advertise 10GB full duplex
666 #define DPNI_ADVERTISED_10000BASET_FULL 0x0000000000000010ULL
668 * Advertise 2.5GB full duplex
670 #define DPNI_ADVERTISED_2500BASEX_FULL 0x0000000000000020ULL
672 * Advertise 5GB full duplex
674 #define DPNI_ADVERTISED_5000BASET_FULL 0x0000000000000040ULL
678 * struct - Structure representing DPNI link configuration
680 * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
681 * @advertising: Speeds that are advertised for autoneg (bitmap)
683 struct dpni_link_cfg {
686 uint64_t advertising;
689 int dpni_set_link_cfg(struct fsl_mc_io *mc_io,
692 const struct dpni_link_cfg *cfg);
695 * struct dpni_link_state - Structure representing DPNI link state
697 * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
698 * @up: Link state; '0' for down, '1' for up
699 * @state_valid: Ignore/Update the state of the link
700 * @supported: Speeds capability of the phy (bitmap)
701 * @advertising: Speeds that are advertised for autoneg (bitmap)
703 struct dpni_link_state {
709 uint64_t advertising;
712 int dpni_get_link_state(struct fsl_mc_io *mc_io,
715 struct dpni_link_state *state);
717 int dpni_set_max_frame_length(struct fsl_mc_io *mc_io,
720 uint16_t max_frame_length);
722 int dpni_get_max_frame_length(struct fsl_mc_io *mc_io,
725 uint16_t *max_frame_length);
727 int dpni_set_mtu(struct fsl_mc_io *mc_io,
732 int dpni_get_mtu(struct fsl_mc_io *mc_io,
737 int dpni_set_multicast_promisc(struct fsl_mc_io *mc_io,
742 int dpni_get_multicast_promisc(struct fsl_mc_io *mc_io,
747 int dpni_set_unicast_promisc(struct fsl_mc_io *mc_io,
752 int dpni_get_unicast_promisc(struct fsl_mc_io *mc_io,
757 int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
760 const uint8_t mac_addr[6]);
762 int dpni_get_primary_mac_addr(struct fsl_mc_io *mc_io,
765 uint8_t mac_addr[6]);
767 int dpni_add_mac_addr(struct fsl_mc_io *mc_io,
770 const uint8_t mac_addr[6]);
772 int dpni_remove_mac_addr(struct fsl_mc_io *mc_io,
775 const uint8_t mac_addr[6]);
777 int dpni_clear_mac_filters(struct fsl_mc_io *mc_io,
783 int dpni_get_port_mac_addr(struct fsl_mc_io *mc_io,
786 uint8_t mac_addr[6]);
788 int dpni_enable_vlan_filter(struct fsl_mc_io *mc_io,
793 int dpni_add_vlan_id(struct fsl_mc_io *mc_io,
798 int dpni_remove_vlan_id(struct fsl_mc_io *mc_io,
803 int dpni_clear_vlan_filters(struct fsl_mc_io *mc_io,
808 * enum dpni_dist_mode - DPNI distribution mode
809 * @DPNI_DIST_MODE_NONE: No distribution
810 * @DPNI_DIST_MODE_HASH: Use hash distribution; only relevant if
811 * the 'DPNI_OPT_DIST_HASH' option was set at DPNI creation
812 * @DPNI_DIST_MODE_FS: Use explicit flow steering; only relevant if
813 * the 'DPNI_OPT_DIST_FS' option was set at DPNI creation
815 enum dpni_dist_mode {
816 DPNI_DIST_MODE_NONE = 0,
817 DPNI_DIST_MODE_HASH = 1,
818 DPNI_DIST_MODE_FS = 2
822 * enum dpni_fs_miss_action - DPNI Flow Steering miss action
823 * @DPNI_FS_MISS_DROP: In case of no-match, drop the frame
824 * @DPNI_FS_MISS_EXPLICIT_FLOWID: In case of no-match, use explicit flow-id
825 * @DPNI_FS_MISS_HASH: In case of no-match, distribute using hash
827 enum dpni_fs_miss_action {
828 DPNI_FS_MISS_DROP = 0,
829 DPNI_FS_MISS_EXPLICIT_FLOWID = 1,
830 DPNI_FS_MISS_HASH = 2
834 * struct dpni_fs_tbl_cfg - Flow Steering table configuration
835 * @miss_action: Miss action selection
836 * @default_flow_id: Used when 'miss_action = DPNI_FS_MISS_EXPLICIT_FLOWID'
837 * @keep_hash_key: used only when miss_action is set to DPNI_FS_MISS_HASH. When
838 * set to one unclassified frames will be distributed according to previous
839 * used hash key. If set to zero hash key will be replaced with the key
840 * provided for flow steering.
841 * @keep_entries: if set to one command will not delete the entries that already
842 * exist into FS table. Use this option with caution: if the table
843 * entries are not compatible with the distribution key the packets
844 * will not be classified properly.
846 struct dpni_fs_tbl_cfg {
847 enum dpni_fs_miss_action miss_action;
848 uint16_t default_flow_id;
850 uint8_t keep_entries;
854 * struct dpni_rx_tc_dist_cfg - Rx traffic class distribution configuration
855 * @dist_size: Set the distribution size;
856 * supported values: 1,2,3,4,6,7,8,12,14,16,24,28,32,48,56,64,96,
857 * 112,128,192,224,256,384,448,512,768,896,1024
858 * @dist_mode: Distribution mode
859 * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
860 * the extractions to be used for the distribution key by calling
861 * dpkg_prepare_key_cfg() relevant only when
862 * 'dist_mode != DPNI_DIST_MODE_NONE', otherwise it can be '0'
863 * @fs_cfg: Flow Steering table configuration; only relevant if
864 * 'dist_mode = DPNI_DIST_MODE_FS'
866 struct dpni_rx_tc_dist_cfg {
868 enum dpni_dist_mode dist_mode;
869 uint64_t key_cfg_iova;
870 struct dpni_fs_tbl_cfg fs_cfg;
873 int dpni_set_rx_tc_dist(struct fsl_mc_io *mc_io,
877 const struct dpni_rx_tc_dist_cfg *cfg);
880 * enum dpni_congestion_unit - DPNI congestion units
881 * @DPNI_CONGESTION_UNIT_BYTES: bytes units
882 * @DPNI_CONGESTION_UNIT_FRAMES: frames units
884 enum dpni_congestion_unit {
885 DPNI_CONGESTION_UNIT_BYTES = 0,
886 DPNI_CONGESTION_UNIT_FRAMES
890 * enum dpni_dest - DPNI destination types
891 * @DPNI_DEST_NONE: Unassigned destination; The queue is set in parked mode and
892 * does not generate FQDAN notifications; user is expected to
893 * dequeue from the queue based on polling or other user-defined
895 * @DPNI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
896 * notifications to the specified DPIO; user is expected to dequeue
897 * from the queue only after notification is received
898 * @DPNI_DEST_DPCON: The queue is set in schedule mode and does not generate
899 * FQDAN notifications, but is connected to the specified DPCON
900 * object; user is expected to dequeue from the DPCON channel
909 * struct dpni_dest_cfg - Structure representing DPNI destination parameters
910 * @dest_type: Destination type
911 * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
912 * @priority: Priority selection within the DPIO or DPCON channel; valid values
913 * are 0-1 or 0-7, depending on the number of priorities in that
914 * channel; not relevant for 'DPNI_DEST_NONE' option
916 struct dpni_dest_cfg {
917 enum dpni_dest dest_type;
922 /* DPNI congestion options */
925 * CSCN message is written to message_iova once entering a
926 * congestion state (see 'threshold_entry')
928 #define DPNI_CONG_OPT_WRITE_MEM_ON_ENTER 0x00000001
930 * CSCN message is written to message_iova once exiting a
931 * congestion state (see 'threshold_exit')
933 #define DPNI_CONG_OPT_WRITE_MEM_ON_EXIT 0x00000002
935 * CSCN write will attempt to allocate into a cache (coherent write);
936 * valid only if 'DPNI_CONG_OPT_WRITE_MEM_<X>' is selected
938 #define DPNI_CONG_OPT_COHERENT_WRITE 0x00000004
940 * if 'dest_cfg.dest_type != DPNI_DEST_NONE' CSCN message is sent to
941 * DPIO/DPCON's WQ channel once entering a congestion state
942 * (see 'threshold_entry')
944 #define DPNI_CONG_OPT_NOTIFY_DEST_ON_ENTER 0x00000008
946 * if 'dest_cfg.dest_type != DPNI_DEST_NONE' CSCN message is sent to
947 * DPIO/DPCON's WQ channel once exiting a congestion state
948 * (see 'threshold_exit')
950 #define DPNI_CONG_OPT_NOTIFY_DEST_ON_EXIT 0x00000010
952 * if 'dest_cfg.dest_type != DPNI_DEST_NONE' when the CSCN is written to the
953 * sw-portal's DQRR, the DQRI interrupt is asserted immediately (if enabled)
955 #define DPNI_CONG_OPT_INTR_COALESCING_DISABLED 0x00000020
957 * This congestion will trigger flow control or priority flow control. This
958 * will have effect only if flow control is enabled with dpni_set_link_cfg()
960 #define DPNI_CONG_OPT_FLOW_CONTROL 0x00000040
963 * enum dpni_congestion_point - Structure representing congestion point
964 * @DPNI_CP_QUEUE: Set congestion per queue, identified by QUEUE_TYPE, TC
966 * @DPNI_CP_GROUP: Set congestion per queue group. Depending on options
967 * used to define the DPNI this can be either per
968 * TC (default) or per interface
969 * (DPNI_OPT_SHARED_CONGESTION set at DPNI create).
970 * QUEUE_INDEX is ignored if this type is used.
971 * @DPNI_CP_CONGESTION_GROUP: Set per congestion group id. This will work
972 * only if the DPNI is created with DPNI_OPT_CUSTOM_CG option
975 enum dpni_congestion_point {
978 DPNI_CP_CONGESTION_GROUP,
982 * struct dpni_congestion_notification_cfg - congestion notification
985 * @threshold_entry: above this threshold we enter a congestion state.
986 * set it to '0' to disable it
987 * @threshold_exit: below this threshold we exit the congestion state.
988 * @message_ctx: The context that will be part of the CSCN message
989 * @message_iova: I/O virtual address (must be in DMA-able memory),
990 * must be 16B aligned; valid only if 'DPNI_CONG_OPT_WRITE_MEM_<X>' is
991 * contained in 'options'
992 * @dest_cfg: CSCN can be send to either DPIO or DPCON WQ channel
993 * @notification_mode: Mask of available options; use 'DPNI_CONG_OPT_<X>' values
994 * @cg_point: Congestion point settings
995 * @cgid: id of the congestion group. The index is relative to dpni.
998 struct dpni_congestion_notification_cfg {
999 enum dpni_congestion_unit units;
1000 uint32_t threshold_entry;
1001 uint32_t threshold_exit;
1002 uint64_t message_ctx;
1003 uint64_t message_iova;
1004 struct dpni_dest_cfg dest_cfg;
1005 uint16_t notification_mode;
1006 enum dpni_congestion_point cg_point;
1010 int dpni_set_congestion_notification(struct fsl_mc_io *mc_io,
1013 enum dpni_queue_type qtype,
1015 const struct dpni_congestion_notification_cfg *cfg);
1017 int dpni_get_congestion_notification(struct fsl_mc_io *mc_io,
1020 enum dpni_queue_type qtype,
1022 struct dpni_congestion_notification_cfg *cfg);
1024 /* DPNI FLC stash options */
1027 * stashes the whole annotation area (up to 192 bytes)
1029 #define DPNI_FLC_STASH_FRAME_ANNOTATION 0x00000001
1032 * struct dpni_queue - Queue structure
1033 * @destination - Destination structure
1034 * @destination.id: ID of the destination, only relevant if DEST_TYPE is > 0.
1035 * Identifies either a DPIO or a DPCON object.
1036 * Not relevant for Tx queues.
1037 * @destination.type: May be one of the following:
1038 * 0 - No destination, queue can be manually
1039 * queried, but will not push traffic or
1040 * notifications to a DPIO;
1041 * 1 - The destination is a DPIO. When traffic
1042 * becomes available in the queue a FQDAN
1043 * (FQ data available notification) will be
1044 * generated to selected DPIO;
1045 * 2 - The destination is a DPCON. The queue is
1046 * associated with a DPCON object for the
1047 * purpose of scheduling between multiple
1048 * queues. The DPCON may be independently
1049 * configured to generate notifications.
1050 * Not relevant for Tx queues.
1051 * @destination.hold_active: Hold active, maintains a queue scheduled for longer
1052 * in a DPIO during dequeue to reduce spread of traffic.
1053 * Only relevant if queues are
1054 * not affined to a single DPIO.
1055 * @user_context: User data, presented to the user along with any frames
1056 * from this queue. Not relevant for Tx queues.
1057 * @flc: FD FLow Context structure
1058 * @flc.value: Default FLC value for traffic dequeued from
1059 * this queue. Please check description of FD
1060 * structure for more information.
1061 * Note that FLC values set using dpni_add_fs_entry,
1062 * if any, take precedence over values per queue.
1063 * @flc.stash_control: Boolean, indicates whether the 6 lowest
1064 * - significant bits are used for stash control.
1065 * significant bits are used for stash control. If set, the 6
1066 * least significant bits in value are interpreted as follows:
1067 * - bits 0-1: indicates the number of 64 byte units of context
1068 * that are stashed. FLC value is interpreted as a memory address
1069 * in this case, excluding the 6 LS bits.
1070 * - bits 2-3: indicates the number of 64 byte units of frame
1071 * annotation to be stashed. Annotation is placed at FD[ADDR].
1072 * - bits 4-5: indicates the number of 64 byte units of frame
1073 * data to be stashed. Frame data is placed at FD[ADDR] +
1075 * For more details check the Frame Descriptor section in the
1076 * hardware documentation.
1077 *@cgid :indicate the cgid to set relative to dpni
1082 enum dpni_dest type;
1086 uint64_t user_context;
1095 * struct dpni_queue_id - Queue identification, used for enqueue commands
1097 * @fqid: FQID used for enqueueing to and/or configuration of this
1099 * @qdbin: Queueing bin, used to enqueue using QDID, DQBIN, QPRI.
1100 * Only relevant for Tx queues.
1102 struct dpni_queue_id {
1108 * enum dpni_confirmation_mode - Defines DPNI options supported for Tx
1110 * @DPNI_CONF_AFFINE: For each Tx queue set associated with a sender there is
1111 * an affine Tx Confirmation queue
1112 * @DPNI_CONF_SINGLE: All Tx queues are associated with a single Tx
1113 * confirmation queue
1114 * @DPNI_CONF_DISABLE: Tx frames are not confirmed. This must be associated
1115 * with proper FD set-up to have buffers release to a Buffer Pool, otherwise
1116 * buffers will be leaked
1118 enum dpni_confirmation_mode {
1124 int dpni_set_tx_confirmation_mode(struct fsl_mc_io *mc_io,
1127 enum dpni_confirmation_mode mode);
1129 int dpni_get_tx_confirmation_mode(struct fsl_mc_io *mc_io,
1132 enum dpni_confirmation_mode *mode);
1135 * struct dpni_qos_tbl_cfg - Structure representing QOS table configuration
1136 * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
1137 * key extractions to be used as the QoS criteria by calling
1138 * dpkg_prepare_key_cfg()
1139 * @discard_on_miss: Set to '1' to discard frames in case of no match (miss);
1140 * '0' to use the 'default_tc' in such cases
1141 * @keep_entries: if set to one will not delele existing table entries. This
1142 * option will work properly only for dpni objects created with
1143 * DPNI_OPT_HAS_KEY_MASKING option. All previous QoS entries must
1144 * be compatible with new key composition rule.
1145 * It is the caller's job to delete incompatible entries before
1146 * executing this function.
1147 * @default_tc: Used in case of no-match and 'discard_on_miss'= 0
1149 struct dpni_qos_tbl_cfg {
1150 uint64_t key_cfg_iova;
1151 int discard_on_miss;
1156 int dpni_set_qos_table(struct fsl_mc_io *mc_io,
1159 const struct dpni_qos_tbl_cfg *cfg);
1162 * struct dpni_rule_cfg - Rule configuration for table lookup
1163 * @key_iova: I/O virtual address of the key (must be in DMA-able memory)
1164 * @mask_iova: I/O virtual address of the mask (must be in DMA-able memory)
1165 * @key_size: key and mask size (in bytes)
1167 struct dpni_rule_cfg {
1173 int dpni_add_qos_entry(struct fsl_mc_io *mc_io,
1176 const struct dpni_rule_cfg *cfg,
1180 int dpni_remove_qos_entry(struct fsl_mc_io *mc_io,
1183 const struct dpni_rule_cfg *cfg);
1185 int dpni_clear_qos_table(struct fsl_mc_io *mc_io,
1190 * Discard matching traffic. If set, this takes precedence over any other
1191 * configuration and matching traffic is always discarded.
1193 #define DPNI_FS_OPT_DISCARD 0x1
1196 * Set FLC value. If set, flc member of truct dpni_fs_action_cfg is used to
1197 * override the FLC value set per queue.
1198 * For more details check the Frame Descriptor section in the hardware
1201 #define DPNI_FS_OPT_SET_FLC 0x2
1204 * Indicates whether the 6 lowest significant bits of FLC are used for stash
1205 * control. If set, the 6 least significant bits in value are interpreted as
1207 * - bits 0-1: indicates the number of 64 byte units of context that are
1208 * stashed. FLC value is interpreted as a memory address in this case,
1209 * excluding the 6 LS bits.
1210 * - bits 2-3: indicates the number of 64 byte units of frame annotation
1211 * to be stashed. Annotation is placed at FD[ADDR].
1212 * - bits 4-5: indicates the number of 64 byte units of frame data to be
1213 * stashed. Frame data is placed at FD[ADDR] + FD[OFFSET].
1214 * This flag is ignored if DPNI_FS_OPT_SET_FLC is not specified.
1216 #define DPNI_FS_OPT_SET_STASH_CONTROL 0x4
1219 * struct dpni_fs_action_cfg - Action configuration for table look-up
1220 * @flc: FLC value for traffic matching this rule. Please check the Frame
1221 * Descriptor section in the hardware documentation for more information.
1222 * @flow_id: Identifies the Rx queue used for matching traffic. Supported
1223 * values are in range 0 to num_queue-1.
1224 * @options: Any combination of DPNI_FS_OPT_ values.
1226 struct dpni_fs_action_cfg {
1232 int dpni_add_fs_entry(struct fsl_mc_io *mc_io,
1237 const struct dpni_rule_cfg *cfg,
1238 const struct dpni_fs_action_cfg *action);
1240 int dpni_remove_fs_entry(struct fsl_mc_io *mc_io,
1244 const struct dpni_rule_cfg *cfg);
1246 int dpni_clear_fs_entries(struct fsl_mc_io *mc_io,
1251 int dpni_get_api_version(struct fsl_mc_io *mc_io,
1253 uint16_t *major_ver,
1254 uint16_t *minor_ver);
1259 #define DPNI_QUEUE_OPT_USER_CTX 0x00000001
1262 * Set queue destination configuration
1264 #define DPNI_QUEUE_OPT_DEST 0x00000002
1267 * Set FD[FLC] configuration for traffic on this queue. Note that FLC values
1268 * set with dpni_add_fs_entry, if any, take precedence over values per queue.
1270 #define DPNI_QUEUE_OPT_FLC 0x00000004
1273 * Set the queue to hold active mode. This prevents the queue from being
1274 * rescheduled between DPIOs while it carries traffic and is active on one
1275 * DPNI. Can help reduce reordering when servicing one queue on multiple
1276 * CPUs, but the queue is also less likely to push data to multiple CPUs
1277 * especially when congested.
1279 #define DPNI_QUEUE_OPT_HOLD_ACTIVE 0x00000008
1281 #define DPNI_QUEUE_OPT_SET_CGID 0x00000040
1282 #define DPNI_QUEUE_OPT_CLEAR_CGID 0x00000080
1284 int dpni_set_queue(struct fsl_mc_io *mc_io,
1287 enum dpni_queue_type qtype,
1291 const struct dpni_queue *queue);
1293 int dpni_get_queue(struct fsl_mc_io *mc_io,
1296 enum dpni_queue_type qtype,
1299 struct dpni_queue *queue,
1300 struct dpni_queue_id *qid);
1302 int dpni_get_statistics(struct fsl_mc_io *mc_io,
1307 union dpni_statistics *stat);
1309 int dpni_reset_statistics(struct fsl_mc_io *mc_io,
1314 * struct dpni_taildrop - Structure representing the taildrop
1315 * @enable: Indicates whether the taildrop is active or not.
1316 * @units: Indicates the unit of THRESHOLD. Queue taildrop only
1317 * supports byte units, this field is ignored and
1318 * assumed = 0 if CONGESTION_POINT is 0.
1319 * @threshold: Threshold value, in units identified by UNITS field. Value 0
1320 * cannot be used as a valid taildrop threshold,
1321 * THRESHOLD must be > 0 if the taildrop is
1323 * @oal : Overhead Accounting Length, a 12-bit, 2's complement value
1324 * with range (-2048 to +2047) representing a fixed per-frame
1325 * overhead to be added to the actual length of a frame when
1326 * performing WRED and tail drop calculations and threshold
1329 struct dpni_taildrop {
1331 enum dpni_congestion_unit units;
1336 int dpni_set_taildrop(struct fsl_mc_io *mc_io,
1339 enum dpni_congestion_point cg_point,
1340 enum dpni_queue_type q_type,
1343 struct dpni_taildrop *taildrop);
1345 int dpni_get_taildrop(struct fsl_mc_io *mc_io,
1348 enum dpni_congestion_point cg_point,
1349 enum dpni_queue_type q_type,
1352 struct dpni_taildrop *taildrop);
1354 int dpni_set_opr(struct fsl_mc_io *mc_io,
1360 struct opr_cfg *cfg);
1362 int dpni_get_opr(struct fsl_mc_io *mc_io,
1367 struct opr_cfg *cfg,
1368 struct opr_qry *qry);
1371 * When used for queue_idx in function dpni_set_rx_dist_default_queue will
1372 * signal to dpni to drop all unclassified frames
1374 #define DPNI_FS_MISS_DROP ((uint16_t)-1)
1377 * struct dpni_rx_dist_cfg - distribution configuration
1378 * @dist_size: distribution size; supported values: 1,2,3,4,6,7,8,
1379 * 12,14,16,24,28,32,48,56,64,96,112,128,192,224,256,384,448,
1381 * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
1382 * the extractions to be used for the distribution key by calling
1383 * dpkg_prepare_key_cfg() relevant only when enable!=0 otherwise
1385 * @enable: enable/disable the distribution.
1386 * @tc: TC id for which distribution is set
1387 * @fs_miss_flow_id: when packet misses all rules from flow steering table and
1388 * hash is disabled it will be put into this queue id; use
1389 * DPNI_FS_MISS_DROP to drop frames. The value of this field is
1390 * used only when flow steering distribution is enabled and hash
1391 * distribution is disabled
1393 struct dpni_rx_dist_cfg {
1395 uint64_t key_cfg_iova;
1398 uint16_t fs_miss_flow_id;
1401 int dpni_set_rx_fs_dist(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
1402 uint16_t token, const struct dpni_rx_dist_cfg *cfg);
1404 int dpni_set_rx_hash_dist(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
1405 uint16_t token, const struct dpni_rx_dist_cfg *cfg);
1407 int dpni_add_custom_tpid(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
1408 uint16_t token, uint16_t tpid);
1410 int dpni_remove_custom_tpid(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
1411 uint16_t token, uint16_t tpid);
1414 * struct dpni_custom_tpid_cfg - custom TPID configuration. Contains custom TPID
1415 * values used in current dpni object to detect 802.1q frames.
1416 * @tpid1: first tag. Not used if zero.
1417 * @tpid2: second tag. Not used if zero.
1419 struct dpni_custom_tpid_cfg {
1424 int dpni_get_custom_tpid(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
1425 uint16_t token, struct dpni_custom_tpid_cfg *tpid);
1427 #endif /* __FSL_DPNI_H */