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)
94 #define DPNI_CMDID_ADD_CUSTOM_TPID DPNI_CMD(0x275)
95 #define DPNI_CMDID_REMOVE_CUSTOM_TPID DPNI_CMD(0x276)
96 #define DPNI_CMDID_GET_CUSTOM_TPID DPNI_CMD(0x277)
98 /* Macros for accessing command fields smaller than 1byte */
99 #define DPNI_MASK(field) \
100 GENMASK(DPNI_##field##_SHIFT + DPNI_##field##_SIZE - 1, \
101 DPNI_##field##_SHIFT)
102 #define dpni_set_field(var, field, val) \
103 ((var) |= (((val) << DPNI_##field##_SHIFT) & DPNI_MASK(field)))
104 #define dpni_get_field(var, field) \
105 (((var) & DPNI_MASK(field)) >> DPNI_##field##_SHIFT)
107 #pragma pack(push, 1)
108 struct dpni_cmd_open {
112 struct dpni_cmd_create {
116 uint8_t mac_filter_entries;
118 uint8_t vlan_filter_entries;
126 struct dpni_cmd_destroy {
130 #define DPNI_BACKUP_POOL(val, order) (((val) & 0x1) << (order))
132 struct dpni_cmd_pool {
134 uint8_t priority_mask;
138 struct dpni_cmd_set_pools {
140 uint8_t backup_pool_mask;
142 struct dpni_cmd_pool pool[8];
143 uint16_t buffer_size[8];
146 /* The enable indication is always the least significant bit */
147 #define DPNI_ENABLE_SHIFT 0
148 #define DPNI_ENABLE_SIZE 1
150 struct dpni_rsp_is_enabled {
154 struct dpni_cmd_set_irq_enable {
160 struct dpni_cmd_get_irq_enable {
165 struct dpni_rsp_get_irq_enable {
169 struct dpni_cmd_set_irq_mask {
174 struct dpni_cmd_get_irq_mask {
179 struct dpni_rsp_get_irq_mask {
183 struct dpni_cmd_get_irq_status {
188 struct dpni_rsp_get_irq_status {
192 struct dpni_cmd_clear_irq_status {
197 struct dpni_rsp_get_attr {
198 /* response word 0 */
202 uint8_t mac_filter_entries;
204 /* response word 1 */
205 uint8_t vlan_filter_entries;
211 /* response word 2 */
212 uint8_t qos_key_size;
214 uint16_t wriop_version;
217 #define DPNI_ERROR_ACTION_SHIFT 0
218 #define DPNI_ERROR_ACTION_SIZE 4
219 #define DPNI_FRAME_ANN_SHIFT 4
220 #define DPNI_FRAME_ANN_SIZE 1
222 struct dpni_cmd_set_errors_behavior {
224 /* from least significant bit: error_action:4, set_frame_annotation:1 */
228 /* There are 3 separate commands for configuring Rx, Tx and Tx confirmation
229 * buffer layouts, but they all share the same parameters.
230 * If one of the functions changes, below structure needs to be split.
233 #define DPNI_PASS_TS_SHIFT 0
234 #define DPNI_PASS_TS_SIZE 1
235 #define DPNI_PASS_PR_SHIFT 1
236 #define DPNI_PASS_PR_SIZE 1
237 #define DPNI_PASS_FS_SHIFT 2
238 #define DPNI_PASS_FS_SIZE 1
239 #define DPNI_PASS_SWO_SHIFT 3
240 #define DPNI_PASS_SWO_SIZE 1
242 struct dpni_cmd_get_buffer_layout {
246 struct dpni_rsp_get_buffer_layout {
247 /* response word 0 */
249 /* from LSB: pass_timestamp:1, parser_result:1, frame_status:1 */
252 /* response word 1 */
253 uint16_t private_data_size;
259 struct dpni_cmd_set_buffer_layout {
264 /* from LSB: pass_timestamp:1, parser_result:1, frame_status:1 */
268 uint16_t private_data_size;
274 struct dpni_cmd_set_offload {
276 uint8_t dpni_offload;
280 struct dpni_cmd_get_offload {
282 uint8_t dpni_offload;
285 struct dpni_rsp_get_offload {
290 struct dpni_cmd_get_qdid {
294 struct dpni_rsp_get_qdid {
298 struct dpni_rsp_get_sp_info {
302 struct dpni_rsp_get_tx_data_offset {
303 uint16_t data_offset;
306 struct dpni_cmd_get_statistics {
311 struct dpni_rsp_get_statistics {
315 struct dpni_cmd_set_link_cfg {
320 uint64_t advertising;
323 #define DPNI_LINK_STATE_SHIFT 0
324 #define DPNI_LINK_STATE_SIZE 1
325 #define DPNI_STATE_VALID_SHIFT 1
326 #define DPNI_STATE_VALID_SIZE 1
328 struct dpni_rsp_get_link_state {
337 uint64_t advertising;
340 struct dpni_cmd_set_max_frame_length {
341 uint16_t max_frame_length;
344 struct dpni_rsp_get_max_frame_length {
345 uint16_t max_frame_length;
348 struct dpni_cmd_set_multicast_promisc {
352 struct dpni_rsp_get_multicast_promisc {
356 struct dpni_cmd_set_unicast_promisc {
360 struct dpni_rsp_get_unicast_promisc {
364 struct dpni_cmd_set_primary_mac_addr {
369 struct dpni_rsp_get_primary_mac_addr {
374 struct dpni_rsp_get_port_mac_addr {
379 struct dpni_cmd_add_mac_addr {
384 struct dpni_cmd_remove_mac_addr {
389 #define DPNI_UNICAST_FILTERS_SHIFT 0
390 #define DPNI_UNICAST_FILTERS_SIZE 1
391 #define DPNI_MULTICAST_FILTERS_SHIFT 1
392 #define DPNI_MULTICAST_FILTERS_SIZE 1
394 struct dpni_cmd_clear_mac_filters {
395 /* from LSB: unicast:1, multicast:1 */
399 struct dpni_cmd_enable_vlan_filter {
404 struct dpni_cmd_vlan_id {
409 #define DPNI_SEPARATE_GRP_SHIFT 0
410 #define DPNI_SEPARATE_GRP_SIZE 1
411 #define DPNI_MODE_1_SHIFT 0
412 #define DPNI_MODE_1_SIZE 4
413 #define DPNI_MODE_2_SHIFT 4
414 #define DPNI_MODE_2_SIZE 4
416 struct dpni_cmd_set_tx_priorities {
418 uint8_t prio_group_A;
419 uint8_t prio_group_B;
424 uint16_t delta_bandwidth[8];
427 #define DPNI_DIST_MODE_SHIFT 0
428 #define DPNI_DIST_MODE_SIZE 4
429 #define DPNI_MISS_ACTION_SHIFT 4
430 #define DPNI_MISS_ACTION_SIZE 4
431 #define DPNI_KEEP_HASH_KEY_SHIFT 7
432 #define DPNI_KEEP_HASH_KEY_SIZE 1
433 #define DPNI_KEEP_ENTRIES_SHIFT 6
434 #define DPNI_KEEP_ENTRIES_SIZE 1
436 struct dpni_cmd_set_rx_tc_dist {
439 /* from LSB: dist_mode:4, miss_action:4 */
443 uint8_t keep_hash_key;
444 uint16_t default_flow_id;
446 uint64_t key_cfg_iova;
449 struct dpni_cmd_get_queue {
455 #define DPNI_DEST_TYPE_SHIFT 0
456 #define DPNI_DEST_TYPE_SIZE 4
457 #define DPNI_STASH_CTRL_SHIFT 6
458 #define DPNI_STASH_CTRL_SIZE 1
459 #define DPNI_HOLD_ACTIVE_SHIFT 7
460 #define DPNI_HOLD_ACTIVE_SIZE 1
462 struct dpni_rsp_get_queue {
463 /* response word 0 */
465 /* response word 1 */
469 /* From LSB: dest_type:4, pad:2, flc_stash_ctrl:1, hold_active:1 */
471 /* response word 2 */
473 /* response word 3 */
474 uint64_t user_context;
475 /* response word 4 */
480 struct dpni_cmd_set_queue {
495 uint64_t user_context;
498 #define DPNI_DROP_ENABLE_SHIFT 0
499 #define DPNI_DROP_ENABLE_SIZE 1
500 #define DPNI_DROP_UNITS_SHIFT 2
501 #define DPNI_DROP_UNITS_SIZE 2
503 struct dpni_early_drop {
504 /* from LSB: enable:1 units:2 */
508 uint8_t green_drop_probability;
510 uint64_t green_max_threshold;
511 uint64_t green_min_threshold;
513 uint8_t yellow_drop_probability;
515 uint64_t yellow_max_threshold;
516 uint64_t yellow_min_threshold;
518 uint8_t red_drop_probability;
520 uint64_t red_max_threshold;
521 uint64_t red_min_threshold;
524 struct dpni_cmd_early_drop {
528 uint64_t early_drop_iova;
531 struct dpni_rsp_get_api_version {
536 struct dpni_cmd_get_taildrop {
537 uint8_t congestion_point;
543 struct dpni_rsp_get_taildrop {
547 /* from LSB: enable:1 oal_lo:7 */
548 uint8_t enable_oal_lo;
549 /* from LSB: oal_hi:5 */
556 #define DPNI_OAL_LO_SHIFT 1
557 #define DPNI_OAL_LO_SIZE 7
558 #define DPNI_OAL_HI_SHIFT 0
559 #define DPNI_OAL_HI_SIZE 5
561 struct dpni_cmd_set_taildrop {
563 uint8_t congestion_point;
569 /* from LSB: enable:1 oal_lo:7 */
570 uint8_t enable_oal_lo;
571 /* from LSB: oal_hi:5 */
578 struct dpni_tx_confirmation_mode {
580 uint8_t confirmation_mode;
583 #define DPNI_DEST_TYPE_SHIFT 0
584 #define DPNI_DEST_TYPE_SIZE 4
585 #define DPNI_CONG_UNITS_SHIFT 4
586 #define DPNI_CONG_UNITS_SIZE 2
588 struct dpni_cmd_set_congestion_notification {
593 uint16_t notification_mode;
594 uint8_t dest_priority;
595 /* from LSB: dest_type: 4 units:2 */
597 uint64_t message_iova;
598 uint64_t message_ctx;
599 uint32_t threshold_entry;
600 uint32_t threshold_exit;
603 struct dpni_cmd_get_congestion_notification {
608 struct dpni_rsp_get_congestion_notification {
611 uint16_t notification_mode;
612 uint8_t dest_priority;
613 /* from LSB: dest_type: 4 units:2 */
615 uint64_t message_iova;
616 uint64_t message_ctx;
617 uint32_t threshold_entry;
618 uint32_t threshold_exit;
621 struct dpni_cmd_set_opr {
634 struct dpni_cmd_get_opr {
640 #define DPNI_RIP_SHIFT 0
641 #define DPNI_RIP_SIZE 1
642 #define DPNI_OPR_ENABLE_SHIFT 1
643 #define DPNI_OPR_ENABLE_SIZE 1
644 #define DPNI_TSEQ_NLIS_SHIFT 0
645 #define DPNI_TSEQ_NLIS_SIZE 1
646 #define DPNI_HSEQ_NLIS_SHIFT 0
647 #define DPNI_HSEQ_NLIS_SIZE 1
649 struct dpni_rsp_get_opr {
651 /* from LSB: rip:1 enable:1 */
680 struct dpni_cmd_add_custom_tpid {
685 struct dpni_cmd_remove_custom_tpid {
690 struct dpni_rsp_get_custom_tpid {
696 #endif /* _FSL_DPNI_CMD_H */