1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (C) 2020-2021 Marvell.
5 #include <rte_cryptodev.h>
6 #include <rte_eventdev.h>
8 #include "otx2_cryptodev.h"
9 #include "otx2_cryptodev_hw_access.h"
10 #include "otx2_cryptodev_qp.h"
11 #include "otx2_cryptodev_mbox.h"
12 #include "otx2_evdev.h"
15 otx2_ca_caps_get(const struct rte_eventdev *dev,
16 const struct rte_cryptodev *cdev, uint32_t *caps)
21 *caps = RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND |
22 RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW |
23 RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD;
29 otx2_ca_qp_sso_link(const struct rte_cryptodev *cdev, struct otx2_cpt_qp *qp,
32 union otx2_cpt_af_lf_ctl2 af_lf_ctl2;
35 ret = otx2_cpt_af_reg_read(cdev, OTX2_CPT_AF_LF_CTL2(qp->id),
36 qp->blkaddr, &af_lf_ctl2.u);
40 af_lf_ctl2.s.sso_pf_func = sso_pf_func;
41 ret = otx2_cpt_af_reg_write(cdev, OTX2_CPT_AF_LF_CTL2(qp->id),
42 qp->blkaddr, af_lf_ctl2.u);
47 otx2_ca_qp_init(struct otx2_cpt_qp *qp, const struct rte_event *event)
51 rte_memcpy(&qp->ev, event, sizeof(struct rte_event));
59 otx2_ca_qp_add(const struct rte_eventdev *dev, const struct rte_cryptodev *cdev,
60 int32_t queue_pair_id, const struct rte_event *event)
62 struct otx2_sso_evdev *sso_evdev = sso_pmd_priv(dev);
63 struct otx2_cpt_vf *vf = cdev->data->dev_private;
64 uint16_t sso_pf_func = otx2_sso_pf_func_get();
65 struct otx2_cpt_qp *qp;
69 if (queue_pair_id == -1) {
70 for (qp_id = 0; qp_id < vf->nb_queues; qp_id++) {
71 qp = cdev->data->queue_pairs[qp_id];
72 ret = otx2_ca_qp_sso_link(cdev, qp, sso_pf_func);
75 for (qp_tmp = 0; qp_tmp < qp_id; qp_tmp++)
76 otx2_ca_qp_del(dev, cdev, qp_tmp);
79 otx2_ca_qp_init(qp, event);
82 qp = cdev->data->queue_pairs[queue_pair_id];
83 ret = otx2_ca_qp_sso_link(cdev, qp, sso_pf_func);
86 otx2_ca_qp_init(qp, event);
89 sso_evdev->rx_offloads |= NIX_RX_OFFLOAD_SECURITY_F;
90 sso_fastpath_fns_set((struct rte_eventdev *)(uintptr_t)dev);
92 /* Update crypto adapter xae count */
93 if (queue_pair_id == -1)
94 sso_evdev->adptr_xae_cnt +=
95 vf->nb_queues * OTX2_CPT_DEFAULT_CMD_QLEN;
97 sso_evdev->adptr_xae_cnt += OTX2_CPT_DEFAULT_CMD_QLEN;
98 sso_xae_reconfigure((struct rte_eventdev *)(uintptr_t)dev);
104 otx2_ca_qp_del(const struct rte_eventdev *dev, const struct rte_cryptodev *cdev,
105 int32_t queue_pair_id)
107 struct otx2_cpt_vf *vf = cdev->data->dev_private;
108 struct otx2_cpt_qp *qp;
115 if (queue_pair_id == -1) {
116 for (qp_id = 0; qp_id < vf->nb_queues; qp_id++) {
117 qp = cdev->data->queue_pairs[qp_id];
118 ret = otx2_ca_qp_sso_link(cdev, qp, 0);
124 qp = cdev->data->queue_pairs[queue_pair_id];
125 ret = otx2_ca_qp_sso_link(cdev, qp, 0);