1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (C) 2021 Marvell International Ltd.
5 #ifndef _OTX2_EVDEV_CRYPTO_ADPTR_TX_H_
6 #define _OTX2_EVDEV_CRYPTO_ADPTR_TX_H_
8 #include <rte_cryptodev.h>
9 #include <cryptodev_pmd.h>
10 #include <rte_event_crypto_adapter.h>
11 #include <rte_eventdev.h>
13 #include <otx2_cryptodev_qp.h>
14 #include <otx2_worker.h>
16 static inline uint16_t
17 otx2_ca_enq(uintptr_t tag_op, const struct rte_event *ev)
19 union rte_event_crypto_metadata *m_data;
20 struct rte_crypto_op *crypto_op;
21 struct rte_cryptodev *cdev;
22 struct otx2_cpt_qp *qp;
26 crypto_op = ev->event_ptr;
27 if (crypto_op == NULL)
30 if (crypto_op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
31 m_data = rte_cryptodev_sym_session_get_user_data(
32 crypto_op->sym->session);
36 cdev_id = m_data->request_info.cdev_id;
37 qp_id = m_data->request_info.queue_pair_id;
38 } else if (crypto_op->sess_type == RTE_CRYPTO_OP_SESSIONLESS &&
39 crypto_op->private_data_offset) {
40 m_data = (union rte_event_crypto_metadata *)
41 ((uint8_t *)crypto_op +
42 crypto_op->private_data_offset);
43 cdev_id = m_data->request_info.cdev_id;
44 qp_id = m_data->request_info.queue_pair_id;
49 cdev = &rte_cryptodevs[cdev_id];
50 qp = cdev->data->queue_pairs[qp_id];
53 otx2_ssogws_head_wait(tag_op);
55 return cdev->enqueue_burst(qp, &crypto_op, 1);
58 rte_pktmbuf_free(crypto_op->sym->m_src);
59 rte_crypto_op_free(crypto_op);
64 static uint16_t __rte_hot
65 otx2_ssogws_ca_enq(void *port, struct rte_event ev[], uint16_t nb_events)
67 struct otx2_ssogws *ws = port;
69 RTE_SET_USED(nb_events);
71 return otx2_ca_enq(ws->tag_op, ev);
74 static uint16_t __rte_hot
75 otx2_ssogws_dual_ca_enq(void *port, struct rte_event ev[], uint16_t nb_events)
77 struct otx2_ssogws_dual *ws = port;
79 RTE_SET_USED(nb_events);
81 return otx2_ca_enq(ws->ws_state[!ws->vws].tag_op, ev);
83 #endif /* _OTX2_EVDEV_CRYPTO_ADPTR_TX_H_ */