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_POOLS DPNI_CMD_V2(0x200)
68 #define DPNI_CMDID_SET_ERRORS_BEHAVIOR DPNI_CMD(0x20B)
70 #define DPNI_CMDID_GET_QDID DPNI_CMD(0x210)
71 #define DPNI_CMDID_GET_SP_INFO DPNI_CMD(0x211)
72 #define DPNI_CMDID_GET_TX_DATA_OFFSET DPNI_CMD(0x212)
73 #define DPNI_CMDID_GET_LINK_STATE DPNI_CMD(0x215)
74 #define DPNI_CMDID_SET_MAX_FRAME_LENGTH DPNI_CMD(0x216)
75 #define DPNI_CMDID_GET_MAX_FRAME_LENGTH DPNI_CMD(0x217)
76 #define DPNI_CMDID_SET_LINK_CFG DPNI_CMD(0x21A)
77 #define DPNI_CMDID_SET_TX_SHAPING DPNI_CMD_V2(0x21B)
79 #define DPNI_CMDID_SET_MCAST_PROMISC DPNI_CMD(0x220)
80 #define DPNI_CMDID_GET_MCAST_PROMISC DPNI_CMD(0x221)
81 #define DPNI_CMDID_SET_UNICAST_PROMISC DPNI_CMD(0x222)
82 #define DPNI_CMDID_GET_UNICAST_PROMISC DPNI_CMD(0x223)
83 #define DPNI_CMDID_SET_PRIM_MAC DPNI_CMD(0x224)
84 #define DPNI_CMDID_GET_PRIM_MAC DPNI_CMD(0x225)
85 #define DPNI_CMDID_ADD_MAC_ADDR DPNI_CMD(0x226)
86 #define DPNI_CMDID_REMOVE_MAC_ADDR DPNI_CMD(0x227)
87 #define DPNI_CMDID_CLR_MAC_FILTERS DPNI_CMD(0x228)
89 #define DPNI_CMDID_ENABLE_VLAN_FILTER DPNI_CMD(0x230)
90 #define DPNI_CMDID_ADD_VLAN_ID DPNI_CMD(0x231)
91 #define DPNI_CMDID_REMOVE_VLAN_ID DPNI_CMD(0x232)
92 #define DPNI_CMDID_CLR_VLAN_FILTERS DPNI_CMD(0x233)
94 #define DPNI_CMDID_SET_RX_TC_DIST DPNI_CMD_V2(0x235)
96 #define DPNI_CMDID_GET_STATISTICS DPNI_CMD_V2(0x25D)
97 #define DPNI_CMDID_RESET_STATISTICS DPNI_CMD(0x25E)
98 #define DPNI_CMDID_GET_QUEUE DPNI_CMD(0x25F)
99 #define DPNI_CMDID_SET_QUEUE DPNI_CMD(0x260)
100 #define DPNI_CMDID_GET_TAILDROP DPNI_CMD_V2(0x261)
101 #define DPNI_CMDID_SET_TAILDROP DPNI_CMD_V2(0x262)
103 #define DPNI_CMDID_GET_PORT_MAC_ADDR DPNI_CMD(0x263)
105 #define DPNI_CMDID_GET_BUFFER_LAYOUT DPNI_CMD(0x264)
106 #define DPNI_CMDID_SET_BUFFER_LAYOUT DPNI_CMD(0x265)
108 #define DPNI_CMDID_SET_CONGESTION_NOTIFICATION DPNI_CMD(0x267)
109 #define DPNI_CMDID_GET_CONGESTION_NOTIFICATION DPNI_CMD(0x268)
110 #define DPNI_CMDID_SET_EARLY_DROP DPNI_CMD_V2(0x269)
111 #define DPNI_CMDID_GET_EARLY_DROP DPNI_CMD_V2(0x26A)
112 #define DPNI_CMDID_GET_OFFLOAD DPNI_CMD(0x26B)
113 #define DPNI_CMDID_SET_OFFLOAD DPNI_CMD(0x26C)
114 #define DPNI_CMDID_SET_TX_CONFIRMATION_MODE DPNI_CMD(0x266)
115 #define DPNI_CMDID_GET_TX_CONFIRMATION_MODE DPNI_CMD(0x26D)
117 /* Macros for accessing command fields smaller than 1byte */
118 #define DPNI_MASK(field) \
119 GENMASK(DPNI_##field##_SHIFT + DPNI_##field##_SIZE - 1, \
120 DPNI_##field##_SHIFT)
121 #define dpni_set_field(var, field, val) \
122 ((var) |= (((val) << DPNI_##field##_SHIFT) & DPNI_MASK(field)))
123 #define dpni_get_field(var, field) \
124 (((var) & DPNI_MASK(field)) >> DPNI_##field##_SHIFT)
126 #pragma pack(push, 1)
127 struct dpni_cmd_open {
131 struct dpni_cmd_create {
135 uint8_t mac_filter_entries;
137 uint8_t vlan_filter_entries;
144 struct dpni_cmd_destroy {
148 #define DPNI_BACKUP_POOL(val, order) (((val) & 0x1) << (order))
150 struct dpni_cmd_pool {
152 uint8_t priority_mask;
156 struct dpni_cmd_set_pools {
158 uint8_t backup_pool_mask;
160 struct dpni_cmd_pool pool[8];
161 uint16_t buffer_size[8];
164 /* The enable indication is always the least significant bit */
165 #define DPNI_ENABLE_SHIFT 0
166 #define DPNI_ENABLE_SIZE 1
168 struct dpni_rsp_is_enabled {
172 struct dpni_rsp_get_attr {
173 /* response word 0 */
177 uint8_t mac_filter_entries;
179 /* response word 1 */
180 uint8_t vlan_filter_entries;
186 /* response word 2 */
187 uint8_t qos_key_size;
189 uint16_t wriop_version;
192 #define DPNI_ERROR_ACTION_SHIFT 0
193 #define DPNI_ERROR_ACTION_SIZE 4
194 #define DPNI_FRAME_ANN_SHIFT 4
195 #define DPNI_FRAME_ANN_SIZE 1
197 struct dpni_cmd_set_errors_behavior {
199 /* from least significant bit: error_action:4, set_frame_annotation:1 */
203 /* There are 3 separate commands for configuring Rx, Tx and Tx confirmation
204 * buffer layouts, but they all share the same parameters.
205 * If one of the functions changes, below structure needs to be split.
208 #define DPNI_PASS_TS_SHIFT 0
209 #define DPNI_PASS_TS_SIZE 1
210 #define DPNI_PASS_PR_SHIFT 1
211 #define DPNI_PASS_PR_SIZE 1
212 #define DPNI_PASS_FS_SHIFT 2
213 #define DPNI_PASS_FS_SIZE 1
215 struct dpni_cmd_get_buffer_layout {
219 struct dpni_rsp_get_buffer_layout {
220 /* response word 0 */
222 /* from LSB: pass_timestamp:1, parser_result:1, frame_status:1 */
225 /* response word 1 */
226 uint16_t private_data_size;
232 struct dpni_cmd_set_buffer_layout {
237 /* from LSB: pass_timestamp:1, parser_result:1, frame_status:1 */
241 uint16_t private_data_size;
247 struct dpni_cmd_set_offload {
249 uint8_t dpni_offload;
253 struct dpni_cmd_get_offload {
255 uint8_t dpni_offload;
258 struct dpni_rsp_get_offload {
263 struct dpni_cmd_get_qdid {
267 struct dpni_rsp_get_qdid {
271 struct dpni_rsp_get_sp_info {
275 struct dpni_rsp_get_tx_data_offset {
276 uint16_t data_offset;
279 struct dpni_cmd_get_statistics {
284 struct dpni_rsp_get_statistics {
288 struct dpni_cmd_set_link_cfg {
295 #define DPNI_LINK_STATE_SHIFT 0
296 #define DPNI_LINK_STATE_SIZE 1
298 struct dpni_rsp_get_link_state {
308 struct dpni_cmd_set_max_frame_length {
309 uint16_t max_frame_length;
312 struct dpni_rsp_get_max_frame_length {
313 uint16_t max_frame_length;
316 struct dpni_cmd_set_multicast_promisc {
320 struct dpni_rsp_get_multicast_promisc {
324 struct dpni_cmd_set_unicast_promisc {
328 struct dpni_rsp_get_unicast_promisc {
332 struct dpni_cmd_set_primary_mac_addr {
337 struct dpni_rsp_get_primary_mac_addr {
342 struct dpni_rsp_get_port_mac_addr {
347 struct dpni_cmd_add_mac_addr {
352 struct dpni_cmd_remove_mac_addr {
357 #define DPNI_UNICAST_FILTERS_SHIFT 0
358 #define DPNI_UNICAST_FILTERS_SIZE 1
359 #define DPNI_MULTICAST_FILTERS_SHIFT 1
360 #define DPNI_MULTICAST_FILTERS_SIZE 1
362 struct dpni_cmd_clear_mac_filters {
363 /* from LSB: unicast:1, multicast:1 */
367 struct dpni_cmd_enable_vlan_filter {
372 struct dpni_cmd_vlan_id {
377 #define DPNI_SEPARATE_GRP_SHIFT 0
378 #define DPNI_SEPARATE_GRP_SIZE 1
379 #define DPNI_MODE_1_SHIFT 0
380 #define DPNI_MODE_1_SIZE 4
381 #define DPNI_MODE_2_SHIFT 4
382 #define DPNI_MODE_2_SIZE 4
384 struct dpni_cmd_set_tx_priorities {
386 uint8_t prio_group_A;
387 uint8_t prio_group_B;
392 uint16_t delta_bandwidth[8];
395 #define DPNI_DIST_MODE_SHIFT 0
396 #define DPNI_DIST_MODE_SIZE 4
397 #define DPNI_MISS_ACTION_SHIFT 4
398 #define DPNI_MISS_ACTION_SIZE 4
399 #define DPNI_KEEP_HASH_KEY_SHIFT 7
400 #define DPNI_KEEP_HASH_KEY_SIZE 1
402 struct dpni_cmd_set_rx_tc_dist {
405 /* from LSB: dist_mode:4, miss_action:4 */
409 uint8_t keep_hash_key;
410 uint16_t default_flow_id;
412 uint64_t key_cfg_iova;
415 struct dpni_cmd_get_queue {
421 #define DPNI_DEST_TYPE_SHIFT 0
422 #define DPNI_DEST_TYPE_SIZE 4
423 #define DPNI_STASH_CTRL_SHIFT 6
424 #define DPNI_STASH_CTRL_SIZE 1
425 #define DPNI_HOLD_ACTIVE_SHIFT 7
426 #define DPNI_HOLD_ACTIVE_SIZE 1
428 struct dpni_rsp_get_queue {
429 /* response word 0 */
431 /* response word 1 */
435 /* From LSB: dest_type:4, pad:2, flc_stash_ctrl:1, hold_active:1 */
437 /* response word 2 */
439 /* response word 3 */
440 uint64_t user_context;
441 /* response word 4 */
446 struct dpni_cmd_set_queue {
461 uint64_t user_context;
464 #define DPNI_DROP_ENABLE_SHIFT 0
465 #define DPNI_DROP_ENABLE_SIZE 1
466 #define DPNI_DROP_UNITS_SHIFT 2
467 #define DPNI_DROP_UNITS_SIZE 2
469 struct dpni_early_drop {
470 /* from LSB: enable:1 units:2 */
474 uint8_t green_drop_probability;
476 uint64_t green_max_threshold;
477 uint64_t green_min_threshold;
479 uint8_t yellow_drop_probability;
481 uint64_t yellow_max_threshold;
482 uint64_t yellow_min_threshold;
484 uint8_t red_drop_probability;
486 uint64_t red_max_threshold;
487 uint64_t red_min_threshold;
490 struct dpni_cmd_early_drop {
494 uint64_t early_drop_iova;
497 struct dpni_rsp_get_api_version {
502 struct dpni_cmd_get_taildrop {
503 uint8_t congestion_point;
509 struct dpni_rsp_get_taildrop {
513 /* from LSB: enable:1 oal_lo:7 */
514 uint8_t enable_oal_lo;
515 /* from LSB: oal_hi:5 */
522 #define DPNI_OAL_LO_SHIFT 1
523 #define DPNI_OAL_LO_SIZE 7
524 #define DPNI_OAL_HI_SHIFT 0
525 #define DPNI_OAL_HI_SIZE 5
527 struct dpni_cmd_set_taildrop {
529 uint8_t congestion_point;
535 /* from LSB: enable:1 oal_lo:7 */
536 uint8_t enable_oal_lo;
537 /* from LSB: oal_hi:5 */
544 struct dpni_tx_confirmation_mode {
546 uint8_t confirmation_mode;
549 #define DPNI_DEST_TYPE_SHIFT 0
550 #define DPNI_DEST_TYPE_SIZE 4
551 #define DPNI_CONG_UNITS_SHIFT 4
552 #define DPNI_CONG_UNITS_SIZE 2
554 struct dpni_cmd_set_congestion_notification {
559 uint16_t notification_mode;
560 uint8_t dest_priority;
561 /* from LSB: dest_type: 4 units:2 */
563 uint64_t message_iova;
564 uint64_t message_ctx;
565 uint32_t threshold_entry;
566 uint32_t threshold_exit;
569 struct dpni_cmd_get_congestion_notification {
574 struct dpni_rsp_get_congestion_notification {
577 uint16_t notification_mode;
578 uint8_t dest_priority;
579 /* from LSB: dest_type: 4 units:2 */
581 uint64_t message_iova;
582 uint64_t message_ctx;
583 uint32_t threshold_entry;
584 uint32_t threshold_exit;
588 #endif /* _FSL_DPNI_CMD_H */