1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
3 * Copyright 2013-2016 Freescale Semiconductor Inc.
4 * Copyright 2016-2017 NXP
7 #ifndef _FSL_DPNI_CMD_H
8 #define _FSL_DPNI_CMD_H
11 #define DPNI_VER_MAJOR 7
12 #define DPNI_VER_MINOR 8
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_ID_OFFSET 4
19 #define DPNI_CMD(id) (((id) << DPNI_CMD_ID_OFFSET) | DPNI_CMD_BASE_VERSION)
20 #define DPNI_CMD_V2(id) (((id) << DPNI_CMD_ID_OFFSET) | DPNI_CMD_VERSION_2)
21 #define DPNI_CMD_V3(id) (((id) << DPNI_CMD_ID_OFFSET) | DPNI_CMD_VERSION_3)
24 #define DPNI_CMDID_OPEN DPNI_CMD(0x801)
25 #define DPNI_CMDID_CLOSE DPNI_CMD(0x800)
26 #define DPNI_CMDID_CREATE DPNI_CMD_V2(0x901)
27 #define DPNI_CMDID_DESTROY DPNI_CMD(0x981)
28 #define DPNI_CMDID_GET_API_VERSION DPNI_CMD(0xa01)
30 #define DPNI_CMDID_ENABLE DPNI_CMD(0x002)
31 #define DPNI_CMDID_DISABLE DPNI_CMD(0x003)
32 #define DPNI_CMDID_GET_ATTR DPNI_CMD_V2(0x004)
33 #define DPNI_CMDID_RESET DPNI_CMD(0x005)
34 #define DPNI_CMDID_IS_ENABLED DPNI_CMD(0x006)
36 #define DPNI_CMDID_SET_IRQ_ENABLE DPNI_CMD(0x012)
37 #define DPNI_CMDID_GET_IRQ_ENABLE DPNI_CMD(0x013)
38 #define DPNI_CMDID_SET_IRQ_MASK DPNI_CMD(0x014)
39 #define DPNI_CMDID_GET_IRQ_MASK DPNI_CMD(0x015)
40 #define DPNI_CMDID_GET_IRQ_STATUS DPNI_CMD(0x016)
41 #define DPNI_CMDID_CLEAR_IRQ_STATUS DPNI_CMD(0x017)
43 #define DPNI_CMDID_SET_POOLS DPNI_CMD_V2(0x200)
44 #define DPNI_CMDID_SET_ERRORS_BEHAVIOR DPNI_CMD(0x20B)
46 #define DPNI_CMDID_GET_QDID DPNI_CMD(0x210)
47 #define DPNI_CMDID_GET_SP_INFO DPNI_CMD(0x211)
48 #define DPNI_CMDID_GET_TX_DATA_OFFSET DPNI_CMD(0x212)
49 #define DPNI_CMDID_GET_LINK_STATE DPNI_CMD_V2(0x215)
50 #define DPNI_CMDID_SET_MAX_FRAME_LENGTH DPNI_CMD(0x216)
51 #define DPNI_CMDID_GET_MAX_FRAME_LENGTH DPNI_CMD(0x217)
52 #define DPNI_CMDID_SET_LINK_CFG DPNI_CMD_V2(0x21A)
53 #define DPNI_CMDID_SET_TX_SHAPING DPNI_CMD_V2(0x21B)
55 #define DPNI_CMDID_SET_MCAST_PROMISC DPNI_CMD(0x220)
56 #define DPNI_CMDID_GET_MCAST_PROMISC DPNI_CMD(0x221)
57 #define DPNI_CMDID_SET_UNICAST_PROMISC DPNI_CMD(0x222)
58 #define DPNI_CMDID_GET_UNICAST_PROMISC DPNI_CMD(0x223)
59 #define DPNI_CMDID_SET_PRIM_MAC DPNI_CMD(0x224)
60 #define DPNI_CMDID_GET_PRIM_MAC DPNI_CMD(0x225)
61 #define DPNI_CMDID_ADD_MAC_ADDR DPNI_CMD(0x226)
62 #define DPNI_CMDID_REMOVE_MAC_ADDR DPNI_CMD(0x227)
63 #define DPNI_CMDID_CLR_MAC_FILTERS DPNI_CMD(0x228)
65 #define DPNI_CMDID_ENABLE_VLAN_FILTER DPNI_CMD(0x230)
66 #define DPNI_CMDID_ADD_VLAN_ID DPNI_CMD(0x231)
67 #define DPNI_CMDID_REMOVE_VLAN_ID DPNI_CMD(0x232)
68 #define DPNI_CMDID_CLR_VLAN_FILTERS DPNI_CMD(0x233)
70 #define DPNI_CMDID_SET_RX_TC_DIST DPNI_CMD_V3(0x235)
72 #define DPNI_CMDID_GET_STATISTICS DPNI_CMD_V2(0x25D)
73 #define DPNI_CMDID_RESET_STATISTICS DPNI_CMD(0x25E)
74 #define DPNI_CMDID_GET_QUEUE DPNI_CMD(0x25F)
75 #define DPNI_CMDID_SET_QUEUE DPNI_CMD(0x260)
76 #define DPNI_CMDID_GET_TAILDROP DPNI_CMD_V2(0x261)
77 #define DPNI_CMDID_SET_TAILDROP DPNI_CMD_V2(0x262)
79 #define DPNI_CMDID_GET_PORT_MAC_ADDR DPNI_CMD(0x263)
81 #define DPNI_CMDID_GET_BUFFER_LAYOUT DPNI_CMD_V2(0x264)
82 #define DPNI_CMDID_SET_BUFFER_LAYOUT DPNI_CMD_V2(0x265)
84 #define DPNI_CMDID_SET_CONGESTION_NOTIFICATION DPNI_CMD(0x267)
85 #define DPNI_CMDID_GET_CONGESTION_NOTIFICATION DPNI_CMD(0x268)
86 #define DPNI_CMDID_SET_EARLY_DROP DPNI_CMD_V2(0x269)
87 #define DPNI_CMDID_GET_EARLY_DROP DPNI_CMD_V2(0x26A)
88 #define DPNI_CMDID_GET_OFFLOAD DPNI_CMD(0x26B)
89 #define DPNI_CMDID_SET_OFFLOAD DPNI_CMD(0x26C)
90 #define DPNI_CMDID_SET_TX_CONFIRMATION_MODE DPNI_CMD(0x266)
91 #define DPNI_CMDID_GET_TX_CONFIRMATION_MODE DPNI_CMD(0x26D)
92 #define DPNI_CMDID_SET_OPR DPNI_CMD(0x26e)
93 #define DPNI_CMDID_GET_OPR DPNI_CMD(0x26f)
95 /* Macros for accessing command fields smaller than 1byte */
96 #define DPNI_MASK(field) \
97 GENMASK(DPNI_##field##_SHIFT + DPNI_##field##_SIZE - 1, \
99 #define dpni_set_field(var, field, val) \
100 ((var) |= (((val) << DPNI_##field##_SHIFT) & DPNI_MASK(field)))
101 #define dpni_get_field(var, field) \
102 (((var) & DPNI_MASK(field)) >> DPNI_##field##_SHIFT)
104 #pragma pack(push, 1)
105 struct dpni_cmd_open {
109 struct dpni_cmd_create {
113 uint8_t mac_filter_entries;
115 uint8_t vlan_filter_entries;
123 struct dpni_cmd_destroy {
127 #define DPNI_BACKUP_POOL(val, order) (((val) & 0x1) << (order))
129 struct dpni_cmd_pool {
131 uint8_t priority_mask;
135 struct dpni_cmd_set_pools {
137 uint8_t backup_pool_mask;
139 struct dpni_cmd_pool pool[8];
140 uint16_t buffer_size[8];
143 /* The enable indication is always the least significant bit */
144 #define DPNI_ENABLE_SHIFT 0
145 #define DPNI_ENABLE_SIZE 1
147 struct dpni_rsp_is_enabled {
151 struct dpni_cmd_set_irq_enable {
157 struct dpni_cmd_get_irq_enable {
162 struct dpni_rsp_get_irq_enable {
166 struct dpni_cmd_set_irq_mask {
171 struct dpni_cmd_get_irq_mask {
176 struct dpni_rsp_get_irq_mask {
180 struct dpni_cmd_get_irq_status {
185 struct dpni_rsp_get_irq_status {
189 struct dpni_cmd_clear_irq_status {
194 struct dpni_rsp_get_attr {
195 /* response word 0 */
199 uint8_t mac_filter_entries;
201 /* response word 1 */
202 uint8_t vlan_filter_entries;
208 /* response word 2 */
209 uint8_t qos_key_size;
211 uint16_t wriop_version;
214 #define DPNI_ERROR_ACTION_SHIFT 0
215 #define DPNI_ERROR_ACTION_SIZE 4
216 #define DPNI_FRAME_ANN_SHIFT 4
217 #define DPNI_FRAME_ANN_SIZE 1
219 struct dpni_cmd_set_errors_behavior {
221 /* from least significant bit: error_action:4, set_frame_annotation:1 */
225 /* There are 3 separate commands for configuring Rx, Tx and Tx confirmation
226 * buffer layouts, but they all share the same parameters.
227 * If one of the functions changes, below structure needs to be split.
230 #define DPNI_PASS_TS_SHIFT 0
231 #define DPNI_PASS_TS_SIZE 1
232 #define DPNI_PASS_PR_SHIFT 1
233 #define DPNI_PASS_PR_SIZE 1
234 #define DPNI_PASS_FS_SHIFT 2
235 #define DPNI_PASS_FS_SIZE 1
236 #define DPNI_PASS_SWO_SHIFT 3
237 #define DPNI_PASS_SWO_SIZE 1
239 struct dpni_cmd_get_buffer_layout {
243 struct dpni_rsp_get_buffer_layout {
244 /* response word 0 */
246 /* from LSB: pass_timestamp:1, parser_result:1, frame_status:1 */
249 /* response word 1 */
250 uint16_t private_data_size;
256 struct dpni_cmd_set_buffer_layout {
261 /* from LSB: pass_timestamp:1, parser_result:1, frame_status:1 */
265 uint16_t private_data_size;
271 struct dpni_cmd_set_offload {
273 uint8_t dpni_offload;
277 struct dpni_cmd_get_offload {
279 uint8_t dpni_offload;
282 struct dpni_rsp_get_offload {
287 struct dpni_cmd_get_qdid {
291 struct dpni_rsp_get_qdid {
295 struct dpni_rsp_get_sp_info {
299 struct dpni_rsp_get_tx_data_offset {
300 uint16_t data_offset;
303 struct dpni_cmd_get_statistics {
308 struct dpni_rsp_get_statistics {
312 struct dpni_cmd_set_link_cfg {
317 uint64_t advertising;
320 #define DPNI_LINK_STATE_SHIFT 0
321 #define DPNI_LINK_STATE_SIZE 1
322 #define DPNI_STATE_VALID_SHIFT 1
323 #define DPNI_STATE_VALID_SIZE 1
325 struct dpni_rsp_get_link_state {
334 uint64_t advertising;
337 struct dpni_cmd_set_max_frame_length {
338 uint16_t max_frame_length;
341 struct dpni_rsp_get_max_frame_length {
342 uint16_t max_frame_length;
345 struct dpni_cmd_set_multicast_promisc {
349 struct dpni_rsp_get_multicast_promisc {
353 struct dpni_cmd_set_unicast_promisc {
357 struct dpni_rsp_get_unicast_promisc {
361 struct dpni_cmd_set_primary_mac_addr {
366 struct dpni_rsp_get_primary_mac_addr {
371 struct dpni_rsp_get_port_mac_addr {
376 struct dpni_cmd_add_mac_addr {
381 struct dpni_cmd_remove_mac_addr {
386 #define DPNI_UNICAST_FILTERS_SHIFT 0
387 #define DPNI_UNICAST_FILTERS_SIZE 1
388 #define DPNI_MULTICAST_FILTERS_SHIFT 1
389 #define DPNI_MULTICAST_FILTERS_SIZE 1
391 struct dpni_cmd_clear_mac_filters {
392 /* from LSB: unicast:1, multicast:1 */
396 struct dpni_cmd_enable_vlan_filter {
401 struct dpni_cmd_vlan_id {
406 #define DPNI_SEPARATE_GRP_SHIFT 0
407 #define DPNI_SEPARATE_GRP_SIZE 1
408 #define DPNI_MODE_1_SHIFT 0
409 #define DPNI_MODE_1_SIZE 4
410 #define DPNI_MODE_2_SHIFT 4
411 #define DPNI_MODE_2_SIZE 4
413 struct dpni_cmd_set_tx_priorities {
415 uint8_t prio_group_A;
416 uint8_t prio_group_B;
421 uint16_t delta_bandwidth[8];
424 #define DPNI_DIST_MODE_SHIFT 0
425 #define DPNI_DIST_MODE_SIZE 4
426 #define DPNI_MISS_ACTION_SHIFT 4
427 #define DPNI_MISS_ACTION_SIZE 4
428 #define DPNI_KEEP_HASH_KEY_SHIFT 7
429 #define DPNI_KEEP_HASH_KEY_SIZE 1
430 #define DPNI_KEEP_ENTRIES_SHIFT 6
431 #define DPNI_KEEP_ENTRIES_SIZE 1
433 struct dpni_cmd_set_rx_tc_dist {
436 /* from LSB: dist_mode:4, miss_action:4 */
440 uint8_t keep_hash_key;
441 uint16_t default_flow_id;
443 uint64_t key_cfg_iova;
446 struct dpni_cmd_get_queue {
452 #define DPNI_DEST_TYPE_SHIFT 0
453 #define DPNI_DEST_TYPE_SIZE 4
454 #define DPNI_STASH_CTRL_SHIFT 6
455 #define DPNI_STASH_CTRL_SIZE 1
456 #define DPNI_HOLD_ACTIVE_SHIFT 7
457 #define DPNI_HOLD_ACTIVE_SIZE 1
459 struct dpni_rsp_get_queue {
460 /* response word 0 */
462 /* response word 1 */
466 /* From LSB: dest_type:4, pad:2, flc_stash_ctrl:1, hold_active:1 */
468 /* response word 2 */
470 /* response word 3 */
471 uint64_t user_context;
472 /* response word 4 */
477 struct dpni_cmd_set_queue {
492 uint64_t user_context;
495 #define DPNI_DROP_ENABLE_SHIFT 0
496 #define DPNI_DROP_ENABLE_SIZE 1
497 #define DPNI_DROP_UNITS_SHIFT 2
498 #define DPNI_DROP_UNITS_SIZE 2
500 struct dpni_early_drop {
501 /* from LSB: enable:1 units:2 */
505 uint8_t green_drop_probability;
507 uint64_t green_max_threshold;
508 uint64_t green_min_threshold;
510 uint8_t yellow_drop_probability;
512 uint64_t yellow_max_threshold;
513 uint64_t yellow_min_threshold;
515 uint8_t red_drop_probability;
517 uint64_t red_max_threshold;
518 uint64_t red_min_threshold;
521 struct dpni_cmd_early_drop {
525 uint64_t early_drop_iova;
528 struct dpni_rsp_get_api_version {
533 struct dpni_cmd_get_taildrop {
534 uint8_t congestion_point;
540 struct dpni_rsp_get_taildrop {
544 /* from LSB: enable:1 oal_lo:7 */
545 uint8_t enable_oal_lo;
546 /* from LSB: oal_hi:5 */
553 #define DPNI_OAL_LO_SHIFT 1
554 #define DPNI_OAL_LO_SIZE 7
555 #define DPNI_OAL_HI_SHIFT 0
556 #define DPNI_OAL_HI_SIZE 5
558 struct dpni_cmd_set_taildrop {
560 uint8_t congestion_point;
566 /* from LSB: enable:1 oal_lo:7 */
567 uint8_t enable_oal_lo;
568 /* from LSB: oal_hi:5 */
575 struct dpni_tx_confirmation_mode {
577 uint8_t confirmation_mode;
580 #define DPNI_DEST_TYPE_SHIFT 0
581 #define DPNI_DEST_TYPE_SIZE 4
582 #define DPNI_CONG_UNITS_SHIFT 4
583 #define DPNI_CONG_UNITS_SIZE 2
585 struct dpni_cmd_set_congestion_notification {
590 uint16_t notification_mode;
591 uint8_t dest_priority;
592 /* from LSB: dest_type: 4 units:2 */
594 uint64_t message_iova;
595 uint64_t message_ctx;
596 uint32_t threshold_entry;
597 uint32_t threshold_exit;
600 struct dpni_cmd_get_congestion_notification {
605 struct dpni_rsp_get_congestion_notification {
608 uint16_t notification_mode;
609 uint8_t dest_priority;
610 /* from LSB: dest_type: 4 units:2 */
612 uint64_t message_iova;
613 uint64_t message_ctx;
614 uint32_t threshold_entry;
615 uint32_t threshold_exit;
618 struct dpni_cmd_set_opr {
631 struct dpni_cmd_get_opr {
637 #define DPNI_RIP_SHIFT 0
638 #define DPNI_RIP_SIZE 1
639 #define DPNI_OPR_ENABLE_SHIFT 1
640 #define DPNI_OPR_ENABLE_SIZE 1
641 #define DPNI_TSEQ_NLIS_SHIFT 0
642 #define DPNI_TSEQ_NLIS_SIZE 1
643 #define DPNI_HSEQ_NLIS_SHIFT 0
644 #define DPNI_HSEQ_NLIS_SIZE 1
646 struct dpni_rsp_get_opr {
648 /* from LSB: rip:1 enable:1 */
678 #endif /* _FSL_DPNI_CMD_H */