1 /* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
2 /* Copyright 2013-2016 Freescale Semiconductor Inc.
5 #ifndef _FSL_DPNI_CMD_H
6 #define _FSL_DPNI_CMD_H
11 #define DPNI_VER_MAJOR 7
12 #define DPNI_VER_MINOR 0
13 #define DPNI_CMD_BASE_VERSION 1
14 #define DPNI_CMD_ID_OFFSET 4
16 #define DPNI_CMD(id) (((id) << DPNI_CMD_ID_OFFSET) | DPNI_CMD_BASE_VERSION)
18 #define DPNI_CMDID_OPEN DPNI_CMD(0x801)
19 #define DPNI_CMDID_CLOSE DPNI_CMD(0x800)
20 #define DPNI_CMDID_CREATE DPNI_CMD(0x901)
21 #define DPNI_CMDID_DESTROY DPNI_CMD(0x900)
22 #define DPNI_CMDID_GET_API_VERSION DPNI_CMD(0xa01)
24 #define DPNI_CMDID_ENABLE DPNI_CMD(0x002)
25 #define DPNI_CMDID_DISABLE DPNI_CMD(0x003)
26 #define DPNI_CMDID_GET_ATTR DPNI_CMD(0x004)
27 #define DPNI_CMDID_RESET DPNI_CMD(0x005)
28 #define DPNI_CMDID_IS_ENABLED DPNI_CMD(0x006)
30 #define DPNI_CMDID_SET_IRQ DPNI_CMD(0x010)
31 #define DPNI_CMDID_GET_IRQ DPNI_CMD(0x011)
32 #define DPNI_CMDID_SET_IRQ_ENABLE DPNI_CMD(0x012)
33 #define DPNI_CMDID_GET_IRQ_ENABLE DPNI_CMD(0x013)
34 #define DPNI_CMDID_SET_IRQ_MASK DPNI_CMD(0x014)
35 #define DPNI_CMDID_GET_IRQ_MASK DPNI_CMD(0x015)
36 #define DPNI_CMDID_GET_IRQ_STATUS DPNI_CMD(0x016)
37 #define DPNI_CMDID_CLEAR_IRQ_STATUS DPNI_CMD(0x017)
39 #define DPNI_CMDID_SET_POOLS DPNI_CMD(0x200)
40 #define DPNI_CMDID_SET_ERRORS_BEHAVIOR DPNI_CMD(0x20B)
42 #define DPNI_CMDID_GET_QDID DPNI_CMD(0x210)
43 #define DPNI_CMDID_GET_TX_DATA_OFFSET DPNI_CMD(0x212)
44 #define DPNI_CMDID_GET_LINK_STATE DPNI_CMD(0x215)
45 #define DPNI_CMDID_SET_MAX_FRAME_LENGTH DPNI_CMD(0x216)
46 #define DPNI_CMDID_GET_MAX_FRAME_LENGTH DPNI_CMD(0x217)
47 #define DPNI_CMDID_SET_LINK_CFG DPNI_CMD(0x21A)
48 #define DPNI_CMDID_SET_TX_SHAPING DPNI_CMD(0x21B)
50 #define DPNI_CMDID_SET_MCAST_PROMISC DPNI_CMD(0x220)
51 #define DPNI_CMDID_GET_MCAST_PROMISC DPNI_CMD(0x221)
52 #define DPNI_CMDID_SET_UNICAST_PROMISC DPNI_CMD(0x222)
53 #define DPNI_CMDID_GET_UNICAST_PROMISC DPNI_CMD(0x223)
54 #define DPNI_CMDID_SET_PRIM_MAC DPNI_CMD(0x224)
55 #define DPNI_CMDID_GET_PRIM_MAC DPNI_CMD(0x225)
56 #define DPNI_CMDID_ADD_MAC_ADDR DPNI_CMD(0x226)
57 #define DPNI_CMDID_REMOVE_MAC_ADDR DPNI_CMD(0x227)
58 #define DPNI_CMDID_CLR_MAC_FILTERS DPNI_CMD(0x228)
60 #define DPNI_CMDID_SET_RX_TC_DIST DPNI_CMD(0x235)
62 #define DPNI_CMDID_ADD_FS_ENT DPNI_CMD(0x244)
63 #define DPNI_CMDID_REMOVE_FS_ENT DPNI_CMD(0x245)
64 #define DPNI_CMDID_CLR_FS_ENT DPNI_CMD(0x246)
66 #define DPNI_CMDID_GET_STATISTICS DPNI_CMD(0x25D)
67 #define DPNI_CMDID_GET_QUEUE DPNI_CMD(0x25F)
68 #define DPNI_CMDID_SET_QUEUE DPNI_CMD(0x260)
69 #define DPNI_CMDID_GET_TAILDROP DPNI_CMD(0x261)
70 #define DPNI_CMDID_SET_TAILDROP DPNI_CMD(0x262)
72 #define DPNI_CMDID_GET_PORT_MAC_ADDR DPNI_CMD(0x263)
74 #define DPNI_CMDID_GET_BUFFER_LAYOUT DPNI_CMD(0x264)
75 #define DPNI_CMDID_SET_BUFFER_LAYOUT DPNI_CMD(0x265)
77 #define DPNI_CMDID_SET_TX_CONFIRMATION_MODE DPNI_CMD(0x266)
78 #define DPNI_CMDID_SET_CONGESTION_NOTIFICATION DPNI_CMD(0x267)
79 #define DPNI_CMDID_GET_CONGESTION_NOTIFICATION DPNI_CMD(0x268)
80 #define DPNI_CMDID_SET_EARLY_DROP DPNI_CMD(0x269)
81 #define DPNI_CMDID_GET_EARLY_DROP DPNI_CMD(0x26A)
82 #define DPNI_CMDID_GET_OFFLOAD DPNI_CMD(0x26B)
83 #define DPNI_CMDID_SET_OFFLOAD DPNI_CMD(0x26C)
85 /* Macros for accessing command fields smaller than 1byte */
86 #define DPNI_MASK(field) \
87 GENMASK(DPNI_##field##_SHIFT + DPNI_##field##_SIZE - 1, \
90 #define dpni_set_field(var, field, val) \
91 ((var) |= (((val) << DPNI_##field##_SHIFT) & DPNI_MASK(field)))
92 #define dpni_get_field(var, field) \
93 (((var) & DPNI_MASK(field)) >> DPNI_##field##_SHIFT)
95 struct dpni_cmd_open {
99 #define DPNI_BACKUP_POOL(val, order) (((val) & 0x1) << (order))
100 struct dpni_cmd_set_pools {
106 __le32 dpbp_id[DPNI_MAX_DPBP];
108 __le16 buffer_size[DPNI_MAX_DPBP];
111 /* The enable indication is always the least significant bit */
112 #define DPNI_ENABLE_SHIFT 0
113 #define DPNI_ENABLE_SIZE 1
115 struct dpni_rsp_is_enabled {
119 struct dpni_rsp_get_irq {
120 /* response word 0 */
123 /* response word 1 */
125 /* response word 2 */
130 struct dpni_cmd_set_irq_enable {
136 struct dpni_cmd_get_irq_enable {
141 struct dpni_rsp_get_irq_enable {
145 struct dpni_cmd_set_irq_mask {
150 struct dpni_cmd_get_irq_mask {
155 struct dpni_rsp_get_irq_mask {
159 struct dpni_cmd_get_irq_status {
164 struct dpni_rsp_get_irq_status {
168 struct dpni_cmd_clear_irq_status {
173 struct dpni_rsp_get_attr {
174 /* response word 0 */
178 u8 mac_filter_entries;
180 /* response word 1 */
181 u8 vlan_filter_entries;
187 /* response word 2 */
190 __le16 wriop_version;
193 #define DPNI_ERROR_ACTION_SHIFT 0
194 #define DPNI_ERROR_ACTION_SIZE 4
195 #define DPNI_FRAME_ANN_SHIFT 4
196 #define DPNI_FRAME_ANN_SIZE 1
198 struct dpni_cmd_set_errors_behavior {
200 /* from least significant bit: error_action:4, set_frame_annotation:1 */
204 /* There are 3 separate commands for configuring Rx, Tx and Tx confirmation
205 * buffer layouts, but they all share the same parameters.
206 * If one of the functions changes, below structure needs to be split.
209 #define DPNI_PASS_TS_SHIFT 0
210 #define DPNI_PASS_TS_SIZE 1
211 #define DPNI_PASS_PR_SHIFT 1
212 #define DPNI_PASS_PR_SIZE 1
213 #define DPNI_PASS_FS_SHIFT 2
214 #define DPNI_PASS_FS_SIZE 1
216 struct dpni_cmd_get_buffer_layout {
220 struct dpni_rsp_get_buffer_layout {
221 /* response word 0 */
223 /* from LSB: pass_timestamp:1, parser_result:1, frame_status:1 */
226 /* response word 1 */
227 __le16 private_data_size;
233 struct dpni_cmd_set_buffer_layout {
238 /* from LSB: pass_timestamp:1, parser_result:1, frame_status:1 */
242 __le16 private_data_size;
248 struct dpni_cmd_set_offload {
254 struct dpni_cmd_get_offload {
259 struct dpni_rsp_get_offload {
264 struct dpni_cmd_get_qdid {
268 struct dpni_rsp_get_qdid {
272 struct dpni_rsp_get_tx_data_offset {
276 struct dpni_cmd_get_statistics {
280 struct dpni_rsp_get_statistics {
281 __le64 counter[DPNI_STATISTICS_CNT];
284 struct dpni_cmd_set_link_cfg {
294 #define DPNI_LINK_STATE_SHIFT 0
295 #define DPNI_LINK_STATE_SIZE 1
297 struct dpni_rsp_get_link_state {
298 /* response word 0 */
303 /* response word 1 */
306 /* response word 2 */
310 struct dpni_cmd_set_max_frame_length {
311 __le16 max_frame_length;
314 struct dpni_rsp_get_max_frame_length {
315 __le16 max_frame_length;
318 struct dpni_cmd_set_multicast_promisc {
322 struct dpni_rsp_get_multicast_promisc {
326 struct dpni_cmd_set_unicast_promisc {
330 struct dpni_rsp_get_unicast_promisc {
334 struct dpni_cmd_set_primary_mac_addr {
339 struct dpni_rsp_get_primary_mac_addr {
344 struct dpni_rsp_get_port_mac_addr {
349 struct dpni_cmd_add_mac_addr {
354 struct dpni_cmd_remove_mac_addr {
359 #define DPNI_UNICAST_FILTERS_SHIFT 0
360 #define DPNI_UNICAST_FILTERS_SIZE 1
361 #define DPNI_MULTICAST_FILTERS_SHIFT 1
362 #define DPNI_MULTICAST_FILTERS_SIZE 1
364 struct dpni_cmd_clear_mac_filters {
365 /* from LSB: unicast:1, multicast:1 */
369 #define DPNI_DIST_MODE_SHIFT 0
370 #define DPNI_DIST_MODE_SIZE 4
371 #define DPNI_MISS_ACTION_SHIFT 4
372 #define DPNI_MISS_ACTION_SIZE 4
374 struct dpni_cmd_set_rx_tc_dist {
378 /* from LSB: dist_mode:4, miss_action:4 */
381 __le16 default_flow_id;
388 /* dpni_set_rx_tc_dist extension (structure of the DMA-able memory at
391 struct dpni_mask_cfg {
396 #define DPNI_EFH_TYPE_SHIFT 0
397 #define DPNI_EFH_TYPE_SIZE 4
398 #define DPNI_EXTRACT_TYPE_SHIFT 0
399 #define DPNI_EXTRACT_TYPE_SIZE 4
401 struct dpni_dist_extract {
404 /* EFH type stored in the 4 least significant bits */
413 u8 num_of_byte_masks;
414 /* Extraction type is stored in the 4 LSBs */
418 struct dpni_mask_cfg masks[4];
421 struct dpni_ext_set_rx_tc_dist {
422 /* extension word 0 */
426 struct dpni_dist_extract extracts[DPKG_MAX_NUM_OF_EXTRACTS];
429 struct dpni_cmd_get_queue {
435 #define DPNI_DEST_TYPE_SHIFT 0
436 #define DPNI_DEST_TYPE_SIZE 4
437 #define DPNI_STASH_CTRL_SHIFT 6
438 #define DPNI_STASH_CTRL_SIZE 1
439 #define DPNI_HOLD_ACTIVE_SHIFT 7
440 #define DPNI_HOLD_ACTIVE_SIZE 1
442 struct dpni_rsp_get_queue {
443 /* response word 0 */
445 /* response word 1 */
449 /* From LSB: dest_type:4, pad:2, flc_stash_ctrl:1, hold_active:1 */
451 /* response word 2 */
453 /* response word 3 */
455 /* response word 4 */
460 struct dpni_cmd_set_queue {
478 struct dpni_cmd_set_taildrop {
486 /* Only least significant bit is relevant */
494 struct dpni_cmd_get_taildrop {
501 struct dpni_rsp_get_taildrop {
505 /* only least significant bit is relevant */
513 struct dpni_rsp_get_api_version {
518 #endif /* _FSL_DPNI_CMD_H */