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 0EC2A440BB for ; Fri, 24 May 2024 19:13:37 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F39AF40693; Fri, 24 May 2024 19:13:36 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id BD00C40271; Fri, 24 May 2024 19:13:34 +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 44O69Ko7015183; Fri, 24 May 2024 10:13:34 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=F IA1Te4Ic1bcLHb5fnpBgTiBeh77QS8qqtXCHrnQI2o=; b=i2j70dpfsQQp1Erng kBSNBjxBcfjq3hq64L2DgMGcf6mKFFiA/LHWUh2PCbGp+S9krcgGeOjX+2lG9UlW DaOEL8MFsElqk3GtMDqgpG5iJtAYhmKUyrFnQYuGWMXoauxoogOd9pce94VVLTRb iKFda/D9ReNFMyqFuJl0sT3IdEYJKhz15YocQolQ2jWCA/hUsCLP+uuf7WejsemB KQZIycwBgpuKkaZh4C2nbHDECZJkJd7KEcEICoKbwxltKhL+f1rzVXJyUKL13I0R 1U4oXqbE1sydy9ZNC2tA0tH64mK3gjpvAUjiJyZYovEZQULGtnWYG8hpgM11d1bJ y2y5A== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3yaa85v1v5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 24 May 2024 10:13:33 -0700 (PDT) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 24 May 2024 10:13:32 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Fri, 24 May 2024 10:13:32 -0700 Received: from localhost.localdomain (unknown [10.28.36.102]) by maili.marvell.com (Postfix) with ESMTP id 65CCA3F707D; Fri, 24 May 2024 10:13:30 -0700 (PDT) From: Akhil Goyal To: CC: , , , , Akhil Goyal , Subject: [PATCH v3] test/crypto: fix enqueue dequeue callback case Date: Fri, 24 May 2024 22:43:27 +0530 Message-ID: <20240524171327.885698-1-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240523124838.3474899-1-gakhil@marvell.com> References: <20240523124838.3474899-1-gakhil@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: 1pbJZdCPRjQv_pUxqCKx49caVdjK81E- X-Proofpoint-GUID: 1pbJZdCPRjQv_pUxqCKx49caVdjK81E- X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.12.28.16 definitions=2024-05-24_05,2024-05-24_01,2024-05-17_01 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org The enqueue/dequeue callback test cases were using the test_null_burst_operation() for doing enqueue/dequeue. But this function is only designed to be run for NULL PMD. Hence for other PMDs, the callback was not getting called. Now, separate processing thread is removed, instead NULL crypto operation is created and processed so that callbacks are called. Also added a check on a global static variable to verify that the callback is actually called and fail the case if it is not getting called. Fixes: 5523a75af539 ("test/crypto: add case for enqueue/dequeue callbacks") Cc: stable@dpdk.org Signed-off-by: Akhil Goyal --- -v3: replaced AES-SHA1 with NULL crypto and removed separate thread. app/test/test_cryptodev.c | 106 ++++++++++++++++++++++++++++++++------ 1 file changed, 89 insertions(+), 17 deletions(-) diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index 1703ebccf1..b644e87106 100644 --- a/app/test/test_cryptodev.c +++ b/app/test/test_cryptodev.c @@ -199,6 +199,8 @@ post_process_raw_dp_op(void *user_data, uint32_t index __rte_unused, static struct crypto_testsuite_params testsuite_params = { NULL }; struct crypto_testsuite_params *p_testsuite_params = &testsuite_params; static struct crypto_unittest_params unittest_params; +static bool enq_cb_called; +static bool deq_cb_called; int process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id, @@ -14556,6 +14558,7 @@ test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops, RTE_SET_USED(ops); RTE_SET_USED(user_param); + enq_cb_called = true; printf("crypto enqueue callback called\n"); return nb_ops; } @@ -14569,21 +14572,58 @@ test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops, RTE_SET_USED(ops); RTE_SET_USED(user_param); + deq_cb_called = true; printf("crypto dequeue callback called\n"); return nb_ops; } /* - * Thread using enqueue/dequeue callback with RCU. + * Process enqueue/dequeue NULL crypto request to verify callback with RCU. */ static int -test_enqdeq_callback_thread(void *arg) +test_enqdeq_callback_null_cipher(void) { - RTE_SET_USED(arg); - /* DP thread calls rte_cryptodev_enqueue_burst()/ - * rte_cryptodev_dequeue_burst() and invokes callback. - */ - test_null_burst_operation(); + struct crypto_testsuite_params *ts_params = &testsuite_params; + struct crypto_unittest_params *ut_params = &unittest_params; + + /* Setup Cipher Parameters */ + ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER; + ut_params->cipher_xform.next = &ut_params->auth_xform; + + ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL; + ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT; + + /* Setup HMAC Parameters */ + ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH; + ut_params->auth_xform.next = NULL; + + ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL; + ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE; + + /* Create Crypto session*/ + ut_params->sess = rte_cryptodev_sym_session_create(ts_params->valid_devs[0], + &ut_params->auth_xform, ts_params->session_mpool); + TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); + + ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, RTE_CRYPTO_OP_TYPE_SYMMETRIC); + TEST_ASSERT_NOT_NULL(ut_params->op, "Failed to allocate symmetric crypto op"); + + /* Generate an operation for each mbuf in burst */ + ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); + TEST_ASSERT_NOT_NULL(ut_params->ibuf, "Failed to allocate mbuf"); + + /* Append some random data */ + TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(ut_params->ibuf, sizeof(unsigned int)), + "no room to append data"); + + rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess); + + ut_params->op->sym->m_src = ut_params->ibuf; + + /* Process crypto operation */ + TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0], ut_params->op), + "failed to process sym crypto op"); + return 0; } @@ -14591,6 +14631,7 @@ static int test_enq_callback_setup(void) { struct crypto_testsuite_params *ts_params = &testsuite_params; + struct rte_cryptodev_sym_capability_idx cap_idx; struct rte_cryptodev_info dev_info; struct rte_cryptodev_qp_conf qp_conf = { .nb_descriptors = MAX_NUM_OPS_INFLIGHT @@ -14598,6 +14639,19 @@ test_enq_callback_setup(void) struct rte_cryptodev_cb *cb; uint16_t qp_id = 0; + int j = 0; + + /* Verify the crypto capabilities for which enqueue/dequeue is done. */ + cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH; + cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL; + if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], + &cap_idx) == NULL) + return TEST_SKIPPED; + cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER; + cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL; + if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], + &cap_idx) == NULL) + return TEST_SKIPPED; /* Stop the device in case it's started so it can be configured */ rte_cryptodev_stop(ts_params->valid_devs[0]); @@ -14621,6 +14675,7 @@ test_enq_callback_setup(void) qp_conf.nb_descriptors, qp_id, ts_params->valid_devs[0]); + enq_cb_called = false; /* Test with invalid crypto device */ cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS, qp_id, test_enq_callback, NULL); @@ -14653,12 +14708,11 @@ test_enq_callback_setup(void) rte_cryptodev_start(ts_params->valid_devs[0]); - /* Launch a thread */ - rte_eal_remote_launch(test_enqdeq_callback_thread, NULL, - rte_get_next_lcore(-1, 1, 0)); + TEST_ASSERT_SUCCESS(test_enqdeq_callback_null_cipher(), "Crypto Processing failed"); - /* Wait until reader exited. */ - rte_eal_mp_wait_lcore(); + /* Wait until callback not called. */ + while (!enq_cb_called && (j++ < 10)) + rte_delay_ms(10); /* Test with invalid crypto device */ TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback( @@ -14683,6 +14737,8 @@ test_enq_callback_setup(void) "qp %u on cryptodev %u", qp_id, ts_params->valid_devs[0]); + TEST_ASSERT(enq_cb_called == true, "Crypto enqueue callback not called"); + return TEST_SUCCESS; } @@ -14690,6 +14746,7 @@ static int test_deq_callback_setup(void) { struct crypto_testsuite_params *ts_params = &testsuite_params; + struct rte_cryptodev_sym_capability_idx cap_idx; struct rte_cryptodev_info dev_info; struct rte_cryptodev_qp_conf qp_conf = { .nb_descriptors = MAX_NUM_OPS_INFLIGHT @@ -14697,6 +14754,19 @@ test_deq_callback_setup(void) struct rte_cryptodev_cb *cb; uint16_t qp_id = 0; + int j = 0; + + /* Verify the crypto capabilities for which enqueue/dequeue is done. */ + cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH; + cap_idx.algo.auth = RTE_CRYPTO_AUTH_NULL; + if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], + &cap_idx) == NULL) + return TEST_SKIPPED; + cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER; + cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_NULL; + if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], + &cap_idx) == NULL) + return TEST_SKIPPED; /* Stop the device in case it's started so it can be configured */ rte_cryptodev_stop(ts_params->valid_devs[0]); @@ -14720,6 +14790,7 @@ test_deq_callback_setup(void) qp_conf.nb_descriptors, qp_id, ts_params->valid_devs[0]); + deq_cb_called = false; /* Test with invalid crypto device */ cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS, qp_id, test_deq_callback, NULL); @@ -14752,12 +14823,11 @@ test_deq_callback_setup(void) rte_cryptodev_start(ts_params->valid_devs[0]); - /* Launch a thread */ - rte_eal_remote_launch(test_enqdeq_callback_thread, NULL, - rte_get_next_lcore(-1, 1, 0)); + TEST_ASSERT_SUCCESS(test_enqdeq_callback_null_cipher(), "Crypto processing failed"); - /* Wait until reader exited. */ - rte_eal_mp_wait_lcore(); + /* Wait until callback not called. */ + while (!deq_cb_called && (j++ < 10)) + rte_delay_ms(10); /* Test with invalid crypto device */ TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback( @@ -14782,6 +14852,8 @@ test_deq_callback_setup(void) "qp %u on cryptodev %u", qp_id, ts_params->valid_devs[0]); + TEST_ASSERT(deq_cb_called == true, "Crypto dequeue callback not called"); + return TEST_SUCCESS; } -- 2.25.1