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,
95 #define DPNI_POOL_ASSOC_QPRI 0
96 #define DPNI_POOL_ASSOC_QDBIN 1
99 * struct dpni_pools_cfg - Structure representing buffer pools configuration
100 * @num_dpbp: Number of DPBPs
101 * @pool_options: Buffer assignment options.
102 * This field is a combination of DPNI_POOL_ASSOC_flags
103 * @pools: Array of buffer pools parameters; The number of valid entries
104 * must match 'num_dpbp' value
105 * @pools.dpbp_id: DPBP object ID
106 * @pools.priority: Priority mask that indicates TC's used with this buffer.
107 * If set to 0x00 MC will assume value 0xff.
108 * @pools.buffer_size: Buffer size
109 * @pools.backup_pool: Backup pool
111 struct dpni_pools_cfg {
119 } pools[DPNI_MAX_DPBP];
122 int dpni_set_pools(struct fsl_mc_io *mc_io,
125 const struct dpni_pools_cfg *cfg);
127 int dpni_enable(struct fsl_mc_io *mc_io,
131 int dpni_disable(struct fsl_mc_io *mc_io,
135 int dpni_is_enabled(struct fsl_mc_io *mc_io,
140 int dpni_reset(struct fsl_mc_io *mc_io,
144 /* DPNI IRQ Index and Events */
146 #define DPNI_IRQ_INDEX 0
148 /* DPNI_IRQ_EVENT_LINK_CHANGED - indicates a change in link state */
149 #define DPNI_IRQ_EVENT_LINK_CHANGED 0x00000001
151 /* DPNI_IRQ_EVENT_ENDPOINT_CHANGED - indicates a change in endpoint */
152 #define DPNI_IRQ_EVENT_ENDPOINT_CHANGED 0x00000002
154 int dpni_set_irq_enable(struct fsl_mc_io *mc_io,
160 int dpni_get_irq_enable(struct fsl_mc_io *mc_io,
166 int dpni_set_irq_mask(struct fsl_mc_io *mc_io,
172 int dpni_get_irq_mask(struct fsl_mc_io *mc_io,
178 int dpni_get_irq_status(struct fsl_mc_io *mc_io,
184 int dpni_clear_irq_status(struct fsl_mc_io *mc_io,
191 * struct dpni_attr - Structure representing DPNI attributes
192 * @options: Any combination of the following options:
193 * DPNI_OPT_TX_FRM_RELEASE
194 * DPNI_OPT_NO_MAC_FILTER
195 * DPNI_OPT_HAS_POLICING
196 * DPNI_OPT_SHARED_CONGESTION
197 * DPNI_OPT_HAS_KEY_MASKING
199 * @num_queues: Number of Tx and Rx queues used for traffic distribution.
200 * @num_tcs: Number of traffic classes (TCs), reserved for the DPNI.
201 * @mac_filter_entries: Number of entries in the MAC address filtering table.
202 * @vlan_filter_entries: Number of entries in the VLAN address filtering table.
203 * @qos_entries: Number of entries in the QoS classification table.
204 * @fs_entries: Number of entries in the flow steering table.
205 * @qos_key_size: Size, in bytes, of the QoS look-up key. Defining a key larger
206 * than this when adding QoS entries will result in an error.
207 * @fs_key_size: Size, in bytes, of the flow steering look-up key. Defining a
208 * key larger than this when composing the hash + FS key will
209 * result in an error.
210 * @wriop_version: Version of WRIOP HW block. The 3 version values are stored
211 * on 6, 5, 5 bits respectively.
217 u8 mac_filter_entries;
218 u8 vlan_filter_entries;
226 int dpni_get_attributes(struct fsl_mc_io *mc_io,
229 struct dpni_attr *attr);
234 * DPNI_ERROR_EOFHE - Extract out of frame header error
236 #define DPNI_ERROR_EOFHE 0x00020000
238 * DPNI_ERROR_FLE - Frame length error
240 #define DPNI_ERROR_FLE 0x00002000
242 * DPNI_ERROR_FPE - Frame physical error
244 #define DPNI_ERROR_FPE 0x00001000
246 * DPNI_ERROR_PHE - Parsing header error
248 #define DPNI_ERROR_PHE 0x00000020
250 * DPNI_ERROR_L3CE - Parser L3 checksum error
252 #define DPNI_ERROR_L3CE 0x00000004
254 * DPNI_ERROR_L4CE - Parser L3 checksum error
256 #define DPNI_ERROR_L4CE 0x00000001
259 * enum dpni_error_action - Defines DPNI behavior for errors
260 * @DPNI_ERROR_ACTION_DISCARD: Discard the frame
261 * @DPNI_ERROR_ACTION_CONTINUE: Continue with the normal flow
262 * @DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE: Send the frame to the error queue
264 enum dpni_error_action {
265 DPNI_ERROR_ACTION_DISCARD = 0,
266 DPNI_ERROR_ACTION_CONTINUE = 1,
267 DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE = 2
271 * struct dpni_error_cfg - Structure representing DPNI errors treatment
272 * @errors: Errors mask; use 'DPNI_ERROR__<X>
273 * @error_action: The desired action for the errors mask
274 * @set_frame_annotation: Set to '1' to mark the errors in frame annotation
275 * status (FAS); relevant only for the non-discard action
277 struct dpni_error_cfg {
279 enum dpni_error_action error_action;
280 int set_frame_annotation;
283 int dpni_set_errors_behavior(struct fsl_mc_io *mc_io,
286 struct dpni_error_cfg *cfg);
288 /* DPNI buffer layout modification options */
291 * DPNI_BUF_LAYOUT_OPT_TIMESTAMP - Select to modify the time-stamp setting
293 #define DPNI_BUF_LAYOUT_OPT_TIMESTAMP 0x00000001
295 * DPNI_BUF_LAYOUT_OPT_PARSER_RESULT - Select to modify the parser-result
296 * setting; not applicable for Tx
298 #define DPNI_BUF_LAYOUT_OPT_PARSER_RESULT 0x00000002
300 * DPNI_BUF_LAYOUT_OPT_FRAME_STATUS - Select to modify the frame-status setting
302 #define DPNI_BUF_LAYOUT_OPT_FRAME_STATUS 0x00000004
304 * DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE - Select to modify the private-data-size setting
306 #define DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE 0x00000008
308 * DPNI_BUF_LAYOUT_OPT_DATA_ALIGN - Select to modify the data-alignment setting
310 #define DPNI_BUF_LAYOUT_OPT_DATA_ALIGN 0x00000010
312 * DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM - Select to modify the data-head-room setting
314 #define DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM 0x00000020
316 * DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM - Select to modify the data-tail-room setting
318 #define DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM 0x00000040
321 * struct dpni_buffer_layout - Structure representing DPNI buffer layout
322 * @options: Flags representing the suggested modifications to the buffer
323 * layout; Use any combination of 'DPNI_BUF_LAYOUT_OPT_<X>' flags
324 * @pass_timestamp: Pass timestamp value
325 * @pass_parser_result: Pass parser results
326 * @pass_frame_status: Pass frame status
327 * @private_data_size: Size kept for private data (in bytes)
328 * @data_align: Data alignment
329 * @data_head_room: Data head room
330 * @data_tail_room: Data tail room
332 struct dpni_buffer_layout {
335 int pass_parser_result;
336 int pass_frame_status;
337 u16 private_data_size;
344 * enum dpni_queue_type - Identifies a type of queue targeted by the command
345 * @DPNI_QUEUE_RX: Rx queue
346 * @DPNI_QUEUE_TX: Tx queue
347 * @DPNI_QUEUE_TX_CONFIRM: Tx confirmation queue
348 * @DPNI_QUEUE_RX_ERR: Rx error queue
350 enum dpni_queue_type {
353 DPNI_QUEUE_TX_CONFIRM,
357 int dpni_get_buffer_layout(struct fsl_mc_io *mc_io,
360 enum dpni_queue_type qtype,
361 struct dpni_buffer_layout *layout);
363 int dpni_set_buffer_layout(struct fsl_mc_io *mc_io,
366 enum dpni_queue_type qtype,
367 const struct dpni_buffer_layout *layout);
370 * enum dpni_offload - Identifies a type of offload targeted by the command
371 * @DPNI_OFF_RX_L3_CSUM: Rx L3 checksum validation
372 * @DPNI_OFF_RX_L4_CSUM: Rx L4 checksum validation
373 * @DPNI_OFF_TX_L3_CSUM: Tx L3 checksum generation
374 * @DPNI_OFF_TX_L4_CSUM: Tx L4 checksum generation
383 int dpni_set_offload(struct fsl_mc_io *mc_io,
386 enum dpni_offload type,
389 int dpni_get_offload(struct fsl_mc_io *mc_io,
392 enum dpni_offload type,
395 int dpni_get_qdid(struct fsl_mc_io *mc_io,
398 enum dpni_queue_type qtype,
401 int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io,
406 #define DPNI_STATISTICS_CNT 7
409 * union dpni_statistics - Union describing the DPNI statistics
410 * @page_0: Page_0 statistics structure
411 * @page_0.ingress_all_frames: Ingress frame count
412 * @page_0.ingress_all_bytes: Ingress byte count
413 * @page_0.ingress_multicast_frames: Ingress multicast frame count
414 * @page_0.ingress_multicast_bytes: Ingress multicast byte count
415 * @page_0.ingress_broadcast_frames: Ingress broadcast frame count
416 * @page_0.ingress_broadcast_bytes: Ingress broadcast byte count
417 * @page_1: Page_1 statistics structure
418 * @page_1.egress_all_frames: Egress frame count
419 * @page_1.egress_all_bytes: Egress byte count
420 * @page_1.egress_multicast_frames: Egress multicast frame count
421 * @page_1.egress_multicast_bytes: Egress multicast byte count
422 * @page_1.egress_broadcast_frames: Egress broadcast frame count
423 * @page_1.egress_broadcast_bytes: Egress broadcast byte count
424 * @page_2: Page_2 statistics structure
425 * @page_2.ingress_filtered_frames: Ingress filtered frame count
426 * @page_2.ingress_discarded_frames: Ingress discarded frame count
427 * @page_2.ingress_nobuffer_discards: Ingress discarded frame count due to
429 * @page_2.egress_discarded_frames: Egress discarded frame count
430 * @page_2.egress_confirmed_frames: Egress confirmed frame count
431 * @page_3: Page_3 statistics structure
432 * @page_3.egress_dequeue_bytes: Cumulative count of the number of bytes
433 * dequeued from egress FQs
434 * @page_3.egress_dequeue_frames: Cumulative count of the number of frames
435 * dequeued from egress FQs
436 * @page_3.egress_reject_bytes: Cumulative count of the number of bytes in
437 * egress frames whose enqueue was rejected
438 * @page_3.egress_reject_frames: Cumulative count of the number of egress
439 * frames whose enqueue was rejected
440 * @page_4: Page_4 statistics structure: congestion points
441 * @page_4.cgr_reject_frames: number of rejected frames due to congestion point
442 * @page_4.cgr_reject_bytes: number of rejected bytes due to congestion point
443 * @page_5: Page_5 statistics structure: policer
444 * @page_5.policer_cnt_red: NUmber of red colored frames
445 * @page_5.policer_cnt_yellow: number of yellow colored frames
446 * @page_5.policer_cnt_green: number of green colored frames
447 * @page_5.policer_cnt_re_red: number of recolored red frames
448 * @page_5.policer_cnt_re_yellow: number of recolored yellow frames
449 * @page_6: Page_6 statistics structure
450 * @page_6.tx_pending_frames: total number of frames pending in egress FQs
451 * @raw: raw statistics structure, used to index counters
453 union dpni_statistics {
455 u64 ingress_all_frames;
456 u64 ingress_all_bytes;
457 u64 ingress_multicast_frames;
458 u64 ingress_multicast_bytes;
459 u64 ingress_broadcast_frames;
460 u64 ingress_broadcast_bytes;
463 u64 egress_all_frames;
464 u64 egress_all_bytes;
465 u64 egress_multicast_frames;
466 u64 egress_multicast_bytes;
467 u64 egress_broadcast_frames;
468 u64 egress_broadcast_bytes;
471 u64 ingress_filtered_frames;
472 u64 ingress_discarded_frames;
473 u64 ingress_nobuffer_discards;
474 u64 egress_discarded_frames;
475 u64 egress_confirmed_frames;
478 u64 egress_dequeue_bytes;
479 u64 egress_dequeue_frames;
480 u64 egress_reject_bytes;
481 u64 egress_reject_frames;
484 u64 cgr_reject_frames;
485 u64 cgr_reject_bytes;
489 u64 policer_cnt_yellow;
490 u64 policer_cnt_green;
491 u64 policer_cnt_re_red;
492 u64 policer_cnt_re_yellow;
495 u64 tx_pending_frames;
498 u64 counter[DPNI_STATISTICS_CNT];
502 int dpni_get_statistics(struct fsl_mc_io *mc_io,
506 union dpni_statistics *stat);
508 #define DPNI_LINK_OPT_AUTONEG 0x0000000000000001ULL
509 #define DPNI_LINK_OPT_HALF_DUPLEX 0x0000000000000002ULL
510 #define DPNI_LINK_OPT_PAUSE 0x0000000000000004ULL
511 #define DPNI_LINK_OPT_ASYM_PAUSE 0x0000000000000008ULL
512 #define DPNI_LINK_OPT_PFC_PAUSE 0x0000000000000010ULL
515 * struct dpni_link_cfg - Structure representing DPNI link configuration
517 * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
519 struct dpni_link_cfg {
524 int dpni_set_link_cfg(struct fsl_mc_io *mc_io,
527 const struct dpni_link_cfg *cfg);
529 int dpni_get_link_cfg(struct fsl_mc_io *mc_io,
532 struct dpni_link_cfg *cfg);
535 * struct dpni_link_state - Structure representing DPNI link state
537 * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
538 * @up: Link state; '0' for down, '1' for up
540 struct dpni_link_state {
546 int dpni_get_link_state(struct fsl_mc_io *mc_io,
549 struct dpni_link_state *state);
551 int dpni_set_max_frame_length(struct fsl_mc_io *mc_io,
554 u16 max_frame_length);
556 int dpni_get_max_frame_length(struct fsl_mc_io *mc_io,
559 u16 *max_frame_length);
561 int dpni_set_multicast_promisc(struct fsl_mc_io *mc_io,
566 int dpni_get_multicast_promisc(struct fsl_mc_io *mc_io,
571 int dpni_set_unicast_promisc(struct fsl_mc_io *mc_io,
576 int dpni_get_unicast_promisc(struct fsl_mc_io *mc_io,
581 int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
584 const u8 mac_addr[6]);
586 int dpni_get_primary_mac_addr(struct fsl_mc_io *mc_io,
591 int dpni_get_port_mac_addr(struct fsl_mc_io *mc_io,
596 int dpni_add_mac_addr(struct fsl_mc_io *mc_io,
599 const u8 mac_addr[6]);
601 int dpni_remove_mac_addr(struct fsl_mc_io *mc_io,
604 const u8 mac_addr[6]);
606 int dpni_clear_mac_filters(struct fsl_mc_io *mc_io,
613 * enum dpni_dist_mode - DPNI distribution mode
614 * @DPNI_DIST_MODE_NONE: No distribution
615 * @DPNI_DIST_MODE_HASH: Use hash distribution; only relevant if
616 * the 'DPNI_OPT_DIST_HASH' option was set at DPNI creation
617 * @DPNI_DIST_MODE_FS: Use explicit flow steering; only relevant if
618 * the 'DPNI_OPT_DIST_FS' option was set at DPNI creation
620 enum dpni_dist_mode {
621 DPNI_DIST_MODE_NONE = 0,
622 DPNI_DIST_MODE_HASH = 1,
623 DPNI_DIST_MODE_FS = 2
627 * enum dpni_fs_miss_action - DPNI Flow Steering miss action
628 * @DPNI_FS_MISS_DROP: In case of no-match, drop the frame
629 * @DPNI_FS_MISS_EXPLICIT_FLOWID: In case of no-match, use explicit flow-id
630 * @DPNI_FS_MISS_HASH: In case of no-match, distribute using hash
632 enum dpni_fs_miss_action {
633 DPNI_FS_MISS_DROP = 0,
634 DPNI_FS_MISS_EXPLICIT_FLOWID = 1,
635 DPNI_FS_MISS_HASH = 2
639 * struct dpni_fs_tbl_cfg - Flow Steering table configuration
640 * @miss_action: Miss action selection
641 * @default_flow_id: Used when 'miss_action = DPNI_FS_MISS_EXPLICIT_FLOWID'
643 struct dpni_fs_tbl_cfg {
644 enum dpni_fs_miss_action miss_action;
648 int dpni_prepare_key_cfg(const struct dpkg_profile_cfg *cfg,
652 * struct dpni_rx_tc_dist_cfg - Rx traffic class distribution configuration
653 * @dist_size: Set the distribution size;
654 * supported values: 1,2,3,4,6,7,8,12,14,16,24,28,32,48,56,64,96,
655 * 112,128,192,224,256,384,448,512,768,896,1024
656 * @dist_mode: Distribution mode
657 * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
658 * the extractions to be used for the distribution key by calling
659 * dpni_prepare_key_cfg() relevant only when
660 * 'dist_mode != DPNI_DIST_MODE_NONE', otherwise it can be '0'
661 * @fs_cfg: Flow Steering table configuration; only relevant if
662 * 'dist_mode = DPNI_DIST_MODE_FS'
664 struct dpni_rx_tc_dist_cfg {
666 enum dpni_dist_mode dist_mode;
668 struct dpni_fs_tbl_cfg fs_cfg;
671 int dpni_set_rx_tc_dist(struct fsl_mc_io *mc_io,
675 const struct dpni_rx_tc_dist_cfg *cfg);
678 * DPNI_FS_MISS_DROP - When used for fs_miss_flow_id in function
679 * dpni_set_rx_dist, will signal to dpni to drop all unclassified frames
681 #define DPNI_FS_MISS_DROP ((uint16_t)-1)
684 * struct dpni_rx_dist_cfg - Rx distribution configuration
685 * @dist_size: distribution size
686 * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
687 * the extractions to be used for the distribution key by calling
688 * dpni_prepare_key_cfg(); relevant only when enable!=0 otherwise
690 * @enable: enable/disable the distribution.
691 * @tc: TC id for which distribution is set
692 * @fs_miss_flow_id: when packet misses all rules from flow steering table and
693 * hash is disabled it will be put into this queue id; use
694 * DPNI_FS_MISS_DROP to drop frames. The value of this field is
695 * used only when flow steering distribution is enabled and hash
696 * distribution is disabled
698 struct dpni_rx_dist_cfg {
706 int dpni_set_rx_fs_dist(struct fsl_mc_io *mc_io,
709 const struct dpni_rx_dist_cfg *cfg);
711 int dpni_set_rx_hash_dist(struct fsl_mc_io *mc_io,
714 const struct dpni_rx_dist_cfg *cfg);
717 * struct dpni_qos_tbl_cfg - Structure representing QOS table configuration
718 * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
719 * key extractions to be used as the QoS criteria by calling
720 * dpkg_prepare_key_cfg()
721 * @discard_on_miss: Set to '1' to discard frames in case of no match (miss);
722 * '0' to use the 'default_tc' in such cases
723 * @default_tc: Used in case of no-match and 'discard_on_miss'= 0
725 struct dpni_qos_tbl_cfg {
731 int dpni_set_qos_table(struct fsl_mc_io *mc_io,
734 const struct dpni_qos_tbl_cfg *cfg);
737 * enum dpni_dest - DPNI destination types
738 * @DPNI_DEST_NONE: Unassigned destination; The queue is set in parked mode and
739 * does not generate FQDAN notifications; user is expected to
740 * dequeue from the queue based on polling or other user-defined
742 * @DPNI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
743 * notifications to the specified DPIO; user is expected to dequeue
744 * from the queue only after notification is received
745 * @DPNI_DEST_DPCON: The queue is set in schedule mode and does not generate
746 * FQDAN notifications, but is connected to the specified DPCON
747 * object; user is expected to dequeue from the DPCON channel
756 * struct dpni_queue - Queue structure
757 * @destination: - Destination structure
758 * @destination.id: ID of the destination, only relevant if DEST_TYPE is > 0.
759 * Identifies either a DPIO or a DPCON object.
760 * Not relevant for Tx queues.
761 * @destination.type: May be one of the following:
762 * 0 - No destination, queue can be manually
763 * queried, but will not push traffic or
764 * notifications to a DPIO;
765 * 1 - The destination is a DPIO. When traffic
766 * becomes available in the queue a FQDAN
767 * (FQ data available notification) will be
768 * generated to selected DPIO;
769 * 2 - The destination is a DPCON. The queue is
770 * associated with a DPCON object for the
771 * purpose of scheduling between multiple
772 * queues. The DPCON may be independently
773 * configured to generate notifications.
774 * Not relevant for Tx queues.
775 * @destination.hold_active: Hold active, maintains a queue scheduled for longer
776 * in a DPIO during dequeue to reduce spread of traffic.
777 * Only relevant if queues are
778 * not affined to a single DPIO.
779 * @user_context: User data, presented to the user along with any frames
780 * from this queue. Not relevant for Tx queues.
781 * @flc: FD FLow Context structure
782 * @flc.value: Default FLC value for traffic dequeued from
783 * this queue. Please check description of FD
784 * structure for more information.
785 * Note that FLC values set using dpni_add_fs_entry,
786 * if any, take precedence over values per queue.
787 * @flc.stash_control: Boolean, indicates whether the 6 lowest
788 * - significant bits are used for stash control.
789 * significant bits are used for stash control. If set, the 6
790 * least significant bits in value are interpreted as follows:
791 * - bits 0-1: indicates the number of 64 byte units of context
792 * that are stashed. FLC value is interpreted as a memory address
793 * in this case, excluding the 6 LS bits.
794 * - bits 2-3: indicates the number of 64 byte units of frame
795 * annotation to be stashed. Annotation is placed at FD[ADDR].
796 * - bits 4-5: indicates the number of 64 byte units of frame
797 * data to be stashed. Frame data is placed at FD[ADDR] +
799 * For more details check the Frame Descriptor section in the
800 * hardware documentation.
817 * struct dpni_queue_id - Queue identification, used for enqueue commands
819 * @fqid: FQID used for enqueueing to and/or configuration of this specific FQ
820 * @qdbin: Queueing bin, used to enqueue using QDID, DQBIN, QPRI. Only relevant
823 struct dpni_queue_id {
828 /* Set User Context */
829 #define DPNI_QUEUE_OPT_USER_CTX 0x00000001
830 #define DPNI_QUEUE_OPT_DEST 0x00000002
831 #define DPNI_QUEUE_OPT_FLC 0x00000004
832 #define DPNI_QUEUE_OPT_HOLD_ACTIVE 0x00000008
834 int dpni_set_queue(struct fsl_mc_io *mc_io,
837 enum dpni_queue_type qtype,
841 const struct dpni_queue *queue);
843 int dpni_get_queue(struct fsl_mc_io *mc_io,
846 enum dpni_queue_type qtype,
849 struct dpni_queue *queue,
850 struct dpni_queue_id *qid);
853 * enum dpni_congestion_unit - DPNI congestion units
854 * @DPNI_CONGESTION_UNIT_BYTES: bytes units
855 * @DPNI_CONGESTION_UNIT_FRAMES: frames units
857 enum dpni_congestion_unit {
858 DPNI_CONGESTION_UNIT_BYTES = 0,
859 DPNI_CONGESTION_UNIT_FRAMES
863 * enum dpni_congestion_point - Structure representing congestion point
864 * @DPNI_CP_QUEUE: Set taildrop per queue, identified by QUEUE_TYPE, TC and
866 * @DPNI_CP_GROUP: Set taildrop per queue group. Depending on options used to
867 * define the DPNI this can be either per TC (default) or per
868 * interface (DPNI_OPT_SHARED_CONGESTION set at DPNI create).
869 * QUEUE_INDEX is ignored if this type is used.
871 enum dpni_congestion_point {
877 * struct dpni_dest_cfg - Structure representing DPNI destination parameters
878 * @dest_type: Destination type
879 * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
880 * @priority: Priority selection within the DPIO or DPCON channel; valid
881 * values are 0-1 or 0-7, depending on the number of priorities
882 * in that channel; not relevant for 'DPNI_DEST_NONE' option
884 struct dpni_dest_cfg {
885 enum dpni_dest dest_type;
890 /* DPNI congestion options */
893 * DPNI_CONG_OPT_FLOW_CONTROL - This congestion will trigger flow control or
894 * priority flow control. This will have effect only if flow control is
895 * enabled with dpni_set_link_cfg().
897 #define DPNI_CONG_OPT_FLOW_CONTROL 0x00000040
900 * struct dpni_congestion_notification_cfg - congestion notification
903 * @threshold_entry: Above this threshold we enter a congestion state.
904 * set it to '0' to disable it
905 * @threshold_exit: Below this threshold we exit the congestion state.
906 * @message_ctx: The context that will be part of the CSCN message
907 * @message_iova: I/O virtual address (must be in DMA-able memory),
908 * must be 16B aligned; valid only if 'DPNI_CONG_OPT_WRITE_MEM_<X>'
909 * is contained in 'options'
910 * @dest_cfg: CSCN can be send to either DPIO or DPCON WQ channel
911 * @notification_mode: Mask of available options; use 'DPNI_CONG_OPT_<X>' values
914 struct dpni_congestion_notification_cfg {
915 enum dpni_congestion_unit units;
920 struct dpni_dest_cfg dest_cfg;
921 u16 notification_mode;
924 int dpni_set_congestion_notification(
925 struct fsl_mc_io *mc_io,
928 enum dpni_queue_type qtype,
930 const struct dpni_congestion_notification_cfg *cfg);
933 * struct dpni_taildrop - Structure representing the taildrop
934 * @enable: Indicates whether the taildrop is active or not.
935 * @units: Indicates the unit of THRESHOLD. Queue taildrop only supports
936 * byte units, this field is ignored and assumed = 0 if
937 * CONGESTION_POINT is 0.
938 * @threshold: Threshold value, in units identified by UNITS field. Value 0
939 * cannot be used as a valid taildrop threshold, THRESHOLD must
940 * be > 0 if the taildrop is enabled.
942 struct dpni_taildrop {
944 enum dpni_congestion_unit units;
948 int dpni_set_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);
957 int dpni_get_taildrop(struct fsl_mc_io *mc_io,
960 enum dpni_congestion_point cg_point,
961 enum dpni_queue_type q_type,
964 struct dpni_taildrop *taildrop);
967 * struct dpni_rule_cfg - Rule configuration for table lookup
968 * @key_iova: I/O virtual address of the key (must be in DMA-able memory)
969 * @mask_iova: I/O virtual address of the mask (must be in DMA-able memory)
970 * @key_size: key and mask size (in bytes)
972 struct dpni_rule_cfg {
979 * DPNI_FS_OPT_DISCARD - Discard matching traffic. If set, this takes
980 * precedence over any other configuration and matching traffic is always
983 #define DPNI_FS_OPT_DISCARD 0x1
986 * DPNI_FS_OPT_SET_FLC - Set FLC value. If set, flc member of struct
987 * dpni_fs_action_cfg is used to override the FLC value set per queue.
988 * For more details check the Frame Descriptor section in the hardware
991 #define DPNI_FS_OPT_SET_FLC 0x2
994 * DPNI_FS_OPT_SET_STASH_CONTROL - Indicates whether the 6 lowest significant
995 * bits of FLC are used for stash control. If set, the 6 least significant bits
996 * in value are interpreted as follows:
997 * - bits 0-1: indicates the number of 64 byte units of context that are
998 * stashed. FLC value is interpreted as a memory address in this case,
999 * excluding the 6 LS bits.
1000 * - bits 2-3: indicates the number of 64 byte units of frame annotation
1001 * to be stashed. Annotation is placed at FD[ADDR].
1002 * - bits 4-5: indicates the number of 64 byte units of frame data to be
1003 * stashed. Frame data is placed at FD[ADDR] + FD[OFFSET].
1004 * This flag is ignored if DPNI_FS_OPT_SET_FLC is not specified.
1006 #define DPNI_FS_OPT_SET_STASH_CONTROL 0x4
1009 * struct dpni_fs_action_cfg - Action configuration for table look-up
1010 * @flc: FLC value for traffic matching this rule. Please check the
1011 * Frame Descriptor section in the hardware documentation for
1013 * @flow_id: Identifies the Rx queue used for matching traffic. Supported
1014 * values are in range 0 to num_queue-1.
1015 * @options: Any combination of DPNI_FS_OPT_ values.
1017 struct dpni_fs_action_cfg {
1023 int dpni_add_fs_entry(struct fsl_mc_io *mc_io,
1028 const struct dpni_rule_cfg *cfg,
1029 const struct dpni_fs_action_cfg *action);
1031 int dpni_remove_fs_entry(struct fsl_mc_io *mc_io,
1035 const struct dpni_rule_cfg *cfg);
1037 int dpni_add_qos_entry(struct fsl_mc_io *mc_io,
1040 const struct dpni_rule_cfg *cfg,
1044 int dpni_remove_qos_entry(struct fsl_mc_io *mc_io,
1047 const struct dpni_rule_cfg *cfg);
1049 int dpni_clear_qos_table(struct fsl_mc_io *mc_io,
1053 int dpni_get_api_version(struct fsl_mc_io *mc_io,
1058 * struct dpni_tx_shaping_cfg - Structure representing DPNI tx shaping configuration
1059 * @rate_limit: Rate in Mbps
1060 * @max_burst_size: Burst size in bytes (up to 64KB)
1062 struct dpni_tx_shaping_cfg {
1067 int dpni_set_tx_shaping(struct fsl_mc_io *mc_io,
1070 const struct dpni_tx_shaping_cfg *tx_cr_shaper,
1071 const struct dpni_tx_shaping_cfg *tx_er_shaper,
1075 * struct dpni_single_step_cfg - configure single step PTP (IEEE 1588)
1076 * @en: enable single step PTP. When enabled the PTPv1 functionality
1077 * will not work. If the field is zero, offset and ch_update
1078 * parameters will be ignored
1079 * @offset: start offset from the beginning of the frame where
1080 * timestamp field is found. The offset must respect all MAC
1081 * headers, VLAN tags and other protocol headers
1082 * @ch_update: when set UDP checksum will be updated inside packet
1083 * @peer_delay: For peer-to-peer transparent clocks add this value to the
1084 * correction field in addition to the transient time update.
1085 * The value expresses nanoseconds.
1086 * @ptp_onestep_reg_base: 1588 SINGLE_STEP register base address. This address
1087 * is used to update directly the register contents.
1088 * User has to create an address mapping for it.
1092 struct dpni_single_step_cfg {
1097 u32 ptp_onestep_reg_base;
1100 int dpni_set_single_step_cfg(struct fsl_mc_io *mc_io,
1103 struct dpni_single_step_cfg *ptp_cfg);
1105 int dpni_get_single_step_cfg(struct fsl_mc_io *mc_io,
1108 struct dpni_single_step_cfg *ptp_cfg);
1110 int dpni_enable_vlan_filter(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
1113 int dpni_add_vlan_id(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
1114 u16 vlan_id, u8 flags, u8 tc_id, u8 flow_id);
1116 int dpni_remove_vlan_id(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
1119 #endif /* __FSL_DPNI_H */