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 7
12 #define DPNI_VER_MINOR 17
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_ID_OFFSET 4
21 #define DPNI_CMD(id) (((id) << DPNI_CMD_ID_OFFSET) | DPNI_CMD_BASE_VERSION)
22 #define DPNI_CMD_V2(id) (((id) << DPNI_CMD_ID_OFFSET) | DPNI_CMD_VERSION_2)
23 #define DPNI_CMD_V3(id) (((id) << DPNI_CMD_ID_OFFSET) | DPNI_CMD_VERSION_3)
24 #define DPNI_CMD_V4(id) (((id) << DPNI_CMD_ID_OFFSET) | DPNI_CMD_VERSION_4)
25 #define DPNI_CMD_V5(id) (((id) << DPNI_CMD_ID_OFFSET) | DPNI_CMD_VERSION_5)
28 #define DPNI_CMDID_OPEN DPNI_CMD(0x801)
29 #define DPNI_CMDID_CLOSE DPNI_CMD(0x800)
30 #define DPNI_CMDID_CREATE DPNI_CMD_V5(0x901)
31 #define DPNI_CMDID_DESTROY DPNI_CMD(0x981)
32 #define DPNI_CMDID_GET_API_VERSION DPNI_CMD(0xa01)
34 #define DPNI_CMDID_ENABLE DPNI_CMD(0x002)
35 #define DPNI_CMDID_DISABLE DPNI_CMD(0x003)
36 #define DPNI_CMDID_GET_ATTR DPNI_CMD_V3(0x004)
37 #define DPNI_CMDID_RESET DPNI_CMD(0x005)
38 #define DPNI_CMDID_IS_ENABLED DPNI_CMD(0x006)
40 #define DPNI_CMDID_SET_IRQ_ENABLE DPNI_CMD(0x012)
41 #define DPNI_CMDID_GET_IRQ_ENABLE DPNI_CMD(0x013)
42 #define DPNI_CMDID_SET_IRQ_MASK DPNI_CMD(0x014)
43 #define DPNI_CMDID_GET_IRQ_MASK DPNI_CMD(0x015)
44 #define DPNI_CMDID_GET_IRQ_STATUS DPNI_CMD(0x016)
45 #define DPNI_CMDID_CLEAR_IRQ_STATUS DPNI_CMD(0x017)
47 #define DPNI_CMDID_SET_POOLS DPNI_CMD_V3(0x200)
48 #define DPNI_CMDID_SET_ERRORS_BEHAVIOR DPNI_CMD(0x20B)
50 #define DPNI_CMDID_GET_QDID DPNI_CMD(0x210)
51 #define DPNI_CMDID_GET_SP_INFO DPNI_CMD(0x211)
52 #define DPNI_CMDID_GET_TX_DATA_OFFSET DPNI_CMD(0x212)
53 #define DPNI_CMDID_GET_LINK_STATE DPNI_CMD_V2(0x215)
54 #define DPNI_CMDID_SET_MAX_FRAME_LENGTH DPNI_CMD(0x216)
55 #define DPNI_CMDID_GET_MAX_FRAME_LENGTH DPNI_CMD(0x217)
56 #define DPNI_CMDID_SET_LINK_CFG DPNI_CMD_V2(0x21A)
57 #define DPNI_CMDID_SET_TX_SHAPING DPNI_CMD_V2(0x21B)
59 #define DPNI_CMDID_SET_MCAST_PROMISC DPNI_CMD(0x220)
60 #define DPNI_CMDID_GET_MCAST_PROMISC DPNI_CMD(0x221)
61 #define DPNI_CMDID_SET_UNICAST_PROMISC DPNI_CMD(0x222)
62 #define DPNI_CMDID_GET_UNICAST_PROMISC DPNI_CMD(0x223)
63 #define DPNI_CMDID_SET_PRIM_MAC DPNI_CMD(0x224)
64 #define DPNI_CMDID_GET_PRIM_MAC DPNI_CMD(0x225)
65 #define DPNI_CMDID_ADD_MAC_ADDR DPNI_CMD_V2(0x226)
66 #define DPNI_CMDID_REMOVE_MAC_ADDR DPNI_CMD(0x227)
67 #define DPNI_CMDID_CLR_MAC_FILTERS DPNI_CMD(0x228)
69 #define DPNI_CMDID_ENABLE_VLAN_FILTER DPNI_CMD(0x230)
70 #define DPNI_CMDID_ADD_VLAN_ID DPNI_CMD_V2(0x231)
71 #define DPNI_CMDID_REMOVE_VLAN_ID DPNI_CMD(0x232)
72 #define DPNI_CMDID_CLR_VLAN_FILTERS DPNI_CMD(0x233)
74 #define DPNI_CMDID_SET_RX_TC_DIST DPNI_CMD_V4(0x235)
76 #define DPNI_CMDID_SET_RX_TC_POLICING DPNI_CMD(0x23E)
78 #define DPNI_CMDID_SET_QOS_TBL DPNI_CMD_V2(0x240)
79 #define DPNI_CMDID_ADD_QOS_ENT DPNI_CMD_V2(0x241)
80 #define DPNI_CMDID_REMOVE_QOS_ENT DPNI_CMD(0x242)
81 #define DPNI_CMDID_CLR_QOS_TBL DPNI_CMD(0x243)
82 #define DPNI_CMDID_ADD_FS_ENT DPNI_CMD_V2(0x244)
83 #define DPNI_CMDID_REMOVE_FS_ENT DPNI_CMD(0x245)
84 #define DPNI_CMDID_CLR_FS_ENT DPNI_CMD(0x246)
86 #define DPNI_CMDID_SET_TX_PRIORITIES DPNI_CMD_V2(0x250)
87 #define DPNI_CMDID_GET_RX_TC_POLICING DPNI_CMD(0x251)
89 #define DPNI_CMDID_GET_STATISTICS DPNI_CMD_V3(0x25D)
90 #define DPNI_CMDID_RESET_STATISTICS DPNI_CMD(0x25E)
91 #define DPNI_CMDID_GET_QUEUE DPNI_CMD_V2(0x25F)
92 #define DPNI_CMDID_SET_QUEUE DPNI_CMD_V2(0x260)
93 #define DPNI_CMDID_GET_TAILDROP DPNI_CMD_V2(0x261)
94 #define DPNI_CMDID_SET_TAILDROP DPNI_CMD_V2(0x262)
96 #define DPNI_CMDID_GET_PORT_MAC_ADDR DPNI_CMD(0x263)
98 #define DPNI_CMDID_GET_BUFFER_LAYOUT DPNI_CMD_V2(0x264)
99 #define DPNI_CMDID_SET_BUFFER_LAYOUT DPNI_CMD_V2(0x265)
101 #define DPNI_CMDID_SET_CONGESTION_NOTIFICATION DPNI_CMD_V2(0x267)
102 #define DPNI_CMDID_GET_CONGESTION_NOTIFICATION DPNI_CMD_V2(0x268)
103 #define DPNI_CMDID_SET_EARLY_DROP DPNI_CMD_V2(0x269)
104 #define DPNI_CMDID_GET_EARLY_DROP DPNI_CMD_V2(0x26A)
105 #define DPNI_CMDID_GET_OFFLOAD DPNI_CMD(0x26B)
106 #define DPNI_CMDID_SET_OFFLOAD DPNI_CMD(0x26C)
107 #define DPNI_CMDID_SET_TX_CONFIRMATION_MODE DPNI_CMD(0x266)
108 #define DPNI_CMDID_GET_TX_CONFIRMATION_MODE DPNI_CMD(0x26D)
109 #define DPNI_CMDID_LOAD_SW_SEQUENCE DPNI_CMD(0x270)
110 #define DPNI_CMDID_ENABLE_SW_SEQUENCE DPNI_CMD(0x271)
111 #define DPNI_CMDID_GET_SW_SEQUENCE_LAYOUT DPNI_CMD(0x272)
112 #define DPNI_CMDID_SET_OPR DPNI_CMD(0x26e)
113 #define DPNI_CMDID_GET_OPR DPNI_CMD(0x26f)
114 #define DPNI_CMDID_SET_RX_FS_DIST DPNI_CMD(0x273)
115 #define DPNI_CMDID_SET_RX_HASH_DIST DPNI_CMD(0x274)
116 #define DPNI_CMDID_ADD_CUSTOM_TPID DPNI_CMD(0x275)
117 #define DPNI_CMDID_REMOVE_CUSTOM_TPID DPNI_CMD(0x276)
118 #define DPNI_CMDID_GET_CUSTOM_TPID DPNI_CMD(0x277)
120 /* Macros for accessing command fields smaller than 1byte */
121 #define DPNI_MASK(field) \
122 GENMASK(DPNI_##field##_SHIFT + DPNI_##field##_SIZE - 1, \
123 DPNI_##field##_SHIFT)
124 #define dpni_set_field(var, field, val) \
125 ((var) |= (((val) << DPNI_##field##_SHIFT) & DPNI_MASK(field)))
126 #define dpni_get_field(var, field) \
127 (((var) & DPNI_MASK(field)) >> DPNI_##field##_SHIFT)
129 #pragma pack(push, 1)
130 struct dpni_cmd_open {
134 struct dpni_cmd_create {
138 uint8_t mac_filter_entries;
140 uint8_t vlan_filter_entries;
149 uint8_t dist_key_size;
152 struct dpni_cmd_destroy {
156 #define DPNI_BACKUP_POOL(val, order) (((val) & 0x1) << (order))
158 struct dpni_cmd_pool {
160 uint8_t priority_mask;
164 struct dpni_cmd_set_pools {
166 uint8_t backup_pool_mask;
168 uint8_t pool_options;
169 struct dpni_cmd_pool pool[8];
170 uint16_t buffer_size[8];
173 /* The enable indication is always the least significant bit */
174 #define DPNI_ENABLE_SHIFT 0
175 #define DPNI_ENABLE_SIZE 1
177 struct dpni_rsp_is_enabled {
181 struct dpni_cmd_set_irq_enable {
187 struct dpni_cmd_get_irq_enable {
192 struct dpni_rsp_get_irq_enable {
196 struct dpni_cmd_set_irq_mask {
201 struct dpni_cmd_get_irq_mask {
206 struct dpni_rsp_get_irq_mask {
210 struct dpni_cmd_get_irq_status {
215 struct dpni_rsp_get_irq_status {
219 struct dpni_cmd_clear_irq_status {
224 struct dpni_rsp_get_attr {
225 /* response word 0 */
229 uint8_t mac_filter_entries;
231 /* response word 1 */
232 uint8_t vlan_filter_entries;
238 /* response word 2 */
239 uint8_t qos_key_size;
241 uint16_t wriop_version;
245 #define DPNI_ERROR_ACTION_SHIFT 0
246 #define DPNI_ERROR_ACTION_SIZE 4
247 #define DPNI_FRAME_ANN_SHIFT 4
248 #define DPNI_FRAME_ANN_SIZE 1
250 struct dpni_cmd_set_errors_behavior {
252 /* from least significant bit: error_action:4, set_frame_annotation:1 */
256 /* There are 3 separate commands for configuring Rx, Tx and Tx confirmation
257 * buffer layouts, but they all share the same parameters.
258 * If one of the functions changes, below structure needs to be split.
261 #define DPNI_PASS_TS_SHIFT 0
262 #define DPNI_PASS_TS_SIZE 1
263 #define DPNI_PASS_PR_SHIFT 1
264 #define DPNI_PASS_PR_SIZE 1
265 #define DPNI_PASS_FS_SHIFT 2
266 #define DPNI_PASS_FS_SIZE 1
267 #define DPNI_PASS_SWO_SHIFT 3
268 #define DPNI_PASS_SWO_SIZE 1
270 struct dpni_cmd_get_buffer_layout {
274 struct dpni_rsp_get_buffer_layout {
275 /* response word 0 */
277 /* from LSB: pass_timestamp:1, parser_result:1, frame_status:1 */
280 /* response word 1 */
281 uint16_t private_data_size;
287 struct dpni_cmd_set_buffer_layout {
292 /* from LSB: pass_timestamp:1, parser_result:1, frame_status:1 */
296 uint16_t private_data_size;
302 struct dpni_cmd_set_offload {
304 uint8_t dpni_offload;
308 struct dpni_cmd_get_offload {
310 uint8_t dpni_offload;
313 struct dpni_rsp_get_offload {
318 struct dpni_cmd_get_qdid {
322 struct dpni_rsp_get_qdid {
326 struct dpni_rsp_get_sp_info {
330 struct dpni_rsp_get_tx_data_offset {
331 uint16_t data_offset;
334 struct dpni_cmd_get_statistics {
339 struct dpni_rsp_get_statistics {
343 struct dpni_cmd_set_link_cfg {
348 uint64_t advertising;
351 #define DPNI_LINK_STATE_SHIFT 0
352 #define DPNI_LINK_STATE_SIZE 1
353 #define DPNI_STATE_VALID_SHIFT 1
354 #define DPNI_STATE_VALID_SIZE 1
356 struct dpni_rsp_get_link_state {
365 uint64_t advertising;
368 #define DPNI_COUPLED_SHIFT 0
369 #define DPNI_COUPLED_SIZE 1
371 struct dpni_cmd_set_tx_shaping {
372 uint16_t tx_cr_max_burst_size;
373 uint16_t tx_er_max_burst_size;
375 uint32_t tx_cr_rate_limit;
376 uint32_t tx_er_rate_limit;
377 /* from LSB: coupled:1 */
381 struct dpni_cmd_set_max_frame_length {
382 uint16_t max_frame_length;
385 struct dpni_rsp_get_max_frame_length {
386 uint16_t max_frame_length;
389 struct dpni_cmd_set_multicast_promisc {
393 struct dpni_rsp_get_multicast_promisc {
397 struct dpni_cmd_set_unicast_promisc {
401 struct dpni_rsp_get_unicast_promisc {
405 struct dpni_cmd_set_primary_mac_addr {
410 struct dpni_rsp_get_primary_mac_addr {
415 struct dpni_rsp_get_port_mac_addr {
420 struct dpni_cmd_add_mac_addr {
428 struct dpni_cmd_remove_mac_addr {
433 #define DPNI_UNICAST_FILTERS_SHIFT 0
434 #define DPNI_UNICAST_FILTERS_SIZE 1
435 #define DPNI_MULTICAST_FILTERS_SHIFT 1
436 #define DPNI_MULTICAST_FILTERS_SIZE 1
438 struct dpni_cmd_clear_mac_filters {
439 /* from LSB: unicast:1, multicast:1 */
443 struct dpni_cmd_enable_vlan_filter {
448 #define DPNI_VLAN_SET_QUEUE_ACTION 1
450 struct dpni_cmd_vlan_id {
458 #define DPNI_SEPARATE_GRP_SHIFT 0
459 #define DPNI_SEPARATE_GRP_SIZE 1
460 #define DPNI_MODE_1_SHIFT 0
461 #define DPNI_MODE_1_SIZE 4
462 #define DPNI_MODE_2_SHIFT 4
463 #define DPNI_MODE_2_SIZE 4
465 struct dpni_cmd_set_tx_priorities {
467 uint8_t prio_group_A;
468 uint8_t prio_group_B;
473 uint16_t delta_bandwidth[8];
476 #define DPNI_DIST_MODE_SHIFT 0
477 #define DPNI_DIST_MODE_SIZE 4
478 #define DPNI_MISS_ACTION_SHIFT 4
479 #define DPNI_MISS_ACTION_SIZE 4
480 #define DPNI_KEEP_HASH_KEY_SHIFT 7
481 #define DPNI_KEEP_HASH_KEY_SIZE 1
482 #define DPNI_KEEP_ENTRIES_SHIFT 6
483 #define DPNI_KEEP_ENTRIES_SIZE 1
485 struct dpni_cmd_set_rx_tc_dist {
488 /* from LSB: dist_mode:4, miss_action:4 */
492 uint8_t keep_hash_key;
493 uint16_t default_flow_id;
495 uint64_t key_cfg_iova;
498 struct dpni_cmd_get_queue {
504 #define DPNI_DEST_TYPE_SHIFT 0
505 #define DPNI_DEST_TYPE_SIZE 4
506 #define DPNI_CGID_VALID_SHIFT 5
507 #define DPNI_CGID_VALID_SIZE 1
508 #define DPNI_STASH_CTRL_SHIFT 6
509 #define DPNI_STASH_CTRL_SIZE 1
510 #define DPNI_HOLD_ACTIVE_SHIFT 7
511 #define DPNI_HOLD_ACTIVE_SIZE 1
513 struct dpni_rsp_get_queue {
514 /* response word 0 */
516 /* response word 1 */
521 * dest_type:4, pad:1, cgid_valid:1, flc_stash_ctrl:1, hold_active:1
524 /* response word 2 */
526 /* response word 3 */
527 uint64_t user_context;
528 /* response word 4 */
536 struct dpni_cmd_set_queue {
551 uint64_t user_context;
556 #define DPNI_DISCARD_ON_MISS_SHIFT 0
557 #define DPNI_DISCARD_ON_MISS_SIZE 1
558 #define DPNI_KEEP_QOS_ENTRIES_SHIFT 1
559 #define DPNI_KEEP_QOS_ENTRIES_SIZE 1
561 struct dpni_cmd_set_qos_table {
565 uint8_t discard_on_miss;
567 uint64_t key_cfg_iova;
570 #define DPNI_QOS_OPT_SET_TC_ONLY 0x0
571 #define DPNI_QOS_OPT_SET_FLOW_ID 0x1
573 struct dpni_cmd_add_qos_entry {
584 struct dpni_cmd_remove_qos_entry {
592 struct dpni_cmd_add_fs_entry {
601 uint16_t redir_token;
604 struct dpni_cmd_remove_fs_entry {
613 struct dpni_cmd_clear_fs_entries {
618 #define DPNI_MODE_SHIFT 0
619 #define DPNI_MODE_SIZE 4
620 #define DPNI_COLOR_SHIFT 4
621 #define DPNI_COLOR_SIZE 4
622 #define DPNI_UNITS_SHIFT 0
623 #define DPNI_UNITS_SIZE 4
625 struct dpni_cmd_set_rx_tc_policing {
626 /* from LSB: mode:4 color:4 */
628 /* from LSB: units: 4 */
639 struct dpni_cmd_get_rx_tc_policing {
644 struct dpni_rsp_get_rx_tc_policing {
645 /* from LSB: mode:4 color:4 */
647 /* from LSB: units: 4 */
657 #define DPNI_DROP_ENABLE_SHIFT 0
658 #define DPNI_DROP_ENABLE_SIZE 1
659 #define DPNI_DROP_UNITS_SHIFT 2
660 #define DPNI_DROP_UNITS_SIZE 2
662 struct dpni_early_drop {
663 /* from LSB: enable:1 units:2 */
667 uint8_t green_drop_probability;
669 uint64_t green_max_threshold;
670 uint64_t green_min_threshold;
672 uint8_t yellow_drop_probability;
674 uint64_t yellow_max_threshold;
675 uint64_t yellow_min_threshold;
677 uint8_t red_drop_probability;
679 uint64_t red_max_threshold;
680 uint64_t red_min_threshold;
683 struct dpni_cmd_early_drop {
687 uint64_t early_drop_iova;
690 struct dpni_rsp_get_api_version {
695 struct dpni_cmd_get_taildrop {
696 uint8_t congestion_point;
702 struct dpni_rsp_get_taildrop {
706 /* from LSB: enable:1 oal_lo:7 */
707 uint8_t enable_oal_lo;
708 /* from LSB: oal_hi:5 */
715 #define DPNI_OAL_LO_SHIFT 1
716 #define DPNI_OAL_LO_SIZE 7
717 #define DPNI_OAL_HI_SHIFT 0
718 #define DPNI_OAL_HI_SIZE 5
720 struct dpni_cmd_set_taildrop {
722 uint8_t congestion_point;
728 /* from LSB: enable:1 oal_lo:7 */
729 uint8_t enable_oal_lo;
730 /* from LSB: oal_hi:5 */
737 struct dpni_tx_confirmation_mode {
739 uint8_t confirmation_mode;
742 #define DPNI_DEST_TYPE_SHIFT 0
743 #define DPNI_DEST_TYPE_SIZE 4
744 #define DPNI_CONG_UNITS_SHIFT 4
745 #define DPNI_CONG_UNITS_SIZE 2
747 struct dpni_cmd_set_congestion_notification {
751 uint8_t congestion_point;
755 uint16_t notification_mode;
756 uint8_t dest_priority;
757 /* from LSB: dest_type: 4 units:2 */
759 uint64_t message_iova;
760 uint64_t message_ctx;
761 uint32_t threshold_entry;
762 uint32_t threshold_exit;
765 struct dpni_cmd_get_congestion_notification {
769 uint8_t congestion_point;
773 struct dpni_rsp_get_congestion_notification {
776 uint16_t notification_mode;
777 uint8_t dest_priority;
778 /* from LSB: dest_type: 4 units:2 */
780 uint64_t message_iova;
781 uint64_t message_ctx;
782 uint32_t threshold_entry;
783 uint32_t threshold_exit;
786 struct dpni_cmd_set_opr {
799 struct dpni_cmd_get_opr {
806 #define DPNI_RIP_SHIFT 0
807 #define DPNI_RIP_SIZE 1
808 #define DPNI_OPR_ENABLE_SHIFT 1
809 #define DPNI_OPR_ENABLE_SIZE 1
810 #define DPNI_TSEQ_NLIS_SHIFT 0
811 #define DPNI_TSEQ_NLIS_SIZE 1
812 #define DPNI_HSEQ_NLIS_SHIFT 0
813 #define DPNI_HSEQ_NLIS_SIZE 1
815 struct dpni_rsp_get_opr {
817 /* from LSB: rip:1 enable:1 */
846 struct dpni_cmd_add_custom_tpid {
851 struct dpni_cmd_remove_custom_tpid {
856 struct dpni_rsp_get_custom_tpid {
861 #define DPNI_RX_FS_DIST_ENABLE_SHIFT 0
862 #define DPNI_RX_FS_DIST_ENABLE_SIZE 1
863 struct dpni_cmd_set_rx_fs_dist {
867 uint16_t miss_flow_id;
869 uint64_t key_cfg_iova;
872 #define DPNI_RX_HASH_DIST_ENABLE_SHIFT 0
873 #define DPNI_RX_HASH_DIST_ENABLE_SIZE 1
874 struct dpni_cmd_set_rx_hash_dist {
879 uint64_t key_cfg_iova;
882 struct dpni_load_sw_sequence {
892 struct dpni_enable_sw_sequence {
899 uint8_t param_offset;
906 struct dpni_get_sw_sequence_layout {
909 uint64_t layout_iova;
912 struct dpni_sw_sequence_layout_entry {
915 uint8_t param_offset;
920 #define DPNI_PTP_ENABLE_SHIFT 0
921 #define DPNI_PTP_ENABLE_SIZE 1
922 #define DPNI_PTP_CH_UPDATE_SHIFT 1
923 #define DPNI_PTP_CH_UPDATE_SIZE 1
924 struct dpni_cmd_single_step_cfg {
930 struct dpni_rsp_single_step_cfg {
936 #define DPNI_PORT_LOOPBACK_EN_SHIFT 0
937 #define DPNI_PORT_LOOPBACK_EN_SIZE 1
939 struct dpni_cmd_set_port_cfg {
944 struct dpni_rsp_get_port_cfg {
950 #endif /* _FSL_DPNI_CMD_H */