crypto/cnxk: add security context skeleton
[dpdk.git] / drivers / crypto / cnxk / cnxk_cryptodev_sec.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(C) 2021 Marvell.
3  */
4
5 #include <rte_cryptodev.h>
6 #include <rte_malloc.h>
7 #include <rte_security.h>
8 #include <rte_security_driver.h>
9
10 #include "cnxk_cryptodev_sec.h"
11
12 /* Common security ops */
13 struct rte_security_ops cnxk_sec_ops = {
14         .session_create = NULL,
15         .session_destroy = NULL,
16         .session_get_size = NULL,
17         .set_pkt_metadata = NULL,
18         .get_userdata = NULL,
19         .capabilities_get = NULL,
20 };
21
22 int
23 cnxk_crypto_sec_ctx_create(struct rte_cryptodev *cdev)
24 {
25         struct rte_security_ctx *ctx;
26
27         ctx = rte_malloc("cnxk_cpt_dev_sec_ctx",
28                          sizeof(struct rte_security_ctx), 0);
29
30         if (ctx == NULL)
31                 return -ENOMEM;
32
33         /* Populate ctx */
34         ctx->device = cdev;
35         ctx->ops = &cnxk_sec_ops;
36         ctx->sess_cnt = 0;
37
38         cdev->security_ctx = ctx;
39
40         return 0;
41 }
42
43 void
44 cnxk_crypto_sec_ctx_destroy(struct rte_cryptodev *cdev)
45 {
46         rte_free(cdev->security_ctx);
47 }