From: Akhil Goyal <gakhil@marvell.com>
To: <dev@dpdk.org>
Cc: <thomas@monjalon.net>, <david.marchand@redhat.com>,
<hemant.agrawal@nxp.com>, <anoobj@marvell.com>,
<pablo.de.lara.guarch@intel.com>, <fiona.trahe@intel.com>,
<declan.doherty@intel.com>, <matan@nvidia.com>, <g.singh@nxp.com>,
<roy.fan.zhang@intel.com>, <jianjay.zhou@huawei.com>,
<asomalap@amd.com>, <ruifeng.wang@arm.com>,
<konstantin.ananyev@intel.com>, <radu.nicolau@intel.com>,
<ajit.khaparde@broadcom.com>, <rnagadheeraj@marvell.com>,
<adwivedi@marvell.com>, <ciara.power@intel.com>,
Akhil Goyal <gakhil@marvell.com>
Subject: [dpdk-dev] [PATCH v2 3/5] cryptodev: move inline APIs into separate structure
Date: Mon, 11 Oct 2021 18:13:07 +0530 [thread overview]
Message-ID: <20211011124309.4066491-4-gakhil@marvell.com> (raw)
In-Reply-To: <20211011124309.4066491-1-gakhil@marvell.com>
Move fastpath inline function pointers from rte_cryptodev into a
separate structure accessed via a flat array.
The intension is to make rte_cryptodev and related structures private
to avoid future API/ABI breakages.
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
lib/cryptodev/cryptodev_pmd.c | 51 ++++++++++++++++++++++++++++++
lib/cryptodev/cryptodev_pmd.h | 11 +++++++
lib/cryptodev/rte_cryptodev.c | 29 +++++++++++++++++
lib/cryptodev/rte_cryptodev_core.h | 29 +++++++++++++++++
lib/cryptodev/version.map | 5 +++
5 files changed, 125 insertions(+)
diff --git a/lib/cryptodev/cryptodev_pmd.c b/lib/cryptodev/cryptodev_pmd.c
index 44a70ecb35..4646708045 100644
--- a/lib/cryptodev/cryptodev_pmd.c
+++ b/lib/cryptodev/cryptodev_pmd.c
@@ -4,6 +4,7 @@
#include <sys/queue.h>
+#include <rte_errno.h>
#include <rte_string_fns.h>
#include <rte_malloc.h>
@@ -160,3 +161,53 @@ rte_cryptodev_pmd_destroy(struct rte_cryptodev *cryptodev)
return 0;
}
+
+static uint16_t
+dummy_crypto_enqueue_burst(__rte_unused void *qp,
+ __rte_unused struct rte_crypto_op **ops,
+ __rte_unused uint16_t nb_ops)
+{
+ CDEV_LOG_ERR(
+ "crypto enqueue burst requested for unconfigured device");
+ rte_errno = ENOTSUP;
+ return 0;
+}
+
+static uint16_t
+dummy_crypto_dequeue_burst(__rte_unused void *qp,
+ __rte_unused struct rte_crypto_op **ops,
+ __rte_unused uint16_t nb_ops)
+{
+ CDEV_LOG_ERR(
+ "crypto dequeue burst requested for unconfigured device");
+ rte_errno = ENOTSUP;
+ return 0;
+}
+
+void
+cryptodev_fp_ops_reset(struct rte_crypto_fp_ops *fp_ops)
+{
+ static void *dummy_data[RTE_MAX_QUEUES_PER_PORT];
+ static const struct rte_crypto_fp_ops dummy = {
+ .enqueue_burst = dummy_crypto_enqueue_burst,
+ .dequeue_burst = dummy_crypto_dequeue_burst,
+ .qp = {
+ .data = dummy_data,
+ .enq_cb = dummy_data,
+ .deq_cb = dummy_data,
+ },
+ };
+
+ *fp_ops = dummy;
+}
+
+void
+cryptodev_fp_ops_set(struct rte_crypto_fp_ops *fp_ops,
+ const struct rte_cryptodev *dev)
+{
+ fp_ops->enqueue_burst = dev->enqueue_burst;
+ fp_ops->dequeue_burst = dev->dequeue_burst;
+ fp_ops->qp.data = dev->data->queue_pairs;
+ fp_ops->qp.enq_cb = (void **)(uintptr_t)dev->enq_cbs;
+ fp_ops->qp.deq_cb = (void **)(uintptr_t)dev->deq_cbs;
+}
diff --git a/lib/cryptodev/cryptodev_pmd.h b/lib/cryptodev/cryptodev_pmd.h
index 36606dd10b..a71edbb991 100644
--- a/lib/cryptodev/cryptodev_pmd.h
+++ b/lib/cryptodev/cryptodev_pmd.h
@@ -516,6 +516,17 @@ RTE_INIT(init_ ##driver_id)\
driver_id = rte_cryptodev_allocate_driver(&crypto_drv, &(drv));\
}
+/* Reset crypto device fastpath APIs to dummy values. */
+__rte_internal
+void
+cryptodev_fp_ops_reset(struct rte_crypto_fp_ops *fp_ops);
+
+/* Setup crypto device fastpath APIs. */
+__rte_internal
+void
+cryptodev_fp_ops_set(struct rte_crypto_fp_ops *fp_ops,
+ const struct rte_cryptodev *dev);
+
static inline void *
get_sym_session_private_data(const struct rte_cryptodev_sym_session *sess,
uint8_t driver_id) {
diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c
index eb86e629aa..2378892d40 100644
--- a/lib/cryptodev/rte_cryptodev.c
+++ b/lib/cryptodev/rte_cryptodev.c
@@ -53,6 +53,9 @@ static struct rte_cryptodev_global cryptodev_globals = {
.nb_devs = 0
};
+/* Public fastpath APIs. */
+struct rte_crypto_fp_ops rte_crypto_fp_ops[RTE_CRYPTO_MAX_DEVS];
+
/* spinlock for crypto device callbacks */
static rte_spinlock_t rte_cryptodev_cb_lock = RTE_SPINLOCK_INITIALIZER;
@@ -903,6 +906,16 @@ rte_cryptodev_pmd_allocate(const char *name, int socket_id)
cryptodev_globals.nb_devs++;
}
+ /*
+ * for secondary process, at that point we expect device
+ * to be already 'usable', so shared data and all function
+ * pointers for fast-path devops have to be setup properly
+ * inside rte_cryptodev.
+ */
+ if (rte_eal_process_type() == RTE_PROC_SECONDARY)
+ cryptodev_fp_ops_set(rte_crypto_fp_ops +
+ cryptodev->data->dev_id, cryptodev);
+
return cryptodev;
}
@@ -917,6 +930,8 @@ rte_cryptodev_pmd_release_device(struct rte_cryptodev *cryptodev)
dev_id = cryptodev->data->dev_id;
+ cryptodev_fp_ops_reset(rte_crypto_fp_ops + dev_id);
+
/* Close device only if device operations have been set */
if (cryptodev->dev_ops) {
ret = rte_cryptodev_close(dev_id);
@@ -1080,6 +1095,9 @@ rte_cryptodev_start(uint8_t dev_id)
}
diag = (*dev->dev_ops->dev_start)(dev);
+ /* expose selection of PMD fast-path functions */
+ cryptodev_fp_ops_set(rte_crypto_fp_ops + dev_id, dev);
+
rte_cryptodev_trace_start(dev_id, diag);
if (diag == 0)
dev->data->dev_started = 1;
@@ -1109,6 +1127,9 @@ rte_cryptodev_stop(uint8_t dev_id)
return;
}
+ /* point fast-path functions to dummy ones */
+ cryptodev_fp_ops_reset(rte_crypto_fp_ops + dev_id);
+
(*dev->dev_ops->dev_stop)(dev);
rte_cryptodev_trace_stop(dev_id);
dev->data->dev_started = 0;
@@ -2411,3 +2432,11 @@ rte_cryptodev_allocate_driver(struct cryptodev_driver *crypto_drv,
return nb_drivers++;
}
+
+RTE_INIT(cryptodev_init_fp_ops)
+{
+ uint32_t i;
+
+ for (i = 0; i != RTE_DIM(rte_crypto_fp_ops); i++)
+ cryptodev_fp_ops_reset(rte_crypto_fp_ops + i);
+}
diff --git a/lib/cryptodev/rte_cryptodev_core.h b/lib/cryptodev/rte_cryptodev_core.h
index 1633e55889..bac5f8d984 100644
--- a/lib/cryptodev/rte_cryptodev_core.h
+++ b/lib/cryptodev/rte_cryptodev_core.h
@@ -25,6 +25,35 @@ typedef uint16_t (*enqueue_pkt_burst_t)(void *qp,
struct rte_crypto_op **ops, uint16_t nb_ops);
/**< Enqueue packets for processing on queue pair of a device. */
+/**
+ * @internal
+ * Structure used to hold opaque pointers to internal ethdev Rx/Tx
+ * queues data.
+ * The main purpose to expose these pointers at all - allow compiler
+ * to fetch this data for fast-path cryptodev inline functions in advance.
+ */
+struct rte_cryptodev_qpdata {
+ /** points to array of internal queue pair data pointers. */
+ void **data;
+ /** points to array of enqueue callback data pointers */
+ void **enq_cb;
+ /** points to array of dequeue callback data pointers */
+ void **deq_cb;
+};
+
+struct rte_crypto_fp_ops {
+ /** PMD enqueue burst function. */
+ enqueue_pkt_burst_t enqueue_burst;
+ /** PMD dequeue burst function. */
+ dequeue_pkt_burst_t dequeue_burst;
+ /** Internal queue pair data pointers. */
+ struct rte_cryptodev_qpdata qp;
+ /** Reserved for future ops. */
+ uintptr_t reserved[4];
+} __rte_cache_aligned;
+
+extern struct rte_crypto_fp_ops rte_crypto_fp_ops[RTE_CRYPTO_MAX_DEVS];
+
/**
* @internal
* The data part, with no function pointers, associated with each device.
diff --git a/lib/cryptodev/version.map b/lib/cryptodev/version.map
index 43cf937e40..ed62ced221 100644
--- a/lib/cryptodev/version.map
+++ b/lib/cryptodev/version.map
@@ -45,6 +45,9 @@ DPDK_22 {
rte_cryptodev_sym_session_init;
rte_cryptodevs;
+ #added in 21.11
+ rte_crypto_fp_ops;
+
local: *;
};
@@ -109,6 +112,8 @@ EXPERIMENTAL {
INTERNAL {
global:
+ cryptodev_fp_ops_reset;
+ cryptodev_fp_ops_set;
rte_cryptodev_allocate_driver;
rte_cryptodev_pmd_allocate;
rte_cryptodev_pmd_callback_process;
--
2.25.1
next prev parent reply other threads:[~2021-10-11 12:43 UTC|newest]
Thread overview: 74+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-29 12:51 [dpdk-dev] [PATCH 0/8] cryptodev: hide internal strutures Akhil Goyal
2021-08-29 12:51 ` [dpdk-dev] [PATCH 1/8] cryptodev: separate out internal structures Akhil Goyal
2021-09-08 10:50 ` Anoob Joseph
2021-09-08 11:11 ` Akhil Goyal
2021-09-13 14:10 ` Zhang, Roy Fan
2021-08-29 12:51 ` [dpdk-dev] [PATCH 2/8] cryptodev: move inline APIs into separate structure Akhil Goyal
2021-09-13 14:11 ` Zhang, Roy Fan
2021-09-16 15:21 ` Ananyev, Konstantin
2021-08-29 12:51 ` [dpdk-dev] [PATCH 3/8] cryptodev: add helper functions for new datapath interface Akhil Goyal
2021-08-30 20:07 ` Zhang, Roy Fan
2021-08-31 6:14 ` Akhil Goyal
2021-09-13 14:20 ` Zhang, Roy Fan
2021-08-29 12:51 ` [dpdk-dev] [PATCH 4/8] cryptodev: use new API for datapath functions Akhil Goyal
2021-09-13 14:20 ` Zhang, Roy Fan
2021-08-29 12:51 ` [dpdk-dev] [PATCH 5/8] drivers/crypto: use new framework for datapath Akhil Goyal
2021-09-13 14:20 ` Zhang, Roy Fan
2021-08-29 12:51 ` [dpdk-dev] [PATCH 6/8] crypto/scheduler: rename enq-deq functions Akhil Goyal
2021-09-13 14:21 ` Zhang, Roy Fan
2021-08-29 12:51 ` [dpdk-dev] [PATCH 7/8] crypto/scheduler: update for new datapath framework Akhil Goyal
2021-09-13 14:21 ` Zhang, Roy Fan
2021-08-29 12:51 ` [dpdk-dev] [PATCH 8/8] cryptodev: move device specific structures Akhil Goyal
2021-09-13 14:22 ` Zhang, Roy Fan
2021-09-06 18:29 ` [dpdk-dev] [PATCH 0/8] cryptodev: hide internal strutures Akhil Goyal
2021-09-13 14:09 ` Zhang, Roy Fan
2021-10-11 12:43 ` [dpdk-dev] [PATCH v2 0/5] cryptodev: hide internal structures Akhil Goyal
2021-10-11 12:43 ` [dpdk-dev] [PATCH v2 1/5] cryptodev: separate out " Akhil Goyal
2021-10-11 14:50 ` Zhang, Roy Fan
2021-10-11 12:43 ` [dpdk-dev] [PATCH v2 2/5] cryptodev: allocate max space for internal qp array Akhil Goyal
2021-10-11 14:51 ` Zhang, Roy Fan
2021-10-11 12:43 ` Akhil Goyal [this message]
2021-10-11 14:45 ` [dpdk-dev] [PATCH v2 3/5] cryptodev: move inline APIs into separate structure Zhang, Roy Fan
2021-10-18 7:02 ` Akhil Goyal
2021-10-11 12:43 ` [dpdk-dev] [PATCH v2 4/5] cryptodev: update fast path APIs to use new flat array Akhil Goyal
2021-10-11 14:54 ` Zhang, Roy Fan
2021-10-11 12:43 ` [dpdk-dev] [PATCH v2 5/5] cryptodev: move device specific structures Akhil Goyal
2021-10-11 15:05 ` Zhang, Roy Fan
2021-10-18 7:07 ` Akhil Goyal
2021-10-11 16:03 ` [dpdk-dev] [PATCH v2 0/5] cryptodev: hide internal structures Zhang, Roy Fan
2021-10-11 17:07 ` Ji, Kai
2021-10-11 18:21 ` Zhang, Roy Fan
2021-10-15 18:38 ` Ananyev, Konstantin
2021-10-15 18:42 ` Akhil Goyal
2021-10-19 11:03 ` Ananyev, Konstantin
2021-10-18 14:41 ` [dpdk-dev] [PATCH v3 0/7] " Akhil Goyal
2021-10-18 14:41 ` [dpdk-dev] [PATCH v3 1/7] cryptodev: separate out " Akhil Goyal
2021-10-18 14:41 ` [dpdk-dev] [PATCH v3 2/7] cryptodev: allocate max space for internal qp array Akhil Goyal
2021-10-18 14:41 ` [dpdk-dev] [PATCH v3 3/7] cryptodev: move inline APIs into separate structure Akhil Goyal
2021-10-19 11:11 ` Ananyev, Konstantin
2021-10-19 11:50 ` Akhil Goyal
2021-10-19 14:27 ` Ananyev, Konstantin
2021-10-19 16:00 ` Zhang, Roy Fan
2021-10-18 14:41 ` [dpdk-dev] [PATCH v3 4/7] cryptodev: add PMD device probe finish API Akhil Goyal
2021-10-19 16:01 ` Zhang, Roy Fan
2021-10-18 14:41 ` [dpdk-dev] [PATCH v3 5/7] drivers/crypto: invoke probing finish function Akhil Goyal
2021-10-19 16:03 ` Zhang, Roy Fan
2021-10-20 7:05 ` Matan Azrad
2021-10-18 14:42 ` [dpdk-dev] [PATCH v3 6/7] cryptodev: update fast path APIs to use new flat array Akhil Goyal
2021-10-19 12:28 ` Ananyev, Konstantin
2021-10-19 12:47 ` Akhil Goyal
2021-10-19 14:25 ` Ananyev, Konstantin
2021-10-18 14:42 ` [dpdk-dev] [PATCH v3 7/7] cryptodev: move device specific structures Akhil Goyal
2021-10-20 10:25 ` [dpdk-dev] [PATCH v3 0/7] cryptodev: hide internal structures Power, Ciara
2021-10-20 11:27 ` [dpdk-dev] [PATCH v4 0/8] " Akhil Goyal
2021-10-20 11:27 ` [dpdk-dev] [PATCH v4 1/8] cryptodev: separate out " Akhil Goyal
2021-10-20 11:27 ` [dpdk-dev] [PATCH v4 2/8] cryptodev: allocate max space for internal qp array Akhil Goyal
2021-10-20 11:27 ` [dpdk-dev] [PATCH v4 3/8] cryptodev: move inline APIs into separate structure Akhil Goyal
2021-10-20 11:27 ` [dpdk-dev] [PATCH v4 4/8] crypto/scheduler: use proper API for device start/stop Akhil Goyal
2021-10-20 11:31 ` Zhang, Roy Fan
2021-10-20 12:20 ` Ananyev, Konstantin
2021-10-20 11:27 ` [dpdk-dev] [PATCH v4 5/8] cryptodev: add PMD device probe finish API Akhil Goyal
2021-10-20 11:27 ` [dpdk-dev] [PATCH v4 6/8] drivers/crypto: invoke probing finish function Akhil Goyal
2021-10-20 11:27 ` [dpdk-dev] [PATCH v4 7/8] cryptodev: update fast path APIs to use new flat array Akhil Goyal
2021-10-20 11:27 ` [dpdk-dev] [PATCH v4 8/8] cryptodev: move device specific structures Akhil Goyal
2021-10-20 13:36 ` [dpdk-dev] [PATCH v4 0/8] cryptodev: hide internal structures Akhil Goyal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211011124309.4066491-4-gakhil@marvell.com \
--to=gakhil@marvell.com \
--cc=adwivedi@marvell.com \
--cc=ajit.khaparde@broadcom.com \
--cc=anoobj@marvell.com \
--cc=asomalap@amd.com \
--cc=ciara.power@intel.com \
--cc=david.marchand@redhat.com \
--cc=declan.doherty@intel.com \
--cc=dev@dpdk.org \
--cc=fiona.trahe@intel.com \
--cc=g.singh@nxp.com \
--cc=hemant.agrawal@nxp.com \
--cc=jianjay.zhou@huawei.com \
--cc=konstantin.ananyev@intel.com \
--cc=matan@nvidia.com \
--cc=pablo.de.lara.guarch@intel.com \
--cc=radu.nicolau@intel.com \
--cc=rnagadheeraj@marvell.com \
--cc=roy.fan.zhang@intel.com \
--cc=ruifeng.wang@arm.com \
--cc=thomas@monjalon.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).