1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (C) 2020 Marvell International Ltd.
3 */
4
5 #ifndef _OTX2_EVDEV_CRYPTO_ADPTR_DP_H_
6 #define _OTX2_EVDEV_CRYPTO_ADPTR_DP_H_
7
8 #include <rte_cryptodev.h>
9 #include <rte_cryptodev_pmd.h>
10 #include <rte_eventdev.h>
11
12 #include "cpt_pmd_logs.h"
13 #include "cpt_ucode.h"
14
15 #include "otx2_cryptodev.h"
16 #include "otx2_cryptodev_hw_access.h"
17 #include "otx2_cryptodev_ops_helper.h"
18 #include "otx2_cryptodev_qp.h"
19
20 static inline void
otx2_ca_deq_post_process(const struct otx2_cpt_qp * qp,struct rte_crypto_op * cop,uintptr_t * rsp,uint8_t cc)21 otx2_ca_deq_post_process(const struct otx2_cpt_qp *qp,
22 struct rte_crypto_op *cop, uintptr_t *rsp,
23 uint8_t cc)
24 {
25 if (cop->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
26 if (likely(cc == NO_ERR)) {
27 /* Verify authentication data if required */
28 if (unlikely(rsp[2]))
29 compl_auth_verify(cop, (uint8_t *)rsp[2],
30 rsp[3]);
31 else
32 cop->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
33 } else {
34 if (cc == ERR_GC_ICV_MISCOMPARE)
35 cop->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
36 else
37 cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
38 }
39
40 if (unlikely(cop->sess_type == RTE_CRYPTO_OP_SESSIONLESS)) {
41 sym_session_clear(otx2_cryptodev_driver_id,
42 cop->sym->session);
43 memset(cop->sym->session, 0,
44 rte_cryptodev_sym_get_existing_header_session_size(
45 cop->sym->session));
46 rte_mempool_put(qp->sess_mp, cop->sym->session);
47 cop->sym->session = NULL;
48 }
49 }
50
51 }
52
53 static inline uint64_t
otx2_handle_crypto_event(uint64_t get_work1)54 otx2_handle_crypto_event(uint64_t get_work1)
55 {
56 struct cpt_request_info *req;
57 struct rte_crypto_op *cop;
58 uintptr_t *rsp;
59 void *metabuf;
60 uint8_t cc;
61
62 req = (struct cpt_request_info *)(get_work1);
63 cc = otx2_cpt_compcode_get(req);
64
65 rsp = req->op;
66 metabuf = (void *)rsp[0];
67 cop = (void *)rsp[1];
68
69 otx2_ca_deq_post_process(req->qp, cop, rsp, cc);
70
71 rte_mempool_put(req->qp->meta_info.pool, metabuf);
72
73 return (uint64_t)(cop);
74 }
75 #endif /* _OTX2_EVDEV_CRYPTO_ADPTR_DP_H_ */
76