]> git.droids-corp.org - dpdk.git/commitdiff
event/octeontx2: add crypto adapter datapath
authorAnkur Dwivedi <adwivedi@marvell.com>
Thu, 8 Oct 2020 10:34:35 +0000 (16:04 +0530)
committerJerin Jacob <jerinj@marvell.com>
Thu, 15 Oct 2020 20:27:49 +0000 (22:27 +0200)
In the op new mode of crypto adapter, the completed crypto operation
is submitted to the event device by the OCTEON TX2 crypto PMD.
During event device dequeue the result of crypto operation is checked.

Signed-off-by: Ankur Dwivedi <adwivedi@marvell.com>
Acked-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
drivers/common/cpt/cpt_common.h
drivers/crypto/octeontx2/otx2_cryptodev_ops.c
drivers/crypto/octeontx2/rte_pmd_octeontx2_crypto_version.map
drivers/event/octeontx2/otx2_evdev_crypto_adptr_dp.h [new file with mode: 0644]
drivers/event/octeontx2/otx2_worker.h
drivers/event/octeontx2/otx2_worker_dual.h

index 0141b2aed5f2698362ccc8368a100af4f6440ada..1ce28e90b78084e19b08183294f0b86c582bc6cf 100644 (file)
@@ -72,6 +72,7 @@ struct cpt_request_info {
                uint64_t ei3;
        } ist;
        uint8_t *rptr;
+       const struct otx2_cpt_qp *qp;
 
        /** Control path fields */
        uint64_t time_out;
index fa958943113de02ae4aa63b6044465037bff48f6..790af02dc66b73bed77f2dd4e3cc25a0034f9a05 100644 (file)
@@ -425,6 +425,48 @@ priv_put:
        return -ENOTSUP;
 }
 
+static __rte_always_inline void __rte_hot
+otx2_ca_enqueue_req(const struct otx2_cpt_qp *qp,
+                   struct cpt_request_info *req,
+                   void *lmtline)
+{
+       union cpt_inst_s inst;
+       uint64_t lmt_status;
+
+       inst.u[0] = 0;
+       inst.s9x.res_addr = req->comp_baddr;
+       inst.u[2] = 0;
+       inst.u[3] = 0;
+
+       inst.s9x.ei0 = req->ist.ei0;
+       inst.s9x.ei1 = req->ist.ei1;
+       inst.s9x.ei2 = req->ist.ei2;
+       inst.s9x.ei3 = req->ist.ei3;
+
+       inst.s9x.qord = 1;
+       inst.s9x.grp = qp->ev.queue_id;
+       inst.s9x.tt = qp->ev.sched_type;
+       inst.s9x.tag = (RTE_EVENT_TYPE_CRYPTODEV << 28) |
+                       qp->ev.flow_id;
+       inst.s9x.wq_ptr = (uint64_t)req >> 3;
+       req->qp = qp;
+
+       do {
+               /* Copy CPT command to LMTLINE */
+               memcpy(lmtline, &inst, sizeof(inst));
+
+               /*
+                * Make sure compiler does not reorder memcpy and ldeor.
+                * LMTST transactions are always flushed from the write
+                * buffer immediately, a DMB is not required to push out
+                * LMTSTs.
+                */
+               rte_io_wmb();
+               lmt_status = otx2_lmt_submit(qp->lf_nq_reg);
+       } while (lmt_status == 0);
+
+}
+
 static __rte_always_inline int32_t __rte_hot
 otx2_cpt_enqueue_req(const struct otx2_cpt_qp *qp,
                     struct pending_queue *pend_q,
@@ -434,6 +476,11 @@ otx2_cpt_enqueue_req(const struct otx2_cpt_qp *qp,
        union cpt_inst_s inst;
        uint64_t lmt_status;
 
+       if (qp->ca_enable) {
+               otx2_ca_enqueue_req(qp, req, lmtline);
+               return 0;
+       }
+
        if (unlikely(pend_q->pending_count >= OTX2_CPT_DEFAULT_CMD_QLEN))
                return -EAGAIN;
 
index 95ebda255ad3c398364eb89aeb621728657f8408..02684781b3cfa922f4f9b017134e99454edbeaec 100644 (file)
@@ -5,6 +5,7 @@ DPDK_21 {
 INTERNAL {
        global:
 
+       otx2_cryptodev_driver_id;
        otx2_cpt_af_reg_read;
        otx2_cpt_af_reg_write;
 
diff --git a/drivers/event/octeontx2/otx2_evdev_crypto_adptr_dp.h b/drivers/event/octeontx2/otx2_evdev_crypto_adptr_dp.h
new file mode 100644 (file)
index 0000000..70b6393
--- /dev/null
@@ -0,0 +1,75 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C) 2020 Marvell International Ltd.
+ */
+
+#ifndef _OTX2_EVDEV_CRYPTO_ADPTR_DP_H_
+#define _OTX2_EVDEV_CRYPTO_ADPTR_DP_H_
+
+#include <rte_cryptodev.h>
+#include <rte_cryptodev_pmd.h>
+#include <rte_eventdev.h>
+
+#include "cpt_pmd_logs.h"
+#include "cpt_ucode.h"
+
+#include "otx2_cryptodev.h"
+#include "otx2_cryptodev_hw_access.h"
+#include "otx2_cryptodev_ops_helper.h"
+#include "otx2_cryptodev_qp.h"
+
+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)
+{
+       if (cop->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+               if (likely(cc == NO_ERR)) {
+                       /* Verify authentication data if required */
+                       if (unlikely(rsp[2]))
+                               compl_auth_verify(cop, (uint8_t *)rsp[2],
+                                                rsp[3]);
+                       else
+                               cop->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
+               } else {
+                       if (cc == ERR_GC_ICV_MISCOMPARE)
+                               cop->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
+                       else
+                               cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
+               }
+
+               if (unlikely(cop->sess_type == RTE_CRYPTO_OP_SESSIONLESS)) {
+                       sym_session_clear(otx2_cryptodev_driver_id,
+                                         cop->sym->session);
+                       memset(cop->sym->session, 0,
+                       rte_cryptodev_sym_get_existing_header_session_size(
+                               cop->sym->session));
+                       rte_mempool_put(qp->sess_mp, cop->sym->session);
+                       cop->sym->session = NULL;
+               }
+       }
+
+}
+
+static inline uint64_t
+otx2_handle_crypto_event(uint64_t get_work1)
+{
+       struct cpt_request_info *req;
+       struct rte_crypto_op *cop;
+       uintptr_t *rsp;
+       void *metabuf;
+       uint8_t cc;
+
+       req = (struct cpt_request_info *)(get_work1);
+       cc = otx2_cpt_compcode_get(req);
+
+       rsp = req->op;
+       metabuf = (void *)rsp[0];
+       cop = (void *)rsp[1];
+
+       otx2_ca_deq_post_process(req->qp, cop, rsp, cc);
+
+       rte_mempool_put(req->qp->meta_info.pool, metabuf);
+
+       return (uint64_t)(cop);
+}
+#endif /* _OTX2_EVDEV_CRYPTO_ADPTR_DP_H_ */
index cde1288d951dfee38c3e167991bfb32c1690a34c..3a3ec0fd4dc9385ff29a9659751b1a6afd39a638 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <otx2_common.h>
 #include "otx2_evdev.h"
+#include "otx2_evdev_crypto_adptr_dp.h"
 #include "otx2_ethdev_sec_tx.h"
 
 /* SSO Operations */
@@ -66,16 +67,23 @@ otx2_ssogws_get_work(struct otx2_ssogws *ws, struct rte_event *ev,
        ws->cur_tt = event.sched_type;
        ws->cur_grp = event.queue_id;
 
-       if (event.sched_type != SSO_TT_EMPTY &&
-           event.event_type == RTE_EVENT_TYPE_ETHDEV) {
-               otx2_wqe_to_mbuf(get_work1, mbuf, event.sub_event_type,
-                                (uint32_t) event.get_work0, flags, lookup_mem);
-               /* Extracting tstamp, if PTP enabled*/
-               tstamp_ptr = *(uint64_t *)(((struct nix_wqe_hdr_s *)get_work1)
-                                            + OTX2_SSO_WQE_SG_PTR);
-               otx2_nix_mbuf_to_tstamp((struct rte_mbuf *)mbuf, ws->tstamp,
-                                       flags, (uint64_t *)tstamp_ptr);
-               get_work1 = mbuf;
+       if (event.sched_type != SSO_TT_EMPTY) {
+               if ((flags & NIX_RX_OFFLOAD_SECURITY_F) &&
+                   (event.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
+                       get_work1 = otx2_handle_crypto_event(get_work1);
+               } else if (event.event_type == RTE_EVENT_TYPE_ETHDEV) {
+                       otx2_wqe_to_mbuf(get_work1, mbuf, event.sub_event_type,
+                                        (uint32_t) event.get_work0, flags,
+                                        lookup_mem);
+                       /* Extracting tstamp, if PTP enabled*/
+                       tstamp_ptr = *(uint64_t *)(((struct nix_wqe_hdr_s *)
+                                                    get_work1) +
+                                                    OTX2_SSO_WQE_SG_PTR);
+                       otx2_nix_mbuf_to_tstamp((struct rte_mbuf *)mbuf,
+                                               ws->tstamp, flags,
+                                               (uint64_t *)tstamp_ptr);
+                       get_work1 = mbuf;
+               }
        }
 
        ev->event = event.get_work0;
index 60aa14cca0c940d8f02aa44c07e983d4a0c0c978..6e6061821735764ddfd1d04fbac6749bf2c2512a 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <otx2_common.h>
 #include "otx2_evdev.h"
+#include "otx2_evdev_crypto_adptr_dp.h"
 
 /* SSO Operations */
 static __rte_always_inline uint16_t
@@ -63,25 +64,32 @@ otx2_ssogws_dual_get_work(struct otx2_ssogws_state *ws,
        ws->cur_tt = event.sched_type;
        ws->cur_grp = event.queue_id;
 
-       if (event.sched_type != SSO_TT_EMPTY &&
-           event.event_type == RTE_EVENT_TYPE_ETHDEV) {
-               uint8_t port = event.sub_event_type;
+       if (event.sched_type != SSO_TT_EMPTY) {
+               if ((flags & NIX_RX_OFFLOAD_SECURITY_F) &&
+                   (event.event_type == RTE_EVENT_TYPE_CRYPTODEV)) {
+                       get_work1 = otx2_handle_crypto_event(get_work1);
+               } else if (event.event_type == RTE_EVENT_TYPE_ETHDEV) {
+                       uint8_t port = event.sub_event_type;
 
-               event.sub_event_type = 0;
-               otx2_wqe_to_mbuf(get_work1, mbuf, port,
-                                event.flow_id, flags, lookup_mem);
-               /* Extracting tstamp, if PTP enabled. CGX will prepend the
-                * timestamp at starting of packet data and it can be derieved
-                * from WQE 9 dword which corresponds to SG iova.
-                * rte_pktmbuf_mtod_offset can be used for this purpose but it
-                * brings down the performance as it reads mbuf->buf_addr which
-                * is not part of cache in general fast path.
-                */
-               tstamp_ptr = *(uint64_t *)(((struct nix_wqe_hdr_s *)get_work1)
-                                            + OTX2_SSO_WQE_SG_PTR);
-               otx2_nix_mbuf_to_tstamp((struct rte_mbuf *)mbuf, tstamp, flags,
-                                       (uint64_t *)tstamp_ptr);
-               get_work1 = mbuf;
+                       event.sub_event_type = 0;
+                       otx2_wqe_to_mbuf(get_work1, mbuf, port,
+                                        event.flow_id, flags, lookup_mem);
+                       /* Extracting tstamp, if PTP enabled. CGX will prepend
+                        * the timestamp at starting of packet data and it can
+                        * be derieved from WQE 9 dword which corresponds to SG
+                        * iova.
+                        * rte_pktmbuf_mtod_offset can be used for this purpose
+                        * but it brings down the performance as it reads
+                        * mbuf->buf_addr which is not part of cache in general
+                        * fast path.
+                        */
+                       tstamp_ptr = *(uint64_t *)(((struct nix_wqe_hdr_s *)
+                                                    get_work1) +
+                                                    OTX2_SSO_WQE_SG_PTR);
+                       otx2_nix_mbuf_to_tstamp((struct rte_mbuf *)mbuf, tstamp,
+                                               flags, (uint64_t *)tstamp_ptr);
+                       get_work1 = mbuf;
+               }
        }
 
        ev->event = event.get_work0;