New upstream version 18.11-rc1
[deb_dpdk.git] / drivers / crypto / dpaa2_sec / mc / fsl_dpseci_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_DPSECI_CMD_H
8 #define _FSL_DPSECI_CMD_H
9
10 /* DPSECI Version */
11 #define DPSECI_VER_MAJOR                5
12 #define DPSECI_VER_MINOR                3
13
14 /* Command versioning */
15 #define DPSECI_CMD_BASE_VERSION         1
16 #define DPSECI_CMD_BASE_VERSION_V2      2
17 #define DPSECI_CMD_BASE_VERSION_V3      3
18 #define DPSECI_CMD_ID_OFFSET            4
19
20 #define DPSECI_CMD_V1(id) \
21         ((id << DPSECI_CMD_ID_OFFSET) | DPSECI_CMD_BASE_VERSION)
22 #define DPSECI_CMD_V2(id) \
23         ((id << DPSECI_CMD_ID_OFFSET) | DPSECI_CMD_BASE_VERSION_V2)
24 #define DPSECI_CMD_V3(id) \
25         ((id << DPSECI_CMD_ID_OFFSET) | DPSECI_CMD_BASE_VERSION_V3)
26
27 /* Command IDs */
28 #define DPSECI_CMDID_CLOSE              DPSECI_CMD_V1(0x800)
29 #define DPSECI_CMDID_OPEN               DPSECI_CMD_V1(0x809)
30 #define DPSECI_CMDID_CREATE             DPSECI_CMD_V3(0x909)
31 #define DPSECI_CMDID_DESTROY            DPSECI_CMD_V1(0x989)
32 #define DPSECI_CMDID_GET_API_VERSION    DPSECI_CMD_V1(0xa09)
33
34 #define DPSECI_CMDID_ENABLE             DPSECI_CMD_V1(0x002)
35 #define DPSECI_CMDID_DISABLE            DPSECI_CMD_V1(0x003)
36 #define DPSECI_CMDID_GET_ATTR           DPSECI_CMD_V1(0x004)
37 #define DPSECI_CMDID_RESET              DPSECI_CMD_V1(0x005)
38 #define DPSECI_CMDID_IS_ENABLED         DPSECI_CMD_V1(0x006)
39
40 #define DPSECI_CMDID_SET_RX_QUEUE       DPSECI_CMD_V1(0x194)
41 #define DPSECI_CMDID_GET_RX_QUEUE       DPSECI_CMD_V1(0x196)
42 #define DPSECI_CMDID_GET_TX_QUEUE       DPSECI_CMD_V1(0x197)
43 #define DPSECI_CMDID_GET_SEC_ATTR       DPSECI_CMD_V2(0x198)
44 #define DPSECI_CMDID_GET_SEC_COUNTERS   DPSECI_CMD_V1(0x199)
45 #define DPSECI_CMDID_SET_OPR            DPSECI_CMD_V1(0x19A)
46 #define DPSECI_CMDID_GET_OPR            DPSECI_CMD_V1(0x19B)
47 #define DPSECI_CMDID_SET_CONGESTION_NOTIFICATION        DPSECI_CMD_V1(0x170)
48 #define DPSECI_CMDID_GET_CONGESTION_NOTIFICATION        DPSECI_CMD_V1(0x171)
49
50 /* Macros for accessing command fields smaller than 1byte */
51 #define DPSECI_MASK(field)        \
52         GENMASK(DPSECI_##field##_SHIFT + DPSECI_##field##_SIZE - 1, \
53                 DPSECI_##field##_SHIFT)
54 #define dpseci_set_field(var, field, val) \
55         ((var) |= (((val) << DPSECI_##field##_SHIFT) & DPSECI_MASK(field)))
56 #define dpseci_get_field(var, field)      \
57         (((var) & DPSECI_MASK(field)) >> DPSECI_##field##_SHIFT)
58
59 #pragma pack(push, 1)
60 struct dpseci_cmd_open {
61         uint32_t dpseci_id;
62 };
63
64 struct dpseci_cmd_create {
65         uint8_t priorities[8];
66         uint8_t num_tx_queues;
67         uint8_t num_rx_queues;
68         uint8_t pad[6];
69         uint32_t options;
70         uint32_t pad2;
71         uint8_t priorities2[8];
72 };
73
74 struct dpseci_cmd_destroy {
75         uint32_t dpseci_id;
76 };
77
78 #define DPSECI_ENABLE_SHIFT     0
79 #define DPSECI_ENABLE_SIZE      1
80
81 struct dpseci_rsp_is_enabled {
82         /* only the first LSB */
83         uint8_t en;
84 };
85
86 struct dpseci_rsp_get_attr {
87         uint32_t id;
88         uint32_t pad;
89         uint8_t num_tx_queues;
90         uint8_t num_rx_queues;
91         uint8_t pad1[6];
92         uint32_t options;
93 };
94
95 #define DPSECI_DEST_TYPE_SHIFT  0
96 #define DPSECI_DEST_TYPE_SIZE   4
97
98 #define DPSECI_ORDER_PRESERVATION_SHIFT 0
99 #define DPSECI_ORDER_PRESERVATION_SIZE  1
100
101 struct dpseci_cmd_set_rx_queue {
102         uint32_t dest_id;
103         uint8_t dest_priority;
104         uint8_t queue;
105         /* from LSB: dest_type:4 */
106         uint8_t dest_type;
107         uint8_t pad;
108         uint64_t user_ctx;
109         uint32_t options;
110         /* only the LSB */
111         uint8_t order_preservation_en;
112 };
113
114 struct dpseci_cmd_get_queue {
115         uint8_t pad[5];
116         uint8_t queue;
117 };
118
119 struct dpseci_rsp_get_rx_queue {
120         uint32_t dest_id;
121         uint8_t dest_priority;
122         uint8_t pad1;
123         /* from LSB: dest_type:4 */
124         uint8_t dest_type;
125         uint8_t pad2;
126         uint64_t user_ctx;
127         uint32_t fqid;
128         /* only the LSB */
129         uint8_t order_preservation_en;
130
131 };
132
133 struct dpseci_rsp_get_tx_queue {
134         uint32_t pad;
135         uint32_t fqid;
136         uint8_t priority;
137 };
138
139 struct dpseci_rsp_get_sec_attr {
140         uint16_t ip_id;
141         uint8_t major_rev;
142         uint8_t minor_rev;
143         uint8_t era;
144         uint8_t pad1[3];
145         uint8_t deco_num;
146         uint8_t zuc_auth_acc_num;
147         uint8_t zuc_enc_acc_num;
148         uint8_t pad2;
149         uint8_t snow_f8_acc_num;
150         uint8_t snow_f9_acc_num;
151         uint8_t crc_acc_num;
152         uint8_t pad3;
153         uint8_t pk_acc_num;
154         uint8_t kasumi_acc_num;
155         uint8_t rng_acc_num;
156         uint8_t pad4;
157         uint8_t md_acc_num;
158         uint8_t arc4_acc_num;
159         uint8_t des_acc_num;
160         uint8_t aes_acc_num;
161         uint8_t ccha_acc_num;
162         uint8_t ptha_acc_num;
163 };
164
165 struct dpseci_rsp_get_sec_counters {
166         uint64_t dequeued_requests;
167         uint64_t ob_enc_requests;
168         uint64_t ib_dec_requests;
169         uint64_t ob_enc_bytes;
170         uint64_t ob_prot_bytes;
171         uint64_t ib_dec_bytes;
172         uint64_t ib_valid_bytes;
173 };
174
175 struct dpseci_rsp_get_api_version {
176         uint16_t major;
177         uint16_t minor;
178 };
179
180 struct dpseci_cmd_set_opr {
181         uint16_t pad0;
182         uint8_t index;
183         uint8_t options;
184         uint8_t pad1[7];
185         uint8_t oloe;
186         uint8_t oeane;
187         uint8_t olws;
188         uint8_t oa;
189         uint8_t oprrws;
190 };
191
192 struct dpseci_cmd_get_opr {
193         uint16_t pad;
194         uint8_t index;
195 };
196
197 #define DPSECI_RIP_SHIFT        0
198 #define DPSECI_RIP_SIZE         1
199 #define DPSECI_OPR_ENABLE_SHIFT 1
200 #define DPSECI_OPR_ENABLE_SIZE  1
201 #define DPSECI_TSEQ_NLIS_SHIFT  0
202 #define DPSECI_TSEQ_NLIS_SIZE   1
203 #define DPSECI_HSEQ_NLIS_SHIFT  0
204 #define DPSECI_HSEQ_NLIS_SIZE   1
205
206 struct dpseci_rsp_get_opr {
207         uint64_t pad0;
208         /* from LSB: rip:1 enable:1 */
209         uint8_t flags;
210         uint16_t pad1;
211         uint8_t oloe;
212         uint8_t oeane;
213         uint8_t olws;
214         uint8_t oa;
215         uint8_t oprrws;
216         uint16_t nesn;
217         uint16_t pad8;
218         uint16_t ndsn;
219         uint16_t pad2;
220         uint16_t ea_tseq;
221         /* only the LSB */
222         uint8_t tseq_nlis;
223         uint8_t pad3;
224         uint16_t ea_hseq;
225         /* only the LSB */
226         uint8_t hseq_nlis;
227         uint8_t pad4;
228         uint16_t ea_hptr;
229         uint16_t pad5;
230         uint16_t ea_tptr;
231         uint16_t pad6;
232         uint16_t opr_vid;
233         uint16_t pad7;
234         uint16_t opr_id;
235 };
236
237 #define DPSECI_DEST_TYPE_SHIFT          0
238 #define DPSECI_DEST_TYPE_SIZE           4
239 #define DPSECI_CG_UNITS_SHIFT           4
240 #define DPSECI_CG_UNITS_SIZE            2
241
242 struct dpseci_cmd_set_congestion_notification {
243         uint32_t dest_id;
244         uint16_t notification_mode;
245         uint8_t dest_priority;
246         /* from LSB: dest_type: 4 units:2 */
247         uint8_t type_units;
248         uint64_t message_iova;
249         uint64_t message_ctx;
250         uint32_t threshold_entry;
251         uint32_t threshold_exit;
252 };
253
254 #pragma pack(pop)
255 #endif /* _FSL_DPSECI_CMD_H */