1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
3 * Copyright 2013-2016 Freescale Semiconductor Inc.
4 * Copyright 2016-2021 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 size of a key
25 #define DPNI_MAX_KEY_SIZE 56
28 * Maximum number of traffic classes
32 * Maximum number of buffer pools per DPNI
34 #define DPNI_MAX_DPBP 8
36 * Maximum number of storage-profiles per DPNI
40 * Maximum number of Tx channels per DPNI
42 #define DPNI_MAX_CHANNELS 16
45 * All traffic classes considered; see dpni_set_queue()
47 #define DPNI_ALL_TCS (uint8_t)(-1)
49 * All flows within traffic class considered; see dpni_set_queue()
51 #define DPNI_ALL_TC_FLOWS (uint16_t)(-1)
54 * Tx traffic is always released to a buffer pool on transmit, there are no
55 * resources allocated to have the frames confirmed back to the source after
58 #define DPNI_OPT_TX_FRM_RELEASE 0x000001
60 * Disables support for MAC address filtering for addresses other than primary
61 * MAC address. This affects both unicast and multicast. Promiscuous mode can
62 * still be enabled/disabled for both unicast and multicast. If promiscuous mode
63 * is disabled, only traffic matching the primary MAC address will be accepted.
65 #define DPNI_OPT_NO_MAC_FILTER 0x000002
67 * Allocate policers for this DPNI. They can be used to rate-limit traffic per
68 * traffic class (TC) basis.
70 #define DPNI_OPT_HAS_POLICING 0x000004
72 * Congestion can be managed in several ways, allowing the buffer pool to
73 * deplete on ingress, taildrop on each queue or use congestion groups for sets
74 * of queues. If set, it configures a single congestion groups across all TCs.
75 * If reset, a congestion group is allocated for each TC. Only relevant if the
76 * DPNI has multiple traffic classes.
78 #define DPNI_OPT_SHARED_CONGESTION 0x000008
80 * Enables TCAM for Flow Steering and QoS look-ups. If not specified, all
81 * look-ups are exact match. Note that TCAM is not available on LS1088 and its
82 * variants. Setting this bit on these SoCs will trigger an error.
84 #define DPNI_OPT_HAS_KEY_MASKING 0x000010
86 * Disables the flow steering table.
88 #define DPNI_OPT_NO_FS 0x000020
91 * Enable the Order Restoration support
93 #define DPNI_OPT_HAS_OPR 0x000040
96 * Order Point Records are shared for the entire TC
98 #define DPNI_OPT_OPR_PER_TC 0x000080
100 * All Tx traffic classes will use a single sender (ignore num_queues for tx)
102 #define DPNI_OPT_SINGLE_SENDER 0x000100
104 * Define a custom number of congestion groups
106 #define DPNI_OPT_CUSTOM_CG 0x000200
108 * Define a custom number of order point records
110 #define DPNI_OPT_CUSTOM_OPR 0x000400
112 * Hash key is shared between all traffic classes
114 #define DPNI_OPT_SHARED_HASH_KEY 0x000800
116 * Flow steering table is shared between all traffic classes
118 #define DPNI_OPT_SHARED_FS 0x001000
120 * Software sequence maximum layout size
122 #define DPNI_SW_SEQUENCE_LAYOUT_SIZE 33
125 * Build a parameter from dpni channel and trafiic class. This parameter
126 * will be used to configure / query information from dpni objects created
127 * to support multiple channels.
129 #define DPNI_BUILD_PARAM(channel, tc_id) (((channel) << 8) | (tc_id))
131 int dpni_open(struct fsl_mc_io *mc_io,
136 int dpni_close(struct fsl_mc_io *mc_io,
141 * struct dpni_cfg - Structure representing DPNI configuration
142 * @options: Any combination of the following options:
143 * DPNI_OPT_TX_FRM_RELEASE
144 * DPNI_OPT_NO_MAC_FILTER
145 * DPNI_OPT_HAS_POLICING
146 * DPNI_OPT_SHARED_CONGESTION
147 * DPNI_OPT_HAS_KEY_MASKING
149 * DPNI_OPT_SINGLE_SENDER
150 * @fs_entries: Number of entries in the flow steering table.
151 * This table is used to select the ingress queue for
152 * ingress traffic, targeting a GPP core or another.
153 * In addition it can be used to discard traffic that
154 * matches the set rule. It is either an exact match table
155 * or a TCAM table, depending on DPNI_OPT_ HAS_KEY_MASKING
156 * bit in OPTIONS field. This field is ignored if
157 * DPNI_OPT_NO_FS bit is set in OPTIONS field. Otherwise,
158 * value 0 defaults to 64. Maximum supported value is 1024.
159 * Note that the total number of entries is limited on the
160 * SoC to as low as 512 entries if TCAM is used.
161 * @vlan_filter_entries: Number of entries in the VLAN address filtering
162 * table. This is an exact match table used to filter
163 * ingress traffic based on VLAN IDs. Value 0 disables VLAN
164 * filtering. Maximum supported value is 16.
165 * @mac_filter_entries: Number of entries in the MAC address filtering
166 * table. This is an exact match table and allows both
167 * unicast and multicast entries. The primary MAC address
168 * of the network interface is not part of this table,
169 * this contains only entries in addition to it. This
170 * field is ignored if DPNI_OPT_ NO_MAC_FILTER is set in
171 * OPTIONS field. Otherwise, value 0 defaults to 80.
172 * Maximum supported value is 80.
173 * @num_queues: Number of Tx and Rx queues used for traffic
174 * distribution. This is orthogonal to QoS and is only
175 * used to distribute traffic to multiple GPP cores.
176 * This configuration affects the number of Tx queues
177 * (logical FQs, all associated with a single CEETM queue),
178 * Rx queues and Tx confirmation queues, if applicable.
179 * Value 0 defaults to one queue. Maximum supported value
181 * @num_tcs: Number of traffic classes (TCs), reserved for the DPNI.
182 * TCs can have different priority levels for the purpose
183 * of Tx scheduling (see DPNI_SET_TX_PRIORITIES), different
184 * BPs (DPNI_ SET_POOLS), policers. There are dedicated QM
185 * queues for traffic classes (including class queues on
186 * Tx). Value 0 defaults to one TC. Maximum supported value
187 * is 16. There are maximum 16 TCs for Tx and 8 TCs for Rx.
188 * When num_tcs>8 Tx will use this value but Rx will have
189 * only 8 traffic classes.
190 * @num_rx_tcs: if set to other value than zero represents number
191 * of TCs used for Rx. Maximum value is 8. If set to zero the
192 * number of Rx TCs will be initialized with the value provided
193 * in num_tcs parameter.
194 * @qos_entries: Number of entries in the QoS classification table. This
195 * table is used to select the TC for ingress traffic. It
196 * is either an exact match or a TCAM table, depending on
197 * DPNI_OPT_ HAS_KEY_MASKING bit in OPTIONS field. This
198 * field is ignored if the DPNI has a single TC. Otherwise,
199 * a value of 0 defaults to 64. Maximum supported value
201 * @num_channels: Number of egress channels used by this dpni object. If
202 * set to zero the dpni object will use a single CEETM channel.
207 uint8_t vlan_filter_entries;
208 uint8_t mac_filter_entries;
215 uint8_t dist_key_size;
216 uint8_t num_channels;
219 int dpni_create(struct fsl_mc_io *mc_io,
222 const struct dpni_cfg *cfg,
225 int dpni_destroy(struct fsl_mc_io *mc_io,
231 * struct dpni_pools_cfg - Structure representing buffer pools configuration
232 * @num_dpbp: Number of DPBPs
233 * @pool_options: Buffer assignment options
234 * This field is a combination of DPNI_POOL_ASSOC_flags
235 * @pools: Array of buffer pools parameters; The number of valid entries
236 * must match 'num_dpbp' value
237 * @pools.dpbp_id: DPBP object ID
238 * @pools.priority: Priority mask that indicates TC's used with this buffer.
239 * I set to 0x00 MC will assume value 0xff.
240 * @pools.buffer_size: Buffer size
241 * @pools.backup_pool: Backup pool
244 #define DPNI_POOL_ASSOC_QPRI 0
245 #define DPNI_POOL_ASSOC_QDBIN 1
247 struct dpni_pools_cfg {
249 uint8_t pool_options;
252 uint8_t priority_mask;
253 uint16_t buffer_size;
255 } pools[DPNI_MAX_DPBP];
258 int dpni_set_pools(struct fsl_mc_io *mc_io,
261 const struct dpni_pools_cfg *cfg);
263 int dpni_enable(struct fsl_mc_io *mc_io,
267 int dpni_disable(struct fsl_mc_io *mc_io,
271 int dpni_is_enabled(struct fsl_mc_io *mc_io,
276 int dpni_reset(struct fsl_mc_io *mc_io,
281 * DPNI IRQ Index and Events
287 #define DPNI_IRQ_INDEX 0
289 * IRQ event - indicates a change in link state
291 #define DPNI_IRQ_EVENT_LINK_CHANGED 0x00000001
293 int dpni_set_irq_enable(struct fsl_mc_io *mc_io,
299 int dpni_get_irq_enable(struct fsl_mc_io *mc_io,
305 int dpni_set_irq_mask(struct fsl_mc_io *mc_io,
311 int dpni_get_irq_mask(struct fsl_mc_io *mc_io,
317 int dpni_get_irq_status(struct fsl_mc_io *mc_io,
323 int dpni_clear_irq_status(struct fsl_mc_io *mc_io,
330 * struct dpni_attr - Structure representing DPNI attributes
331 * @options: Any combination of the following options:
332 * DPNI_OPT_TX_FRM_RELEASE
333 * DPNI_OPT_NO_MAC_FILTER
334 * DPNI_OPT_HAS_POLICING
335 * DPNI_OPT_SHARED_CONGESTION
336 * DPNI_OPT_HAS_KEY_MASKING
338 * @num_queues: Number of Tx and Rx queues used for traffic distribution.
339 * @num_rx_tcs: Number of RX traffic classes (TCs), reserved for the DPNI.
340 * @num_tx_tcs: Number of TX traffic classes (TCs), reserved for the DPNI.
341 * @mac_filter_entries: Number of entries in the MAC address filtering
343 * @vlan_filter_entries: Number of entries in the VLAN address filtering
345 * @qos_entries: Number of entries in the QoS classification table.
346 * @fs_entries: Number of entries in the flow steering table.
347 * @qos_key_size: Size, in bytes, of the QoS look-up key. Defining a key larger
348 * than this when adding QoS entries will result
350 * @fs_key_size: Size, in bytes, of the flow steering look-up key. Defining a
351 * key larger than this when composing the hash + FS key
352 * will result in an error.
353 * @wriop_version: Version of WRIOP HW block.
354 * The 3 version values are stored on 6, 5, 5 bits
357 * - 0x400 - WRIOP version 1.0.0, used on LS2080 and
359 * - 0x421 - WRIOP version 1.1.1, used on LS2088 and
361 * - 0x422 - WRIOP version 1.1.2, used on LS1088 and
363 * - 0xC00 - WRIOP version 3.0.0, used on LX2160 and
371 uint8_t mac_filter_entries;
372 uint8_t vlan_filter_entries;
375 uint8_t qos_key_size;
377 uint16_t wriop_version;
379 uint8_t num_channels;
382 int dpni_get_attributes(struct fsl_mc_io *mc_io,
385 struct dpni_attr *attr);
392 * Discard error. When set all discarded frames in wriop will be enqueued to
393 * error queue. To be used in dpni_set_errors_behavior() only if error_action
394 * parameter is set to DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE.
396 #define DPNI_ERROR_DISC 0x80000000
399 * Extract out of frame header error
401 #define DPNI_ERROR_MS 0x40000000
402 #define DPNI_ERROR_PTP 0x08000000
403 /* Ethernet multicast frame */
404 #define DPNI_ERROR_MC 0x04000000
405 /* Ethernet broadcast frame */
406 #define DPNI_ERROR_BC 0x02000000
407 #define DPNI_ERROR_KSE 0x00040000
408 #define DPNI_ERROR_EOFHE 0x00020000
409 #define DPNI_ERROR_MNLE 0x00010000
410 #define DPNI_ERROR_TIDE 0x00008000
411 #define DPNI_ERROR_PIEE 0x00004000
415 #define DPNI_ERROR_FLE 0x00002000
417 * Frame physical error
419 #define DPNI_ERROR_FPE 0x00001000
420 #define DPNI_ERROR_PTE 0x00000080
421 #define DPNI_ERROR_ISP 0x00000040
423 * Parsing header error
425 #define DPNI_ERROR_PHE 0x00000020
427 #define DPNI_ERROR_BLE 0x00000010
429 * Parser L3 checksum error
431 #define DPNI_ERROR_L3CV 0x00000008
433 #define DPNI_ERROR_L3CE 0x00000004
435 * Parser L4 checksum error
437 #define DPNI_ERROR_L4CV 0x00000002
439 #define DPNI_ERROR_L4CE 0x00000001
441 * enum dpni_error_action - Defines DPNI behavior for errors
442 * @DPNI_ERROR_ACTION_DISCARD: Discard the frame
443 * @DPNI_ERROR_ACTION_CONTINUE: Continue with the normal flow
444 * @DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE: Send the frame to the error queue
446 enum dpni_error_action {
447 DPNI_ERROR_ACTION_DISCARD = 0,
448 DPNI_ERROR_ACTION_CONTINUE = 1,
449 DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE = 2
453 * struct dpni_error_cfg - Structure representing DPNI errors treatment
454 * @errors: Errors mask; use 'DPNI_ERROR__<X>
455 * @error_action: The desired action for the errors mask
456 * @set_frame_annotation: Set to '1' to mark the errors in frame
457 * annotation status (FAS); relevant only
458 * for the non-discard action
460 struct dpni_error_cfg {
462 enum dpni_error_action error_action;
463 int set_frame_annotation;
466 int dpni_set_errors_behavior(struct fsl_mc_io *mc_io,
469 struct dpni_error_cfg *cfg);
472 * DPNI buffer layout modification options
476 * Select to modify the time-stamp setting
478 #define DPNI_BUF_LAYOUT_OPT_TIMESTAMP 0x00000001
480 * Select to modify the parser-result setting; not applicable for Tx
482 #define DPNI_BUF_LAYOUT_OPT_PARSER_RESULT 0x00000002
484 * Select to modify the frame-status setting
486 #define DPNI_BUF_LAYOUT_OPT_FRAME_STATUS 0x00000004
488 * Select to modify the private-data-size setting
490 #define DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE 0x00000008
492 * Select to modify the data-alignment setting
494 #define DPNI_BUF_LAYOUT_OPT_DATA_ALIGN 0x00000010
496 * Select to modify the data-head-room setting
498 #define DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM 0x00000020
500 * Select to modify the data-tail-room setting
502 #define DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM 0x00000040
504 * Select to modify the sw-opaque value setting
506 #define DPNI_BUF_LAYOUT_OPT_SW_OPAQUE 0x00000080
508 * Select to disable Scatter Gather and use single buffer
510 #define DPNI_BUF_LAYOUT_OPT_NO_SG 0x00000100
513 * struct dpni_buffer_layout - Structure representing DPNI buffer layout
514 * @options: Flags representing the suggested modifications to the
516 * Use any combination of 'DPNI_BUF_LAYOUT_OPT_<X>' flags
517 * @pass_timestamp: Pass timestamp value
518 * @pass_parser_result: Pass parser results
519 * @pass_frame_status: Pass frame status
520 * @private_data_size: Size kept for private data (in bytes)
521 * @data_align: Data alignment
522 * @data_head_room: Data head room
523 * @data_tail_room: Data tail room
525 struct dpni_buffer_layout {
528 int pass_parser_result;
529 int pass_frame_status;
531 uint16_t private_data_size;
533 uint16_t data_head_room;
534 uint16_t data_tail_room;
538 * enum dpni_queue_type - Identifies a type of queue targeted by the command
539 * @DPNI_QUEUE_RX: Rx queue
540 * @DPNI_QUEUE_TX: Tx queue
541 * @DPNI_QUEUE_TX_CONFIRM: Tx confirmation queue
542 * @DPNI_QUEUE_RX_ERR: Rx error queue
544 enum dpni_queue_type {
547 DPNI_QUEUE_TX_CONFIRM,
551 int dpni_get_buffer_layout(struct fsl_mc_io *mc_io,
554 enum dpni_queue_type qtype,
555 struct dpni_buffer_layout *layout);
557 int dpni_set_buffer_layout(struct fsl_mc_io *mc_io,
560 enum dpni_queue_type qtype,
561 const struct dpni_buffer_layout *layout);
564 * enum dpni_offload - Identifies a type of offload targeted by the command
565 * @DPNI_OFF_RX_L3_CSUM: Rx L3 checksum validation
566 * @DPNI_OFF_RX_L4_CSUM: Rx L4 checksum validation
567 * @DPNI_OFF_TX_L3_CSUM: Tx L3 checksum generation
568 * @DPNI_OFF_TX_L4_CSUM: Tx L4 checksum generation
569 * @DPNI_OPT_FLCTYPE_HASH: flow context will be generated by WRIOP for AIOP or
580 int dpni_set_offload(struct fsl_mc_io *mc_io,
583 enum dpni_offload type,
586 int dpni_get_offload(struct fsl_mc_io *mc_io,
589 enum dpni_offload type,
592 int dpni_get_qdid(struct fsl_mc_io *mc_io,
595 enum dpni_queue_type qtype,
598 int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io,
601 uint16_t *data_offset);
603 #define DPNI_STATISTICS_CNT 7
606 * union dpni_statistics - Union describing the DPNI statistics
607 * @page_0: Page_0 statistics structure
608 * @page_0.ingress_all_frames: Ingress frame count
609 * @page_0.ingress_all_bytes: Ingress byte count
610 * @page_0.ingress_multicast_frames: Ingress multicast frame count
611 * @page_0.ingress_multicast_bytes: Ingress multicast byte count
612 * @page_0.ingress_broadcast_frames: Ingress broadcast frame count
613 * @page_0.ingress_broadcast_bytes: Ingress broadcast byte count
614 * @page_1: Page_1 statistics structure
615 * @page_1.egress_all_frames: Egress frame count
616 * @page_1.egress_all_bytes: Egress byte count
617 * @page_1.egress_multicast_frames: Egress multicast frame count
618 * @page_1.egress_multicast_bytes: Egress multicast byte count
619 * @page_1.egress_broadcast_frames: Egress broadcast frame count
620 * @page_1.egress_broadcast_bytes: Egress broadcast byte count
621 * @page_2: Page_2 statistics structure
622 * @page_2.ingress_filtered_frames: Ingress filtered frame count
623 * @page_2.ingress_discarded_frames: Ingress discarded frame count
624 * @page_2.ingress_nobuffer_discards: Ingress discarded frame count due to
626 * @page_2.egress_discarded_frames: Egress discarded frame count
627 * @page_2.egress_confirmed_frames: Egress confirmed frame count
628 * @page_3: Page_3 statistics structure with values for the selected TC
629 * @page_3.ceetm_dequeue_bytes: Cumulative count of the number of bytes dequeued
630 * @page_3.ceetm_dequeue_frames: Cumulative count of the number of frames
632 * @page_3.ceetm_reject_bytes: Cumulative count of the number of bytes in all
633 * frames whose enqueue was rejected
634 * @page_3.ceetm_reject_frames: Cumulative count of all frame enqueues rejected
635 * @page_4: congestion point drops for selected TC
636 * @page_4.cgr_reject_frames: number of rejected frames due to congestion point
637 * @page_4.cgr_reject_bytes: number of rejected bytes due to congestion point
638 * @page_5: policer statistics per TC
639 * @page_5.policer_cnt_red: NUmber of red colored frames
640 * @page_5.policer_cnt_yellow: number of yellow colored frames
641 * @page_5.policer_cnt_green: number of green colored frames
642 * @page_5.policer_cnt_re_red: number of recolored red frames
643 * @page_5.policer_cnt_re_yellow: number of recolored yellow frames
644 * @page_6.tx_pending_frames_cnt: total number of frames pending in Tx queues
645 * @raw: raw statistics structure, used to index counters
647 union dpni_statistics {
649 uint64_t ingress_all_frames;
650 uint64_t ingress_all_bytes;
651 uint64_t ingress_multicast_frames;
652 uint64_t ingress_multicast_bytes;
653 uint64_t ingress_broadcast_frames;
654 uint64_t ingress_broadcast_bytes;
657 uint64_t egress_all_frames;
658 uint64_t egress_all_bytes;
659 uint64_t egress_multicast_frames;
660 uint64_t egress_multicast_bytes;
661 uint64_t egress_broadcast_frames;
662 uint64_t egress_broadcast_bytes;
665 uint64_t ingress_filtered_frames;
666 uint64_t ingress_discarded_frames;
667 uint64_t ingress_nobuffer_discards;
668 uint64_t egress_discarded_frames;
669 uint64_t egress_confirmed_frames;
672 uint64_t ceetm_dequeue_bytes;
673 uint64_t ceetm_dequeue_frames;
674 uint64_t ceetm_reject_bytes;
675 uint64_t ceetm_reject_frames;
678 uint64_t cgr_reject_frames;
679 uint64_t cgr_reject_bytes;
682 uint64_t policer_cnt_red;
683 uint64_t policer_cnt_yellow;
684 uint64_t policer_cnt_green;
685 uint64_t policer_cnt_re_red;
686 uint64_t policer_cnt_re_yellow;
689 uint64_t tx_pending_frames_cnt;
692 uint64_t counter[DPNI_STATISTICS_CNT];
697 * Enable auto-negotiation
699 #define DPNI_LINK_OPT_AUTONEG 0x0000000000000001ULL
701 * Enable half-duplex mode
703 #define DPNI_LINK_OPT_HALF_DUPLEX 0x0000000000000002ULL
705 * Enable pause frames
707 #define DPNI_LINK_OPT_PAUSE 0x0000000000000004ULL
709 * Enable a-symmetric pause frames
711 #define DPNI_LINK_OPT_ASYM_PAUSE 0x0000000000000008ULL
713 * Enable priority flow control pause frames
715 #define DPNI_LINK_OPT_PFC_PAUSE 0x0000000000000010ULL
718 * Advertise 10MB full duplex
720 #define DPNI_ADVERTISED_10BASET_FULL 0x0000000000000001ULL
722 * Advertise 100MB full duplex
724 #define DPNI_ADVERTISED_100BASET_FULL 0x0000000000000002ULL
726 * Advertise 1GB full duplex
728 #define DPNI_ADVERTISED_1000BASET_FULL 0x0000000000000004ULL
730 * Advertise auto-negotiation enable
732 #define DPNI_ADVERTISED_AUTONEG 0x0000000000000008ULL
734 * Advertise 10GB full duplex
736 #define DPNI_ADVERTISED_10000BASET_FULL 0x0000000000000010ULL
738 * Advertise 2.5GB full duplex
740 #define DPNI_ADVERTISED_2500BASEX_FULL 0x0000000000000020ULL
742 * Advertise 5GB full duplex
744 #define DPNI_ADVERTISED_5000BASET_FULL 0x0000000000000040ULL
748 * struct - Structure representing DPNI link configuration
750 * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
751 * @advertising: Speeds that are advertised for autoneg (bitmap)
753 struct dpni_link_cfg {
756 uint64_t advertising;
759 int dpni_set_link_cfg(struct fsl_mc_io *mc_io,
762 const struct dpni_link_cfg *cfg);
765 * struct dpni_link_state - Structure representing DPNI link state
767 * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
768 * @up: Link state; '0' for down, '1' for up
769 * @state_valid: Ignore/Update the state of the link
770 * @supported: Speeds capability of the phy (bitmap)
771 * @advertising: Speeds that are advertised for autoneg (bitmap)
773 struct dpni_link_state {
779 uint64_t advertising;
782 int dpni_get_link_state(struct fsl_mc_io *mc_io,
785 struct dpni_link_state *state);
788 * struct dpni_tx_shaping - Structure representing DPNI tx shaping configuration
789 * @rate_limit: Rate in Mbits/s
790 * @max_burst_size: Burst size in bytes (up to 64KB)
792 struct dpni_tx_shaping_cfg {
794 uint16_t max_burst_size;
798 * Build the parameter for dpni_set_tx_shaping() call
799 * @oal: Overhead accounting length. 11bit value added to the size of
800 * each frame. Used only for LNI shaping. If set to zero, will use default
801 * value of 24. Ignored if shaping_lni is set to zero.
802 * @shaping_lni: 1 for LNI shaping (configure whole throughput of the dpni object)
803 * 0 for channel shaping (configure shaping for individual channels)
804 * Set to one only if dpni is connected to a dpmac object.
805 * @channel_id: Channel to be configured. Ignored shaping_lni is set to 1
806 * @coupled: Committed and excess rates are coupled
808 #define DPNI_TX_SHAPING_PARAM(oal, shaping_lni, channel_id, coupled) ( \
809 ((uint32_t)(((oal) & 0x7ff) << 16)) | \
810 ((uint32_t)((channel_id) & 0xff) << 8) | \
811 ((uint32_t)(!!shaping_lni) << 1) | \
812 ((uint32_t)!!coupled))
814 int dpni_set_tx_shaping(struct fsl_mc_io *mc_io,
817 const struct dpni_tx_shaping_cfg *tx_cr_shaper,
818 const struct dpni_tx_shaping_cfg *tx_er_shaper,
821 int dpni_set_max_frame_length(struct fsl_mc_io *mc_io,
824 uint16_t max_frame_length);
826 int dpni_get_max_frame_length(struct fsl_mc_io *mc_io,
829 uint16_t *max_frame_length);
831 int dpni_set_mtu(struct fsl_mc_io *mc_io,
836 int dpni_get_mtu(struct fsl_mc_io *mc_io,
841 int dpni_set_multicast_promisc(struct fsl_mc_io *mc_io,
846 int dpni_get_multicast_promisc(struct fsl_mc_io *mc_io,
851 int dpni_set_unicast_promisc(struct fsl_mc_io *mc_io,
856 int dpni_get_unicast_promisc(struct fsl_mc_io *mc_io,
861 int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
864 const uint8_t mac_addr[6]);
866 int dpni_get_primary_mac_addr(struct fsl_mc_io *mc_io,
869 uint8_t mac_addr[6]);
872 * Set mac addr queue action
874 #define DPNI_MAC_SET_QUEUE_ACTION 1
876 int dpni_add_mac_addr(struct fsl_mc_io *mc_io,
879 const uint8_t mac_addr[6],
884 int dpni_remove_mac_addr(struct fsl_mc_io *mc_io,
887 const uint8_t mac_addr[6]);
889 int dpni_clear_mac_filters(struct fsl_mc_io *mc_io,
895 int dpni_get_port_mac_addr(struct fsl_mc_io *mc_io,
898 uint8_t mac_addr[6]);
900 int dpni_enable_vlan_filter(struct fsl_mc_io *mc_io,
906 * Set vlan filter queue action
908 #define DPNI_VLAN_SET_QUEUE_ACTION 1
910 int dpni_add_vlan_id(struct fsl_mc_io *mc_io,
918 int dpni_remove_vlan_id(struct fsl_mc_io *mc_io,
923 int dpni_clear_vlan_filters(struct fsl_mc_io *mc_io,
928 * enum dpni_tx_schedule_mode - DPNI Tx scheduling mode
929 * @DPNI_TX_SCHED_STRICT_PRIORITY: strict priority
930 * @DPNI_TX_SCHED_WEIGHTED_A: weighted based scheduling in group A
931 * @DPNI_TX_SCHED_WEIGHTED_B: weighted based scheduling in group B
933 enum dpni_tx_schedule_mode {
934 DPNI_TX_SCHED_STRICT_PRIORITY = 0,
935 DPNI_TX_SCHED_WEIGHTED_A,
936 DPNI_TX_SCHED_WEIGHTED_B,
940 * struct dpni_tx_schedule_cfg - Structure representing Tx scheduling conf
941 * @mode: Scheduling mode
942 * @delta_bandwidth: Bandwidth represented in weights from 100 to 10000;
943 * not applicable for 'strict-priority' mode;
945 struct dpni_tx_schedule_cfg {
946 enum dpni_tx_schedule_mode mode;
947 uint16_t delta_bandwidth;
951 * struct dpni_tx_priorities_cfg - Structure representing transmission
952 * priorities for DPNI TCs
953 * @channel_idx: channel to perform the configuration
954 * @tc_sched: An array of traffic-classes
955 * @prio_group_A: Priority of group A
956 * @prio_group_B: Priority of group B
957 * @separate_groups: Treat A and B groups as separate
959 struct dpni_tx_priorities_cfg {
961 struct dpni_tx_schedule_cfg tc_sched[DPNI_MAX_TC];
962 uint32_t prio_group_A;
963 uint32_t prio_group_B;
964 uint8_t separate_groups;
967 int dpni_set_tx_priorities(struct fsl_mc_io *mc_io,
970 const struct dpni_tx_priorities_cfg *cfg);
973 * enum dpni_dist_mode - DPNI distribution mode
974 * @DPNI_DIST_MODE_NONE: No distribution
975 * @DPNI_DIST_MODE_HASH: Use hash distribution; only relevant if
976 * the 'DPNI_OPT_DIST_HASH' option was set at DPNI creation
977 * @DPNI_DIST_MODE_FS: Use explicit flow steering; only relevant if
978 * the 'DPNI_OPT_DIST_FS' option was set at DPNI creation
980 enum dpni_dist_mode {
981 DPNI_DIST_MODE_NONE = 0,
982 DPNI_DIST_MODE_HASH = 1,
983 DPNI_DIST_MODE_FS = 2
987 * enum dpni_fs_miss_action - DPNI Flow Steering miss action
988 * @DPNI_FS_MISS_DROP: In case of no-match, drop the frame
989 * @DPNI_FS_MISS_EXPLICIT_FLOWID: In case of no-match, use explicit flow-id
990 * @DPNI_FS_MISS_HASH: In case of no-match, distribute using hash
992 enum dpni_fs_miss_action {
993 DPNI_FS_MISS_DROP = 0,
994 DPNI_FS_MISS_EXPLICIT_FLOWID = 1,
995 DPNI_FS_MISS_HASH = 2
999 * struct dpni_fs_tbl_cfg - Flow Steering table configuration
1000 * @miss_action: Miss action selection
1001 * @default_flow_id: Used when 'miss_action = DPNI_FS_MISS_EXPLICIT_FLOWID'
1002 * @keep_hash_key: used only when miss_action is set to DPNI_FS_MISS_HASH. When
1003 * set to one unclassified frames will be distributed according to previous
1004 * used hash key. If set to zero hash key will be replaced with the key
1005 * provided for flow steering.
1006 * @keep_entries: if set to one command will not delete the entries that already
1007 * exist into FS table. Use this option with caution: if the table
1008 * entries are not compatible with the distribution key the packets
1009 * will not be classified properly.
1011 struct dpni_fs_tbl_cfg {
1012 enum dpni_fs_miss_action miss_action;
1013 uint16_t default_flow_id;
1015 uint8_t keep_entries;
1019 * struct dpni_rx_tc_dist_cfg - Rx traffic class distribution configuration
1020 * @dist_size: Set the distribution size;
1021 * supported values: 1,2,3,4,6,7,8,12,14,16,24,28,32,48,56,64,96,
1022 * 112,128,192,224,256,384,448,512,768,896,1024
1023 * @dist_mode: Distribution mode
1024 * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
1025 * the extractions to be used for the distribution key by calling
1026 * dpkg_prepare_key_cfg() relevant only when
1027 * 'dist_mode != DPNI_DIST_MODE_NONE', otherwise it can be '0'
1028 * @fs_cfg: Flow Steering table configuration; only relevant if
1029 * 'dist_mode = DPNI_DIST_MODE_FS'
1031 struct dpni_rx_tc_dist_cfg {
1033 enum dpni_dist_mode dist_mode;
1034 uint64_t key_cfg_iova;
1035 struct dpni_fs_tbl_cfg fs_cfg;
1038 int dpni_set_rx_tc_dist(struct fsl_mc_io *mc_io,
1042 const struct dpni_rx_tc_dist_cfg *cfg);
1045 * Set to select color aware mode (otherwise - color blind)
1047 #define DPNI_POLICER_OPT_COLOR_AWARE 0x00000001
1049 * Set to discard frame with RED color
1051 #define DPNI_POLICER_OPT_DISCARD_RED 0x00000002
1054 * enum dpni_policer_mode - selecting the policer mode
1055 * @DPNI_POLICER_MODE_NONE: Policer is disabled
1056 * @DPNI_POLICER_MODE_PASS_THROUGH: Policer pass through
1057 * @DPNI_POLICER_MODE_RFC_2698: Policer algorithm RFC 2698
1058 * @DPNI_POLICER_MODE_RFC_4115: Policer algorithm RFC 4115
1060 enum dpni_policer_mode {
1061 DPNI_POLICER_MODE_NONE = 0,
1062 DPNI_POLICER_MODE_PASS_THROUGH,
1063 DPNI_POLICER_MODE_RFC_2698,
1064 DPNI_POLICER_MODE_RFC_4115
1068 * enum dpni_policer_unit - DPNI policer units
1069 * @DPNI_POLICER_UNIT_BYTES: bytes units
1070 * @DPNI_POLICER_UNIT_FRAMES: frames units
1072 enum dpni_policer_unit {
1073 DPNI_POLICER_UNIT_BYTES = 0,
1074 DPNI_POLICER_UNIT_FRAMES
1078 * enum dpni_policer_color - selecting the policer color
1079 * @DPNI_POLICER_COLOR_GREEN: Green color
1080 * @DPNI_POLICER_COLOR_YELLOW: Yellow color
1081 * @DPNI_POLICER_COLOR_RED: Red color
1083 enum dpni_policer_color {
1084 DPNI_POLICER_COLOR_GREEN = 0,
1085 DPNI_POLICER_COLOR_YELLOW,
1086 DPNI_POLICER_COLOR_RED
1090 * struct dpni_rx_tc_policing_cfg - Policer configuration
1091 * @options: Mask of available options; use 'DPNI_POLICER_OPT_<X>' values
1092 * @mode: policer mode
1093 * @default_color: For pass-through mode the policer re-colors with this
1094 * color any incoming packets. For Color aware non-pass-through mode:
1095 * policer re-colors with this color all packets with FD[DROPP]>2.
1096 * @units: Bytes or Packets
1097 * @cir: Committed information rate (CIR) in Kbps or packets/second
1098 * @cbs: Committed burst size (CBS) in bytes or packets
1099 * @eir: Peak information rate (PIR, rfc2698) in Kbps or packets/second
1100 * Excess information rate (EIR, rfc4115) in Kbps or packets/second
1101 * @ebs: Peak burst size (PBS, rfc2698) in bytes or packets
1102 * Excess burst size (EBS, rfc4115) in bytes or packets
1104 struct dpni_rx_tc_policing_cfg {
1106 enum dpni_policer_mode mode;
1107 enum dpni_policer_unit units;
1108 enum dpni_policer_color default_color;
1116 int dpni_set_rx_tc_policing(struct fsl_mc_io *mc_io,
1120 const struct dpni_rx_tc_policing_cfg *cfg);
1122 int dpni_get_rx_tc_policing(struct fsl_mc_io *mc_io,
1126 struct dpni_rx_tc_policing_cfg *cfg);
1129 * enum dpni_congestion_unit - DPNI congestion units
1130 * @DPNI_CONGESTION_UNIT_BYTES: bytes units
1131 * @DPNI_CONGESTION_UNIT_FRAMES: frames units
1133 enum dpni_congestion_unit {
1134 DPNI_CONGESTION_UNIT_BYTES = 0,
1135 DPNI_CONGESTION_UNIT_FRAMES
1139 * enum dpni_early_drop_mode - DPNI early drop mode
1140 * @DPNI_EARLY_DROP_MODE_NONE: early drop is disabled
1141 * @DPNI_EARLY_DROP_MODE_TAIL: early drop in taildrop mode
1142 * @DPNI_EARLY_DROP_MODE_WRED: early drop in WRED mode
1144 enum dpni_early_drop_mode {
1145 DPNI_EARLY_DROP_MODE_NONE = 0,
1146 DPNI_EARLY_DROP_MODE_TAIL,
1147 DPNI_EARLY_DROP_MODE_WRED
1151 * struct dpni_wred_cfg - WRED configuration
1152 * @max_threshold: maximum threshold that packets may be discarded. Above this
1153 * threshold all packets are discarded; must be less than 2^39;
1154 * approximated to be expressed as (x+256)*2^(y-1) due to HW
1156 * @min_threshold: minimum threshold that packets may be discarded at
1157 * @drop_probability: probability that a packet will be discarded (1-100,
1158 * associated with the max_threshold).
1160 struct dpni_wred_cfg {
1161 uint64_t max_threshold;
1162 uint64_t min_threshold;
1163 uint8_t drop_probability;
1167 * struct dpni_early_drop_cfg - early-drop configuration
1168 * @enable: drop enable
1169 * @units: units type
1170 * @green: WRED - 'green' configuration
1171 * @yellow: WRED - 'yellow' configuration
1172 * @red: WRED - 'red' configuration
1174 struct dpni_early_drop_cfg {
1176 enum dpni_congestion_unit units;
1177 struct dpni_wred_cfg green;
1178 struct dpni_wred_cfg yellow;
1179 struct dpni_wred_cfg red;
1182 void dpni_prepare_early_drop(const struct dpni_early_drop_cfg *cfg,
1183 uint8_t *early_drop_buf);
1185 void dpni_extract_early_drop(struct dpni_early_drop_cfg *cfg,
1186 const uint8_t *early_drop_buf);
1188 int dpni_set_early_drop(struct fsl_mc_io *mc_io,
1191 enum dpni_queue_type qtype,
1193 uint64_t early_drop_iova);
1195 int dpni_get_early_drop(struct fsl_mc_io *mc_io,
1198 enum dpni_queue_type qtype,
1200 uint64_t early_drop_iova);
1203 * enum dpni_dest - DPNI destination types
1204 * @DPNI_DEST_NONE: Unassigned destination; The queue is set in parked mode and
1205 * does not generate FQDAN notifications; user is expected to
1206 * dequeue from the queue based on polling or other user-defined
1208 * @DPNI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
1209 * notifications to the specified DPIO; user is expected to dequeue
1210 * from the queue only after notification is received
1211 * @DPNI_DEST_DPCON: The queue is set in schedule mode and does not generate
1212 * FQDAN notifications, but is connected to the specified DPCON
1213 * object; user is expected to dequeue from the DPCON channel
1222 * struct dpni_dest_cfg - Structure representing DPNI destination parameters
1223 * @dest_type: Destination type
1224 * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
1225 * @priority: Priority selection within the DPIO or DPCON channel; valid values
1226 * are 0-1 or 0-7, depending on the number of priorities in that
1227 * channel; not relevant for 'DPNI_DEST_NONE' option
1229 struct dpni_dest_cfg {
1230 enum dpni_dest dest_type;
1235 /* DPNI congestion options */
1238 * CSCN message is written to message_iova once entering a
1239 * congestion state (see 'threshold_entry')
1241 #define DPNI_CONG_OPT_WRITE_MEM_ON_ENTER 0x00000001
1243 * CSCN message is written to message_iova once exiting a
1244 * congestion state (see 'threshold_exit')
1246 #define DPNI_CONG_OPT_WRITE_MEM_ON_EXIT 0x00000002
1248 * CSCN write will attempt to allocate into a cache (coherent write);
1249 * valid only if 'DPNI_CONG_OPT_WRITE_MEM_<X>' is selected
1251 #define DPNI_CONG_OPT_COHERENT_WRITE 0x00000004
1253 * if 'dest_cfg.dest_type != DPNI_DEST_NONE' CSCN message is sent to
1254 * DPIO/DPCON's WQ channel once entering a congestion state
1255 * (see 'threshold_entry')
1257 #define DPNI_CONG_OPT_NOTIFY_DEST_ON_ENTER 0x00000008
1259 * if 'dest_cfg.dest_type != DPNI_DEST_NONE' CSCN message is sent to
1260 * DPIO/DPCON's WQ channel once exiting a congestion state
1261 * (see 'threshold_exit')
1263 #define DPNI_CONG_OPT_NOTIFY_DEST_ON_EXIT 0x00000010
1265 * if 'dest_cfg.dest_type != DPNI_DEST_NONE' when the CSCN is written to the
1266 * sw-portal's DQRR, the DQRI interrupt is asserted immediately (if enabled)
1268 #define DPNI_CONG_OPT_INTR_COALESCING_DISABLED 0x00000020
1270 * This congestion will trigger flow control or priority flow control. This
1271 * will have effect only if flow control is enabled with dpni_set_link_cfg()
1273 #define DPNI_CONG_OPT_FLOW_CONTROL 0x00000040
1276 * enum dpni_congestion_point - Structure representing congestion point
1277 * @DPNI_CP_QUEUE: Set congestion per queue, identified by QUEUE_TYPE, TC
1279 * @DPNI_CP_GROUP: Set congestion per queue group. Depending on options
1280 * used to define the DPNI this can be either per
1281 * TC (default) or per interface
1282 * (DPNI_OPT_SHARED_CONGESTION set at DPNI create).
1283 * QUEUE_INDEX is ignored if this type is used.
1284 * @DPNI_CP_CONGESTION_GROUP: Set per congestion group id. This will work
1285 * only if the DPNI is created with DPNI_OPT_CUSTOM_CG option
1288 enum dpni_congestion_point {
1291 DPNI_CP_CONGESTION_GROUP,
1295 * struct dpni_congestion_notification_cfg - congestion notification
1297 * @units: units type
1298 * @threshold_entry: above this threshold we enter a congestion state.
1299 * set it to '0' to disable it
1300 * @threshold_exit: below this threshold we exit the congestion state.
1301 * @message_ctx: The context that will be part of the CSCN message
1302 * @message_iova: I/O virtual address (must be in DMA-able memory),
1303 * must be 16B aligned; valid only if 'DPNI_CONG_OPT_WRITE_MEM_<X>' is
1304 * contained in 'options'
1305 * @dest_cfg: CSCN can be send to either DPIO or DPCON WQ channel
1306 * @notification_mode: Mask of available options; use 'DPNI_CONG_OPT_<X>' values
1307 * @cg_point: Congestion point settings
1308 * @cgid: id of the congestion group. The index is relative to dpni.
1311 struct dpni_congestion_notification_cfg {
1312 enum dpni_congestion_unit units;
1313 uint32_t threshold_entry;
1314 uint32_t threshold_exit;
1315 uint64_t message_ctx;
1316 uint64_t message_iova;
1317 struct dpni_dest_cfg dest_cfg;
1318 uint16_t notification_mode;
1319 enum dpni_congestion_point cg_point;
1323 int dpni_set_congestion_notification(struct fsl_mc_io *mc_io,
1326 enum dpni_queue_type qtype,
1328 const struct dpni_congestion_notification_cfg *cfg);
1330 int dpni_get_congestion_notification(struct fsl_mc_io *mc_io,
1333 enum dpni_queue_type qtype,
1335 struct dpni_congestion_notification_cfg *cfg);
1337 /* DPNI FLC stash options */
1340 * stashes the whole annotation area (up to 192 bytes)
1342 #define DPNI_FLC_STASH_FRAME_ANNOTATION 0x00000001
1345 * struct dpni_queue - Queue structure
1346 * @destination - Destination structure
1347 * @destination.id: ID of the destination, only relevant if DEST_TYPE is > 0.
1348 * Identifies either a DPIO or a DPCON object.
1349 * Not relevant for Tx queues.
1350 * @destination.type: May be one of the following:
1351 * 0 - No destination, queue can be manually
1352 * queried, but will not push traffic or
1353 * notifications to a DPIO;
1354 * 1 - The destination is a DPIO. When traffic
1355 * becomes available in the queue a FQDAN
1356 * (FQ data available notification) will be
1357 * generated to selected DPIO;
1358 * 2 - The destination is a DPCON. The queue is
1359 * associated with a DPCON object for the
1360 * purpose of scheduling between multiple
1361 * queues. The DPCON may be independently
1362 * configured to generate notifications.
1363 * Not relevant for Tx queues.
1364 * @destination.hold_active: Hold active, maintains a queue scheduled for longer
1365 * in a DPIO during dequeue to reduce spread of traffic.
1366 * Only relevant if queues are
1367 * not affined to a single DPIO.
1368 * @user_context: User data, presented to the user along with any frames
1369 * from this queue. Not relevant for Tx queues.
1370 * @flc: FD FLow Context structure
1371 * @flc.value: Default FLC value for traffic dequeued from
1372 * this queue. Please check description of FD
1373 * structure for more information.
1374 * Note that FLC values set using dpni_add_fs_entry,
1375 * if any, take precedence over values per queue.
1376 * @flc.stash_control: Boolean, indicates whether the 6 lowest
1377 * - significant bits are used for stash control.
1378 * significant bits are used for stash control. If set, the 6
1379 * least significant bits in value are interpreted as follows:
1380 * - bits 0-1: indicates the number of 64 byte units of context
1381 * that are stashed. FLC value is interpreted as a memory address
1382 * in this case, excluding the 6 LS bits.
1383 * - bits 2-3: indicates the number of 64 byte units of frame
1384 * annotation to be stashed. Annotation is placed at FD[ADDR].
1385 * - bits 4-5: indicates the number of 64 byte units of frame
1386 * data to be stashed. Frame data is placed at FD[ADDR] +
1388 * For more details check the Frame Descriptor section in the
1389 * hardware documentation.
1390 *@cgid :indicate the cgid to set relative to dpni
1395 enum dpni_dest type;
1399 uint64_t user_context;
1408 * struct dpni_queue_id - Queue identification, used for enqueue commands
1410 * @fqid: FQID used for enqueueing to and/or configuration of this
1412 * @qdbin: Queueing bin, used to enqueue using QDID, DQBIN, QPRI.
1413 * Only relevant for Tx queues.
1415 struct dpni_queue_id {
1421 * enum dpni_confirmation_mode - Defines DPNI options supported for Tx
1423 * @DPNI_CONF_AFFINE: For each Tx queue set associated with a sender there is
1424 * an affine Tx Confirmation queue
1425 * @DPNI_CONF_SINGLE: All Tx queues are associated with a single Tx
1426 * confirmation queue
1427 * @DPNI_CONF_DISABLE: Tx frames are not confirmed. This must be associated
1428 * with proper FD set-up to have buffers release to a Buffer Pool, otherwise
1429 * buffers will be leaked
1431 enum dpni_confirmation_mode {
1437 int dpni_set_tx_confirmation_mode(struct fsl_mc_io *mc_io,
1440 enum dpni_confirmation_mode mode);
1442 int dpni_get_tx_confirmation_mode(struct fsl_mc_io *mc_io,
1445 enum dpni_confirmation_mode *mode);
1448 * struct dpni_qos_tbl_cfg - Structure representing QOS table configuration
1449 * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
1450 * key extractions to be used as the QoS criteria by calling
1451 * dpkg_prepare_key_cfg()
1452 * @discard_on_miss: Set to '1' to discard frames in case of no match (miss);
1453 * '0' to use the 'default_tc' in such cases
1454 * @keep_entries: if set to one will not delete existing table entries. This
1455 * option will work properly only for dpni objects created with
1456 * DPNI_OPT_HAS_KEY_MASKING option. All previous QoS entries must
1457 * be compatible with new key composition rule.
1458 * It is the caller's job to delete incompatible entries before
1459 * executing this function.
1460 * @default_tc: Used in case of no-match and 'discard_on_miss'= 0
1462 struct dpni_qos_tbl_cfg {
1463 uint64_t key_cfg_iova;
1464 int discard_on_miss;
1469 int dpni_set_qos_table(struct fsl_mc_io *mc_io,
1472 const struct dpni_qos_tbl_cfg *cfg);
1475 * struct dpni_rule_cfg - Rule configuration for table lookup
1476 * @key_iova: I/O virtual address of the key (must be in DMA-able memory)
1477 * @mask_iova: I/O virtual address of the mask (must be in DMA-able memory)
1478 * @key_size: key and mask size (in bytes)
1480 struct dpni_rule_cfg {
1486 int dpni_add_qos_entry(struct fsl_mc_io *mc_io,
1489 const struct dpni_rule_cfg *cfg,
1495 int dpni_remove_qos_entry(struct fsl_mc_io *mc_io,
1498 const struct dpni_rule_cfg *cfg);
1500 int dpni_clear_qos_table(struct fsl_mc_io *mc_io,
1505 * Discard matching traffic. If set, this takes precedence over any other
1506 * configuration and matching traffic is always discarded.
1508 #define DPNI_FS_OPT_DISCARD 0x1
1511 * Set FLC value. If set, flc member of truct dpni_fs_action_cfg is used to
1512 * override the FLC value set per queue.
1513 * For more details check the Frame Descriptor section in the hardware
1516 #define DPNI_FS_OPT_SET_FLC 0x2
1519 * Indicates whether the 6 lowest significant bits of FLC are used for stash
1520 * control. If set, the 6 least significant bits in value are interpreted as
1522 * - bits 0-1: indicates the number of 64 byte units of context that are
1523 * stashed. FLC value is interpreted as a memory address in this case,
1524 * excluding the 6 LS bits.
1525 * - bits 2-3: indicates the number of 64 byte units of frame annotation
1526 * to be stashed. Annotation is placed at FD[ADDR].
1527 * - bits 4-5: indicates the number of 64 byte units of frame data to be
1528 * stashed. Frame data is placed at FD[ADDR] + FD[OFFSET].
1529 * This flag is ignored if DPNI_FS_OPT_SET_FLC is not specified.
1531 #define DPNI_FS_OPT_SET_STASH_CONTROL 0x4
1534 * Redirect matching traffic to Rx part of another dpni object. The frame
1535 * will be classified according to new qos and flow steering rules from
1536 * target dpni object.
1538 #define DPNI_FS_OPT_REDIRECT_TO_DPNI_RX 0x08
1541 * Redirect matching traffic into Tx queue of another dpni object. The
1542 * frame will be transmitted directly
1544 #define DPNI_FS_OPT_REDIRECT_TO_DPNI_TX 0x10
1547 * struct dpni_fs_action_cfg - Action configuration for table look-up
1548 * @flc: FLC value for traffic matching this rule. Please check the Frame
1549 * Descriptor section in the hardware documentation for more information.
1550 * @flow_id: Identifies the Rx queue used for matching traffic. Supported
1551 * values are in range 0 to num_queue-1.
1552 * @redirect_obj_token: token that identifies the object where frame is
1553 * redirected when this rule is hit. This parameter is used only when one of the
1554 * flags DPNI_FS_OPT_REDIRECT_TO_DPNI_RX or DPNI_FS_OPT_REDIRECT_TO_DPNI_TX is
1556 * The token is obtained using dpni_open() API call. The object must stay
1557 * open during the operation to ensure the fact that application has access
1558 * on it. If the object is destroyed of closed next actions will take place:
1559 * - if DPNI_FS_OPT_DISCARD is set the frame will be discarded by current dpni
1560 * - if DPNI_FS_OPT_DISCARD is cleared the frame will be enqueued in queue with
1561 * index provided in flow_id parameter.
1562 * @options: Any combination of DPNI_FS_OPT_ values.
1564 struct dpni_fs_action_cfg {
1567 uint16_t redirect_obj_token;
1571 int dpni_add_fs_entry(struct fsl_mc_io *mc_io,
1576 const struct dpni_rule_cfg *cfg,
1577 const struct dpni_fs_action_cfg *action);
1579 int dpni_remove_fs_entry(struct fsl_mc_io *mc_io,
1583 const struct dpni_rule_cfg *cfg);
1585 int dpni_clear_fs_entries(struct fsl_mc_io *mc_io,
1590 int dpni_get_api_version(struct fsl_mc_io *mc_io,
1592 uint16_t *major_ver,
1593 uint16_t *minor_ver);
1598 #define DPNI_QUEUE_OPT_USER_CTX 0x00000001
1601 * Set queue destination configuration
1603 #define DPNI_QUEUE_OPT_DEST 0x00000002
1606 * Set FD[FLC] configuration for traffic on this queue. Note that FLC values
1607 * set with dpni_add_fs_entry, if any, take precedence over values per queue.
1609 #define DPNI_QUEUE_OPT_FLC 0x00000004
1612 * Set the queue to hold active mode. This prevents the queue from being
1613 * rescheduled between DPIOs while it carries traffic and is active on one
1614 * DPNI. Can help reduce reordering when servicing one queue on multiple
1615 * CPUs, but the queue is also less likely to push data to multiple CPUs
1616 * especially when congested.
1618 #define DPNI_QUEUE_OPT_HOLD_ACTIVE 0x00000008
1620 #define DPNI_QUEUE_OPT_SET_CGID 0x00000040
1621 #define DPNI_QUEUE_OPT_CLEAR_CGID 0x00000080
1623 int dpni_set_queue(struct fsl_mc_io *mc_io,
1626 enum dpni_queue_type qtype,
1630 const struct dpni_queue *queue);
1632 int dpni_get_queue(struct fsl_mc_io *mc_io,
1635 enum dpni_queue_type qtype,
1638 struct dpni_queue *queue,
1639 struct dpni_queue_id *qid);
1641 int dpni_get_statistics(struct fsl_mc_io *mc_io,
1646 union dpni_statistics *stat);
1648 int dpni_reset_statistics(struct fsl_mc_io *mc_io,
1653 * struct dpni_taildrop - Structure representing the taildrop
1654 * @enable: Indicates whether the taildrop is active or not.
1655 * @units: Indicates the unit of THRESHOLD. Queue taildrop only
1656 * supports byte units, this field is ignored and
1657 * assumed = 0 if CONGESTION_POINT is 0.
1658 * @threshold: Threshold value, in units identified by UNITS field. Value 0
1659 * cannot be used as a valid taildrop threshold,
1660 * THRESHOLD must be > 0 if the taildrop is
1662 * @oal : Overhead Accounting Length, a 12-bit, 2's complement value
1663 * with range (-2048 to +2047) representing a fixed per-frame
1664 * overhead to be added to the actual length of a frame when
1665 * performing WRED and tail drop calculations and threshold
1668 struct dpni_taildrop {
1670 enum dpni_congestion_unit units;
1675 int dpni_set_taildrop(struct fsl_mc_io *mc_io,
1678 enum dpni_congestion_point cg_point,
1679 enum dpni_queue_type q_type,
1682 struct dpni_taildrop *taildrop);
1684 int dpni_get_taildrop(struct fsl_mc_io *mc_io,
1687 enum dpni_congestion_point cg_point,
1688 enum dpni_queue_type q_type,
1691 struct dpni_taildrop *taildrop);
1693 int dpni_set_opr(struct fsl_mc_io *mc_io,
1699 struct opr_cfg *cfg,
1702 int dpni_get_opr(struct fsl_mc_io *mc_io,
1707 struct opr_cfg *cfg,
1708 struct opr_qry *qry,
1713 * When used for queue_idx in function dpni_set_rx_dist_default_queue will
1714 * signal to dpni to drop all unclassified frames
1716 #define DPNI_FS_MISS_DROP ((uint16_t)-1)
1719 * struct dpni_rx_dist_cfg - distribution configuration
1720 * @dist_size: distribution size; supported values: 1,2,3,4,6,7,8,
1721 * 12,14,16,24,28,32,48,56,64,96,112,128,192,224,256,384,448,
1723 * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
1724 * the extractions to be used for the distribution key by calling
1725 * dpkg_prepare_key_cfg() relevant only when enable!=0 otherwise
1727 * @enable: enable/disable the distribution.
1728 * @tc: TC id for which distribution is set
1729 * @fs_miss_flow_id: when packet misses all rules from flow steering table and
1730 * hash is disabled it will be put into this queue id; use
1731 * DPNI_FS_MISS_DROP to drop frames. The value of this field is
1732 * used only when flow steering distribution is enabled and hash
1733 * distribution is disabled
1735 struct dpni_rx_dist_cfg {
1737 uint64_t key_cfg_iova;
1740 uint16_t fs_miss_flow_id;
1743 int dpni_set_rx_fs_dist(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
1744 uint16_t token, const struct dpni_rx_dist_cfg *cfg);
1746 int dpni_set_rx_hash_dist(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
1747 uint16_t token, const struct dpni_rx_dist_cfg *cfg);
1749 int dpni_add_custom_tpid(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
1750 uint16_t token, uint16_t tpid);
1752 int dpni_remove_custom_tpid(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
1753 uint16_t token, uint16_t tpid);
1756 * struct dpni_custom_tpid_cfg - custom TPID configuration. Contains custom TPID
1757 * values used in current dpni object to detect 802.1q frames.
1758 * @tpid1: first tag. Not used if zero.
1759 * @tpid2: second tag. Not used if zero.
1761 struct dpni_custom_tpid_cfg {
1766 int dpni_get_custom_tpid(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
1767 uint16_t token, struct dpni_custom_tpid_cfg *tpid);
1770 * enum dpni_soft_sequence_dest - Enumeration of WRIOP software sequence
1772 * @DPNI_SS_INGRESS: Ingress parser
1773 * @DPNI_SS_EGRESS: Egress parser
1775 enum dpni_soft_sequence_dest {
1776 DPNI_SS_INGRESS = 0,
1781 * struct dpni_load_ss_cfg - Structure for Software Sequence load configuration
1782 * @dest: Destination of the Software Sequence: ingress or egress parser
1783 * @ss_size: Size of the Software Sequence
1784 * @ss_offset: The offset where to load the Software Sequence (0x20-0x7FD)
1785 * @ss_iova: I/O virtual address of the Software Sequence
1787 struct dpni_load_ss_cfg {
1788 enum dpni_soft_sequence_dest dest;
1795 * struct dpni_enable_ss_cfg - Structure for software sequence enable
1797 * @dest: Destination of the Software Sequence: ingress or egress parser
1798 * @hxs: HXS to attach the software sequence to
1799 * @set_start: If the Software Sequence or HDR it is attached to is set as
1801 * If hxs=DUMMY_LAST_HXS the ss_offset is set directly as parser
1802 * start else the hdr index code is set as parser start
1803 * @ss_offset: The offset of the Software Sequence to enable or set as parse
1805 * @param_size: Size of the software sequence parameters
1806 * @param_offset: Offset in the parameter zone for the software sequence
1808 * @param_iova: I/O virtual address of the parameters
1810 struct dpni_enable_ss_cfg {
1811 enum dpni_soft_sequence_dest dest;
1816 uint8_t param_offset;
1817 uint64_t param_iova;
1821 * dpni_load_sw_sequence() - Loads a software sequence in parser memory.
1822 * @mc_io: Pointer to MC portal's I/O object
1823 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1824 * @token: Token of DPNI object
1825 * @cfg: Software sequence load configuration
1826 * Return: '0' on Success; Error code otherwise.
1828 int dpni_load_sw_sequence(struct fsl_mc_io *mc_io,
1831 struct dpni_load_ss_cfg *cfg);
1834 * dpni_enable_sw_sequence() - Enables a software sequence in the parser
1836 * corresponding to the ingress or egress of the DPNI.
1837 * @mc_io: Pointer to MC portal's I/O object
1838 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1839 * @token: Token of DPNI object
1840 * @cfg: Software sequence enable configuration
1841 * Return: '0' on Success; Error code otherwise.
1843 int dpni_enable_sw_sequence(struct fsl_mc_io *mc_io,
1846 struct dpni_enable_ss_cfg *cfg);
1849 * struct dpni_sw_sequence_layout - Structure for software sequence enable
1851 * @num_ss: Number of software sequences returned
1852 * @ss: Array of software sequence entries. The number of valid entries
1853 * must match 'num_ss' value
1855 struct dpni_sw_sequence_layout {
1860 uint8_t param_offset;
1862 } ss[DPNI_SW_SEQUENCE_LAYOUT_SIZE];
1866 * dpni_get_sw_sequence_layout() - Get the soft sequence layout
1867 * @mc_io: Pointer to MC portal's I/O object
1868 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1869 * @token: Token of DPNI object
1870 * @src: Source of the layout (WRIOP Rx or Tx)
1871 * @ss_layout_iova: I/O virtual address of 264 bytes DMA-able memory
1873 * warning: After calling this function, call dpni_extract_sw_sequence_layout()
1876 * Return: '0' on Success; error code otherwise.
1878 int dpni_get_sw_sequence_layout(struct fsl_mc_io *mc_io,
1881 enum dpni_soft_sequence_dest src,
1882 uint64_t ss_layout_iova);
1885 * dpni_extract_sw_sequence_layout() - extract the software sequence layout
1886 * @layout: software sequence layout
1887 * @sw_sequence_layout_buf:Zeroed 264 bytes of memory before mapping it to DMA
1889 * This function has to be called after dpni_get_sw_sequence_layout
1891 void dpni_extract_sw_sequence_layout(struct dpni_sw_sequence_layout *layout,
1892 const uint8_t *sw_sequence_layout_buf);
1895 * struct dpni_ptp_cfg - configure single step PTP (IEEE 1588)
1896 * @en: enable single step PTP. When enabled the PTPv1 functionality will
1897 * not work. If the field is zero, offset and ch_update parameters
1899 * @offset: start offset from the beginning of the frame where timestamp
1900 * field is found. The offset must respect all MAC headers, VLAN
1901 * tags and other protocol headers
1902 * @ch_update: when set UDP checksum will be updated inside packet
1903 * @peer_delay: For peer-to-peer transparent clocks add this value to the
1904 * correction field in addition to the transient time update. The
1905 * value expresses nanoseconds.
1907 struct dpni_single_step_cfg {
1911 uint32_t peer_delay;
1914 int dpni_set_single_step_cfg(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
1915 uint16_t token, struct dpni_single_step_cfg *ptp_cfg);
1917 int dpni_get_single_step_cfg(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
1918 uint16_t token, struct dpni_single_step_cfg *ptp_cfg);
1921 * loopback_en field is valid when calling function dpni_set_port_cfg
1923 #define DPNI_PORT_CFG_LOOPBACK 0x01
1926 * struct dpni_port_cfg - custom configuration for dpni physical port
1927 * @loopback_en: port loopback enabled
1929 struct dpni_port_cfg {
1933 int dpni_set_port_cfg(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
1934 uint16_t token, uint32_t flags, struct dpni_port_cfg *port_cfg);
1936 int dpni_get_port_cfg(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
1937 uint16_t token, struct dpni_port_cfg *port_cfg);
1939 #endif /* __FSL_DPNI_H */