net/mlx5: fix meter creation default state
[dpdk.git] / drivers / bus / fslmc / mc / fsl_dpdmai_cmd.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2017-2018, 2020-2021 NXP
3  */
4 #ifndef _FSL_DPDMAI_CMD_H
5 #define _FSL_DPDMAI_CMD_H
6
7 /* DPDMAI Version */
8 #define DPDMAI_VER_MAJOR                3
9 #define DPDMAI_VER_MINOR                4
10
11 /* Command versioning */
12 #define DPDMAI_CMD_BASE_VERSION         1
13 #define DPDMAI_CMD_VERSION_2            2
14 #define DPDMAI_CMD_VERSION_3            3
15 #define DPDMAI_CMD_ID_OFFSET            4
16
17 #define DPDMAI_CMD(id)  ((id << DPDMAI_CMD_ID_OFFSET) | DPDMAI_CMD_BASE_VERSION)
18 #define DPDMAI_CMD_V2(id) ((id << DPDMAI_CMD_ID_OFFSET) | DPDMAI_CMD_VERSION_2)
19 #define DPDMAI_CMD_V3(id) ((id << DPDMAI_CMD_ID_OFFSET) | DPDMAI_CMD_VERSION_3)
20
21 /* Command IDs */
22 #define DPDMAI_CMDID_CLOSE              DPDMAI_CMD(0x800)
23 #define DPDMAI_CMDID_OPEN               DPDMAI_CMD(0x80E)
24 #define DPDMAI_CMDID_CREATE             DPDMAI_CMD_V3(0x90E)
25 #define DPDMAI_CMDID_DESTROY            DPDMAI_CMD(0x98E)
26 #define DPDMAI_CMDID_GET_API_VERSION    DPDMAI_CMD(0xa0E)
27
28 #define DPDMAI_CMDID_ENABLE             DPDMAI_CMD(0x002)
29 #define DPDMAI_CMDID_DISABLE            DPDMAI_CMD(0x003)
30 #define DPDMAI_CMDID_GET_ATTR           DPDMAI_CMD_V3(0x004)
31 #define DPDMAI_CMDID_RESET              DPDMAI_CMD(0x005)
32 #define DPDMAI_CMDID_IS_ENABLED         DPDMAI_CMD(0x006)
33
34 #define DPDMAI_CMDID_SET_RX_QUEUE       DPDMAI_CMD_V2(0x1A0)
35 #define DPDMAI_CMDID_GET_RX_QUEUE       DPDMAI_CMD_V2(0x1A1)
36 #define DPDMAI_CMDID_GET_TX_QUEUE       DPDMAI_CMD_V2(0x1A2)
37
38 /* Macros for accessing command fields smaller than 1byte */
39 #define DPDMAI_MASK(field)        \
40         GENMASK(DPDMAI_##field##_SHIFT + DPDMAI_##field##_SIZE - 1, \
41                 DPDMAI_##field##_SHIFT)
42 #define dpdmai_set_field(var, field, val) \
43         ((var) |= (((val) << DPDMAI_##field##_SHIFT) & DPDMAI_MASK(field)))
44 #define dpdmai_get_field(var, field)      \
45         (((var) & DPDMAI_MASK(field)) >> DPDMAI_##field##_SHIFT)
46
47 #pragma pack(push, 1)
48 struct dpdmai_cmd_open {
49         uint32_t dpdmai_id;
50 };
51
52 struct dpdmai_cmd_create {
53         uint8_t num_queues;
54         uint8_t priorities[2];
55         uint8_t pad;
56         uint32_t options;
57 };
58
59 struct dpdmai_cmd_destroy {
60         uint32_t dpdmai_id;
61 };
62
63 #define DPDMAI_ENABLE_SHIFT     0
64 #define DPDMAI_ENABLE_SIZE      1
65
66 struct dpdmai_rsp_is_enabled {
67         /* only the LSB bit */
68         uint8_t en;
69 };
70
71 struct dpdmai_rsp_get_attr {
72         uint32_t id;
73         uint8_t num_of_priorities;
74         uint8_t num_of_queues;
75         uint16_t pad;
76         uint32_t options;
77 };
78
79 #define DPDMAI_DEST_TYPE_SHIFT  0
80 #define DPDMAI_DEST_TYPE_SIZE   4
81
82 struct dpdmai_cmd_set_rx_queue {
83         uint32_t dest_id;
84         uint8_t dest_priority;
85         uint8_t priority;
86         /* from LSB: dest_type:4 */
87         uint8_t dest_type;
88         uint8_t queue_idx;
89         uint64_t user_ctx;
90         uint32_t options;
91 };
92
93 struct dpdmai_cmd_get_queue {
94         uint8_t pad[5];
95         uint8_t priority;
96         uint8_t queue_idx;
97 };
98
99 struct dpdmai_rsp_get_rx_queue {
100         uint32_t dest_id;
101         uint8_t dest_priority;
102         uint8_t pad1;
103         /* from LSB: dest_type:4 */
104         uint8_t dest_type;
105         uint8_t pad2;
106         uint64_t user_ctx;
107         uint32_t fqid;
108 };
109
110 struct dpdmai_rsp_get_tx_queue {
111         uint64_t pad;
112         uint32_t fqid;
113 };
114
115 #pragma pack(pop)
116 #endif /* _FSL_DPDMAI_CMD_H */