test/event_crypto: use crypto adapter enqueue API
authorShijith Thotton <sthotton@marvell.com>
Thu, 15 Apr 2021 09:13:51 +0000 (14:43 +0530)
committerJerin Jacob <jerinj@marvell.com>
Sat, 17 Apr 2021 16:50:06 +0000 (18:50 +0200)
Use rte_event_crypto_adapter_enqueue() API to enqueue events to crypto
adapter if forward mode is supported in driver.

Signed-off-by: Shijith Thotton <sthotton@marvell.com>
Acked-by: Abhinandan Gujjar <abhinandan.gujjar@intel.com>
app/test/test_event_crypto_adapter.c

index 335211c..f689bc1 100644 (file)
@@ -64,6 +64,7 @@ struct event_crypto_adapter_test_params {
        struct rte_mempool *session_priv_mpool;
        struct rte_cryptodev_config *config;
        uint8_t crypto_event_port_id;
+       uint8_t internal_port_op_fwd;
 };
 
 struct rte_event response_info = {
@@ -110,9 +111,12 @@ send_recv_ev(struct rte_event *ev)
        struct rte_event recv_ev;
        int ret;
 
-       ret = rte_event_enqueue_burst(evdev, TEST_APP_PORT_ID, ev, NUM);
-       TEST_ASSERT_EQUAL(ret, NUM,
-                         "Failed to send event to crypto adapter\n");
+       if (params.internal_port_op_fwd)
+               ret = rte_event_crypto_adapter_enqueue(evdev, TEST_APP_PORT_ID,
+                                                      ev, NUM);
+       else
+               ret = rte_event_enqueue_burst(evdev, TEST_APP_PORT_ID, ev, NUM);
+       TEST_ASSERT_EQUAL(ret, NUM, "Failed to send event to crypto adapter\n");
 
        while (rte_event_dequeue_burst(evdev,
                        TEST_APP_PORT_ID, &recv_ev, NUM, 0) == 0)
@@ -747,9 +751,12 @@ configure_event_crypto_adapter(enum rte_event_crypto_adapter_mode mode)
            !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND))
                goto adapter_create;
 
-       if ((mode == RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD) &&
-           !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))
-               return -ENOTSUP;
+       if (mode == RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD) {
+               if (cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD)
+                       params.internal_port_op_fwd = 1;
+               else
+                       return -ENOTSUP;
+       }
 
        if ((mode == RTE_EVENT_CRYPTO_ADAPTER_OP_NEW) &&
            !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
@@ -771,9 +778,11 @@ adapter_create:
 
        TEST_ASSERT_SUCCESS(ret, "Failed to add queue pair\n");
 
-       ret = rte_event_crypto_adapter_event_port_get(TEST_ADAPTER_ID,
-                               &params.crypto_event_port_id);
-       TEST_ASSERT_SUCCESS(ret, "Failed to get event port\n");
+       if (!params.internal_port_op_fwd) {
+               ret = rte_event_crypto_adapter_event_port_get(TEST_ADAPTER_ID,
+                                               &params.crypto_event_port_id);
+               TEST_ASSERT_SUCCESS(ret, "Failed to get event port\n");
+       }
 
        return TEST_SUCCESS;
 }
@@ -809,15 +818,15 @@ test_crypto_adapter_conf(enum rte_event_crypto_adapter_mode mode)
 
        if (!crypto_adapter_setup_done) {
                ret = configure_event_crypto_adapter(mode);
-               if (!ret) {
+               if (ret)
+                       return ret;
+               if (!params.internal_port_op_fwd) {
                        qid = TEST_CRYPTO_EV_QUEUE_ID;
                        ret = rte_event_port_link(evdev,
                                params.crypto_event_port_id, &qid, NULL, 1);
                        TEST_ASSERT(ret >= 0, "Failed to link queue %d "
                                        "port=%u\n", qid,
                                        params.crypto_event_port_id);
-               } else {
-                       return ret;
                }
                crypto_adapter_setup_done = 1;
        }