1 /* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
2 /* Copyright 2013-2016 Freescale Semiconductor Inc.
13 /* Data Path Network Interface API
14 * Contains initialization APIs and runtime control APIs for DPNI
17 /** General DPNI macros */
20 * DPNI_MAX_TC - Maximum number of traffic classes
24 * DPNI_MAX_DPBP - Maximum number of buffer pools per DPNI
26 #define DPNI_MAX_DPBP 8
29 * DPNI_ALL_TCS - All traffic classes considered; see dpni_set_queue()
31 #define DPNI_ALL_TCS (u8)(-1)
33 * DPNI_ALL_TC_FLOWS - All flows within traffic class considered; see
36 #define DPNI_ALL_TC_FLOWS (u16)(-1)
38 * DPNI_NEW_FLOW_ID - Generate new flow ID; see dpni_set_queue()
40 #define DPNI_NEW_FLOW_ID (u16)(-1)
43 * DPNI_OPT_TX_FRM_RELEASE - Tx traffic is always released to a buffer pool on
44 * transmit, there are no resources allocated to have the frames confirmed back
45 * to the source after transmission.
47 #define DPNI_OPT_TX_FRM_RELEASE 0x000001
49 * DPNI_OPT_NO_MAC_FILTER - Disables support for MAC address filtering for
50 * addresses other than primary MAC address. This affects both unicast and
51 * multicast. Promiscuous mode can still be enabled/disabled for both unicast
52 * and multicast. If promiscuous mode is disabled, only traffic matching the
53 * primary MAC address will be accepted.
55 #define DPNI_OPT_NO_MAC_FILTER 0x000002
57 * DPNI_OPT_HAS_POLICING - Allocate policers for this DPNI. They can be used to
58 * rate-limit traffic per traffic class (TC) basis.
60 #define DPNI_OPT_HAS_POLICING 0x000004
62 * DPNI_OPT_SHARED_CONGESTION - Congestion can be managed in several ways,
63 * allowing the buffer pool to deplete on ingress, taildrop on each queue or
64 * use congestion groups for sets of queues. If set, it configures a single
65 * congestion groups across all TCs. If reset, a congestion group is allocated
66 * for each TC. Only relevant if the DPNI has multiple traffic classes.
68 #define DPNI_OPT_SHARED_CONGESTION 0x000008
70 * DPNI_OPT_HAS_KEY_MASKING - Enables TCAM for Flow Steering and QoS look-ups.
71 * If not specified, all look-ups are exact match. Note that TCAM is not
72 * available on LS1088 and its variants. Setting this bit on these SoCs will
75 #define DPNI_OPT_HAS_KEY_MASKING 0x000010
77 * DPNI_OPT_NO_FS - Disables the flow steering table.
79 #define DPNI_OPT_NO_FS 0x000020
81 * DPNI_OPT_SHARED_FS - Flow steering table is shared between all traffic
84 #define DPNI_OPT_SHARED_FS 0x001000
86 int dpni_open(struct fsl_mc_io *mc_io,
91 int dpni_close(struct fsl_mc_io *mc_io,
96 * struct dpni_pools_cfg - Structure representing buffer pools configuration
97 * @num_dpbp: Number of DPBPs
98 * @pools: Array of buffer pools parameters; The number of valid entries
99 * must match 'num_dpbp' value
100 * @pools.dpbp_id: DPBP object ID
101 * @pools.buffer_size: Buffer size
102 * @pools.backup_pool: Backup pool
104 struct dpni_pools_cfg {
110 } pools[DPNI_MAX_DPBP];
113 int dpni_set_pools(struct fsl_mc_io *mc_io,
116 const struct dpni_pools_cfg *cfg);
118 int dpni_enable(struct fsl_mc_io *mc_io,
122 int dpni_disable(struct fsl_mc_io *mc_io,
126 int dpni_is_enabled(struct fsl_mc_io *mc_io,
131 int dpni_reset(struct fsl_mc_io *mc_io,
135 /* DPNI IRQ Index and Events */
137 #define DPNI_IRQ_INDEX 0
139 /* DPNI_IRQ_EVENT_LINK_CHANGED - indicates a change in link state */
140 #define DPNI_IRQ_EVENT_LINK_CHANGED 0x00000001
142 /* DPNI_IRQ_EVENT_ENDPOINT_CHANGED - indicates a change in endpoint */
143 #define DPNI_IRQ_EVENT_ENDPOINT_CHANGED 0x00000002
145 int dpni_set_irq_enable(struct fsl_mc_io *mc_io,
151 int dpni_get_irq_enable(struct fsl_mc_io *mc_io,
157 int dpni_set_irq_mask(struct fsl_mc_io *mc_io,
163 int dpni_get_irq_mask(struct fsl_mc_io *mc_io,
169 int dpni_get_irq_status(struct fsl_mc_io *mc_io,
175 int dpni_clear_irq_status(struct fsl_mc_io *mc_io,
182 * struct dpni_attr - Structure representing DPNI attributes
183 * @options: Any combination of the following options:
184 * DPNI_OPT_TX_FRM_RELEASE
185 * DPNI_OPT_NO_MAC_FILTER
186 * DPNI_OPT_HAS_POLICING
187 * DPNI_OPT_SHARED_CONGESTION
188 * DPNI_OPT_HAS_KEY_MASKING
190 * @num_queues: Number of Tx and Rx queues used for traffic distribution.
191 * @num_tcs: Number of traffic classes (TCs), reserved for the DPNI.
192 * @mac_filter_entries: Number of entries in the MAC address filtering table.
193 * @vlan_filter_entries: Number of entries in the VLAN address filtering table.
194 * @qos_entries: Number of entries in the QoS classification table.
195 * @fs_entries: Number of entries in the flow steering table.
196 * @qos_key_size: Size, in bytes, of the QoS look-up key. Defining a key larger
197 * than this when adding QoS entries will result in an error.
198 * @fs_key_size: Size, in bytes, of the flow steering look-up key. Defining a
199 * key larger than this when composing the hash + FS key will
200 * result in an error.
201 * @wriop_version: Version of WRIOP HW block. The 3 version values are stored
202 * on 6, 5, 5 bits respectively.
208 u8 mac_filter_entries;
209 u8 vlan_filter_entries;
217 int dpni_get_attributes(struct fsl_mc_io *mc_io,
220 struct dpni_attr *attr);
225 * DPNI_ERROR_EOFHE - Extract out of frame header error
227 #define DPNI_ERROR_EOFHE 0x00020000
229 * DPNI_ERROR_FLE - Frame length error
231 #define DPNI_ERROR_FLE 0x00002000
233 * DPNI_ERROR_FPE - Frame physical error
235 #define DPNI_ERROR_FPE 0x00001000
237 * DPNI_ERROR_PHE - Parsing header error
239 #define DPNI_ERROR_PHE 0x00000020
241 * DPNI_ERROR_L3CE - Parser L3 checksum error
243 #define DPNI_ERROR_L3CE 0x00000004
245 * DPNI_ERROR_L4CE - Parser L3 checksum error
247 #define DPNI_ERROR_L4CE 0x00000001
250 * enum dpni_error_action - Defines DPNI behavior for errors
251 * @DPNI_ERROR_ACTION_DISCARD: Discard the frame
252 * @DPNI_ERROR_ACTION_CONTINUE: Continue with the normal flow
253 * @DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE: Send the frame to the error queue
255 enum dpni_error_action {
256 DPNI_ERROR_ACTION_DISCARD = 0,
257 DPNI_ERROR_ACTION_CONTINUE = 1,
258 DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE = 2
262 * struct dpni_error_cfg - Structure representing DPNI errors treatment
263 * @errors: Errors mask; use 'DPNI_ERROR__<X>
264 * @error_action: The desired action for the errors mask
265 * @set_frame_annotation: Set to '1' to mark the errors in frame annotation
266 * status (FAS); relevant only for the non-discard action
268 struct dpni_error_cfg {
270 enum dpni_error_action error_action;
271 int set_frame_annotation;
274 int dpni_set_errors_behavior(struct fsl_mc_io *mc_io,
277 struct dpni_error_cfg *cfg);
279 /* DPNI buffer layout modification options */
282 * DPNI_BUF_LAYOUT_OPT_TIMESTAMP - Select to modify the time-stamp setting
284 #define DPNI_BUF_LAYOUT_OPT_TIMESTAMP 0x00000001
286 * DPNI_BUF_LAYOUT_OPT_PARSER_RESULT - Select to modify the parser-result
287 * setting; not applicable for Tx
289 #define DPNI_BUF_LAYOUT_OPT_PARSER_RESULT 0x00000002
291 * DPNI_BUF_LAYOUT_OPT_FRAME_STATUS - Select to modify the frame-status setting
293 #define DPNI_BUF_LAYOUT_OPT_FRAME_STATUS 0x00000004
295 * DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE - Select to modify the private-data-size setting
297 #define DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE 0x00000008
299 * DPNI_BUF_LAYOUT_OPT_DATA_ALIGN - Select to modify the data-alignment setting
301 #define DPNI_BUF_LAYOUT_OPT_DATA_ALIGN 0x00000010
303 * DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM - Select to modify the data-head-room setting
305 #define DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM 0x00000020
307 * DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM - Select to modify the data-tail-room setting
309 #define DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM 0x00000040
312 * struct dpni_buffer_layout - Structure representing DPNI buffer layout
313 * @options: Flags representing the suggested modifications to the buffer
314 * layout; Use any combination of 'DPNI_BUF_LAYOUT_OPT_<X>' flags
315 * @pass_timestamp: Pass timestamp value
316 * @pass_parser_result: Pass parser results
317 * @pass_frame_status: Pass frame status
318 * @private_data_size: Size kept for private data (in bytes)
319 * @data_align: Data alignment
320 * @data_head_room: Data head room
321 * @data_tail_room: Data tail room
323 struct dpni_buffer_layout {
326 int pass_parser_result;
327 int pass_frame_status;
328 u16 private_data_size;
335 * enum dpni_queue_type - Identifies a type of queue targeted by the command
336 * @DPNI_QUEUE_RX: Rx queue
337 * @DPNI_QUEUE_TX: Tx queue
338 * @DPNI_QUEUE_TX_CONFIRM: Tx confirmation queue
339 * @DPNI_QUEUE_RX_ERR: Rx error queue
341 enum dpni_queue_type {
344 DPNI_QUEUE_TX_CONFIRM,
348 int dpni_get_buffer_layout(struct fsl_mc_io *mc_io,
351 enum dpni_queue_type qtype,
352 struct dpni_buffer_layout *layout);
354 int dpni_set_buffer_layout(struct fsl_mc_io *mc_io,
357 enum dpni_queue_type qtype,
358 const struct dpni_buffer_layout *layout);
361 * enum dpni_offload - Identifies a type of offload targeted by the command
362 * @DPNI_OFF_RX_L3_CSUM: Rx L3 checksum validation
363 * @DPNI_OFF_RX_L4_CSUM: Rx L4 checksum validation
364 * @DPNI_OFF_TX_L3_CSUM: Tx L3 checksum generation
365 * @DPNI_OFF_TX_L4_CSUM: Tx L4 checksum generation
374 int dpni_set_offload(struct fsl_mc_io *mc_io,
377 enum dpni_offload type,
380 int dpni_get_offload(struct fsl_mc_io *mc_io,
383 enum dpni_offload type,
386 int dpni_get_qdid(struct fsl_mc_io *mc_io,
389 enum dpni_queue_type qtype,
392 int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io,
397 #define DPNI_STATISTICS_CNT 7
400 * union dpni_statistics - Union describing the DPNI statistics
401 * @page_0: Page_0 statistics structure
402 * @page_0.ingress_all_frames: Ingress frame count
403 * @page_0.ingress_all_bytes: Ingress byte count
404 * @page_0.ingress_multicast_frames: Ingress multicast frame count
405 * @page_0.ingress_multicast_bytes: Ingress multicast byte count
406 * @page_0.ingress_broadcast_frames: Ingress broadcast frame count
407 * @page_0.ingress_broadcast_bytes: Ingress broadcast byte count
408 * @page_1: Page_1 statistics structure
409 * @page_1.egress_all_frames: Egress frame count
410 * @page_1.egress_all_bytes: Egress byte count
411 * @page_1.egress_multicast_frames: Egress multicast frame count
412 * @page_1.egress_multicast_bytes: Egress multicast byte count
413 * @page_1.egress_broadcast_frames: Egress broadcast frame count
414 * @page_1.egress_broadcast_bytes: Egress broadcast byte count
415 * @page_2: Page_2 statistics structure
416 * @page_2.ingress_filtered_frames: Ingress filtered frame count
417 * @page_2.ingress_discarded_frames: Ingress discarded frame count
418 * @page_2.ingress_nobuffer_discards: Ingress discarded frame count due to
420 * @page_2.egress_discarded_frames: Egress discarded frame count
421 * @page_2.egress_confirmed_frames: Egress confirmed frame count
422 * @page_3: Page_3 statistics structure
423 * @page_3.egress_dequeue_bytes: Cumulative count of the number of bytes
424 * dequeued from egress FQs
425 * @page_3.egress_dequeue_frames: Cumulative count of the number of frames
426 * dequeued from egress FQs
427 * @page_3.egress_reject_bytes: Cumulative count of the number of bytes in
428 * egress frames whose enqueue was rejected
429 * @page_3.egress_reject_frames: Cumulative count of the number of egress
430 * frames whose enqueue was rejected
431 * @page_4: Page_4 statistics structure: congestion points
432 * @page_4.cgr_reject_frames: number of rejected frames due to congestion point
433 * @page_4.cgr_reject_bytes: number of rejected bytes due to congestion point
434 * @page_5: Page_5 statistics structure: policer
435 * @page_5.policer_cnt_red: NUmber of red colored frames
436 * @page_5.policer_cnt_yellow: number of yellow colored frames
437 * @page_5.policer_cnt_green: number of green colored frames
438 * @page_5.policer_cnt_re_red: number of recolored red frames
439 * @page_5.policer_cnt_re_yellow: number of recolored yellow frames
440 * @page_6: Page_6 statistics structure
441 * @page_6.tx_pending_frames: total number of frames pending in egress FQs
442 * @raw: raw statistics structure, used to index counters
444 union dpni_statistics {
446 u64 ingress_all_frames;
447 u64 ingress_all_bytes;
448 u64 ingress_multicast_frames;
449 u64 ingress_multicast_bytes;
450 u64 ingress_broadcast_frames;
451 u64 ingress_broadcast_bytes;
454 u64 egress_all_frames;
455 u64 egress_all_bytes;
456 u64 egress_multicast_frames;
457 u64 egress_multicast_bytes;
458 u64 egress_broadcast_frames;
459 u64 egress_broadcast_bytes;
462 u64 ingress_filtered_frames;
463 u64 ingress_discarded_frames;
464 u64 ingress_nobuffer_discards;
465 u64 egress_discarded_frames;
466 u64 egress_confirmed_frames;
469 u64 egress_dequeue_bytes;
470 u64 egress_dequeue_frames;
471 u64 egress_reject_bytes;
472 u64 egress_reject_frames;
475 u64 cgr_reject_frames;
476 u64 cgr_reject_bytes;
480 u64 policer_cnt_yellow;
481 u64 policer_cnt_green;
482 u64 policer_cnt_re_red;
483 u64 policer_cnt_re_yellow;
486 u64 tx_pending_frames;
489 u64 counter[DPNI_STATISTICS_CNT];
493 int dpni_get_statistics(struct fsl_mc_io *mc_io,
497 union dpni_statistics *stat);
499 #define DPNI_LINK_OPT_AUTONEG 0x0000000000000001ULL
500 #define DPNI_LINK_OPT_HALF_DUPLEX 0x0000000000000002ULL
501 #define DPNI_LINK_OPT_PAUSE 0x0000000000000004ULL
502 #define DPNI_LINK_OPT_ASYM_PAUSE 0x0000000000000008ULL
503 #define DPNI_LINK_OPT_PFC_PAUSE 0x0000000000000010ULL
506 * struct dpni_link_cfg - Structure representing DPNI link configuration
508 * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
510 struct dpni_link_cfg {
515 int dpni_set_link_cfg(struct fsl_mc_io *mc_io,
518 const struct dpni_link_cfg *cfg);
520 int dpni_get_link_cfg(struct fsl_mc_io *mc_io,
523 struct dpni_link_cfg *cfg);
526 * struct dpni_link_state - Structure representing DPNI link state
528 * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
529 * @up: Link state; '0' for down, '1' for up
531 struct dpni_link_state {
537 int dpni_get_link_state(struct fsl_mc_io *mc_io,
540 struct dpni_link_state *state);
542 int dpni_set_max_frame_length(struct fsl_mc_io *mc_io,
545 u16 max_frame_length);
547 int dpni_get_max_frame_length(struct fsl_mc_io *mc_io,
550 u16 *max_frame_length);
552 int dpni_set_multicast_promisc(struct fsl_mc_io *mc_io,
557 int dpni_get_multicast_promisc(struct fsl_mc_io *mc_io,
562 int dpni_set_unicast_promisc(struct fsl_mc_io *mc_io,
567 int dpni_get_unicast_promisc(struct fsl_mc_io *mc_io,
572 int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
575 const u8 mac_addr[6]);
577 int dpni_get_primary_mac_addr(struct fsl_mc_io *mc_io,
582 int dpni_get_port_mac_addr(struct fsl_mc_io *mc_io,
587 int dpni_add_mac_addr(struct fsl_mc_io *mc_io,
590 const u8 mac_addr[6]);
592 int dpni_remove_mac_addr(struct fsl_mc_io *mc_io,
595 const u8 mac_addr[6]);
597 int dpni_clear_mac_filters(struct fsl_mc_io *mc_io,
604 * enum dpni_dist_mode - DPNI distribution mode
605 * @DPNI_DIST_MODE_NONE: No distribution
606 * @DPNI_DIST_MODE_HASH: Use hash distribution; only relevant if
607 * the 'DPNI_OPT_DIST_HASH' option was set at DPNI creation
608 * @DPNI_DIST_MODE_FS: Use explicit flow steering; only relevant if
609 * the 'DPNI_OPT_DIST_FS' option was set at DPNI creation
611 enum dpni_dist_mode {
612 DPNI_DIST_MODE_NONE = 0,
613 DPNI_DIST_MODE_HASH = 1,
614 DPNI_DIST_MODE_FS = 2
618 * enum dpni_fs_miss_action - DPNI Flow Steering miss action
619 * @DPNI_FS_MISS_DROP: In case of no-match, drop the frame
620 * @DPNI_FS_MISS_EXPLICIT_FLOWID: In case of no-match, use explicit flow-id
621 * @DPNI_FS_MISS_HASH: In case of no-match, distribute using hash
623 enum dpni_fs_miss_action {
624 DPNI_FS_MISS_DROP = 0,
625 DPNI_FS_MISS_EXPLICIT_FLOWID = 1,
626 DPNI_FS_MISS_HASH = 2
630 * struct dpni_fs_tbl_cfg - Flow Steering table configuration
631 * @miss_action: Miss action selection
632 * @default_flow_id: Used when 'miss_action = DPNI_FS_MISS_EXPLICIT_FLOWID'
634 struct dpni_fs_tbl_cfg {
635 enum dpni_fs_miss_action miss_action;
639 int dpni_prepare_key_cfg(const struct dpkg_profile_cfg *cfg,
643 * struct dpni_rx_tc_dist_cfg - Rx traffic class distribution configuration
644 * @dist_size: Set the distribution size;
645 * supported values: 1,2,3,4,6,7,8,12,14,16,24,28,32,48,56,64,96,
646 * 112,128,192,224,256,384,448,512,768,896,1024
647 * @dist_mode: Distribution mode
648 * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
649 * the extractions to be used for the distribution key by calling
650 * dpni_prepare_key_cfg() relevant only when
651 * 'dist_mode != DPNI_DIST_MODE_NONE', otherwise it can be '0'
652 * @fs_cfg: Flow Steering table configuration; only relevant if
653 * 'dist_mode = DPNI_DIST_MODE_FS'
655 struct dpni_rx_tc_dist_cfg {
657 enum dpni_dist_mode dist_mode;
659 struct dpni_fs_tbl_cfg fs_cfg;
662 int dpni_set_rx_tc_dist(struct fsl_mc_io *mc_io,
666 const struct dpni_rx_tc_dist_cfg *cfg);
669 * DPNI_FS_MISS_DROP - When used for fs_miss_flow_id in function
670 * dpni_set_rx_dist, will signal to dpni to drop all unclassified frames
672 #define DPNI_FS_MISS_DROP ((uint16_t)-1)
675 * struct dpni_rx_dist_cfg - Rx distribution configuration
676 * @dist_size: distribution size
677 * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
678 * the extractions to be used for the distribution key by calling
679 * dpni_prepare_key_cfg(); relevant only when enable!=0 otherwise
681 * @enable: enable/disable the distribution.
682 * @tc: TC id for which distribution is set
683 * @fs_miss_flow_id: when packet misses all rules from flow steering table and
684 * hash is disabled it will be put into this queue id; use
685 * DPNI_FS_MISS_DROP to drop frames. The value of this field is
686 * used only when flow steering distribution is enabled and hash
687 * distribution is disabled
689 struct dpni_rx_dist_cfg {
697 int dpni_set_rx_fs_dist(struct fsl_mc_io *mc_io,
700 const struct dpni_rx_dist_cfg *cfg);
702 int dpni_set_rx_hash_dist(struct fsl_mc_io *mc_io,
705 const struct dpni_rx_dist_cfg *cfg);
708 * struct dpni_qos_tbl_cfg - Structure representing QOS table configuration
709 * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
710 * key extractions to be used as the QoS criteria by calling
711 * dpkg_prepare_key_cfg()
712 * @discard_on_miss: Set to '1' to discard frames in case of no match (miss);
713 * '0' to use the 'default_tc' in such cases
714 * @default_tc: Used in case of no-match and 'discard_on_miss'= 0
716 struct dpni_qos_tbl_cfg {
722 int dpni_set_qos_table(struct fsl_mc_io *mc_io,
725 const struct dpni_qos_tbl_cfg *cfg);
728 * enum dpni_dest - DPNI destination types
729 * @DPNI_DEST_NONE: Unassigned destination; The queue is set in parked mode and
730 * does not generate FQDAN notifications; user is expected to
731 * dequeue from the queue based on polling or other user-defined
733 * @DPNI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
734 * notifications to the specified DPIO; user is expected to dequeue
735 * from the queue only after notification is received
736 * @DPNI_DEST_DPCON: The queue is set in schedule mode and does not generate
737 * FQDAN notifications, but is connected to the specified DPCON
738 * object; user is expected to dequeue from the DPCON channel
747 * struct dpni_queue - Queue structure
748 * @destination: - Destination structure
749 * @destination.id: ID of the destination, only relevant if DEST_TYPE is > 0.
750 * Identifies either a DPIO or a DPCON object.
751 * Not relevant for Tx queues.
752 * @destination.type: May be one of the following:
753 * 0 - No destination, queue can be manually
754 * queried, but will not push traffic or
755 * notifications to a DPIO;
756 * 1 - The destination is a DPIO. When traffic
757 * becomes available in the queue a FQDAN
758 * (FQ data available notification) will be
759 * generated to selected DPIO;
760 * 2 - The destination is a DPCON. The queue is
761 * associated with a DPCON object for the
762 * purpose of scheduling between multiple
763 * queues. The DPCON may be independently
764 * configured to generate notifications.
765 * Not relevant for Tx queues.
766 * @destination.hold_active: Hold active, maintains a queue scheduled for longer
767 * in a DPIO during dequeue to reduce spread of traffic.
768 * Only relevant if queues are
769 * not affined to a single DPIO.
770 * @user_context: User data, presented to the user along with any frames
771 * from this queue. Not relevant for Tx queues.
772 * @flc: FD FLow Context structure
773 * @flc.value: Default FLC value for traffic dequeued from
774 * this queue. Please check description of FD
775 * structure for more information.
776 * Note that FLC values set using dpni_add_fs_entry,
777 * if any, take precedence over values per queue.
778 * @flc.stash_control: Boolean, indicates whether the 6 lowest
779 * - significant bits are used for stash control.
780 * significant bits are used for stash control. If set, the 6
781 * least significant bits in value are interpreted as follows:
782 * - bits 0-1: indicates the number of 64 byte units of context
783 * that are stashed. FLC value is interpreted as a memory address
784 * in this case, excluding the 6 LS bits.
785 * - bits 2-3: indicates the number of 64 byte units of frame
786 * annotation to be stashed. Annotation is placed at FD[ADDR].
787 * - bits 4-5: indicates the number of 64 byte units of frame
788 * data to be stashed. Frame data is placed at FD[ADDR] +
790 * For more details check the Frame Descriptor section in the
791 * hardware documentation.
808 * struct dpni_queue_id - Queue identification, used for enqueue commands
810 * @fqid: FQID used for enqueueing to and/or configuration of this specific FQ
811 * @qdbin: Queueing bin, used to enqueue using QDID, DQBIN, QPRI. Only relevant
814 struct dpni_queue_id {
819 /* Set User Context */
820 #define DPNI_QUEUE_OPT_USER_CTX 0x00000001
821 #define DPNI_QUEUE_OPT_DEST 0x00000002
822 #define DPNI_QUEUE_OPT_FLC 0x00000004
823 #define DPNI_QUEUE_OPT_HOLD_ACTIVE 0x00000008
825 int dpni_set_queue(struct fsl_mc_io *mc_io,
828 enum dpni_queue_type qtype,
832 const struct dpni_queue *queue);
834 int dpni_get_queue(struct fsl_mc_io *mc_io,
837 enum dpni_queue_type qtype,
840 struct dpni_queue *queue,
841 struct dpni_queue_id *qid);
844 * enum dpni_congestion_unit - DPNI congestion units
845 * @DPNI_CONGESTION_UNIT_BYTES: bytes units
846 * @DPNI_CONGESTION_UNIT_FRAMES: frames units
848 enum dpni_congestion_unit {
849 DPNI_CONGESTION_UNIT_BYTES = 0,
850 DPNI_CONGESTION_UNIT_FRAMES
854 * enum dpni_congestion_point - Structure representing congestion point
855 * @DPNI_CP_QUEUE: Set taildrop per queue, identified by QUEUE_TYPE, TC and
857 * @DPNI_CP_GROUP: Set taildrop per queue group. Depending on options used to
858 * define the DPNI this can be either per TC (default) or per
859 * interface (DPNI_OPT_SHARED_CONGESTION set at DPNI create).
860 * QUEUE_INDEX is ignored if this type is used.
862 enum dpni_congestion_point {
868 * struct dpni_dest_cfg - Structure representing DPNI destination parameters
869 * @dest_type: Destination type
870 * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
871 * @priority: Priority selection within the DPIO or DPCON channel; valid
872 * values are 0-1 or 0-7, depending on the number of priorities
873 * in that channel; not relevant for 'DPNI_DEST_NONE' option
875 struct dpni_dest_cfg {
876 enum dpni_dest dest_type;
881 /* DPNI congestion options */
884 * DPNI_CONG_OPT_FLOW_CONTROL - This congestion will trigger flow control or
885 * priority flow control. This will have effect only if flow control is
886 * enabled with dpni_set_link_cfg().
888 #define DPNI_CONG_OPT_FLOW_CONTROL 0x00000040
891 * struct dpni_congestion_notification_cfg - congestion notification
894 * @threshold_entry: Above this threshold we enter a congestion state.
895 * set it to '0' to disable it
896 * @threshold_exit: Below this threshold we exit the congestion state.
897 * @message_ctx: The context that will be part of the CSCN message
898 * @message_iova: I/O virtual address (must be in DMA-able memory),
899 * must be 16B aligned; valid only if 'DPNI_CONG_OPT_WRITE_MEM_<X>'
900 * is contained in 'options'
901 * @dest_cfg: CSCN can be send to either DPIO or DPCON WQ channel
902 * @notification_mode: Mask of available options; use 'DPNI_CONG_OPT_<X>' values
905 struct dpni_congestion_notification_cfg {
906 enum dpni_congestion_unit units;
911 struct dpni_dest_cfg dest_cfg;
912 u16 notification_mode;
915 int dpni_set_congestion_notification(
916 struct fsl_mc_io *mc_io,
919 enum dpni_queue_type qtype,
921 const struct dpni_congestion_notification_cfg *cfg);
924 * struct dpni_taildrop - Structure representing the taildrop
925 * @enable: Indicates whether the taildrop is active or not.
926 * @units: Indicates the unit of THRESHOLD. Queue taildrop only supports
927 * byte units, this field is ignored and assumed = 0 if
928 * CONGESTION_POINT is 0.
929 * @threshold: Threshold value, in units identified by UNITS field. Value 0
930 * cannot be used as a valid taildrop threshold, THRESHOLD must
931 * be > 0 if the taildrop is enabled.
933 struct dpni_taildrop {
935 enum dpni_congestion_unit units;
939 int dpni_set_taildrop(struct fsl_mc_io *mc_io,
942 enum dpni_congestion_point cg_point,
943 enum dpni_queue_type q_type,
946 struct dpni_taildrop *taildrop);
948 int dpni_get_taildrop(struct fsl_mc_io *mc_io,
951 enum dpni_congestion_point cg_point,
952 enum dpni_queue_type q_type,
955 struct dpni_taildrop *taildrop);
958 * struct dpni_rule_cfg - Rule configuration for table lookup
959 * @key_iova: I/O virtual address of the key (must be in DMA-able memory)
960 * @mask_iova: I/O virtual address of the mask (must be in DMA-able memory)
961 * @key_size: key and mask size (in bytes)
963 struct dpni_rule_cfg {
970 * DPNI_FS_OPT_DISCARD - Discard matching traffic. If set, this takes
971 * precedence over any other configuration and matching traffic is always
974 #define DPNI_FS_OPT_DISCARD 0x1
977 * DPNI_FS_OPT_SET_FLC - Set FLC value. If set, flc member of struct
978 * dpni_fs_action_cfg is used to override the FLC value set per queue.
979 * For more details check the Frame Descriptor section in the hardware
982 #define DPNI_FS_OPT_SET_FLC 0x2
985 * DPNI_FS_OPT_SET_STASH_CONTROL - Indicates whether the 6 lowest significant
986 * bits of FLC are used for stash control. If set, the 6 least significant bits
987 * in value are interpreted as follows:
988 * - bits 0-1: indicates the number of 64 byte units of context that are
989 * stashed. FLC value is interpreted as a memory address in this case,
990 * excluding the 6 LS bits.
991 * - bits 2-3: indicates the number of 64 byte units of frame annotation
992 * to be stashed. Annotation is placed at FD[ADDR].
993 * - bits 4-5: indicates the number of 64 byte units of frame data to be
994 * stashed. Frame data is placed at FD[ADDR] + FD[OFFSET].
995 * This flag is ignored if DPNI_FS_OPT_SET_FLC is not specified.
997 #define DPNI_FS_OPT_SET_STASH_CONTROL 0x4
1000 * struct dpni_fs_action_cfg - Action configuration for table look-up
1001 * @flc: FLC value for traffic matching this rule. Please check the
1002 * Frame Descriptor section in the hardware documentation for
1004 * @flow_id: Identifies the Rx queue used for matching traffic. Supported
1005 * values are in range 0 to num_queue-1.
1006 * @options: Any combination of DPNI_FS_OPT_ values.
1008 struct dpni_fs_action_cfg {
1014 int dpni_add_fs_entry(struct fsl_mc_io *mc_io,
1019 const struct dpni_rule_cfg *cfg,
1020 const struct dpni_fs_action_cfg *action);
1022 int dpni_remove_fs_entry(struct fsl_mc_io *mc_io,
1026 const struct dpni_rule_cfg *cfg);
1028 int dpni_add_qos_entry(struct fsl_mc_io *mc_io,
1031 const struct dpni_rule_cfg *cfg,
1035 int dpni_remove_qos_entry(struct fsl_mc_io *mc_io,
1038 const struct dpni_rule_cfg *cfg);
1040 int dpni_clear_qos_table(struct fsl_mc_io *mc_io,
1044 int dpni_get_api_version(struct fsl_mc_io *mc_io,
1049 * struct dpni_tx_shaping_cfg - Structure representing DPNI tx shaping configuration
1050 * @rate_limit: Rate in Mbps
1051 * @max_burst_size: Burst size in bytes (up to 64KB)
1053 struct dpni_tx_shaping_cfg {
1058 int dpni_set_tx_shaping(struct fsl_mc_io *mc_io,
1061 const struct dpni_tx_shaping_cfg *tx_cr_shaper,
1062 const struct dpni_tx_shaping_cfg *tx_er_shaper,
1066 * struct dpni_single_step_cfg - configure single step PTP (IEEE 1588)
1067 * @en: enable single step PTP. When enabled the PTPv1 functionality
1068 * will not work. If the field is zero, offset and ch_update
1069 * parameters will be ignored
1070 * @offset: start offset from the beginning of the frame where
1071 * timestamp field is found. The offset must respect all MAC
1072 * headers, VLAN tags and other protocol headers
1073 * @ch_update: when set UDP checksum will be updated inside packet
1074 * @peer_delay: For peer-to-peer transparent clocks add this value to the
1075 * correction field in addition to the transient time update.
1076 * The value expresses nanoseconds.
1078 struct dpni_single_step_cfg {
1085 int dpni_set_single_step_cfg(struct fsl_mc_io *mc_io,
1088 struct dpni_single_step_cfg *ptp_cfg);
1090 int dpni_get_single_step_cfg(struct fsl_mc_io *mc_io,
1093 struct dpni_single_step_cfg *ptp_cfg);
1095 int dpni_enable_vlan_filter(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
1098 int dpni_add_vlan_id(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
1099 u16 vlan_id, u8 flags, u8 tc_id, u8 flow_id);
1101 int dpni_remove_vlan_id(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
1104 #endif /* __FSL_DPNI_H */