crypto/cnxk: support lookaside IPsec AES-CTR
[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 <cryptodev_pmd.h>
6 #include <rte_malloc.h>
7 #include <rte_security.h>
8 #include <rte_security_driver.h>
9
10 #include "cnxk_cryptodev_capabilities.h"
11 #include "cnxk_cryptodev_sec.h"
12
13 /* Common security ops */
14 struct rte_security_ops cnxk_sec_ops = {
15         .session_create = NULL,
16         .session_destroy = NULL,
17         .session_get_size = NULL,
18         .session_stats_get = NULL,
19         .set_pkt_metadata = NULL,
20         .get_userdata = NULL,
21         .capabilities_get = cnxk_crypto_sec_capabilities_get
22 };
23
24 int
25 cnxk_crypto_sec_ctx_create(struct rte_cryptodev *cdev)
26 {
27         struct rte_security_ctx *ctx;
28
29         ctx = rte_malloc("cnxk_cpt_dev_sec_ctx",
30                          sizeof(struct rte_security_ctx), 0);
31
32         if (ctx == NULL)
33                 return -ENOMEM;
34
35         /* Populate ctx */
36         ctx->device = cdev;
37         ctx->ops = &cnxk_sec_ops;
38         ctx->sess_cnt = 0;
39
40         cdev->security_ctx = ctx;
41
42         return 0;
43 }
44
45 void
46 cnxk_crypto_sec_ctx_destroy(struct rte_cryptodev *cdev)
47 {
48         rte_free(cdev->security_ctx);
49 }