1 /* Copyright 2013-2016 Freescale Semiconductor Inc.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the name of the above-listed copyright holders nor the
12 * names of any contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
16 * ALTERNATIVELY, this software may be distributed under the terms of the
17 * GNU General Public License ("GPL") as published by the Free Software
18 * Foundation, either version 2 of that License or (at your option) any
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
33 #ifndef _FSL_DPNI_CMD_H
34 #define _FSL_DPNI_CMD_H
39 #define DPNI_VER_MAJOR 7
40 #define DPNI_VER_MINOR 0
41 #define DPNI_CMD_BASE_VERSION 1
42 #define DPNI_CMD_ID_OFFSET 4
44 #define DPNI_CMD(id) (((id) << DPNI_CMD_ID_OFFSET) | DPNI_CMD_BASE_VERSION)
46 #define DPNI_CMDID_OPEN DPNI_CMD(0x801)
47 #define DPNI_CMDID_CLOSE DPNI_CMD(0x800)
48 #define DPNI_CMDID_CREATE DPNI_CMD(0x901)
49 #define DPNI_CMDID_DESTROY DPNI_CMD(0x900)
50 #define DPNI_CMDID_GET_API_VERSION DPNI_CMD(0xa01)
52 #define DPNI_CMDID_ENABLE DPNI_CMD(0x002)
53 #define DPNI_CMDID_DISABLE DPNI_CMD(0x003)
54 #define DPNI_CMDID_GET_ATTR DPNI_CMD(0x004)
55 #define DPNI_CMDID_RESET DPNI_CMD(0x005)
56 #define DPNI_CMDID_IS_ENABLED DPNI_CMD(0x006)
58 #define DPNI_CMDID_SET_IRQ DPNI_CMD(0x010)
59 #define DPNI_CMDID_GET_IRQ DPNI_CMD(0x011)
60 #define DPNI_CMDID_SET_IRQ_ENABLE DPNI_CMD(0x012)
61 #define DPNI_CMDID_GET_IRQ_ENABLE DPNI_CMD(0x013)
62 #define DPNI_CMDID_SET_IRQ_MASK DPNI_CMD(0x014)
63 #define DPNI_CMDID_GET_IRQ_MASK DPNI_CMD(0x015)
64 #define DPNI_CMDID_GET_IRQ_STATUS DPNI_CMD(0x016)
65 #define DPNI_CMDID_CLEAR_IRQ_STATUS DPNI_CMD(0x017)
67 #define DPNI_CMDID_SET_POOLS DPNI_CMD(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_TX_DATA_OFFSET DPNI_CMD(0x212)
72 #define DPNI_CMDID_GET_LINK_STATE DPNI_CMD(0x215)
73 #define DPNI_CMDID_SET_MAX_FRAME_LENGTH DPNI_CMD(0x216)
74 #define DPNI_CMDID_GET_MAX_FRAME_LENGTH DPNI_CMD(0x217)
75 #define DPNI_CMDID_SET_LINK_CFG DPNI_CMD(0x21A)
76 #define DPNI_CMDID_SET_TX_SHAPING DPNI_CMD(0x21B)
78 #define DPNI_CMDID_SET_MCAST_PROMISC DPNI_CMD(0x220)
79 #define DPNI_CMDID_GET_MCAST_PROMISC DPNI_CMD(0x221)
80 #define DPNI_CMDID_SET_UNICAST_PROMISC DPNI_CMD(0x222)
81 #define DPNI_CMDID_GET_UNICAST_PROMISC DPNI_CMD(0x223)
82 #define DPNI_CMDID_SET_PRIM_MAC DPNI_CMD(0x224)
83 #define DPNI_CMDID_GET_PRIM_MAC DPNI_CMD(0x225)
84 #define DPNI_CMDID_ADD_MAC_ADDR DPNI_CMD(0x226)
85 #define DPNI_CMDID_REMOVE_MAC_ADDR DPNI_CMD(0x227)
86 #define DPNI_CMDID_CLR_MAC_FILTERS DPNI_CMD(0x228)
88 #define DPNI_CMDID_SET_RX_TC_DIST DPNI_CMD(0x235)
90 #define DPNI_CMDID_ADD_FS_ENT DPNI_CMD(0x244)
91 #define DPNI_CMDID_REMOVE_FS_ENT DPNI_CMD(0x245)
92 #define DPNI_CMDID_CLR_FS_ENT DPNI_CMD(0x246)
94 #define DPNI_CMDID_GET_STATISTICS DPNI_CMD(0x25D)
95 #define DPNI_CMDID_GET_QUEUE DPNI_CMD(0x25F)
96 #define DPNI_CMDID_SET_QUEUE DPNI_CMD(0x260)
97 #define DPNI_CMDID_GET_TAILDROP DPNI_CMD(0x261)
98 #define DPNI_CMDID_SET_TAILDROP DPNI_CMD(0x262)
100 #define DPNI_CMDID_GET_PORT_MAC_ADDR DPNI_CMD(0x263)
102 #define DPNI_CMDID_GET_BUFFER_LAYOUT DPNI_CMD(0x264)
103 #define DPNI_CMDID_SET_BUFFER_LAYOUT DPNI_CMD(0x265)
105 #define DPNI_CMDID_SET_TX_CONFIRMATION_MODE DPNI_CMD(0x266)
106 #define DPNI_CMDID_SET_CONGESTION_NOTIFICATION DPNI_CMD(0x267)
107 #define DPNI_CMDID_GET_CONGESTION_NOTIFICATION DPNI_CMD(0x268)
108 #define DPNI_CMDID_SET_EARLY_DROP DPNI_CMD(0x269)
109 #define DPNI_CMDID_GET_EARLY_DROP DPNI_CMD(0x26A)
110 #define DPNI_CMDID_GET_OFFLOAD DPNI_CMD(0x26B)
111 #define DPNI_CMDID_SET_OFFLOAD DPNI_CMD(0x26C)
113 /* Macros for accessing command fields smaller than 1byte */
114 #define DPNI_MASK(field) \
115 GENMASK(DPNI_##field##_SHIFT + DPNI_##field##_SIZE - 1, \
116 DPNI_##field##_SHIFT)
118 #define dpni_set_field(var, field, val) \
119 ((var) |= (((val) << DPNI_##field##_SHIFT) & DPNI_MASK(field)))
120 #define dpni_get_field(var, field) \
121 (((var) & DPNI_MASK(field)) >> DPNI_##field##_SHIFT)
123 struct dpni_cmd_open {
127 #define DPNI_BACKUP_POOL(val, order) (((val) & 0x1) << (order))
128 struct dpni_cmd_set_pools {
134 __le32 dpbp_id[DPNI_MAX_DPBP];
136 __le16 buffer_size[DPNI_MAX_DPBP];
139 /* The enable indication is always the least significant bit */
140 #define DPNI_ENABLE_SHIFT 0
141 #define DPNI_ENABLE_SIZE 1
143 struct dpni_rsp_is_enabled {
147 struct dpni_rsp_get_irq {
148 /* response word 0 */
151 /* response word 1 */
153 /* response word 2 */
158 struct dpni_cmd_set_irq_enable {
164 struct dpni_cmd_get_irq_enable {
169 struct dpni_rsp_get_irq_enable {
173 struct dpni_cmd_set_irq_mask {
178 struct dpni_cmd_get_irq_mask {
183 struct dpni_rsp_get_irq_mask {
187 struct dpni_cmd_get_irq_status {
192 struct dpni_rsp_get_irq_status {
196 struct dpni_cmd_clear_irq_status {
201 struct dpni_rsp_get_attr {
202 /* response word 0 */
206 u8 mac_filter_entries;
208 /* response word 1 */
209 u8 vlan_filter_entries;
215 /* response word 2 */
218 __le16 wriop_version;
221 #define DPNI_ERROR_ACTION_SHIFT 0
222 #define DPNI_ERROR_ACTION_SIZE 4
223 #define DPNI_FRAME_ANN_SHIFT 4
224 #define DPNI_FRAME_ANN_SIZE 1
226 struct dpni_cmd_set_errors_behavior {
228 /* from least significant bit: error_action:4, set_frame_annotation:1 */
232 /* There are 3 separate commands for configuring Rx, Tx and Tx confirmation
233 * buffer layouts, but they all share the same parameters.
234 * If one of the functions changes, below structure needs to be split.
237 #define DPNI_PASS_TS_SHIFT 0
238 #define DPNI_PASS_TS_SIZE 1
239 #define DPNI_PASS_PR_SHIFT 1
240 #define DPNI_PASS_PR_SIZE 1
241 #define DPNI_PASS_FS_SHIFT 2
242 #define DPNI_PASS_FS_SIZE 1
244 struct dpni_cmd_get_buffer_layout {
248 struct dpni_rsp_get_buffer_layout {
249 /* response word 0 */
251 /* from LSB: pass_timestamp:1, parser_result:1, frame_status:1 */
254 /* response word 1 */
255 __le16 private_data_size;
261 struct dpni_cmd_set_buffer_layout {
266 /* from LSB: pass_timestamp:1, parser_result:1, frame_status:1 */
270 __le16 private_data_size;
276 struct dpni_cmd_set_offload {
282 struct dpni_cmd_get_offload {
287 struct dpni_rsp_get_offload {
292 struct dpni_cmd_get_qdid {
296 struct dpni_rsp_get_qdid {
300 struct dpni_rsp_get_tx_data_offset {
304 struct dpni_cmd_get_statistics {
308 struct dpni_rsp_get_statistics {
309 __le64 counter[DPNI_STATISTICS_CNT];
312 struct dpni_cmd_set_link_cfg {
322 #define DPNI_LINK_STATE_SHIFT 0
323 #define DPNI_LINK_STATE_SIZE 1
325 struct dpni_rsp_get_link_state {
326 /* response word 0 */
331 /* response word 1 */
334 /* response word 2 */
338 struct dpni_cmd_set_max_frame_length {
339 __le16 max_frame_length;
342 struct dpni_rsp_get_max_frame_length {
343 __le16 max_frame_length;
346 struct dpni_cmd_set_multicast_promisc {
350 struct dpni_rsp_get_multicast_promisc {
354 struct dpni_cmd_set_unicast_promisc {
358 struct dpni_rsp_get_unicast_promisc {
362 struct dpni_cmd_set_primary_mac_addr {
367 struct dpni_rsp_get_primary_mac_addr {
372 struct dpni_rsp_get_port_mac_addr {
377 struct dpni_cmd_add_mac_addr {
382 struct dpni_cmd_remove_mac_addr {
387 #define DPNI_UNICAST_FILTERS_SHIFT 0
388 #define DPNI_UNICAST_FILTERS_SIZE 1
389 #define DPNI_MULTICAST_FILTERS_SHIFT 1
390 #define DPNI_MULTICAST_FILTERS_SIZE 1
392 struct dpni_cmd_clear_mac_filters {
393 /* from LSB: unicast:1, multicast:1 */
397 #define DPNI_DIST_MODE_SHIFT 0
398 #define DPNI_DIST_MODE_SIZE 4
399 #define DPNI_MISS_ACTION_SHIFT 4
400 #define DPNI_MISS_ACTION_SIZE 4
402 struct dpni_cmd_set_rx_tc_dist {
406 /* from LSB: dist_mode:4, miss_action:4 */
409 __le16 default_flow_id;
416 /* dpni_set_rx_tc_dist extension (structure of the DMA-able memory at
419 struct dpni_mask_cfg {
424 #define DPNI_EFH_TYPE_SHIFT 0
425 #define DPNI_EFH_TYPE_SIZE 4
426 #define DPNI_EXTRACT_TYPE_SHIFT 0
427 #define DPNI_EXTRACT_TYPE_SIZE 4
429 struct dpni_dist_extract {
432 /* EFH type stored in the 4 least significant bits */
441 u8 num_of_byte_masks;
442 /* Extraction type is stored in the 4 LSBs */
446 struct dpni_mask_cfg masks[4];
449 struct dpni_ext_set_rx_tc_dist {
450 /* extension word 0 */
454 struct dpni_dist_extract extracts[DPKG_MAX_NUM_OF_EXTRACTS];
457 struct dpni_cmd_get_queue {
463 #define DPNI_DEST_TYPE_SHIFT 0
464 #define DPNI_DEST_TYPE_SIZE 4
465 #define DPNI_STASH_CTRL_SHIFT 6
466 #define DPNI_STASH_CTRL_SIZE 1
467 #define DPNI_HOLD_ACTIVE_SHIFT 7
468 #define DPNI_HOLD_ACTIVE_SIZE 1
470 struct dpni_rsp_get_queue {
471 /* response word 0 */
473 /* response word 1 */
477 /* From LSB: dest_type:4, pad:2, flc_stash_ctrl:1, hold_active:1 */
479 /* response word 2 */
481 /* response word 3 */
483 /* response word 4 */
488 struct dpni_cmd_set_queue {
506 struct dpni_cmd_set_taildrop {
514 /* Only least significant bit is relevant */
522 struct dpni_cmd_get_taildrop {
529 struct dpni_rsp_get_taildrop {
533 /* only least significant bit is relevant */
541 struct dpni_rsp_get_api_version {
546 #endif /* _FSL_DPNI_CMD_H */