1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
3 * Copyright 2013-2016 Freescale Semiconductor Inc.
4 * Copyright 2016-2017 NXP
7 #ifndef _FSL_DPNI_CMD_H
8 #define _FSL_DPNI_CMD_H
11 #define DPNI_VER_MAJOR 7
12 #define DPNI_VER_MINOR 3
14 #define DPNI_CMD_BASE_VERSION 1
15 #define DPNI_CMD_VERSION_2 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_VERSION_2)
22 #define DPNI_CMDID_OPEN DPNI_CMD(0x801)
23 #define DPNI_CMDID_CLOSE DPNI_CMD(0x800)
24 #define DPNI_CMDID_CREATE DPNI_CMD(0x901)
25 #define DPNI_CMDID_DESTROY DPNI_CMD(0x981)
26 #define DPNI_CMDID_GET_API_VERSION DPNI_CMD(0xa01)
28 #define DPNI_CMDID_ENABLE DPNI_CMD(0x002)
29 #define DPNI_CMDID_DISABLE DPNI_CMD(0x003)
30 #define DPNI_CMDID_GET_ATTR DPNI_CMD_V2(0x004)
31 #define DPNI_CMDID_RESET DPNI_CMD(0x005)
32 #define DPNI_CMDID_IS_ENABLED DPNI_CMD(0x006)
34 #define DPNI_CMDID_SET_IRQ_ENABLE DPNI_CMD(0x012)
35 #define DPNI_CMDID_GET_IRQ_ENABLE DPNI_CMD(0x013)
36 #define DPNI_CMDID_SET_IRQ_MASK DPNI_CMD(0x014)
37 #define DPNI_CMDID_GET_IRQ_MASK DPNI_CMD(0x015)
38 #define DPNI_CMDID_GET_IRQ_STATUS DPNI_CMD(0x016)
39 #define DPNI_CMDID_CLEAR_IRQ_STATUS DPNI_CMD(0x017)
41 #define DPNI_CMDID_SET_POOLS DPNI_CMD_V2(0x200)
42 #define DPNI_CMDID_SET_ERRORS_BEHAVIOR DPNI_CMD(0x20B)
44 #define DPNI_CMDID_GET_QDID DPNI_CMD(0x210)
45 #define DPNI_CMDID_GET_SP_INFO DPNI_CMD(0x211)
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_ENABLE_VLAN_FILTER DPNI_CMD(0x230)
64 #define DPNI_CMDID_ADD_VLAN_ID DPNI_CMD(0x231)
65 #define DPNI_CMDID_REMOVE_VLAN_ID DPNI_CMD(0x232)
66 #define DPNI_CMDID_CLR_VLAN_FILTERS DPNI_CMD(0x233)
68 #define DPNI_CMDID_SET_RX_TC_DIST DPNI_CMD_V2(0x235)
70 #define DPNI_CMDID_GET_STATISTICS DPNI_CMD_V2(0x25D)
71 #define DPNI_CMDID_RESET_STATISTICS DPNI_CMD(0x25E)
72 #define DPNI_CMDID_GET_QUEUE DPNI_CMD(0x25F)
73 #define DPNI_CMDID_SET_QUEUE DPNI_CMD(0x260)
74 #define DPNI_CMDID_GET_TAILDROP DPNI_CMD_V2(0x261)
75 #define DPNI_CMDID_SET_TAILDROP DPNI_CMD_V2(0x262)
77 #define DPNI_CMDID_GET_PORT_MAC_ADDR DPNI_CMD(0x263)
79 #define DPNI_CMDID_GET_BUFFER_LAYOUT DPNI_CMD(0x264)
80 #define DPNI_CMDID_SET_BUFFER_LAYOUT DPNI_CMD(0x265)
82 #define DPNI_CMDID_SET_CONGESTION_NOTIFICATION DPNI_CMD(0x267)
83 #define DPNI_CMDID_GET_CONGESTION_NOTIFICATION DPNI_CMD(0x268)
84 #define DPNI_CMDID_SET_EARLY_DROP DPNI_CMD_V2(0x269)
85 #define DPNI_CMDID_GET_EARLY_DROP DPNI_CMD_V2(0x26A)
86 #define DPNI_CMDID_GET_OFFLOAD DPNI_CMD(0x26B)
87 #define DPNI_CMDID_SET_OFFLOAD DPNI_CMD(0x26C)
88 #define DPNI_CMDID_SET_TX_CONFIRMATION_MODE DPNI_CMD(0x266)
89 #define DPNI_CMDID_GET_TX_CONFIRMATION_MODE DPNI_CMD(0x26D)
91 /* Macros for accessing command fields smaller than 1byte */
92 #define DPNI_MASK(field) \
93 GENMASK(DPNI_##field##_SHIFT + DPNI_##field##_SIZE - 1, \
95 #define dpni_set_field(var, field, val) \
96 ((var) |= (((val) << DPNI_##field##_SHIFT) & DPNI_MASK(field)))
97 #define dpni_get_field(var, field) \
98 (((var) & DPNI_MASK(field)) >> DPNI_##field##_SHIFT)
100 #pragma pack(push, 1)
101 struct dpni_cmd_open {
105 struct dpni_cmd_create {
109 uint8_t mac_filter_entries;
111 uint8_t vlan_filter_entries;
118 struct dpni_cmd_destroy {
122 #define DPNI_BACKUP_POOL(val, order) (((val) & 0x1) << (order))
124 struct dpni_cmd_pool {
126 uint8_t priority_mask;
130 struct dpni_cmd_set_pools {
132 uint8_t backup_pool_mask;
134 struct dpni_cmd_pool pool[8];
135 uint16_t buffer_size[8];
138 /* The enable indication is always the least significant bit */
139 #define DPNI_ENABLE_SHIFT 0
140 #define DPNI_ENABLE_SIZE 1
142 struct dpni_rsp_is_enabled {
146 struct dpni_cmd_set_irq_enable {
152 struct dpni_cmd_get_irq_enable {
157 struct dpni_rsp_get_irq_enable {
161 struct dpni_cmd_set_irq_mask {
166 struct dpni_cmd_get_irq_mask {
171 struct dpni_rsp_get_irq_mask {
175 struct dpni_cmd_get_irq_status {
180 struct dpni_rsp_get_irq_status {
184 struct dpni_cmd_clear_irq_status {
189 struct dpni_rsp_get_attr {
190 /* response word 0 */
194 uint8_t mac_filter_entries;
196 /* response word 1 */
197 uint8_t vlan_filter_entries;
203 /* response word 2 */
204 uint8_t qos_key_size;
206 uint16_t wriop_version;
209 #define DPNI_ERROR_ACTION_SHIFT 0
210 #define DPNI_ERROR_ACTION_SIZE 4
211 #define DPNI_FRAME_ANN_SHIFT 4
212 #define DPNI_FRAME_ANN_SIZE 1
214 struct dpni_cmd_set_errors_behavior {
216 /* from least significant bit: error_action:4, set_frame_annotation:1 */
220 /* There are 3 separate commands for configuring Rx, Tx and Tx confirmation
221 * buffer layouts, but they all share the same parameters.
222 * If one of the functions changes, below structure needs to be split.
225 #define DPNI_PASS_TS_SHIFT 0
226 #define DPNI_PASS_TS_SIZE 1
227 #define DPNI_PASS_PR_SHIFT 1
228 #define DPNI_PASS_PR_SIZE 1
229 #define DPNI_PASS_FS_SHIFT 2
230 #define DPNI_PASS_FS_SIZE 1
232 struct dpni_cmd_get_buffer_layout {
236 struct dpni_rsp_get_buffer_layout {
237 /* response word 0 */
239 /* from LSB: pass_timestamp:1, parser_result:1, frame_status:1 */
242 /* response word 1 */
243 uint16_t private_data_size;
249 struct dpni_cmd_set_buffer_layout {
254 /* from LSB: pass_timestamp:1, parser_result:1, frame_status:1 */
258 uint16_t private_data_size;
264 struct dpni_cmd_set_offload {
266 uint8_t dpni_offload;
270 struct dpni_cmd_get_offload {
272 uint8_t dpni_offload;
275 struct dpni_rsp_get_offload {
280 struct dpni_cmd_get_qdid {
284 struct dpni_rsp_get_qdid {
288 struct dpni_rsp_get_sp_info {
292 struct dpni_rsp_get_tx_data_offset {
293 uint16_t data_offset;
296 struct dpni_cmd_get_statistics {
301 struct dpni_rsp_get_statistics {
305 struct dpni_cmd_set_link_cfg {
312 #define DPNI_LINK_STATE_SHIFT 0
313 #define DPNI_LINK_STATE_SIZE 1
315 struct dpni_rsp_get_link_state {
325 struct dpni_cmd_set_max_frame_length {
326 uint16_t max_frame_length;
329 struct dpni_rsp_get_max_frame_length {
330 uint16_t max_frame_length;
333 struct dpni_cmd_set_multicast_promisc {
337 struct dpni_rsp_get_multicast_promisc {
341 struct dpni_cmd_set_unicast_promisc {
345 struct dpni_rsp_get_unicast_promisc {
349 struct dpni_cmd_set_primary_mac_addr {
354 struct dpni_rsp_get_primary_mac_addr {
359 struct dpni_rsp_get_port_mac_addr {
364 struct dpni_cmd_add_mac_addr {
369 struct dpni_cmd_remove_mac_addr {
374 #define DPNI_UNICAST_FILTERS_SHIFT 0
375 #define DPNI_UNICAST_FILTERS_SIZE 1
376 #define DPNI_MULTICAST_FILTERS_SHIFT 1
377 #define DPNI_MULTICAST_FILTERS_SIZE 1
379 struct dpni_cmd_clear_mac_filters {
380 /* from LSB: unicast:1, multicast:1 */
384 struct dpni_cmd_enable_vlan_filter {
389 struct dpni_cmd_vlan_id {
394 #define DPNI_SEPARATE_GRP_SHIFT 0
395 #define DPNI_SEPARATE_GRP_SIZE 1
396 #define DPNI_MODE_1_SHIFT 0
397 #define DPNI_MODE_1_SIZE 4
398 #define DPNI_MODE_2_SHIFT 4
399 #define DPNI_MODE_2_SIZE 4
401 struct dpni_cmd_set_tx_priorities {
403 uint8_t prio_group_A;
404 uint8_t prio_group_B;
409 uint16_t delta_bandwidth[8];
412 #define DPNI_DIST_MODE_SHIFT 0
413 #define DPNI_DIST_MODE_SIZE 4
414 #define DPNI_MISS_ACTION_SHIFT 4
415 #define DPNI_MISS_ACTION_SIZE 4
416 #define DPNI_KEEP_HASH_KEY_SHIFT 7
417 #define DPNI_KEEP_HASH_KEY_SIZE 1
419 struct dpni_cmd_set_rx_tc_dist {
422 /* from LSB: dist_mode:4, miss_action:4 */
426 uint8_t keep_hash_key;
427 uint16_t default_flow_id;
429 uint64_t key_cfg_iova;
432 struct dpni_cmd_get_queue {
438 #define DPNI_DEST_TYPE_SHIFT 0
439 #define DPNI_DEST_TYPE_SIZE 4
440 #define DPNI_STASH_CTRL_SHIFT 6
441 #define DPNI_STASH_CTRL_SIZE 1
442 #define DPNI_HOLD_ACTIVE_SHIFT 7
443 #define DPNI_HOLD_ACTIVE_SIZE 1
445 struct dpni_rsp_get_queue {
446 /* response word 0 */
448 /* response word 1 */
452 /* From LSB: dest_type:4, pad:2, flc_stash_ctrl:1, hold_active:1 */
454 /* response word 2 */
456 /* response word 3 */
457 uint64_t user_context;
458 /* response word 4 */
463 struct dpni_cmd_set_queue {
478 uint64_t user_context;
481 #define DPNI_DROP_ENABLE_SHIFT 0
482 #define DPNI_DROP_ENABLE_SIZE 1
483 #define DPNI_DROP_UNITS_SHIFT 2
484 #define DPNI_DROP_UNITS_SIZE 2
486 struct dpni_early_drop {
487 /* from LSB: enable:1 units:2 */
491 uint8_t green_drop_probability;
493 uint64_t green_max_threshold;
494 uint64_t green_min_threshold;
496 uint8_t yellow_drop_probability;
498 uint64_t yellow_max_threshold;
499 uint64_t yellow_min_threshold;
501 uint8_t red_drop_probability;
503 uint64_t red_max_threshold;
504 uint64_t red_min_threshold;
507 struct dpni_cmd_early_drop {
511 uint64_t early_drop_iova;
514 struct dpni_rsp_get_api_version {
519 struct dpni_cmd_get_taildrop {
520 uint8_t congestion_point;
526 struct dpni_rsp_get_taildrop {
530 /* from LSB: enable:1 oal_lo:7 */
531 uint8_t enable_oal_lo;
532 /* from LSB: oal_hi:5 */
539 #define DPNI_OAL_LO_SHIFT 1
540 #define DPNI_OAL_LO_SIZE 7
541 #define DPNI_OAL_HI_SHIFT 0
542 #define DPNI_OAL_HI_SIZE 5
544 struct dpni_cmd_set_taildrop {
546 uint8_t congestion_point;
552 /* from LSB: enable:1 oal_lo:7 */
553 uint8_t enable_oal_lo;
554 /* from LSB: oal_hi:5 */
561 struct dpni_tx_confirmation_mode {
563 uint8_t confirmation_mode;
566 #define DPNI_DEST_TYPE_SHIFT 0
567 #define DPNI_DEST_TYPE_SIZE 4
568 #define DPNI_CONG_UNITS_SHIFT 4
569 #define DPNI_CONG_UNITS_SIZE 2
571 struct dpni_cmd_set_congestion_notification {
576 uint16_t notification_mode;
577 uint8_t dest_priority;
578 /* from LSB: dest_type: 4 units:2 */
580 uint64_t message_iova;
581 uint64_t message_ctx;
582 uint32_t threshold_entry;
583 uint32_t threshold_exit;
586 struct dpni_cmd_get_congestion_notification {
591 struct dpni_rsp_get_congestion_notification {
594 uint16_t notification_mode;
595 uint8_t dest_priority;
596 /* from LSB: dest_type: 4 units:2 */
598 uint64_t message_iova;
599 uint64_t message_ctx;
600 uint32_t threshold_entry;
601 uint32_t threshold_exit;
605 #endif /* _FSL_DPNI_CMD_H */