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_SET_QOS_TBL DPNI_CMD(0x240)
66 #define DPNI_CMDID_ADD_QOS_ENT DPNI_CMD(0x241)
67 #define DPNI_CMDID_REMOVE_QOS_ENT DPNI_CMD(0x242)
68 #define DPNI_CMDID_CLR_QOS_TBL DPNI_CMD(0x243)
69 #define DPNI_CMDID_ADD_FS_ENT DPNI_CMD(0x244)
70 #define DPNI_CMDID_REMOVE_FS_ENT DPNI_CMD(0x245)
71 #define DPNI_CMDID_CLR_FS_ENT DPNI_CMD(0x246)
73 #define DPNI_CMDID_GET_STATISTICS DPNI_CMD(0x25D)
74 #define DPNI_CMDID_GET_QUEUE DPNI_CMD(0x25F)
75 #define DPNI_CMDID_SET_QUEUE DPNI_CMD(0x260)
76 #define DPNI_CMDID_GET_TAILDROP DPNI_CMD(0x261)
77 #define DPNI_CMDID_SET_TAILDROP DPNI_CMD(0x262)
79 #define DPNI_CMDID_GET_PORT_MAC_ADDR DPNI_CMD(0x263)
81 #define DPNI_CMDID_GET_BUFFER_LAYOUT DPNI_CMD(0x264)
82 #define DPNI_CMDID_SET_BUFFER_LAYOUT DPNI_CMD(0x265)
84 #define DPNI_CMDID_SET_TX_CONFIRMATION_MODE DPNI_CMD(0x266)
85 #define DPNI_CMDID_SET_CONGESTION_NOTIFICATION DPNI_CMD(0x267)
86 #define DPNI_CMDID_GET_CONGESTION_NOTIFICATION DPNI_CMD(0x268)
87 #define DPNI_CMDID_SET_EARLY_DROP DPNI_CMD(0x269)
88 #define DPNI_CMDID_GET_EARLY_DROP DPNI_CMD(0x26A)
89 #define DPNI_CMDID_GET_OFFLOAD DPNI_CMD(0x26B)
90 #define DPNI_CMDID_SET_OFFLOAD DPNI_CMD(0x26C)
92 #define DPNI_CMDID_SET_RX_FS_DIST DPNI_CMD(0x273)
93 #define DPNI_CMDID_SET_RX_HASH_DIST DPNI_CMD(0x274)
94 #define DPNI_CMDID_GET_LINK_CFG DPNI_CMD(0x278)
96 #define DPNI_CMDID_SET_SINGLE_STEP_CFG DPNI_CMD(0x279)
97 #define DPNI_CMDID_GET_SINGLE_STEP_CFG DPNI_CMD(0x27a)
99 /* Macros for accessing command fields smaller than 1byte */
100 #define DPNI_MASK(field) \
101 GENMASK(DPNI_##field##_SHIFT + DPNI_##field##_SIZE - 1, \
102 DPNI_##field##_SHIFT)
104 #define dpni_set_field(var, field, val) \
105 ((var) |= (((val) << DPNI_##field##_SHIFT) & DPNI_MASK(field)))
106 #define dpni_get_field(var, field) \
107 (((var) & DPNI_MASK(field)) >> DPNI_##field##_SHIFT)
109 struct dpni_cmd_open
{
113 #define DPNI_BACKUP_POOL(val, order) (((val) & 0x1) << (order))
114 struct dpni_cmd_set_pools
{
120 __le32 dpbp_id
[DPNI_MAX_DPBP
];
122 __le16 buffer_size
[DPNI_MAX_DPBP
];
125 /* The enable indication is always the least significant bit */
126 #define DPNI_ENABLE_SHIFT 0
127 #define DPNI_ENABLE_SIZE 1
129 struct dpni_rsp_is_enabled
{
133 struct dpni_rsp_get_irq
{
134 /* response word 0 */
137 /* response word 1 */
139 /* response word 2 */
144 struct dpni_cmd_set_irq_enable
{
150 struct dpni_cmd_get_irq_enable
{
155 struct dpni_rsp_get_irq_enable
{
159 struct dpni_cmd_set_irq_mask
{
164 struct dpni_cmd_get_irq_mask
{
169 struct dpni_rsp_get_irq_mask
{
173 struct dpni_cmd_get_irq_status
{
178 struct dpni_rsp_get_irq_status
{
182 struct dpni_cmd_clear_irq_status
{
187 struct dpni_rsp_get_attr
{
188 /* response word 0 */
192 u8 mac_filter_entries
;
194 /* response word 1 */
195 u8 vlan_filter_entries
;
201 /* response word 2 */
204 __le16 wriop_version
;
207 #define DPNI_ERROR_ACTION_SHIFT 0
208 #define DPNI_ERROR_ACTION_SIZE 4
209 #define DPNI_FRAME_ANN_SHIFT 4
210 #define DPNI_FRAME_ANN_SIZE 1
212 struct dpni_cmd_set_errors_behavior
{
214 /* from least significant bit: error_action:4, set_frame_annotation:1 */
218 /* There are 3 separate commands for configuring Rx, Tx and Tx confirmation
219 * buffer layouts, but they all share the same parameters.
220 * If one of the functions changes, below structure needs to be split.
223 #define DPNI_PASS_TS_SHIFT 0
224 #define DPNI_PASS_TS_SIZE 1
225 #define DPNI_PASS_PR_SHIFT 1
226 #define DPNI_PASS_PR_SIZE 1
227 #define DPNI_PASS_FS_SHIFT 2
228 #define DPNI_PASS_FS_SIZE 1
230 struct dpni_cmd_get_buffer_layout
{
234 struct dpni_rsp_get_buffer_layout
{
235 /* response word 0 */
237 /* from LSB: pass_timestamp:1, parser_result:1, frame_status:1 */
240 /* response word 1 */
241 __le16 private_data_size
;
247 struct dpni_cmd_set_buffer_layout
{
252 /* from LSB: pass_timestamp:1, parser_result:1, frame_status:1 */
256 __le16 private_data_size
;
262 struct dpni_cmd_set_offload
{
268 struct dpni_cmd_get_offload
{
273 struct dpni_rsp_get_offload
{
278 struct dpni_cmd_get_qdid
{
282 struct dpni_rsp_get_qdid
{
286 struct dpni_rsp_get_tx_data_offset
{
290 struct dpni_cmd_get_statistics
{
294 struct dpni_rsp_get_statistics
{
295 __le64 counter
[DPNI_STATISTICS_CNT
];
298 struct dpni_cmd_link_cfg
{
308 #define DPNI_LINK_STATE_SHIFT 0
309 #define DPNI_LINK_STATE_SIZE 1
311 struct dpni_rsp_get_link_state
{
312 /* response word 0 */
317 /* response word 1 */
320 /* response word 2 */
324 struct dpni_cmd_set_max_frame_length
{
325 __le16 max_frame_length
;
328 struct dpni_rsp_get_max_frame_length
{
329 __le16 max_frame_length
;
332 struct dpni_cmd_set_multicast_promisc
{
336 struct dpni_rsp_get_multicast_promisc
{
340 struct dpni_cmd_set_unicast_promisc
{
344 struct dpni_rsp_get_unicast_promisc
{
348 struct dpni_cmd_set_primary_mac_addr
{
353 struct dpni_rsp_get_primary_mac_addr
{
358 struct dpni_rsp_get_port_mac_addr
{
363 struct dpni_cmd_add_mac_addr
{
368 struct dpni_cmd_remove_mac_addr
{
373 #define DPNI_UNICAST_FILTERS_SHIFT 0
374 #define DPNI_UNICAST_FILTERS_SIZE 1
375 #define DPNI_MULTICAST_FILTERS_SHIFT 1
376 #define DPNI_MULTICAST_FILTERS_SIZE 1
378 struct dpni_cmd_clear_mac_filters
{
379 /* from LSB: unicast:1, multicast:1 */
383 #define DPNI_DIST_MODE_SHIFT 0
384 #define DPNI_DIST_MODE_SIZE 4
385 #define DPNI_MISS_ACTION_SHIFT 4
386 #define DPNI_MISS_ACTION_SIZE 4
388 struct dpni_cmd_set_rx_tc_dist
{
392 /* from LSB: dist_mode:4, miss_action:4 */
395 __le16 default_flow_id
;
402 /* dpni_set_rx_tc_dist extension (structure of the DMA-able memory at
405 struct dpni_mask_cfg
{
410 #define DPNI_EFH_TYPE_SHIFT 0
411 #define DPNI_EFH_TYPE_SIZE 4
412 #define DPNI_EXTRACT_TYPE_SHIFT 0
413 #define DPNI_EXTRACT_TYPE_SIZE 4
415 struct dpni_dist_extract
{
418 /* EFH type stored in the 4 least significant bits */
427 u8 num_of_byte_masks
;
428 /* Extraction type is stored in the 4 LSBs */
432 struct dpni_mask_cfg masks
[4];
435 struct dpni_ext_set_rx_tc_dist
{
436 /* extension word 0 */
440 struct dpni_dist_extract extracts
[DPKG_MAX_NUM_OF_EXTRACTS
];
443 struct dpni_cmd_get_queue
{
449 #define DPNI_DEST_TYPE_SHIFT 0
450 #define DPNI_DEST_TYPE_SIZE 4
451 #define DPNI_STASH_CTRL_SHIFT 6
452 #define DPNI_STASH_CTRL_SIZE 1
453 #define DPNI_HOLD_ACTIVE_SHIFT 7
454 #define DPNI_HOLD_ACTIVE_SIZE 1
456 struct dpni_rsp_get_queue
{
457 /* response word 0 */
459 /* response word 1 */
463 /* From LSB: dest_type:4, pad:2, flc_stash_ctrl:1, hold_active:1 */
465 /* response word 2 */
467 /* response word 3 */
469 /* response word 4 */
474 struct dpni_cmd_set_queue
{
492 struct dpni_cmd_set_taildrop
{
500 /* Only least significant bit is relevant */
508 struct dpni_cmd_get_taildrop
{
515 struct dpni_rsp_get_taildrop
{
519 /* only least significant bit is relevant */
527 struct dpni_rsp_get_api_version
{
532 #define DPNI_RX_FS_DIST_ENABLE_SHIFT 0
533 #define DPNI_RX_FS_DIST_ENABLE_SIZE 1
534 struct dpni_cmd_set_rx_fs_dist
{
543 #define DPNI_RX_HASH_DIST_ENABLE_SHIFT 0
544 #define DPNI_RX_HASH_DIST_ENABLE_SIZE 1
545 struct dpni_cmd_set_rx_hash_dist
{
553 struct dpni_cmd_add_fs_entry
{
568 struct dpni_cmd_remove_fs_entry
{
580 #define DPNI_DISCARD_ON_MISS_SHIFT 0
581 #define DPNI_DISCARD_ON_MISS_SIZE 1
583 struct dpni_cmd_set_qos_table
{
592 struct dpni_cmd_add_qos_entry
{
602 struct dpni_cmd_remove_qos_entry
{
610 #define DPNI_DEST_TYPE_SHIFT 0
611 #define DPNI_DEST_TYPE_SIZE 4
612 #define DPNI_CONG_UNITS_SHIFT 4
613 #define DPNI_CONG_UNITS_SIZE 2
615 struct dpni_cmd_set_congestion_notification
{
622 __le16 notification_mode
;
624 /* from LSB: dest_type: 4 units:2 */
631 __le32 threshold_entry
;
632 __le32 threshold_exit
;
635 #define DPNI_COUPLED_SHIFT 0
636 #define DPNI_COUPLED_SIZE 1
638 struct dpni_cmd_set_tx_shaping
{
639 __le16 tx_cr_max_burst_size
;
640 __le16 tx_er_max_burst_size
;
642 __le32 tx_cr_rate_limit
;
643 __le32 tx_er_rate_limit
;
644 /* from LSB: coupled:1 */
648 #define DPNI_PTP_ENABLE_SHIFT 0
649 #define DPNI_PTP_ENABLE_SIZE 1
650 #define DPNI_PTP_CH_UPDATE_SHIFT 1
651 #define DPNI_PTP_CH_UPDATE_SIZE 1
653 struct dpni_cmd_single_step_cfg
{
659 struct dpni_rsp_single_step_cfg
{
665 #endif /* _FSL_DPNI_CMD_H */