1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
3 * Copyright 2013-2016 Freescale Semiconductor Inc.
4 * Copyright 2016-2021 NXP
7 #ifndef _FSL_DPNI_CMD_H
8 #define _FSL_DPNI_CMD_H
11 #define DPNI_VER_MAJOR 8
12 #define DPNI_VER_MINOR 0
14 #define DPNI_CMD_BASE_VERSION 1
15 #define DPNI_CMD_VERSION_2 2
16 #define DPNI_CMD_VERSION_3 3
17 #define DPNI_CMD_VERSION_4 4
18 #define DPNI_CMD_VERSION_5 5
19 #define DPNI_CMD_VERSION_6 6
20 #define DPNI_CMD_ID_OFFSET 4
22 #define DPNI_CMD(id) (((id) << DPNI_CMD_ID_OFFSET) | DPNI_CMD_BASE_VERSION)
23 #define DPNI_CMD_V2(id) (((id) << DPNI_CMD_ID_OFFSET) | DPNI_CMD_VERSION_2)
24 #define DPNI_CMD_V3(id) (((id) << DPNI_CMD_ID_OFFSET) | DPNI_CMD_VERSION_3)
25 #define DPNI_CMD_V4(id) (((id) << DPNI_CMD_ID_OFFSET) | DPNI_CMD_VERSION_4)
26 #define DPNI_CMD_V5(id) (((id) << DPNI_CMD_ID_OFFSET) | DPNI_CMD_VERSION_5)
27 #define DPNI_CMD_V6(id) (((id) << DPNI_CMD_ID_OFFSET) | DPNI_CMD_VERSION_6)
30 #define DPNI_CMDID_OPEN DPNI_CMD(0x801)
31 #define DPNI_CMDID_CLOSE DPNI_CMD(0x800)
32 #define DPNI_CMDID_CREATE DPNI_CMD_V6(0x901)
33 #define DPNI_CMDID_DESTROY DPNI_CMD(0x981)
34 #define DPNI_CMDID_GET_API_VERSION DPNI_CMD(0xa01)
36 #define DPNI_CMDID_ENABLE DPNI_CMD(0x002)
37 #define DPNI_CMDID_DISABLE DPNI_CMD(0x003)
38 #define DPNI_CMDID_GET_ATTR DPNI_CMD_V4(0x004)
39 #define DPNI_CMDID_RESET DPNI_CMD(0x005)
40 #define DPNI_CMDID_IS_ENABLED DPNI_CMD(0x006)
42 #define DPNI_CMDID_SET_IRQ_ENABLE DPNI_CMD(0x012)
43 #define DPNI_CMDID_GET_IRQ_ENABLE DPNI_CMD(0x013)
44 #define DPNI_CMDID_SET_IRQ_MASK DPNI_CMD(0x014)
45 #define DPNI_CMDID_GET_IRQ_MASK DPNI_CMD(0x015)
46 #define DPNI_CMDID_GET_IRQ_STATUS DPNI_CMD(0x016)
47 #define DPNI_CMDID_CLEAR_IRQ_STATUS DPNI_CMD(0x017)
49 #define DPNI_CMDID_SET_POOLS DPNI_CMD_V3(0x200)
50 #define DPNI_CMDID_SET_ERRORS_BEHAVIOR DPNI_CMD(0x20B)
52 #define DPNI_CMDID_GET_QDID DPNI_CMD(0x210)
53 #define DPNI_CMDID_GET_SP_INFO DPNI_CMD(0x211)
54 #define DPNI_CMDID_GET_TX_DATA_OFFSET DPNI_CMD(0x212)
55 #define DPNI_CMDID_GET_LINK_STATE DPNI_CMD_V2(0x215)
56 #define DPNI_CMDID_SET_MAX_FRAME_LENGTH DPNI_CMD(0x216)
57 #define DPNI_CMDID_GET_MAX_FRAME_LENGTH DPNI_CMD(0x217)
58 #define DPNI_CMDID_SET_LINK_CFG DPNI_CMD_V2(0x21A)
59 #define DPNI_CMDID_SET_TX_SHAPING DPNI_CMD_V3(0x21B)
61 #define DPNI_CMDID_SET_MCAST_PROMISC DPNI_CMD(0x220)
62 #define DPNI_CMDID_GET_MCAST_PROMISC DPNI_CMD(0x221)
63 #define DPNI_CMDID_SET_UNICAST_PROMISC DPNI_CMD(0x222)
64 #define DPNI_CMDID_GET_UNICAST_PROMISC DPNI_CMD(0x223)
65 #define DPNI_CMDID_SET_PRIM_MAC DPNI_CMD(0x224)
66 #define DPNI_CMDID_GET_PRIM_MAC DPNI_CMD(0x225)
67 #define DPNI_CMDID_ADD_MAC_ADDR DPNI_CMD_V2(0x226)
68 #define DPNI_CMDID_REMOVE_MAC_ADDR DPNI_CMD(0x227)
69 #define DPNI_CMDID_CLR_MAC_FILTERS DPNI_CMD(0x228)
71 #define DPNI_CMDID_ENABLE_VLAN_FILTER DPNI_CMD(0x230)
72 #define DPNI_CMDID_ADD_VLAN_ID DPNI_CMD_V2(0x231)
73 #define DPNI_CMDID_REMOVE_VLAN_ID DPNI_CMD(0x232)
74 #define DPNI_CMDID_CLR_VLAN_FILTERS DPNI_CMD(0x233)
76 #define DPNI_CMDID_SET_RX_TC_DIST DPNI_CMD_V4(0x235)
78 #define DPNI_CMDID_SET_RX_TC_POLICING DPNI_CMD(0x23E)
80 #define DPNI_CMDID_SET_QOS_TBL DPNI_CMD_V2(0x240)
81 #define DPNI_CMDID_ADD_QOS_ENT DPNI_CMD_V2(0x241)
82 #define DPNI_CMDID_REMOVE_QOS_ENT DPNI_CMD(0x242)
83 #define DPNI_CMDID_CLR_QOS_TBL DPNI_CMD(0x243)
84 #define DPNI_CMDID_ADD_FS_ENT DPNI_CMD_V2(0x244)
85 #define DPNI_CMDID_REMOVE_FS_ENT DPNI_CMD(0x245)
86 #define DPNI_CMDID_CLR_FS_ENT DPNI_CMD(0x246)
88 #define DPNI_CMDID_SET_TX_PRIORITIES DPNI_CMD_V3(0x250)
89 #define DPNI_CMDID_GET_RX_TC_POLICING DPNI_CMD(0x251)
91 #define DPNI_CMDID_GET_STATISTICS DPNI_CMD_V4(0x25D)
92 #define DPNI_CMDID_RESET_STATISTICS DPNI_CMD(0x25E)
93 #define DPNI_CMDID_GET_QUEUE DPNI_CMD_V3(0x25F)
94 #define DPNI_CMDID_SET_QUEUE DPNI_CMD_V3(0x260)
95 #define DPNI_CMDID_GET_TAILDROP DPNI_CMD_V2(0x261)
96 #define DPNI_CMDID_SET_TAILDROP DPNI_CMD_V3(0x262)
98 #define DPNI_CMDID_GET_PORT_MAC_ADDR DPNI_CMD(0x263)
100 #define DPNI_CMDID_GET_BUFFER_LAYOUT DPNI_CMD_V2(0x264)
101 #define DPNI_CMDID_SET_BUFFER_LAYOUT DPNI_CMD_V2(0x265)
103 #define DPNI_CMDID_SET_CONGESTION_NOTIFICATION DPNI_CMD_V3(0x267)
104 #define DPNI_CMDID_GET_CONGESTION_NOTIFICATION DPNI_CMD_V3(0x268)
105 #define DPNI_CMDID_SET_EARLY_DROP DPNI_CMD_V3(0x269)
106 #define DPNI_CMDID_GET_EARLY_DROP DPNI_CMD_V3(0x26A)
107 #define DPNI_CMDID_GET_OFFLOAD DPNI_CMD(0x26B)
108 #define DPNI_CMDID_SET_OFFLOAD DPNI_CMD(0x26C)
109 #define DPNI_CMDID_SET_TX_CONFIRMATION_MODE DPNI_CMD(0x266)
110 #define DPNI_CMDID_GET_TX_CONFIRMATION_MODE DPNI_CMD(0x26D)
111 #define DPNI_CMDID_SET_OPR DPNI_CMD(0x26e)
112 #define DPNI_CMDID_GET_OPR DPNI_CMD(0x26f)
113 #define DPNI_CMDID_LOAD_SW_SEQUENCE DPNI_CMD(0x270)
114 #define DPNI_CMDID_ENABLE_SW_SEQUENCE DPNI_CMD(0x271)
115 #define DPNI_CMDID_GET_SW_SEQUENCE_LAYOUT DPNI_CMD(0x272)
116 #define DPNI_CMDID_SET_RX_FS_DIST DPNI_CMD(0x273)
117 #define DPNI_CMDID_SET_RX_HASH_DIST DPNI_CMD(0x274)
118 #define DPNI_CMDID_ADD_CUSTOM_TPID DPNI_CMD(0x275)
119 #define DPNI_CMDID_REMOVE_CUSTOM_TPID DPNI_CMD(0x276)
120 #define DPNI_CMDID_GET_CUSTOM_TPID DPNI_CMD(0x277)
121 #define DPNI_CMDID_GET_LINK_CFG DPNI_CMD(0x278)
122 #define DPNI_CMDID_SET_PORT_CFG DPNI_CMD(0x27B)
124 /* Macros for accessing command fields smaller than 1byte */
125 #define DPNI_MASK(field) \
126 GENMASK(DPNI_##field##_SHIFT + DPNI_##field##_SIZE - 1, \
127 DPNI_##field##_SHIFT)
128 #define dpni_set_field(var, field, val) \
129 ((var) |= (((val) << DPNI_##field##_SHIFT) & DPNI_MASK(field)))
130 #define dpni_get_field(var, field) \
131 (((var) & DPNI_MASK(field)) >> DPNI_##field##_SHIFT)
133 #pragma pack(push, 1)
134 struct dpni_cmd_open {
138 struct dpni_cmd_create {
142 uint8_t mac_filter_entries;
143 uint8_t num_channels;
144 uint8_t vlan_filter_entries;
153 uint8_t dist_key_size;
156 struct dpni_cmd_destroy {
160 #define DPNI_BACKUP_POOL(val, order) (((val) & 0x1) << (order))
162 struct dpni_cmd_pool {
164 uint8_t priority_mask;
168 struct dpni_cmd_set_pools {
170 uint8_t backup_pool_mask;
172 uint8_t pool_options;
173 struct dpni_cmd_pool pool[8];
174 uint16_t buffer_size[8];
177 /* The enable indication is always the least significant bit */
178 #define DPNI_ENABLE_SHIFT 0
179 #define DPNI_ENABLE_SIZE 1
181 struct dpni_rsp_is_enabled {
185 struct dpni_cmd_set_irq_enable {
191 struct dpni_cmd_get_irq_enable {
196 struct dpni_rsp_get_irq_enable {
200 struct dpni_cmd_set_irq_mask {
205 struct dpni_cmd_get_irq_mask {
210 struct dpni_rsp_get_irq_mask {
214 struct dpni_cmd_get_irq_status {
219 struct dpni_rsp_get_irq_status {
223 struct dpni_cmd_clear_irq_status {
228 struct dpni_rsp_get_attr {
229 /* response word 0 */
233 uint8_t mac_filter_entries;
235 /* response word 1 */
236 uint8_t vlan_filter_entries;
237 uint8_t num_channels;
242 /* response word 2 */
243 uint8_t qos_key_size;
245 uint16_t wriop_version;
249 #define DPNI_ERROR_ACTION_SHIFT 0
250 #define DPNI_ERROR_ACTION_SIZE 4
251 #define DPNI_FRAME_ANN_SHIFT 4
252 #define DPNI_FRAME_ANN_SIZE 1
254 struct dpni_cmd_set_errors_behavior {
256 /* from least significant bit: error_action:4, set_frame_annotation:1 */
260 /* There are 3 separate commands for configuring Rx, Tx and Tx confirmation
261 * buffer layouts, but they all share the same parameters.
262 * If one of the functions changes, below structure needs to be split.
265 #define DPNI_PASS_TS_SHIFT 0
266 #define DPNI_PASS_TS_SIZE 1
267 #define DPNI_PASS_PR_SHIFT 1
268 #define DPNI_PASS_PR_SIZE 1
269 #define DPNI_PASS_FS_SHIFT 2
270 #define DPNI_PASS_FS_SIZE 1
271 #define DPNI_PASS_SWO_SHIFT 3
272 #define DPNI_PASS_SWO_SIZE 1
274 struct dpni_cmd_get_buffer_layout {
278 struct dpni_rsp_get_buffer_layout {
279 /* response word 0 */
281 /* from LSB: pass_timestamp:1, parser_result:1, frame_status:1 */
284 /* response word 1 */
285 uint16_t private_data_size;
291 struct dpni_cmd_set_buffer_layout {
296 /* from LSB: pass_timestamp:1, parser_result:1, frame_status:1 */
300 uint16_t private_data_size;
306 struct dpni_cmd_set_offload {
308 uint8_t dpni_offload;
312 struct dpni_cmd_get_offload {
314 uint8_t dpni_offload;
317 struct dpni_rsp_get_offload {
322 struct dpni_cmd_get_qdid {
326 struct dpni_rsp_get_qdid {
330 struct dpni_rsp_get_sp_info {
334 struct dpni_rsp_get_tx_data_offset {
335 uint16_t data_offset;
338 struct dpni_cmd_get_statistics {
343 struct dpni_rsp_get_statistics {
347 struct dpni_cmd_set_link_cfg {
352 uint64_t advertising;
355 #define DPNI_LINK_STATE_SHIFT 0
356 #define DPNI_LINK_STATE_SIZE 1
357 #define DPNI_STATE_VALID_SHIFT 1
358 #define DPNI_STATE_VALID_SIZE 1
360 struct dpni_rsp_get_link_state {
369 uint64_t advertising;
372 #define DPNI_COUPLED_SHIFT 0
373 #define DPNI_COUPLED_SIZE 1
374 #define DPNI_LNI_SHAPER_SHIFT 1
375 #define DPNI_LNI_SHAPER_SIZE 1
377 struct dpni_cmd_set_tx_shaping {
378 uint16_t tx_cr_max_burst_size;
379 uint16_t tx_er_max_burst_size;
381 uint32_t tx_cr_rate_limit;
382 uint32_t tx_er_rate_limit;
383 /* from LSB: coupled:1, lni_shaper: 1*/
389 struct dpni_cmd_set_max_frame_length {
390 uint16_t max_frame_length;
393 struct dpni_rsp_get_max_frame_length {
394 uint16_t max_frame_length;
397 struct dpni_cmd_set_multicast_promisc {
401 struct dpni_rsp_get_multicast_promisc {
405 struct dpni_cmd_set_unicast_promisc {
409 struct dpni_rsp_get_unicast_promisc {
413 struct dpni_cmd_set_primary_mac_addr {
418 struct dpni_rsp_get_primary_mac_addr {
423 struct dpni_rsp_get_port_mac_addr {
428 struct dpni_cmd_add_mac_addr {
436 struct dpni_cmd_remove_mac_addr {
441 #define DPNI_UNICAST_FILTERS_SHIFT 0
442 #define DPNI_UNICAST_FILTERS_SIZE 1
443 #define DPNI_MULTICAST_FILTERS_SHIFT 1
444 #define DPNI_MULTICAST_FILTERS_SIZE 1
446 struct dpni_cmd_clear_mac_filters {
447 /* from LSB: unicast:1, multicast:1 */
451 struct dpni_cmd_enable_vlan_filter {
456 struct dpni_cmd_vlan_id {
464 #define DPNI_SEPARATE_GRP_SHIFT 0
465 #define DPNI_SEPARATE_GRP_SIZE 1
466 #define DPNI_MODE_1_SHIFT 0
467 #define DPNI_MODE_1_SIZE 4
468 #define DPNI_MODE_2_SHIFT 4
469 #define DPNI_MODE_2_SIZE 4
471 struct dpni_cmd_set_tx_priorities {
473 uint8_t prio_group_A;
474 uint8_t prio_group_B;
480 uint16_t delta_bandwidth[8];
483 #define DPNI_DIST_MODE_SHIFT 0
484 #define DPNI_DIST_MODE_SIZE 4
485 #define DPNI_MISS_ACTION_SHIFT 4
486 #define DPNI_MISS_ACTION_SIZE 4
487 #define DPNI_KEEP_HASH_KEY_SHIFT 7
488 #define DPNI_KEEP_HASH_KEY_SIZE 1
489 #define DPNI_KEEP_ENTRIES_SHIFT 6
490 #define DPNI_KEEP_ENTRIES_SIZE 1
492 struct dpni_cmd_set_rx_tc_dist {
495 /* from LSB: dist_mode:4, miss_action:4 */
499 uint8_t keep_hash_key;
500 uint16_t default_flow_id;
502 uint64_t key_cfg_iova;
505 struct dpni_cmd_get_queue {
512 #define DPNI_DEST_TYPE_SHIFT 0
513 #define DPNI_DEST_TYPE_SIZE 4
514 #define DPNI_CGID_VALID_SHIFT 5
515 #define DPNI_CGID_VALID_SIZE 1
516 #define DPNI_STASH_CTRL_SHIFT 6
517 #define DPNI_STASH_CTRL_SIZE 1
518 #define DPNI_HOLD_ACTIVE_SHIFT 7
519 #define DPNI_HOLD_ACTIVE_SIZE 1
521 struct dpni_rsp_get_queue {
522 /* response word 0 */
524 /* response word 1 */
529 * dest_type:4, pad:1, cgid_valid:1, flc_stash_ctrl:1, hold_active:1
532 /* response word 2 */
534 /* response word 3 */
535 uint64_t user_context;
536 /* response word 4 */
544 struct dpni_cmd_set_queue {
559 uint64_t user_context;
565 #define DPNI_DISCARD_ON_MISS_SHIFT 0
566 #define DPNI_DISCARD_ON_MISS_SIZE 1
567 #define DPNI_KEEP_QOS_ENTRIES_SHIFT 1
568 #define DPNI_KEEP_QOS_ENTRIES_SIZE 1
570 struct dpni_cmd_set_qos_table {
574 uint8_t discard_on_miss;
576 uint64_t key_cfg_iova;
579 #define DPNI_QOS_OPT_SET_TC_ONLY 0x0
580 #define DPNI_QOS_OPT_SET_FLOW_ID 0x1
582 struct dpni_cmd_add_qos_entry {
593 struct dpni_cmd_remove_qos_entry {
601 struct dpni_cmd_add_fs_entry {
610 uint16_t redir_token;
613 struct dpni_cmd_remove_fs_entry {
622 struct dpni_cmd_clear_fs_entries {
627 #define DPNI_MODE_SHIFT 0
628 #define DPNI_MODE_SIZE 4
629 #define DPNI_COLOR_SHIFT 4
630 #define DPNI_COLOR_SIZE 4
631 #define DPNI_UNITS_SHIFT 0
632 #define DPNI_UNITS_SIZE 4
634 struct dpni_cmd_set_rx_tc_policing {
635 /* from LSB: mode:4 color:4 */
637 /* from LSB: units: 4 */
648 struct dpni_cmd_get_rx_tc_policing {
653 struct dpni_rsp_get_rx_tc_policing {
654 /* from LSB: mode:4 color:4 */
656 /* from LSB: units: 4 */
666 #define DPNI_DROP_ENABLE_SHIFT 0
667 #define DPNI_DROP_ENABLE_SIZE 1
668 #define DPNI_DROP_UNITS_SHIFT 2
669 #define DPNI_DROP_UNITS_SIZE 2
671 struct dpni_early_drop {
672 /* from LSB: enable:1 units:2 */
676 uint8_t green_drop_probability;
678 uint64_t green_max_threshold;
679 uint64_t green_min_threshold;
681 uint8_t yellow_drop_probability;
683 uint64_t yellow_max_threshold;
684 uint64_t yellow_min_threshold;
686 uint8_t red_drop_probability;
688 uint64_t red_max_threshold;
689 uint64_t red_min_threshold;
692 struct dpni_cmd_early_drop {
697 uint64_t early_drop_iova;
700 struct dpni_rsp_get_api_version {
705 struct dpni_cmd_get_taildrop {
706 uint8_t congestion_point;
712 struct dpni_rsp_get_taildrop {
716 /* from LSB: enable:1 oal_lo:7 */
717 uint8_t enable_oal_lo;
718 /* from LSB: oal_hi:5 */
725 #define DPNI_OAL_LO_SHIFT 1
726 #define DPNI_OAL_LO_SIZE 7
727 #define DPNI_OAL_HI_SHIFT 0
728 #define DPNI_OAL_HI_SIZE 5
730 struct dpni_cmd_set_taildrop {
732 uint8_t congestion_point;
739 /* from LSB: enable:1 oal_lo:7 */
740 uint8_t enable_oal_lo;
741 /* from LSB: oal_hi:5 */
748 struct dpni_tx_confirmation_mode {
750 uint8_t confirmation_mode;
753 #define DPNI_DEST_TYPE_SHIFT 0
754 #define DPNI_DEST_TYPE_SIZE 4
755 #define DPNI_CONG_UNITS_SHIFT 4
756 #define DPNI_CONG_UNITS_SIZE 2
758 struct dpni_cmd_set_congestion_notification {
762 uint8_t congestion_point;
766 uint16_t notification_mode;
767 uint8_t dest_priority;
768 /* from LSB: dest_type: 4 units:2 */
770 uint64_t message_iova;
771 uint64_t message_ctx;
772 uint32_t threshold_entry;
773 uint32_t threshold_exit;
776 struct dpni_cmd_get_congestion_notification {
780 uint8_t congestion_point;
784 struct dpni_rsp_get_congestion_notification {
787 uint16_t notification_mode;
788 uint8_t dest_priority;
789 /* from LSB: dest_type: 4 units:2 */
791 uint64_t message_iova;
792 uint64_t message_ctx;
793 uint32_t threshold_entry;
794 uint32_t threshold_exit;
797 struct dpni_cmd_set_opr {
810 struct dpni_cmd_get_opr {
817 #define DPNI_RIP_SHIFT 0
818 #define DPNI_RIP_SIZE 1
819 #define DPNI_OPR_ENABLE_SHIFT 1
820 #define DPNI_OPR_ENABLE_SIZE 1
821 #define DPNI_TSEQ_NLIS_SHIFT 0
822 #define DPNI_TSEQ_NLIS_SIZE 1
823 #define DPNI_HSEQ_NLIS_SHIFT 0
824 #define DPNI_HSEQ_NLIS_SIZE 1
826 struct dpni_rsp_get_opr {
828 /* from LSB: rip:1 enable:1 */
857 struct dpni_load_sw_sequence {
867 struct dpni_enable_sw_sequence {
874 uint8_t param_offset;
881 struct dpni_get_sw_sequence_layout {
884 uint64_t layout_iova;
887 struct dpni_sw_sequence_layout_entry {
890 uint8_t param_offset;
895 #define DPNI_PTP_ENABLE_SHIFT 0
896 #define DPNI_PTP_ENABLE_SIZE 1
897 #define DPNI_PTP_CH_UPDATE_SHIFT 1
898 #define DPNI_PTP_CH_UPDATE_SIZE 1
899 struct dpni_cmd_single_step_cfg {
905 struct dpni_rsp_single_step_cfg {
911 #define DPNI_PORT_LOOPBACK_EN_SHIFT 0
912 #define DPNI_PORT_LOOPBACK_EN_SIZE 1
914 struct dpni_cmd_set_port_cfg {
919 struct dpni_rsp_get_port_cfg {
924 #define DPNI_RX_FS_DIST_ENABLE_SHIFT 0
925 #define DPNI_RX_FS_DIST_ENABLE_SIZE 1
926 struct dpni_cmd_set_rx_fs_dist {
930 uint16_t miss_flow_id;
932 uint64_t key_cfg_iova;
935 #define DPNI_RX_HASH_DIST_ENABLE_SHIFT 0
936 #define DPNI_RX_HASH_DIST_ENABLE_SIZE 1
937 struct dpni_cmd_set_rx_hash_dist {
942 uint64_t key_cfg_iova;
945 struct dpni_cmd_add_custom_tpid {
950 struct dpni_cmd_remove_custom_tpid {
955 struct dpni_rsp_get_custom_tpid {
961 #endif /* _FSL_DPNI_CMD_H */