From: Akhil Goyal <akhil.go...@nxp.com>

Signed-off-by: Akhil Goyal <akhil.go...@nxp.com>
Signed-off-by: Ashish Jain <ashish.j...@nxp.com>
---
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c   | 90 ++++++++++++++++++-
 drivers/crypto/dpaa2_sec/dpaa2_sec_event.h    | 18 ++++
 drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h     |  2 +
 .../dpaa2_sec/rte_pmd_dpaa2_sec_version.map   |  8 ++
 4 files changed, 116 insertions(+), 2 deletions(-)
 create mode 100644 drivers/crypto/dpaa2_sec/dpaa2_sec_event.h

diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c 
b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
index 53e493457..ae38f507b 100644
--- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
+++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
  *   Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved.
- *   Copyright 2016 NXP
+ *   Copyright 2016-2018 NXP
  *
  */
 
@@ -10,7 +10,6 @@
 
 #include <rte_mbuf.h>
 #include <rte_cryptodev.h>
-#include <rte_security_driver.h>
 #include <rte_malloc.h>
 #include <rte_memcpy.h>
 #include <rte_string_fns.h>
@@ -28,6 +27,7 @@
 #include <fsl_mc_sys.h>
 
 #include "dpaa2_sec_priv.h"
+#include "dpaa2_sec_event.h"
 #include "dpaa2_sec_logs.h"
 
 /* Required types */
@@ -2853,6 +2853,92 @@ void dpaa2_sec_stats_reset(struct rte_cryptodev *dev)
        }
 }
 
+static void __attribute__((hot))
+dpaa2_sec_process_parallel_event(struct qbman_swp *swp,
+                                const struct qbman_fd *fd,
+                                const struct qbman_result *dq,
+                                struct dpaa2_queue *rxq,
+                                struct rte_event *ev)
+{
+       /* Prefetching mbuf */
+       rte_prefetch0((void *)(size_t)(DPAA2_GET_FD_ADDR(fd)-
+               rte_dpaa2_bpid_info[DPAA2_GET_FD_BPID(fd)].meta_data_size));
+
+       /* Prefetching ipsec crypto_op stored in priv data of mbuf */
+       rte_prefetch0((void *)(size_t)(DPAA2_GET_FD_ADDR(fd)-64));
+
+       ev->flow_id = rxq->ev.flow_id;
+       ev->sub_event_type = rxq->ev.sub_event_type;
+       ev->event_type = RTE_EVENT_TYPE_CRYPTODEV;
+       ev->op = RTE_EVENT_OP_NEW;
+       ev->sched_type = rxq->ev.sched_type;
+       ev->queue_id = rxq->ev.queue_id;
+       ev->priority = rxq->ev.priority;
+       ev->event_ptr = sec_fd_to_mbuf(fd, ((struct rte_cryptodev *)
+                               (rxq->dev))->driver_id);
+
+       qbman_swp_dqrr_consume(swp, dq);
+}
+
+int
+dpaa2_sec_eventq_attach(const struct rte_cryptodev *dev,
+               int qp_id,
+               uint16_t dpcon_id,
+               const struct rte_event *event)
+{
+       struct dpaa2_sec_dev_private *priv = dev->data->dev_private;
+       struct fsl_mc_io *dpseci = (struct fsl_mc_io *)priv->hw;
+       struct dpaa2_sec_qp *qp = dev->data->queue_pairs[qp_id];
+       struct dpseci_rx_queue_cfg cfg;
+       int ret;
+
+       if (event->sched_type == RTE_SCHED_TYPE_PARALLEL)
+               qp->rx_vq.cb = dpaa2_sec_process_parallel_event;
+       else
+               return -EINVAL;
+
+       memset(&cfg, 0, sizeof(struct dpseci_rx_queue_cfg));
+       cfg.options = DPSECI_QUEUE_OPT_DEST;
+       cfg.dest_cfg.dest_type = DPSECI_DEST_DPCON;
+       cfg.dest_cfg.dest_id = dpcon_id;
+       cfg.dest_cfg.priority = event->priority;
+
+       cfg.options |= DPSECI_QUEUE_OPT_USER_CTX;
+       cfg.user_ctx = (size_t)(qp);
+
+       ret = dpseci_set_rx_queue(dpseci, CMD_PRI_LOW, priv->token,
+                                 qp_id, &cfg);
+       if (ret) {
+               RTE_LOG(ERR, PMD, "Error in dpseci_set_queue: ret: %d\n", ret);
+               return ret;
+       }
+
+       memcpy(&qp->rx_vq.ev, event, sizeof(struct rte_event));
+
+       return 0;
+}
+
+int
+dpaa2_sec_eventq_detach(const struct rte_cryptodev *dev,
+                       int qp_id)
+{
+       struct dpaa2_sec_dev_private *priv = dev->data->dev_private;
+       struct fsl_mc_io *dpseci = (struct fsl_mc_io *)priv->hw;
+       struct dpseci_rx_queue_cfg cfg;
+       int ret;
+
+       memset(&cfg, 0, sizeof(struct dpseci_rx_queue_cfg));
+       cfg.options = DPSECI_QUEUE_OPT_DEST;
+       cfg.dest_cfg.dest_type = DPSECI_DEST_NONE;
+
+       ret = dpseci_set_rx_queue(dpseci, CMD_PRI_LOW, priv->token,
+                                 qp_id, &cfg);
+       if (ret)
+               RTE_LOG(ERR, PMD, "Error in dpseci_set_queue: ret: %d\n", ret);
+
+       return ret;
+}
+
 static struct rte_cryptodev_ops crypto_ops = {
        .dev_configure        = dpaa2_sec_dev_configure,
        .dev_start            = dpaa2_sec_dev_start,
diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_event.h 
b/drivers/crypto/dpaa2_sec/dpaa2_sec_event.h
new file mode 100644
index 000000000..977099429
--- /dev/null
+++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_event.h
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2018 NXP
+ *
+ */
+
+#ifndef _DPAA2_SEC_EVENT_H_
+#define _DPAA2_SEC_EVENT_H_
+
+int
+dpaa2_sec_eventq_attach(const struct rte_cryptodev *dev,
+               int qp_id,
+               uint16_t dpcon_id,
+               const struct rte_event *event);
+
+int dpaa2_sec_eventq_detach(const struct rte_cryptodev *dev,
+               int qp_id);
+
+#endif /* _DPAA2_SEC_EVENT_H_ */
diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h 
b/drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h
index d015be1e9..bce9633c0 100644
--- a/drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h
+++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h
@@ -8,6 +8,8 @@
 #ifndef _RTE_DPAA2_SEC_PMD_PRIVATE_H_
 #define _RTE_DPAA2_SEC_PMD_PRIVATE_H_
 
+#include <rte_security_driver.h>
+
 #define CRYPTODEV_NAME_DPAA2_SEC_PMD   crypto_dpaa2_sec
 /**< NXP DPAA2 - SEC PMD device name */
 
diff --git a/drivers/crypto/dpaa2_sec/rte_pmd_dpaa2_sec_version.map 
b/drivers/crypto/dpaa2_sec/rte_pmd_dpaa2_sec_version.map
index 8591cc0b1..0bfb986d0 100644
--- a/drivers/crypto/dpaa2_sec/rte_pmd_dpaa2_sec_version.map
+++ b/drivers/crypto/dpaa2_sec/rte_pmd_dpaa2_sec_version.map
@@ -2,3 +2,11 @@ DPDK_17.05 {
 
        local: *;
 };
+
+DPDK_18.11 {
+       global:
+
+       dpaa2_sec_eventq_attach;
+       dpaa2_sec_eventq_detach;
+
+} DPDK_17.05;
-- 
2.17.1

Reply via email to