From: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
To: <dev@dpdk.org>, Maxime Coquelin <maxime.coquelin@redhat.com>,
Chenbo Xia <chenbox@nvidia.com>
Cc: Anoob Joseph <anoobj@marvell.com>,
Akhil Goyal <gakhil@marvell.com>, <bruce.richardson@intel.com>,
<ciara.power@intel.com>, <jerinj@marvell.com>,
<fanzhang.oss@gmail.com>, <arkadiuszx.kusztal@intel.com>,
<kai.ji@intel.com>, <jack.bond-preston@foss.arm.com>,
<david.marchand@redhat.com>, <hemant.agrawal@nxp.com>,
<pablo.de.lara.guarch@intel.com>, <fiona.trahe@intel.com>,
<declan.doherty@intel.com>, <matan@nvidia.com>,
<ruifeng.wang@arm.com>, <abhinandan.gujjar@intel.com>,
<sunilprakashrao.uttarwar@amd.com>, <andrew.boyer@amd.com>,
<ajit.khaparde@broadcom.com>, <raveendra.padasalagi@broadcom.com>,
<vikas.gupta@broadcom.com>, <zhangfei.gao@linaro.org>,
<g.singh@nxp.com>, <jianjay.zhou@huawei.com>,
<lee.daly@intel.com>, Brian Dooley <brian.dooley@intel.com>,
Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
Subject: [PATCH 5/6] examples/vhost_crypto: add asymmetric support
Date: Thu, 5 Sep 2024 20:26:09 +0530 [thread overview]
Message-ID: <20240905145612.1732-6-gmuthukrishn@marvell.com> (raw)
In-Reply-To: <20240905145612.1732-1-gmuthukrishn@marvell.com>
Add symmetric support.
Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
examples/vhost_crypto/main.c | 50 +++++++++++++++++++++---------------
1 file changed, 29 insertions(+), 21 deletions(-)
diff --git a/examples/vhost_crypto/main.c b/examples/vhost_crypto/main.c
index 558c09a60f..bed7fc637d 100644
--- a/examples/vhost_crypto/main.c
+++ b/examples/vhost_crypto/main.c
@@ -45,7 +45,8 @@ struct lcore_option {
struct __rte_cache_aligned vhost_crypto_info {
int vids[MAX_NB_SOCKETS];
uint32_t nb_vids;
- struct rte_mempool *sess_pool;
+ struct rte_mempool *sym_sess_pool;
+ struct rte_mempool *asym_sess_pool;
struct rte_mempool *cop_pool;
uint8_t cid;
uint32_t qid;
@@ -302,7 +303,8 @@ new_device(int vid)
return -ENOENT;
}
- ret = rte_vhost_crypto_create(vid, info->cid, info->sess_pool,
+ ret = rte_vhost_crypto_create(vid, info->cid, info->sym_sess_pool,
+ info->asym_sess_pool,
rte_lcore_to_socket_id(options.los[i].lcore_id));
if (ret) {
RTE_LOG(ERR, USER1, "Cannot create vhost crypto\n");
@@ -362,8 +364,8 @@ destroy_device(int vid)
}
static const struct rte_vhost_device_ops virtio_crypto_device_ops = {
- .new_device = new_device,
- .destroy_device = destroy_device,
+ .new_connection = new_device,
+ .destroy_connection = destroy_device,
};
static int
@@ -385,7 +387,7 @@ vhost_crypto_worker(void *arg)
for (i = 0; i < NB_VIRTIO_QUEUES; i++) {
if (rte_crypto_op_bulk_alloc(info->cop_pool,
- RTE_CRYPTO_OP_TYPE_SYMMETRIC, ops[i],
+ RTE_CRYPTO_OP_TYPE_UNDEFINED, ops[i],
burst_size) < burst_size) {
RTE_LOG(ERR, USER1, "Failed to alloc cops\n");
ret = -1;
@@ -409,20 +411,12 @@ vhost_crypto_worker(void *arg)
rte_cryptodev_enqueue_burst(
info->cid, info->qid, ops[j],
fetched);
- if (unlikely(rte_crypto_op_bulk_alloc(
- info->cop_pool,
- RTE_CRYPTO_OP_TYPE_SYMMETRIC,
- ops[j], fetched) < fetched)) {
- RTE_LOG(ERR, USER1, "Failed realloc\n");
- return -1;
- }
-
fetched = rte_cryptodev_dequeue_burst(
info->cid, info->qid,
ops_deq[j], RTE_MIN(burst_size,
info->nb_inflight_ops));
fetched = rte_vhost_crypto_finalize_requests(
- ops_deq[j], fetched, callfds,
+ info->vids[i], j, ops_deq[j], fetched, callfds,
&nb_callfds);
info->nb_inflight_ops -= fetched;
@@ -455,7 +449,8 @@ free_resource(void)
continue;
rte_mempool_free(info->cop_pool);
- rte_mempool_free(info->sess_pool);
+ rte_mempool_free(info->sym_sess_pool);
+ rte_mempool_free(info->asym_sess_pool);
for (j = 0; j < lo->nb_sockets; j++) {
rte_vhost_driver_unregister(lo->socket_files[i]);
@@ -539,21 +534,34 @@ main(int argc, char *argv[])
goto error_exit;
}
- snprintf(name, 127, "SESS_POOL_%u", lo->lcore_id);
- info->sess_pool = rte_cryptodev_sym_session_pool_create(name,
+ snprintf(name, 127, "SYM_SESS_POOL_%u", lo->lcore_id);
+ info->sym_sess_pool = rte_cryptodev_sym_session_pool_create(name,
SESSION_MAP_ENTRIES,
rte_cryptodev_sym_get_private_session_size(
info->cid), 0, 0,
rte_lcore_to_socket_id(lo->lcore_id));
- if (!info->sess_pool) {
- RTE_LOG(ERR, USER1, "Failed to create mempool");
+ if (!info->sym_sess_pool) {
+ RTE_LOG(ERR, USER1, "Failed to create sym session mempool");
+ goto error_exit;
+ }
+
+ /* TODO: storing vhost_crypto_data_req (56 bytes) in user_data,
+ * but it needs to be moved somewhere.
+ */
+ snprintf(name, 127, "ASYM_SESS_POOL_%u", lo->lcore_id);
+ info->asym_sess_pool = rte_cryptodev_asym_session_pool_create(name,
+ SESSION_MAP_ENTRIES, 0, 64,
+ rte_lcore_to_socket_id(lo->lcore_id));
+
+ if (!info->asym_sess_pool) {
+ RTE_LOG(ERR, USER1, "Failed to create asym session mempool");
goto error_exit;
}
snprintf(name, 127, "COPPOOL_%u", lo->lcore_id);
info->cop_pool = rte_crypto_op_pool_create(name,
- RTE_CRYPTO_OP_TYPE_SYMMETRIC, NB_MEMPOOL_OBJS,
+ RTE_CRYPTO_OP_TYPE_UNDEFINED, NB_MEMPOOL_OBJS,
NB_CACHE_OBJS, VHOST_CRYPTO_MAX_IV_LEN,
rte_lcore_to_socket_id(lo->lcore_id));
@@ -566,7 +574,7 @@ main(int argc, char *argv[])
options.infos[i] = info;
qp_conf.nb_descriptors = NB_CRYPTO_DESCRIPTORS;
- qp_conf.mp_session = info->sess_pool;
+ qp_conf.mp_session = info->sym_sess_pool;
for (j = 0; j < dev_info.max_nb_queue_pairs; j++) {
ret = rte_cryptodev_queue_pair_setup(info->cid, j,
--
2.21.0
next prev parent reply other threads:[~2024-09-05 14:57 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-05 14:56 [PATCH 0/6] vhost: add asymmetric crypto support Gowrishankar Muthukrishnan
2024-09-05 14:56 ` [PATCH 1/6] cryptodev: move RSA padding information into xform Gowrishankar Muthukrishnan
2024-09-05 14:56 ` [PATCH 2/6] cryptodev: fix RSA xform for ASN.1 syntax Gowrishankar Muthukrishnan
2024-09-05 14:56 ` [PATCH 3/6] vhost: add asymmetric RSA support Gowrishankar Muthukrishnan
2024-09-05 14:56 ` [PATCH 4/6] crypto/virtio: " Gowrishankar Muthukrishnan
2024-09-05 14:56 ` Gowrishankar Muthukrishnan [this message]
2024-09-05 14:56 ` [PATCH 6/6] app/test: add asymmetric tests for virtio pmd Gowrishankar Muthukrishnan
2024-10-10 3:10 ` Stephen Hemminger
2024-10-04 6:11 ` [PATCH v2 0/2] cryptodev: fix RSA xform to support VirtIO standard Gowrishankar Muthukrishnan
2024-10-04 6:11 ` [PATCH v2 1/2] cryptodev: fix RSA xform for ASN.1 syntax Gowrishankar Muthukrishnan
2024-10-07 7:19 ` Kusztal, ArkadiuszX
2024-10-07 7:32 ` Kusztal, ArkadiuszX
2024-10-04 6:11 ` [PATCH v2 2/2] cryptodev: move RSA padding information into xform Gowrishankar Muthukrishnan
2024-10-09 15:23 ` Akhil Goyal
2024-10-09 16:16 ` Kusztal, ArkadiuszX
2024-10-09 19:45 ` 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=20240905145612.1732-6-gmuthukrishn@marvell.com \
--to=gmuthukrishn@marvell.com \
--cc=abhinandan.gujjar@intel.com \
--cc=ajit.khaparde@broadcom.com \
--cc=andrew.boyer@amd.com \
--cc=anoobj@marvell.com \
--cc=arkadiuszx.kusztal@intel.com \
--cc=brian.dooley@intel.com \
--cc=bruce.richardson@intel.com \
--cc=chenbox@nvidia.com \
--cc=ciara.power@intel.com \
--cc=david.marchand@redhat.com \
--cc=declan.doherty@intel.com \
--cc=dev@dpdk.org \
--cc=fanzhang.oss@gmail.com \
--cc=fiona.trahe@intel.com \
--cc=g.singh@nxp.com \
--cc=gakhil@marvell.com \
--cc=hemant.agrawal@nxp.com \
--cc=jack.bond-preston@foss.arm.com \
--cc=jerinj@marvell.com \
--cc=jianjay.zhou@huawei.com \
--cc=kai.ji@intel.com \
--cc=lee.daly@intel.com \
--cc=matan@nvidia.com \
--cc=maxime.coquelin@redhat.com \
--cc=pablo.de.lara.guarch@intel.com \
--cc=raveendra.padasalagi@broadcom.com \
--cc=ruifeng.wang@arm.com \
--cc=sunilprakashrao.uttarwar@amd.com \
--cc=vikas.gupta@broadcom.com \
--cc=zhangfei.gao@linaro.org \
/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).