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_3RD_VERSION 3
17 #define DPNI_CMD_ID_OFFSET 4
19 #define DPNI_CMD(id) (((id) << DPNI_CMD_ID_OFFSET) | DPNI_CMD_BASE_VERSION)
20 #define DPNI_CMD_V2(id) (((id) << DPNI_CMD_ID_OFFSET) | DPNI_CMD_2ND_VERSION)
21 #define DPNI_CMD_V3(id) (((id) << DPNI_CMD_ID_OFFSET) | DPNI_CMD_3RD_VERSION)
23 #define DPNI_CMDID_OPEN DPNI_CMD(0x801)
24 #define DPNI_CMDID_CLOSE DPNI_CMD(0x800)
25 #define DPNI_CMDID_CREATE DPNI_CMD(0x901)
26 #define DPNI_CMDID_DESTROY DPNI_CMD(0x900)
27 #define DPNI_CMDID_GET_API_VERSION DPNI_CMD(0xa01)
29 #define DPNI_CMDID_ENABLE DPNI_CMD(0x002)
30 #define DPNI_CMDID_DISABLE DPNI_CMD(0x003)
31 #define DPNI_CMDID_GET_ATTR DPNI_CMD(0x004)
32 #define DPNI_CMDID_RESET DPNI_CMD(0x005)
33 #define DPNI_CMDID_IS_ENABLED DPNI_CMD(0x006)
35 #define DPNI_CMDID_SET_IRQ DPNI_CMD(0x010)
36 #define DPNI_CMDID_GET_IRQ DPNI_CMD(0x011)
37 #define DPNI_CMDID_SET_IRQ_ENABLE DPNI_CMD(0x012)
38 #define DPNI_CMDID_GET_IRQ_ENABLE DPNI_CMD(0x013)
39 #define DPNI_CMDID_SET_IRQ_MASK DPNI_CMD(0x014)
40 #define DPNI_CMDID_GET_IRQ_MASK DPNI_CMD(0x015)
41 #define DPNI_CMDID_GET_IRQ_STATUS DPNI_CMD(0x016)
42 #define DPNI_CMDID_CLEAR_IRQ_STATUS DPNI_CMD(0x017)
44 #define DPNI_CMDID_SET_POOLS DPNI_CMD_V3(0x200)
45 #define DPNI_CMDID_SET_ERRORS_BEHAVIOR DPNI_CMD(0x20B)
47 #define DPNI_CMDID_GET_QDID DPNI_CMD(0x210)
48 #define DPNI_CMDID_GET_TX_DATA_OFFSET DPNI_CMD(0x212)
49 #define DPNI_CMDID_GET_LINK_STATE DPNI_CMD(0x215)
50 #define DPNI_CMDID_SET_MAX_FRAME_LENGTH DPNI_CMD(0x216)
51 #define DPNI_CMDID_GET_MAX_FRAME_LENGTH DPNI_CMD(0x217)
52 #define DPNI_CMDID_SET_LINK_CFG DPNI_CMD(0x21A)
53 #define DPNI_CMDID_SET_TX_SHAPING DPNI_CMD_V2(0x21B)
55 #define DPNI_CMDID_SET_MCAST_PROMISC DPNI_CMD(0x220)
56 #define DPNI_CMDID_GET_MCAST_PROMISC DPNI_CMD(0x221)
57 #define DPNI_CMDID_SET_UNICAST_PROMISC DPNI_CMD(0x222)
58 #define DPNI_CMDID_GET_UNICAST_PROMISC DPNI_CMD(0x223)
59 #define DPNI_CMDID_SET_PRIM_MAC DPNI_CMD(0x224)
60 #define DPNI_CMDID_GET_PRIM_MAC DPNI_CMD(0x225)
61 #define DPNI_CMDID_ADD_MAC_ADDR DPNI_CMD(0x226)
62 #define DPNI_CMDID_REMOVE_MAC_ADDR DPNI_CMD(0x227)
63 #define DPNI_CMDID_CLR_MAC_FILTERS DPNI_CMD(0x228)
65 #define DPNI_CMDID_SET_RX_TC_DIST DPNI_CMD(0x235)
67 #define DPNI_CMDID_ENABLE_VLAN_FILTER DPNI_CMD(0x230)
68 #define DPNI_CMDID_ADD_VLAN_ID DPNI_CMD_V2(0x231)
69 #define DPNI_CMDID_REMOVE_VLAN_ID DPNI_CMD(0x232)
71 #define DPNI_CMDID_SET_QOS_TBL DPNI_CMD(0x240)
72 #define DPNI_CMDID_ADD_QOS_ENT DPNI_CMD(0x241)
73 #define DPNI_CMDID_REMOVE_QOS_ENT DPNI_CMD(0x242)
74 #define DPNI_CMDID_CLR_QOS_TBL DPNI_CMD(0x243)
75 #define DPNI_CMDID_ADD_FS_ENT DPNI_CMD(0x244)
76 #define DPNI_CMDID_REMOVE_FS_ENT DPNI_CMD(0x245)
77 #define DPNI_CMDID_CLR_FS_ENT DPNI_CMD(0x246)
79 #define DPNI_CMDID_GET_STATISTICS DPNI_CMD(0x25D)
80 #define DPNI_CMDID_GET_QUEUE DPNI_CMD(0x25F)
81 #define DPNI_CMDID_SET_QUEUE DPNI_CMD(0x260)
82 #define DPNI_CMDID_GET_TAILDROP DPNI_CMD(0x261)
83 #define DPNI_CMDID_SET_TAILDROP DPNI_CMD(0x262)
85 #define DPNI_CMDID_GET_PORT_MAC_ADDR DPNI_CMD(0x263)
87 #define DPNI_CMDID_GET_BUFFER_LAYOUT DPNI_CMD(0x264)
88 #define DPNI_CMDID_SET_BUFFER_LAYOUT DPNI_CMD(0x265)
90 #define DPNI_CMDID_SET_TX_CONFIRMATION_MODE DPNI_CMD(0x266)
91 #define DPNI_CMDID_SET_CONGESTION_NOTIFICATION DPNI_CMD(0x267)
92 #define DPNI_CMDID_GET_CONGESTION_NOTIFICATION DPNI_CMD(0x268)
93 #define DPNI_CMDID_SET_EARLY_DROP DPNI_CMD(0x269)
94 #define DPNI_CMDID_GET_EARLY_DROP DPNI_CMD(0x26A)
95 #define DPNI_CMDID_GET_OFFLOAD DPNI_CMD(0x26B)
96 #define DPNI_CMDID_SET_OFFLOAD DPNI_CMD(0x26C)
98 #define DPNI_CMDID_SET_RX_FS_DIST DPNI_CMD(0x273)
99 #define DPNI_CMDID_SET_RX_HASH_DIST DPNI_CMD(0x274)
100 #define DPNI_CMDID_GET_LINK_CFG DPNI_CMD(0x278)
102 #define DPNI_CMDID_SET_SINGLE_STEP_CFG DPNI_CMD(0x279)
103 #define DPNI_CMDID_GET_SINGLE_STEP_CFG DPNI_CMD_V2(0x27a)
105 /* Macros for accessing command fields smaller than 1byte */
106 #define DPNI_MASK(field) \
107 GENMASK(DPNI_##field##_SHIFT + DPNI_##field##_SIZE - 1, \
108 DPNI_##field##_SHIFT)
110 #define dpni_set_field(var, field, val) \
111 ((var) |= (((val) << DPNI_##field##_SHIFT) & DPNI_MASK(field)))
112 #define dpni_get_field(var, field) \
113 (((var) & DPNI_MASK(field)) >> DPNI_##field##_SHIFT)
115 struct dpni_cmd_open {
119 #define DPNI_BACKUP_POOL(val, order) (((val) & 0x1) << (order))
121 struct dpni_cmd_pool {
127 struct dpni_cmd_set_pools {
132 struct dpni_cmd_pool pool[DPNI_MAX_DPBP];
133 __le16 buffer_size[DPNI_MAX_DPBP];
136 /* The enable indication is always the least significant bit */
137 #define DPNI_ENABLE_SHIFT 0
138 #define DPNI_ENABLE_SIZE 1
140 struct dpni_rsp_is_enabled {
144 struct dpni_rsp_get_irq {
145 /* response word 0 */
148 /* response word 1 */
150 /* response word 2 */
155 struct dpni_cmd_set_irq_enable {
161 struct dpni_cmd_get_irq_enable {
166 struct dpni_rsp_get_irq_enable {
170 struct dpni_cmd_set_irq_mask {
175 struct dpni_cmd_get_irq_mask {
180 struct dpni_rsp_get_irq_mask {
184 struct dpni_cmd_get_irq_status {
189 struct dpni_rsp_get_irq_status {
193 struct dpni_cmd_clear_irq_status {
198 struct dpni_rsp_get_attr {
199 /* response word 0 */
203 u8 mac_filter_entries;
205 /* response word 1 */
206 u8 vlan_filter_entries;
212 /* response word 2 */
215 __le16 wriop_version;
218 #define DPNI_ERROR_ACTION_SHIFT 0
219 #define DPNI_ERROR_ACTION_SIZE 4
220 #define DPNI_FRAME_ANN_SHIFT 4
221 #define DPNI_FRAME_ANN_SIZE 1
223 struct dpni_cmd_set_errors_behavior {
225 /* from least significant bit: error_action:4, set_frame_annotation:1 */
229 /* There are 3 separate commands for configuring Rx, Tx and Tx confirmation
230 * buffer layouts, but they all share the same parameters.
231 * If one of the functions changes, below structure needs to be split.
234 #define DPNI_PASS_TS_SHIFT 0
235 #define DPNI_PASS_TS_SIZE 1
236 #define DPNI_PASS_PR_SHIFT 1
237 #define DPNI_PASS_PR_SIZE 1
238 #define DPNI_PASS_FS_SHIFT 2
239 #define DPNI_PASS_FS_SIZE 1
241 struct dpni_cmd_get_buffer_layout {
245 struct dpni_rsp_get_buffer_layout {
246 /* response word 0 */
248 /* from LSB: pass_timestamp:1, parser_result:1, frame_status:1 */
251 /* response word 1 */
252 __le16 private_data_size;
258 struct dpni_cmd_set_buffer_layout {
263 /* from LSB: pass_timestamp:1, parser_result:1, frame_status:1 */
267 __le16 private_data_size;
273 struct dpni_cmd_set_offload {
279 struct dpni_cmd_get_offload {
284 struct dpni_rsp_get_offload {
289 struct dpni_cmd_get_qdid {
293 struct dpni_rsp_get_qdid {
297 struct dpni_rsp_get_tx_data_offset {
301 struct dpni_cmd_get_statistics {
305 struct dpni_rsp_get_statistics {
306 __le64 counter[DPNI_STATISTICS_CNT];
309 struct dpni_cmd_link_cfg {
319 #define DPNI_LINK_STATE_SHIFT 0
320 #define DPNI_LINK_STATE_SIZE 1
322 struct dpni_rsp_get_link_state {
323 /* response word 0 */
328 /* response word 1 */
331 /* response word 2 */
335 struct dpni_cmd_set_max_frame_length {
336 __le16 max_frame_length;
339 struct dpni_rsp_get_max_frame_length {
340 __le16 max_frame_length;
343 struct dpni_cmd_set_multicast_promisc {
347 struct dpni_rsp_get_multicast_promisc {
351 struct dpni_cmd_set_unicast_promisc {
355 struct dpni_rsp_get_unicast_promisc {
359 struct dpni_cmd_set_primary_mac_addr {
364 struct dpni_rsp_get_primary_mac_addr {
369 struct dpni_rsp_get_port_mac_addr {
374 struct dpni_cmd_add_mac_addr {
379 struct dpni_cmd_remove_mac_addr {
384 #define DPNI_UNICAST_FILTERS_SHIFT 0
385 #define DPNI_UNICAST_FILTERS_SIZE 1
386 #define DPNI_MULTICAST_FILTERS_SHIFT 1
387 #define DPNI_MULTICAST_FILTERS_SIZE 1
389 struct dpni_cmd_clear_mac_filters {
390 /* from LSB: unicast:1, multicast:1 */
394 #define DPNI_DIST_MODE_SHIFT 0
395 #define DPNI_DIST_MODE_SIZE 4
396 #define DPNI_MISS_ACTION_SHIFT 4
397 #define DPNI_MISS_ACTION_SIZE 4
399 struct dpni_cmd_set_rx_tc_dist {
403 /* from LSB: dist_mode:4, miss_action:4 */
406 __le16 default_flow_id;
413 /* dpni_set_rx_tc_dist extension (structure of the DMA-able memory at
416 struct dpni_mask_cfg {
421 #define DPNI_EFH_TYPE_SHIFT 0
422 #define DPNI_EFH_TYPE_SIZE 4
423 #define DPNI_EXTRACT_TYPE_SHIFT 0
424 #define DPNI_EXTRACT_TYPE_SIZE 4
426 struct dpni_dist_extract {
429 /* EFH type stored in the 4 least significant bits */
438 u8 num_of_byte_masks;
439 /* Extraction type is stored in the 4 LSBs */
443 struct dpni_mask_cfg masks[4];
446 struct dpni_ext_set_rx_tc_dist {
447 /* extension word 0 */
451 struct dpni_dist_extract extracts[DPKG_MAX_NUM_OF_EXTRACTS];
454 struct dpni_cmd_get_queue {
460 #define DPNI_DEST_TYPE_SHIFT 0
461 #define DPNI_DEST_TYPE_SIZE 4
462 #define DPNI_STASH_CTRL_SHIFT 6
463 #define DPNI_STASH_CTRL_SIZE 1
464 #define DPNI_HOLD_ACTIVE_SHIFT 7
465 #define DPNI_HOLD_ACTIVE_SIZE 1
467 struct dpni_rsp_get_queue {
468 /* response word 0 */
470 /* response word 1 */
474 /* From LSB: dest_type:4, pad:2, flc_stash_ctrl:1, hold_active:1 */
476 /* response word 2 */
478 /* response word 3 */
480 /* response word 4 */
485 struct dpni_cmd_set_queue {
503 struct dpni_cmd_set_taildrop {
511 /* Only least significant bit is relevant */
519 struct dpni_cmd_get_taildrop {
526 struct dpni_rsp_get_taildrop {
530 /* only least significant bit is relevant */
538 struct dpni_rsp_get_api_version {
543 #define DPNI_RX_FS_DIST_ENABLE_SHIFT 0
544 #define DPNI_RX_FS_DIST_ENABLE_SIZE 1
545 struct dpni_cmd_set_rx_fs_dist {
554 #define DPNI_RX_HASH_DIST_ENABLE_SHIFT 0
555 #define DPNI_RX_HASH_DIST_ENABLE_SIZE 1
556 struct dpni_cmd_set_rx_hash_dist {
564 struct dpni_cmd_add_fs_entry {
579 struct dpni_cmd_remove_fs_entry {
591 #define DPNI_DISCARD_ON_MISS_SHIFT 0
592 #define DPNI_DISCARD_ON_MISS_SIZE 1
594 struct dpni_cmd_set_qos_table {
603 struct dpni_cmd_add_qos_entry {
613 struct dpni_cmd_remove_qos_entry {
621 #define DPNI_DEST_TYPE_SHIFT 0
622 #define DPNI_DEST_TYPE_SIZE 4
623 #define DPNI_CONG_UNITS_SHIFT 4
624 #define DPNI_CONG_UNITS_SIZE 2
626 struct dpni_cmd_set_congestion_notification {
633 __le16 notification_mode;
635 /* from LSB: dest_type: 4 units:2 */
642 __le32 threshold_entry;
643 __le32 threshold_exit;
646 #define DPNI_COUPLED_SHIFT 0
647 #define DPNI_COUPLED_SIZE 1
649 struct dpni_cmd_set_tx_shaping {
650 __le16 tx_cr_max_burst_size;
651 __le16 tx_er_max_burst_size;
653 __le32 tx_cr_rate_limit;
654 __le32 tx_er_rate_limit;
655 /* from LSB: coupled:1 */
659 #define DPNI_PTP_ENABLE_SHIFT 0
660 #define DPNI_PTP_ENABLE_SIZE 1
661 #define DPNI_PTP_CH_UPDATE_SHIFT 1
662 #define DPNI_PTP_CH_UPDATE_SIZE 1
664 struct dpni_cmd_single_step_cfg {
668 __le32 ptp_onestep_reg_base;
672 struct dpni_rsp_single_step_cfg {
676 __le32 ptp_onestep_reg_base;
680 struct dpni_cmd_enable_vlan_filter {
685 struct dpni_cmd_vlan_id {
693 #endif /* _FSL_DPNI_CMD_H */