LCOV - code coverage report
Current view: top level - spdk/examples/accel/perf - accel_perf.c (source / functions) Hit Total Coverage
Test: Combined Lines: 0 988 0.0 %
Date: 2024-11-18 06:44:01 Functions: 0 24 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 533 0.0 %

           Branch data     Line data    Source code
       1                 :            : /*   SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  *   Copyright (C) 2020 Intel Corporation.
       3                 :            :  *   Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES.
       4                 :            :  *   All rights reserved.
       5                 :            :  */
       6                 :            : 
       7                 :            : #include "spdk/stdinc.h"
       8                 :            : #include "spdk/thread.h"
       9                 :            : #include "spdk/env.h"
      10                 :            : #include "spdk/event.h"
      11                 :            : #include "spdk/log.h"
      12                 :            : #include "spdk/string.h"
      13                 :            : #include "spdk/accel.h"
      14                 :            : #include "spdk/crc32.h"
      15                 :            : #include "spdk/util.h"
      16                 :            : #include "spdk/xor.h"
      17                 :            : #include "spdk/dif.h"
      18                 :            : 
      19                 :            : #define DATA_PATTERN 0x5a
      20                 :            : #define ALIGN_4K 0x1000
      21                 :            : #define COMP_BUF_PAD_PERCENTAGE 1.1L
      22                 :            : 
      23                 :            : static uint64_t g_tsc_rate;
      24                 :            : static uint64_t g_tsc_end;
      25                 :            : static int g_rc;
      26                 :            : static int g_xfer_size_bytes = 4096;
      27                 :            : static int g_block_size_bytes = 512;
      28                 :            : static int g_md_size_bytes = 8;
      29                 :            : static int g_queue_depth = 32;
      30                 :            : /* g_allocate_depth indicates how many tasks we allocate per worker. It will
      31                 :            :  * be at least as much as the queue depth.
      32                 :            :  */
      33                 :            : static int g_allocate_depth = 0;
      34                 :            : static int g_threads_per_core = 1;
      35                 :            : static int g_time_in_sec = 5;
      36                 :            : static uint32_t g_crc32c_seed = 0;
      37                 :            : static uint32_t g_chained_count = 1;
      38                 :            : static int g_fail_percent_goal = 0;
      39                 :            : static uint8_t g_fill_pattern = 255;
      40                 :            : static uint32_t g_xor_src_count = 2;
      41                 :            : static bool g_verify = false;
      42                 :            : static const char *g_workload_type = NULL;
      43                 :            : static enum spdk_accel_opcode g_workload_selection = SPDK_ACCEL_OPC_LAST;
      44                 :            : static const char *g_module_name = NULL;
      45                 :            : static struct worker_thread *g_workers = NULL;
      46                 :            : static int g_num_workers = 0;
      47                 :            : static char *g_cd_file_in_name = NULL;
      48                 :            : static pthread_mutex_t g_workers_lock = PTHREAD_MUTEX_INITIALIZER;
      49                 :            : static struct spdk_app_opts g_opts = {};
      50                 :            : 
      51                 :            : struct ap_compress_seg {
      52                 :            :         void            *uncompressed_data;
      53                 :            :         uint32_t        uncompressed_len;
      54                 :            :         struct iovec    *uncompressed_iovs;
      55                 :            :         uint32_t        uncompressed_iovcnt;
      56                 :            : 
      57                 :            :         void            *compressed_data;
      58                 :            :         uint32_t        compressed_len;
      59                 :            :         uint32_t        compressed_len_padded;
      60                 :            :         struct iovec    *compressed_iovs;
      61                 :            :         uint32_t        compressed_iovcnt;
      62                 :            : 
      63                 :            :         STAILQ_ENTRY(ap_compress_seg)   link;
      64                 :            : };
      65                 :            : 
      66                 :            : static STAILQ_HEAD(, ap_compress_seg) g_compress_segs = STAILQ_HEAD_INITIALIZER(g_compress_segs);
      67                 :            : 
      68                 :            : struct worker_thread;
      69                 :            : static void accel_done(void *ref, int status);
      70                 :            : 
      71                 :            : struct display_info {
      72                 :            :         int core;
      73                 :            :         int thread;
      74                 :            : };
      75                 :            : 
      76                 :            : struct ap_task {
      77                 :            :         void                    *src;
      78                 :            :         struct iovec            *src_iovs;
      79                 :            :         uint32_t                src_iovcnt;
      80                 :            :         void                    **sources;
      81                 :            :         struct iovec            *dst_iovs;
      82                 :            :         uint32_t                dst_iovcnt;
      83                 :            :         struct iovec            md_iov;
      84                 :            :         void                    *dst;
      85                 :            :         void                    *dst2;
      86                 :            :         uint32_t                *crc_dst;
      87                 :            :         uint32_t                compressed_sz;
      88                 :            :         struct ap_compress_seg *cur_seg;
      89                 :            :         struct worker_thread    *worker;
      90                 :            :         int                     expected_status; /* used for the compare operation */
      91                 :            :         uint32_t                num_blocks; /* used for the DIF related operations */
      92                 :            :         struct spdk_dif_ctx     dif_ctx;
      93                 :            :         struct spdk_dif_error   dif_err;
      94                 :            :         TAILQ_ENTRY(ap_task)    link;
      95                 :            : };
      96                 :            : 
      97                 :            : struct worker_thread {
      98                 :            :         struct spdk_io_channel          *ch;
      99                 :            :         struct spdk_accel_opcode_stats  stats;
     100                 :            :         uint64_t                        xfer_failed;
     101                 :            :         uint64_t                        injected_miscompares;
     102                 :            :         uint64_t                        current_queue_depth;
     103                 :            :         TAILQ_HEAD(, ap_task)           tasks_pool;
     104                 :            :         struct worker_thread            *next;
     105                 :            :         unsigned                        core;
     106                 :            :         struct spdk_thread              *thread;
     107                 :            :         bool                            is_draining;
     108                 :            :         struct spdk_poller              *is_draining_poller;
     109                 :            :         struct spdk_poller              *stop_poller;
     110                 :            :         void                            *task_base;
     111                 :            :         struct display_info             display;
     112                 :            :         enum spdk_accel_opcode          workload;
     113                 :            : };
     114                 :            : 
     115                 :            : static void
     116                 :          0 : dump_user_config(void)
     117                 :            : {
     118                 :          0 :         const char *module_name = NULL;
     119                 :            :         int rc;
     120                 :            : 
     121                 :          0 :         rc = spdk_accel_get_opc_module_name(g_workload_selection, &module_name);
     122         [ #  # ]:          0 :         if (rc) {
     123                 :          0 :                 printf("error getting module name (%d)\n", rc);
     124                 :          0 :         }
     125                 :            : 
     126                 :          0 :         printf("\nSPDK Configuration:\n");
     127                 :          0 :         printf("Core mask:      %s\n\n", g_opts.reactor_mask);
     128                 :          0 :         printf("Accel Perf Configuration:\n");
     129                 :          0 :         printf("Workload Type:  %s\n", g_workload_type);
     130   [ #  #  #  # ]:          0 :         if (g_workload_selection == SPDK_ACCEL_OPC_CRC32C ||
     131                 :          0 :             g_workload_selection == SPDK_ACCEL_OPC_COPY_CRC32C) {
     132                 :          0 :                 printf("CRC-32C seed:   %u\n", g_crc32c_seed);
     133         [ #  # ]:          0 :         } else if (g_workload_selection == SPDK_ACCEL_OPC_FILL) {
     134                 :          0 :                 printf("Fill pattern:   0x%x\n", g_fill_pattern);
     135   [ #  #  #  # ]:          0 :         } else if ((g_workload_selection == SPDK_ACCEL_OPC_COMPARE) && g_fail_percent_goal > 0) {
     136                 :          0 :                 printf("Failure inject: %u percent\n", g_fail_percent_goal);
     137         [ #  # ]:          0 :         } else if (g_workload_selection == SPDK_ACCEL_OPC_XOR) {
     138                 :          0 :                 printf("Source buffers: %u\n", g_xor_src_count);
     139                 :          0 :         }
     140   [ #  #  #  # ]:          0 :         if (g_workload_selection == SPDK_ACCEL_OPC_COPY_CRC32C ||
     141         [ #  # ]:          0 :             g_workload_selection == SPDK_ACCEL_OPC_DIF_VERIFY ||
     142         [ #  # ]:          0 :             g_workload_selection == SPDK_ACCEL_OPC_DIF_GENERATE ||
     143         [ #  # ]:          0 :             g_workload_selection == SPDK_ACCEL_OPC_DIX_VERIFY ||
     144         [ #  # ]:          0 :             g_workload_selection == SPDK_ACCEL_OPC_DIX_GENERATE ||
     145                 :          0 :             g_workload_selection == SPDK_ACCEL_OPC_DIF_GENERATE_COPY) {
     146                 :          0 :                 printf("Vector size:    %u bytes\n", g_xfer_size_bytes);
     147                 :          0 :                 printf("Transfer size:  %u bytes\n", g_xfer_size_bytes * g_chained_count);
     148                 :          0 :         } else {
     149                 :          0 :                 printf("Transfer size:  %u bytes\n", g_xfer_size_bytes);
     150                 :            :         }
     151   [ #  #  #  # ]:          0 :         if (g_workload_selection == SPDK_ACCEL_OPC_DIF_GENERATE ||
     152         [ #  # ]:          0 :             g_workload_selection == SPDK_ACCEL_OPC_DIF_VERIFY ||
     153         [ #  # ]:          0 :             g_workload_selection == SPDK_ACCEL_OPC_DIX_GENERATE ||
     154                 :          0 :             g_workload_selection == SPDK_ACCEL_OPC_DIX_VERIFY) {
     155                 :          0 :                 printf("Block size:     %u bytes\n", g_block_size_bytes);
     156                 :          0 :                 printf("Metadata size:  %u bytes\n", g_md_size_bytes);
     157                 :          0 :         }
     158                 :          0 :         printf("Vector count    %u\n", g_chained_count);
     159                 :          0 :         printf("Module:         %s\n", module_name);
     160   [ #  #  #  # ]:          0 :         if (g_workload_selection == SPDK_ACCEL_OPC_COMPRESS ||
     161                 :          0 :             g_workload_selection == SPDK_ACCEL_OPC_DECOMPRESS) {
     162                 :          0 :                 printf("File Name:      %s\n", g_cd_file_in_name);
     163                 :          0 :         }
     164                 :          0 :         printf("Queue depth:    %u\n", g_queue_depth);
     165                 :          0 :         printf("Allocate depth: %u\n", g_allocate_depth);
     166                 :          0 :         printf("# threads/core: %u\n", g_threads_per_core);
     167                 :          0 :         printf("Run time:       %u seconds\n", g_time_in_sec);
     168                 :          0 :         printf("Verify:         %s\n\n", g_verify ? "Yes" : "No");
     169                 :          0 : }
     170                 :            : 
     171                 :            : static void
     172                 :          0 : usage(void)
     173                 :            : {
     174                 :          0 :         printf("accel_perf options:\n");
     175                 :          0 :         printf("\t[-h help message]\n");
     176                 :          0 :         printf("\t[-q queue depth per core]\n");
     177                 :          0 :         printf("\t[-C for supported workloads, use this value to configure the io vector size to test (default 1)\n");
     178                 :          0 :         printf("\t[-T number of threads per core\n");
     179                 :          0 :         printf("\t[-o transfer size in bytes (default: 4KiB. For compress/decompress, 0 means the input file size)]\n");
     180                 :          0 :         printf("\t[-t time in seconds]\n");
     181                 :          0 :         printf("\t[-w workload type must be one of these: copy, fill, crc32c, copy_crc32c, compare, compress, decompress, dualcast, xor,\n");
     182                 :          0 :         printf("\t[                                       dif_verify, dif_verify_copy, dif_generate, dif_generate_copy, dix_generate, dix_verify\n");
     183                 :          0 :         printf("\t[-M assign module to the operation, not compatible with accel_assign_opc RPC\n");
     184                 :          0 :         printf("\t[-l for compress/decompress workloads, name of uncompressed input file\n");
     185                 :          0 :         printf("\t[-S for crc32c workload, use this seed value (default 0)\n");
     186                 :          0 :         printf("\t[-P for compare workload, percentage of operations that should miscompare (percent, default 0)\n");
     187                 :          0 :         printf("\t[-f for fill workload, use this BYTE value (default 255)\n");
     188                 :          0 :         printf("\t[-x for xor workload, use this number of source buffers (default, minimum: 2)]\n");
     189                 :          0 :         printf("\t[-y verify result if this switch is on]\n");
     190                 :          0 :         printf("\t[-a tasks to allocate per core (default: same value as -q)]\n");
     191                 :          0 :         printf("\t\tCan be used to spread operations across a wider range of memory.\n");
     192                 :          0 : }
     193                 :            : 
     194                 :            : static int
     195                 :          0 : parse_args(int ch, char *arg)
     196                 :            : {
     197                 :          0 :         int argval = 0;
     198                 :            : 
     199         [ #  # ]:          0 :         switch (ch) {
     200                 :            :         case 'a':
     201                 :            :         case 'C':
     202                 :            :         case 'f':
     203                 :            :         case 'T':
     204                 :            :         case 'o':
     205                 :            :         case 'P':
     206                 :            :         case 'q':
     207                 :            :         case 'S':
     208                 :            :         case 't':
     209                 :            :         case 'x':
     210                 :          0 :                 argval = spdk_strtol(optarg, 10);
     211         [ #  # ]:          0 :                 if (argval < 0) {
     212                 :          0 :                         fprintf(stderr, "-%c option must be non-negative.\n", ch);
     213                 :          0 :                         usage();
     214                 :          0 :                         return 1;
     215                 :            :                 }
     216                 :          0 :                 break;
     217                 :            :         default:
     218                 :          0 :                 break;
     219                 :            :         };
     220                 :            : 
     221   [ #  #  #  #  :          0 :         switch (ch) {
          #  #  #  #  #  
          #  #  #  #  #  
                      # ]
     222                 :            :         case 'a':
     223                 :          0 :                 g_allocate_depth = argval;
     224                 :          0 :                 break;
     225                 :            :         case 'C':
     226                 :          0 :                 g_chained_count = argval;
     227                 :          0 :                 break;
     228                 :            :         case 'l':
     229                 :          0 :                 g_cd_file_in_name = optarg;
     230                 :          0 :                 break;
     231                 :            :         case 'f':
     232                 :          0 :                 g_fill_pattern = (uint8_t)argval;
     233                 :          0 :                 break;
     234                 :            :         case 'T':
     235                 :          0 :                 g_threads_per_core = argval;
     236                 :          0 :                 break;
     237                 :            :         case 'o':
     238                 :          0 :                 g_xfer_size_bytes = argval;
     239                 :          0 :                 break;
     240                 :            :         case 'P':
     241                 :          0 :                 g_fail_percent_goal = argval;
     242                 :          0 :                 break;
     243                 :            :         case 'q':
     244                 :          0 :                 g_queue_depth = argval;
     245                 :          0 :                 break;
     246                 :            :         case 'S':
     247                 :          0 :                 g_crc32c_seed = argval;
     248                 :          0 :                 break;
     249                 :            :         case 't':
     250                 :          0 :                 g_time_in_sec = argval;
     251                 :          0 :                 break;
     252                 :            :         case 'x':
     253                 :          0 :                 g_xor_src_count = argval;
     254                 :          0 :                 break;
     255                 :            :         case 'y':
     256                 :          0 :                 g_verify = true;
     257                 :          0 :                 break;
     258                 :            :         case 'w':
     259                 :          0 :                 g_workload_type = optarg;
     260         [ #  # ]:          0 :                 if (!strcmp(g_workload_type, "copy")) {
     261                 :          0 :                         g_workload_selection = SPDK_ACCEL_OPC_COPY;
     262         [ #  # ]:          0 :                 } else if (!strcmp(g_workload_type, "fill")) {
     263                 :          0 :                         g_workload_selection = SPDK_ACCEL_OPC_FILL;
     264         [ #  # ]:          0 :                 } else if (!strcmp(g_workload_type, "crc32c")) {
     265                 :          0 :                         g_workload_selection = SPDK_ACCEL_OPC_CRC32C;
     266         [ #  # ]:          0 :                 } else if (!strcmp(g_workload_type, "copy_crc32c")) {
     267                 :          0 :                         g_workload_selection = SPDK_ACCEL_OPC_COPY_CRC32C;
     268         [ #  # ]:          0 :                 } else if (!strcmp(g_workload_type, "compare")) {
     269                 :          0 :                         g_workload_selection = SPDK_ACCEL_OPC_COMPARE;
     270         [ #  # ]:          0 :                 } else if (!strcmp(g_workload_type, "dualcast")) {
     271                 :          0 :                         g_workload_selection = SPDK_ACCEL_OPC_DUALCAST;
     272         [ #  # ]:          0 :                 } else if (!strcmp(g_workload_type, "compress")) {
     273                 :          0 :                         g_workload_selection = SPDK_ACCEL_OPC_COMPRESS;
     274         [ #  # ]:          0 :                 } else if (!strcmp(g_workload_type, "decompress")) {
     275                 :          0 :                         g_workload_selection = SPDK_ACCEL_OPC_DECOMPRESS;
     276         [ #  # ]:          0 :                 } else if (!strcmp(g_workload_type, "xor")) {
     277                 :          0 :                         g_workload_selection = SPDK_ACCEL_OPC_XOR;
     278         [ #  # ]:          0 :                 } else if (!strcmp(g_workload_type, "dif_verify")) {
     279                 :          0 :                         g_workload_selection = SPDK_ACCEL_OPC_DIF_VERIFY;
     280         [ #  # ]:          0 :                 } else if (!strcmp(g_workload_type, "dif_verify_copy")) {
     281                 :          0 :                         g_workload_selection = SPDK_ACCEL_OPC_DIF_VERIFY_COPY;
     282         [ #  # ]:          0 :                 } else if (!strcmp(g_workload_type, "dif_generate")) {
     283                 :          0 :                         g_workload_selection = SPDK_ACCEL_OPC_DIF_GENERATE;
     284         [ #  # ]:          0 :                 } else if (!strcmp(g_workload_type, "dif_generate_copy")) {
     285                 :          0 :                         g_workload_selection = SPDK_ACCEL_OPC_DIF_GENERATE_COPY;
     286         [ #  # ]:          0 :                 } else if (!strcmp(g_workload_type, "dix_verify")) {
     287                 :          0 :                         g_workload_selection = SPDK_ACCEL_OPC_DIX_VERIFY;
     288         [ #  # ]:          0 :                 } else if (!strcmp(g_workload_type, "dix_generate")) {
     289                 :          0 :                         g_workload_selection = SPDK_ACCEL_OPC_DIX_GENERATE;
     290                 :          0 :                 } else {
     291                 :          0 :                         fprintf(stderr, "Unsupported workload type: %s\n", optarg);
     292                 :          0 :                         usage();
     293                 :          0 :                         return 1;
     294                 :            :                 }
     295                 :          0 :                 break;
     296                 :            :         case 'M':
     297                 :          0 :                 g_module_name = optarg;
     298                 :          0 :                 break;
     299                 :            : 
     300                 :            :         default:
     301                 :          0 :                 usage();
     302                 :          0 :                 return 1;
     303                 :            :         }
     304                 :            : 
     305                 :          0 :         return 0;
     306                 :          0 : }
     307                 :            : 
     308                 :            : static int dump_result(void);
     309                 :            : static void
     310                 :          0 : unregister_worker(void *arg1)
     311                 :            : {
     312                 :          0 :         struct worker_thread *worker = arg1;
     313                 :            : 
     314         [ #  # ]:          0 :         if (worker->ch) {
     315                 :          0 :                 spdk_accel_get_opcode_stats(worker->ch, worker->workload,
     316                 :          0 :                                             &worker->stats, sizeof(worker->stats));
     317                 :          0 :                 spdk_put_io_channel(worker->ch);
     318                 :          0 :                 worker->ch = NULL;
     319                 :          0 :         }
     320                 :          0 :         free(worker->task_base);
     321                 :          0 :         spdk_thread_exit(spdk_get_thread());
     322                 :          0 :         pthread_mutex_lock(&g_workers_lock);
     323         [ #  # ]:          0 :         assert(g_num_workers >= 1);
     324         [ #  # ]:          0 :         if (--g_num_workers == 0) {
     325                 :          0 :                 pthread_mutex_unlock(&g_workers_lock);
     326                 :            :                 /* Only dump results on successful runs */
     327         [ #  # ]:          0 :                 if (g_rc == 0) {
     328                 :          0 :                         g_rc = dump_result();
     329                 :          0 :                 }
     330                 :          0 :                 spdk_app_stop(g_rc);
     331                 :          0 :         } else {
     332                 :          0 :                 pthread_mutex_unlock(&g_workers_lock);
     333                 :            :         }
     334                 :          0 : }
     335                 :            : 
     336                 :            : static void
     337                 :          0 : accel_perf_construct_iovs(void *buf, uint64_t sz, struct iovec *iovs, uint32_t iovcnt)
     338                 :            : {
     339                 :            :         uint64_t ele_size;
     340                 :            :         uint8_t *data;
     341                 :            :         uint32_t i;
     342                 :            : 
     343                 :          0 :         ele_size = spdk_divide_round_up(sz, iovcnt);
     344                 :            : 
     345                 :          0 :         data = buf;
     346         [ #  # ]:          0 :         for (i = 0; i < iovcnt; i++) {
     347         [ #  # ]:          0 :                 ele_size = spdk_min(ele_size, sz);
     348         [ #  # ]:          0 :                 assert(ele_size > 0);
     349                 :            : 
     350                 :          0 :                 iovs[i].iov_base = data;
     351                 :          0 :                 iovs[i].iov_len = ele_size;
     352                 :            : 
     353                 :          0 :                 data += ele_size;
     354                 :          0 :                 sz -= ele_size;
     355                 :          0 :         }
     356         [ #  # ]:          0 :         assert(sz == 0);
     357                 :          0 : }
     358                 :            : 
     359                 :            : static int
     360                 :          0 : _get_task_data_bufs(struct ap_task *task)
     361                 :            : {
     362                 :          0 :         uint32_t align = 0;
     363                 :          0 :         uint32_t i = 0;
     364                 :          0 :         int src_buff_len = g_xfer_size_bytes;
     365                 :          0 :         int dst_buff_len = g_xfer_size_bytes;
     366                 :            :         int md_buff_len;
     367                 :            :         struct spdk_dif_ctx_init_ext_opts dif_opts;
     368                 :            :         uint32_t num_blocks, transfer_size_with_md;
     369                 :            :         int rc;
     370                 :            : 
     371                 :            :         /* For dualcast, the DSA HW requires 4K alignment on destination addresses but
     372                 :            :          * we do this for all modules to keep it simple.
     373                 :            :          */
     374         [ #  # ]:          0 :         if (g_workload_selection == SPDK_ACCEL_OPC_DUALCAST) {
     375                 :          0 :                 align = ALIGN_4K;
     376                 :          0 :         }
     377                 :            : 
     378   [ #  #  #  # ]:          0 :         if (g_workload_selection == SPDK_ACCEL_OPC_COMPRESS ||
     379                 :          0 :             g_workload_selection == SPDK_ACCEL_OPC_DECOMPRESS) {
     380                 :          0 :                 task->cur_seg = STAILQ_FIRST(&g_compress_segs);
     381                 :            : 
     382         [ #  # ]:          0 :                 if (g_workload_selection == SPDK_ACCEL_OPC_COMPRESS) {
     383                 :          0 :                         dst_buff_len = task->cur_seg->compressed_len_padded;
     384                 :          0 :                 }
     385                 :            : 
     386                 :          0 :                 task->dst = spdk_dma_zmalloc(dst_buff_len, align, NULL);
     387         [ #  # ]:          0 :                 if (task->dst == NULL) {
     388                 :          0 :                         fprintf(stderr, "Unable to alloc dst buffer\n");
     389                 :          0 :                         return -ENOMEM;
     390                 :            :                 }
     391                 :            : 
     392                 :          0 :                 task->dst_iovs = calloc(g_chained_count, sizeof(struct iovec));
     393         [ #  # ]:          0 :                 if (!task->dst_iovs) {
     394                 :          0 :                         fprintf(stderr, "cannot allocate task->dst_iovs for task=%p\n", task);
     395                 :          0 :                         return -ENOMEM;
     396                 :            :                 }
     397                 :          0 :                 task->dst_iovcnt = g_chained_count;
     398                 :          0 :                 accel_perf_construct_iovs(task->dst, dst_buff_len, task->dst_iovs, task->dst_iovcnt);
     399                 :            : 
     400                 :          0 :                 return 0;
     401                 :            :         }
     402                 :            : 
     403         [ #  # ]:          0 :         if (g_workload_selection == SPDK_ACCEL_OPC_DIF_GENERATE_COPY) {
     404                 :          0 :                 task->dst_iovcnt = g_chained_count;
     405                 :          0 :                 task->dst_iovs = calloc(task->dst_iovcnt, sizeof(struct iovec));
     406         [ #  # ]:          0 :                 if (!task->dst_iovs) {
     407                 :          0 :                         fprintf(stderr, "cannot allocate task->dst_iovs for task=%p\n", task);
     408                 :          0 :                         return -ENOMEM;
     409                 :            :                 }
     410                 :            : 
     411                 :          0 :                 num_blocks = g_xfer_size_bytes / g_block_size_bytes;
     412                 :            :                 /* Add bytes for each block for metadata */
     413                 :          0 :                 transfer_size_with_md = g_xfer_size_bytes + (num_blocks * g_md_size_bytes);
     414                 :          0 :                 task->num_blocks = num_blocks;
     415                 :            : 
     416         [ #  # ]:          0 :                 for (i = 0; i < task->dst_iovcnt; i++) {
     417                 :          0 :                         task->dst_iovs[i].iov_base = spdk_dma_zmalloc(transfer_size_with_md, 0, NULL);
     418         [ #  # ]:          0 :                         if (task->dst_iovs[i].iov_base == NULL) {
     419                 :          0 :                                 return -ENOMEM;
     420                 :            :                         }
     421                 :          0 :                         task->dst_iovs[i].iov_len = transfer_size_with_md;
     422                 :          0 :                 }
     423                 :            : 
     424                 :          0 :                 dif_opts.size = SPDK_SIZEOF(&dif_opts, dif_pi_format);
     425                 :          0 :                 dif_opts.dif_pi_format = SPDK_DIF_PI_FORMAT_16;
     426                 :            : 
     427                 :          0 :                 rc = spdk_dif_ctx_init(&task->dif_ctx,
     428                 :          0 :                                        g_block_size_bytes + g_md_size_bytes,
     429                 :          0 :                                        g_md_size_bytes, true, true,
     430                 :            :                                        SPDK_DIF_TYPE1,
     431                 :            :                                        SPDK_DIF_FLAGS_GUARD_CHECK | SPDK_DIF_FLAGS_APPTAG_CHECK | SPDK_DIF_FLAGS_REFTAG_CHECK,
     432                 :            :                                        0x123, 0xFFFF, 0x234, 0, 0, &dif_opts);
     433         [ #  # ]:          0 :                 if (rc != 0) {
     434                 :          0 :                         fprintf(stderr, "Initialization of DIF context failed, error (%d)\n", rc);
     435                 :          0 :                         return rc;
     436                 :            :                 }
     437                 :          0 :         }
     438                 :            : 
     439         [ #  # ]:          0 :         if (g_workload_selection == SPDK_ACCEL_OPC_DIF_VERIFY_COPY) {
     440                 :            :                 /* Allocate source buffers */
     441                 :          0 :                 task->src_iovcnt = g_chained_count;
     442                 :          0 :                 task->src_iovs = calloc(task->src_iovcnt, sizeof(struct iovec));
     443         [ #  # ]:          0 :                 if (!task->src_iovs) {
     444                 :          0 :                         fprintf(stderr, "cannot allocate task->src_iovs for task=%p\n", task);
     445                 :          0 :                         return -ENOMEM;
     446                 :            :                 }
     447                 :            : 
     448                 :          0 :                 num_blocks = g_xfer_size_bytes / g_block_size_bytes;
     449                 :            :                 /* Add bytes for each block for metadata */
     450                 :          0 :                 transfer_size_with_md = g_xfer_size_bytes + (num_blocks * g_md_size_bytes);
     451                 :          0 :                 task->num_blocks = num_blocks;
     452                 :            : 
     453         [ #  # ]:          0 :                 for (i = 0; i < task->src_iovcnt; i++) {
     454                 :          0 :                         task->src_iovs[i].iov_base = spdk_dma_zmalloc(transfer_size_with_md, 0, NULL);
     455         [ #  # ]:          0 :                         if (task->src_iovs[i].iov_base == NULL) {
     456                 :          0 :                                 return -ENOMEM;
     457                 :            :                         }
     458                 :          0 :                         memset(task->src_iovs[i].iov_base, DATA_PATTERN, transfer_size_with_md);
     459                 :          0 :                         task->src_iovs[i].iov_len = transfer_size_with_md;
     460                 :          0 :                 }
     461                 :            : 
     462                 :            :                 /* Allocate destination buffers */
     463                 :          0 :                 task->dst_iovcnt = g_chained_count;
     464                 :          0 :                 task->dst_iovs = calloc(task->dst_iovcnt, sizeof(struct iovec));
     465         [ #  # ]:          0 :                 if (!task->dst_iovs) {
     466                 :          0 :                         fprintf(stderr, "cannot allocated task->dst_iovs fot task=%p\n", task);
     467                 :          0 :                         return -ENOMEM;
     468                 :            :                 }
     469                 :            : 
     470         [ #  # ]:          0 :                 for (i = 0; i < task->dst_iovcnt; i++) {
     471                 :          0 :                         task->dst_iovs[i].iov_base = spdk_dma_zmalloc(dst_buff_len, 0, NULL);
     472         [ #  # ]:          0 :                         if (task->dst_iovs[i].iov_base == NULL) {
     473                 :          0 :                                 return -ENOMEM;
     474                 :            :                         }
     475                 :          0 :                         task->dst_iovs[i].iov_len = dst_buff_len;
     476                 :          0 :                 }
     477                 :            : 
     478                 :          0 :                 dif_opts.size = SPDK_SIZEOF(&dif_opts, dif_pi_format);
     479                 :          0 :                 dif_opts.dif_pi_format = SPDK_DIF_PI_FORMAT_16;
     480                 :            : 
     481                 :            :                 /* Init DIF ctx */
     482                 :          0 :                 rc = spdk_dif_ctx_init(&task->dif_ctx,
     483                 :          0 :                                        g_block_size_bytes + g_md_size_bytes,
     484                 :          0 :                                        g_md_size_bytes, true, true,
     485                 :            :                                        SPDK_DIF_TYPE1,
     486                 :            :                                        SPDK_DIF_FLAGS_GUARD_CHECK | SPDK_DIF_FLAGS_APPTAG_CHECK | SPDK_DIF_FLAGS_REFTAG_CHECK,
     487                 :            :                                        0x123, 0xFFFF, 0x234, 0, 0, &dif_opts);
     488         [ #  # ]:          0 :                 if (rc != 0) {
     489                 :          0 :                         fprintf(stderr, "Initialization of DIF context failed, error (%d)\n", rc);
     490                 :          0 :                         return rc;
     491                 :            :                 }
     492                 :            : 
     493                 :          0 :                 rc = spdk_dif_generate(task->src_iovs, task->src_iovcnt, task->num_blocks, &task->dif_ctx);
     494         [ #  # ]:          0 :                 if (rc != 0) {
     495                 :          0 :                         fprintf(stderr, "Generation of DIF failed, error (%d)\n", rc);
     496                 :          0 :                         return rc;
     497                 :            :                 }
     498                 :          0 :         }
     499                 :            : 
     500   [ #  #  #  # ]:          0 :         if (g_workload_selection == SPDK_ACCEL_OPC_CRC32C ||
     501                 :          0 :             g_workload_selection == SPDK_ACCEL_OPC_COPY_CRC32C) {
     502                 :          0 :                 task->crc_dst = spdk_dma_zmalloc(sizeof(*task->crc_dst), 0, NULL);
     503                 :          0 :         }
     504                 :            : 
     505   [ #  #  #  # ]:          0 :         if (g_workload_selection == SPDK_ACCEL_OPC_CRC32C ||
     506         [ #  # ]:          0 :             g_workload_selection == SPDK_ACCEL_OPC_COPY_CRC32C ||
     507         [ #  # ]:          0 :             g_workload_selection == SPDK_ACCEL_OPC_DIF_VERIFY ||
     508         [ #  # ]:          0 :             g_workload_selection == SPDK_ACCEL_OPC_DIF_GENERATE ||
     509         [ #  # ]:          0 :             g_workload_selection == SPDK_ACCEL_OPC_DIF_GENERATE_COPY ||
     510         [ #  # ]:          0 :             g_workload_selection == SPDK_ACCEL_OPC_DIX_VERIFY ||
     511                 :          0 :             g_workload_selection == SPDK_ACCEL_OPC_DIX_GENERATE) {
     512         [ #  # ]:          0 :                 assert(g_chained_count > 0);
     513                 :          0 :                 task->src_iovcnt = g_chained_count;
     514                 :          0 :                 task->src_iovs = calloc(task->src_iovcnt, sizeof(struct iovec));
     515         [ #  # ]:          0 :                 if (!task->src_iovs) {
     516                 :          0 :                         fprintf(stderr, "cannot allocated task->src_iovs fot task=%p\n", task);
     517                 :          0 :                         return -ENOMEM;
     518                 :            :                 }
     519                 :            : 
     520         [ #  # ]:          0 :                 if (g_workload_selection == SPDK_ACCEL_OPC_COPY_CRC32C) {
     521                 :          0 :                         dst_buff_len = g_xfer_size_bytes * g_chained_count;
     522                 :          0 :                 }
     523                 :            : 
     524   [ #  #  #  # ]:          0 :                 if (g_workload_selection == SPDK_ACCEL_OPC_DIF_GENERATE ||
     525                 :          0 :                     g_workload_selection == SPDK_ACCEL_OPC_DIF_VERIFY) {
     526                 :          0 :                         src_buff_len += (g_xfer_size_bytes / g_block_size_bytes) * g_md_size_bytes;
     527                 :          0 :                 }
     528                 :            : 
     529         [ #  # ]:          0 :                 for (i = 0; i < task->src_iovcnt; i++) {
     530                 :          0 :                         task->src_iovs[i].iov_base = spdk_dma_zmalloc(src_buff_len, 0, NULL);
     531         [ #  # ]:          0 :                         if (task->src_iovs[i].iov_base == NULL) {
     532                 :          0 :                                 return -ENOMEM;
     533                 :            :                         }
     534                 :          0 :                         memset(task->src_iovs[i].iov_base, DATA_PATTERN, src_buff_len);
     535                 :          0 :                         task->src_iovs[i].iov_len = src_buff_len;
     536                 :          0 :                 }
     537   [ #  #  #  # ]:          0 :                 if (g_workload_selection == SPDK_ACCEL_OPC_DIX_GENERATE ||
     538                 :          0 :                     g_workload_selection == SPDK_ACCEL_OPC_DIX_VERIFY) {
     539                 :          0 :                         md_buff_len = (g_xfer_size_bytes / g_block_size_bytes) * g_md_size_bytes *
     540                 :          0 :                                       g_chained_count;
     541                 :          0 :                         task->md_iov.iov_base = spdk_dma_zmalloc(md_buff_len, 0, NULL);
     542         [ #  # ]:          0 :                         if (task->md_iov.iov_base == NULL) {
     543                 :          0 :                                 return -ENOMEM;
     544                 :            :                         }
     545                 :          0 :                         task->md_iov.iov_len = md_buff_len;
     546                 :          0 :                 }
     547         [ #  # ]:          0 :         } else if (g_workload_selection == SPDK_ACCEL_OPC_XOR) {
     548         [ #  # ]:          0 :                 assert(g_xor_src_count > 1);
     549                 :          0 :                 task->sources = calloc(g_xor_src_count, sizeof(*task->sources));
     550         [ #  # ]:          0 :                 if (!task->sources) {
     551                 :          0 :                         return -ENOMEM;
     552                 :            :                 }
     553                 :            : 
     554         [ #  # ]:          0 :                 for (i = 0; i < g_xor_src_count; i++) {
     555                 :          0 :                         task->sources[i] = spdk_dma_zmalloc(g_xfer_size_bytes, 0, NULL);
     556         [ #  # ]:          0 :                         if (!task->sources[i]) {
     557                 :          0 :                                 return -ENOMEM;
     558                 :            :                         }
     559                 :          0 :                         memset(task->sources[i], DATA_PATTERN, g_xfer_size_bytes);
     560                 :          0 :                 }
     561                 :          0 :         } else {
     562                 :          0 :                 task->src = spdk_dma_zmalloc(g_xfer_size_bytes, 0, NULL);
     563         [ #  # ]:          0 :                 if (task->src == NULL) {
     564                 :          0 :                         fprintf(stderr, "Unable to alloc src buffer\n");
     565                 :          0 :                         return -ENOMEM;
     566                 :            :                 }
     567                 :            : 
     568                 :            :                 /* For fill, set the entire src buffer so we can check if verify is enabled. */
     569         [ #  # ]:          0 :                 if (g_workload_selection == SPDK_ACCEL_OPC_FILL) {
     570                 :          0 :                         memset(task->src, g_fill_pattern, g_xfer_size_bytes);
     571                 :          0 :                 } else {
     572                 :          0 :                         memset(task->src, DATA_PATTERN, g_xfer_size_bytes);
     573                 :            :                 }
     574                 :            :         }
     575                 :            : 
     576   [ #  #  #  # ]:          0 :         if (g_workload_selection != SPDK_ACCEL_OPC_CRC32C &&
     577         [ #  # ]:          0 :             g_workload_selection != SPDK_ACCEL_OPC_DIF_VERIFY &&
     578         [ #  # ]:          0 :             g_workload_selection != SPDK_ACCEL_OPC_DIF_GENERATE &&
     579         [ #  # ]:          0 :             g_workload_selection != SPDK_ACCEL_OPC_DIF_GENERATE_COPY &&
     580         [ #  # ]:          0 :             g_workload_selection != SPDK_ACCEL_OPC_DIF_VERIFY_COPY &&
     581         [ #  # ]:          0 :             g_workload_selection != SPDK_ACCEL_OPC_DIX_VERIFY &&
     582                 :          0 :             g_workload_selection != SPDK_ACCEL_OPC_DIX_GENERATE) {
     583                 :          0 :                 task->dst = spdk_dma_zmalloc(dst_buff_len, align, NULL);
     584         [ #  # ]:          0 :                 if (task->dst == NULL) {
     585                 :          0 :                         fprintf(stderr, "Unable to alloc dst buffer\n");
     586                 :          0 :                         return -ENOMEM;
     587                 :            :                 }
     588                 :            : 
     589                 :            :                 /* For compare we want the buffers to match, otherwise not. */
     590         [ #  # ]:          0 :                 if (g_workload_selection == SPDK_ACCEL_OPC_COMPARE) {
     591                 :          0 :                         memset(task->dst, DATA_PATTERN, dst_buff_len);
     592                 :          0 :                 } else {
     593                 :          0 :                         memset(task->dst, ~DATA_PATTERN, dst_buff_len);
     594                 :            :                 }
     595                 :          0 :         }
     596                 :            : 
     597                 :            :         /* For dualcast 2 buffers are needed for the operation.  */
     598   [ #  #  #  # ]:          0 :         if (g_workload_selection == SPDK_ACCEL_OPC_DUALCAST ||
     599         [ #  # ]:          0 :             (g_workload_selection == SPDK_ACCEL_OPC_XOR && g_verify)) {
     600                 :          0 :                 task->dst2 = spdk_dma_zmalloc(g_xfer_size_bytes, align, NULL);
     601         [ #  # ]:          0 :                 if (task->dst2 == NULL) {
     602                 :          0 :                         fprintf(stderr, "Unable to alloc dst buffer\n");
     603                 :          0 :                         return -ENOMEM;
     604                 :            :                 }
     605                 :          0 :                 memset(task->dst2, ~DATA_PATTERN, g_xfer_size_bytes);
     606                 :          0 :         }
     607                 :            : 
     608   [ #  #  #  # ]:          0 :         if (g_workload_selection == SPDK_ACCEL_OPC_DIF_GENERATE ||
     609         [ #  # ]:          0 :             g_workload_selection == SPDK_ACCEL_OPC_DIF_VERIFY ||
     610                 :          0 :             g_workload_selection == SPDK_ACCEL_OPC_DIF_VERIFY_COPY) {
     611                 :          0 :                 dif_opts.size = SPDK_SIZEOF(&dif_opts, dif_pi_format);
     612                 :          0 :                 dif_opts.dif_pi_format = SPDK_DIF_PI_FORMAT_16;
     613                 :            : 
     614                 :          0 :                 task->num_blocks = (g_xfer_size_bytes * g_chained_count) / g_block_size_bytes;
     615                 :            : 
     616                 :          0 :                 rc = spdk_dif_ctx_init(&task->dif_ctx,
     617                 :          0 :                                        g_block_size_bytes + g_md_size_bytes,
     618                 :          0 :                                        g_md_size_bytes, true, true,
     619                 :            :                                        SPDK_DIF_TYPE1,
     620                 :            :                                        SPDK_DIF_FLAGS_GUARD_CHECK | SPDK_DIF_FLAGS_APPTAG_CHECK | SPDK_DIF_FLAGS_REFTAG_CHECK,
     621                 :            :                                        16, 0xFFFF, 10, 0, 0, &dif_opts);
     622         [ #  # ]:          0 :                 if (rc != 0) {
     623                 :          0 :                         fprintf(stderr, "Initialization of DIF context failed, error (%d)\n", rc);
     624                 :          0 :                         return rc;
     625                 :            :                 }
     626                 :            : 
     627   [ #  #  #  # ]:          0 :                 if ((g_workload_selection == SPDK_ACCEL_OPC_DIF_VERIFY) ||
     628                 :          0 :                     (g_workload_selection == SPDK_ACCEL_OPC_DIF_VERIFY_COPY)) {
     629                 :          0 :                         rc = spdk_dif_generate(task->src_iovs, task->src_iovcnt, task->num_blocks, &task->dif_ctx);
     630         [ #  # ]:          0 :                         if (rc != 0) {
     631                 :          0 :                                 fprintf(stderr, "Generation of DIF failed, error (%d)\n", rc);
     632                 :          0 :                                 return rc;
     633                 :            :                         }
     634                 :          0 :                 }
     635                 :          0 :         }
     636   [ #  #  #  # ]:          0 :         if (g_workload_selection == SPDK_ACCEL_OPC_DIX_GENERATE ||
     637                 :          0 :             g_workload_selection == SPDK_ACCEL_OPC_DIX_VERIFY) {
     638                 :          0 :                 dif_opts.size = SPDK_SIZEOF(&dif_opts, dif_pi_format);
     639                 :          0 :                 dif_opts.dif_pi_format = SPDK_DIF_PI_FORMAT_16;
     640                 :            : 
     641                 :          0 :                 task->num_blocks = (g_xfer_size_bytes * g_chained_count) / g_block_size_bytes;
     642                 :            : 
     643                 :          0 :                 rc = spdk_dif_ctx_init(&task->dif_ctx,
     644                 :          0 :                                        g_block_size_bytes,
     645                 :          0 :                                        g_md_size_bytes, false, true,
     646                 :            :                                        SPDK_DIF_TYPE1,
     647                 :            :                                        SPDK_DIF_FLAGS_GUARD_CHECK | SPDK_DIF_FLAGS_APPTAG_CHECK |
     648                 :            :                                        SPDK_DIF_FLAGS_REFTAG_CHECK,
     649                 :            :                                        0x123, 0xFFFF, 0x234, 0, 0, &dif_opts);
     650         [ #  # ]:          0 :                 if (rc != 0) {
     651                 :          0 :                         fprintf(stderr, "Initialization of DIX context failed, error (%d)\n", rc);
     652                 :          0 :                         return rc;
     653                 :            :                 }
     654         [ #  # ]:          0 :                 if (g_workload_selection == SPDK_ACCEL_OPC_DIX_VERIFY) {
     655                 :          0 :                         rc = spdk_dix_generate(task->src_iovs, task->src_iovcnt, &task->md_iov,
     656                 :          0 :                                                task->num_blocks, &task->dif_ctx);
     657         [ #  # ]:          0 :                         if (rc != 0) {
     658                 :          0 :                                 fprintf(stderr, "Generation of DIX failed, error (%d)\n", rc);
     659                 :          0 :                                 return rc;
     660                 :            :                         }
     661                 :          0 :                 }
     662                 :            : 
     663                 :          0 :         }
     664                 :            : 
     665                 :          0 :         return 0;
     666                 :          0 : }
     667                 :            : 
     668                 :            : inline static struct ap_task *
     669                 :          0 : _get_task(struct worker_thread *worker)
     670                 :            : {
     671                 :            :         struct ap_task *task;
     672                 :            : 
     673         [ #  # ]:          0 :         if (!TAILQ_EMPTY(&worker->tasks_pool)) {
     674                 :          0 :                 task = TAILQ_FIRST(&worker->tasks_pool);
     675         [ #  # ]:          0 :                 TAILQ_REMOVE(&worker->tasks_pool, task, link);
     676                 :          0 :         } else {
     677                 :          0 :                 fprintf(stderr, "Unable to get ap_task\n");
     678                 :          0 :                 return NULL;
     679                 :            :         }
     680                 :            : 
     681                 :          0 :         return task;
     682                 :          0 : }
     683                 :            : 
     684                 :            : /* Submit one operation using the same ap task that just completed. */
     685                 :            : static void
     686                 :          0 : _submit_single(struct worker_thread *worker, struct ap_task *task)
     687                 :            : {
     688                 :            :         int random_num;
     689                 :          0 :         int rc = 0;
     690                 :            : 
     691         [ #  # ]:          0 :         assert(worker);
     692                 :            : 
     693   [ #  #  #  #  :          0 :         switch (worker->workload) {
          #  #  #  #  #  
          #  #  #  #  #  
                   #  # ]
     694                 :            :         case SPDK_ACCEL_OPC_COPY:
     695                 :          0 :                 rc = spdk_accel_submit_copy(worker->ch, task->dst, task->src,
     696                 :          0 :                                             g_xfer_size_bytes, accel_done, task);
     697                 :          0 :                 break;
     698                 :            :         case SPDK_ACCEL_OPC_FILL:
     699                 :            :                 /* For fill use the first byte of the task->dst buffer */
     700                 :          0 :                 rc = spdk_accel_submit_fill(worker->ch, task->dst, *(uint8_t *)task->src,
     701                 :          0 :                                             g_xfer_size_bytes, accel_done, task);
     702                 :          0 :                 break;
     703                 :            :         case SPDK_ACCEL_OPC_CRC32C:
     704                 :          0 :                 rc = spdk_accel_submit_crc32cv(worker->ch, task->crc_dst,
     705                 :          0 :                                                task->src_iovs, task->src_iovcnt, g_crc32c_seed,
     706                 :          0 :                                                accel_done, task);
     707                 :          0 :                 break;
     708                 :            :         case SPDK_ACCEL_OPC_COPY_CRC32C:
     709                 :          0 :                 rc = spdk_accel_submit_copy_crc32cv(worker->ch, task->dst, task->src_iovs, task->src_iovcnt,
     710                 :          0 :                                                     task->crc_dst, g_crc32c_seed, accel_done, task);
     711                 :          0 :                 break;
     712                 :            :         case SPDK_ACCEL_OPC_COMPARE:
     713                 :          0 :                 random_num = rand() % 100;
     714         [ #  # ]:          0 :                 if (random_num < g_fail_percent_goal) {
     715                 :          0 :                         task->expected_status = -EILSEQ;
     716                 :          0 :                         *(uint8_t *)task->dst = ~DATA_PATTERN;
     717                 :          0 :                 } else {
     718                 :          0 :                         task->expected_status = 0;
     719                 :          0 :                         *(uint8_t *)task->dst = DATA_PATTERN;
     720                 :            :                 }
     721                 :          0 :                 rc = spdk_accel_submit_compare(worker->ch, task->dst, task->src,
     722                 :          0 :                                                g_xfer_size_bytes, accel_done, task);
     723                 :          0 :                 break;
     724                 :            :         case SPDK_ACCEL_OPC_DUALCAST:
     725                 :          0 :                 rc = spdk_accel_submit_dualcast(worker->ch, task->dst, task->dst2,
     726                 :          0 :                                                 task->src, g_xfer_size_bytes, accel_done, task);
     727                 :          0 :                 break;
     728                 :            :         case SPDK_ACCEL_OPC_COMPRESS:
     729                 :          0 :                 task->src_iovs = task->cur_seg->uncompressed_iovs;
     730                 :          0 :                 task->src_iovcnt = task->cur_seg->uncompressed_iovcnt;
     731                 :          0 :                 rc = spdk_accel_submit_compress(worker->ch, task->dst, task->cur_seg->compressed_len_padded,
     732                 :          0 :                                                 task->src_iovs,
     733                 :          0 :                                                 task->src_iovcnt, &task->compressed_sz, accel_done, task);
     734                 :          0 :                 break;
     735                 :            :         case SPDK_ACCEL_OPC_DECOMPRESS:
     736                 :          0 :                 task->src_iovs = task->cur_seg->compressed_iovs;
     737                 :          0 :                 task->src_iovcnt = task->cur_seg->compressed_iovcnt;
     738                 :          0 :                 rc = spdk_accel_submit_decompress(worker->ch, task->dst_iovs, task->dst_iovcnt, task->src_iovs,
     739                 :          0 :                                                   task->src_iovcnt, NULL, accel_done, task);
     740                 :          0 :                 break;
     741                 :            :         case SPDK_ACCEL_OPC_XOR:
     742                 :          0 :                 rc = spdk_accel_submit_xor(worker->ch, task->dst, task->sources, g_xor_src_count,
     743                 :          0 :                                            g_xfer_size_bytes, accel_done, task);
     744                 :          0 :                 break;
     745                 :            :         case SPDK_ACCEL_OPC_DIF_VERIFY:
     746                 :          0 :                 rc = spdk_accel_submit_dif_verify(worker->ch, task->src_iovs, task->src_iovcnt, task->num_blocks,
     747                 :          0 :                                                   &task->dif_ctx, &task->dif_err, accel_done, task);
     748                 :          0 :                 break;
     749                 :            :         case SPDK_ACCEL_OPC_DIF_GENERATE:
     750                 :          0 :                 rc = spdk_accel_submit_dif_generate(worker->ch, task->src_iovs, task->src_iovcnt, task->num_blocks,
     751                 :          0 :                                                     &task->dif_ctx, accel_done, task);
     752                 :          0 :                 break;
     753                 :            :         case SPDK_ACCEL_OPC_DIF_GENERATE_COPY:
     754                 :          0 :                 rc = spdk_accel_submit_dif_generate_copy(worker->ch, task->dst_iovs, task->dst_iovcnt,
     755                 :          0 :                                 task->src_iovs, task->src_iovcnt,
     756                 :          0 :                                 task->num_blocks, &task->dif_ctx, accel_done, task);
     757                 :          0 :                 break;
     758                 :            :         case SPDK_ACCEL_OPC_DIF_VERIFY_COPY:
     759                 :          0 :                 rc = spdk_accel_submit_dif_verify_copy(worker->ch, task->dst_iovs, task->dst_iovcnt,
     760                 :          0 :                                                        task->src_iovs, task->src_iovcnt, task->num_blocks,
     761                 :          0 :                                                        &task->dif_ctx, &task->dif_err, accel_done, task);
     762                 :          0 :                 break;
     763                 :            :         case SPDK_ACCEL_OPC_DIX_GENERATE:
     764                 :          0 :                 rc = spdk_accel_submit_dix_generate(worker->ch, task->src_iovs, task->src_iovcnt,
     765                 :          0 :                                                     &task->md_iov, task->num_blocks,
     766                 :          0 :                                                     &task->dif_ctx, accel_done, task);
     767                 :          0 :                 break;
     768                 :            :         case SPDK_ACCEL_OPC_DIX_VERIFY:
     769                 :          0 :                 rc = spdk_accel_submit_dix_verify(worker->ch, task->src_iovs, task->src_iovcnt,
     770                 :          0 :                                                   &task->md_iov, task->num_blocks,
     771                 :          0 :                                                   &task->dif_ctx, &task->dif_err, accel_done, task);
     772                 :          0 :                 break;
     773                 :            :         default:
     774                 :          0 :                 assert(false);
     775                 :            :                 break;
     776                 :            : 
     777                 :            :         }
     778                 :            : 
     779                 :          0 :         worker->current_queue_depth++;
     780         [ #  # ]:          0 :         if (rc) {
     781                 :          0 :                 accel_done(task, rc);
     782                 :          0 :         }
     783                 :          0 : }
     784                 :            : 
     785                 :            : static void
     786                 :          0 : _free_task_buffers(struct ap_task *task)
     787                 :            : {
     788                 :            :         uint32_t i;
     789                 :            : 
     790   [ #  #  #  # ]:          0 :         if (g_workload_selection == SPDK_ACCEL_OPC_DECOMPRESS ||
     791                 :          0 :             g_workload_selection == SPDK_ACCEL_OPC_COMPRESS) {
     792                 :          0 :                 free(task->dst_iovs);
     793   [ #  #  #  # ]:          0 :         } else if (g_workload_selection == SPDK_ACCEL_OPC_CRC32C ||
     794         [ #  # ]:          0 :                    g_workload_selection == SPDK_ACCEL_OPC_COPY_CRC32C ||
     795         [ #  # ]:          0 :                    g_workload_selection == SPDK_ACCEL_OPC_DIF_VERIFY ||
     796         [ #  # ]:          0 :                    g_workload_selection == SPDK_ACCEL_OPC_DIF_GENERATE ||
     797         [ #  # ]:          0 :                    g_workload_selection == SPDK_ACCEL_OPC_DIF_GENERATE_COPY ||
     798         [ #  # ]:          0 :                    g_workload_selection == SPDK_ACCEL_OPC_DIF_VERIFY_COPY ||
     799         [ #  # ]:          0 :                    g_workload_selection == SPDK_ACCEL_OPC_DIX_VERIFY ||
     800                 :          0 :                    g_workload_selection == SPDK_ACCEL_OPC_DIX_GENERATE) {
     801         [ #  # ]:          0 :                 if (task->crc_dst) {
     802                 :          0 :                         spdk_dma_free(task->crc_dst);
     803                 :          0 :                 }
     804         [ #  # ]:          0 :                 if (task->src_iovs) {
     805         [ #  # ]:          0 :                         for (i = 0; i < task->src_iovcnt; i++) {
     806         [ #  # ]:          0 :                                 if (task->src_iovs[i].iov_base) {
     807                 :          0 :                                         spdk_dma_free(task->src_iovs[i].iov_base);
     808                 :          0 :                                 }
     809                 :          0 :                         }
     810                 :          0 :                         free(task->src_iovs);
     811                 :          0 :                 }
     812         [ #  # ]:          0 :                 if (task->dst_iovs) {
     813         [ #  # ]:          0 :                         for (i = 0; i < task->dst_iovcnt; i++) {
     814         [ #  # ]:          0 :                                 if (task->dst_iovs[i].iov_base) {
     815                 :          0 :                                         spdk_dma_free(task->dst_iovs[i].iov_base);
     816                 :          0 :                                 }
     817                 :          0 :                         }
     818                 :          0 :                         free(task->dst_iovs);
     819                 :          0 :                 }
     820         [ #  # ]:          0 :                 if (task->md_iov.iov_base) {
     821                 :          0 :                         spdk_dma_free(task->md_iov.iov_base);
     822                 :          0 :                 }
     823         [ #  # ]:          0 :         } else if (g_workload_selection == SPDK_ACCEL_OPC_XOR) {
     824         [ #  # ]:          0 :                 if (task->sources) {
     825         [ #  # ]:          0 :                         for (i = 0; i < g_xor_src_count; i++) {
     826                 :          0 :                                 spdk_dma_free(task->sources[i]);
     827                 :          0 :                         }
     828                 :          0 :                         free(task->sources);
     829                 :          0 :                 }
     830                 :          0 :         } else {
     831                 :          0 :                 spdk_dma_free(task->src);
     832                 :            :         }
     833                 :            : 
     834                 :          0 :         spdk_dma_free(task->dst);
     835   [ #  #  #  # ]:          0 :         if (g_workload_selection == SPDK_ACCEL_OPC_DUALCAST || g_workload_selection == SPDK_ACCEL_OPC_XOR) {
     836                 :          0 :                 spdk_dma_free(task->dst2);
     837                 :          0 :         }
     838                 :          0 : }
     839                 :            : 
     840                 :            : static int
     841                 :          0 : _vector_memcmp(void *_dst, struct iovec *src_src_iovs, uint32_t iovcnt)
     842                 :            : {
     843                 :            :         uint32_t i;
     844                 :          0 :         uint32_t ttl_len = 0;
     845                 :          0 :         uint8_t *dst = (uint8_t *)_dst;
     846                 :            : 
     847         [ #  # ]:          0 :         for (i = 0; i < iovcnt; i++) {
     848         [ #  # ]:          0 :                 if (memcmp(dst, src_src_iovs[i].iov_base, src_src_iovs[i].iov_len)) {
     849                 :          0 :                         return -1;
     850                 :            :                 }
     851                 :          0 :                 dst += src_src_iovs[i].iov_len;
     852                 :          0 :                 ttl_len += src_src_iovs[i].iov_len;
     853                 :          0 :         }
     854                 :            : 
     855         [ #  # ]:          0 :         if (ttl_len != iovcnt * g_xfer_size_bytes) {
     856                 :          0 :                 return -1;
     857                 :            :         }
     858                 :            : 
     859                 :          0 :         return 0;
     860                 :          0 : }
     861                 :            : 
     862                 :            : static int _worker_stop(void *arg);
     863                 :            : 
     864                 :            : static void
     865                 :          0 : accel_done(void *arg1, int status)
     866                 :            : {
     867                 :          0 :         struct ap_task *task = arg1;
     868                 :          0 :         struct worker_thread *worker = task->worker;
     869                 :            :         uint32_t sw_crc32c;
     870                 :            :         struct spdk_dif_error err_blk;
     871                 :            : 
     872         [ #  # ]:          0 :         assert(worker);
     873         [ #  # ]:          0 :         assert(worker->current_queue_depth > 0);
     874                 :            : 
     875   [ #  #  #  # ]:          0 :         if (g_verify && status == 0) {
     876   [ #  #  #  #  :          0 :                 switch (worker->workload) {
          #  #  #  #  #  
          #  #  #  #  #  
                   #  # ]
     877                 :            :                 case SPDK_ACCEL_OPC_COPY_CRC32C:
     878                 :          0 :                         sw_crc32c = spdk_crc32c_iov_update(task->src_iovs, task->src_iovcnt, ~g_crc32c_seed);
     879         [ #  # ]:          0 :                         if (*task->crc_dst != sw_crc32c) {
     880                 :          0 :                                 SPDK_NOTICELOG("CRC-32C miscompare\n");
     881                 :          0 :                                 worker->xfer_failed++;
     882                 :          0 :                         }
     883         [ #  # ]:          0 :                         if (_vector_memcmp(task->dst, task->src_iovs, task->src_iovcnt)) {
     884                 :          0 :                                 SPDK_NOTICELOG("Data miscompare\n");
     885                 :          0 :                                 worker->xfer_failed++;
     886                 :          0 :                         }
     887                 :          0 :                         break;
     888                 :            :                 case SPDK_ACCEL_OPC_CRC32C:
     889                 :          0 :                         sw_crc32c = spdk_crc32c_iov_update(task->src_iovs, task->src_iovcnt, ~g_crc32c_seed);
     890         [ #  # ]:          0 :                         if (*task->crc_dst != sw_crc32c) {
     891                 :          0 :                                 SPDK_NOTICELOG("CRC-32C miscompare\n");
     892                 :          0 :                                 worker->xfer_failed++;
     893                 :          0 :                         }
     894                 :          0 :                         break;
     895                 :            :                 case SPDK_ACCEL_OPC_COPY:
     896         [ #  # ]:          0 :                         if (memcmp(task->src, task->dst, g_xfer_size_bytes)) {
     897                 :          0 :                                 SPDK_NOTICELOG("Data miscompare\n");
     898                 :          0 :                                 worker->xfer_failed++;
     899                 :          0 :                         }
     900                 :          0 :                         break;
     901                 :            :                 case SPDK_ACCEL_OPC_DUALCAST:
     902         [ #  # ]:          0 :                         if (memcmp(task->src, task->dst, g_xfer_size_bytes)) {
     903                 :          0 :                                 SPDK_NOTICELOG("Data miscompare, first destination\n");
     904                 :          0 :                                 worker->xfer_failed++;
     905                 :          0 :                         }
     906         [ #  # ]:          0 :                         if (memcmp(task->src, task->dst2, g_xfer_size_bytes)) {
     907                 :          0 :                                 SPDK_NOTICELOG("Data miscompare, second destination\n");
     908                 :          0 :                                 worker->xfer_failed++;
     909                 :          0 :                         }
     910                 :          0 :                         break;
     911                 :            :                 case SPDK_ACCEL_OPC_FILL:
     912         [ #  # ]:          0 :                         if (memcmp(task->dst, task->src, g_xfer_size_bytes)) {
     913                 :          0 :                                 SPDK_NOTICELOG("Data miscompare\n");
     914                 :          0 :                                 worker->xfer_failed++;
     915                 :          0 :                         }
     916                 :          0 :                         break;
     917                 :            :                 case SPDK_ACCEL_OPC_COMPARE:
     918                 :          0 :                         break;
     919                 :            :                 case SPDK_ACCEL_OPC_COMPRESS:
     920                 :          0 :                         break;
     921                 :            :                 case SPDK_ACCEL_OPC_DECOMPRESS:
     922         [ #  # ]:          0 :                         if (memcmp(task->dst, task->cur_seg->uncompressed_data, task->cur_seg->uncompressed_len)) {
     923                 :          0 :                                 SPDK_NOTICELOG("Data miscompare on decompression\n");
     924                 :          0 :                                 worker->xfer_failed++;
     925                 :          0 :                         }
     926                 :          0 :                         break;
     927                 :            :                 case SPDK_ACCEL_OPC_XOR:
     928   [ #  #  #  #  :          0 :                         if (spdk_xor_gen(task->dst2, task->sources, g_xor_src_count,
                   #  # ]
     929                 :          0 :                                          g_xfer_size_bytes) != 0) {
     930                 :          0 :                                 SPDK_ERRLOG("Failed to generate xor for verification\n");
     931         [ #  # ]:          0 :                         } else if (memcmp(task->dst, task->dst2, g_xfer_size_bytes)) {
     932                 :          0 :                                 SPDK_NOTICELOG("Data miscompare\n");
     933                 :          0 :                                 worker->xfer_failed++;
     934                 :          0 :                         }
     935                 :          0 :                         break;
     936                 :            :                 case SPDK_ACCEL_OPC_DIF_VERIFY:
     937                 :          0 :                         break;
     938                 :            :                 case SPDK_ACCEL_OPC_DIF_GENERATE:
     939   [ #  #  #  #  :          0 :                         if (spdk_dif_verify(task->src_iovs, task->src_iovcnt, task->num_blocks,
                   #  # ]
     940                 :          0 :                                             &task->dif_ctx, &err_blk) != 0) {
     941                 :          0 :                                 SPDK_NOTICELOG("Data miscompare, "
     942                 :            :                                                "err_type %u, expected %lu, actual %lu, err_offset %u\n",
     943                 :            :                                                err_blk.err_type, err_blk.expected,
     944                 :            :                                                err_blk.actual, err_blk.err_offset);
     945                 :          0 :                                 worker->xfer_failed++;
     946                 :          0 :                         }
     947                 :          0 :                         break;
     948                 :            :                 case SPDK_ACCEL_OPC_DIF_GENERATE_COPY:
     949   [ #  #  #  #  :          0 :                         if (spdk_dif_verify(task->dst_iovs, task->dst_iovcnt, task->num_blocks,
                   #  # ]
     950                 :          0 :                                             &task->dif_ctx, &err_blk) != 0) {
     951                 :          0 :                                 SPDK_NOTICELOG("Data miscompare, "
     952                 :            :                                                "err_type %u, expected %lu, actual %lu, err_offset %u\n",
     953                 :            :                                                err_blk.err_type, err_blk.expected,
     954                 :            :                                                err_blk.actual, err_blk.err_offset);
     955                 :          0 :                                 worker->xfer_failed++;
     956                 :          0 :                         }
     957                 :          0 :                         break;
     958                 :            :                 case SPDK_ACCEL_OPC_DIF_VERIFY_COPY:
     959                 :          0 :                         break;
     960                 :            :                 case SPDK_ACCEL_OPC_DIX_GENERATE:
     961   [ #  #  #  #  :          0 :                         if (spdk_dix_verify(task->src_iovs, task->src_iovcnt, &task->md_iov,
                   #  # ]
     962                 :          0 :                                             task->num_blocks, &task->dif_ctx, &err_blk) != 0) {
     963                 :          0 :                                 SPDK_NOTICELOG("Data miscompare, "
     964                 :            :                                                "err_type %u, expected %lu, actual %lu, err_offset %u\n",
     965                 :            :                                                err_blk.err_type, err_blk.expected,
     966                 :            :                                                err_blk.actual, err_blk.err_offset);
     967                 :          0 :                                 worker->xfer_failed++;
     968                 :          0 :                         }
     969                 :          0 :                         break;
     970                 :            :                 case SPDK_ACCEL_OPC_DIX_VERIFY:
     971                 :          0 :                         break;
     972                 :            :                 default:
     973                 :          0 :                         assert(false);
     974                 :            :                         break;
     975                 :            :                 }
     976                 :          0 :         }
     977                 :            : 
     978   [ #  #  #  # ]:          0 :         if (worker->workload == SPDK_ACCEL_OPC_COMPRESS ||
     979                 :          0 :             g_workload_selection == SPDK_ACCEL_OPC_DECOMPRESS) {
     980                 :            :                 /* Advance the task to the next segment */
     981                 :          0 :                 task->cur_seg = STAILQ_NEXT(task->cur_seg, link);
     982         [ #  # ]:          0 :                 if (task->cur_seg == NULL) {
     983                 :          0 :                         task->cur_seg = STAILQ_FIRST(&g_compress_segs);
     984                 :          0 :                 }
     985                 :          0 :         }
     986                 :            : 
     987         [ #  # ]:          0 :         if (task->expected_status == -EILSEQ) {
     988         [ #  # ]:          0 :                 assert(status != 0);
     989                 :          0 :                 worker->injected_miscompares++;
     990                 :          0 :                 status = 0;
     991         [ #  # ]:          0 :         } else if (status) {
     992                 :            :                 /* Expected to pass but the accel module reported an error (ex: COMPARE operation). */
     993                 :          0 :                 worker->xfer_failed++;
     994                 :          0 :         }
     995                 :            : 
     996                 :          0 :         worker->current_queue_depth--;
     997                 :            : 
     998   [ #  #  #  # ]:          0 :         if (!worker->is_draining && status == 0) {
     999                 :          0 :                 TAILQ_INSERT_TAIL(&worker->tasks_pool, task, link);
    1000                 :          0 :                 task = _get_task(worker);
    1001                 :          0 :                 _submit_single(worker, task);
    1002                 :          0 :         } else {
    1003                 :          0 :                 TAILQ_INSERT_TAIL(&worker->tasks_pool, task, link);
    1004                 :            :         }
    1005                 :          0 : }
    1006                 :            : 
    1007                 :            : static int
    1008                 :          0 : dump_result(void)
    1009                 :            : {
    1010                 :          0 :         uint64_t total_completed = 0;
    1011                 :          0 :         uint64_t total_failed = 0;
    1012                 :          0 :         uint64_t total_miscompared = 0;
    1013                 :          0 :         uint64_t total_xfer_per_sec, total_bw_in_MiBps = 0;
    1014                 :          0 :         struct worker_thread *worker = g_workers;
    1015                 :            :         char tmp[64];
    1016                 :            : 
    1017                 :          0 :         printf("\n%-12s %20s %16s %16s %16s\n",
    1018                 :            :                "Core,Thread", "Transfers", "Bandwidth", "Failed", "Miscompares");
    1019                 :          0 :         printf("------------------------------------------------------------------------------------\n");
    1020         [ #  # ]:          0 :         while (worker != NULL) {
    1021                 :            : 
    1022                 :          0 :                 uint64_t xfer_per_sec = worker->stats.executed / g_time_in_sec;
    1023                 :          0 :                 uint64_t bw_in_MiBps = worker->stats.num_bytes /
    1024                 :          0 :                                        (g_time_in_sec * 1024 * 1024);
    1025                 :            : 
    1026                 :          0 :                 total_completed += worker->stats.executed;
    1027                 :          0 :                 total_failed += worker->xfer_failed;
    1028                 :          0 :                 total_miscompared += worker->injected_miscompares;
    1029                 :          0 :                 total_bw_in_MiBps += bw_in_MiBps;
    1030                 :            : 
    1031                 :          0 :                 snprintf(tmp, sizeof(tmp), "%u,%u", worker->display.core, worker->display.thread);
    1032         [ #  # ]:          0 :                 if (xfer_per_sec) {
    1033                 :          0 :                         printf("%-12s %18" PRIu64 "/s %10" PRIu64 " MiB/s %16"PRIu64 " %16" PRIu64 "\n",
    1034                 :          0 :                                tmp, xfer_per_sec, bw_in_MiBps, worker->xfer_failed,
    1035                 :          0 :                                worker->injected_miscompares);
    1036                 :          0 :                 }
    1037                 :            : 
    1038                 :          0 :                 worker = worker->next;
    1039                 :            :         }
    1040                 :            : 
    1041                 :          0 :         total_xfer_per_sec = total_completed / g_time_in_sec;
    1042                 :            : 
    1043                 :          0 :         printf("====================================================================================\n");
    1044                 :          0 :         printf("%-12s %18" PRIu64 "/s %10" PRIu64 " MiB/s %16"PRIu64 " %16" PRIu64 "\n",
    1045                 :          0 :                "Total", total_xfer_per_sec, total_bw_in_MiBps, total_failed, total_miscompared);
    1046                 :            : 
    1047                 :          0 :         return total_failed ? 1 : 0;
    1048                 :            : }
    1049                 :            : 
    1050                 :            : static inline void
    1051                 :          0 : _free_task_buffers_in_pool(struct worker_thread *worker)
    1052                 :            : {
    1053                 :            :         struct ap_task *task;
    1054                 :            : 
    1055         [ #  # ]:          0 :         assert(worker);
    1056         [ #  # ]:          0 :         while ((task = TAILQ_FIRST(&worker->tasks_pool))) {
    1057         [ #  # ]:          0 :                 TAILQ_REMOVE(&worker->tasks_pool, task, link);
    1058                 :          0 :                 _free_task_buffers(task);
    1059                 :            :         }
    1060                 :          0 : }
    1061                 :            : 
    1062                 :            : static int
    1063                 :          0 : _check_draining(void *arg)
    1064                 :            : {
    1065                 :          0 :         struct worker_thread *worker = arg;
    1066                 :            : 
    1067         [ #  # ]:          0 :         assert(worker);
    1068                 :            : 
    1069         [ #  # ]:          0 :         if (worker->current_queue_depth == 0) {
    1070                 :          0 :                 _free_task_buffers_in_pool(worker);
    1071                 :          0 :                 spdk_poller_unregister(&worker->is_draining_poller);
    1072                 :          0 :                 unregister_worker(worker);
    1073                 :          0 :         }
    1074                 :            : 
    1075                 :          0 :         return SPDK_POLLER_BUSY;
    1076                 :            : }
    1077                 :            : 
    1078                 :            : static int
    1079                 :          0 : _worker_stop(void *arg)
    1080                 :            : {
    1081                 :          0 :         struct worker_thread *worker = arg;
    1082                 :            : 
    1083         [ #  # ]:          0 :         assert(worker);
    1084                 :            : 
    1085                 :          0 :         spdk_poller_unregister(&worker->stop_poller);
    1086                 :            : 
    1087                 :            :         /* now let the worker drain and check it's outstanding IO with a poller */
    1088                 :          0 :         worker->is_draining = true;
    1089                 :          0 :         worker->is_draining_poller = SPDK_POLLER_REGISTER(_check_draining, worker, 0);
    1090                 :            : 
    1091                 :          0 :         return SPDK_POLLER_BUSY;
    1092                 :            : }
    1093                 :            : 
    1094                 :            : static void shutdown_cb(void);
    1095                 :            : 
    1096                 :            : static void
    1097                 :          0 : _init_thread(void *arg1)
    1098                 :            : {
    1099                 :            :         struct worker_thread *worker;
    1100                 :            :         struct ap_task *task;
    1101                 :          0 :         int i, num_tasks = g_allocate_depth;
    1102                 :          0 :         struct display_info *display = arg1;
    1103                 :            : 
    1104                 :          0 :         worker = calloc(1, sizeof(*worker));
    1105         [ #  # ]:          0 :         if (worker == NULL) {
    1106                 :          0 :                 fprintf(stderr, "Unable to allocate worker\n");
    1107                 :          0 :                 free(display);
    1108                 :          0 :                 spdk_thread_exit(spdk_get_thread());
    1109                 :          0 :                 goto no_worker;
    1110                 :            :         }
    1111                 :            : 
    1112                 :          0 :         worker->workload = g_workload_selection;
    1113                 :          0 :         worker->display.core = display->core;
    1114                 :          0 :         worker->display.thread = display->thread;
    1115                 :          0 :         free(display);
    1116                 :          0 :         worker->core = spdk_env_get_current_core();
    1117                 :          0 :         worker->thread = spdk_get_thread();
    1118                 :          0 :         pthread_mutex_lock(&g_workers_lock);
    1119                 :          0 :         g_num_workers++;
    1120                 :          0 :         worker->next = g_workers;
    1121                 :          0 :         g_workers = worker;
    1122                 :          0 :         pthread_mutex_unlock(&g_workers_lock);
    1123                 :          0 :         worker->ch = spdk_accel_get_io_channel();
    1124         [ #  # ]:          0 :         if (worker->ch == NULL) {
    1125                 :          0 :                 fprintf(stderr, "Unable to get an accel channel\n");
    1126                 :          0 :                 goto error;
    1127                 :            :         }
    1128                 :            : 
    1129                 :          0 :         TAILQ_INIT(&worker->tasks_pool);
    1130                 :            : 
    1131                 :          0 :         worker->task_base = calloc(num_tasks, sizeof(struct ap_task));
    1132         [ #  # ]:          0 :         if (worker->task_base == NULL) {
    1133                 :          0 :                 fprintf(stderr, "Could not allocate task base.\n");
    1134                 :          0 :                 goto error;
    1135                 :            :         }
    1136                 :            : 
    1137                 :          0 :         task = worker->task_base;
    1138         [ #  # ]:          0 :         for (i = 0; i < num_tasks; i++) {
    1139                 :          0 :                 TAILQ_INSERT_TAIL(&worker->tasks_pool, task, link);
    1140                 :          0 :                 task->worker = worker;
    1141         [ #  # ]:          0 :                 if (_get_task_data_bufs(task)) {
    1142                 :          0 :                         fprintf(stderr, "Unable to get data bufs\n");
    1143                 :          0 :                         goto error;
    1144                 :            :                 }
    1145                 :          0 :                 task++;
    1146                 :          0 :         }
    1147                 :            : 
    1148                 :            :         /* Register a poller that will stop the worker at time elapsed */
    1149                 :          0 :         worker->stop_poller = SPDK_POLLER_REGISTER(_worker_stop, worker,
    1150                 :            :                               g_time_in_sec * 1000000ULL);
    1151                 :            : 
    1152                 :            :         /* Load up queue depth worth of operations. */
    1153         [ #  # ]:          0 :         for (i = 0; i < g_queue_depth; i++) {
    1154                 :          0 :                 task = _get_task(worker);
    1155         [ #  # ]:          0 :                 if (task == NULL) {
    1156                 :          0 :                         goto error;
    1157                 :            :                 }
    1158                 :            : 
    1159                 :          0 :                 _submit_single(worker, task);
    1160                 :          0 :         }
    1161                 :          0 :         return;
    1162                 :            : error:
    1163                 :            : 
    1164                 :          0 :         _free_task_buffers_in_pool(worker);
    1165                 :          0 :         free(worker->task_base);
    1166                 :          0 :         worker->task_base = NULL;
    1167                 :            : no_worker:
    1168                 :          0 :         shutdown_cb();
    1169                 :          0 :         g_rc = -1;
    1170                 :          0 : }
    1171                 :            : 
    1172                 :            : static void
    1173                 :          0 : accel_perf_start(void *arg1)
    1174                 :            : {
    1175                 :          0 :         struct spdk_cpuset tmp_cpumask = {};
    1176                 :            :         char thread_name[32];
    1177                 :            :         uint32_t i;
    1178                 :            :         int j;
    1179                 :            :         struct spdk_thread *thread;
    1180                 :            :         struct display_info *display;
    1181                 :            : 
    1182                 :          0 :         g_tsc_rate = spdk_get_ticks_hz();
    1183                 :          0 :         g_tsc_end = spdk_get_ticks() + g_time_in_sec * g_tsc_rate;
    1184                 :            : 
    1185                 :          0 :         dump_user_config();
    1186                 :            : 
    1187                 :          0 :         printf("Running for %d seconds...\n", g_time_in_sec);
    1188                 :          0 :         fflush(stdout);
    1189                 :            : 
    1190                 :            :         /* Create worker threads for each core that was specified. */
    1191         [ #  # ]:          0 :         SPDK_ENV_FOREACH_CORE(i) {
    1192         [ #  # ]:          0 :                 for (j = 0; j < g_threads_per_core; j++) {
    1193                 :          0 :                         snprintf(thread_name, sizeof(thread_name), "ap_worker_%u_%u", i, j);
    1194                 :          0 :                         spdk_cpuset_zero(&tmp_cpumask);
    1195                 :          0 :                         spdk_cpuset_set_cpu(&tmp_cpumask, i, true);
    1196                 :          0 :                         thread = spdk_thread_create(thread_name, &tmp_cpumask);
    1197                 :          0 :                         display = calloc(1, sizeof(*display));
    1198         [ #  # ]:          0 :                         if (display == NULL) {
    1199                 :          0 :                                 fprintf(stderr, "Unable to allocate memory\n");
    1200                 :          0 :                                 spdk_app_stop(-1);
    1201                 :          0 :                                 return;
    1202                 :            :                         }
    1203                 :          0 :                         display->core = i;
    1204                 :          0 :                         display->thread = j;
    1205                 :          0 :                         spdk_thread_send_msg(thread, _init_thread, display);
    1206                 :          0 :                 }
    1207                 :          0 :         }
    1208                 :          0 : }
    1209                 :            : 
    1210                 :            : static void
    1211                 :          0 : accel_perf_free_compress_segs(void)
    1212                 :            : {
    1213                 :            :         struct ap_compress_seg *seg, *tmp;
    1214                 :            : 
    1215   [ #  #  #  # ]:          0 :         STAILQ_FOREACH_SAFE(seg, &g_compress_segs, link, tmp) {
    1216                 :          0 :                 free(seg->uncompressed_iovs);
    1217                 :          0 :                 free(seg->compressed_iovs);
    1218                 :          0 :                 spdk_dma_free(seg->compressed_data);
    1219                 :          0 :                 spdk_dma_free(seg->uncompressed_data);
    1220         [ #  # ]:          0 :                 STAILQ_REMOVE_HEAD(&g_compress_segs, link);
    1221                 :          0 :                 free(seg);
    1222                 :          0 :         }
    1223                 :          0 : }
    1224                 :            : 
    1225                 :            : struct accel_perf_prep_ctx {
    1226                 :            :         FILE                    *file;
    1227                 :            :         long                    remaining;
    1228                 :            :         struct spdk_io_channel  *ch;
    1229                 :            :         struct ap_compress_seg  *cur_seg;
    1230                 :            : };
    1231                 :            : 
    1232                 :            : static void accel_perf_prep_process_seg(struct accel_perf_prep_ctx *ctx);
    1233                 :            : 
    1234                 :            : static void
    1235                 :          0 : accel_perf_prep_process_seg_cpl(void *ref, int status)
    1236                 :            : {
    1237                 :          0 :         struct accel_perf_prep_ctx *ctx = ref;
    1238                 :            :         struct ap_compress_seg *seg;
    1239                 :            : 
    1240         [ #  # ]:          0 :         if (status != 0) {
    1241                 :          0 :                 fprintf(stderr, "error (%d) on initial compress completion\n", status);
    1242                 :          0 :                 spdk_dma_free(ctx->cur_seg->compressed_data);
    1243                 :          0 :                 spdk_dma_free(ctx->cur_seg->uncompressed_data);
    1244                 :          0 :                 free(ctx->cur_seg);
    1245                 :          0 :                 spdk_put_io_channel(ctx->ch);
    1246                 :          0 :                 fclose(ctx->file);
    1247                 :          0 :                 free(ctx);
    1248                 :          0 :                 spdk_app_stop(-status);
    1249                 :          0 :                 return;
    1250                 :            :         }
    1251                 :            : 
    1252                 :          0 :         seg = ctx->cur_seg;
    1253                 :            : 
    1254         [ #  # ]:          0 :         if (g_workload_selection == SPDK_ACCEL_OPC_DECOMPRESS) {
    1255                 :          0 :                 seg->compressed_iovs = calloc(g_chained_count, sizeof(struct iovec));
    1256         [ #  # ]:          0 :                 if (seg->compressed_iovs == NULL) {
    1257                 :          0 :                         fprintf(stderr, "unable to allocate iovec\n");
    1258                 :          0 :                         spdk_dma_free(seg->compressed_data);
    1259                 :          0 :                         spdk_dma_free(seg->uncompressed_data);
    1260                 :          0 :                         free(seg);
    1261                 :          0 :                         spdk_put_io_channel(ctx->ch);
    1262                 :          0 :                         fclose(ctx->file);
    1263                 :          0 :                         free(ctx);
    1264                 :          0 :                         spdk_app_stop(-ENOMEM);
    1265                 :          0 :                         return;
    1266                 :            :                 }
    1267                 :          0 :                 seg->compressed_iovcnt = g_chained_count;
    1268                 :            : 
    1269                 :          0 :                 accel_perf_construct_iovs(seg->compressed_data, seg->compressed_len, seg->compressed_iovs,
    1270                 :          0 :                                           seg->compressed_iovcnt);
    1271                 :          0 :         }
    1272                 :            : 
    1273                 :          0 :         STAILQ_INSERT_TAIL(&g_compress_segs, seg, link);
    1274                 :          0 :         ctx->remaining -= seg->uncompressed_len;
    1275                 :            : 
    1276                 :          0 :         accel_perf_prep_process_seg(ctx);
    1277                 :          0 : }
    1278                 :            : 
    1279                 :            : static void
    1280                 :          0 : accel_perf_prep_process_seg(struct accel_perf_prep_ctx *ctx)
    1281                 :            : {
    1282                 :            :         struct ap_compress_seg *seg;
    1283                 :            :         int sz, sz_read, sz_padded;
    1284                 :            :         void *ubuf, *cbuf;
    1285                 :            :         struct iovec iov[1];
    1286                 :            :         int rc;
    1287                 :            : 
    1288         [ #  # ]:          0 :         if (ctx->remaining == 0) {
    1289                 :          0 :                 spdk_put_io_channel(ctx->ch);
    1290                 :          0 :                 fclose(ctx->file);
    1291                 :          0 :                 free(ctx);
    1292                 :          0 :                 accel_perf_start(NULL);
    1293                 :          0 :                 return;
    1294                 :            :         }
    1295                 :            : 
    1296         [ #  # ]:          0 :         sz = spdk_min(ctx->remaining, g_xfer_size_bytes);
    1297                 :            :         /* Add 10% pad to the compress buffer for incompressible data. Note that a real app
    1298                 :            :          * would likely either deal with the failure of not having a large enough buffer
    1299                 :            :          * by submitting another operation with a larger one.  Or, like the vbdev module
    1300                 :            :          * does, just accept the error and use the data uncompressed marking it as such in
    1301                 :            :          * its own metadata so that in the future it doesn't try to decompress uncompressed
    1302                 :            :          * data, etc.
    1303                 :            :          */
    1304                 :          0 :         sz_padded = sz * COMP_BUF_PAD_PERCENTAGE;
    1305                 :            : 
    1306                 :          0 :         ubuf = spdk_dma_zmalloc(sz, ALIGN_4K, NULL);
    1307         [ #  # ]:          0 :         if (!ubuf) {
    1308                 :          0 :                 fprintf(stderr, "unable to allocate uncompress buffer\n");
    1309                 :          0 :                 rc = -ENOMEM;
    1310                 :          0 :                 goto error;
    1311                 :            :         }
    1312                 :            : 
    1313                 :          0 :         cbuf = spdk_dma_malloc(sz_padded, ALIGN_4K, NULL);
    1314         [ #  # ]:          0 :         if (!cbuf) {
    1315                 :          0 :                 fprintf(stderr, "unable to allocate compress buffer\n");
    1316                 :          0 :                 rc = -ENOMEM;
    1317                 :          0 :                 spdk_dma_free(ubuf);
    1318                 :          0 :                 goto error;
    1319                 :            :         }
    1320                 :            : 
    1321                 :          0 :         seg = calloc(1, sizeof(*seg));
    1322         [ #  # ]:          0 :         if (!seg) {
    1323                 :          0 :                 fprintf(stderr, "unable to allocate comp/decomp segment\n");
    1324                 :          0 :                 spdk_dma_free(ubuf);
    1325                 :          0 :                 spdk_dma_free(cbuf);
    1326                 :          0 :                 rc = -ENOMEM;
    1327                 :          0 :                 goto error;
    1328                 :            :         }
    1329                 :            : 
    1330                 :          0 :         sz_read = fread(ubuf, sizeof(uint8_t), sz, ctx->file);
    1331         [ #  # ]:          0 :         if (sz_read != sz) {
    1332                 :          0 :                 fprintf(stderr, "unable to read input file\n");
    1333                 :          0 :                 free(seg);
    1334                 :          0 :                 spdk_dma_free(ubuf);
    1335                 :          0 :                 spdk_dma_free(cbuf);
    1336                 :          0 :                 rc = -errno;
    1337                 :          0 :                 goto error;
    1338                 :            :         }
    1339                 :            : 
    1340         [ #  # ]:          0 :         if (g_workload_selection == SPDK_ACCEL_OPC_COMPRESS) {
    1341                 :          0 :                 seg->uncompressed_iovs = calloc(g_chained_count, sizeof(struct iovec));
    1342         [ #  # ]:          0 :                 if (seg->uncompressed_iovs == NULL) {
    1343                 :          0 :                         fprintf(stderr, "unable to allocate iovec\n");
    1344                 :          0 :                         free(seg);
    1345                 :          0 :                         spdk_dma_free(ubuf);
    1346                 :          0 :                         spdk_dma_free(cbuf);
    1347                 :          0 :                         rc = -ENOMEM;
    1348                 :          0 :                         goto error;
    1349                 :            :                 }
    1350                 :          0 :                 seg->uncompressed_iovcnt = g_chained_count;
    1351                 :          0 :                 accel_perf_construct_iovs(ubuf, sz, seg->uncompressed_iovs, seg->uncompressed_iovcnt);
    1352                 :          0 :         }
    1353                 :            : 
    1354                 :          0 :         seg->uncompressed_data = ubuf;
    1355                 :          0 :         seg->uncompressed_len = sz;
    1356                 :          0 :         seg->compressed_data = cbuf;
    1357                 :          0 :         seg->compressed_len = sz;
    1358                 :          0 :         seg->compressed_len_padded = sz_padded;
    1359                 :            : 
    1360                 :          0 :         ctx->cur_seg = seg;
    1361                 :          0 :         iov[0].iov_base = seg->uncompressed_data;
    1362                 :          0 :         iov[0].iov_len = seg->uncompressed_len;
    1363                 :            :         /* Note that anytime a call is made to spdk_accel_submit_compress() there's a chance
    1364                 :            :          * it will fail with -ENOMEM in the event that the destination buffer is not large enough
    1365                 :            :          * to hold the compressed data.  This example app simply adds 10% buffer for compressed data
    1366                 :            :          * but real applications may want to consider a more sophisticated method.
    1367                 :            :          */
    1368                 :          0 :         rc = spdk_accel_submit_compress(ctx->ch, seg->compressed_data, seg->compressed_len_padded, iov, 1,
    1369                 :          0 :                                         &seg->compressed_len, accel_perf_prep_process_seg_cpl, ctx);
    1370         [ #  # ]:          0 :         if (rc < 0) {
    1371                 :          0 :                 fprintf(stderr, "error (%d) on initial compress submission\n", rc);
    1372                 :          0 :                 goto error;
    1373                 :            :         }
    1374                 :            : 
    1375                 :          0 :         return;
    1376                 :            : 
    1377                 :            : error:
    1378                 :          0 :         spdk_put_io_channel(ctx->ch);
    1379                 :          0 :         fclose(ctx->file);
    1380                 :          0 :         free(ctx);
    1381                 :          0 :         spdk_app_stop(rc);
    1382                 :          0 : }
    1383                 :            : 
    1384                 :            : static void
    1385                 :          0 : accel_perf_prep(void *arg1)
    1386                 :            : {
    1387                 :            :         struct accel_perf_prep_ctx *ctx;
    1388                 :          0 :         const char *module_name = NULL;
    1389                 :          0 :         int rc = 0;
    1390                 :            : 
    1391         [ #  # ]:          0 :         if (g_module_name) {
    1392                 :          0 :                 rc = spdk_accel_get_opc_module_name(g_workload_selection, &module_name);
    1393   [ #  #  #  # ]:          0 :                 if (rc != 0 || strcmp(g_module_name, module_name) != 0) {
    1394                 :          0 :                         fprintf(stderr, "Module '%s' was assigned via JSON config or RPC, instead of '%s'\n",
    1395                 :          0 :                                 module_name, g_module_name);
    1396                 :          0 :                         fprintf(stderr, "-M option is not compatible with accel_assign_opc RPC\n");
    1397                 :          0 :                         rc = -EINVAL;
    1398                 :          0 :                         goto error_end;
    1399                 :            :                 }
    1400                 :          0 :         }
    1401                 :            : 
    1402   [ #  #  #  # ]:          0 :         if (g_workload_selection != SPDK_ACCEL_OPC_COMPRESS &&
    1403                 :          0 :             g_workload_selection != SPDK_ACCEL_OPC_DECOMPRESS) {
    1404                 :          0 :                 accel_perf_start(arg1);
    1405                 :          0 :                 return;
    1406                 :            :         }
    1407                 :            : 
    1408         [ #  # ]:          0 :         if (g_cd_file_in_name == NULL) {
    1409                 :          0 :                 fprintf(stdout, "A filename is required.\n");
    1410                 :          0 :                 rc = -EINVAL;
    1411                 :          0 :                 goto error_end;
    1412                 :            :         }
    1413                 :            : 
    1414   [ #  #  #  # ]:          0 :         if (g_workload_selection == SPDK_ACCEL_OPC_COMPRESS && g_verify) {
    1415                 :          0 :                 fprintf(stdout, "\nCompression does not support the verify option, aborting.\n");
    1416                 :          0 :                 rc = -ENOTSUP;
    1417                 :          0 :                 goto error_end;
    1418                 :            :         }
    1419                 :            : 
    1420                 :          0 :         printf("Preparing input file...\n");
    1421                 :            : 
    1422                 :          0 :         ctx = calloc(1, sizeof(*ctx));
    1423         [ #  # ]:          0 :         if (ctx == NULL) {
    1424                 :          0 :                 rc = -ENOMEM;
    1425                 :          0 :                 goto error_end;
    1426                 :            :         }
    1427                 :            : 
    1428                 :          0 :         ctx->file = fopen(g_cd_file_in_name, "r");
    1429         [ #  # ]:          0 :         if (ctx->file == NULL) {
    1430                 :          0 :                 fprintf(stderr, "Could not open file %s.\n", g_cd_file_in_name);
    1431                 :          0 :                 rc = -errno;
    1432                 :          0 :                 goto error_ctx;
    1433                 :            :         }
    1434                 :            : 
    1435                 :          0 :         fseek(ctx->file, 0L, SEEK_END);
    1436                 :          0 :         ctx->remaining = ftell(ctx->file);
    1437                 :          0 :         fseek(ctx->file, 0L, SEEK_SET);
    1438                 :            : 
    1439                 :          0 :         ctx->ch = spdk_accel_get_io_channel();
    1440         [ #  # ]:          0 :         if (ctx->ch == NULL) {
    1441                 :          0 :                 rc = -EAGAIN;
    1442                 :          0 :                 goto error_file;
    1443                 :            :         }
    1444                 :            : 
    1445         [ #  # ]:          0 :         if (g_xfer_size_bytes == 0) {
    1446                 :            :                 /* size of 0 means "file at a time" */
    1447                 :          0 :                 g_xfer_size_bytes = ctx->remaining;
    1448                 :          0 :         }
    1449                 :            : 
    1450                 :          0 :         accel_perf_prep_process_seg(ctx);
    1451                 :          0 :         return;
    1452                 :            : 
    1453                 :            : error_file:
    1454                 :          0 :         fclose(ctx->file);
    1455                 :            : error_ctx:
    1456                 :          0 :         free(ctx);
    1457                 :            : error_end:
    1458                 :          0 :         spdk_app_stop(rc);
    1459                 :          0 : }
    1460                 :            : 
    1461                 :            : static void
    1462                 :          0 : worker_shutdown(void *ctx)
    1463                 :            : {
    1464                 :          0 :         _worker_stop(ctx);
    1465                 :          0 : }
    1466                 :            : 
    1467                 :            : static void
    1468                 :          0 : shutdown_cb(void)
    1469                 :            : {
    1470                 :            :         struct worker_thread *worker;
    1471                 :            : 
    1472                 :          0 :         pthread_mutex_lock(&g_workers_lock);
    1473         [ #  # ]:          0 :         if (!g_workers) {
    1474                 :          0 :                 spdk_app_stop(1);
    1475                 :          0 :                 goto unlock;
    1476                 :            :         }
    1477                 :            : 
    1478                 :          0 :         worker = g_workers;
    1479         [ #  # ]:          0 :         while (worker) {
    1480                 :          0 :                 spdk_thread_send_msg(worker->thread, worker_shutdown, worker);
    1481                 :          0 :                 worker = worker->next;
    1482                 :            :         }
    1483                 :            : unlock:
    1484                 :          0 :         pthread_mutex_unlock(&g_workers_lock);
    1485                 :          0 : }
    1486                 :            : 
    1487                 :            : int
    1488                 :          0 : main(int argc, char **argv)
    1489                 :            : {
    1490                 :            :         struct worker_thread *worker, *tmp;
    1491                 :            :         int rc;
    1492                 :            : 
    1493                 :          0 :         pthread_mutex_init(&g_workers_lock, NULL);
    1494                 :          0 :         spdk_app_opts_init(&g_opts, sizeof(g_opts));
    1495                 :          0 :         g_opts.name = "accel_perf";
    1496                 :          0 :         g_opts.reactor_mask = "0x1";
    1497                 :          0 :         g_opts.shutdown_cb = shutdown_cb;
    1498                 :          0 :         g_opts.rpc_addr = NULL;
    1499                 :            : 
    1500                 :          0 :         rc = spdk_app_parse_args(argc, argv, &g_opts, "a:C:o:q:t:yw:M:P:f:T:l:S:x:", NULL,
    1501                 :            :                                  parse_args, usage);
    1502         [ #  # ]:          0 :         if (rc != SPDK_APP_PARSE_ARGS_SUCCESS) {
    1503                 :          0 :                 return rc == SPDK_APP_PARSE_ARGS_HELP ? 0 : 1;
    1504                 :            :         }
    1505                 :            : 
    1506         [ #  # ]:          0 :         if (g_workload_selection == SPDK_ACCEL_OPC_LAST) {
    1507                 :          0 :                 fprintf(stderr, "Must provide a workload type\n");
    1508                 :          0 :                 usage();
    1509                 :          0 :                 return -1;
    1510                 :            :         }
    1511                 :            : 
    1512   [ #  #  #  # ]:          0 :         if (g_allocate_depth > 0 && g_queue_depth > g_allocate_depth) {
    1513                 :          0 :                 fprintf(stdout, "allocate depth must be at least as big as queue depth\n");
    1514                 :          0 :                 usage();
    1515                 :          0 :                 return -1;
    1516                 :            :         }
    1517                 :            : 
    1518         [ #  # ]:          0 :         if (g_allocate_depth == 0) {
    1519                 :          0 :                 g_allocate_depth = g_queue_depth;
    1520                 :          0 :         }
    1521                 :            : 
    1522   [ #  #  #  # ]:          0 :         if ((g_workload_selection == SPDK_ACCEL_OPC_CRC32C ||
    1523         [ #  # ]:          0 :              g_workload_selection == SPDK_ACCEL_OPC_COPY_CRC32C ||
    1524         [ #  # ]:          0 :              g_workload_selection == SPDK_ACCEL_OPC_DIF_VERIFY ||
    1525         [ #  # ]:          0 :              g_workload_selection == SPDK_ACCEL_OPC_DIF_GENERATE ||
    1526         [ #  # ]:          0 :              g_workload_selection == SPDK_ACCEL_OPC_DIX_VERIFY ||
    1527                 :          0 :              g_workload_selection == SPDK_ACCEL_OPC_DIX_GENERATE) &&
    1528                 :          0 :             g_chained_count == 0) {
    1529                 :          0 :                 usage();
    1530                 :          0 :                 return -1;
    1531                 :            :         }
    1532                 :            : 
    1533   [ #  #  #  # ]:          0 :         if (g_workload_selection == SPDK_ACCEL_OPC_XOR && g_xor_src_count < 2) {
    1534                 :          0 :                 usage();
    1535                 :          0 :                 return -1;
    1536                 :            :         }
    1537                 :            : 
    1538   [ #  #  #  # ]:          0 :         if (g_module_name && spdk_accel_assign_opc(g_workload_selection, g_module_name)) {
    1539                 :          0 :                 fprintf(stderr, "Was not able to assign '%s' module to the workload\n", g_module_name);
    1540                 :          0 :                 usage();
    1541                 :          0 :                 return -1;
    1542                 :            :         }
    1543                 :            : 
    1544                 :          0 :         g_rc = spdk_app_start(&g_opts, accel_perf_prep, NULL);
    1545         [ #  # ]:          0 :         if (g_rc) {
    1546                 :          0 :                 SPDK_ERRLOG("ERROR starting application\n");
    1547                 :          0 :         }
    1548                 :            : 
    1549                 :          0 :         pthread_mutex_destroy(&g_workers_lock);
    1550                 :            : 
    1551                 :          0 :         worker = g_workers;
    1552         [ #  # ]:          0 :         while (worker) {
    1553                 :          0 :                 tmp = worker->next;
    1554                 :          0 :                 free(worker);
    1555                 :          0 :                 worker = tmp;
    1556                 :            :         }
    1557                 :          0 :         accel_perf_free_compress_segs();
    1558                 :          0 :         spdk_app_fini();
    1559                 :          0 :         return g_rc;
    1560                 :          0 : }

Generated by: LCOV version 1.14