LCOV - code coverage report
Current view: top level - app/test - test_event_crypto_adapter.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 1 560 0.2 %
Date: 2025-03-01 20:23:48 Functions: 1 34 2.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 374 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2018 Intel Corporation.
       3                 :            :  * All rights reserved.
       4                 :            :  */
       5                 :            : 
       6                 :            : #include "test.h"
       7                 :            : #include <string.h>
       8                 :            : #include <rte_common.h>
       9                 :            : #include <rte_malloc.h>
      10                 :            : #include <rte_mempool.h>
      11                 :            : #include <rte_mbuf.h>
      12                 :            : #include <rte_cryptodev.h>
      13                 :            : 
      14                 :            : #ifdef RTE_EXEC_ENV_WINDOWS
      15                 :            : static int
      16                 :            : test_event_crypto_adapter(void)
      17                 :            : {
      18                 :            :         printf("event_crypto_adapter not supported on Windows, skipping test\n");
      19                 :            :         return TEST_SKIPPED;
      20                 :            : }
      21                 :            : 
      22                 :            : #else
      23                 :            : 
      24                 :            : #include <rte_eventdev.h>
      25                 :            : #include <rte_bus_vdev.h>
      26                 :            : #include <rte_service.h>
      27                 :            : #include <rte_event_crypto_adapter.h>
      28                 :            : 
      29                 :            : #define PKT_TRACE                  0
      30                 :            : #define NUM                        1
      31                 :            : #define DEFAULT_NUM_XFORMS        (2)
      32                 :            : #define NUM_MBUFS                 (8191)
      33                 :            : #define MBUF_CACHE_SIZE           (256)
      34                 :            : #define MAXIMUM_IV_LENGTH         (16)
      35                 :            : #define DEFAULT_NUM_OPS_INFLIGHT   1024
      36                 :            : #define MAX_NB_SESSIONS            4
      37                 :            : #define TEST_APP_PORT_ID           0
      38                 :            : #define TEST_APP_EV_QUEUE_ID       0
      39                 :            : #define TEST_APP_EV_PRIORITY       0
      40                 :            : #define TEST_APP_EV_FLOWID         0xAABB
      41                 :            : #define TEST_CRYPTO_EV_QUEUE_ID    1
      42                 :            : #define TEST_ADAPTER_ID            0
      43                 :            : #define TEST_CDEV_ID               0
      44                 :            : #define TEST_CDEV_QP_ID            0
      45                 :            : #define PACKET_LENGTH              64
      46                 :            : #define NB_TEST_PORTS              1
      47                 :            : #define NB_TEST_QUEUES             2
      48                 :            : #define NUM_CORES                  1
      49                 :            : #define CRYPTODEV_NAME_NULL_PMD    crypto_null
      50                 :            : 
      51                 :            : #define MBUF_SIZE              (sizeof(struct rte_mbuf) + \
      52                 :            :                                 RTE_PKTMBUF_HEADROOM + PACKET_LENGTH)
      53                 :            : #define IV_OFFSET              (sizeof(struct rte_crypto_op) + \
      54                 :            :                                 sizeof(struct rte_crypto_sym_op) + \
      55                 :            :                                 DEFAULT_NUM_XFORMS * \
      56                 :            :                                 sizeof(struct rte_crypto_sym_xform))
      57                 :            : 
      58                 :            : /* Handle log statements in same manner as test macros */
      59                 :            : #define LOG_DBG(...)    RTE_LOG(DEBUG, EAL, __VA_ARGS__)
      60                 :            : 
      61                 :            : static const uint8_t text_64B[] = {
      62                 :            :         0x05, 0x15, 0x77, 0x32, 0xc9, 0x66, 0x91, 0x50,
      63                 :            :         0x93, 0x9f, 0xbb, 0x4e, 0x2e, 0x5a, 0x02, 0xd0,
      64                 :            :         0x2d, 0x9d, 0x31, 0x5d, 0xc8, 0x9e, 0x86, 0x36,
      65                 :            :         0x54, 0x5c, 0x50, 0xe8, 0x75, 0x54, 0x74, 0x5e,
      66                 :            :         0xd5, 0xa2, 0x84, 0x21, 0x2d, 0xc5, 0xf8, 0x1c,
      67                 :            :         0x55, 0x1a, 0xba, 0x91, 0xce, 0xb5, 0xa3, 0x1e,
      68                 :            :         0x31, 0xbf, 0xe9, 0xa1, 0x97, 0x5c, 0x2b, 0xd6,
      69                 :            :         0x57, 0xa5, 0x9f, 0xab, 0xbd, 0xb0, 0x9b, 0x9c
      70                 :            : };
      71                 :            : #define DATA_SIZE               512
      72                 :            : struct modex_test_data {
      73                 :            :         enum rte_crypto_asym_xform_type xform_type;
      74                 :            :         struct {
      75                 :            :                 uint8_t data[DATA_SIZE];
      76                 :            :                 uint16_t len;
      77                 :            :         } base;
      78                 :            :         struct {
      79                 :            :                 uint8_t data[DATA_SIZE];
      80                 :            :                 uint16_t len;
      81                 :            :         } exponent;
      82                 :            :         struct {
      83                 :            :                 uint8_t data[DATA_SIZE];
      84                 :            :                 uint16_t len;
      85                 :            :         } modulus;
      86                 :            :         struct {
      87                 :            :                 uint8_t data[DATA_SIZE];
      88                 :            :                 uint16_t len;
      89                 :            :         } reminder;
      90                 :            :         uint16_t result_len;
      91                 :            : };
      92                 :            : 
      93                 :            : static struct
      94                 :            : modex_test_data modex_test_case = {
      95                 :            :         .xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX,
      96                 :            :         .base = {
      97                 :            :                 .data = {
      98                 :            :                         0xF8, 0xBA, 0x1A, 0x55, 0xD0, 0x2F, 0x85,
      99                 :            :                         0xAE, 0x96, 0x7B, 0xB6, 0x2F, 0xB6, 0xCD,
     100                 :            :                         0xA8, 0xEB, 0x7E, 0x78, 0xA0, 0x50
     101                 :            :                 },
     102                 :            :                 .len = 20,
     103                 :            :         },
     104                 :            :         .exponent = {
     105                 :            :                 .data = {
     106                 :            :                         0x01, 0x00, 0x01
     107                 :            :                 },
     108                 :            :                 .len = 3,
     109                 :            :         },
     110                 :            :         .reminder = {
     111                 :            :                 .data = {
     112                 :            :                         0x2C, 0x60, 0x75, 0x45, 0x98, 0x9D, 0xE0, 0x72,
     113                 :            :                         0xA0, 0x9D, 0x3A, 0x9E, 0x03, 0x38, 0x73, 0x3C,
     114                 :            :                         0x31, 0x83, 0x04, 0xFE, 0x75, 0x43, 0xE6, 0x17,
     115                 :            :                         0x5C, 0x01, 0x29, 0x51, 0x69, 0x33, 0x62, 0x2D,
     116                 :            :                         0x78, 0xBE, 0xAE, 0xC4, 0xBC, 0xDE, 0x7E, 0x2C,
     117                 :            :                         0x77, 0x84, 0xF2, 0xC5, 0x14, 0xB5, 0x2F, 0xF7,
     118                 :            :                         0xC5, 0x94, 0xEF, 0x86, 0x75, 0x75, 0xB5, 0x11,
     119                 :            :                         0xE5, 0x0E, 0x0A, 0x29, 0x76, 0xE2, 0xEA, 0x32,
     120                 :            :                         0x0E, 0x43, 0x77, 0x7E, 0x2C, 0x27, 0xAC, 0x3B,
     121                 :            :                         0x86, 0xA5, 0xDB, 0xC9, 0x48, 0x40, 0xE8, 0x99,
     122                 :            :                         0x9A, 0x0A, 0x3D, 0xD6, 0x74, 0xFA, 0x2E, 0x2E,
     123                 :            :                         0x5B, 0xAF, 0x8C, 0x99, 0x44, 0x2A, 0x67, 0x38,
     124                 :            :                         0x27, 0x41, 0x59, 0x9D, 0xB8, 0x51, 0xC9, 0xF7,
     125                 :            :                         0x43, 0x61, 0x31, 0x6E, 0xF1, 0x25, 0x38, 0x7F,
     126                 :            :                         0xAE, 0xC6, 0xD0, 0xBB, 0x29, 0x76, 0x3F, 0x46,
     127                 :            :                         0x2E, 0x1B, 0xE4, 0x67, 0x71, 0xE3, 0x87, 0x5A
     128                 :            :                 },
     129                 :            :                 .len = 128,
     130                 :            :         },
     131                 :            :         .modulus = {
     132                 :            :                 .data = {
     133                 :            :                         0xb3, 0xa1, 0xaf, 0xb7, 0x13, 0x08, 0x00, 0x0a,
     134                 :            :                         0x35, 0xdc, 0x2b, 0x20, 0x8d, 0xa1, 0xb5, 0xce,
     135                 :            :                         0x47, 0x8a, 0xc3, 0x80, 0xf4, 0x7d, 0x4a, 0xa2,
     136                 :            :                         0x62, 0xfd, 0x61, 0x7f, 0xb5, 0xa8, 0xde, 0x0a,
     137                 :            :                         0x17, 0x97, 0xa0, 0xbf, 0xdf, 0x56, 0x5a, 0x3d,
     138                 :            :                         0x51, 0x56, 0x4f, 0x70, 0x70, 0x3f, 0x63, 0x6a,
     139                 :            :                         0x44, 0x5b, 0xad, 0x84, 0x0d, 0x3f, 0x27, 0x6e,
     140                 :            :                         0x3b, 0x34, 0x91, 0x60, 0x14, 0xb9, 0xaa, 0x72,
     141                 :            :                         0xfd, 0xa3, 0x64, 0xd2, 0x03, 0xa7, 0x53, 0x87,
     142                 :            :                         0x9e, 0x88, 0x0b, 0xc1, 0x14, 0x93, 0x1a, 0x62,
     143                 :            :                         0xff, 0xb1, 0x5d, 0x74, 0xcd, 0x59, 0x63, 0x18,
     144                 :            :                         0x11, 0x3d, 0x4f, 0xba, 0x75, 0xd4, 0x33, 0x4e,
     145                 :            :                         0x23, 0x6b, 0x7b, 0x57, 0x44, 0xe1, 0xd3, 0x03,
     146                 :            :                         0x13, 0xa6, 0xf0, 0x8b, 0x60, 0xb0, 0x9e, 0xee,
     147                 :            :                         0x75, 0x08, 0x9d, 0x71, 0x63, 0x13, 0xcb, 0xa6,
     148                 :            :                         0x81, 0x92, 0x14, 0x03, 0x22, 0x2d, 0xde, 0x55
     149                 :            :                 },
     150                 :            :                 .len = 128,
     151                 :            :         },
     152                 :            :         .result_len = 128,
     153                 :            : };
     154                 :            : 
     155                 :            : struct event_crypto_adapter_test_params {
     156                 :            :         struct rte_mempool *mbuf_pool;
     157                 :            :         struct rte_mempool *op_mpool;
     158                 :            :         struct rte_mempool *asym_op_mpool;
     159                 :            :         struct rte_mempool *session_mpool;
     160                 :            :         struct rte_mempool *asym_sess_mpool;
     161                 :            :         struct rte_cryptodev_config *config;
     162                 :            :         uint8_t crypto_event_port_id;
     163                 :            :         uint8_t internal_port_op_fwd;
     164                 :            : };
     165                 :            : 
     166                 :            : struct rte_event response_info = {
     167                 :            :         .queue_id = TEST_APP_EV_QUEUE_ID,
     168                 :            :         .sched_type = RTE_SCHED_TYPE_ATOMIC,
     169                 :            :         .flow_id = TEST_APP_EV_FLOWID,
     170                 :            :         .priority = TEST_APP_EV_PRIORITY
     171                 :            : };
     172                 :            : 
     173                 :            : struct rte_event_crypto_request request_info = {
     174                 :            :         .cdev_id = TEST_CDEV_ID,
     175                 :            :         .queue_pair_id = TEST_CDEV_QP_ID
     176                 :            : };
     177                 :            : 
     178                 :            : static struct event_crypto_adapter_test_params params;
     179                 :            : static uint8_t crypto_adapter_setup_done;
     180                 :            : static uint32_t slcore_id;
     181                 :            : static int evdev;
     182                 :            : 
     183                 :            : static struct rte_mbuf *
     184                 :          0 : alloc_fill_mbuf(struct rte_mempool *mpool, const uint8_t *data,
     185                 :            :                 size_t len, uint8_t blocksize)
     186                 :            : {
     187                 :          0 :         struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
     188         [ #  # ]:          0 :         size_t t_len = len - (blocksize ? (len % blocksize) : 0);
     189                 :            : 
     190         [ #  # ]:          0 :         if (m) {
     191                 :          0 :                 char *dst = rte_pktmbuf_append(m, t_len);
     192                 :            : 
     193         [ #  # ]:          0 :                 if (!dst) {
     194                 :          0 :                         rte_pktmbuf_free(m);
     195                 :          0 :                         return NULL;
     196                 :            :                 }
     197                 :            : 
     198                 :            :                 rte_memcpy(dst, (const void *)data, t_len);
     199                 :            :         }
     200                 :            :         return m;
     201                 :            : }
     202                 :            : 
     203                 :            : static int
     204                 :          0 : send_recv_ev(struct rte_event *ev)
     205                 :            : {
     206                 :            :         struct rte_crypto_op *op;
     207                 :            :         struct rte_event recv_ev;
     208                 :            :         int ret;
     209                 :            : 
     210         [ #  # ]:          0 :         if (params.internal_port_op_fwd)
     211                 :          0 :                 ret = rte_event_crypto_adapter_enqueue(evdev, TEST_APP_PORT_ID,
     212                 :            :                                                        ev, NUM);
     213                 :            :         else
     214                 :          0 :                 ret = rte_event_enqueue_burst(evdev, TEST_APP_PORT_ID, ev, NUM);
     215         [ #  # ]:          0 :         TEST_ASSERT_EQUAL(ret, NUM, "Failed to send event to crypto adapter\n");
     216                 :            : 
     217                 :          0 :         while (rte_event_dequeue_burst(evdev,
     218         [ #  # ]:          0 :                         TEST_APP_PORT_ID, &recv_ev, NUM, 0) == 0)
     219                 :            :                 rte_pause();
     220                 :            : 
     221                 :          0 :         op = recv_ev.event_ptr;
     222         [ #  # ]:          0 :         if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
     223                 :            : #if PKT_TRACE
     224                 :            :                 struct rte_mbuf *m = op->sym->m_src;
     225                 :            :                 rte_pktmbuf_dump(stdout, m, rte_pktmbuf_pkt_len(m));
     226                 :            : #endif
     227                 :          0 :                 rte_pktmbuf_free(op->sym->m_src);
     228                 :            :         } else {
     229                 :            :                 uint8_t *data_expected = NULL, *data_received = NULL;
     230                 :            :                 uint32_t data_size;
     231                 :            : 
     232                 :            :                 data_expected = modex_test_case.reminder.data;
     233                 :          0 :                 data_received = op->asym->modex.result.data;
     234                 :          0 :                 data_size = op->asym->modex.result.length;
     235                 :          0 :                 ret = memcmp(data_expected, data_received, data_size);
     236         [ #  # ]:          0 :                 TEST_ASSERT_EQUAL(ret, 0,
     237                 :            :                                 "Data mismatch for asym crypto adapter\n");
     238                 :          0 :                 rte_free(op->asym->modex.result.data);
     239                 :            :         }
     240                 :          0 :         rte_crypto_op_free(op);
     241                 :            : 
     242                 :          0 :         return TEST_SUCCESS;
     243                 :            : }
     244                 :            : 
     245                 :            : static int
     246                 :          0 : test_crypto_adapter_stats(void)
     247                 :            : {
     248                 :            :         struct rte_event_crypto_adapter_stats stats;
     249                 :            : 
     250                 :          0 :         rte_event_crypto_adapter_stats_get(TEST_ADAPTER_ID, &stats);
     251                 :            :         printf(" +------------------------------------------------------+\n");
     252                 :            :         printf(" + Crypto adapter stats for instance %u:\n", TEST_ADAPTER_ID);
     253                 :          0 :         printf(" + Event port poll count          %" PRIx64 "\n",
     254                 :            :                 stats.event_poll_count);
     255                 :          0 :         printf(" + Event dequeue count            %" PRIx64 "\n",
     256                 :            :                 stats.event_deq_count);
     257                 :          0 :         printf(" + Cryptodev enqueue count        %" PRIx64 "\n",
     258                 :            :                 stats.crypto_enq_count);
     259                 :          0 :         printf(" + Cryptodev enqueue failed count %" PRIx64 "\n",
     260                 :            :                 stats.crypto_enq_fail);
     261                 :          0 :         printf(" + Cryptodev dequeue count        %" PRIx64 "\n",
     262                 :            :                 stats.crypto_deq_count);
     263                 :          0 :         printf(" + Event enqueue count            %" PRIx64 "\n",
     264                 :            :                 stats.event_enq_count);
     265                 :          0 :         printf(" + Event enqueue retry count      %" PRIx64 "\n",
     266                 :            :                 stats.event_enq_retry_count);
     267                 :          0 :         printf(" + Event enqueue fail count       %" PRIx64 "\n",
     268                 :            :                 stats.event_enq_fail_count);
     269                 :            :         printf(" +------------------------------------------------------+\n");
     270                 :            : 
     271                 :          0 :         rte_event_crypto_adapter_stats_reset(TEST_ADAPTER_ID);
     272                 :          0 :         return TEST_SUCCESS;
     273                 :            : }
     274                 :            : 
     275                 :            : static int
     276                 :          0 : test_crypto_adapter_params(void)
     277                 :            : {
     278                 :            :         int err, rc;
     279                 :            :         struct rte_event_crypto_adapter_runtime_params in_params;
     280                 :            :         struct rte_event_crypto_adapter_runtime_params out_params;
     281                 :            :         uint32_t cap;
     282                 :          0 :         struct rte_event_crypto_adapter_queue_conf queue_conf = {
     283                 :            :                 .ev = response_info,
     284                 :            :         };
     285                 :            : 
     286                 :          0 :         err = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID, &cap);
     287         [ #  # ]:          0 :         if (err == -ENOTSUP)
     288                 :            :                 return TEST_SKIPPED;
     289                 :            : 
     290         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(err, "Failed to get adapter capabilities\n");
     291                 :            : 
     292         [ #  # ]:          0 :         if (cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND) {
     293                 :          0 :                 err = rte_event_crypto_adapter_queue_pair_add(TEST_ADAPTER_ID,
     294                 :            :                                 TEST_CDEV_ID, TEST_CDEV_QP_ID, &queue_conf);
     295                 :            :         } else
     296                 :          0 :                 err = rte_event_crypto_adapter_queue_pair_add(TEST_ADAPTER_ID,
     297                 :            :                                         TEST_CDEV_ID, TEST_CDEV_QP_ID, NULL);
     298                 :            : 
     299         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(err, "Failed to add queue pair\n");
     300                 :            : 
     301                 :          0 :         err = rte_event_crypto_adapter_runtime_params_init(&in_params);
     302         [ #  # ]:          0 :         TEST_ASSERT(err == 0, "Expected 0 got %d", err);
     303                 :          0 :         err = rte_event_crypto_adapter_runtime_params_init(&out_params);
     304         [ #  # ]:          0 :         TEST_ASSERT(err == 0, "Expected 0 got %d", err);
     305                 :            : 
     306                 :            :         /* Case 1: Get the default value of mbufs processed by adapter */
     307                 :          0 :         err = rte_event_crypto_adapter_runtime_params_get(TEST_ADAPTER_ID,
     308                 :            :                                                           &out_params);
     309         [ #  # ]:          0 :         if (err == -ENOTSUP) {
     310                 :            :                 rc = TEST_SKIPPED;
     311                 :          0 :                 goto queue_pair_del;
     312                 :            :         }
     313         [ #  # ]:          0 :         TEST_ASSERT(err == 0, "Expected 0 got %d", err);
     314                 :            : 
     315                 :            :         /* Case 2: Set max_nb = 32 (=BATCH_SEIZE) */
     316                 :          0 :         in_params.max_nb = 32;
     317                 :            : 
     318                 :          0 :         err = rte_event_crypto_adapter_runtime_params_set(TEST_ADAPTER_ID,
     319                 :            :                                                           &in_params);
     320         [ #  # ]:          0 :         TEST_ASSERT(err == 0, "Expected 0 got %d", err);
     321                 :            : 
     322                 :          0 :         err = rte_event_crypto_adapter_runtime_params_get(TEST_ADAPTER_ID,
     323                 :            :                                                           &out_params);
     324         [ #  # ]:          0 :         TEST_ASSERT(err == 0, "Expected 0 got %d", err);
     325         [ #  # ]:          0 :         TEST_ASSERT(in_params.max_nb == out_params.max_nb, "Expected %u got %u",
     326                 :            :                     in_params.max_nb, out_params.max_nb);
     327                 :            : 
     328                 :            :         /* Case 3: Set max_nb = 192 */
     329                 :          0 :         in_params.max_nb = 192;
     330                 :            : 
     331                 :          0 :         err = rte_event_crypto_adapter_runtime_params_set(TEST_ADAPTER_ID,
     332                 :            :                                                           &in_params);
     333         [ #  # ]:          0 :         TEST_ASSERT(err == 0, "Expected 0 got %d", err);
     334                 :            : 
     335                 :          0 :         err = rte_event_crypto_adapter_runtime_params_get(TEST_ADAPTER_ID,
     336                 :            :                                                           &out_params);
     337         [ #  # ]:          0 :         TEST_ASSERT(err == 0, "Expected 0 got %d", err);
     338         [ #  # ]:          0 :         TEST_ASSERT(in_params.max_nb == out_params.max_nb, "Expected %u got %u",
     339                 :            :                     in_params.max_nb, out_params.max_nb);
     340                 :            : 
     341                 :            :         /* Case 4: Set max_nb = 256 */
     342                 :          0 :         in_params.max_nb = 256;
     343                 :            : 
     344                 :          0 :         err = rte_event_crypto_adapter_runtime_params_set(TEST_ADAPTER_ID,
     345                 :            :                                                           &in_params);
     346         [ #  # ]:          0 :         TEST_ASSERT(err == 0, "Expected 0 got %d", err);
     347                 :            : 
     348                 :          0 :         err = rte_event_crypto_adapter_runtime_params_get(TEST_ADAPTER_ID,
     349                 :            :                                                           &out_params);
     350         [ #  # ]:          0 :         TEST_ASSERT(err == 0, "Expected 0 got %d", err);
     351         [ #  # ]:          0 :         TEST_ASSERT(in_params.max_nb == out_params.max_nb, "Expected %u got %u",
     352                 :            :                     in_params.max_nb, out_params.max_nb);
     353                 :            : 
     354                 :            :         /* Case 5: Set max_nb = 30(<BATCH_SIZE) */
     355                 :          0 :         in_params.max_nb = 30;
     356                 :            : 
     357                 :          0 :         err = rte_event_crypto_adapter_runtime_params_set(TEST_ADAPTER_ID,
     358                 :            :                                                           &in_params);
     359         [ #  # ]:          0 :         TEST_ASSERT(err == 0, "Expected 0 got %d", err);
     360                 :            : 
     361                 :          0 :         err = rte_event_crypto_adapter_runtime_params_get(TEST_ADAPTER_ID,
     362                 :            :                                                           &out_params);
     363         [ #  # ]:          0 :         TEST_ASSERT(err == 0, "Expected 0 got %d", err);
     364         [ #  # ]:          0 :         TEST_ASSERT(in_params.max_nb == out_params.max_nb, "Expected %u got %u",
     365                 :            :                     in_params.max_nb, out_params.max_nb);
     366                 :            : 
     367                 :            :         /* Case 6: Set max_nb = 512 */
     368                 :          0 :         in_params.max_nb = 512;
     369                 :            : 
     370                 :          0 :         err = rte_event_crypto_adapter_runtime_params_set(TEST_ADAPTER_ID,
     371                 :            :                                                           &in_params);
     372         [ #  # ]:          0 :         TEST_ASSERT(err == 0, "Expected 0 got %d", err);
     373                 :            : 
     374                 :          0 :         err = rte_event_crypto_adapter_runtime_params_get(TEST_ADAPTER_ID,
     375                 :            :                                                           &out_params);
     376         [ #  # ]:          0 :         TEST_ASSERT(err == 0, "Expected 0 got %d", err);
     377         [ #  # ]:          0 :         TEST_ASSERT(in_params.max_nb == out_params.max_nb, "Expected %u got %u",
     378                 :            :                     in_params.max_nb, out_params.max_nb);
     379                 :            : 
     380                 :            :         rc = TEST_SUCCESS;
     381                 :          0 : queue_pair_del:
     382                 :          0 :         err = rte_event_crypto_adapter_queue_pair_del(TEST_ADAPTER_ID,
     383                 :            :                                         TEST_CDEV_ID, TEST_CDEV_QP_ID);
     384         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(err, "Failed to delete add queue pair\n");
     385                 :            : 
     386                 :            :         return rc;
     387                 :            : }
     388                 :            : 
     389                 :            : static int
     390                 :          0 : test_op_forward_mode(uint8_t session_less)
     391                 :            : {
     392                 :            :         struct rte_crypto_sym_xform cipher_xform;
     393                 :            :         union rte_event_crypto_metadata m_data;
     394                 :            :         struct rte_crypto_sym_op *sym_op;
     395                 :            :         struct rte_crypto_op *op;
     396                 :            :         struct rte_mbuf *m;
     397                 :            :         struct rte_event ev;
     398                 :            :         uint32_t cap;
     399                 :            :         void *sess;
     400                 :            :         int ret;
     401                 :            : 
     402                 :            :         memset(&m_data, 0, sizeof(m_data));
     403                 :            : 
     404                 :          0 :         m = alloc_fill_mbuf(params.mbuf_pool, text_64B, PACKET_LENGTH, 0);
     405         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf!\n");
     406                 :            : #if PKT_TRACE
     407                 :            :         rte_pktmbuf_dump(stdout, m, rte_pktmbuf_pkt_len(m));
     408                 :            : #endif
     409                 :            :         /* Setup Cipher Parameters */
     410                 :          0 :         cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
     411                 :          0 :         cipher_xform.next = NULL;
     412                 :          0 :         cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
     413                 :          0 :         cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
     414                 :            : 
     415                 :          0 :         op = rte_crypto_op_alloc(params.op_mpool,
     416                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
     417         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(op,
     418                 :            :                 "Failed to allocate symmetric crypto operation struct\n");
     419                 :            : 
     420                 :            :         sym_op = op->sym;
     421                 :            : 
     422         [ #  # ]:          0 :         if (!session_less) {
     423                 :          0 :                 sess = rte_cryptodev_sym_session_create(TEST_CDEV_ID,
     424                 :            :                                 &cipher_xform, params.session_mpool);
     425         [ #  # ]:          0 :                 TEST_ASSERT_NOT_NULL(sess, "Session creation failed\n");
     426                 :            : 
     427                 :          0 :                 ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID,
     428                 :            :                                                         &cap);
     429         [ #  # ]:          0 :                 TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
     430                 :            : 
     431         [ #  # ]:          0 :                 if (cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA) {
     432                 :            :                         /* Fill in private user data information */
     433                 :          0 :                         m_data.request_info.cdev_id = request_info.cdev_id;
     434                 :          0 :                         m_data.request_info.queue_pair_id =
     435                 :          0 :                                 request_info.queue_pair_id;
     436                 :          0 :                         m_data.response_info.event = response_info.event;
     437                 :          0 :                         rte_cryptodev_session_event_mdata_set(TEST_CDEV_ID,
     438                 :            :                                         sess, RTE_CRYPTO_OP_TYPE_SYMMETRIC,
     439                 :            :                                         RTE_CRYPTO_OP_WITH_SESSION,
     440                 :            :                                         &m_data, sizeof(m_data));
     441                 :            :                 }
     442                 :            : 
     443                 :            :                 rte_crypto_op_attach_sym_session(op, sess);
     444                 :            :         } else {
     445                 :            :                 struct rte_crypto_sym_xform *first_xform;
     446                 :            : 
     447                 :          0 :                 rte_crypto_op_sym_xforms_alloc(op, NUM);
     448                 :          0 :                 op->sess_type = RTE_CRYPTO_OP_SESSIONLESS;
     449                 :            :                 first_xform = &cipher_xform;
     450                 :          0 :                 sym_op->xform = first_xform;
     451                 :            :                 uint32_t len = IV_OFFSET + MAXIMUM_IV_LENGTH;
     452                 :          0 :                 op->private_data_offset = len;
     453                 :            :                 /* Fill in private data information */
     454                 :          0 :                 m_data.request_info.cdev_id = request_info.cdev_id;
     455                 :          0 :                 m_data.request_info.queue_pair_id = request_info.queue_pair_id;
     456                 :          0 :                 m_data.response_info.event = response_info.event;
     457         [ #  # ]:          0 :                 rte_memcpy((uint8_t *)op + len, &m_data, sizeof(m_data));
     458                 :            :         }
     459                 :            : 
     460                 :          0 :         sym_op->m_src = m;
     461                 :          0 :         sym_op->cipher.data.offset = 0;
     462                 :          0 :         sym_op->cipher.data.length = PACKET_LENGTH;
     463                 :            : 
     464                 :            :         /* Fill in event info and update event_ptr with rte_crypto_op */
     465                 :            :         memset(&ev, 0, sizeof(ev));
     466                 :          0 :         ev.queue_id = TEST_CRYPTO_EV_QUEUE_ID;
     467                 :          0 :         ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
     468                 :          0 :         ev.flow_id = 0xAABB;
     469                 :          0 :         ev.event_ptr = op;
     470                 :            : 
     471                 :          0 :         ret = send_recv_ev(&ev);
     472         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(ret, "Failed to send/receive event to "
     473                 :            :                                 "crypto adapter\n");
     474                 :            : 
     475                 :          0 :         test_crypto_adapter_stats();
     476                 :            : 
     477                 :          0 :         return TEST_SUCCESS;
     478                 :            : }
     479                 :            : 
     480                 :            : static int
     481                 :          0 : map_adapter_service_core(void)
     482                 :            : {
     483                 :            :         uint32_t adapter_service_id;
     484                 :            :         int ret;
     485                 :            : 
     486         [ #  # ]:          0 :         if (rte_event_crypto_adapter_service_id_get(TEST_ADAPTER_ID,
     487                 :            :                                                 &adapter_service_id) == 0) {
     488                 :            :                 uint32_t core_list[NUM_CORES];
     489                 :            : 
     490                 :          0 :                 ret = rte_service_lcore_list(core_list, NUM_CORES);
     491         [ #  # ]:          0 :                 TEST_ASSERT(ret >= 0, "Failed to get service core list!");
     492                 :            : 
     493         [ #  # ]:          0 :                 if (core_list[0] != slcore_id) {
     494         [ #  # ]:          0 :                         TEST_ASSERT_SUCCESS(rte_service_lcore_add(slcore_id),
     495                 :            :                                                 "Failed to add service core");
     496         [ #  # ]:          0 :                         TEST_ASSERT_SUCCESS(rte_service_lcore_start(slcore_id),
     497                 :            :                                                 "Failed to start service core");
     498                 :            :                 }
     499                 :            : 
     500         [ #  # ]:          0 :                 TEST_ASSERT_SUCCESS(rte_service_map_lcore_set(
     501                 :            :                                         adapter_service_id, slcore_id, 1),
     502                 :            :                                         "Failed to map adapter service");
     503                 :            :         }
     504                 :            : 
     505                 :            :         return TEST_SUCCESS;
     506                 :            : }
     507                 :            : 
     508                 :            : static int
     509                 :          0 : test_sessionless_with_op_forward_mode(void)
     510                 :            : {
     511                 :            :         uint32_t cap;
     512                 :            :         int ret;
     513                 :            : 
     514                 :          0 :         ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID, &cap);
     515         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
     516                 :            : 
     517         [ #  # ]:          0 :         if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD) &&
     518                 :            :             !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
     519                 :          0 :                 map_adapter_service_core();
     520                 :            :         else {
     521         [ #  # ]:          0 :                 if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))
     522                 :            :                         return TEST_SKIPPED;
     523                 :            :         }
     524                 :            : 
     525         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(rte_event_crypto_adapter_start(TEST_ADAPTER_ID),
     526                 :            :                                 "Failed to start event crypto adapter");
     527                 :            : 
     528                 :          0 :         ret = test_op_forward_mode(1);
     529         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(ret, "Sessionless - FORWARD mode test failed\n");
     530                 :            :         return TEST_SUCCESS;
     531                 :            : }
     532                 :            : 
     533                 :            : static int
     534                 :          0 : test_session_with_op_forward_mode(void)
     535                 :            : {
     536                 :            :         uint32_t cap;
     537                 :            :         int ret;
     538                 :            : 
     539                 :          0 :         ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID, &cap);
     540         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
     541                 :            : 
     542         [ #  # ]:          0 :         if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD) &&
     543                 :            :             !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
     544                 :          0 :                 map_adapter_service_core();
     545                 :            :         else {
     546         [ #  # ]:          0 :                 if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))
     547                 :            :                         return TEST_SKIPPED;
     548                 :            :         }
     549                 :            : 
     550         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(rte_event_crypto_adapter_start(TEST_ADAPTER_ID
     551                 :            :                                 ), "Failed to start event crypto adapter");
     552                 :            : 
     553                 :          0 :         ret = test_op_forward_mode(0);
     554         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(ret, "Session based - FORWARD mode test failed\n");
     555                 :            :         return TEST_SUCCESS;
     556                 :            : }
     557                 :            : 
     558                 :            : static int
     559                 :          0 : test_asym_op_forward_mode(uint8_t session_less)
     560                 :            : {
     561                 :            :         const struct rte_cryptodev_asymmetric_xform_capability *capability;
     562                 :            :         struct rte_cryptodev_asym_capability_idx cap_idx;
     563                 :            :         struct rte_crypto_asym_xform xform_tc;
     564                 :            :         union rte_event_crypto_metadata m_data;
     565                 :            :         struct rte_cryptodev_info dev_info;
     566                 :            :         struct rte_crypto_asym_op *asym_op;
     567                 :            :         struct rte_crypto_op *op;
     568                 :          0 :         uint8_t input[4096] = {0};
     569                 :            :         uint8_t *result = NULL;
     570                 :            :         struct rte_event ev;
     571                 :          0 :         void *sess = NULL;
     572                 :            :         uint32_t cap;
     573                 :            :         int ret;
     574                 :            : 
     575                 :            :         memset(&m_data, 0, sizeof(m_data));
     576                 :            : 
     577                 :          0 :         rte_cryptodev_info_get(TEST_CDEV_ID, &dev_info);
     578   [ #  #  #  # ]:          0 :         if (session_less && !(dev_info.feature_flags &
     579                 :            :                                 RTE_CRYPTODEV_FF_ASYM_SESSIONLESS)) {
     580                 :          0 :                 RTE_LOG(INFO, USER1,
     581                 :            :                         "Device doesn't support Asym sessionless ops. Test Skipped\n");
     582                 :          0 :                 return TEST_SKIPPED;
     583                 :            :         }
     584                 :            :         /* Setup Cipher Parameters */
     585                 :          0 :         xform_tc.next = NULL;
     586                 :          0 :         xform_tc.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX;
     587                 :          0 :         cap_idx.type = xform_tc.xform_type;
     588                 :          0 :         capability = rte_cryptodev_asym_capability_get(TEST_CDEV_ID, &cap_idx);
     589                 :            : 
     590         [ #  # ]:          0 :         if (capability == NULL) {
     591                 :          0 :                 RTE_LOG(INFO, USER1,
     592                 :            :                         "Device doesn't support MODEX. Test Skipped\n");
     593                 :          0 :                 return TEST_SKIPPED;
     594                 :            :         }
     595                 :            : 
     596                 :          0 :         op = rte_crypto_op_alloc(params.asym_op_mpool,
     597                 :            :                         RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
     598         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(op,
     599                 :            :                 "Failed to allocate asymmetric crypto operation struct\n");
     600                 :            : 
     601                 :            :         asym_op = op->asym;
     602                 :            : 
     603                 :          0 :         result = rte_zmalloc(NULL, modex_test_case.result_len, 0);
     604                 :          0 :         xform_tc.modex.modulus.data = modex_test_case.modulus.data;
     605                 :          0 :         xform_tc.modex.modulus.length = modex_test_case.modulus.len;
     606                 :          0 :         xform_tc.modex.exponent.data = modex_test_case.exponent.data;
     607                 :          0 :         xform_tc.modex.exponent.length = modex_test_case.exponent.len;
     608                 :          0 :         memcpy(input, modex_test_case.base.data,
     609                 :          0 :                 modex_test_case.base.len);
     610                 :          0 :         asym_op->modex.base.data = input;
     611                 :          0 :         asym_op->modex.base.length = modex_test_case.base.len;
     612                 :          0 :         asym_op->modex.result.data = result;
     613                 :          0 :         asym_op->modex.result.length = modex_test_case.result_len;
     614         [ #  # ]:          0 :         if (rte_cryptodev_asym_xform_capability_check_modlen(capability,
     615                 :          0 :                         xform_tc.modex.modulus.length)) {
     616                 :          0 :                 RTE_LOG(INFO, USER1,
     617                 :            :                         "line %u FAILED: %s", __LINE__,
     618                 :            :                         "Invalid MODULUS length specified");
     619                 :          0 :                 return TEST_FAILED;
     620                 :            :         }
     621                 :            : 
     622         [ #  # ]:          0 :         if (!session_less) {
     623                 :            :                 /* Create Crypto session*/
     624                 :          0 :                 ret = rte_cryptodev_asym_session_create(TEST_CDEV_ID,
     625                 :            :                                 &xform_tc, params.asym_sess_mpool, &sess);
     626         [ #  # ]:          0 :                 TEST_ASSERT_SUCCESS(ret, "Failed to init session\n");
     627                 :            : 
     628                 :          0 :                 ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID,
     629                 :            :                                                         &cap);
     630         [ #  # ]:          0 :                 TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
     631                 :            : 
     632         [ #  # ]:          0 :                 if (cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA) {
     633                 :            :                         /* Fill in private user data information */
     634                 :          0 :                         m_data.request_info.cdev_id = request_info.cdev_id;
     635                 :          0 :                         m_data.request_info.queue_pair_id =
     636                 :          0 :                                 request_info.queue_pair_id;
     637                 :          0 :                         m_data.response_info.event = response_info.event;
     638                 :          0 :                         rte_cryptodev_session_event_mdata_set(TEST_CDEV_ID,
     639                 :            :                                         sess, RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
     640                 :            :                                         RTE_CRYPTO_OP_WITH_SESSION,
     641                 :            :                                         &m_data, sizeof(m_data));
     642                 :            :                 }
     643                 :            : 
     644         [ #  # ]:          0 :                 rte_crypto_op_attach_asym_session(op, sess);
     645                 :            :         } else {
     646                 :          0 :                 op->sess_type = RTE_CRYPTO_OP_SESSIONLESS;
     647                 :          0 :                 asym_op->xform = &xform_tc;
     648                 :          0 :                 op->private_data_offset = (sizeof(struct rte_crypto_op) +
     649                 :            :                                 sizeof(struct rte_crypto_asym_op) +
     650                 :            :                                 DEFAULT_NUM_XFORMS *
     651                 :            :                                 sizeof(struct rte_crypto_asym_xform));
     652                 :            :                 /* Fill in private data information */
     653                 :          0 :                 m_data.request_info.cdev_id = request_info.cdev_id;
     654                 :          0 :                 m_data.request_info.queue_pair_id = request_info.queue_pair_id;
     655                 :          0 :                 m_data.response_info.event = response_info.event;
     656         [ #  # ]:          0 :                 rte_memcpy((uint8_t *)op + op->private_data_offset,
     657                 :            :                                 &m_data, sizeof(m_data));
     658                 :            :         }
     659                 :            :         /* Fill in event info and update event_ptr with rte_crypto_op */
     660                 :            :         memset(&ev, 0, sizeof(ev));
     661                 :          0 :         ev.queue_id = TEST_CRYPTO_EV_QUEUE_ID;
     662                 :          0 :         ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
     663                 :          0 :         ev.flow_id = 0xAABB;
     664                 :          0 :         ev.event_ptr = op;
     665                 :            : 
     666                 :          0 :         ret = send_recv_ev(&ev);
     667         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(ret, "Failed to send/receive event to "
     668                 :            :                                 "crypto adapter\n");
     669                 :            : 
     670                 :          0 :         test_crypto_adapter_stats();
     671                 :            : 
     672                 :          0 :         return TEST_SUCCESS;
     673                 :            : }
     674                 :            : 
     675                 :            : 
     676                 :            : static int
     677                 :          0 : test_asym_sessionless_with_op_forward_mode(void)
     678                 :            : {
     679                 :            :         uint32_t cap;
     680                 :            :         int ret;
     681                 :            : 
     682                 :          0 :         ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID, &cap);
     683         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
     684                 :            : 
     685         [ #  # ]:          0 :         if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD) &&
     686                 :            :             !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
     687                 :          0 :                 map_adapter_service_core();
     688                 :            :         else {
     689         [ #  # ]:          0 :                 if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))
     690                 :            :                         return TEST_SKIPPED;
     691                 :            :         }
     692                 :            : 
     693         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(rte_event_crypto_adapter_start(TEST_ADAPTER_ID),
     694                 :            :                                 "Failed to start event crypto adapter");
     695                 :            : 
     696                 :          0 :         return test_asym_op_forward_mode(1);
     697                 :            : }
     698                 :            : 
     699                 :            : static int
     700                 :          0 : test_asym_session_with_op_forward_mode(void)
     701                 :            : {
     702                 :            :         uint32_t cap;
     703                 :            :         int ret;
     704                 :            : 
     705                 :          0 :         ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID, &cap);
     706         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
     707                 :            : 
     708         [ #  # ]:          0 :         if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD) &&
     709                 :            :             !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
     710                 :          0 :                 map_adapter_service_core();
     711                 :            :         else {
     712         [ #  # ]:          0 :                 if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))
     713                 :            :                         return TEST_SKIPPED;
     714                 :            :         }
     715                 :            : 
     716         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(rte_event_crypto_adapter_start(TEST_ADAPTER_ID
     717                 :            :                                 ), "Failed to start event crypto adapter");
     718                 :            : 
     719                 :          0 :         return test_asym_op_forward_mode(0);
     720                 :            : }
     721                 :            : 
     722                 :            : static int
     723                 :          0 : send_op_recv_ev(struct rte_crypto_op *op)
     724                 :            : {
     725                 :            :         struct rte_crypto_op *recv_op;
     726                 :            :         struct rte_event ev;
     727                 :            :         int ret;
     728                 :            : 
     729                 :          0 :         ret = rte_cryptodev_enqueue_burst(TEST_CDEV_ID, TEST_CDEV_QP_ID,
     730                 :            :                                           &op, NUM);
     731         [ #  # ]:          0 :         TEST_ASSERT_EQUAL(ret, NUM, "Failed to enqueue to cryptodev\n");
     732                 :            :         memset(&ev, 0, sizeof(ev));
     733                 :            : 
     734                 :          0 :         while (rte_event_dequeue_burst(evdev,
     735         [ #  # ]:          0 :                 TEST_APP_PORT_ID, &ev, NUM, 0) == 0)
     736                 :            :                 rte_pause();
     737                 :            : 
     738                 :          0 :         recv_op = ev.event_ptr;
     739         [ #  # ]:          0 :         if (recv_op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
     740                 :            : #if PKT_TRACE
     741                 :            :                 struct rte_mbuf *m = recv_op->sym->m_src;
     742                 :            :                 rte_pktmbuf_dump(stdout, m, rte_pktmbuf_pkt_len(m));
     743                 :            : #endif
     744                 :          0 :                 rte_pktmbuf_free(recv_op->sym->m_src);
     745                 :            :         } else {
     746                 :            :                 uint8_t *data_expected = NULL, *data_received = NULL;
     747                 :            :                 uint32_t data_size;
     748                 :            : 
     749                 :            :                 data_expected = modex_test_case.reminder.data;
     750                 :          0 :                 data_received = op->asym->modex.result.data;
     751                 :          0 :                 data_size = op->asym->modex.result.length;
     752                 :          0 :                 ret = memcmp(data_expected, data_received, data_size);
     753         [ #  # ]:          0 :                 TEST_ASSERT_EQUAL(ret, 0,
     754                 :            :                                 "Data mismatch for asym crypto adapter\n");
     755                 :          0 :                 rte_free(op->asym->modex.result.data);
     756                 :            :         }
     757                 :          0 :         rte_crypto_op_free(recv_op);
     758                 :            : 
     759                 :          0 :         return TEST_SUCCESS;
     760                 :            : }
     761                 :            : 
     762                 :            : static int
     763                 :          0 : test_op_new_mode(uint8_t session_less)
     764                 :            : {
     765                 :            :         struct rte_crypto_sym_xform cipher_xform;
     766                 :            :         union rte_event_crypto_metadata m_data;
     767                 :            :         struct rte_crypto_sym_op *sym_op;
     768                 :            :         struct rte_crypto_op *op;
     769                 :            :         struct rte_mbuf *m;
     770                 :            :         uint32_t cap;
     771                 :            :         void *sess;
     772                 :            :         int ret;
     773                 :            : 
     774                 :            :         memset(&m_data, 0, sizeof(m_data));
     775                 :            : 
     776                 :          0 :         m = alloc_fill_mbuf(params.mbuf_pool, text_64B, PACKET_LENGTH, 0);
     777         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf!\n");
     778                 :            : #if PKT_TRACE
     779                 :            :         rte_pktmbuf_dump(stdout, m, rte_pktmbuf_pkt_len(m));
     780                 :            : #endif
     781                 :            :         /* Setup Cipher Parameters */
     782                 :          0 :         cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
     783                 :          0 :         cipher_xform.next = NULL;
     784                 :          0 :         cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
     785                 :          0 :         cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
     786                 :            : 
     787                 :          0 :         op = rte_crypto_op_alloc(params.op_mpool,
     788                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
     789         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(op, "Failed to allocate crypto_op!\n");
     790                 :            : 
     791                 :            :         sym_op = op->sym;
     792                 :            : 
     793         [ #  # ]:          0 :         if (!session_less) {
     794                 :          0 :                 sess = rte_cryptodev_sym_session_create(TEST_CDEV_ID,
     795                 :            :                                 &cipher_xform, params.session_mpool);
     796         [ #  # ]:          0 :                 TEST_ASSERT_NOT_NULL(sess, "Session creation failed\n");
     797                 :            : 
     798                 :          0 :                 ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID,
     799                 :            :                                                         &cap);
     800         [ #  # ]:          0 :                 TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
     801                 :            : 
     802         [ #  # ]:          0 :                 if (cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA) {
     803                 :            :                         /* Fill in private user data information */
     804                 :          0 :                         m_data.response_info.event = response_info.event;
     805                 :          0 :                         rte_cryptodev_session_event_mdata_set(TEST_CDEV_ID,
     806                 :            :                                         sess, RTE_CRYPTO_OP_TYPE_SYMMETRIC,
     807                 :            :                                         RTE_CRYPTO_OP_WITH_SESSION,
     808                 :            :                                         &m_data, sizeof(m_data));
     809                 :            :                 }
     810                 :            : 
     811                 :            :                 rte_crypto_op_attach_sym_session(op, sess);
     812                 :            :         } else {
     813                 :            :                 struct rte_crypto_sym_xform *first_xform;
     814                 :            : 
     815                 :          0 :                 rte_crypto_op_sym_xforms_alloc(op, NUM);
     816                 :          0 :                 op->sess_type = RTE_CRYPTO_OP_SESSIONLESS;
     817                 :            :                 first_xform = &cipher_xform;
     818                 :          0 :                 sym_op->xform = first_xform;
     819                 :            :                 uint32_t len = IV_OFFSET + MAXIMUM_IV_LENGTH;
     820                 :          0 :                 op->private_data_offset = len;
     821                 :            :                 /* Fill in private data information */
     822                 :          0 :                 m_data.response_info.event = response_info.event;
     823         [ #  # ]:          0 :                 rte_memcpy((uint8_t *)op + len, &m_data, sizeof(m_data));
     824                 :            :         }
     825                 :            : 
     826                 :          0 :         sym_op->m_src = m;
     827                 :          0 :         sym_op->cipher.data.offset = 0;
     828                 :          0 :         sym_op->cipher.data.length = PACKET_LENGTH;
     829                 :            : 
     830                 :          0 :         ret = send_op_recv_ev(op);
     831         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(ret, "Failed to enqueue op to cryptodev\n");
     832                 :            : 
     833                 :          0 :         test_crypto_adapter_stats();
     834                 :            : 
     835                 :          0 :         return TEST_SUCCESS;
     836                 :            : }
     837                 :            : 
     838                 :            : static int
     839                 :          0 : test_sessionless_with_op_new_mode(void)
     840                 :            : {
     841                 :            :         uint32_t cap;
     842                 :            :         int ret;
     843                 :            : 
     844                 :          0 :         ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID, &cap);
     845         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
     846                 :            : 
     847         [ #  # ]:          0 :         if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD) &&
     848                 :            :             !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
     849                 :          0 :                 map_adapter_service_core();
     850                 :            :         else {
     851         [ #  # ]:          0 :                 if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
     852                 :            :                         return TEST_SKIPPED;
     853                 :            :         }
     854                 :            : 
     855                 :            :         /* start the event crypto adapter */
     856         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(rte_event_crypto_adapter_start(TEST_ADAPTER_ID),
     857                 :            :                                 "Failed to start event crypto adapter");
     858                 :            : 
     859                 :          0 :         ret = test_op_new_mode(1);
     860         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(ret, "Sessionless - NEW mode test failed\n");
     861                 :            :         return TEST_SUCCESS;
     862                 :            : }
     863                 :            : 
     864                 :            : static int
     865                 :          0 : test_session_with_op_new_mode(void)
     866                 :            : {
     867                 :            :         uint32_t cap;
     868                 :            :         int ret;
     869                 :            : 
     870                 :          0 :         ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID, &cap);
     871         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
     872                 :            : 
     873         [ #  # ]:          0 :         if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD) &&
     874                 :            :             !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
     875                 :          0 :                 map_adapter_service_core();
     876                 :            :         else {
     877         [ #  # ]:          0 :                 if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
     878                 :            :                         return TEST_SKIPPED;
     879                 :            :         }
     880                 :            : 
     881         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(rte_event_crypto_adapter_start(TEST_ADAPTER_ID),
     882                 :            :                                 "Failed to start event crypto adapter");
     883                 :            : 
     884                 :          0 :         ret = test_op_new_mode(0);
     885         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(ret, "Session based - NEW mode test failed\n");
     886                 :            :         return TEST_SUCCESS;
     887                 :            : }
     888                 :            : 
     889                 :            : static int
     890                 :          0 : test_asym_op_new_mode(uint8_t session_less)
     891                 :            : {
     892                 :            :         const struct rte_cryptodev_asymmetric_xform_capability *capability;
     893                 :            :         struct rte_cryptodev_asym_capability_idx cap_idx;
     894                 :            :         struct rte_crypto_asym_xform xform_tc;
     895                 :            :         union rte_event_crypto_metadata m_data;
     896                 :            :         struct rte_cryptodev_info dev_info;
     897                 :            :         struct rte_crypto_asym_op *asym_op;
     898                 :            :         struct rte_crypto_op *op;
     899                 :          0 :         uint8_t input[4096] = {0};
     900                 :            :         uint8_t *result = NULL;
     901                 :          0 :         void *sess = NULL;
     902                 :            :         uint32_t cap;
     903                 :            :         int ret;
     904                 :            : 
     905                 :            :         memset(&m_data, 0, sizeof(m_data));
     906                 :            : 
     907                 :          0 :         rte_cryptodev_info_get(TEST_CDEV_ID, &dev_info);
     908   [ #  #  #  # ]:          0 :         if (session_less && !(dev_info.feature_flags &
     909                 :            :                                 RTE_CRYPTODEV_FF_ASYM_SESSIONLESS)) {
     910                 :          0 :                 RTE_LOG(INFO, USER1,
     911                 :            :                         "Device doesn't support Asym sessionless ops. Test Skipped\n");
     912                 :          0 :                 return TEST_SKIPPED;
     913                 :            :         }
     914                 :            :         /* Setup Cipher Parameters */
     915                 :          0 :         xform_tc.next = NULL;
     916                 :          0 :         xform_tc.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX;
     917                 :          0 :         cap_idx.type = xform_tc.xform_type;
     918                 :          0 :         capability = rte_cryptodev_asym_capability_get(TEST_CDEV_ID, &cap_idx);
     919                 :            : 
     920         [ #  # ]:          0 :         if (capability == NULL) {
     921                 :          0 :                 RTE_LOG(INFO, USER1,
     922                 :            :                         "Device doesn't support MODEX. Test Skipped\n");
     923                 :          0 :                 return TEST_SKIPPED;
     924                 :            :         }
     925                 :            : 
     926                 :          0 :         op = rte_crypto_op_alloc(params.asym_op_mpool,
     927                 :            :                         RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
     928         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(op, "Failed to allocate asym crypto_op!\n");
     929                 :            : 
     930                 :            :         asym_op = op->asym;
     931                 :            : 
     932                 :          0 :         result = rte_zmalloc(NULL, modex_test_case.result_len, 0);
     933                 :          0 :         xform_tc.modex.modulus.data = modex_test_case.modulus.data;
     934                 :          0 :         xform_tc.modex.modulus.length = modex_test_case.modulus.len;
     935                 :          0 :         xform_tc.modex.exponent.data = modex_test_case.exponent.data;
     936                 :          0 :         xform_tc.modex.exponent.length = modex_test_case.exponent.len;
     937                 :          0 :         memcpy(input, modex_test_case.base.data,
     938                 :          0 :                 modex_test_case.base.len);
     939                 :          0 :         asym_op->modex.base.data = input;
     940                 :          0 :         asym_op->modex.base.length = modex_test_case.base.len;
     941                 :          0 :         asym_op->modex.result.data = result;
     942                 :          0 :         asym_op->modex.result.length = modex_test_case.result_len;
     943         [ #  # ]:          0 :         if (rte_cryptodev_asym_xform_capability_check_modlen(capability,
     944                 :          0 :                         xform_tc.modex.modulus.length)) {
     945                 :          0 :                 RTE_LOG(INFO, USER1,
     946                 :            :                         "line %u FAILED: %s", __LINE__,
     947                 :            :                         "Invalid MODULUS length specified");
     948                 :          0 :                 return TEST_FAILED;
     949                 :            :         }
     950                 :            : 
     951         [ #  # ]:          0 :         if (!session_less) {
     952                 :          0 :                 ret = rte_cryptodev_asym_session_create(TEST_CDEV_ID,
     953                 :            :                                 &xform_tc, params.asym_sess_mpool, &sess);
     954         [ #  # ]:          0 :                 TEST_ASSERT_NOT_NULL(sess, "Session creation failed\n");
     955         [ #  # ]:          0 :                 TEST_ASSERT_SUCCESS(ret, "Failed to init session\n");
     956                 :            : 
     957                 :          0 :                 ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID,
     958                 :            :                                                         &cap);
     959         [ #  # ]:          0 :                 TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
     960                 :            : 
     961         [ #  # ]:          0 :                 if (cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA) {
     962                 :            :                         /* Fill in private user data information */
     963                 :          0 :                         m_data.response_info.event = response_info.event;
     964                 :          0 :                         rte_cryptodev_session_event_mdata_set(TEST_CDEV_ID,
     965                 :            :                                         sess, RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
     966                 :            :                                         RTE_CRYPTO_OP_WITH_SESSION,
     967                 :            :                                         &m_data, sizeof(m_data));
     968                 :            :                 }
     969                 :            : 
     970         [ #  # ]:          0 :                 rte_crypto_op_attach_asym_session(op, sess);
     971                 :            :         } else {
     972                 :          0 :                 op->sess_type = RTE_CRYPTO_OP_SESSIONLESS;
     973                 :          0 :                 asym_op->xform = &xform_tc;
     974                 :          0 :                 op->private_data_offset = (sizeof(struct rte_crypto_op) +
     975                 :            :                                 sizeof(struct rte_crypto_asym_op) +
     976                 :            :                                 DEFAULT_NUM_XFORMS *
     977                 :            :                                 sizeof(struct rte_crypto_asym_xform));
     978                 :            :                 /* Fill in private data information */
     979                 :          0 :                 m_data.response_info.event = response_info.event;
     980         [ #  # ]:          0 :                 rte_memcpy((uint8_t *)op + op->private_data_offset,
     981                 :            :                                 &m_data, sizeof(m_data));
     982                 :            :         }
     983                 :            : 
     984                 :          0 :         ret = send_op_recv_ev(op);
     985         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(ret, "Failed to enqueue op to cryptodev\n");
     986                 :            : 
     987                 :          0 :         test_crypto_adapter_stats();
     988                 :            : 
     989                 :          0 :         return TEST_SUCCESS;
     990                 :            : }
     991                 :            : 
     992                 :            : static int
     993                 :          0 : test_asym_sessionless_with_op_new_mode(void)
     994                 :            : {
     995                 :            :         uint32_t cap;
     996                 :            :         int ret;
     997                 :            : 
     998                 :          0 :         ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID, &cap);
     999         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
    1000                 :            : 
    1001         [ #  # ]:          0 :         if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD) &&
    1002                 :            :             !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
    1003                 :          0 :                 map_adapter_service_core();
    1004                 :            :         else {
    1005         [ #  # ]:          0 :                 if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
    1006                 :            :                         return TEST_SKIPPED;
    1007                 :            :         }
    1008                 :            : 
    1009                 :            :         /* start the event crypto adapter */
    1010         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(rte_event_crypto_adapter_start(TEST_ADAPTER_ID),
    1011                 :            :                                 "Failed to start event crypto adapter");
    1012                 :            : 
    1013                 :          0 :         return test_asym_op_new_mode(1);
    1014                 :            : }
    1015                 :            : 
    1016                 :            : static int
    1017                 :          0 : test_asym_session_with_op_new_mode(void)
    1018                 :            : {
    1019                 :            :         uint32_t cap;
    1020                 :            :         int ret;
    1021                 :            : 
    1022                 :          0 :         ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID, &cap);
    1023         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
    1024                 :            : 
    1025         [ #  # ]:          0 :         if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD) &&
    1026                 :            :             !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
    1027                 :          0 :                 map_adapter_service_core();
    1028                 :            :         else {
    1029         [ #  # ]:          0 :                 if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
    1030                 :            :                         return TEST_SKIPPED;
    1031                 :            :         }
    1032                 :            : 
    1033         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(rte_event_crypto_adapter_start(TEST_ADAPTER_ID),
    1034                 :            :                                 "Failed to start event crypto adapter");
    1035                 :            : 
    1036                 :          0 :         return test_asym_op_new_mode(0);
    1037                 :            : }
    1038                 :            : 
    1039                 :            : static int
    1040                 :          0 : configure_cryptodev(void)
    1041                 :            : {
    1042                 :            :         const struct rte_cryptodev_capabilities *capability;
    1043                 :            :         struct rte_cryptodev_qp_conf qp_conf;
    1044                 :            :         struct rte_cryptodev_config conf;
    1045                 :            :         struct rte_cryptodev_info info;
    1046                 :            :         unsigned int session_size;
    1047                 :            :         unsigned int i = 0;
    1048                 :            :         uint8_t nb_devs;
    1049                 :            :         int ret;
    1050                 :            : 
    1051                 :            : 
    1052                 :          0 :         params.mbuf_pool = rte_pktmbuf_pool_create(
    1053                 :            :                         "CRYPTO_ADAPTER_MBUFPOOL",
    1054                 :            :                         NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
    1055                 :          0 :                         rte_socket_id());
    1056         [ #  # ]:          0 :         if (params.mbuf_pool == NULL) {
    1057                 :          0 :                 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
    1058                 :          0 :                 return TEST_FAILED;
    1059                 :            :         }
    1060                 :            : 
    1061                 :          0 :         params.op_mpool = rte_crypto_op_pool_create(
    1062                 :            :                         "EVENT_CRYPTO_SYM_OP_POOL",
    1063                 :            :                         RTE_CRYPTO_OP_TYPE_SYMMETRIC,
    1064                 :            :                         NUM_MBUFS, MBUF_CACHE_SIZE,
    1065                 :            :                         DEFAULT_NUM_XFORMS *
    1066                 :            :                         sizeof(struct rte_crypto_sym_xform) +
    1067                 :            :                         MAXIMUM_IV_LENGTH +
    1068                 :            :                         sizeof(union rte_event_crypto_metadata),
    1069                 :          0 :                         rte_socket_id());
    1070         [ #  # ]:          0 :         if (params.op_mpool == NULL) {
    1071                 :          0 :                 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
    1072                 :          0 :                 return TEST_FAILED;
    1073                 :            :         }
    1074                 :            : 
    1075                 :            : 
    1076                 :          0 :         nb_devs = rte_cryptodev_count();
    1077         [ #  # ]:          0 :         if (!nb_devs) {
    1078                 :            :                 /* Create a NULL crypto device */
    1079                 :          0 :                 ret = rte_vdev_init(
    1080                 :            :                         RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
    1081                 :            : 
    1082         [ #  # ]:          0 :                 TEST_ASSERT(ret == 0, "Failed to create pmd:%s instance\n",
    1083                 :            :                             RTE_STR(CRYPTODEV_NAME_NULL_PMD));
    1084                 :            :         }
    1085                 :            : 
    1086                 :          0 :         nb_devs = rte_cryptodev_count();
    1087         [ #  # ]:          0 :         if (!nb_devs) {
    1088                 :          0 :                 RTE_LOG(ERR, USER1, "No crypto devices found!\n");
    1089                 :          0 :                 return TEST_FAILED;
    1090                 :            :         }
    1091                 :            : 
    1092                 :            :         /*
    1093                 :            :          * Create mempool with maximum number of sessions * 2,
    1094                 :            :          * to include the session headers & private data
    1095                 :            :          */
    1096                 :          0 :         session_size = rte_cryptodev_sym_get_private_session_size(TEST_CDEV_ID);
    1097                 :          0 :         session_size += sizeof(union rte_event_crypto_metadata);
    1098                 :            : 
    1099                 :          0 :         params.session_mpool = rte_cryptodev_sym_session_pool_create(
    1100                 :            :                         "CRYPTO_ADAPTER_SESSION_MP",
    1101                 :            :                         MAX_NB_SESSIONS, session_size, 0,
    1102                 :            :                         sizeof(union rte_event_crypto_metadata),
    1103                 :            :                         SOCKET_ID_ANY);
    1104         [ #  # ]:          0 :         TEST_ASSERT_NOT_NULL(params.session_mpool,
    1105                 :            :                         "session mempool allocation failed\n");
    1106                 :            : 
    1107                 :          0 :         rte_cryptodev_info_get(TEST_CDEV_ID, &info);
    1108                 :            : 
    1109         [ #  # ]:          0 :         while ((capability = &info.capabilities[i++])->op !=
    1110                 :            :                         RTE_CRYPTO_OP_TYPE_UNDEFINED) {
    1111         [ #  # ]:          0 :                 if (capability->op == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
    1112                 :          0 :                         params.asym_op_mpool = rte_crypto_op_pool_create(
    1113                 :            :                                 "EVENT_CRYPTO_ASYM_OP_POOL",
    1114                 :            :                                 RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
    1115                 :            :                                 NUM_MBUFS, MBUF_CACHE_SIZE,
    1116                 :            :                                 (DEFAULT_NUM_XFORMS *
    1117                 :            :                                 sizeof(struct rte_crypto_asym_xform)) +
    1118                 :            :                                 sizeof(union rte_event_crypto_metadata),
    1119                 :          0 :                                 rte_socket_id());
    1120         [ #  # ]:          0 :                         TEST_ASSERT_NOT_NULL(params.asym_op_mpool,
    1121                 :            :                                         "Can't create CRYPTO_ASYM_OP_POOL\n");
    1122                 :            : 
    1123                 :          0 :                         params.asym_sess_mpool =
    1124                 :          0 :                                 rte_cryptodev_asym_session_pool_create(
    1125                 :            :                                         "CRYPTO_AD_ASYM_SESS_MP",
    1126                 :            :                                         MAX_NB_SESSIONS, 0,
    1127                 :            :                                         sizeof(union rte_event_crypto_metadata),
    1128                 :            :                                         SOCKET_ID_ANY);
    1129         [ #  # ]:          0 :                         TEST_ASSERT_NOT_NULL(params.asym_sess_mpool,
    1130                 :            :                                 "asym session mempool allocation failed\n");
    1131                 :            :                         break;
    1132                 :            :                 }
    1133                 :            :         }
    1134                 :            : 
    1135                 :          0 :         conf.nb_queue_pairs = info.max_nb_queue_pairs;
    1136                 :          0 :         conf.socket_id = SOCKET_ID_ANY;
    1137                 :          0 :         conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
    1138                 :            : 
    1139         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(rte_cryptodev_configure(TEST_CDEV_ID, &conf),
    1140                 :            :                         "Failed to configure cryptodev %u with %u qps\n",
    1141                 :            :                         TEST_CDEV_ID, conf.nb_queue_pairs);
    1142                 :            : 
    1143                 :          0 :         qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
    1144                 :          0 :         qp_conf.mp_session = params.session_mpool;
    1145                 :            : 
    1146         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
    1147                 :            :                         TEST_CDEV_ID, TEST_CDEV_QP_ID, &qp_conf,
    1148                 :            :                         rte_cryptodev_socket_id(TEST_CDEV_ID)),
    1149                 :            :                         "Failed to setup queue pair %u on cryptodev %u\n",
    1150                 :            :                         TEST_CDEV_QP_ID, TEST_CDEV_ID);
    1151                 :            : 
    1152                 :            :         return TEST_SUCCESS;
    1153                 :            : }
    1154                 :            : 
    1155                 :            : static inline void
    1156                 :            : evdev_set_conf_values(struct rte_event_dev_config *dev_conf,
    1157                 :            :                       const struct rte_event_dev_info *info)
    1158                 :            : {
    1159                 :          0 :         *dev_conf = (struct rte_event_dev_config) {
    1160                 :          0 :                 .dequeue_timeout_ns = info->min_dequeue_timeout_ns,
    1161                 :            :                 .nb_event_ports = NB_TEST_PORTS,
    1162                 :            :                 .nb_event_queues = NB_TEST_QUEUES,
    1163                 :          0 :                 .nb_event_queue_flows = info->max_event_queue_flows,
    1164                 :          0 :                 .nb_event_port_dequeue_depth = info->max_event_port_dequeue_depth,
    1165                 :          0 :                 .nb_event_port_enqueue_depth = info->max_event_port_enqueue_depth,
    1166                 :          0 :                 .nb_events_limit = info->max_num_events,
    1167                 :            :         };
    1168                 :            : }
    1169                 :            : 
    1170                 :            : static int
    1171                 :          0 : configure_eventdev(void)
    1172                 :            : {
    1173                 :            :         struct rte_event_queue_conf queue_conf;
    1174                 :            :         struct rte_event_dev_config devconf;
    1175                 :            :         struct rte_event_dev_info info;
    1176                 :            :         uint32_t queue_count;
    1177                 :            :         uint32_t port_count;
    1178                 :            :         int ret;
    1179                 :            :         uint8_t qid;
    1180                 :            : 
    1181         [ #  # ]:          0 :         if (!rte_event_dev_count()) {
    1182                 :            :                 /* If there is no hardware eventdev, or no software vdev was
    1183                 :            :                  * specified on the command line, create an instance of
    1184                 :            :                  * event_sw.
    1185                 :            :                  */
    1186                 :          0 :                 LOG_DBG("Failed to find a valid event device... "
    1187                 :            :                         "testing with event_sw device\n");
    1188         [ #  # ]:          0 :                 TEST_ASSERT_SUCCESS(rte_vdev_init("event_sw0", NULL),
    1189                 :            :                                         "Error creating eventdev");
    1190                 :          0 :                 evdev = rte_event_dev_get_dev_id("event_sw0");
    1191                 :            :         }
    1192                 :            : 
    1193                 :          0 :         ret = rte_event_dev_info_get(evdev, &info);
    1194         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info\n");
    1195                 :            : 
    1196                 :            :         evdev_set_conf_values(&devconf, &info);
    1197                 :            : 
    1198                 :          0 :         ret = rte_event_dev_configure(evdev, &devconf);
    1199         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(ret, "Failed to configure eventdev\n");
    1200                 :            : 
    1201                 :            :         /* Set up event queue */
    1202                 :          0 :         ret = rte_event_dev_attr_get(evdev, RTE_EVENT_DEV_ATTR_QUEUE_COUNT,
    1203                 :            :                                         &queue_count);
    1204         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(ret, "Queue count get failed\n");
    1205         [ #  # ]:          0 :         TEST_ASSERT_EQUAL(queue_count, 2, "Unexpected queue count\n");
    1206                 :            : 
    1207                 :          0 :         qid = TEST_APP_EV_QUEUE_ID;
    1208                 :          0 :         ret = rte_event_queue_setup(evdev, qid, NULL);
    1209         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(ret, "Failed to setup queue=%d\n", qid);
    1210                 :            : 
    1211                 :          0 :         queue_conf.nb_atomic_flows = info.max_event_queue_flows;
    1212                 :          0 :         queue_conf.nb_atomic_order_sequences = 32;
    1213                 :          0 :         queue_conf.schedule_type = RTE_SCHED_TYPE_ATOMIC;
    1214                 :          0 :         queue_conf.priority = RTE_EVENT_DEV_PRIORITY_HIGHEST;
    1215                 :          0 :         queue_conf.event_queue_cfg = RTE_EVENT_QUEUE_CFG_SINGLE_LINK;
    1216                 :            : 
    1217                 :          0 :         qid = TEST_CRYPTO_EV_QUEUE_ID;
    1218                 :          0 :         ret = rte_event_queue_setup(evdev, qid, &queue_conf);
    1219         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(ret, "Failed to setup queue=%u\n", qid);
    1220                 :            : 
    1221                 :            :         /* Set up event port */
    1222                 :          0 :         ret = rte_event_dev_attr_get(evdev, RTE_EVENT_DEV_ATTR_PORT_COUNT,
    1223                 :            :                                         &port_count);
    1224         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(ret, "Port count get failed\n");
    1225         [ #  # ]:          0 :         TEST_ASSERT_EQUAL(port_count, 1, "Unexpected port count\n");
    1226                 :            : 
    1227                 :          0 :         ret = rte_event_port_setup(evdev, TEST_APP_PORT_ID, NULL);
    1228         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(ret, "Failed to setup port=%d\n",
    1229                 :            :                             TEST_APP_PORT_ID);
    1230                 :            : 
    1231                 :          0 :         qid = TEST_APP_EV_QUEUE_ID;
    1232                 :          0 :         ret = rte_event_port_link(evdev, TEST_APP_PORT_ID, &qid, NULL, 1);
    1233         [ #  # ]:          0 :         TEST_ASSERT(ret >= 0, "Failed to link queue port=%d\n",
    1234                 :            :                     TEST_APP_PORT_ID);
    1235                 :            : 
    1236                 :            :         return TEST_SUCCESS;
    1237                 :            : }
    1238                 :            : 
    1239                 :            : static void
    1240                 :          0 : test_crypto_adapter_free(void)
    1241                 :            : {
    1242                 :          0 :         rte_event_crypto_adapter_free(TEST_ADAPTER_ID);
    1243                 :          0 : }
    1244                 :            : 
    1245                 :            : static int
    1246                 :          0 : test_crypto_adapter_create(void)
    1247                 :            : {
    1248                 :          0 :         struct rte_event_port_conf conf = {
    1249                 :            :                 .dequeue_depth = 8,
    1250                 :            :                 .enqueue_depth = 8,
    1251                 :            :                 .new_event_threshold = 1200,
    1252                 :            :         };
    1253                 :            :         uint32_t cap;
    1254                 :            :         int ret;
    1255                 :            : 
    1256                 :          0 :         ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID, &cap);
    1257         [ #  # ]:          0 :         if (ret == -ENOTSUP)
    1258                 :            :                 return ret;
    1259                 :            : 
    1260                 :            :         /* Create adapter with default port creation callback */
    1261                 :          0 :         ret = rte_event_crypto_adapter_create(TEST_ADAPTER_ID,
    1262                 :            :                                               evdev,
    1263                 :            :                                               &conf, 0);
    1264         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(ret, "Failed to create event crypto adapter\n");
    1265                 :            : 
    1266                 :            :         return TEST_SUCCESS;
    1267                 :            : }
    1268                 :            : 
    1269                 :            : static int
    1270                 :          0 : test_crypto_adapter_qp_add_del(void)
    1271                 :            : {
    1272                 :          0 :         struct rte_event_crypto_adapter_queue_conf queue_conf = {
    1273                 :            :                 .ev = response_info,
    1274                 :            :         };
    1275                 :            : 
    1276                 :            :         uint32_t cap;
    1277                 :            :         int ret;
    1278                 :            : 
    1279                 :          0 :         ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID, &cap);
    1280         [ #  # ]:          0 :         if (ret == -ENOTSUP)
    1281                 :            :                 return TEST_SKIPPED;
    1282                 :            : 
    1283         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
    1284                 :            : 
    1285         [ #  # ]:          0 :         if (cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND) {
    1286                 :          0 :                 ret = rte_event_crypto_adapter_queue_pair_add(TEST_ADAPTER_ID,
    1287                 :            :                                 TEST_CDEV_ID, TEST_CDEV_QP_ID, &queue_conf);
    1288                 :            :         } else
    1289                 :          0 :                 ret = rte_event_crypto_adapter_queue_pair_add(TEST_ADAPTER_ID,
    1290                 :            :                                         TEST_CDEV_ID, TEST_CDEV_QP_ID, NULL);
    1291                 :            : 
    1292         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(ret, "Failed to create add queue pair\n");
    1293                 :            : 
    1294                 :          0 :         ret = rte_event_crypto_adapter_queue_pair_del(TEST_ADAPTER_ID,
    1295                 :            :                                         TEST_CDEV_ID, TEST_CDEV_QP_ID);
    1296         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(ret, "Failed to delete add queue pair\n");
    1297                 :            : 
    1298                 :            :         return TEST_SUCCESS;
    1299                 :            : }
    1300                 :            : 
    1301                 :            : static int
    1302                 :          0 : configure_event_crypto_adapter(enum rte_event_crypto_adapter_mode mode)
    1303                 :            : {
    1304                 :          0 :         struct rte_event_port_conf conf = {
    1305                 :            :                 .dequeue_depth = 8,
    1306                 :            :                 .enqueue_depth = 8,
    1307                 :            :                 .new_event_threshold = 1200,
    1308                 :            :         };
    1309                 :            : 
    1310                 :          0 :         struct rte_event_crypto_adapter_queue_conf queue_conf = {
    1311                 :            :                 .ev = response_info,
    1312                 :            :         };
    1313                 :            : 
    1314                 :            :         uint32_t cap;
    1315                 :            :         int ret;
    1316                 :            : 
    1317                 :          0 :         ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID, &cap);
    1318         [ #  # ]:          0 :         if (ret == -ENOTSUP)
    1319                 :            :                 return ret;
    1320                 :            : 
    1321         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n");
    1322                 :            : 
    1323                 :            :         /* Skip mode and capability mismatch check for SW eventdev */
    1324                 :          0 :         if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW) &&
    1325         [ #  # ]:          0 :             !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD) &&
    1326                 :            :             !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND))
    1327                 :          0 :                 goto adapter_create;
    1328                 :            : 
    1329         [ #  # ]:          0 :         if (mode == RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD) {
    1330         [ #  # ]:          0 :                 if (cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD)
    1331                 :          0 :                         params.internal_port_op_fwd = 1;
    1332                 :            :                 else
    1333                 :            :                         return -ENOTSUP;
    1334                 :            :         }
    1335                 :            : 
    1336         [ #  # ]:          0 :         if ((mode == RTE_EVENT_CRYPTO_ADAPTER_OP_NEW) &&
    1337         [ #  # ]:          0 :             !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
    1338                 :            :                 return -ENOTSUP;
    1339                 :            : 
    1340                 :          0 : adapter_create:
    1341                 :            :         /* Create adapter with default port creation callback */
    1342                 :          0 :         ret = rte_event_crypto_adapter_create(TEST_ADAPTER_ID,
    1343                 :            :                                               evdev,
    1344                 :            :                                               &conf, mode);
    1345         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(ret, "Failed to create event crypto adapter\n");
    1346                 :            : 
    1347         [ #  # ]:          0 :         if (cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND) {
    1348                 :          0 :                 ret = rte_event_crypto_adapter_queue_pair_add(TEST_ADAPTER_ID,
    1349                 :            :                                 TEST_CDEV_ID, TEST_CDEV_QP_ID, &queue_conf);
    1350                 :            :         } else
    1351                 :          0 :                 ret = rte_event_crypto_adapter_queue_pair_add(TEST_ADAPTER_ID,
    1352                 :            :                                 TEST_CDEV_ID, TEST_CDEV_QP_ID, NULL);
    1353                 :            : 
    1354         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(ret, "Failed to add queue pair\n");
    1355                 :            : 
    1356         [ #  # ]:          0 :         if (!params.internal_port_op_fwd) {
    1357                 :          0 :                 ret = rte_event_crypto_adapter_event_port_get(TEST_ADAPTER_ID,
    1358                 :            :                                                 &params.crypto_event_port_id);
    1359         [ #  # ]:          0 :                 TEST_ASSERT_SUCCESS(ret, "Failed to get event port\n");
    1360                 :            :         }
    1361                 :            : 
    1362                 :            :         return TEST_SUCCESS;
    1363                 :            : }
    1364                 :            : 
    1365                 :            : static void
    1366                 :          0 : test_crypto_adapter_stop(void)
    1367                 :            : {
    1368                 :            :         uint32_t evdev_service_id, adapter_service_id;
    1369                 :            : 
    1370                 :            :         /* retrieve service ids & stop services */
    1371         [ #  # ]:          0 :         if (rte_event_crypto_adapter_service_id_get(TEST_ADAPTER_ID,
    1372                 :            :                                                 &adapter_service_id) == 0) {
    1373                 :          0 :                 rte_service_runstate_set(adapter_service_id, 0);
    1374                 :          0 :                 rte_service_lcore_stop(slcore_id);
    1375                 :          0 :                 rte_service_lcore_del(slcore_id);
    1376                 :          0 :                 rte_event_crypto_adapter_stop(TEST_ADAPTER_ID);
    1377                 :            :         }
    1378                 :            : 
    1379         [ #  # ]:          0 :         if (rte_event_dev_service_id_get(evdev, &evdev_service_id) == 0) {
    1380                 :          0 :                 rte_service_runstate_set(evdev_service_id, 0);
    1381                 :          0 :                 rte_service_lcore_stop(slcore_id);
    1382                 :          0 :                 rte_service_lcore_del(slcore_id);
    1383                 :          0 :                 rte_cryptodev_stop(TEST_CDEV_ID);
    1384                 :          0 :                 rte_event_dev_stop(evdev);
    1385                 :            :         } else {
    1386                 :          0 :                 rte_cryptodev_stop(TEST_CDEV_ID);
    1387                 :          0 :                 rte_event_dev_stop(evdev);
    1388                 :            :         }
    1389                 :          0 : }
    1390                 :            : 
    1391                 :            : static int
    1392                 :          0 : test_crypto_adapter_conf(enum rte_event_crypto_adapter_mode mode)
    1393                 :            : {
    1394                 :            :         uint32_t evdev_service_id;
    1395                 :            :         uint8_t qid;
    1396                 :            :         int ret;
    1397                 :            : 
    1398         [ #  # ]:          0 :         if (!crypto_adapter_setup_done) {
    1399                 :          0 :                 ret = configure_event_crypto_adapter(mode);
    1400         [ #  # ]:          0 :                 if (ret)
    1401                 :            :                         return ret;
    1402         [ #  # ]:          0 :                 if (!params.internal_port_op_fwd) {
    1403                 :          0 :                         qid = TEST_CRYPTO_EV_QUEUE_ID;
    1404                 :          0 :                         ret = rte_event_port_link(evdev,
    1405                 :          0 :                                 params.crypto_event_port_id, &qid, NULL, 1);
    1406         [ #  # ]:          0 :                         TEST_ASSERT(ret >= 0, "Failed to link queue %d "
    1407                 :            :                                         "port=%u\n", qid,
    1408                 :            :                                         params.crypto_event_port_id);
    1409                 :            :                 }
    1410                 :          0 :                 crypto_adapter_setup_done = 1;
    1411                 :            :         }
    1412                 :            : 
    1413                 :            :         /* retrieve service ids */
    1414         [ #  # ]:          0 :         if (rte_event_dev_service_id_get(evdev, &evdev_service_id) == 0) {
    1415                 :            :                 /* add a service core and start it */
    1416         [ #  # ]:          0 :                 TEST_ASSERT_SUCCESS(rte_service_lcore_add(slcore_id),
    1417                 :            :                                         "Failed to add service core");
    1418         [ #  # ]:          0 :                 TEST_ASSERT_SUCCESS(rte_service_lcore_start(slcore_id),
    1419                 :            :                                         "Failed to start service core");
    1420                 :            : 
    1421                 :            :                 /* map services to it */
    1422         [ #  # ]:          0 :                 TEST_ASSERT_SUCCESS(rte_service_map_lcore_set(evdev_service_id,
    1423                 :            :                                 slcore_id, 1), "Failed to map evdev service");
    1424                 :            : 
    1425                 :            :                 /* set services to running */
    1426         [ #  # ]:          0 :                 TEST_ASSERT_SUCCESS(rte_service_runstate_set(evdev_service_id,
    1427                 :            :                                         1), "Failed to start evdev service");
    1428                 :            :         }
    1429                 :            : 
    1430                 :            :         /* start the eventdev */
    1431         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(rte_event_dev_start(evdev),
    1432                 :            :                                 "Failed to start event device");
    1433                 :            : 
    1434                 :            :         /* start the cryptodev */
    1435         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(rte_cryptodev_start(TEST_CDEV_ID),
    1436                 :            :                                 "Failed to start crypto device");
    1437                 :            : 
    1438                 :            :         return TEST_SUCCESS;
    1439                 :            : }
    1440                 :            : 
    1441                 :            : static int
    1442                 :          0 : test_crypto_adapter_conf_op_forward_mode(void)
    1443                 :            : {
    1444                 :            :         enum rte_event_crypto_adapter_mode mode;
    1445                 :            : 
    1446                 :            :         mode = RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD;
    1447                 :            : 
    1448                 :          0 :         return test_crypto_adapter_conf(mode);
    1449                 :            : }
    1450                 :            : 
    1451                 :            : static int
    1452                 :          0 : test_crypto_adapter_conf_op_new_mode(void)
    1453                 :            : {
    1454                 :            :         enum rte_event_crypto_adapter_mode mode;
    1455                 :            : 
    1456                 :            :         mode = RTE_EVENT_CRYPTO_ADAPTER_OP_NEW;
    1457                 :            : 
    1458                 :          0 :         return test_crypto_adapter_conf(mode);
    1459                 :            : }
    1460                 :            : 
    1461                 :            : 
    1462                 :            : static int
    1463                 :          0 : testsuite_setup(void)
    1464                 :            : {
    1465                 :            :         int ret;
    1466                 :            : 
    1467                 :          0 :         slcore_id = rte_get_next_lcore(-1, 1, 0);
    1468         [ #  # ]:          0 :         TEST_ASSERT_NOT_EQUAL(slcore_id, RTE_MAX_LCORE, "At least 2 lcores "
    1469                 :            :                         "are required to run this autotest\n");
    1470                 :            : 
    1471                 :            :         /* Setup and start event device. */
    1472                 :          0 :         ret = configure_eventdev();
    1473         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(ret, "Failed to setup eventdev\n");
    1474                 :            : 
    1475                 :            :         /* Setup and start crypto device. */
    1476                 :          0 :         ret = configure_cryptodev();
    1477         [ #  # ]:          0 :         TEST_ASSERT_SUCCESS(ret, "cryptodev initialization failed\n");
    1478                 :            : 
    1479                 :            :         return TEST_SUCCESS;
    1480                 :            : }
    1481                 :            : 
    1482                 :            : static void
    1483                 :          0 : crypto_adapter_teardown(void)
    1484                 :            : {
    1485                 :            :         int ret;
    1486                 :            : 
    1487         [ #  # ]:          0 :         if (!crypto_adapter_setup_done)
    1488                 :            :                 return;
    1489                 :            : 
    1490                 :          0 :         ret = rte_event_crypto_adapter_stop(TEST_ADAPTER_ID);
    1491         [ #  # ]:          0 :         if (ret < 0)
    1492                 :          0 :                 RTE_LOG(ERR, USER1, "Failed to stop adapter!");
    1493                 :            : 
    1494                 :          0 :         ret = rte_event_crypto_adapter_queue_pair_del(TEST_ADAPTER_ID,
    1495                 :            :                                         TEST_CDEV_ID, TEST_CDEV_QP_ID);
    1496         [ #  # ]:          0 :         if (ret < 0)
    1497                 :          0 :                 RTE_LOG(ERR, USER1, "Failed to delete queue pair!");
    1498                 :            : 
    1499                 :          0 :         ret = rte_event_crypto_adapter_free(TEST_ADAPTER_ID);
    1500         [ #  # ]:          0 :         if (ret < 0)
    1501                 :          0 :                 RTE_LOG(ERR, USER1, "Failed to free adapter!");
    1502                 :            : 
    1503                 :          0 :         crypto_adapter_setup_done = 0;
    1504                 :            : }
    1505                 :            : 
    1506                 :            : static void
    1507                 :          0 : crypto_teardown(void)
    1508                 :            : {
    1509                 :            :         /* Free mbuf mempool */
    1510         [ #  # ]:          0 :         if (params.mbuf_pool != NULL) {
    1511                 :          0 :                 RTE_LOG(DEBUG, USER1, "CRYPTO_ADAPTER_MBUFPOOL count %u\n",
    1512                 :            :                 rte_mempool_avail_count(params.mbuf_pool));
    1513                 :          0 :                 rte_mempool_free(params.mbuf_pool);
    1514                 :          0 :                 params.mbuf_pool = NULL;
    1515                 :            :         }
    1516                 :            : 
    1517                 :            :         /* Free session mempool */
    1518         [ #  # ]:          0 :         if (params.session_mpool != NULL) {
    1519                 :          0 :                 RTE_LOG(DEBUG, USER1, "CRYPTO_ADAPTER_SESSION_MP count %u\n",
    1520                 :            :                 rte_mempool_avail_count(params.session_mpool));
    1521                 :          0 :                 rte_mempool_free(params.session_mpool);
    1522                 :          0 :                 params.session_mpool = NULL;
    1523                 :            :         }
    1524                 :            : 
    1525                 :            :         /* Free asym session mempool */
    1526         [ #  # ]:          0 :         if (params.asym_sess_mpool != NULL) {
    1527                 :          0 :                 RTE_LOG(DEBUG, USER1, "CRYPTO_AD_ASYM_SESS_MP count %u\n",
    1528                 :            :                 rte_mempool_avail_count(params.asym_sess_mpool));
    1529                 :          0 :                 rte_mempool_free(params.asym_sess_mpool);
    1530                 :          0 :                 params.asym_sess_mpool = NULL;
    1531                 :            :         }
    1532                 :            :         /* Free asym ops mempool */
    1533         [ #  # ]:          0 :         if (params.asym_op_mpool != NULL) {
    1534                 :          0 :                 RTE_LOG(DEBUG, USER1, "EVENT_CRYPTO_ASYM_OP_POOL count %u\n",
    1535                 :            :                 rte_mempool_avail_count(params.asym_op_mpool));
    1536                 :          0 :                 rte_mempool_free(params.asym_op_mpool);
    1537                 :          0 :                 params.asym_op_mpool = NULL;
    1538                 :            :         }
    1539                 :            : 
    1540                 :            :         /* Free ops mempool */
    1541         [ #  # ]:          0 :         if (params.op_mpool != NULL) {
    1542                 :          0 :                 RTE_LOG(DEBUG, USER1, "EVENT_CRYPTO_SYM_OP_POOL count %u\n",
    1543                 :            :                 rte_mempool_avail_count(params.op_mpool));
    1544                 :          0 :                 rte_mempool_free(params.op_mpool);
    1545                 :          0 :                 params.op_mpool = NULL;
    1546                 :            :         }
    1547                 :          0 : }
    1548                 :            : 
    1549                 :            : static void
    1550                 :            : eventdev_teardown(void)
    1551                 :            : {
    1552                 :          0 :         rte_event_dev_stop(evdev);
    1553                 :            : }
    1554                 :            : 
    1555                 :            : static void
    1556                 :          0 : testsuite_teardown(void)
    1557                 :            : {
    1558                 :          0 :         crypto_adapter_teardown();
    1559                 :          0 :         crypto_teardown();
    1560                 :            :         eventdev_teardown();
    1561                 :          0 : }
    1562                 :            : 
    1563                 :            : static struct unit_test_suite functional_testsuite = {
    1564                 :            :         .suite_name = "Event crypto adapter test suite",
    1565                 :            :         .setup = testsuite_setup,
    1566                 :            :         .teardown = testsuite_teardown,
    1567                 :            :         .unit_test_cases = {
    1568                 :            : 
    1569                 :            :                 TEST_CASE_ST(NULL, test_crypto_adapter_free,
    1570                 :            :                                 test_crypto_adapter_create),
    1571                 :            : 
    1572                 :            :                 TEST_CASE_ST(test_crypto_adapter_create,
    1573                 :            :                                 test_crypto_adapter_free,
    1574                 :            :                                 test_crypto_adapter_qp_add_del),
    1575                 :            : 
    1576                 :            :                 TEST_CASE_ST(test_crypto_adapter_create,
    1577                 :            :                                 test_crypto_adapter_free,
    1578                 :            :                                 test_crypto_adapter_stats),
    1579                 :            : 
    1580                 :            :                 TEST_CASE_ST(test_crypto_adapter_create,
    1581                 :            :                                 test_crypto_adapter_free,
    1582                 :            :                                 test_crypto_adapter_params),
    1583                 :            : 
    1584                 :            :                 TEST_CASE_ST(test_crypto_adapter_conf_op_forward_mode,
    1585                 :            :                                 test_crypto_adapter_stop,
    1586                 :            :                                 test_session_with_op_forward_mode),
    1587                 :            : 
    1588                 :            :                 TEST_CASE_ST(test_crypto_adapter_conf_op_forward_mode,
    1589                 :            :                                 test_crypto_adapter_stop,
    1590                 :            :                                 test_sessionless_with_op_forward_mode),
    1591                 :            : 
    1592                 :            :                 TEST_CASE_ST(test_crypto_adapter_conf_op_new_mode,
    1593                 :            :                                 test_crypto_adapter_stop,
    1594                 :            :                                 test_session_with_op_new_mode),
    1595                 :            : 
    1596                 :            :                 TEST_CASE_ST(test_crypto_adapter_conf_op_new_mode,
    1597                 :            :                                 test_crypto_adapter_stop,
    1598                 :            :                                 test_sessionless_with_op_new_mode),
    1599                 :            : 
    1600                 :            :                 TEST_CASE_ST(test_crypto_adapter_conf_op_forward_mode,
    1601                 :            :                                 test_crypto_adapter_stop,
    1602                 :            :                                 test_asym_session_with_op_forward_mode),
    1603                 :            : 
    1604                 :            :                 TEST_CASE_ST(test_crypto_adapter_conf_op_forward_mode,
    1605                 :            :                                 test_crypto_adapter_stop,
    1606                 :            :                                 test_asym_sessionless_with_op_forward_mode),
    1607                 :            : 
    1608                 :            :                 TEST_CASE_ST(test_crypto_adapter_conf_op_new_mode,
    1609                 :            :                                 test_crypto_adapter_stop,
    1610                 :            :                                 test_asym_session_with_op_new_mode),
    1611                 :            : 
    1612                 :            :                 TEST_CASE_ST(test_crypto_adapter_conf_op_new_mode,
    1613                 :            :                                 test_crypto_adapter_stop,
    1614                 :            :                                 test_asym_sessionless_with_op_new_mode),
    1615                 :            : 
    1616                 :            :                 TEST_CASES_END() /**< NULL terminate unit test array */
    1617                 :            :         }
    1618                 :            : };
    1619                 :            : 
    1620                 :            : static int
    1621                 :          0 : test_event_crypto_adapter(void)
    1622                 :            : {
    1623                 :          0 :         return unit_test_suite_runner(&functional_testsuite);
    1624                 :            : }
    1625                 :            : 
    1626                 :            : #endif /* !RTE_EXEC_ENV_WINDOWS */
    1627                 :            : 
    1628                 :        252 : REGISTER_TEST_COMMAND(event_crypto_adapter_autotest,
    1629                 :            :                 test_event_crypto_adapter);

Generated by: LCOV version 1.14