2 * This file is provided under a dual BSD/GPLv2 license. When using or
3 * redistributing this file, you may do so under either license.
7 * Copyright 2013-2016 Freescale Semiconductor Inc.
8 * Copyright 2016-2017 NXP.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met:
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * * Neither the name of the above-listed copyright holders nor the
18 * names of any contributors may be used to endorse or promote products
19 * derived from this software without specific prior written permission.
23 * ALTERNATIVELY, this software may be distributed under the terms of the
24 * GNU General Public License ("GPL") as published by the Free Software
25 * Foundation, either version 2 of that License or (at your option) any
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
32 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 * POSSIBILITY OF SUCH DAMAGE.
40 #ifndef _FSL_DPNI_CMD_H
41 #define _FSL_DPNI_CMD_H
44 #define DPNI_VER_MAJOR 7
45 #define DPNI_VER_MINOR 3
47 #define DPNI_CMD_BASE_VERSION 1
48 #define DPNI_CMD_VERSION_2 2
49 #define DPNI_CMD_ID_OFFSET 4
51 #define DPNI_CMD(id) (((id) << DPNI_CMD_ID_OFFSET) | DPNI_CMD_BASE_VERSION)
52 #define DPNI_CMD_V2(id) (((id) << DPNI_CMD_ID_OFFSET) | DPNI_CMD_VERSION_2)
55 #define DPNI_CMDID_OPEN DPNI_CMD(0x801)
56 #define DPNI_CMDID_CLOSE DPNI_CMD(0x800)
57 #define DPNI_CMDID_CREATE DPNI_CMD(0x901)
58 #define DPNI_CMDID_DESTROY DPNI_CMD(0x981)
59 #define DPNI_CMDID_GET_API_VERSION DPNI_CMD(0xa01)
61 #define DPNI_CMDID_ENABLE DPNI_CMD(0x002)
62 #define DPNI_CMDID_DISABLE DPNI_CMD(0x003)
63 #define DPNI_CMDID_GET_ATTR DPNI_CMD_V2(0x004)
64 #define DPNI_CMDID_RESET DPNI_CMD(0x005)
65 #define DPNI_CMDID_IS_ENABLED DPNI_CMD(0x006)
67 #define DPNI_CMDID_SET_IRQ_ENABLE DPNI_CMD(0x012)
68 #define DPNI_CMDID_GET_IRQ_ENABLE DPNI_CMD(0x013)
69 #define DPNI_CMDID_SET_IRQ_MASK DPNI_CMD(0x014)
70 #define DPNI_CMDID_GET_IRQ_MASK DPNI_CMD(0x015)
71 #define DPNI_CMDID_GET_IRQ_STATUS DPNI_CMD(0x016)
72 #define DPNI_CMDID_CLEAR_IRQ_STATUS DPNI_CMD(0x017)
74 #define DPNI_CMDID_SET_POOLS DPNI_CMD_V2(0x200)
75 #define DPNI_CMDID_SET_ERRORS_BEHAVIOR DPNI_CMD(0x20B)
77 #define DPNI_CMDID_GET_QDID DPNI_CMD(0x210)
78 #define DPNI_CMDID_GET_SP_INFO DPNI_CMD(0x211)
79 #define DPNI_CMDID_GET_TX_DATA_OFFSET DPNI_CMD(0x212)
80 #define DPNI_CMDID_GET_LINK_STATE DPNI_CMD(0x215)
81 #define DPNI_CMDID_SET_MAX_FRAME_LENGTH DPNI_CMD(0x216)
82 #define DPNI_CMDID_GET_MAX_FRAME_LENGTH DPNI_CMD(0x217)
83 #define DPNI_CMDID_SET_LINK_CFG DPNI_CMD(0x21A)
84 #define DPNI_CMDID_SET_TX_SHAPING DPNI_CMD_V2(0x21B)
86 #define DPNI_CMDID_SET_MCAST_PROMISC DPNI_CMD(0x220)
87 #define DPNI_CMDID_GET_MCAST_PROMISC DPNI_CMD(0x221)
88 #define DPNI_CMDID_SET_UNICAST_PROMISC DPNI_CMD(0x222)
89 #define DPNI_CMDID_GET_UNICAST_PROMISC DPNI_CMD(0x223)
90 #define DPNI_CMDID_SET_PRIM_MAC DPNI_CMD(0x224)
91 #define DPNI_CMDID_GET_PRIM_MAC DPNI_CMD(0x225)
92 #define DPNI_CMDID_ADD_MAC_ADDR DPNI_CMD(0x226)
93 #define DPNI_CMDID_REMOVE_MAC_ADDR DPNI_CMD(0x227)
94 #define DPNI_CMDID_CLR_MAC_FILTERS DPNI_CMD(0x228)
96 #define DPNI_CMDID_ENABLE_VLAN_FILTER DPNI_CMD(0x230)
97 #define DPNI_CMDID_ADD_VLAN_ID DPNI_CMD(0x231)
98 #define DPNI_CMDID_REMOVE_VLAN_ID DPNI_CMD(0x232)
99 #define DPNI_CMDID_CLR_VLAN_FILTERS DPNI_CMD(0x233)
101 #define DPNI_CMDID_SET_RX_TC_DIST DPNI_CMD_V2(0x235)
103 #define DPNI_CMDID_GET_STATISTICS DPNI_CMD_V2(0x25D)
104 #define DPNI_CMDID_RESET_STATISTICS DPNI_CMD(0x25E)
105 #define DPNI_CMDID_GET_QUEUE DPNI_CMD(0x25F)
106 #define DPNI_CMDID_SET_QUEUE DPNI_CMD(0x260)
107 #define DPNI_CMDID_GET_TAILDROP DPNI_CMD_V2(0x261)
108 #define DPNI_CMDID_SET_TAILDROP DPNI_CMD_V2(0x262)
110 #define DPNI_CMDID_GET_PORT_MAC_ADDR DPNI_CMD(0x263)
112 #define DPNI_CMDID_GET_BUFFER_LAYOUT DPNI_CMD(0x264)
113 #define DPNI_CMDID_SET_BUFFER_LAYOUT DPNI_CMD(0x265)
115 #define DPNI_CMDID_SET_CONGESTION_NOTIFICATION DPNI_CMD(0x267)
116 #define DPNI_CMDID_GET_CONGESTION_NOTIFICATION DPNI_CMD(0x268)
117 #define DPNI_CMDID_SET_EARLY_DROP DPNI_CMD_V2(0x269)
118 #define DPNI_CMDID_GET_EARLY_DROP DPNI_CMD_V2(0x26A)
119 #define DPNI_CMDID_GET_OFFLOAD DPNI_CMD(0x26B)
120 #define DPNI_CMDID_SET_OFFLOAD DPNI_CMD(0x26C)
121 #define DPNI_CMDID_SET_TX_CONFIRMATION_MODE DPNI_CMD(0x266)
122 #define DPNI_CMDID_GET_TX_CONFIRMATION_MODE DPNI_CMD(0x26D)
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;
144 uint8_t vlan_filter_entries;
151 struct dpni_cmd_destroy {
155 #define DPNI_BACKUP_POOL(val, order) (((val) & 0x1) << (order))
157 struct dpni_cmd_pool {
159 uint8_t priority_mask;
163 struct dpni_cmd_set_pools {
165 uint8_t backup_pool_mask;
167 struct dpni_cmd_pool pool[8];
168 uint16_t buffer_size[8];
171 /* The enable indication is always the least significant bit */
172 #define DPNI_ENABLE_SHIFT 0
173 #define DPNI_ENABLE_SIZE 1
175 struct dpni_rsp_is_enabled {
179 struct dpni_cmd_set_irq_enable {
185 struct dpni_cmd_get_irq_enable {
190 struct dpni_rsp_get_irq_enable {
194 struct dpni_cmd_set_irq_mask {
199 struct dpni_cmd_get_irq_mask {
204 struct dpni_rsp_get_irq_mask {
208 struct dpni_cmd_get_irq_status {
213 struct dpni_rsp_get_irq_status {
217 struct dpni_cmd_clear_irq_status {
222 struct dpni_rsp_get_attr {
223 /* response word 0 */
227 uint8_t mac_filter_entries;
229 /* response word 1 */
230 uint8_t vlan_filter_entries;
236 /* response word 2 */
237 uint8_t qos_key_size;
239 uint16_t wriop_version;
242 #define DPNI_ERROR_ACTION_SHIFT 0
243 #define DPNI_ERROR_ACTION_SIZE 4
244 #define DPNI_FRAME_ANN_SHIFT 4
245 #define DPNI_FRAME_ANN_SIZE 1
247 struct dpni_cmd_set_errors_behavior {
249 /* from least significant bit: error_action:4, set_frame_annotation:1 */
253 /* There are 3 separate commands for configuring Rx, Tx and Tx confirmation
254 * buffer layouts, but they all share the same parameters.
255 * If one of the functions changes, below structure needs to be split.
258 #define DPNI_PASS_TS_SHIFT 0
259 #define DPNI_PASS_TS_SIZE 1
260 #define DPNI_PASS_PR_SHIFT 1
261 #define DPNI_PASS_PR_SIZE 1
262 #define DPNI_PASS_FS_SHIFT 2
263 #define DPNI_PASS_FS_SIZE 1
265 struct dpni_cmd_get_buffer_layout {
269 struct dpni_rsp_get_buffer_layout {
270 /* response word 0 */
272 /* from LSB: pass_timestamp:1, parser_result:1, frame_status:1 */
275 /* response word 1 */
276 uint16_t private_data_size;
282 struct dpni_cmd_set_buffer_layout {
287 /* from LSB: pass_timestamp:1, parser_result:1, frame_status:1 */
291 uint16_t private_data_size;
297 struct dpni_cmd_set_offload {
299 uint8_t dpni_offload;
303 struct dpni_cmd_get_offload {
305 uint8_t dpni_offload;
308 struct dpni_rsp_get_offload {
313 struct dpni_cmd_get_qdid {
317 struct dpni_rsp_get_qdid {
321 struct dpni_rsp_get_sp_info {
325 struct dpni_rsp_get_tx_data_offset {
326 uint16_t data_offset;
329 struct dpni_cmd_get_statistics {
334 struct dpni_rsp_get_statistics {
338 struct dpni_cmd_set_link_cfg {
345 #define DPNI_LINK_STATE_SHIFT 0
346 #define DPNI_LINK_STATE_SIZE 1
348 struct dpni_rsp_get_link_state {
358 struct dpni_cmd_set_max_frame_length {
359 uint16_t max_frame_length;
362 struct dpni_rsp_get_max_frame_length {
363 uint16_t max_frame_length;
366 struct dpni_cmd_set_multicast_promisc {
370 struct dpni_rsp_get_multicast_promisc {
374 struct dpni_cmd_set_unicast_promisc {
378 struct dpni_rsp_get_unicast_promisc {
382 struct dpni_cmd_set_primary_mac_addr {
387 struct dpni_rsp_get_primary_mac_addr {
392 struct dpni_rsp_get_port_mac_addr {
397 struct dpni_cmd_add_mac_addr {
402 struct dpni_cmd_remove_mac_addr {
407 #define DPNI_UNICAST_FILTERS_SHIFT 0
408 #define DPNI_UNICAST_FILTERS_SIZE 1
409 #define DPNI_MULTICAST_FILTERS_SHIFT 1
410 #define DPNI_MULTICAST_FILTERS_SIZE 1
412 struct dpni_cmd_clear_mac_filters {
413 /* from LSB: unicast:1, multicast:1 */
417 struct dpni_cmd_enable_vlan_filter {
422 struct dpni_cmd_vlan_id {
427 #define DPNI_SEPARATE_GRP_SHIFT 0
428 #define DPNI_SEPARATE_GRP_SIZE 1
429 #define DPNI_MODE_1_SHIFT 0
430 #define DPNI_MODE_1_SIZE 4
431 #define DPNI_MODE_2_SHIFT 4
432 #define DPNI_MODE_2_SIZE 4
434 struct dpni_cmd_set_tx_priorities {
436 uint8_t prio_group_A;
437 uint8_t prio_group_B;
442 uint16_t delta_bandwidth[8];
445 #define DPNI_DIST_MODE_SHIFT 0
446 #define DPNI_DIST_MODE_SIZE 4
447 #define DPNI_MISS_ACTION_SHIFT 4
448 #define DPNI_MISS_ACTION_SIZE 4
449 #define DPNI_KEEP_HASH_KEY_SHIFT 7
450 #define DPNI_KEEP_HASH_KEY_SIZE 1
452 struct dpni_cmd_set_rx_tc_dist {
455 /* from LSB: dist_mode:4, miss_action:4 */
459 uint8_t keep_hash_key;
460 uint16_t default_flow_id;
462 uint64_t key_cfg_iova;
465 struct dpni_cmd_get_queue {
471 #define DPNI_DEST_TYPE_SHIFT 0
472 #define DPNI_DEST_TYPE_SIZE 4
473 #define DPNI_STASH_CTRL_SHIFT 6
474 #define DPNI_STASH_CTRL_SIZE 1
475 #define DPNI_HOLD_ACTIVE_SHIFT 7
476 #define DPNI_HOLD_ACTIVE_SIZE 1
478 struct dpni_rsp_get_queue {
479 /* response word 0 */
481 /* response word 1 */
485 /* From LSB: dest_type:4, pad:2, flc_stash_ctrl:1, hold_active:1 */
487 /* response word 2 */
489 /* response word 3 */
490 uint64_t user_context;
491 /* response word 4 */
496 struct dpni_cmd_set_queue {
511 uint64_t user_context;
514 #define DPNI_DROP_ENABLE_SHIFT 0
515 #define DPNI_DROP_ENABLE_SIZE 1
516 #define DPNI_DROP_UNITS_SHIFT 2
517 #define DPNI_DROP_UNITS_SIZE 2
519 struct dpni_early_drop {
520 /* from LSB: enable:1 units:2 */
524 uint8_t green_drop_probability;
526 uint64_t green_max_threshold;
527 uint64_t green_min_threshold;
529 uint8_t yellow_drop_probability;
531 uint64_t yellow_max_threshold;
532 uint64_t yellow_min_threshold;
534 uint8_t red_drop_probability;
536 uint64_t red_max_threshold;
537 uint64_t red_min_threshold;
540 struct dpni_cmd_early_drop {
544 uint64_t early_drop_iova;
547 struct dpni_rsp_get_api_version {
552 struct dpni_cmd_get_taildrop {
553 uint8_t congestion_point;
559 struct dpni_rsp_get_taildrop {
563 /* from LSB: enable:1 oal_lo:7 */
564 uint8_t enable_oal_lo;
565 /* from LSB: oal_hi:5 */
572 #define DPNI_OAL_LO_SHIFT 1
573 #define DPNI_OAL_LO_SIZE 7
574 #define DPNI_OAL_HI_SHIFT 0
575 #define DPNI_OAL_HI_SIZE 5
577 struct dpni_cmd_set_taildrop {
579 uint8_t congestion_point;
585 /* from LSB: enable:1 oal_lo:7 */
586 uint8_t enable_oal_lo;
587 /* from LSB: oal_hi:5 */
594 struct dpni_tx_confirmation_mode {
596 uint8_t confirmation_mode;
599 #define DPNI_DEST_TYPE_SHIFT 0
600 #define DPNI_DEST_TYPE_SIZE 4
601 #define DPNI_CONG_UNITS_SHIFT 4
602 #define DPNI_CONG_UNITS_SIZE 2
604 struct dpni_cmd_set_congestion_notification {
609 uint16_t notification_mode;
610 uint8_t dest_priority;
611 /* from LSB: dest_type: 4 units:2 */
613 uint64_t message_iova;
614 uint64_t message_ctx;
615 uint32_t threshold_entry;
616 uint32_t threshold_exit;
619 struct dpni_cmd_get_congestion_notification {
624 struct dpni_rsp_get_congestion_notification {
627 uint16_t notification_mode;
628 uint8_t dest_priority;
629 /* from LSB: dest_type: 4 units:2 */
631 uint64_t message_iova;
632 uint64_t message_ctx;
633 uint32_t threshold_entry;
634 uint32_t threshold_exit;
638 #endif /* _FSL_DPNI_CMD_H */