d937e6f37a0c0c16c4f92bb4ec540126ae60373a
[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_sec.h"
11
12 static struct rte_security_ops otx2_crypto_sec_ops = {
13         .session_create         = NULL,
14         .session_destroy        = NULL,
15         .session_get_size       = NULL,
16         .set_pkt_metadata       = NULL,
17         .get_userdata           = NULL,
18         .capabilities_get       = NULL
19 };
20
21 int
22 otx2_crypto_sec_ctx_create(struct rte_cryptodev *cdev)
23 {
24         struct rte_security_ctx *ctx;
25
26         ctx = rte_malloc("otx2_cpt_dev_sec_ctx",
27                          sizeof(struct rte_security_ctx), 0);
28
29         if (ctx == NULL)
30                 return -ENOMEM;
31
32         /* Populate ctx */
33         ctx->device = cdev;
34         ctx->ops = &otx2_crypto_sec_ops;
35         ctx->sess_cnt = 0;
36
37         cdev->security_ctx = ctx;
38
39         return 0;
40 }
41
42 void
43 otx2_crypto_sec_ctx_destroy(struct rte_cryptodev *cdev)
44 {
45         rte_free(cdev->security_ctx);
46 }