906a87b9e5b1b57adee0d820cbaaf528e92fabf6
[dpdk.git] / drivers / crypto / octeontx2 / otx2_cryptodev_sec.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (C) 2020 Marvell International Ltd.
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 "otx2_cryptodev.h"
11 #include "otx2_cryptodev_capabilities.h"
12 #include "otx2_cryptodev_sec.h"
13
14 static struct rte_security_ops otx2_crypto_sec_ops = {
15         .session_create         = NULL,
16         .session_destroy        = NULL,
17         .session_get_size       = NULL,
18         .set_pkt_metadata       = NULL,
19         .get_userdata           = NULL,
20         .capabilities_get       = otx2_crypto_sec_capabilities_get
21 };
22
23 int
24 otx2_crypto_sec_ctx_create(struct rte_cryptodev *cdev)
25 {
26         struct rte_security_ctx *ctx;
27
28         ctx = rte_malloc("otx2_cpt_dev_sec_ctx",
29                          sizeof(struct rte_security_ctx), 0);
30
31         if (ctx == NULL)
32                 return -ENOMEM;
33
34         /* Populate ctx */
35         ctx->device = cdev;
36         ctx->ops = &otx2_crypto_sec_ops;
37         ctx->sess_cnt = 0;
38
39         cdev->security_ctx = ctx;
40
41         return 0;
42 }
43
44 void
45 otx2_crypto_sec_ctx_destroy(struct rte_cryptodev *cdev)
46 {
47         rte_free(cdev->security_ctx);
48 }