net/octeontx2: create security context
[dpdk.git] / drivers / net / octeontx2 / otx2_ethdev_sec.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (C) 2020 Marvell International Ltd.
3  */
4
5 #include <rte_ethdev.h>
6 #include <rte_malloc.h>
7 #include <rte_security.h>
8
9 #include "otx2_ethdev_sec.h"
10
11 int
12 otx2_eth_sec_ctx_create(struct rte_eth_dev *eth_dev)
13 {
14         struct rte_security_ctx *ctx;
15
16         ctx = rte_malloc("otx2_eth_sec_ctx",
17                          sizeof(struct rte_security_ctx), 0);
18         if (ctx == NULL)
19                 return -ENOMEM;
20
21         /* Populate ctx */
22
23         ctx->device = eth_dev;
24         ctx->sess_cnt = 0;
25
26         eth_dev->security_ctx = ctx;
27
28         return 0;
29 }
30
31 void
32 otx2_eth_sec_ctx_destroy(struct rte_eth_dev *eth_dev)
33 {
34         rte_free(eth_dev->security_ctx);
35 }