New upstream version 18.02
[deb_dpdk.git] / drivers / net / dpaa2 / mc / fsl_dpni_cmd.h
1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
2  *
3  * Copyright 2013-2016 Freescale Semiconductor Inc.
4  * Copyright 2016-2017 NXP
5  *
6  */
7 #ifndef _FSL_DPNI_CMD_H
8 #define _FSL_DPNI_CMD_H
9
10 /* DPNI Version */
11 #define DPNI_VER_MAJOR                          7
12 #define DPNI_VER_MINOR                          3
13
14 #define DPNI_CMD_BASE_VERSION                   1
15 #define DPNI_CMD_VERSION_2                      2
16 #define DPNI_CMD_ID_OFFSET                      4
17
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)
20
21 /* Command IDs */
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)
27
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)
33
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)
40
41 #define DPNI_CMDID_SET_POOLS                    DPNI_CMD_V2(0x200)
42 #define DPNI_CMDID_SET_ERRORS_BEHAVIOR          DPNI_CMD(0x20B)
43
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)
52
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)
62
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)
67
68 #define DPNI_CMDID_SET_RX_TC_DIST               DPNI_CMD_V2(0x235)
69
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)
76
77 #define DPNI_CMDID_GET_PORT_MAC_ADDR            DPNI_CMD(0x263)
78
79 #define DPNI_CMDID_GET_BUFFER_LAYOUT            DPNI_CMD(0x264)
80 #define DPNI_CMDID_SET_BUFFER_LAYOUT            DPNI_CMD(0x265)
81
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)
90
91 /* Macros for accessing command fields smaller than 1byte */
92 #define DPNI_MASK(field)        \
93         GENMASK(DPNI_##field##_SHIFT + DPNI_##field##_SIZE - 1, \
94                 DPNI_##field##_SHIFT)
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)
99
100 #pragma pack(push, 1)
101 struct dpni_cmd_open {
102         uint32_t dpni_id;
103 };
104
105 struct dpni_cmd_create {
106         uint32_t options;
107         uint8_t num_queues;
108         uint8_t num_tcs;
109         uint8_t mac_filter_entries;
110         uint8_t pad1;
111         uint8_t vlan_filter_entries;
112         uint8_t pad2;
113         uint8_t qos_entries;
114         uint8_t pad3;
115         uint16_t fs_entries;
116 };
117
118 struct dpni_cmd_destroy {
119         uint32_t dpsw_id;
120 };
121
122 #define DPNI_BACKUP_POOL(val, order)    (((val) & 0x1) << (order))
123
124 struct dpni_cmd_pool {
125         uint16_t dpbp_id;
126         uint8_t priority_mask;
127         uint8_t pad;
128 };
129
130 struct dpni_cmd_set_pools {
131         uint8_t num_dpbp;
132         uint8_t backup_pool_mask;
133         uint16_t pad;
134         struct dpni_cmd_pool pool[8];
135         uint16_t buffer_size[8];
136 };
137
138 /* The enable indication is always the least significant bit */
139 #define DPNI_ENABLE_SHIFT               0
140 #define DPNI_ENABLE_SIZE                1
141
142 struct dpni_rsp_is_enabled {
143         uint8_t enabled;
144 };
145
146 struct dpni_cmd_set_irq_enable {
147         uint8_t enable;
148         uint8_t pad[3];
149         uint8_t irq_index;
150 };
151
152 struct dpni_cmd_get_irq_enable {
153         uint32_t pad;
154         uint8_t irq_index;
155 };
156
157 struct dpni_rsp_get_irq_enable {
158         uint8_t enabled;
159 };
160
161 struct dpni_cmd_set_irq_mask {
162         uint32_t mask;
163         uint8_t irq_index;
164 };
165
166 struct dpni_cmd_get_irq_mask {
167         uint32_t pad;
168         uint8_t irq_index;
169 };
170
171 struct dpni_rsp_get_irq_mask {
172         uint32_t mask;
173 };
174
175 struct dpni_cmd_get_irq_status {
176         uint32_t status;
177         uint8_t irq_index;
178 };
179
180 struct dpni_rsp_get_irq_status {
181         uint32_t status;
182 };
183
184 struct dpni_cmd_clear_irq_status {
185         uint32_t status;
186         uint8_t irq_index;
187 };
188
189 struct dpni_rsp_get_attr {
190         /* response word 0 */
191         uint32_t options;
192         uint8_t num_queues;
193         uint8_t num_rx_tcs;
194         uint8_t mac_filter_entries;
195         uint8_t num_tx_tcs;
196         /* response word 1 */
197         uint8_t vlan_filter_entries;
198         uint8_t pad1;
199         uint8_t qos_entries;
200         uint8_t pad2;
201         uint16_t fs_entries;
202         uint16_t pad3;
203         /* response word 2 */
204         uint8_t qos_key_size;
205         uint8_t fs_key_size;
206         uint16_t wriop_version;
207 };
208
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
213
214 struct dpni_cmd_set_errors_behavior {
215         uint32_t errors;
216         /* from least significant bit: error_action:4, set_frame_annotation:1 */
217         uint8_t flags;
218 };
219
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.
223  */
224
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
231
232 struct dpni_cmd_get_buffer_layout {
233         uint8_t qtype;
234 };
235
236 struct dpni_rsp_get_buffer_layout {
237         /* response word 0 */
238         uint8_t pad0[6];
239         /* from LSB: pass_timestamp:1, parser_result:1, frame_status:1 */
240         uint8_t flags;
241         uint8_t pad1;
242         /* response word 1 */
243         uint16_t private_data_size;
244         uint16_t data_align;
245         uint16_t head_room;
246         uint16_t tail_room;
247 };
248
249 struct dpni_cmd_set_buffer_layout {
250         /* cmd word 0 */
251         uint8_t qtype;
252         uint8_t pad0[3];
253         uint16_t options;
254         /* from LSB: pass_timestamp:1, parser_result:1, frame_status:1 */
255         uint8_t flags;
256         uint8_t pad1;
257         /* cmd word 1 */
258         uint16_t private_data_size;
259         uint16_t data_align;
260         uint16_t head_room;
261         uint16_t tail_room;
262 };
263
264 struct dpni_cmd_set_offload {
265         uint8_t pad[3];
266         uint8_t dpni_offload;
267         uint32_t config;
268 };
269
270 struct dpni_cmd_get_offload {
271         uint8_t pad[3];
272         uint8_t dpni_offload;
273 };
274
275 struct dpni_rsp_get_offload {
276         uint32_t pad;
277         uint32_t config;
278 };
279
280 struct dpni_cmd_get_qdid {
281         uint8_t qtype;
282 };
283
284 struct dpni_rsp_get_qdid {
285         uint16_t qdid;
286 };
287
288 struct dpni_rsp_get_sp_info {
289         uint16_t spids[2];
290 };
291
292 struct dpni_rsp_get_tx_data_offset {
293         uint16_t data_offset;
294 };
295
296 struct dpni_cmd_get_statistics {
297         uint8_t page_number;
298         uint8_t param;
299 };
300
301 struct dpni_rsp_get_statistics {
302         uint64_t counter[7];
303 };
304
305 struct dpni_cmd_set_link_cfg {
306         uint64_t pad0;
307         uint32_t rate;
308         uint32_t pad1;
309         uint64_t options;
310 };
311
312 #define DPNI_LINK_STATE_SHIFT           0
313 #define DPNI_LINK_STATE_SIZE            1
314
315 struct dpni_rsp_get_link_state {
316         uint32_t pad0;
317         /* from LSB: up:1 */
318         uint8_t flags;
319         uint8_t pad1[3];
320         uint32_t rate;
321         uint32_t pad2;
322         uint64_t options;
323 };
324
325 struct dpni_cmd_set_max_frame_length {
326         uint16_t max_frame_length;
327 };
328
329 struct dpni_rsp_get_max_frame_length {
330         uint16_t max_frame_length;
331 };
332
333 struct dpni_cmd_set_multicast_promisc {
334         uint8_t enable;
335 };
336
337 struct dpni_rsp_get_multicast_promisc {
338         uint8_t enabled;
339 };
340
341 struct dpni_cmd_set_unicast_promisc {
342         uint8_t enable;
343 };
344
345 struct dpni_rsp_get_unicast_promisc {
346         uint8_t enabled;
347 };
348
349 struct dpni_cmd_set_primary_mac_addr {
350         uint16_t pad;
351         uint8_t mac_addr[6];
352 };
353
354 struct dpni_rsp_get_primary_mac_addr {
355         uint16_t pad;
356         uint8_t mac_addr[6];
357 };
358
359 struct dpni_rsp_get_port_mac_addr {
360         uint16_t pad;
361         uint8_t mac_addr[6];
362 };
363
364 struct dpni_cmd_add_mac_addr {
365         uint16_t pad;
366         uint8_t mac_addr[6];
367 };
368
369 struct dpni_cmd_remove_mac_addr {
370         uint16_t pad;
371         uint8_t mac_addr[6];
372 };
373
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
378
379 struct dpni_cmd_clear_mac_filters {
380         /* from LSB: unicast:1, multicast:1 */
381         uint8_t flags;
382 };
383
384 struct dpni_cmd_enable_vlan_filter {
385         /* only the LSB */
386         uint8_t en;
387 };
388
389 struct dpni_cmd_vlan_id {
390         uint32_t pad;
391         uint16_t vlan_id;
392 };
393
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
400
401 struct dpni_cmd_set_tx_priorities {
402         uint16_t flags;
403         uint8_t prio_group_A;
404         uint8_t prio_group_B;
405         uint32_t pad0;
406         uint8_t modes[4];
407         uint32_t pad1;
408         uint64_t pad2;
409         uint16_t delta_bandwidth[8];
410 };
411
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
418
419 struct dpni_cmd_set_rx_tc_dist {
420         uint16_t dist_size;
421         uint8_t tc_id;
422         /* from LSB: dist_mode:4, miss_action:4 */
423         uint8_t flags;
424         uint8_t pad0;
425         /* only the LSB */
426         uint8_t keep_hash_key;
427         uint16_t default_flow_id;
428         uint64_t pad1[5];
429         uint64_t key_cfg_iova;
430 };
431
432 struct dpni_cmd_get_queue {
433         uint8_t qtype;
434         uint8_t tc;
435         uint8_t index;
436 };
437
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
444
445 struct dpni_rsp_get_queue {
446         /* response word 0 */
447         uint64_t pad0;
448         /* response word 1 */
449         uint32_t dest_id;
450         uint16_t pad1;
451         uint8_t dest_prio;
452         /* From LSB: dest_type:4, pad:2, flc_stash_ctrl:1, hold_active:1 */
453         uint8_t flags;
454         /* response word 2 */
455         uint64_t flc;
456         /* response word 3 */
457         uint64_t user_context;
458         /* response word 4 */
459         uint32_t fqid;
460         uint16_t qdbin;
461 };
462
463 struct dpni_cmd_set_queue {
464         /* cmd word 0 */
465         uint8_t qtype;
466         uint8_t tc;
467         uint8_t index;
468         uint8_t options;
469         uint32_t pad0;
470         /* cmd word 1 */
471         uint32_t dest_id;
472         uint16_t pad1;
473         uint8_t dest_prio;
474         uint8_t flags;
475         /* cmd word 2 */
476         uint64_t flc;
477         /* cmd word 3 */
478         uint64_t user_context;
479 };
480
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
485
486 struct dpni_early_drop {
487         /* from LSB: enable:1 units:2 */
488         uint8_t flags;
489         uint8_t pad0[3];
490         uint32_t pad1;
491         uint8_t green_drop_probability;
492         uint8_t pad2[7];
493         uint64_t green_max_threshold;
494         uint64_t green_min_threshold;
495         uint64_t pad3;
496         uint8_t yellow_drop_probability;
497         uint8_t pad4[7];
498         uint64_t yellow_max_threshold;
499         uint64_t yellow_min_threshold;
500         uint64_t pad5;
501         uint8_t red_drop_probability;
502         uint8_t pad6[7];
503         uint64_t red_max_threshold;
504         uint64_t red_min_threshold;
505 };
506
507 struct dpni_cmd_early_drop {
508         uint8_t qtype;
509         uint8_t tc;
510         uint8_t pad[6];
511         uint64_t early_drop_iova;
512 };
513
514 struct dpni_rsp_get_api_version {
515         uint16_t major;
516         uint16_t minor;
517 };
518
519 struct dpni_cmd_get_taildrop {
520         uint8_t congestion_point;
521         uint8_t qtype;
522         uint8_t tc;
523         uint8_t index;
524 };
525
526 struct dpni_rsp_get_taildrop {
527         /* cmd word 0 */
528         uint64_t pad0;
529         /* cmd word 1 */
530         /* from LSB: enable:1 oal_lo:7 */
531         uint8_t enable_oal_lo;
532         /* from LSB: oal_hi:5 */
533         uint8_t oal_hi;
534         uint8_t units;
535         uint8_t pad2;
536         uint32_t threshold;
537 };
538
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
543
544 struct dpni_cmd_set_taildrop {
545         /* cmd word 0 */
546         uint8_t congestion_point;
547         uint8_t qtype;
548         uint8_t tc;
549         uint8_t index;
550         uint32_t pad0;
551         /* cmd word 1 */
552         /* from LSB: enable:1 oal_lo:7 */
553         uint8_t enable_oal_lo;
554         /* from LSB: oal_hi:5 */
555         uint8_t oal_hi;
556         uint8_t units;
557         uint8_t pad2;
558         uint32_t threshold;
559 };
560
561 struct dpni_tx_confirmation_mode {
562         uint32_t pad;
563         uint8_t confirmation_mode;
564 };
565
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
570
571 struct dpni_cmd_set_congestion_notification {
572         uint8_t qtype;
573         uint8_t tc;
574         uint8_t pad[6];
575         uint32_t dest_id;
576         uint16_t notification_mode;
577         uint8_t dest_priority;
578         /* from LSB: dest_type: 4 units:2 */
579         uint8_t type_units;
580         uint64_t message_iova;
581         uint64_t message_ctx;
582         uint32_t threshold_entry;
583         uint32_t threshold_exit;
584 };
585
586 struct dpni_cmd_get_congestion_notification {
587         uint8_t qtype;
588         uint8_t tc;
589 };
590
591 struct dpni_rsp_get_congestion_notification {
592         uint64_t pad;
593         uint32_t dest_id;
594         uint16_t notification_mode;
595         uint8_t dest_priority;
596         /* from LSB: dest_type: 4 units:2 */
597         uint8_t type_units;
598         uint64_t message_iova;
599         uint64_t message_ctx;
600         uint32_t threshold_entry;
601         uint32_t threshold_exit;
602 };
603
604 #pragma pack(pop)
605 #endif /* _FSL_DPNI_CMD_H */