1
2
3
4
5
6
7#include <linux/fsl/mc.h>
8#include "dpseci.h"
9#include "dpseci_cmd.h"
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27int dpseci_open(struct fsl_mc_io *mc_io, u32 cmd_flags, int dpseci_id,
28 u16 *token)
29{
30 struct fsl_mc_command cmd = { 0 };
31 struct dpseci_cmd_open *cmd_params;
32 int err;
33
34 cmd.header = mc_encode_cmd_header(DPSECI_CMDID_OPEN,
35 cmd_flags,
36 0);
37 cmd_params = (struct dpseci_cmd_open *)cmd.params;
38 cmd_params->dpseci_id = cpu_to_le32(dpseci_id);
39 err = mc_send_command(mc_io, &cmd);
40 if (err)
41 return err;
42
43 *token = mc_cmd_hdr_read_token(&cmd);
44
45 return 0;
46}
47
48
49
50
51
52
53
54
55
56
57
58
59int dpseci_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token)
60{
61 struct fsl_mc_command cmd = { 0 };
62
63 cmd.header = mc_encode_cmd_header(DPSECI_CMDID_CLOSE,
64 cmd_flags,
65 token);
66 return mc_send_command(mc_io, &cmd);
67}
68
69
70
71
72
73
74
75
76
77int dpseci_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token)
78{
79 struct fsl_mc_command cmd = { 0 };
80
81 cmd.header = mc_encode_cmd_header(DPSECI_CMDID_ENABLE,
82 cmd_flags,
83 token);
84 return mc_send_command(mc_io, &cmd);
85}
86
87
88
89
90
91
92
93
94
95int dpseci_disable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token)
96{
97 struct fsl_mc_command cmd = { 0 };
98
99 cmd.header = mc_encode_cmd_header(DPSECI_CMDID_DISABLE,
100 cmd_flags,
101 token);
102
103 return mc_send_command(mc_io, &cmd);
104}
105
106
107
108
109
110
111
112
113
114
115int dpseci_is_enabled(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
116 int *en)
117{
118 struct fsl_mc_command cmd = { 0 };
119 struct dpseci_rsp_is_enabled *rsp_params;
120 int err;
121
122 cmd.header = mc_encode_cmd_header(DPSECI_CMDID_IS_ENABLED,
123 cmd_flags,
124 token);
125 err = mc_send_command(mc_io, &cmd);
126 if (err)
127 return err;
128
129 rsp_params = (struct dpseci_rsp_is_enabled *)cmd.params;
130 *en = dpseci_get_field(rsp_params->is_enabled, ENABLE);
131
132 return 0;
133}
134
135
136
137
138
139
140
141
142
143
144int dpseci_get_attributes(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
145 struct dpseci_attr *attr)
146{
147 struct fsl_mc_command cmd = { 0 };
148 struct dpseci_rsp_get_attributes *rsp_params;
149 int err;
150
151 cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_ATTR,
152 cmd_flags,
153 token);
154 err = mc_send_command(mc_io, &cmd);
155 if (err)
156 return err;
157
158 rsp_params = (struct dpseci_rsp_get_attributes *)cmd.params;
159 attr->id = le32_to_cpu(rsp_params->id);
160 attr->num_tx_queues = rsp_params->num_tx_queues;
161 attr->num_rx_queues = rsp_params->num_rx_queues;
162 attr->options = le32_to_cpu(rsp_params->options);
163
164 return 0;
165}
166
167
168
169
170
171
172
173
174
175
176
177
178
179int dpseci_set_rx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
180 u8 queue, const struct dpseci_rx_queue_cfg *cfg)
181{
182 struct fsl_mc_command cmd = { 0 };
183 struct dpseci_cmd_queue *cmd_params;
184
185 cmd.header = mc_encode_cmd_header(DPSECI_CMDID_SET_RX_QUEUE,
186 cmd_flags,
187 token);
188 cmd_params = (struct dpseci_cmd_queue *)cmd.params;
189 cmd_params->dest_id = cpu_to_le32(cfg->dest_cfg.dest_id);
190 cmd_params->priority = cfg->dest_cfg.priority;
191 cmd_params->queue = queue;
192 dpseci_set_field(cmd_params->dest_type, DEST_TYPE,
193 cfg->dest_cfg.dest_type);
194 cmd_params->user_ctx = cpu_to_le64(cfg->user_ctx);
195 cmd_params->options = cpu_to_le32(cfg->options);
196 dpseci_set_field(cmd_params->order_preservation_en, ORDER_PRESERVATION,
197 cfg->order_preservation_en);
198
199 return mc_send_command(mc_io, &cmd);
200}
201
202
203
204
205
206
207
208
209
210
211
212
213int dpseci_get_rx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
214 u8 queue, struct dpseci_rx_queue_attr *attr)
215{
216 struct fsl_mc_command cmd = { 0 };
217 struct dpseci_cmd_queue *cmd_params;
218 int err;
219
220 cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_RX_QUEUE,
221 cmd_flags,
222 token);
223 cmd_params = (struct dpseci_cmd_queue *)cmd.params;
224 cmd_params->queue = queue;
225 err = mc_send_command(mc_io, &cmd);
226 if (err)
227 return err;
228
229 attr->dest_cfg.dest_id = le32_to_cpu(cmd_params->dest_id);
230 attr->dest_cfg.priority = cmd_params->priority;
231 attr->dest_cfg.dest_type = dpseci_get_field(cmd_params->dest_type,
232 DEST_TYPE);
233 attr->user_ctx = le64_to_cpu(cmd_params->user_ctx);
234 attr->fqid = le32_to_cpu(cmd_params->fqid);
235 attr->order_preservation_en =
236 dpseci_get_field(cmd_params->order_preservation_en,
237 ORDER_PRESERVATION);
238
239 return 0;
240}
241
242
243
244
245
246
247
248
249
250
251
252
253int dpseci_get_tx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
254 u8 queue, struct dpseci_tx_queue_attr *attr)
255{
256 struct fsl_mc_command cmd = { 0 };
257 struct dpseci_cmd_queue *cmd_params;
258 struct dpseci_rsp_get_tx_queue *rsp_params;
259 int err;
260
261 cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_TX_QUEUE,
262 cmd_flags,
263 token);
264 cmd_params = (struct dpseci_cmd_queue *)cmd.params;
265 cmd_params->queue = queue;
266 err = mc_send_command(mc_io, &cmd);
267 if (err)
268 return err;
269
270 rsp_params = (struct dpseci_rsp_get_tx_queue *)cmd.params;
271 attr->fqid = le32_to_cpu(rsp_params->fqid);
272 attr->priority = rsp_params->priority;
273
274 return 0;
275}
276
277
278
279
280
281
282
283
284
285
286int dpseci_get_sec_attr(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
287 struct dpseci_sec_attr *attr)
288{
289 struct fsl_mc_command cmd = { 0 };
290 struct dpseci_rsp_get_sec_attr *rsp_params;
291 int err;
292
293 cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_SEC_ATTR,
294 cmd_flags,
295 token);
296 err = mc_send_command(mc_io, &cmd);
297 if (err)
298 return err;
299
300 rsp_params = (struct dpseci_rsp_get_sec_attr *)cmd.params;
301 attr->ip_id = le16_to_cpu(rsp_params->ip_id);
302 attr->major_rev = rsp_params->major_rev;
303 attr->minor_rev = rsp_params->minor_rev;
304 attr->era = rsp_params->era;
305 attr->deco_num = rsp_params->deco_num;
306 attr->zuc_auth_acc_num = rsp_params->zuc_auth_acc_num;
307 attr->zuc_enc_acc_num = rsp_params->zuc_enc_acc_num;
308 attr->snow_f8_acc_num = rsp_params->snow_f8_acc_num;
309 attr->snow_f9_acc_num = rsp_params->snow_f9_acc_num;
310 attr->crc_acc_num = rsp_params->crc_acc_num;
311 attr->pk_acc_num = rsp_params->pk_acc_num;
312 attr->kasumi_acc_num = rsp_params->kasumi_acc_num;
313 attr->rng_acc_num = rsp_params->rng_acc_num;
314 attr->md_acc_num = rsp_params->md_acc_num;
315 attr->arc4_acc_num = rsp_params->arc4_acc_num;
316 attr->des_acc_num = rsp_params->des_acc_num;
317 attr->aes_acc_num = rsp_params->aes_acc_num;
318 attr->ccha_acc_num = rsp_params->ccha_acc_num;
319 attr->ptha_acc_num = rsp_params->ptha_acc_num;
320
321 return 0;
322}
323
324
325
326
327
328
329
330
331
332
333int dpseci_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags,
334 u16 *major_ver, u16 *minor_ver)
335{
336 struct fsl_mc_command cmd = { 0 };
337 struct dpseci_rsp_get_api_version *rsp_params;
338 int err;
339
340 cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_API_VERSION,
341 cmd_flags, 0);
342 err = mc_send_command(mc_io, &cmd);
343 if (err)
344 return err;
345
346 rsp_params = (struct dpseci_rsp_get_api_version *)cmd.params;
347 *major_ver = le16_to_cpu(rsp_params->major);
348 *minor_ver = le16_to_cpu(rsp_params->minor);
349
350 return 0;
351}
352
353
354
355
356
357
358
359
360
361
362
363int dpseci_set_congestion_notification(struct fsl_mc_io *mc_io, u32 cmd_flags,
364 u16 token, const struct dpseci_congestion_notification_cfg *cfg)
365{
366 struct fsl_mc_command cmd = { 0 };
367 struct dpseci_cmd_congestion_notification *cmd_params;
368
369 cmd.header = mc_encode_cmd_header(
370 DPSECI_CMDID_SET_CONGESTION_NOTIFICATION,
371 cmd_flags,
372 token);
373 cmd_params = (struct dpseci_cmd_congestion_notification *)cmd.params;
374 cmd_params->dest_id = cpu_to_le32(cfg->dest_cfg.dest_id);
375 cmd_params->notification_mode = cpu_to_le16(cfg->notification_mode);
376 cmd_params->priority = cfg->dest_cfg.priority;
377 dpseci_set_field(cmd_params->options, CGN_DEST_TYPE,
378 cfg->dest_cfg.dest_type);
379 dpseci_set_field(cmd_params->options, CGN_UNITS, cfg->units);
380 cmd_params->message_iova = cpu_to_le64(cfg->message_iova);
381 cmd_params->message_ctx = cpu_to_le64(cfg->message_ctx);
382 cmd_params->threshold_entry = cpu_to_le32(cfg->threshold_entry);
383 cmd_params->threshold_exit = cpu_to_le32(cfg->threshold_exit);
384
385 return mc_send_command(mc_io, &cmd);
386}
387
388
389
390
391
392
393
394
395
396
397
398int dpseci_get_congestion_notification(struct fsl_mc_io *mc_io, u32 cmd_flags,
399 u16 token, struct dpseci_congestion_notification_cfg *cfg)
400{
401 struct fsl_mc_command cmd = { 0 };
402 struct dpseci_cmd_congestion_notification *rsp_params;
403 int err;
404
405 cmd.header = mc_encode_cmd_header(
406 DPSECI_CMDID_GET_CONGESTION_NOTIFICATION,
407 cmd_flags,
408 token);
409 err = mc_send_command(mc_io, &cmd);
410 if (err)
411 return err;
412
413 rsp_params = (struct dpseci_cmd_congestion_notification *)cmd.params;
414 cfg->dest_cfg.dest_id = le32_to_cpu(rsp_params->dest_id);
415 cfg->notification_mode = le16_to_cpu(rsp_params->notification_mode);
416 cfg->dest_cfg.priority = rsp_params->priority;
417 cfg->dest_cfg.dest_type = dpseci_get_field(rsp_params->options,
418 CGN_DEST_TYPE);
419 cfg->units = dpseci_get_field(rsp_params->options, CGN_UNITS);
420 cfg->message_iova = le64_to_cpu(rsp_params->message_iova);
421 cfg->message_ctx = le64_to_cpu(rsp_params->message_ctx);
422 cfg->threshold_entry = le32_to_cpu(rsp_params->threshold_entry);
423 cfg->threshold_exit = le32_to_cpu(rsp_params->threshold_exit);
424
425 return 0;
426}
427