crypto/dpaa2_sec: support event crypto adapter
dpaa2_sec hw queues can be attached to a hw dpaa2 event device and the application can configure the event crypto adapter to access the dpaa2_sec packets using hardware events. This patch defines APIs which can be used by the dpaa2 event device to attach/detach dpaa2_sec queues. Signed-off-by: Akhil Goyal <akhil.goyal@nxp.com> Signed-off-by: Ashish Jain <ashish.jain@nxp.com>
This commit is contained in:
parent
df1740a8db
commit
bffc7d561c
@ -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>
|
||||
@ -29,6 +28,7 @@
|
||||
#include <fsl_mc_sys.h>
|
||||
|
||||
#include "dpaa2_sec_priv.h"
|
||||
#include "dpaa2_sec_event.h"
|
||||
#include "dpaa2_sec_logs.h"
|
||||
|
||||
/* Required types */
|
||||
@ -2854,6 +2854,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,
|
||||
|
18
drivers/crypto/dpaa2_sec/dpaa2_sec_event.h
Normal file
18
drivers/crypto/dpaa2_sec/dpaa2_sec_event.h
Normal file
@ -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_ */
|
@ -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 */
|
||||
|
||||
|
@ -2,3 +2,11 @@ DPDK_17.05 {
|
||||
|
||||
local: *;
|
||||
};
|
||||
|
||||
DPDK_18.11 {
|
||||
global:
|
||||
|
||||
dpaa2_sec_eventq_attach;
|
||||
dpaa2_sec_eventq_detach;
|
||||
|
||||
} DPDK_17.05;
|
||||
|
Loading…
Reference in New Issue
Block a user