Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright 2017 NXP.
3 : : * Copyright(c) 2017 Intel Corporation.
4 : : * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
5 : : */
6 : :
7 : : #include <stdalign.h>
8 : : #include <ctype.h>
9 : : #include <stdlib.h>
10 : :
11 : : #include <rte_cryptodev.h>
12 : : #include <dev_driver.h>
13 : : #include <rte_telemetry.h>
14 : : #include "rte_security.h"
15 : : #include "rte_security_driver.h"
16 : :
17 : : /* Macro to check for invalid pointers */
18 : : #define RTE_PTR_OR_ERR_RET(ptr, retval) do { \
19 : : if ((ptr) == NULL) \
20 : : return retval; \
21 : : } while (0)
22 : :
23 : : /* Macro to check for invalid pointers chains */
24 : : #define RTE_PTR_CHAIN3_OR_ERR_RET(p1, p2, p3, retval, last_retval) do { \
25 : : RTE_PTR_OR_ERR_RET(p1, retval); \
26 : : RTE_PTR_OR_ERR_RET(p1->p2, retval); \
27 : : RTE_PTR_OR_ERR_RET(p1->p2->p3, last_retval); \
28 : : } while (0)
29 : :
30 : : #define RTE_SECURITY_DYNFIELD_NAME "rte_security_dynfield_metadata"
31 : : #define RTE_SECURITY_OOP_DYNFIELD_NAME "rte_security_oop_dynfield_metadata"
32 : :
33 : : int rte_security_dynfield_offset = -1;
34 : : int rte_security_oop_dynfield_offset = -1;
35 : :
36 : : int
37 : 0 : rte_security_dynfield_register(void)
38 : : {
39 : : static const struct rte_mbuf_dynfield dynfield_desc = {
40 : : .name = RTE_SECURITY_DYNFIELD_NAME,
41 : : .size = sizeof(rte_security_dynfield_t),
42 : : .align = alignof(rte_security_dynfield_t),
43 : : };
44 : 0 : rte_security_dynfield_offset =
45 : 0 : rte_mbuf_dynfield_register(&dynfield_desc);
46 : 0 : return rte_security_dynfield_offset;
47 : : }
48 : :
49 : : int
50 : 0 : rte_security_oop_dynfield_register(void)
51 : : {
52 : : static const struct rte_mbuf_dynfield dynfield_desc = {
53 : : .name = RTE_SECURITY_OOP_DYNFIELD_NAME,
54 : : .size = sizeof(rte_security_oop_dynfield_t),
55 : : .align = alignof(rte_security_oop_dynfield_t),
56 : : };
57 : :
58 : 0 : rte_security_oop_dynfield_offset =
59 : 0 : rte_mbuf_dynfield_register(&dynfield_desc);
60 : 0 : return rte_security_oop_dynfield_offset;
61 : : }
62 : :
63 : : void *
64 : 59 : rte_security_session_create(void *ctx,
65 : : struct rte_security_session_conf *conf,
66 : : struct rte_mempool *mp)
67 : : {
68 : 59 : struct rte_security_session *sess = NULL;
69 : : struct rte_security_ctx *instance = ctx;
70 : : uint32_t sess_priv_size;
71 : :
72 [ + + + + : 59 : RTE_PTR_CHAIN3_OR_ERR_RET(instance, ops, session_create, NULL, NULL);
+ + ]
73 [ + + ]: 56 : RTE_PTR_OR_ERR_RET(conf, NULL);
74 [ + + ]: 55 : RTE_PTR_OR_ERR_RET(mp, NULL);
75 : :
76 : 54 : sess_priv_size = instance->ops->session_get_size(instance->device);
77 [ + - ]: 54 : if (mp->elt_size < (sizeof(struct rte_security_session) + sess_priv_size))
78 : : return NULL;
79 : :
80 [ + + ]: 54 : if (rte_mempool_get(mp, (void **)&sess))
81 : : return NULL;
82 : :
83 : : /* Clear session priv data */
84 : 53 : memset(sess->driver_priv_data, 0, sess_priv_size);
85 : :
86 : 53 : sess->driver_priv_data_iova = rte_mempool_virt2iova(sess) +
87 : : offsetof(struct rte_security_session, driver_priv_data);
88 [ + + ]: 53 : if (instance->ops->session_create(instance->device, conf, sess)) {
89 [ - + ]: 1 : rte_mempool_put(mp, (void *)sess);
90 : 1 : return NULL;
91 : : }
92 : 52 : instance->sess_cnt++;
93 : :
94 : 52 : return (void *)sess;
95 : : }
96 : :
97 : : int
98 : 7 : rte_security_session_update(void *ctx, void *sess, struct rte_security_session_conf *conf)
99 : : {
100 : : struct rte_security_ctx *instance = ctx;
101 : :
102 [ + + + + : 7 : RTE_PTR_CHAIN3_OR_ERR_RET(instance, ops, session_update, -EINVAL,
+ + ]
103 : : -ENOTSUP);
104 [ + + ]: 4 : RTE_PTR_OR_ERR_RET(sess, -EINVAL);
105 [ + + ]: 3 : RTE_PTR_OR_ERR_RET(conf, -EINVAL);
106 : :
107 : 2 : return instance->ops->session_update(instance->device, sess, conf);
108 : : }
109 : :
110 : : unsigned int
111 : 6 : rte_security_session_get_size(void *ctx)
112 : : {
113 : : struct rte_security_ctx *instance = ctx;
114 : :
115 [ + + + + : 6 : RTE_PTR_CHAIN3_OR_ERR_RET(instance, ops, session_get_size, 0, 0);
+ + ]
116 : :
117 : 2 : return (sizeof(struct rte_security_session) +
118 : 2 : instance->ops->session_get_size(instance->device));
119 : : }
120 : :
121 : : int
122 : 6 : rte_security_session_stats_get(void *ctx, void *sess, struct rte_security_stats *stats)
123 : : {
124 : : struct rte_security_ctx *instance = ctx;
125 : :
126 [ + + + + : 6 : RTE_PTR_CHAIN3_OR_ERR_RET(instance, ops, session_stats_get, -EINVAL,
+ + ]
127 : : -ENOTSUP);
128 : : /* Parameter sess can be NULL in case of getting global statistics. */
129 [ + + ]: 3 : RTE_PTR_OR_ERR_RET(stats, -EINVAL);
130 : :
131 : 2 : return instance->ops->session_stats_get(instance->device, sess, stats);
132 : : }
133 : :
134 : : int
135 : 57 : rte_security_session_destroy(void *ctx, void *sess)
136 : : {
137 : : struct rte_security_ctx *instance = ctx;
138 : : int ret;
139 : :
140 [ + + + + : 57 : RTE_PTR_CHAIN3_OR_ERR_RET(instance, ops, session_destroy, -EINVAL,
+ + ]
141 : : -ENOTSUP);
142 [ + + ]: 54 : RTE_PTR_OR_ERR_RET(sess, -EINVAL);
143 : :
144 : 53 : ret = instance->ops->session_destroy(instance->device, sess);
145 [ + + ]: 53 : if (ret != 0)
146 : : return ret;
147 : :
148 : 52 : rte_mempool_put(rte_mempool_from_obj(sess), (void *)sess);
149 : :
150 [ + - ]: 52 : if (instance->sess_cnt)
151 : 52 : instance->sess_cnt--;
152 : :
153 : : return 0;
154 : : }
155 : :
156 : : int
157 : 0 : rte_security_macsec_sc_create(void *ctx, struct rte_security_macsec_sc *conf)
158 : : {
159 : : struct rte_security_ctx *instance = ctx;
160 : : int sc_id;
161 : :
162 [ # # # # : 0 : RTE_PTR_CHAIN3_OR_ERR_RET(instance, ops, macsec_sc_create, -EINVAL, -ENOTSUP);
# # ]
163 [ # # ]: 0 : RTE_PTR_OR_ERR_RET(conf, -EINVAL);
164 : :
165 : 0 : sc_id = instance->ops->macsec_sc_create(instance->device, conf);
166 [ # # ]: 0 : if (sc_id >= 0)
167 : 0 : instance->macsec_sc_cnt++;
168 : :
169 : : return sc_id;
170 : : }
171 : :
172 : : int
173 : 0 : rte_security_macsec_sa_create(void *ctx, struct rte_security_macsec_sa *conf)
174 : : {
175 : : struct rte_security_ctx *instance = ctx;
176 : : int sa_id;
177 : :
178 [ # # # # : 0 : RTE_PTR_CHAIN3_OR_ERR_RET(instance, ops, macsec_sa_create, -EINVAL, -ENOTSUP);
# # ]
179 [ # # ]: 0 : RTE_PTR_OR_ERR_RET(conf, -EINVAL);
180 : :
181 : 0 : sa_id = instance->ops->macsec_sa_create(instance->device, conf);
182 [ # # ]: 0 : if (sa_id >= 0)
183 : 0 : instance->macsec_sa_cnt++;
184 : :
185 : : return sa_id;
186 : : }
187 : :
188 : : int
189 : 0 : rte_security_macsec_sc_destroy(void *ctx, uint16_t sc_id,
190 : : enum rte_security_macsec_direction dir)
191 : : {
192 : : struct rte_security_ctx *instance = ctx;
193 : : int ret;
194 : :
195 [ # # # # : 0 : RTE_PTR_CHAIN3_OR_ERR_RET(instance, ops, macsec_sc_destroy, -EINVAL, -ENOTSUP);
# # ]
196 : :
197 : 0 : ret = instance->ops->macsec_sc_destroy(instance->device, sc_id, dir);
198 [ # # ]: 0 : if (ret != 0)
199 : : return ret;
200 : :
201 [ # # ]: 0 : if (instance->macsec_sc_cnt)
202 : 0 : instance->macsec_sc_cnt--;
203 : :
204 : : return 0;
205 : : }
206 : :
207 : : int
208 : 0 : rte_security_macsec_sa_destroy(void *ctx, uint16_t sa_id,
209 : : enum rte_security_macsec_direction dir)
210 : : {
211 : : struct rte_security_ctx *instance = ctx;
212 : : int ret;
213 : :
214 [ # # # # : 0 : RTE_PTR_CHAIN3_OR_ERR_RET(instance, ops, macsec_sa_destroy, -EINVAL, -ENOTSUP);
# # ]
215 : :
216 : 0 : ret = instance->ops->macsec_sa_destroy(instance->device, sa_id, dir);
217 [ # # ]: 0 : if (ret != 0)
218 : : return ret;
219 : :
220 [ # # ]: 0 : if (instance->macsec_sa_cnt)
221 : 0 : instance->macsec_sa_cnt--;
222 : :
223 : : return 0;
224 : : }
225 : :
226 : : int
227 : 0 : rte_security_macsec_sc_stats_get(void *ctx, uint16_t sc_id,
228 : : enum rte_security_macsec_direction dir,
229 : : struct rte_security_macsec_sc_stats *stats)
230 : : {
231 : : struct rte_security_ctx *instance = ctx;
232 : :
233 [ # # # # : 0 : RTE_PTR_CHAIN3_OR_ERR_RET(instance, ops, macsec_sc_stats_get, -EINVAL, -ENOTSUP);
# # ]
234 [ # # ]: 0 : RTE_PTR_OR_ERR_RET(stats, -EINVAL);
235 : :
236 : 0 : return instance->ops->macsec_sc_stats_get(instance->device, sc_id, dir, stats);
237 : : }
238 : :
239 : : int
240 : 0 : rte_security_macsec_sa_stats_get(void *ctx, uint16_t sa_id,
241 : : enum rte_security_macsec_direction dir,
242 : : struct rte_security_macsec_sa_stats *stats)
243 : : {
244 : : struct rte_security_ctx *instance = ctx;
245 : :
246 [ # # # # : 0 : RTE_PTR_CHAIN3_OR_ERR_RET(instance, ops, macsec_sa_stats_get, -EINVAL, -ENOTSUP);
# # ]
247 [ # # ]: 0 : RTE_PTR_OR_ERR_RET(stats, -EINVAL);
248 : :
249 : 0 : return instance->ops->macsec_sa_stats_get(instance->device, sa_id, dir, stats);
250 : : }
251 : :
252 : : int
253 : 3 : __rte_security_set_pkt_metadata(void *ctx, void *sess, struct rte_mbuf *m, void *params)
254 : : {
255 : : struct rte_security_ctx *instance = ctx;
256 : : #ifdef RTE_DEBUG
257 : : RTE_PTR_OR_ERR_RET(sess, -EINVAL);
258 : : RTE_PTR_OR_ERR_RET(instance, -EINVAL);
259 : : RTE_PTR_OR_ERR_RET(instance->ops, -EINVAL);
260 : : #endif
261 [ + + ]: 3 : if (instance->ops->set_pkt_metadata == NULL)
262 : : return -ENOTSUP;
263 : 2 : return instance->ops->set_pkt_metadata(instance->device, sess, m, params);
264 : : }
265 : :
266 : : const struct rte_security_capability *
267 : 5 : rte_security_capabilities_get(void *ctx)
268 : : {
269 : : struct rte_security_ctx *instance = ctx;
270 : :
271 [ + + + + : 5 : RTE_PTR_CHAIN3_OR_ERR_RET(instance, ops, capabilities_get, NULL, NULL);
+ + ]
272 : :
273 : 2 : return instance->ops->capabilities_get(instance->device);
274 : : }
275 : :
276 : : const struct rte_security_capability *
277 : 16 : rte_security_capability_get(void *ctx, struct rte_security_capability_idx *idx)
278 : : {
279 : : const struct rte_security_capability *capabilities;
280 : : const struct rte_security_capability *capability;
281 : : struct rte_security_ctx *instance = ctx;
282 : : uint16_t i = 0;
283 : :
284 [ + + + + : 16 : RTE_PTR_CHAIN3_OR_ERR_RET(instance, ops, capabilities_get, NULL, NULL);
+ + ]
285 [ + + ]: 13 : RTE_PTR_OR_ERR_RET(idx, NULL);
286 : :
287 : 12 : capabilities = instance->ops->capabilities_get(instance->device);
288 : :
289 [ + + ]: 12 : if (capabilities == NULL)
290 : : return NULL;
291 : :
292 : 23 : while ((capability = &capabilities[i++])->action
293 [ + + ]: 23 : != RTE_SECURITY_ACTION_TYPE_NONE) {
294 [ + + ]: 15 : if (capability->action == idx->action &&
295 [ + + ]: 10 : capability->protocol == idx->protocol) {
296 : : if (idx->protocol == RTE_SECURITY_PROTOCOL_IPSEC) {
297 : 4 : if (capability->ipsec.proto ==
298 [ + + ]: 4 : idx->ipsec.proto &&
299 : 3 : capability->ipsec.mode ==
300 [ + + ]: 3 : idx->ipsec.mode &&
301 : 2 : capability->ipsec.direction ==
302 [ + + ]: 2 : idx->ipsec.direction)
303 : 1 : return capability;
304 : : } else if (idx->protocol == RTE_SECURITY_PROTOCOL_PDCP) {
305 : 2 : if (capability->pdcp.domain ==
306 [ + + ]: 2 : idx->pdcp.domain)
307 : 1 : return capability;
308 : : } else if (idx->protocol ==
309 : : RTE_SECURITY_PROTOCOL_DOCSIS) {
310 : 2 : if (capability->docsis.direction ==
311 [ + + ]: 2 : idx->docsis.direction)
312 : 1 : return capability;
313 : : } else if (idx->protocol ==
314 : : RTE_SECURITY_PROTOCOL_MACSEC) {
315 [ # # ]: 0 : if (idx->macsec.alg == capability->macsec.alg)
316 : 0 : return capability;
317 : : } else if (idx->protocol == RTE_SECURITY_PROTOCOL_TLS_RECORD) {
318 [ # # ]: 0 : if (capability->tls_record.ver == idx->tls_record.ver &&
319 [ # # ]: 0 : capability->tls_record.type == idx->tls_record.type)
320 : 0 : return capability;
321 : : }
322 : : }
323 : : }
324 : :
325 : : return NULL;
326 : : }
327 : :
328 : : int
329 : 0 : rte_security_rx_inject_configure(void *ctx, uint16_t port_id, bool enable)
330 : : {
331 : : struct rte_security_ctx *instance = ctx;
332 : :
333 [ # # ]: 0 : RTE_PTR_OR_ERR_RET(instance, -EINVAL);
334 [ # # ]: 0 : RTE_PTR_OR_ERR_RET(instance->ops, -ENOTSUP);
335 [ # # ]: 0 : RTE_PTR_OR_ERR_RET(instance->ops->rx_inject_configure, -ENOTSUP);
336 : :
337 : 0 : return instance->ops->rx_inject_configure(instance->device, port_id, enable);
338 : : }
339 : :
340 : : uint16_t
341 : 0 : rte_security_inb_pkt_rx_inject(void *ctx, struct rte_mbuf **pkts, void **sess,
342 : : uint16_t nb_pkts)
343 : : {
344 : : struct rte_security_ctx *instance = ctx;
345 : :
346 : 0 : return instance->ops->inb_pkt_rx_inject(instance->device, pkts,
347 : : (struct rte_security_session **)sess, nb_pkts);
348 : : }
349 : :
350 : : static int
351 : 0 : security_handle_cryptodev_list(const char *cmd __rte_unused,
352 : : const char *params __rte_unused,
353 : : struct rte_tel_data *d)
354 : : {
355 : : int dev_id;
356 : :
357 [ # # ]: 0 : if (rte_cryptodev_count() < 1)
358 : : return -1;
359 : :
360 : 0 : rte_tel_data_start_array(d, RTE_TEL_INT_VAL);
361 [ # # ]: 0 : for (dev_id = 0; dev_id < RTE_CRYPTO_MAX_DEVS; dev_id++)
362 [ # # # # ]: 0 : if (rte_cryptodev_is_valid_dev(dev_id) &&
363 : 0 : rte_cryptodev_get_sec_ctx(dev_id))
364 : 0 : rte_tel_data_add_array_int(d, dev_id);
365 : :
366 : : return 0;
367 : : }
368 : :
369 : : #define CRYPTO_CAPS_SZ \
370 : : (RTE_ALIGN_CEIL(sizeof(struct rte_cryptodev_capabilities), \
371 : : sizeof(uint64_t)) / sizeof(uint64_t))
372 : :
373 : : static int
374 : 0 : crypto_caps_array(struct rte_tel_data *d,
375 : : const struct rte_cryptodev_capabilities *capabilities)
376 : : {
377 : : const struct rte_cryptodev_capabilities *dev_caps;
378 : : uint64_t caps_val[CRYPTO_CAPS_SZ];
379 : : unsigned int i = 0, j;
380 : :
381 : 0 : rte_tel_data_start_array(d, RTE_TEL_UINT_VAL);
382 : :
383 [ # # ]: 0 : while ((dev_caps = &capabilities[i++])->op !=
384 : : RTE_CRYPTO_OP_TYPE_UNDEFINED) {
385 : : memset(&caps_val, 0, CRYPTO_CAPS_SZ * sizeof(caps_val[0]));
386 : : rte_memcpy(caps_val, dev_caps, sizeof(capabilities[0]));
387 [ # # ]: 0 : for (j = 0; j < CRYPTO_CAPS_SZ; j++)
388 : 0 : rte_tel_data_add_array_uint(d, caps_val[j]);
389 : : }
390 : :
391 : 0 : return (i - 1);
392 : : }
393 : :
394 : : #define SEC_CAPS_SZ \
395 : : (RTE_ALIGN_CEIL(sizeof(struct rte_security_capability), \
396 : : sizeof(uint64_t)) / sizeof(uint64_t))
397 : :
398 : : static int
399 : 0 : sec_caps_array(struct rte_tel_data *d,
400 : : const struct rte_security_capability *capabilities)
401 : : {
402 : : const struct rte_security_capability *dev_caps;
403 : : uint64_t caps_val[SEC_CAPS_SZ];
404 : : unsigned int i = 0, j;
405 : :
406 : 0 : rte_tel_data_start_array(d, RTE_TEL_UINT_VAL);
407 : :
408 [ # # ]: 0 : while ((dev_caps = &capabilities[i++])->action !=
409 : : RTE_SECURITY_ACTION_TYPE_NONE) {
410 : : memset(&caps_val, 0, SEC_CAPS_SZ * sizeof(caps_val[0]));
411 : : rte_memcpy(caps_val, dev_caps, sizeof(capabilities[0]));
412 [ # # ]: 0 : for (j = 0; j < SEC_CAPS_SZ; j++)
413 : 0 : rte_tel_data_add_array_uint(d, caps_val[j]);
414 : : }
415 : :
416 : 0 : return i - 1;
417 : : }
418 : :
419 : : static const struct rte_security_capability *
420 : : security_capability_by_index(const struct rte_security_capability *capabilities,
421 : : int index)
422 : : {
423 : : const struct rte_security_capability *dev_caps = NULL;
424 : : int i = 0;
425 : :
426 [ # # ]: 0 : while ((dev_caps = &capabilities[i])->action !=
427 : : RTE_SECURITY_ACTION_TYPE_NONE) {
428 [ # # ]: 0 : if (i == index)
429 : : return dev_caps;
430 : :
431 : 0 : ++i;
432 : : }
433 : :
434 : : return NULL;
435 : : }
436 : :
437 : : static int
438 : 0 : security_capabilities_from_dev_id(int dev_id, const void **caps)
439 : : {
440 : : const struct rte_security_capability *capabilities;
441 : : void *sec_ctx;
442 : :
443 [ # # ]: 0 : if (rte_cryptodev_is_valid_dev(dev_id) == 0)
444 : : return -EINVAL;
445 : :
446 : 0 : sec_ctx = rte_cryptodev_get_sec_ctx(dev_id);
447 [ # # ]: 0 : RTE_PTR_OR_ERR_RET(sec_ctx, -EINVAL);
448 : :
449 : 0 : capabilities = rte_security_capabilities_get(sec_ctx);
450 [ # # ]: 0 : RTE_PTR_OR_ERR_RET(capabilities, -EINVAL);
451 : :
452 : 0 : *caps = capabilities;
453 : 0 : return 0;
454 : : }
455 : :
456 : : static int
457 : 0 : security_handle_cryptodev_sec_caps(const char *cmd __rte_unused, const char *params,
458 : : struct rte_tel_data *d)
459 : : {
460 : : const struct rte_security_capability *capabilities;
461 : : struct rte_tel_data *sec_caps;
462 : : char *end_param;
463 : : int sec_caps_n;
464 : : int dev_id;
465 : : int rc;
466 : :
467 [ # # # # : 0 : if (!params || strlen(params) == 0 || !isdigit(*params))
# # ]
468 : : return -EINVAL;
469 : :
470 : 0 : dev_id = strtoul(params, &end_param, 0);
471 [ # # ]: 0 : if (*end_param != '\0')
472 : 0 : CDEV_LOG_ERR("Extra parameters passed to command, ignoring");
473 : :
474 : 0 : rc = security_capabilities_from_dev_id(dev_id, (void *)&capabilities);
475 [ # # ]: 0 : if (rc < 0)
476 : : return rc;
477 : :
478 : 0 : sec_caps = rte_tel_data_alloc();
479 [ # # ]: 0 : RTE_PTR_OR_ERR_RET(sec_caps, -ENOMEM);
480 : :
481 : 0 : rte_tel_data_start_dict(d);
482 : 0 : sec_caps_n = sec_caps_array(sec_caps, capabilities);
483 : 0 : rte_tel_data_add_dict_container(d, "sec_caps", sec_caps, 0);
484 : 0 : rte_tel_data_add_dict_int(d, "sec_caps_n", sec_caps_n);
485 : :
486 : 0 : return 0;
487 : : }
488 : :
489 : : static int
490 : 0 : security_handle_cryptodev_crypto_caps(const char *cmd __rte_unused, const char *params,
491 : : struct rte_tel_data *d)
492 : : {
493 : : const struct rte_security_capability *capabilities;
494 : : struct rte_tel_data *crypto_caps;
495 : : const char *capa_param;
496 : : int dev_id, capa_id;
497 : : int crypto_caps_n;
498 : : char *end_param;
499 : : int rc;
500 : :
501 [ # # # # : 0 : if (!params || strlen(params) == 0 || !isdigit(*params))
# # ]
502 : : return -EINVAL;
503 : :
504 : 0 : dev_id = strtoul(params, &end_param, 0);
505 : 0 : capa_param = strtok(end_param, ",");
506 [ # # # # : 0 : if (!capa_param || strlen(capa_param) == 0 || !isdigit(*capa_param))
# # ]
507 : : return -EINVAL;
508 : :
509 : 0 : capa_id = strtoul(capa_param, &end_param, 0);
510 [ # # ]: 0 : if (*end_param != '\0')
511 : 0 : CDEV_LOG_ERR("Extra parameters passed to command, ignoring");
512 : :
513 : 0 : rc = security_capabilities_from_dev_id(dev_id, (void *)&capabilities);
514 [ # # ]: 0 : if (rc < 0)
515 : : return rc;
516 : :
517 : 0 : capabilities = security_capability_by_index(capabilities, capa_id);
518 [ # # ]: 0 : RTE_PTR_OR_ERR_RET(capabilities, -EINVAL);
519 : :
520 : 0 : crypto_caps = rte_tel_data_alloc();
521 [ # # ]: 0 : RTE_PTR_OR_ERR_RET(crypto_caps, -ENOMEM);
522 : :
523 : 0 : rte_tel_data_start_dict(d);
524 : 0 : crypto_caps_n = crypto_caps_array(crypto_caps, capabilities->crypto_capabilities);
525 : :
526 : 0 : rte_tel_data_add_dict_container(d, "crypto_caps", crypto_caps, 0);
527 : 0 : rte_tel_data_add_dict_int(d, "crypto_caps_n", crypto_caps_n);
528 : :
529 : 0 : return 0;
530 : : }
531 : :
532 : 252 : RTE_INIT(security_init_telemetry)
533 : : {
534 : 252 : rte_telemetry_register_cmd("/security/cryptodev/list",
535 : : security_handle_cryptodev_list,
536 : : "Returns list of available crypto devices by IDs. No parameters.");
537 : :
538 : 252 : rte_telemetry_register_cmd("/security/cryptodev/sec_caps",
539 : : security_handle_cryptodev_sec_caps,
540 : : "Returns security capabilities for a cryptodev. Parameters: int dev_id");
541 : :
542 : 252 : rte_telemetry_register_cmd("/security/cryptodev/crypto_caps",
543 : : security_handle_cryptodev_crypto_caps,
544 : : "Returns crypto capabilities for a security capability. Parameters: int dev_id, sec_cap_id");
545 : 252 : }
|