From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4006645845; Thu, 22 Aug 2024 12:29:07 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 324AD42E6E; Thu, 22 Aug 2024 12:29:07 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 9483D42E66 for ; Thu, 22 Aug 2024 12:29:05 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47M8YVDX025626; Thu, 22 Aug 2024 03:29:04 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=pfpt0220; bh=VX2M/+setPzswewXp/QBzA5 yAvO07vNILHDi1BrrM5c=; b=AbC5Mnp8/YR95K/FwZkg1xoJ3qs+m496YrvJ/1m ccCsk0C9q7B5C+jr+SbVYnqgcTNanejR647PRanrwn44SdrAsGGwqCZrL4mGD3eR wih1XlRMn31QgLlEUguulKP15/XFoEH0HTkN1tkj/khv8Wuv9ePRBViWAUgBCWJC mRDaB+EqacHXkMDb2fSzoio6x7of1NPdyGn03bFrwan6dmC02WL6NG4XgRlTNVz7 5TS9Ga6bg2tyfKeQ0I4FYw2YsumumDqMbECLCa0JyBSuHiz9xDT3pFhCwXoDB3Gh d5THzz0vlwdiD7cNozMDN8lhS8UuEm3+ae9ajsnbfqfFqIQ== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 415aw2nd52-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 22 Aug 2024 03:29:04 -0700 (PDT) Received: from DC6WP-EXCH02.marvell.com (10.76.176.209) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 22 Aug 2024 03:29:03 -0700 Received: from maili.marvell.com (10.69.176.80) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Thu, 22 Aug 2024 03:29:03 -0700 Received: from localhost.localdomain (unknown [10.28.36.179]) by maili.marvell.com (Postfix) with ESMTP id 45C123F707D; Thu, 22 Aug 2024 03:29:00 -0700 (PDT) From: Vidya Sagar Velumuri To: Akhil Goyal , Fan Zhang CC: , , , , , , Subject: [PATCH v1 1/3] cryptodev: add queue pair reset API Date: Thu, 22 Aug 2024 03:28:54 -0700 Message-ID: <20240822102856.3965710-1-vvelumuri@marvell.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: A6jceA9yHI3k6glve5tqM3zELkCyiYRD X-Proofpoint-ORIG-GUID: A6jceA9yHI3k6glve5tqM3zELkCyiYRD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-22_03,2024-08-19_03,2024-05-17_01 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 The API will reset the specific queue pair of a cryptodev. The current API, cryptodev_queue_pair_setup(), requires the cryptodev to be stopped before reconfiguring any queue pair. Stopping the cryptodev in one thread can result in a segmentation fault when multiple queues are used for enqueue and dequeue operations. On supported PMDs, the cryptodev_queue_pair_reset() will reconfigure/reset the queue pair without affecting other queues or the cryptodev state. The caller should ensure that there are no enqueue or dequeue operations ongoing on that queue and that there are no inflight packets before calling this API. Signed-off-by: Vidya Sagar Velumuri diff --git a/lib/cryptodev/cryptodev_pmd.h b/lib/cryptodev/cryptodev_pmd.h index 6c114f7181..311ae63abb 100644 --- a/lib/cryptodev/cryptodev_pmd.h +++ b/lib/cryptodev/cryptodev_pmd.h @@ -290,6 +290,22 @@ typedef int (*cryptodev_queue_pair_setup_t)(struct rte_cryptodev *dev, typedef int (*cryptodev_queue_pair_release_t)(struct rte_cryptodev *dev, uint16_t qp_id); +/** + * Reset or reconfigure a queue pair for a device. + * + * @param dev Crypto device pointer + * @param qp_id Queue pair index + * @param qp_conf Queue configuration structure + * @param socket_id Socket index + * + * @return + * - 0: on success. + * - ENOTSUP: if crypto device does not support the operation. + */ +typedef int (*cryptodev_queue_pair_reset_t)(struct rte_cryptodev *dev, + uint16_t qp_id, const struct rte_cryptodev_qp_conf *qp_conf, + int socket_id); + /** * Create a session mempool to allocate sessions from * @@ -476,6 +492,8 @@ struct rte_cryptodev_ops { /**< Set up a device queue pair. */ cryptodev_queue_pair_release_t queue_pair_release; /**< Release a queue pair. */ + cryptodev_queue_pair_reset_t queue_pair_reset; + /**< Reset a queue pair. */ cryptodev_sym_get_session_private_size_t sym_session_get_size; /**< Return private session. */ diff --git a/lib/cryptodev/cryptodev_trace.h b/lib/cryptodev/cryptodev_trace.h index 935f0d564b..633f17afe1 100644 --- a/lib/cryptodev/cryptodev_trace.h +++ b/lib/cryptodev/cryptodev_trace.h @@ -58,6 +58,16 @@ RTE_TRACE_POINT( rte_trace_point_emit_ptr(conf->mp_session); ) +RTE_TRACE_POINT( + rte_cryptodev_trace_queue_pair_reset, + RTE_TRACE_POINT_ARGS(uint8_t dev_id, uint16_t queue_pair_id, + const struct rte_cryptodev_qp_conf *conf, int socket_id), + rte_trace_point_emit_u8(dev_id); + rte_trace_point_emit_u16(queue_pair_id); + rte_trace_point_emit_u32(conf->nb_descriptors); + rte_trace_point_emit_int(socket_id); +) + RTE_TRACE_POINT( rte_cryptodev_trace_sym_session_pool_create, RTE_TRACE_POINT_ARGS(const char *name, uint32_t nb_elts, diff --git a/lib/cryptodev/cryptodev_trace_points.c b/lib/cryptodev/cryptodev_trace_points.c index 7403412553..6f37780595 100644 --- a/lib/cryptodev/cryptodev_trace_points.c +++ b/lib/cryptodev/cryptodev_trace_points.c @@ -21,6 +21,9 @@ RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_close, RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_queue_pair_setup, lib.cryptodev.queue.pair.setup) +RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_queue_pair_reset, + lib.cryptodev.queue.pair.reset) + RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_sym_session_pool_create, lib.cryptodev.sym.pool.create) diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c index 682c9f49d0..281ca51cf3 100644 --- a/lib/cryptodev/rte_cryptodev.c +++ b/lib/cryptodev/rte_cryptodev.c @@ -1222,6 +1222,30 @@ rte_cryptodev_queue_pairs_config(struct rte_cryptodev *dev, uint16_t nb_qpairs, return 0; } +int +rte_cryptodev_queue_pair_reset(uint8_t dev_id, uint16_t queue_pair_id, + const struct rte_cryptodev_qp_conf *qp_conf, int socket_id) +{ + struct rte_cryptodev *dev; + + if (!rte_cryptodev_is_valid_dev(dev_id)) { + CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id); + return -EINVAL; + } + + dev = &rte_crypto_devices[dev_id]; + if (queue_pair_id >= dev->data->nb_queue_pairs) { + CDEV_LOG_ERR("Invalid queue_pair_id=%d", queue_pair_id); + return -EINVAL; + } + + if (*dev->dev_ops->queue_pair_reset == NULL) + return -ENOTSUP; + + rte_cryptodev_trace_queue_pair_reset(dev_id, queue_pair_id, qp_conf, socket_id); + return (*dev->dev_ops->queue_pair_reset)(dev, queue_pair_id, qp_conf, socket_id); +} + int rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config) { diff --git a/lib/cryptodev/rte_cryptodev.h b/lib/cryptodev/rte_cryptodev.h index bec947f6d5..e0fc35db2a 100644 --- a/lib/cryptodev/rte_cryptodev.h +++ b/lib/cryptodev/rte_cryptodev.h @@ -840,6 +840,35 @@ int rte_cryptodev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id, const struct rte_cryptodev_qp_conf *qp_conf, int socket_id); +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Reset a queue pair for a device. + * The caller of this API must ensure that, there are no enqueues to the queue and there are no + * pending/inflight packets in the queue when the API is called. + * The API can reconfigure the queue pair when the queue pair configuration data is provided. + * + * @param dev_id The identifier of the device. + * @param queue_pair_id The index of the queue pairs to set up. The value must be in the + * range [0, nb_queue_pair - 1] previously supplied to + * rte_cryptodev_configure(). + * @param qp_conf The pointer to configuration data to be used for the queue pair. + * It should be NULL, if the API is called from an interrupt context. + * @param socket_id The *socket_id* argument is the socket identifier in case of NUMA. + * The value can be *SOCKET_ID_ANY* if there is no NUMA constraint + * for the DMA memory allocated for the queue pair. + * + * @return + * - 0: Queue pair is reset successfully. + * - ENOTSUP: If the operation is not supported by the PMD. + * - <0: Queue pair reset failed + */ +__rte_experimental +int +rte_cryptodev_queue_pair_reset(uint8_t dev_id, uint16_t queue_pair_id, + const struct rte_cryptodev_qp_conf *qp_conf, int socket_id); + /** * Get the status of queue pairs setup on a specific crypto device * diff --git a/lib/cryptodev/version.map b/lib/cryptodev/version.map index fdac0d876e..eec06d9939 100644 --- a/lib/cryptodev/version.map +++ b/lib/cryptodev/version.map @@ -87,6 +87,9 @@ EXPERIMENTAL { # added in 24.03 __rte_cryptodev_trace_qp_depth_used; + + # added in 24.07 + rte_cryptodev_queue_pair_reset; }; INTERNAL { -- 2.25.1