1 /* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
2 /* Copyright 2013-2016 Freescale Semiconductor Inc.
6 #ifndef _FSL_DPNI_CMD_H
7 #define _FSL_DPNI_CMD_H
12 #define DPNI_VER_MAJOR 7
13 #define DPNI_VER_MINOR 0
14 #define DPNI_CMD_BASE_VERSION 1
15 #define DPNI_CMD_2ND_VERSION 2
16 #define DPNI_CMD_ID_OFFSET 4
18 #define DPNI_CMD(id) (((id) << DPNI_CMD_ID_OFFSET) | DPNI_CMD_BASE_VERSION)
19 #define DPNI_CMD_V2(id) (((id) << DPNI_CMD_ID_OFFSET) | DPNI_CMD_2ND_VERSION)
21 #define DPNI_CMDID_OPEN DPNI_CMD(0x801)
22 #define DPNI_CMDID_CLOSE DPNI_CMD(0x800)
23 #define DPNI_CMDID_CREATE DPNI_CMD(0x901)
24 #define DPNI_CMDID_DESTROY DPNI_CMD(0x900)
25 #define DPNI_CMDID_GET_API_VERSION DPNI_CMD(0xa01)
27 #define DPNI_CMDID_ENABLE DPNI_CMD(0x002)
28 #define DPNI_CMDID_DISABLE DPNI_CMD(0x003)
29 #define DPNI_CMDID_GET_ATTR DPNI_CMD(0x004)
30 #define DPNI_CMDID_RESET DPNI_CMD(0x005)
31 #define DPNI_CMDID_IS_ENABLED DPNI_CMD(0x006)
33 #define DPNI_CMDID_SET_IRQ DPNI_CMD(0x010)
34 #define DPNI_CMDID_GET_IRQ DPNI_CMD(0x011)
35 #define DPNI_CMDID_SET_IRQ_ENABLE DPNI_CMD(0x012)
36 #define DPNI_CMDID_GET_IRQ_ENABLE DPNI_CMD(0x013)
37 #define DPNI_CMDID_SET_IRQ_MASK DPNI_CMD(0x014)
38 #define DPNI_CMDID_GET_IRQ_MASK DPNI_CMD(0x015)
39 #define DPNI_CMDID_GET_IRQ_STATUS DPNI_CMD(0x016)
40 #define DPNI_CMDID_CLEAR_IRQ_STATUS DPNI_CMD(0x017)
42 #define DPNI_CMDID_SET_POOLS DPNI_CMD(0x200)
43 #define DPNI_CMDID_SET_ERRORS_BEHAVIOR DPNI_CMD(0x20B)
45 #define DPNI_CMDID_GET_QDID DPNI_CMD(0x210)
46 #define DPNI_CMDID_GET_TX_DATA_OFFSET DPNI_CMD(0x212)
47 #define DPNI_CMDID_GET_LINK_STATE DPNI_CMD(0x215)
48 #define DPNI_CMDID_SET_MAX_FRAME_LENGTH DPNI_CMD(0x216)
49 #define DPNI_CMDID_GET_MAX_FRAME_LENGTH DPNI_CMD(0x217)
50 #define DPNI_CMDID_SET_LINK_CFG DPNI_CMD(0x21A)
51 #define DPNI_CMDID_SET_TX_SHAPING DPNI_CMD_V2(0x21B)
53 #define DPNI_CMDID_SET_MCAST_PROMISC DPNI_CMD(0x220)
54 #define DPNI_CMDID_GET_MCAST_PROMISC DPNI_CMD(0x221)
55 #define DPNI_CMDID_SET_UNICAST_PROMISC DPNI_CMD(0x222)
56 #define DPNI_CMDID_GET_UNICAST_PROMISC DPNI_CMD(0x223)
57 #define DPNI_CMDID_SET_PRIM_MAC DPNI_CMD(0x224)
58 #define DPNI_CMDID_GET_PRIM_MAC DPNI_CMD(0x225)
59 #define DPNI_CMDID_ADD_MAC_ADDR DPNI_CMD(0x226)
60 #define DPNI_CMDID_REMOVE_MAC_ADDR DPNI_CMD(0x227)
61 #define DPNI_CMDID_CLR_MAC_FILTERS DPNI_CMD(0x228)
63 #define DPNI_CMDID_SET_RX_TC_DIST DPNI_CMD(0x235)
65 #define DPNI_CMDID_ENABLE_VLAN_FILTER DPNI_CMD(0x230)
66 #define DPNI_CMDID_ADD_VLAN_ID DPNI_CMD_V2(0x231)
67 #define DPNI_CMDID_REMOVE_VLAN_ID DPNI_CMD(0x232)
69 #define DPNI_CMDID_SET_QOS_TBL DPNI_CMD(0x240)
70 #define DPNI_CMDID_ADD_QOS_ENT DPNI_CMD(0x241)
71 #define DPNI_CMDID_REMOVE_QOS_ENT DPNI_CMD(0x242)
72 #define DPNI_CMDID_CLR_QOS_TBL DPNI_CMD(0x243)
73 #define DPNI_CMDID_ADD_FS_ENT DPNI_CMD(0x244)
74 #define DPNI_CMDID_REMOVE_FS_ENT DPNI_CMD(0x245)
75 #define DPNI_CMDID_CLR_FS_ENT DPNI_CMD(0x246)
77 #define DPNI_CMDID_GET_STATISTICS DPNI_CMD(0x25D)
78 #define DPNI_CMDID_GET_QUEUE DPNI_CMD(0x25F)
79 #define DPNI_CMDID_SET_QUEUE DPNI_CMD(0x260)
80 #define DPNI_CMDID_GET_TAILDROP DPNI_CMD(0x261)
81 #define DPNI_CMDID_SET_TAILDROP DPNI_CMD(0x262)
83 #define DPNI_CMDID_GET_PORT_MAC_ADDR DPNI_CMD(0x263)
85 #define DPNI_CMDID_GET_BUFFER_LAYOUT DPNI_CMD(0x264)
86 #define DPNI_CMDID_SET_BUFFER_LAYOUT DPNI_CMD(0x265)
88 #define DPNI_CMDID_SET_TX_CONFIRMATION_MODE DPNI_CMD(0x266)
89 #define DPNI_CMDID_SET_CONGESTION_NOTIFICATION DPNI_CMD(0x267)
90 #define DPNI_CMDID_GET_CONGESTION_NOTIFICATION DPNI_CMD(0x268)
91 #define DPNI_CMDID_SET_EARLY_DROP DPNI_CMD(0x269)
92 #define DPNI_CMDID_GET_EARLY_DROP DPNI_CMD(0x26A)
93 #define DPNI_CMDID_GET_OFFLOAD DPNI_CMD(0x26B)
94 #define DPNI_CMDID_SET_OFFLOAD DPNI_CMD(0x26C)
96 #define DPNI_CMDID_SET_RX_FS_DIST DPNI_CMD(0x273)
97 #define DPNI_CMDID_SET_RX_HASH_DIST DPNI_CMD(0x274)
98 #define DPNI_CMDID_GET_LINK_CFG DPNI_CMD(0x278)
100 #define DPNI_CMDID_SET_SINGLE_STEP_CFG DPNI_CMD(0x279)
101 #define DPNI_CMDID_GET_SINGLE_STEP_CFG DPNI_CMD(0x27a)
103 /* Macros for accessing command fields smaller than 1byte */
104 #define DPNI_MASK(field) \
105 GENMASK(DPNI_##field##_SHIFT + DPNI_##field##_SIZE - 1, \
106 DPNI_##field##_SHIFT)
108 #define dpni_set_field(var, field, val) \
109 ((var) |= (((val) << DPNI_##field##_SHIFT) & DPNI_MASK(field)))
110 #define dpni_get_field(var, field) \
111 (((var) & DPNI_MASK(field)) >> DPNI_##field##_SHIFT)
113 struct dpni_cmd_open {
117 #define DPNI_BACKUP_POOL(val, order) (((val) & 0x1) << (order))
118 struct dpni_cmd_set_pools {
124 __le32 dpbp_id[DPNI_MAX_DPBP];
126 __le16 buffer_size[DPNI_MAX_DPBP];
129 /* The enable indication is always the least significant bit */
130 #define DPNI_ENABLE_SHIFT 0
131 #define DPNI_ENABLE_SIZE 1
133 struct dpni_rsp_is_enabled {
137 struct dpni_rsp_get_irq {
138 /* response word 0 */
141 /* response word 1 */
143 /* response word 2 */
148 struct dpni_cmd_set_irq_enable {
154 struct dpni_cmd_get_irq_enable {
159 struct dpni_rsp_get_irq_enable {
163 struct dpni_cmd_set_irq_mask {
168 struct dpni_cmd_get_irq_mask {
173 struct dpni_rsp_get_irq_mask {
177 struct dpni_cmd_get_irq_status {
182 struct dpni_rsp_get_irq_status {
186 struct dpni_cmd_clear_irq_status {
191 struct dpni_rsp_get_attr {
192 /* response word 0 */
196 u8 mac_filter_entries;
198 /* response word 1 */
199 u8 vlan_filter_entries;
205 /* response word 2 */
208 __le16 wriop_version;
211 #define DPNI_ERROR_ACTION_SHIFT 0
212 #define DPNI_ERROR_ACTION_SIZE 4
213 #define DPNI_FRAME_ANN_SHIFT 4
214 #define DPNI_FRAME_ANN_SIZE 1
216 struct dpni_cmd_set_errors_behavior {
218 /* from least significant bit: error_action:4, set_frame_annotation:1 */
222 /* There are 3 separate commands for configuring Rx, Tx and Tx confirmation
223 * buffer layouts, but they all share the same parameters.
224 * If one of the functions changes, below structure needs to be split.
227 #define DPNI_PASS_TS_SHIFT 0
228 #define DPNI_PASS_TS_SIZE 1
229 #define DPNI_PASS_PR_SHIFT 1
230 #define DPNI_PASS_PR_SIZE 1
231 #define DPNI_PASS_FS_SHIFT 2
232 #define DPNI_PASS_FS_SIZE 1
234 struct dpni_cmd_get_buffer_layout {
238 struct dpni_rsp_get_buffer_layout {
239 /* response word 0 */
241 /* from LSB: pass_timestamp:1, parser_result:1, frame_status:1 */
244 /* response word 1 */
245 __le16 private_data_size;
251 struct dpni_cmd_set_buffer_layout {
256 /* from LSB: pass_timestamp:1, parser_result:1, frame_status:1 */
260 __le16 private_data_size;
266 struct dpni_cmd_set_offload {
272 struct dpni_cmd_get_offload {
277 struct dpni_rsp_get_offload {
282 struct dpni_cmd_get_qdid {
286 struct dpni_rsp_get_qdid {
290 struct dpni_rsp_get_tx_data_offset {
294 struct dpni_cmd_get_statistics {
298 struct dpni_rsp_get_statistics {
299 __le64 counter[DPNI_STATISTICS_CNT];
302 struct dpni_cmd_link_cfg {
312 #define DPNI_LINK_STATE_SHIFT 0
313 #define DPNI_LINK_STATE_SIZE 1
315 struct dpni_rsp_get_link_state {
316 /* response word 0 */
321 /* response word 1 */
324 /* response word 2 */
328 struct dpni_cmd_set_max_frame_length {
329 __le16 max_frame_length;
332 struct dpni_rsp_get_max_frame_length {
333 __le16 max_frame_length;
336 struct dpni_cmd_set_multicast_promisc {
340 struct dpni_rsp_get_multicast_promisc {
344 struct dpni_cmd_set_unicast_promisc {
348 struct dpni_rsp_get_unicast_promisc {
352 struct dpni_cmd_set_primary_mac_addr {
357 struct dpni_rsp_get_primary_mac_addr {
362 struct dpni_rsp_get_port_mac_addr {
367 struct dpni_cmd_add_mac_addr {
372 struct dpni_cmd_remove_mac_addr {
377 #define DPNI_UNICAST_FILTERS_SHIFT 0
378 #define DPNI_UNICAST_FILTERS_SIZE 1
379 #define DPNI_MULTICAST_FILTERS_SHIFT 1
380 #define DPNI_MULTICAST_FILTERS_SIZE 1
382 struct dpni_cmd_clear_mac_filters {
383 /* from LSB: unicast:1, multicast:1 */
387 #define DPNI_DIST_MODE_SHIFT 0
388 #define DPNI_DIST_MODE_SIZE 4
389 #define DPNI_MISS_ACTION_SHIFT 4
390 #define DPNI_MISS_ACTION_SIZE 4
392 struct dpni_cmd_set_rx_tc_dist {
396 /* from LSB: dist_mode:4, miss_action:4 */
399 __le16 default_flow_id;
406 /* dpni_set_rx_tc_dist extension (structure of the DMA-able memory at
409 struct dpni_mask_cfg {
414 #define DPNI_EFH_TYPE_SHIFT 0
415 #define DPNI_EFH_TYPE_SIZE 4
416 #define DPNI_EXTRACT_TYPE_SHIFT 0
417 #define DPNI_EXTRACT_TYPE_SIZE 4
419 struct dpni_dist_extract {
422 /* EFH type stored in the 4 least significant bits */
431 u8 num_of_byte_masks;
432 /* Extraction type is stored in the 4 LSBs */
436 struct dpni_mask_cfg masks[4];
439 struct dpni_ext_set_rx_tc_dist {
440 /* extension word 0 */
444 struct dpni_dist_extract extracts[DPKG_MAX_NUM_OF_EXTRACTS];
447 struct dpni_cmd_get_queue {
453 #define DPNI_DEST_TYPE_SHIFT 0
454 #define DPNI_DEST_TYPE_SIZE 4
455 #define DPNI_STASH_CTRL_SHIFT 6
456 #define DPNI_STASH_CTRL_SIZE 1
457 #define DPNI_HOLD_ACTIVE_SHIFT 7
458 #define DPNI_HOLD_ACTIVE_SIZE 1
460 struct dpni_rsp_get_queue {
461 /* response word 0 */
463 /* response word 1 */
467 /* From LSB: dest_type:4, pad:2, flc_stash_ctrl:1, hold_active:1 */
469 /* response word 2 */
471 /* response word 3 */
473 /* response word 4 */
478 struct dpni_cmd_set_queue {
496 struct dpni_cmd_set_taildrop {
504 /* Only least significant bit is relevant */
512 struct dpni_cmd_get_taildrop {
519 struct dpni_rsp_get_taildrop {
523 /* only least significant bit is relevant */
531 struct dpni_rsp_get_api_version {
536 #define DPNI_RX_FS_DIST_ENABLE_SHIFT 0
537 #define DPNI_RX_FS_DIST_ENABLE_SIZE 1
538 struct dpni_cmd_set_rx_fs_dist {
547 #define DPNI_RX_HASH_DIST_ENABLE_SHIFT 0
548 #define DPNI_RX_HASH_DIST_ENABLE_SIZE 1
549 struct dpni_cmd_set_rx_hash_dist {
557 struct dpni_cmd_add_fs_entry {
572 struct dpni_cmd_remove_fs_entry {
584 #define DPNI_DISCARD_ON_MISS_SHIFT 0
585 #define DPNI_DISCARD_ON_MISS_SIZE 1
587 struct dpni_cmd_set_qos_table {
596 struct dpni_cmd_add_qos_entry {
606 struct dpni_cmd_remove_qos_entry {
614 #define DPNI_DEST_TYPE_SHIFT 0
615 #define DPNI_DEST_TYPE_SIZE 4
616 #define DPNI_CONG_UNITS_SHIFT 4
617 #define DPNI_CONG_UNITS_SIZE 2
619 struct dpni_cmd_set_congestion_notification {
626 __le16 notification_mode;
628 /* from LSB: dest_type: 4 units:2 */
635 __le32 threshold_entry;
636 __le32 threshold_exit;
639 #define DPNI_COUPLED_SHIFT 0
640 #define DPNI_COUPLED_SIZE 1
642 struct dpni_cmd_set_tx_shaping {
643 __le16 tx_cr_max_burst_size;
644 __le16 tx_er_max_burst_size;
646 __le32 tx_cr_rate_limit;
647 __le32 tx_er_rate_limit;
648 /* from LSB: coupled:1 */
652 #define DPNI_PTP_ENABLE_SHIFT 0
653 #define DPNI_PTP_ENABLE_SIZE 1
654 #define DPNI_PTP_CH_UPDATE_SHIFT 1
655 #define DPNI_PTP_CH_UPDATE_SIZE 1
657 struct dpni_cmd_single_step_cfg {
663 struct dpni_rsp_single_step_cfg {
669 struct dpni_cmd_enable_vlan_filter {
674 struct dpni_cmd_vlan_id {
682 #endif /* _FSL_DPNI_CMD_H */