From patchwork Thu Sep 28 09:52:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gowrishankar Muthukrishnan X-Patchwork-Id: 132114 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7EC464265E; Thu, 28 Sep 2023 11:53:56 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5AD0040E40; Thu, 28 Sep 2023 11:53:39 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id EDF6E40E01 for ; Thu, 28 Sep 2023 11:53:37 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38S8hFkE019297; Thu, 28 Sep 2023 02:53:37 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=DMSzLSG9hsh7ZrtUft033e8ukGDRxHE2q9+Rgja3+9o=; b=HhsmT/GGKrDCIjIjXC4ZwKLHASnrMYfAqeJqQOn2HPpx0jQBmFS9nHpYoKfINiNM+4bO Fvo4TSXveL8WYhFwx2lZNHEMgkVJ9eNvQ6d2FXCLDeXGD+0B8hKt9VMP1mYS74Qu2jiq TpeT0bsVKe3f2dRymstWkDD8npHz+09kWOdhL8dYdsW975RgOiQSM7C91Kut8r8qP1h/ sb+Z/gQwH2FUNWObJbWlP4L0vpX37z4oxEUWqdAKEfONTe+yuNaf4TRzUDLlaU4BTMzo Bjvi0Xm5GTbmwzlOTs1WNe2bV7jgMEw6VbDkfbRbiHhO8tg4bciupf6ymzGUOiCuMv37 Wg== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3tcu1qtdh4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 28 Sep 2023 02:53:36 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Thu, 28 Sep 2023 02:53:35 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Thu, 28 Sep 2023 02:53:35 -0700 Received: from BG-LT91401.marvell.com (BG-LT91401.marvell.com [10.28.168.34]) by maili.marvell.com (Postfix) with ESMTP id BF2905C68EF; Thu, 28 Sep 2023 02:53:32 -0700 (PDT) From: Gowrishankar Muthukrishnan To: CC: , Akhil Goyal , Fan Zhang , Kai Ji , Arkadiusz Kusztal , Maxime Coquelin , Chenbo Xia , Jay Zhou , Gowrishankar Muthukrishnan Subject: [RFC 5/6] examples/vhost_crypto: add asymmetric support Date: Thu, 28 Sep 2023 15:22:59 +0530 Message-ID: <20230928095300.1353-6-gmuthukrishn@marvell.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20230928095300.1353-1-gmuthukrishn@marvell.com> References: <20230928095300.1353-1-gmuthukrishn@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: PDFloVCquP7qEao48nSQh2idPCNMsB8s X-Proofpoint-ORIG-GUID: PDFloVCquP7qEao48nSQh2idPCNMsB8s X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-09-28_07,2023-09-27_01,2023-05-22_02 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Add symmetric support. Signed-off-by: Gowrishankar Muthukrishnan --- 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 02987ebd76..f9e2732d18 100644 --- a/examples/vhost_crypto/main.c +++ b/examples/vhost_crypto/main.c @@ -45,7 +45,8 @@ struct lcore_option { struct 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,