1 /* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
2 /* Copyright 2013-2016 Freescale Semiconductor Inc.
14 * Data Path Network Interface API
15 * Contains initialization APIs and runtime control APIs for DPNI
18 /** General DPNI macros */
21 * Maximum number of traffic classes
25 * Maximum number of buffer pools per DPNI
27 #define DPNI_MAX_DPBP 8
30 * All traffic classes considered; see dpni_set_queue()
32 #define DPNI_ALL_TCS (u8)(-1)
34 * All flows within traffic class considered; see dpni_set_queue()
36 #define DPNI_ALL_TC_FLOWS (u16)(-1)
38 * Generate new flow ID; see dpni_set_queue()
40 #define DPNI_NEW_FLOW_ID (u16)(-1)
43 * Tx traffic is always released to a buffer pool on transmit, there are no
44 * resources allocated to have the frames confirmed back to the source after
47 #define DPNI_OPT_TX_FRM_RELEASE 0x000001
49 * Disables support for MAC address filtering for addresses other than primary
50 * MAC address. This affects both unicast and multicast. Promiscuous mode can
51 * still be enabled/disabled for both unicast and multicast. If promiscuous mode
52 * is disabled, only traffic matching the primary MAC address will be accepted.
54 #define DPNI_OPT_NO_MAC_FILTER 0x000002
56 * Allocate policers for this DPNI. They can be used to rate-limit traffic per
57 * traffic class (TC) basis.
59 #define DPNI_OPT_HAS_POLICING 0x000004
61 * Congestion can be managed in several ways, allowing the buffer pool to
62 * deplete on ingress, taildrop on each queue or use congestion groups for sets
63 * of queues. If set, it configures a single congestion groups across all TCs.
64 * If reset, a congestion group is allocated for each TC. Only relevant if the
65 * DPNI has multiple traffic classes.
67 #define DPNI_OPT_SHARED_CONGESTION 0x000008
69 * Enables TCAM for Flow Steering and QoS look-ups. If not specified, all
70 * look-ups are exact match. Note that TCAM is not available on LS1088 and its
71 * variants. Setting this bit on these SoCs will trigger an error.
73 #define DPNI_OPT_HAS_KEY_MASKING 0x000010
75 * Disables the flow steering table.
77 #define DPNI_OPT_NO_FS 0x000020
79 * Flow steering table is shared between all traffic classes
81 #define DPNI_OPT_SHARED_FS 0x001000
83 int dpni_open(struct fsl_mc_io
*mc_io
,
88 int dpni_close(struct fsl_mc_io
*mc_io
,
93 * struct dpni_pools_cfg - Structure representing buffer pools configuration
94 * @num_dpbp: Number of DPBPs
95 * @pools: Array of buffer pools parameters; The number of valid entries
96 * must match 'num_dpbp' value
97 * @pools.dpbp_id: DPBP object ID
98 * @pools.buffer_size: Buffer size
99 * @pools.backup_pool: Backup pool
101 struct dpni_pools_cfg
{
107 } pools
[DPNI_MAX_DPBP
];
110 int dpni_set_pools(struct fsl_mc_io
*mc_io
,
113 const struct dpni_pools_cfg
*cfg
);
115 int dpni_enable(struct fsl_mc_io
*mc_io
,
119 int dpni_disable(struct fsl_mc_io
*mc_io
,
123 int dpni_is_enabled(struct fsl_mc_io
*mc_io
,
128 int dpni_reset(struct fsl_mc_io
*mc_io
,
133 * DPNI IRQ Index and Events
139 #define DPNI_IRQ_INDEX 0
142 * indicates a change in link state
143 * indicates a change in endpoint
145 #define DPNI_IRQ_EVENT_LINK_CHANGED 0x00000001
146 #define DPNI_IRQ_EVENT_ENDPOINT_CHANGED 0x00000002
148 int dpni_set_irq_enable(struct fsl_mc_io
*mc_io
,
154 int dpni_get_irq_enable(struct fsl_mc_io
*mc_io
,
160 int dpni_set_irq_mask(struct fsl_mc_io
*mc_io
,
166 int dpni_get_irq_mask(struct fsl_mc_io
*mc_io
,
172 int dpni_get_irq_status(struct fsl_mc_io
*mc_io
,
178 int dpni_clear_irq_status(struct fsl_mc_io
*mc_io
,
185 * struct dpni_attr - Structure representing DPNI attributes
186 * @options: Any combination of the following options:
187 * DPNI_OPT_TX_FRM_RELEASE
188 * DPNI_OPT_NO_MAC_FILTER
189 * DPNI_OPT_HAS_POLICING
190 * DPNI_OPT_SHARED_CONGESTION
191 * DPNI_OPT_HAS_KEY_MASKING
193 * @num_queues: Number of Tx and Rx queues used for traffic distribution.
194 * @num_tcs: Number of traffic classes (TCs), reserved for the DPNI.
195 * @mac_filter_entries: Number of entries in the MAC address filtering table.
196 * @vlan_filter_entries: Number of entries in the VLAN address filtering table.
197 * @qos_entries: Number of entries in the QoS classification table.
198 * @fs_entries: Number of entries in the flow steering table.
199 * @qos_key_size: Size, in bytes, of the QoS look-up key. Defining a key larger
200 * than this when adding QoS entries will result in an error.
201 * @fs_key_size: Size, in bytes, of the flow steering look-up key. Defining a
202 * key larger than this when composing the hash + FS key will
203 * result in an error.
204 * @wriop_version: Version of WRIOP HW block. The 3 version values are stored
205 * on 6, 5, 5 bits respectively.
211 u8 mac_filter_entries
;
212 u8 vlan_filter_entries
;
220 int dpni_get_attributes(struct fsl_mc_io
*mc_io
,
223 struct dpni_attr
*attr
);
230 * Extract out of frame header error
232 #define DPNI_ERROR_EOFHE 0x00020000
236 #define DPNI_ERROR_FLE 0x00002000
238 * Frame physical error
240 #define DPNI_ERROR_FPE 0x00001000
242 * Parsing header error
244 #define DPNI_ERROR_PHE 0x00000020
246 * Parser L3 checksum error
248 #define DPNI_ERROR_L3CE 0x00000004
250 * Parser L3 checksum error
252 #define DPNI_ERROR_L4CE 0x00000001
255 * enum dpni_error_action - Defines DPNI behavior for errors
256 * @DPNI_ERROR_ACTION_DISCARD: Discard the frame
257 * @DPNI_ERROR_ACTION_CONTINUE: Continue with the normal flow
258 * @DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE: Send the frame to the error queue
260 enum dpni_error_action
{
261 DPNI_ERROR_ACTION_DISCARD
= 0,
262 DPNI_ERROR_ACTION_CONTINUE
= 1,
263 DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE
= 2
267 * struct dpni_error_cfg - Structure representing DPNI errors treatment
268 * @errors: Errors mask; use 'DPNI_ERROR__<X>
269 * @error_action: The desired action for the errors mask
270 * @set_frame_annotation: Set to '1' to mark the errors in frame annotation
271 * status (FAS); relevant only for the non-discard action
273 struct dpni_error_cfg
{
275 enum dpni_error_action error_action
;
276 int set_frame_annotation
;
279 int dpni_set_errors_behavior(struct fsl_mc_io
*mc_io
,
282 struct dpni_error_cfg
*cfg
);
285 * DPNI buffer layout modification options
289 * Select to modify the time-stamp setting
291 #define DPNI_BUF_LAYOUT_OPT_TIMESTAMP 0x00000001
293 * Select to modify the parser-result setting; not applicable for Tx
295 #define DPNI_BUF_LAYOUT_OPT_PARSER_RESULT 0x00000002
297 * Select to modify the frame-status setting
299 #define DPNI_BUF_LAYOUT_OPT_FRAME_STATUS 0x00000004
301 * Select to modify the private-data-size setting
303 #define DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE 0x00000008
305 * Select to modify the data-alignment setting
307 #define DPNI_BUF_LAYOUT_OPT_DATA_ALIGN 0x00000010
309 * Select to modify the data-head-room setting
311 #define DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM 0x00000020
313 * Select to modify the data-tail-room setting
315 #define DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM 0x00000040
318 * struct dpni_buffer_layout - Structure representing DPNI buffer layout
319 * @options: Flags representing the suggested modifications to the buffer
320 * layout; Use any combination of 'DPNI_BUF_LAYOUT_OPT_<X>' flags
321 * @pass_timestamp: Pass timestamp value
322 * @pass_parser_result: Pass parser results
323 * @pass_frame_status: Pass frame status
324 * @private_data_size: Size kept for private data (in bytes)
325 * @data_align: Data alignment
326 * @data_head_room: Data head room
327 * @data_tail_room: Data tail room
329 struct dpni_buffer_layout
{
332 int pass_parser_result
;
333 int pass_frame_status
;
334 u16 private_data_size
;
341 * enum dpni_queue_type - Identifies a type of queue targeted by the command
342 * @DPNI_QUEUE_RX: Rx queue
343 * @DPNI_QUEUE_TX: Tx queue
344 * @DPNI_QUEUE_TX_CONFIRM: Tx confirmation queue
345 * @DPNI_QUEUE_RX_ERR: Rx error queue
346 */enum dpni_queue_type
{
349 DPNI_QUEUE_TX_CONFIRM
,
353 int dpni_get_buffer_layout(struct fsl_mc_io
*mc_io
,
356 enum dpni_queue_type qtype
,
357 struct dpni_buffer_layout
*layout
);
359 int dpni_set_buffer_layout(struct fsl_mc_io
*mc_io
,
362 enum dpni_queue_type qtype
,
363 const struct dpni_buffer_layout
*layout
);
366 * enum dpni_offload - Identifies a type of offload targeted by the command
367 * @DPNI_OFF_RX_L3_CSUM: Rx L3 checksum validation
368 * @DPNI_OFF_RX_L4_CSUM: Rx L4 checksum validation
369 * @DPNI_OFF_TX_L3_CSUM: Tx L3 checksum generation
370 * @DPNI_OFF_TX_L4_CSUM: Tx L4 checksum generation
379 int dpni_set_offload(struct fsl_mc_io
*mc_io
,
382 enum dpni_offload type
,
385 int dpni_get_offload(struct fsl_mc_io
*mc_io
,
388 enum dpni_offload type
,
391 int dpni_get_qdid(struct fsl_mc_io
*mc_io
,
394 enum dpni_queue_type qtype
,
397 int dpni_get_tx_data_offset(struct fsl_mc_io
*mc_io
,
402 #define DPNI_STATISTICS_CNT 7
405 * union dpni_statistics - Union describing the DPNI statistics
406 * @page_0: Page_0 statistics structure
407 * @page_0.ingress_all_frames: Ingress frame count
408 * @page_0.ingress_all_bytes: Ingress byte count
409 * @page_0.ingress_multicast_frames: Ingress multicast frame count
410 * @page_0.ingress_multicast_bytes: Ingress multicast byte count
411 * @page_0.ingress_broadcast_frames: Ingress broadcast frame count
412 * @page_0.ingress_broadcast_bytes: Ingress broadcast byte count
413 * @page_1: Page_1 statistics structure
414 * @page_1.egress_all_frames: Egress frame count
415 * @page_1.egress_all_bytes: Egress byte count
416 * @page_1.egress_multicast_frames: Egress multicast frame count
417 * @page_1.egress_multicast_bytes: Egress multicast byte count
418 * @page_1.egress_broadcast_frames: Egress broadcast frame count
419 * @page_1.egress_broadcast_bytes: Egress broadcast byte count
420 * @page_2: Page_2 statistics structure
421 * @page_2.ingress_filtered_frames: Ingress filtered frame count
422 * @page_2.ingress_discarded_frames: Ingress discarded frame count
423 * @page_2.ingress_nobuffer_discards: Ingress discarded frame count due to
425 * @page_2.egress_discarded_frames: Egress discarded frame count
426 * @page_2.egress_confirmed_frames: Egress confirmed frame count
427 * @page3: Page_3 statistics structure
428 * @page_3.egress_dequeue_bytes: Cumulative count of the number of bytes
429 * dequeued from egress FQs
430 * @page_3.egress_dequeue_frames: Cumulative count of the number of frames
431 * dequeued from egress FQs
432 * @page_3.egress_reject_bytes: Cumulative count of the number of bytes in
433 * egress frames whose enqueue was rejected
434 * @page_3.egress_reject_frames: Cumulative count of the number of egress
435 * frames whose enqueue was rejected
436 * @page_4: Page_4 statistics structure: congestion points
437 * @page_4.cgr_reject_frames: number of rejected frames due to congestion point
438 * @page_4.cgr_reject_bytes: number of rejected bytes due to congestion point
439 * @page_5: Page_5 statistics structure: policer
440 * @page_5.policer_cnt_red: NUmber of red colored frames
441 * @page_5.policer_cnt_yellow: number of yellow colored frames
442 * @page_5.policer_cnt_green: number of green colored frames
443 * @page_5.policer_cnt_re_red: number of recolored red frames
444 * @page_5.policer_cnt_re_yellow: number of recolored yellow frames
445 * @page_6: Page_6 statistics structure
446 * @page_6.tx_pending_frames: total number of frames pending in egress FQs
447 * @raw: raw statistics structure, used to index counters
449 union dpni_statistics
{
451 u64 ingress_all_frames
;
452 u64 ingress_all_bytes
;
453 u64 ingress_multicast_frames
;
454 u64 ingress_multicast_bytes
;
455 u64 ingress_broadcast_frames
;
456 u64 ingress_broadcast_bytes
;
459 u64 egress_all_frames
;
460 u64 egress_all_bytes
;
461 u64 egress_multicast_frames
;
462 u64 egress_multicast_bytes
;
463 u64 egress_broadcast_frames
;
464 u64 egress_broadcast_bytes
;
467 u64 ingress_filtered_frames
;
468 u64 ingress_discarded_frames
;
469 u64 ingress_nobuffer_discards
;
470 u64 egress_discarded_frames
;
471 u64 egress_confirmed_frames
;
474 u64 egress_dequeue_bytes
;
475 u64 egress_dequeue_frames
;
476 u64 egress_reject_bytes
;
477 u64 egress_reject_frames
;
480 u64 cgr_reject_frames
;
481 u64 cgr_reject_bytes
;
485 u64 policer_cnt_yellow
;
486 u64 policer_cnt_green
;
487 u64 policer_cnt_re_red
;
488 u64 policer_cnt_re_yellow
;
491 u64 tx_pending_frames
;
494 u64 counter
[DPNI_STATISTICS_CNT
];
498 int dpni_get_statistics(struct fsl_mc_io
*mc_io
,
502 union dpni_statistics
*stat
);
505 * Enable auto-negotiation
507 #define DPNI_LINK_OPT_AUTONEG 0x0000000000000001ULL
509 * Enable half-duplex mode
511 #define DPNI_LINK_OPT_HALF_DUPLEX 0x0000000000000002ULL
513 * Enable pause frames
515 #define DPNI_LINK_OPT_PAUSE 0x0000000000000004ULL
517 * Enable a-symmetric pause frames
519 #define DPNI_LINK_OPT_ASYM_PAUSE 0x0000000000000008ULL
522 * Enable priority flow control pause frames
524 #define DPNI_LINK_OPT_PFC_PAUSE 0x0000000000000010ULL
527 * struct - Structure representing DPNI link configuration
529 * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
531 struct dpni_link_cfg
{
536 int dpni_set_link_cfg(struct fsl_mc_io
*mc_io
,
539 const struct dpni_link_cfg
*cfg
);
541 int dpni_get_link_cfg(struct fsl_mc_io
*mc_io
,
544 struct dpni_link_cfg
*cfg
);
547 * struct dpni_link_state - Structure representing DPNI link state
549 * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
550 * @up: Link state; '0' for down, '1' for up
552 struct dpni_link_state
{
558 int dpni_get_link_state(struct fsl_mc_io
*mc_io
,
561 struct dpni_link_state
*state
);
563 int dpni_set_max_frame_length(struct fsl_mc_io
*mc_io
,
566 u16 max_frame_length
);
568 int dpni_get_max_frame_length(struct fsl_mc_io
*mc_io
,
571 u16
*max_frame_length
);
573 int dpni_set_multicast_promisc(struct fsl_mc_io
*mc_io
,
578 int dpni_get_multicast_promisc(struct fsl_mc_io
*mc_io
,
583 int dpni_set_unicast_promisc(struct fsl_mc_io
*mc_io
,
588 int dpni_get_unicast_promisc(struct fsl_mc_io
*mc_io
,
593 int dpni_set_primary_mac_addr(struct fsl_mc_io
*mc_io
,
596 const u8 mac_addr
[6]);
598 int dpni_get_primary_mac_addr(struct fsl_mc_io
*mc_io
,
603 int dpni_get_port_mac_addr(struct fsl_mc_io
*mc_io
,
608 int dpni_add_mac_addr(struct fsl_mc_io
*mc_io
,
611 const u8 mac_addr
[6]);
613 int dpni_remove_mac_addr(struct fsl_mc_io
*mc_io
,
616 const u8 mac_addr
[6]);
618 int dpni_clear_mac_filters(struct fsl_mc_io
*mc_io
,
625 * enum dpni_dist_mode - DPNI distribution mode
626 * @DPNI_DIST_MODE_NONE: No distribution
627 * @DPNI_DIST_MODE_HASH: Use hash distribution; only relevant if
628 * the 'DPNI_OPT_DIST_HASH' option was set at DPNI creation
629 * @DPNI_DIST_MODE_FS: Use explicit flow steering; only relevant if
630 * the 'DPNI_OPT_DIST_FS' option was set at DPNI creation
632 enum dpni_dist_mode
{
633 DPNI_DIST_MODE_NONE
= 0,
634 DPNI_DIST_MODE_HASH
= 1,
635 DPNI_DIST_MODE_FS
= 2
639 * enum dpni_fs_miss_action - DPNI Flow Steering miss action
640 * @DPNI_FS_MISS_DROP: In case of no-match, drop the frame
641 * @DPNI_FS_MISS_EXPLICIT_FLOWID: In case of no-match, use explicit flow-id
642 * @DPNI_FS_MISS_HASH: In case of no-match, distribute using hash
644 enum dpni_fs_miss_action
{
645 DPNI_FS_MISS_DROP
= 0,
646 DPNI_FS_MISS_EXPLICIT_FLOWID
= 1,
647 DPNI_FS_MISS_HASH
= 2
651 * struct dpni_fs_tbl_cfg - Flow Steering table configuration
652 * @miss_action: Miss action selection
653 * @default_flow_id: Used when 'miss_action = DPNI_FS_MISS_EXPLICIT_FLOWID'
655 struct dpni_fs_tbl_cfg
{
656 enum dpni_fs_miss_action miss_action
;
660 int dpni_prepare_key_cfg(const struct dpkg_profile_cfg
*cfg
,
664 * struct dpni_rx_tc_dist_cfg - Rx traffic class distribution configuration
665 * @dist_size: Set the distribution size;
666 * supported values: 1,2,3,4,6,7,8,12,14,16,24,28,32,48,56,64,96,
667 * 112,128,192,224,256,384,448,512,768,896,1024
668 * @dist_mode: Distribution mode
669 * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
670 * the extractions to be used for the distribution key by calling
671 * dpni_prepare_key_cfg() relevant only when
672 * 'dist_mode != DPNI_DIST_MODE_NONE', otherwise it can be '0'
673 * @fs_cfg: Flow Steering table configuration; only relevant if
674 * 'dist_mode = DPNI_DIST_MODE_FS'
676 struct dpni_rx_tc_dist_cfg
{
678 enum dpni_dist_mode dist_mode
;
680 struct dpni_fs_tbl_cfg fs_cfg
;
683 int dpni_set_rx_tc_dist(struct fsl_mc_io
*mc_io
,
687 const struct dpni_rx_tc_dist_cfg
*cfg
);
690 * When used for fs_miss_flow_id in function dpni_set_rx_dist,
691 * will signal to dpni to drop all unclassified frames
693 #define DPNI_FS_MISS_DROP ((uint16_t)-1)
696 * struct dpni_rx_dist_cfg - Rx distribution configuration
697 * @dist_size: distribution size
698 * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
699 * the extractions to be used for the distribution key by calling
700 * dpni_prepare_key_cfg(); relevant only when enable!=0 otherwise
702 * @enable: enable/disable the distribution.
703 * @tc: TC id for which distribution is set
704 * @fs_miss_flow_id: when packet misses all rules from flow steering table and
705 * hash is disabled it will be put into this queue id; use
706 * DPNI_FS_MISS_DROP to drop frames. The value of this field is
707 * used only when flow steering distribution is enabled and hash
708 * distribution is disabled
710 struct dpni_rx_dist_cfg
{
718 int dpni_set_rx_fs_dist(struct fsl_mc_io
*mc_io
,
721 const struct dpni_rx_dist_cfg
*cfg
);
723 int dpni_set_rx_hash_dist(struct fsl_mc_io
*mc_io
,
726 const struct dpni_rx_dist_cfg
*cfg
);
729 * struct dpni_qos_tbl_cfg - Structure representing QOS table configuration
730 * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
731 * key extractions to be used as the QoS criteria by calling
732 * dpkg_prepare_key_cfg()
733 * @discard_on_miss: Set to '1' to discard frames in case of no match (miss);
734 * '0' to use the 'default_tc' in such cases
735 * @default_tc: Used in case of no-match and 'discard_on_miss'= 0
737 struct dpni_qos_tbl_cfg
{
743 int dpni_set_qos_table(struct fsl_mc_io
*mc_io
,
746 const struct dpni_qos_tbl_cfg
*cfg
);
749 * enum dpni_dest - DPNI destination types
750 * @DPNI_DEST_NONE: Unassigned destination; The queue is set in parked mode and
751 * does not generate FQDAN notifications; user is expected to
752 * dequeue from the queue based on polling or other user-defined
754 * @DPNI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
755 * notifications to the specified DPIO; user is expected to dequeue
756 * from the queue only after notification is received
757 * @DPNI_DEST_DPCON: The queue is set in schedule mode and does not generate
758 * FQDAN notifications, but is connected to the specified DPCON
759 * object; user is expected to dequeue from the DPCON channel
768 * struct dpni_queue - Queue structure
769 * @destination - Destination structure
770 * @destination.id: ID of the destination, only relevant if DEST_TYPE is > 0.
771 * Identifies either a DPIO or a DPCON object.
772 * Not relevant for Tx queues.
773 * @destination.type: May be one of the following:
774 * 0 - No destination, queue can be manually
775 * queried, but will not push traffic or
776 * notifications to a DPIO;
777 * 1 - The destination is a DPIO. When traffic
778 * becomes available in the queue a FQDAN
779 * (FQ data available notification) will be
780 * generated to selected DPIO;
781 * 2 - The destination is a DPCON. The queue is
782 * associated with a DPCON object for the
783 * purpose of scheduling between multiple
784 * queues. The DPCON may be independently
785 * configured to generate notifications.
786 * Not relevant for Tx queues.
787 * @destination.hold_active: Hold active, maintains a queue scheduled for longer
788 * in a DPIO during dequeue to reduce spread of traffic.
789 * Only relevant if queues are
790 * not affined to a single DPIO.
791 * @user_context: User data, presented to the user along with any frames
792 * from this queue. Not relevant for Tx queues.
793 * @flc: FD FLow Context structure
794 * @flc.value: Default FLC value for traffic dequeued from
795 * this queue. Please check description of FD
796 * structure for more information.
797 * Note that FLC values set using dpni_add_fs_entry,
798 * if any, take precedence over values per queue.
799 * @flc.stash_control: Boolean, indicates whether the 6 lowest
800 * - significant bits are used for stash control.
801 * significant bits are used for stash control. If set, the 6
802 * least significant bits in value are interpreted as follows:
803 * - bits 0-1: indicates the number of 64 byte units of context
804 * that are stashed. FLC value is interpreted as a memory address
805 * in this case, excluding the 6 LS bits.
806 * - bits 2-3: indicates the number of 64 byte units of frame
807 * annotation to be stashed. Annotation is placed at FD[ADDR].
808 * - bits 4-5: indicates the number of 64 byte units of frame
809 * data to be stashed. Frame data is placed at FD[ADDR] +
811 * For more details check the Frame Descriptor section in the
812 * hardware documentation.
829 * struct dpni_queue_id - Queue identification, used for enqueue commands
831 * @fqid: FQID used for enqueueing to and/or configuration of this specific FQ
832 * @qdbin: Queueing bin, used to enqueue using QDID, DQBIN, QPRI. Only relevant
835 struct dpni_queue_id
{
843 #define DPNI_QUEUE_OPT_USER_CTX 0x00000001
844 #define DPNI_QUEUE_OPT_DEST 0x00000002
845 #define DPNI_QUEUE_OPT_FLC 0x00000004
846 #define DPNI_QUEUE_OPT_HOLD_ACTIVE 0x00000008
848 int dpni_set_queue(struct fsl_mc_io
*mc_io
,
851 enum dpni_queue_type qtype
,
855 const struct dpni_queue
*queue
);
857 int dpni_get_queue(struct fsl_mc_io
*mc_io
,
860 enum dpni_queue_type qtype
,
863 struct dpni_queue
*queue
,
864 struct dpni_queue_id
*qid
);
867 * enum dpni_congestion_unit - DPNI congestion units
868 * @DPNI_CONGESTION_UNIT_BYTES: bytes units
869 * @DPNI_CONGESTION_UNIT_FRAMES: frames units
871 enum dpni_congestion_unit
{
872 DPNI_CONGESTION_UNIT_BYTES
= 0,
873 DPNI_CONGESTION_UNIT_FRAMES
877 * enum dpni_congestion_point - Structure representing congestion point
878 * @DPNI_CP_QUEUE: Set taildrop per queue, identified by QUEUE_TYPE, TC and
880 * @DPNI_CP_GROUP: Set taildrop per queue group. Depending on options used to
881 * define the DPNI this can be either per TC (default) or per
882 * interface (DPNI_OPT_SHARED_CONGESTION set at DPNI create).
883 * QUEUE_INDEX is ignored if this type is used.
885 enum dpni_congestion_point
{
891 * struct dpni_dest_cfg - Structure representing DPNI destination parameters
892 * @dest_type: Destination type
893 * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
894 * @priority: Priority selection within the DPIO or DPCON channel; valid
895 * values are 0-1 or 0-7, depending on the number of priorities
896 * in that channel; not relevant for 'DPNI_DEST_NONE' option
898 struct dpni_dest_cfg
{
899 enum dpni_dest dest_type
;
904 /* DPNI congestion options */
907 * This congestion will trigger flow control or priority flow control.
908 * This will have effect only if flow control is enabled with
909 * dpni_set_link_cfg().
911 #define DPNI_CONG_OPT_FLOW_CONTROL 0x00000040
914 * struct dpni_congestion_notification_cfg - congestion notification
917 * @threshold_entry: Above this threshold we enter a congestion state.
918 * set it to '0' to disable it
919 * @threshold_exit: Below this threshold we exit the congestion state.
920 * @message_ctx: The context that will be part of the CSCN message
921 * @message_iova: I/O virtual address (must be in DMA-able memory),
922 * must be 16B aligned; valid only if 'DPNI_CONG_OPT_WRITE_MEM_<X>'
923 * is contained in 'options'
924 * @dest_cfg: CSCN can be send to either DPIO or DPCON WQ channel
925 * @notification_mode: Mask of available options; use 'DPNI_CONG_OPT_<X>' values
928 struct dpni_congestion_notification_cfg
{
929 enum dpni_congestion_unit units
;
934 struct dpni_dest_cfg dest_cfg
;
935 u16 notification_mode
;
938 int dpni_set_congestion_notification(
939 struct fsl_mc_io
*mc_io
,
942 enum dpni_queue_type qtype
,
944 const struct dpni_congestion_notification_cfg
*cfg
);
947 * struct dpni_taildrop - Structure representing the taildrop
948 * @enable: Indicates whether the taildrop is active or not.
949 * @units: Indicates the unit of THRESHOLD. Queue taildrop only supports
950 * byte units, this field is ignored and assumed = 0 if
951 * CONGESTION_POINT is 0.
952 * @threshold: Threshold value, in units identified by UNITS field. Value 0
953 * cannot be used as a valid taildrop threshold, THRESHOLD must
954 * be > 0 if the taildrop is enabled.
956 struct dpni_taildrop
{
958 enum dpni_congestion_unit units
;
962 int dpni_set_taildrop(struct fsl_mc_io
*mc_io
,
965 enum dpni_congestion_point cg_point
,
966 enum dpni_queue_type q_type
,
969 struct dpni_taildrop
*taildrop
);
971 int dpni_get_taildrop(struct fsl_mc_io
*mc_io
,
974 enum dpni_congestion_point cg_point
,
975 enum dpni_queue_type q_type
,
978 struct dpni_taildrop
*taildrop
);
981 * struct dpni_rule_cfg - Rule configuration for table lookup
982 * @key_iova: I/O virtual address of the key (must be in DMA-able memory)
983 * @mask_iova: I/O virtual address of the mask (must be in DMA-able memory)
984 * @key_size: key and mask size (in bytes)
986 struct dpni_rule_cfg
{
993 * Discard matching traffic. If set, this takes precedence over any other
994 * configuration and matching traffic is always discarded.
996 #define DPNI_FS_OPT_DISCARD 0x1
999 * Set FLC value. If set, flc member of struct dpni_fs_action_cfg is used to
1000 * override the FLC value set per queue.
1001 * For more details check the Frame Descriptor section in the hardware
1004 #define DPNI_FS_OPT_SET_FLC 0x2
1007 * Indicates whether the 6 lowest significant bits of FLC are used for stash
1008 * control. If set, the 6 least significant bits in value are interpreted as
1010 * - bits 0-1: indicates the number of 64 byte units of context that are
1011 * stashed. FLC value is interpreted as a memory address in this case,
1012 * excluding the 6 LS bits.
1013 * - bits 2-3: indicates the number of 64 byte units of frame annotation
1014 * to be stashed. Annotation is placed at FD[ADDR].
1015 * - bits 4-5: indicates the number of 64 byte units of frame data to be
1016 * stashed. Frame data is placed at FD[ADDR] + FD[OFFSET].
1017 * This flag is ignored if DPNI_FS_OPT_SET_FLC is not specified.
1019 #define DPNI_FS_OPT_SET_STASH_CONTROL 0x4
1022 * struct dpni_fs_action_cfg - Action configuration for table look-up
1023 * @flc: FLC value for traffic matching this rule. Please check the
1024 * Frame Descriptor section in the hardware documentation for
1026 * @flow_id: Identifies the Rx queue used for matching traffic. Supported
1027 * values are in range 0 to num_queue-1.
1028 * @options: Any combination of DPNI_FS_OPT_ values.
1030 struct dpni_fs_action_cfg
{
1036 int dpni_add_fs_entry(struct fsl_mc_io
*mc_io
,
1041 const struct dpni_rule_cfg
*cfg
,
1042 const struct dpni_fs_action_cfg
*action
);
1044 int dpni_remove_fs_entry(struct fsl_mc_io
*mc_io
,
1048 const struct dpni_rule_cfg
*cfg
);
1050 int dpni_add_qos_entry(struct fsl_mc_io
*mc_io
,
1053 const struct dpni_rule_cfg
*cfg
,
1057 int dpni_remove_qos_entry(struct fsl_mc_io
*mc_io
,
1060 const struct dpni_rule_cfg
*cfg
);
1062 int dpni_clear_qos_table(struct fsl_mc_io
*mc_io
,
1066 int dpni_get_api_version(struct fsl_mc_io
*mc_io
,
1071 * struct dpni_tx_shaping - Structure representing DPNI tx shaping configuration
1072 * @rate_limit: Rate in Mbps
1073 * @max_burst_size: Burst size in bytes (up to 64KB)
1075 struct dpni_tx_shaping_cfg
{
1080 int dpni_set_tx_shaping(struct fsl_mc_io
*mc_io
,
1083 const struct dpni_tx_shaping_cfg
*tx_cr_shaper
,
1084 const struct dpni_tx_shaping_cfg
*tx_er_shaper
,
1088 * struct dpni_single_step_cfg - configure single step PTP (IEEE 1588)
1089 * @en: enable single step PTP. When enabled the PTPv1 functionality
1090 * will not work. If the field is zero, offset and ch_update
1091 * parameters will be ignored
1092 * @offset: start offset from the beginning of the frame where
1093 * timestamp field is found. The offset must respect all MAC
1094 * headers, VLAN tags and other protocol headers
1095 * @ch_update: when set UDP checksum will be updated inside packet
1096 * @peer_delay: For peer-to-peer transparent clocks add this value to the
1097 * correction field in addition to the transient time update.
1098 * The value expresses nanoseconds.
1100 struct dpni_single_step_cfg
{
1107 int dpni_set_single_step_cfg(struct fsl_mc_io
*mc_io
,
1110 struct dpni_single_step_cfg
*ptp_cfg
);
1112 int dpni_get_single_step_cfg(struct fsl_mc_io
*mc_io
,
1115 struct dpni_single_step_cfg
*ptp_cfg
);
1117 #endif /* __FSL_DPNI_H */