* [PATCH] test/crypto: fix enqueue dequeue callback case @ 2024-05-22 13:48 Akhil Goyal 2024-05-23 12:48 ` [PATCH v2] " Akhil Goyal 0 siblings, 1 reply; 6+ messages in thread From: Akhil Goyal @ 2024-05-22 13:48 UTC (permalink / raw) To: dev Cc: ganapati.kundapura, abhinandan.gujjar, fanzhang.oss, anoobj, Akhil Goyal, stable 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, used a function test_AES_CBC_HMAC_SHA1_encrypt_digest() which is normally supported by most of the PMDs. 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 <gakhil@marvell.com> --- app/test/test_cryptodev.c | 49 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index f2d249f6b8..380238816b 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, @@ -14671,6 +14673,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; } @@ -14684,6 +14687,7 @@ 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; } @@ -14698,7 +14702,7 @@ test_enqdeq_callback_thread(void *arg) /* DP thread calls rte_cryptodev_enqueue_burst()/ * rte_cryptodev_dequeue_burst() and invokes callback. */ - test_null_burst_operation(); + test_AES_CBC_HMAC_SHA1_encrypt_digest(); return 0; } @@ -14706,6 +14710,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 @@ -14713,6 +14718,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_SHA1_HMAC; + 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_AES_CBC; + 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]); @@ -14736,6 +14754,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); @@ -14775,6 +14794,10 @@ test_enq_callback_setup(void) /* 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( RTE_CRYPTO_MAX_DEVS, qp_id, cb), @@ -14798,6 +14821,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; } @@ -14805,6 +14830,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 @@ -14812,7 +14838,21 @@ test_deq_callback_setup(void) struct rte_cryptodev_cb *cb; uint16_t qp_id = 0; + int j = 0; + /* The callbacks are tested by sending AES-CBC-SHA1-HMAC ops, + * hence the PMD should support these algos. */ + cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH; + cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC; + 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_AES_CBC; + 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]); @@ -14835,6 +14875,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); @@ -14874,6 +14915,10 @@ test_deq_callback_setup(void) /* 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( RTE_CRYPTO_MAX_DEVS, qp_id, cb), @@ -14897,6 +14942,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 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] test/crypto: fix enqueue dequeue callback case 2024-05-22 13:48 [PATCH] test/crypto: fix enqueue dequeue callback case Akhil Goyal @ 2024-05-23 12:48 ` Akhil Goyal 2024-05-23 17:30 ` Kundapura, Ganapati 2024-05-24 17:13 ` [PATCH v3] " Akhil Goyal 0 siblings, 2 replies; 6+ messages in thread From: Akhil Goyal @ 2024-05-23 12:48 UTC (permalink / raw) To: dev Cc: ganapati.kundapura, abhinandan.gujjar, fanzhang.oss, anoobj, Akhil Goyal, stable 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, used a function test_AES_CBC_HMAC_SHA1_encrypt_digest() which is normally supported by most of the PMDs. 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 <gakhil@marvell.com> --- app/test/test_cryptodev.c | 48 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index 1703ebccf1..87ffde6a8b 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,6 +14572,7 @@ 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; } @@ -14583,7 +14587,7 @@ test_enqdeq_callback_thread(void *arg) /* DP thread calls rte_cryptodev_enqueue_burst()/ * rte_cryptodev_dequeue_burst() and invokes callback. */ - test_null_burst_operation(); + test_AES_CBC_HMAC_SHA1_encrypt_digest(); return 0; } @@ -14591,6 +14595,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 +14603,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_SHA1_HMAC; + 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_AES_CBC; + 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 +14639,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); @@ -14660,6 +14679,10 @@ test_enq_callback_setup(void) /* 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( RTE_CRYPTO_MAX_DEVS, qp_id, cb), @@ -14683,6 +14706,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 +14715,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 +14723,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_SHA1_HMAC; + 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_AES_CBC; + 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 +14759,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); @@ -14759,6 +14799,10 @@ test_deq_callback_setup(void) /* 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( RTE_CRYPTO_MAX_DEVS, qp_id, cb), @@ -14782,6 +14826,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 ^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH v2] test/crypto: fix enqueue dequeue callback case 2024-05-23 12:48 ` [PATCH v2] " Akhil Goyal @ 2024-05-23 17:30 ` Kundapura, Ganapati 2024-05-24 17:13 ` [PATCH v3] " Akhil Goyal 1 sibling, 0 replies; 6+ messages in thread From: Kundapura, Ganapati @ 2024-05-23 17:30 UTC (permalink / raw) To: Akhil Goyal, dev; +Cc: Gujjar, Abhinandan S, fanzhang.oss, anoobj, stable Hi, > -----Original Message----- > From: Akhil Goyal <gakhil@marvell.com> > Sent: Thursday, May 23, 2024 6:19 PM > To: dev@dpdk.org > Cc: Kundapura, Ganapati <ganapati.kundapura@intel.com>; Gujjar, > Abhinandan S <abhinandan.gujjar@intel.com>; fanzhang.oss@gmail.com; > anoobj@marvell.com; Akhil Goyal <gakhil@marvell.com>; stable@dpdk.org > Subject: [PATCH v2] test/crypto: fix enqueue dequeue callback case > > 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, used a function test_AES_CBC_HMAC_SHA1_encrypt_digest() > which is normally supported by most of the PMDs. > 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 <gakhil@marvell.com> > --- > app/test/test_cryptodev.c | 48 > ++++++++++++++++++++++++++++++++++++++- > 1 file changed, 47 insertions(+), 1 deletion(-) > > diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index > 1703ebccf1..87ffde6a8b 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,6 +14572,7 @@ 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; > } > @@ -14583,7 +14587,7 @@ test_enqdeq_callback_thread(void *arg) > /* DP thread calls rte_cryptodev_enqueue_burst()/ > * rte_cryptodev_dequeue_burst() and invokes callback. > */ > - test_null_burst_operation(); > + test_AES_CBC_HMAC_SHA1_encrypt_digest(); With this change cryptodev_null_autotest is skipping test_enq_callback_setup and test_deq_callback_setup tests as NULL PMD doesn't support RTE_CRYPTO_SYM_XFORM_AUTH and RTE_CRYPTO_AUTH_SHA1_HMAC capabilities. Would be better if it works for both NULL PMD and other PMD's. > return 0; > } > > @@ -14591,6 +14595,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 > +14603,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_SHA1_HMAC; > + 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_AES_CBC; > + 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 +14639,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); > @@ -14660,6 +14679,10 @@ test_enq_callback_setup(void) > /* 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( > RTE_CRYPTO_MAX_DEVS, qp_id, cb), > @@ -14683,6 +14706,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 +14715,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 > +14723,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_SHA1_HMAC; > + 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_AES_CBC; > + 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 +14759,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); > @@ -14759,6 +14799,10 @@ test_deq_callback_setup(void) > /* 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( > RTE_CRYPTO_MAX_DEVS, qp_id, cb), > @@ -14782,6 +14826,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 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3] test/crypto: fix enqueue dequeue callback case 2024-05-23 12:48 ` [PATCH v2] " Akhil Goyal 2024-05-23 17:30 ` Kundapura, Ganapati @ 2024-05-24 17:13 ` Akhil Goyal 2024-05-27 10:48 ` Kundapura, Ganapati 1 sibling, 1 reply; 6+ messages in thread From: Akhil Goyal @ 2024-05-24 17:13 UTC (permalink / raw) To: dev Cc: ganapati.kundapura, abhinandan.gujjar, fanzhang.oss, anoobj, Akhil Goyal, stable 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 <gakhil@marvell.com> --- -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 ^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH v3] test/crypto: fix enqueue dequeue callback case 2024-05-24 17:13 ` [PATCH v3] " Akhil Goyal @ 2024-05-27 10:48 ` Kundapura, Ganapati 2024-05-30 9:27 ` Akhil Goyal 0 siblings, 1 reply; 6+ messages in thread From: Kundapura, Ganapati @ 2024-05-27 10:48 UTC (permalink / raw) To: Akhil Goyal, dev; +Cc: Gujjar, Abhinandan S, fanzhang.oss, anoobj, stable Tested cryptodev_qat_autotest and cryptodev_null_autotest this patch along with https://patches.dpdk.org/project/dpdk/patch/20240416081222.3002268-1-ganapati.kundapura@intel.com/, callbacks are getting called for both NULL pmd and qat pmd. Acked-by: Ganapati Kundapura <ganapati.kundapura@intel.com> Thanks, Ganapati > -----Original Message----- > From: Akhil Goyal <gakhil@marvell.com> > Sent: Friday, May 24, 2024 10:43 PM > To: dev@dpdk.org > Cc: Kundapura, Ganapati <ganapati.kundapura@intel.com>; Gujjar, > Abhinandan S <abhinandan.gujjar@intel.com>; fanzhang.oss@gmail.com; > anoobj@marvell.com; Akhil Goyal <gakhil@marvell.com>; stable@dpdk.org > Subject: [PATCH v3] test/crypto: fix enqueue dequeue callback case > > 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 <gakhil@marvell.com> > --- > -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 ^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH v3] test/crypto: fix enqueue dequeue callback case 2024-05-27 10:48 ` Kundapura, Ganapati @ 2024-05-30 9:27 ` Akhil Goyal 0 siblings, 0 replies; 6+ messages in thread From: Akhil Goyal @ 2024-05-30 9:27 UTC (permalink / raw) To: Kundapura, Ganapati, dev Cc: Gujjar, Abhinandan S, fanzhang.oss, Anoob Joseph, stable > Tested cryptodev_qat_autotest and cryptodev_null_autotest this patch along > with https://patches.dpdk.org/project/dpdk/patch/20240416081222.3002268-1-ganapati.kundapura@intel.com/ , callbacks are getting called for both NULL pmd and qat > pmd. > > Acked-by: Ganapati Kundapura <ganapati.kundapura@intel.com> Applied to dpdk-next-crypto Fixed a couple of minor typos in comments. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-05-30 9:27 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2024-05-22 13:48 [PATCH] test/crypto: fix enqueue dequeue callback case Akhil Goyal 2024-05-23 12:48 ` [PATCH v2] " Akhil Goyal 2024-05-23 17:30 ` Kundapura, Ganapati 2024-05-24 17:13 ` [PATCH v3] " Akhil Goyal 2024-05-27 10:48 ` Kundapura, Ganapati 2024-05-30 9:27 ` Akhil Goyal
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).