LCOV - code coverage report
Current view: top level - app/test-compress-perf - comp_perf_test_cyclecount.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 239 0.0 %
Date: 2025-02-01 18:54:23 Functions: 0 5 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2019 Intel Corporation
       3                 :            :  */
       4                 :            : 
       5                 :            : #include <stdlib.h>
       6                 :            : 
       7                 :            : #include <rte_malloc.h>
       8                 :            : #include <rte_eal.h>
       9                 :            : #include <rte_log.h>
      10                 :            : #include <rte_cycles.h>
      11                 :            : #include "rte_spinlock.h"
      12                 :            : #include <rte_compressdev.h>
      13                 :            : 
      14                 :            : #include "comp_perf_test_cyclecount.h"
      15                 :            : 
      16                 :            : struct cperf_cyclecount_ctx {
      17                 :            :         struct cperf_verify_ctx ver;
      18                 :            : 
      19                 :            :         uint32_t ops_enq_retries;
      20                 :            :         uint32_t ops_deq_retries;
      21                 :            : 
      22                 :            :         uint64_t duration_op;
      23                 :            :         uint64_t duration_enq;
      24                 :            :         uint64_t duration_deq;
      25                 :            : };
      26                 :            : 
      27                 :            : void
      28                 :          0 : cperf_cyclecount_test_destructor(void *arg)
      29                 :            : {
      30                 :            :         struct cperf_cyclecount_ctx *ctx = arg;
      31                 :            : 
      32                 :          0 :         if (arg) {
      33                 :          0 :                 comp_perf_free_memory(ctx->ver.options, &ctx->ver.mem);
      34                 :          0 :                 rte_free(arg);
      35                 :            :         }
      36                 :          0 : }
      37                 :            : 
      38                 :            : void *
      39                 :          0 : cperf_cyclecount_test_constructor(uint8_t dev_id, uint16_t qp_id,
      40                 :            :                 struct comp_test_data *options)
      41                 :            : {
      42                 :            :         struct cperf_cyclecount_ctx *ctx = NULL;
      43                 :            : 
      44                 :          0 :         ctx = rte_malloc(NULL, sizeof(struct cperf_cyclecount_ctx), 0);
      45                 :            : 
      46                 :          0 :         if (ctx == NULL)
      47                 :            :                 return NULL;
      48                 :            : 
      49                 :          0 :         ctx->ver.mem.dev_id = dev_id;
      50                 :          0 :         ctx->ver.mem.qp_id = qp_id;
      51                 :          0 :         ctx->ver.options = options;
      52                 :          0 :         ctx->ver.silent = 1; /* ver. part will be silent */
      53                 :            : 
      54                 :          0 :         if (!comp_perf_allocate_memory(ctx->ver.options, &ctx->ver.mem)
      55                 :          0 :                         && !prepare_bufs(ctx->ver.options, &ctx->ver.mem))
      56                 :            :                 return ctx;
      57                 :            : 
      58                 :          0 :         cperf_cyclecount_test_destructor(ctx);
      59                 :          0 :         return NULL;
      60                 :            : }
      61                 :            : 
      62                 :            : static int
      63                 :          0 : cperf_cyclecount_op_setup(struct rte_comp_op **ops,
      64                 :            :                                  struct cperf_cyclecount_ctx *ctx,
      65                 :            :                                  struct rte_mbuf **input_bufs,
      66                 :            :                                  struct rte_mbuf **output_bufs,
      67                 :            :                                  void *priv_xform,
      68                 :            :                                  uint32_t out_seg_sz)
      69                 :            : {
      70                 :          0 :         struct comp_test_data *test_data = ctx->ver.options;
      71                 :            :         struct cperf_mem_resources *mem = &ctx->ver.mem;
      72                 :            : 
      73                 :            :         uint32_t i, iter, num_iter;
      74                 :            :         int res = 0;
      75                 :            :         uint16_t ops_needed;
      76                 :            : 
      77                 :          0 :         num_iter = test_data->num_iter;
      78                 :            : 
      79                 :          0 :         for (iter = 0; iter < num_iter; iter++) {
      80                 :          0 :                 uint32_t remaining_ops = mem->total_bufs;
      81                 :            :                 uint32_t total_enq_ops = 0;
      82                 :            :                 uint16_t num_enq = 0;
      83                 :            :                 uint16_t num_deq = 0;
      84                 :            : 
      85                 :          0 :                 while (remaining_ops > 0) {
      86                 :          0 :                         uint16_t num_ops = RTE_MIN(remaining_ops,
      87                 :            :                                                    test_data->burst_sz);
      88                 :            :                         ops_needed = num_ops;
      89                 :            : 
      90                 :            :                         /* Allocate compression operations */
      91                 :          0 :                         if (ops_needed && rte_mempool_get_bulk(
      92                 :            :                                                 mem->op_pool,
      93                 :            :                                                 (void **)ops,
      94                 :            :                                                 ops_needed) != 0) {
      95                 :          0 :                                 RTE_LOG(ERR, USER1,
      96                 :            :                                       "Cyclecount: could not allocate enough operations\n");
      97                 :            :                                 res = -1;
      98                 :          0 :                                 goto end;
      99                 :            :                         }
     100                 :            : 
     101                 :          0 :                         for (i = 0; i < ops_needed; i++) {
     102                 :            : 
     103                 :            :                                 /* Calculate next buffer to attach */
     104                 :            :                                 /* to operation */
     105                 :          0 :                                 uint32_t buf_id = total_enq_ops + i;
     106                 :          0 :                                 uint16_t op_id = i;
     107                 :            : 
     108                 :            :                                 /* Reset all data in output buffers */
     109                 :          0 :                                 struct rte_mbuf *m = output_bufs[buf_id];
     110                 :            : 
     111                 :          0 :                                 m->pkt_len = out_seg_sz * m->nb_segs;
     112                 :          0 :                                 while (m) {
     113                 :          0 :                                         m->data_len = m->buf_len - m->data_off;
     114                 :          0 :                                         m = m->next;
     115                 :            :                                 }
     116                 :          0 :                                 ops[op_id]->m_src = input_bufs[buf_id];
     117                 :          0 :                                 ops[op_id]->m_dst = output_bufs[buf_id];
     118                 :          0 :                                 ops[op_id]->src.offset = 0;
     119                 :          0 :                                 ops[op_id]->src.length =
     120                 :          0 :                                         rte_pktmbuf_pkt_len(input_bufs[buf_id]);
     121                 :          0 :                                 ops[op_id]->dst.offset = 0;
     122                 :          0 :                                 ops[op_id]->flush_flag = RTE_COMP_FLUSH_FINAL;
     123                 :          0 :                                 ops[op_id]->input_chksum = buf_id;
     124                 :          0 :                                 ops[op_id]->private_xform = priv_xform;
     125                 :            :                         }
     126                 :            : 
     127                 :            :                         /* E N Q U E U I N G */
     128                 :            :                         /* assuming that all ops are enqueued */
     129                 :            :                         /* instead of the real enqueue operation */
     130                 :            :                         num_enq = num_ops;
     131                 :            : 
     132                 :          0 :                         remaining_ops -= num_enq;
     133                 :          0 :                         total_enq_ops += num_enq;
     134                 :            : 
     135                 :            :                         /* D E Q U E U I N G */
     136                 :            :                         /* assuming that all ops dequeued */
     137                 :            :                         /* instead of the real dequeue operation */
     138                 :            :                         num_deq = num_ops;
     139                 :            : 
     140                 :          0 :                         rte_mempool_put_bulk(mem->op_pool,
     141                 :            :                                              (void **)ops, num_deq);
     142                 :            :                 }
     143                 :            :         }
     144                 :            :         return res;
     145                 :            : end:
     146                 :          0 :         rte_mempool_put_bulk(mem->op_pool, (void **)ops, ops_needed);
     147                 :          0 :         rte_free(ops);
     148                 :            : 
     149                 :          0 :         return res;
     150                 :            : }
     151                 :            : 
     152                 :            : static int
     153                 :          0 : main_loop(struct cperf_cyclecount_ctx *ctx, enum rte_comp_xform_type type)
     154                 :            : {
     155                 :          0 :         struct comp_test_data *test_data = ctx->ver.options;
     156                 :            :         struct cperf_mem_resources *mem = &ctx->ver.mem;
     157                 :          0 :         uint8_t dev_id = mem->dev_id;
     158                 :            :         uint32_t i, iter, num_iter;
     159                 :            :         struct rte_comp_op **ops, **deq_ops;
     160                 :          0 :         void *priv_xform = NULL;
     161                 :            :         struct rte_comp_xform xform;
     162                 :            :         struct rte_mbuf **input_bufs, **output_bufs;
     163                 :            :         int ret, res = 0;
     164                 :            :         int allocated = 0;
     165                 :            :         uint32_t out_seg_sz;
     166                 :            : 
     167                 :            :         uint64_t tsc_start, tsc_end, tsc_duration;
     168                 :            : 
     169                 :          0 :         if (test_data == NULL || !test_data->burst_sz) {
     170                 :          0 :                 RTE_LOG(ERR, USER1, "Unknown burst size\n");
     171                 :          0 :                 return -1;
     172                 :            :         }
     173                 :          0 :         ctx->duration_enq = 0;
     174                 :          0 :         ctx->duration_deq = 0;
     175                 :          0 :         ctx->ops_enq_retries = 0;
     176                 :          0 :         ctx->ops_deq_retries = 0;
     177                 :            : 
     178                 :            :         /* one array for both enqueue and dequeue */
     179                 :          0 :         ops = rte_zmalloc_socket(NULL,
     180                 :          0 :                 (test_data->burst_sz + mem->total_bufs) *
     181                 :            :                 sizeof(struct rte_comp_op *),
     182                 :          0 :                 0, rte_socket_id());
     183                 :            : 
     184                 :          0 :         if (ops == NULL) {
     185                 :          0 :                 RTE_LOG(ERR, USER1,
     186                 :            :                         "Can't allocate memory for ops structures\n");
     187                 :          0 :                 return -1;
     188                 :            :         }
     189                 :            : 
     190                 :          0 :         deq_ops = &ops[test_data->burst_sz];
     191                 :            : 
     192                 :          0 :         if (type == RTE_COMP_COMPRESS) {
     193                 :          0 :                 xform = (struct rte_comp_xform) {
     194                 :            :                         .type = RTE_COMP_COMPRESS,
     195                 :            :                         .compress = {
     196                 :          0 :                                 .algo = test_data->test_algo,
     197                 :          0 :                                 .level = test_data->level,
     198                 :          0 :                                 .window_size = test_data->window_sz,
     199                 :            :                                 .chksum = RTE_COMP_CHECKSUM_NONE,
     200                 :            :                                 .hash_algo = RTE_COMP_HASH_ALGO_NONE
     201                 :            :                         }
     202                 :            :                 };
     203                 :          0 :                 if (test_data->test_algo == RTE_COMP_ALGO_DEFLATE)
     204                 :          0 :                         xform.compress.deflate.huffman = test_data->huffman_enc;
     205                 :          0 :                 else if (test_data->test_algo == RTE_COMP_ALGO_LZ4)
     206                 :          0 :                         xform.compress.lz4.flags = test_data->lz4_flags;
     207                 :          0 :                 input_bufs = mem->decomp_bufs;
     208                 :          0 :                 output_bufs = mem->comp_bufs;
     209                 :          0 :                 out_seg_sz = test_data->out_seg_sz;
     210                 :            :         } else {
     211                 :          0 :                 xform = (struct rte_comp_xform) {
     212                 :            :                         .type = RTE_COMP_DECOMPRESS,
     213                 :            :                         .decompress = {
     214                 :          0 :                                 .algo = test_data->test_algo,
     215                 :            :                                 .chksum = RTE_COMP_CHECKSUM_NONE,
     216                 :          0 :                                 .window_size = test_data->window_sz,
     217                 :            :                                 .hash_algo = RTE_COMP_HASH_ALGO_NONE
     218                 :            :                         }
     219                 :            :                 };
     220                 :          0 :                 if (test_data->test_algo == RTE_COMP_ALGO_LZ4)
     221                 :          0 :                         xform.decompress.lz4.flags = test_data->lz4_flags;
     222                 :          0 :                 input_bufs = mem->comp_bufs;
     223                 :          0 :                 output_bufs = mem->decomp_bufs;
     224                 :          0 :                 out_seg_sz = test_data->seg_sz;
     225                 :            :         }
     226                 :            : 
     227                 :            :         /* Create private xform */
     228                 :          0 :         if (rte_compressdev_private_xform_create(dev_id, &xform,
     229                 :            :                                                 &priv_xform) < 0) {
     230                 :          0 :                 RTE_LOG(ERR, USER1, "Private xform could not be created\n");
     231                 :            :                 res = -1;
     232                 :          0 :                 goto end;
     233                 :            :         }
     234                 :            : 
     235                 :            :         tsc_start = rte_rdtsc_precise();
     236                 :          0 :         ret = cperf_cyclecount_op_setup(ops,
     237                 :            :                                 ctx,
     238                 :            :                                 input_bufs,
     239                 :            :                                 output_bufs,
     240                 :            :                                 priv_xform,
     241                 :            :                                 out_seg_sz);
     242                 :            : 
     243                 :            :         tsc_end = rte_rdtsc_precise();
     244                 :            : 
     245                 :            :         /* ret value check postponed a bit to cancel extra 'if' bias */
     246                 :          0 :         if (ret < 0) {
     247                 :          0 :                 RTE_LOG(ERR, USER1, "Setup function failed\n");
     248                 :            :                 res = -1;
     249                 :          0 :                 goto end;
     250                 :            :         }
     251                 :            : 
     252                 :          0 :         tsc_duration = tsc_end - tsc_start;
     253                 :          0 :         ctx->duration_op = tsc_duration;
     254                 :            : 
     255                 :          0 :         num_iter = test_data->num_iter;
     256                 :          0 :         for (iter = 0; iter < num_iter; iter++) {
     257                 :          0 :                 uint32_t total_ops = mem->total_bufs;
     258                 :            :                 uint32_t remaining_ops = mem->total_bufs;
     259                 :            :                 uint32_t total_deq_ops = 0;
     260                 :            :                 uint32_t total_enq_ops = 0;
     261                 :            :                 uint16_t ops_unused = 0;
     262                 :            :                 uint16_t num_enq = 0;
     263                 :            :                 uint16_t num_deq = 0;
     264                 :            : 
     265                 :          0 :                 while (remaining_ops > 0) {
     266                 :          0 :                         uint16_t num_ops = RTE_MIN(remaining_ops,
     267                 :            :                                                    test_data->burst_sz);
     268                 :          0 :                         uint16_t ops_needed = num_ops - ops_unused;
     269                 :            : 
     270                 :            :                         /*
     271                 :            :                          * Move the unused operations from the previous
     272                 :            :                          * enqueue_burst call to the front, to maintain order
     273                 :            :                          */
     274                 :          0 :                         if ((ops_unused > 0) && (num_enq > 0)) {
     275                 :          0 :                                 size_t nb_b_to_mov =
     276                 :          0 :                                       ops_unused * sizeof(struct rte_comp_op *);
     277                 :            : 
     278                 :          0 :                                 memmove(ops, &ops[num_enq], nb_b_to_mov);
     279                 :            :                         }
     280                 :            : 
     281                 :            :                         /* Allocate compression operations */
     282                 :          0 :                         if (ops_needed && rte_mempool_get_bulk(
     283                 :            :                                                 mem->op_pool,
     284                 :          0 :                                                 (void **)&ops[ops_unused],
     285                 :            :                                                 ops_needed) != 0) {
     286                 :          0 :                                 RTE_LOG(ERR, USER1,
     287                 :            :                                       "Could not allocate enough operations\n");
     288                 :            :                                 res = -1;
     289                 :          0 :                                 goto end;
     290                 :            :                         }
     291                 :          0 :                         allocated += ops_needed;
     292                 :            : 
     293                 :          0 :                         for (i = 0; i < ops_needed; i++) {
     294                 :            :                                 /*
     295                 :            :                                  * Calculate next buffer to attach to operation
     296                 :            :                                  */
     297                 :          0 :                                 uint32_t buf_id = total_enq_ops + i +
     298                 :            :                                                 ops_unused;
     299                 :          0 :                                 uint16_t op_id = ops_unused + i;
     300                 :            :                                 /* Reset all data in output buffers */
     301                 :          0 :                                 struct rte_mbuf *m = output_bufs[buf_id];
     302                 :            : 
     303                 :          0 :                                 m->pkt_len = out_seg_sz * m->nb_segs;
     304                 :          0 :                                 while (m) {
     305                 :          0 :                                         m->data_len = m->buf_len - m->data_off;
     306                 :          0 :                                         m = m->next;
     307                 :            :                                 }
     308                 :          0 :                                 ops[op_id]->m_src = input_bufs[buf_id];
     309                 :          0 :                                 ops[op_id]->m_dst = output_bufs[buf_id];
     310                 :          0 :                                 ops[op_id]->src.offset = 0;
     311                 :          0 :                                 ops[op_id]->src.length =
     312                 :          0 :                                         rte_pktmbuf_pkt_len(input_bufs[buf_id]);
     313                 :          0 :                                 ops[op_id]->dst.offset = 0;
     314                 :          0 :                                 ops[op_id]->flush_flag = RTE_COMP_FLUSH_FINAL;
     315                 :          0 :                                 ops[op_id]->input_chksum = buf_id;
     316                 :          0 :                                 ops[op_id]->private_xform = priv_xform;
     317                 :            :                         }
     318                 :            : 
     319                 :          0 :                         if (unlikely(test_data->perf_comp_force_stop))
     320                 :          0 :                                 goto end;
     321                 :            : 
     322                 :            :                         tsc_start = rte_rdtsc_precise();
     323                 :          0 :                         num_enq = rte_compressdev_enqueue_burst(dev_id,
     324                 :          0 :                                                                 mem->qp_id, ops,
     325                 :            :                                                                 num_ops);
     326                 :            :                         tsc_end = rte_rdtsc_precise();
     327                 :          0 :                         tsc_duration = tsc_end - tsc_start;
     328                 :          0 :                         ctx->duration_enq += tsc_duration;
     329                 :            : 
     330                 :          0 :                         if (num_enq < num_ops)
     331                 :          0 :                                 ctx->ops_enq_retries++;
     332                 :            : 
     333                 :          0 :                         if (test_data->cyclecount_delay)
     334                 :          0 :                                 rte_delay_us_block(test_data->cyclecount_delay);
     335                 :            : 
     336                 :          0 :                         if (num_enq == 0) {
     337                 :            :                                 struct rte_compressdev_stats stats;
     338                 :            : 
     339                 :          0 :                                 rte_compressdev_stats_get(dev_id, &stats);
     340                 :          0 :                                 if (stats.enqueue_err_count) {
     341                 :            :                                         res = -1;
     342                 :          0 :                                         goto end;
     343                 :            :                                 }
     344                 :            :                         }
     345                 :            : 
     346                 :          0 :                         ops_unused = num_ops - num_enq;
     347                 :          0 :                         remaining_ops -= num_enq;
     348                 :          0 :                         total_enq_ops += num_enq;
     349                 :            : 
     350                 :            :                         tsc_start = rte_rdtsc_precise();
     351                 :          0 :                         num_deq = rte_compressdev_dequeue_burst(dev_id,
     352                 :          0 :                                                            mem->qp_id,
     353                 :            :                                                            deq_ops,
     354                 :            :                                                            allocated);
     355                 :            :                         tsc_end = rte_rdtsc_precise();
     356                 :          0 :                         tsc_duration = tsc_end - tsc_start;
     357                 :          0 :                         ctx->duration_deq += tsc_duration;
     358                 :            : 
     359                 :          0 :                         if (num_deq < allocated)
     360                 :          0 :                                 ctx->ops_deq_retries++;
     361                 :            : 
     362                 :          0 :                         total_deq_ops += num_deq;
     363                 :            : 
     364                 :          0 :                         if (iter == num_iter - 1) {
     365                 :          0 :                                 for (i = 0; i < num_deq; i++) {
     366                 :          0 :                                         struct rte_comp_op *op = deq_ops[i];
     367                 :            : 
     368                 :          0 :                                         if (op->status !=
     369                 :            :                                                 RTE_COMP_OP_STATUS_SUCCESS) {
     370                 :          0 :                                                 RTE_LOG(ERR, USER1, "Some operations were not successful\n");
     371                 :          0 :                                                 goto end;
     372                 :            :                                         }
     373                 :            : 
     374                 :          0 :                                         struct rte_mbuf *m = op->m_dst;
     375                 :            : 
     376                 :          0 :                                         m->pkt_len = op->produced;
     377                 :            :                                         uint32_t remaining_data = op->produced;
     378                 :            :                                         uint16_t data_to_append;
     379                 :            : 
     380                 :          0 :                                         while (remaining_data > 0) {
     381                 :          0 :                                                 data_to_append =
     382                 :          0 :                                                         RTE_MIN(remaining_data,
     383                 :            :                                                              out_seg_sz);
     384                 :          0 :                                                 m->data_len = data_to_append;
     385                 :          0 :                                                 remaining_data -=
     386                 :            :                                                                 data_to_append;
     387                 :          0 :                                                 m = m->next;
     388                 :            :                                         }
     389                 :            :                                 }
     390                 :            :                         }
     391                 :          0 :                         rte_mempool_put_bulk(mem->op_pool,
     392                 :            :                                              (void **)deq_ops, num_deq);
     393                 :          0 :                         allocated -= num_deq;
     394                 :            :                 }
     395                 :            : 
     396                 :            :                 /* Dequeue the last operations */
     397                 :          0 :                 while (total_deq_ops < total_ops) {
     398                 :          0 :                         if (unlikely(test_data->perf_comp_force_stop))
     399                 :          0 :                                 goto end;
     400                 :            : 
     401                 :            :                         tsc_start = rte_rdtsc_precise();
     402                 :          0 :                         num_deq = rte_compressdev_dequeue_burst(dev_id,
     403                 :          0 :                                                 mem->qp_id,
     404                 :            :                                                 deq_ops,
     405                 :          0 :                                                 test_data->burst_sz);
     406                 :            :                         tsc_end = rte_rdtsc_precise();
     407                 :          0 :                         tsc_duration = tsc_end - tsc_start;
     408                 :          0 :                         ctx->duration_deq += tsc_duration;
     409                 :          0 :                         ctx->ops_deq_retries++;
     410                 :            : 
     411                 :          0 :                         if (num_deq == 0) {
     412                 :            :                                 struct rte_compressdev_stats stats;
     413                 :            : 
     414                 :          0 :                                 rte_compressdev_stats_get(dev_id, &stats);
     415                 :          0 :                                 if (stats.dequeue_err_count) {
     416                 :            :                                         res = -1;
     417                 :          0 :                                         goto end;
     418                 :            :                                 }
     419                 :            :                         }
     420                 :          0 :                         total_deq_ops += num_deq;
     421                 :            : 
     422                 :          0 :                         if (iter == num_iter - 1) {
     423                 :          0 :                                 for (i = 0; i < num_deq; i++) {
     424                 :          0 :                                         struct rte_comp_op *op = deq_ops[i];
     425                 :            : 
     426                 :          0 :                                         if (op->status !=
     427                 :            :                                                 RTE_COMP_OP_STATUS_SUCCESS) {
     428                 :          0 :                                                 RTE_LOG(ERR, USER1, "Some operations were not successful\n");
     429                 :          0 :                                                 goto end;
     430                 :            :                                         }
     431                 :            : 
     432                 :          0 :                                         struct rte_mbuf *m = op->m_dst;
     433                 :            : 
     434                 :          0 :                                         m->pkt_len = op->produced;
     435                 :            :                                         uint32_t remaining_data = op->produced;
     436                 :            :                                         uint16_t data_to_append;
     437                 :            : 
     438                 :          0 :                                         while (remaining_data > 0) {
     439                 :          0 :                                                 data_to_append =
     440                 :          0 :                                                 RTE_MIN(remaining_data,
     441                 :            :                                                         out_seg_sz);
     442                 :          0 :                                                 m->data_len = data_to_append;
     443                 :          0 :                                                 remaining_data -=
     444                 :            :                                                                 data_to_append;
     445                 :          0 :                                                 m = m->next;
     446                 :            :                                         }
     447                 :            :                                 }
     448                 :            :                         }
     449                 :          0 :                         rte_mempool_put_bulk(mem->op_pool,
     450                 :            :                                              (void **)deq_ops, num_deq);
     451                 :          0 :                         allocated -= num_deq;
     452                 :            :                 }
     453                 :            :         }
     454                 :            :         allocated = 0;
     455                 :            : 
     456                 :          0 : end:
     457                 :          0 :         if (allocated)
     458                 :          0 :                 rte_mempool_put_bulk(mem->op_pool, (void **)ops, allocated);
     459                 :          0 :         rte_compressdev_private_xform_free(dev_id, priv_xform);
     460                 :          0 :         rte_free(ops);
     461                 :            : 
     462                 :          0 :         if (test_data->perf_comp_force_stop) {
     463                 :          0 :                 RTE_LOG(ERR, USER1,
     464                 :            :                       "lcore: %d Perf. test has been aborted by user\n",
     465                 :            :                         mem->lcore_id);
     466                 :            :                 res = -1;
     467                 :            :         }
     468                 :            :         return res;
     469                 :            : }
     470                 :            : 
     471                 :            : int
     472                 :          0 : cperf_cyclecount_test_runner(void *test_ctx)
     473                 :            : {
     474                 :            :         struct cperf_cyclecount_ctx *ctx = test_ctx;
     475                 :          0 :         struct comp_test_data *test_data = ctx->ver.options;
     476                 :            :         uint32_t lcore = rte_lcore_id();
     477                 :            :         static uint16_t display_once;
     478                 :            :         static rte_spinlock_t print_spinlock;
     479                 :            :         int i;
     480                 :            : 
     481                 :            :         uint32_t ops_enq_retries_comp;
     482                 :            :         uint32_t ops_deq_retries_comp;
     483                 :            : 
     484                 :            :         uint32_t ops_enq_retries_decomp;
     485                 :            :         uint32_t ops_deq_retries_decomp;
     486                 :            : 
     487                 :            :         uint32_t duration_setup_per_op;
     488                 :            : 
     489                 :            :         uint32_t duration_enq_per_op_comp;
     490                 :            :         uint32_t duration_deq_per_op_comp;
     491                 :            : 
     492                 :            :         uint32_t duration_enq_per_op_decomp;
     493                 :            :         uint32_t duration_deq_per_op_decomp;
     494                 :            : 
     495                 :          0 :         ctx->ver.mem.lcore_id = lcore;
     496                 :            : 
     497                 :            :         uint16_t exp = 0;
     498                 :            :         /*
     499                 :            :          * printing information about current compression thread
     500                 :            :          */
     501                 :          0 :         if (rte_atomic_compare_exchange_strong_explicit(&ctx->ver.mem.print_info_once, &exp,
     502                 :            :                                 1, rte_memory_order_relaxed,  rte_memory_order_relaxed))
     503                 :          0 :                 printf("    lcore: %u,"
     504                 :            :                                 " driver name: %s,"
     505                 :            :                                 " device name: %s,"
     506                 :            :                                 " device id: %u,"
     507                 :            :                                 " socket id: %u,"
     508                 :            :                                 " queue pair id: %u\n",
     509                 :            :                         lcore,
     510                 :          0 :                         ctx->ver.options->driver_name,
     511                 :            :                         rte_compressdev_name_get(ctx->ver.mem.dev_id),
     512                 :          0 :                         ctx->ver.mem.dev_id,
     513                 :          0 :                         rte_compressdev_socket_id(ctx->ver.mem.dev_id),
     514                 :          0 :                         ctx->ver.mem.qp_id);
     515                 :            : 
     516                 :            :         /*
     517                 :            :          * First the verification part is needed
     518                 :            :          */
     519                 :          0 :         if (cperf_verify_test_runner(&ctx->ver))
     520                 :            :                 return EXIT_FAILURE;
     521                 :            : 
     522                 :          0 :         if (test_data->test_op & COMPRESS) {
     523                 :            :                 /*
     524                 :            :                  * Run the test twice, discarding the first performance
     525                 :            :                  * results, before the cache is warmed up
     526                 :            :                  */
     527                 :          0 :                 for (i = 0; i < 2; i++) {
     528                 :          0 :                         if (main_loop(ctx, RTE_COMP_COMPRESS) < 0)
     529                 :            :                                 return EXIT_FAILURE;
     530                 :            :                 }
     531                 :            : 
     532                 :          0 :                 ops_enq_retries_comp = ctx->ops_enq_retries;
     533                 :          0 :                 ops_deq_retries_comp = ctx->ops_deq_retries;
     534                 :            : 
     535                 :          0 :                 duration_enq_per_op_comp = ctx->duration_enq /
     536                 :          0 :                                 (ctx->ver.mem.total_bufs * test_data->num_iter);
     537                 :          0 :                 duration_deq_per_op_comp = ctx->duration_deq /
     538                 :            :                                 (ctx->ver.mem.total_bufs * test_data->num_iter);
     539                 :            :         } else {
     540                 :            :                 ops_enq_retries_comp = 0;
     541                 :            :                 ops_deq_retries_comp = 0;
     542                 :            : 
     543                 :            :                 duration_enq_per_op_comp = 0;
     544                 :            :                 duration_deq_per_op_comp = 0;
     545                 :            :         }
     546                 :            : 
     547                 :          0 :         if (test_data->test_op & DECOMPRESS) {
     548                 :            :                 /*
     549                 :            :                  * Run the test twice, discarding the first performance
     550                 :            :                  * results, before the cache is warmed up
     551                 :            :                  */
     552                 :          0 :                 for (i = 0; i < 2; i++) {
     553                 :          0 :                         if (main_loop(ctx, RTE_COMP_DECOMPRESS) < 0)
     554                 :            :                                 return EXIT_FAILURE;
     555                 :            :                 }
     556                 :            : 
     557                 :          0 :                 ops_enq_retries_decomp = ctx->ops_enq_retries;
     558                 :          0 :                 ops_deq_retries_decomp = ctx->ops_deq_retries;
     559                 :            : 
     560                 :          0 :                 duration_enq_per_op_decomp = ctx->duration_enq /
     561                 :          0 :                                 (ctx->ver.mem.total_bufs * test_data->num_iter);
     562                 :          0 :                 duration_deq_per_op_decomp = ctx->duration_deq /
     563                 :            :                                 (ctx->ver.mem.total_bufs * test_data->num_iter);
     564                 :            :         } else {
     565                 :            :                 ops_enq_retries_decomp = 0;
     566                 :            :                 ops_deq_retries_decomp = 0;
     567                 :            : 
     568                 :            :                 duration_enq_per_op_decomp = 0;
     569                 :            :                 duration_deq_per_op_decomp = 0;
     570                 :            :         }
     571                 :            : 
     572                 :          0 :         duration_setup_per_op = ctx->duration_op /
     573                 :          0 :                         (ctx->ver.mem.total_bufs * test_data->num_iter);
     574                 :            : 
     575                 :            :         /* R E P O R T processing */
     576                 :            :         rte_spinlock_lock(&print_spinlock);
     577                 :            : 
     578                 :          0 :         if (display_once == 0) {
     579                 :          0 :                 display_once = 1;
     580                 :            : 
     581                 :            :                 printf("\nLegend for the table\n"
     582                 :            :                 "  - Retries section: number of retries for the following operations:\n"
     583                 :            :                 "    [C-e] - compression enqueue\n"
     584                 :            :                 "    [C-d] - compression dequeue\n"
     585                 :            :                 "    [D-e] - decompression enqueue\n"
     586                 :            :                 "    [D-d] - decompression dequeue\n"
     587                 :            :                 "  - Cycles section: number of cycles per 'op' for the following operations:\n"
     588                 :            :                 "    setup/op - memory allocation, op configuration and memory deallocation\n"
     589                 :            :                 "    [C-e] - compression enqueue\n"
     590                 :            :                 "    [C-d] - compression dequeue\n"
     591                 :            :                 "    [D-e] - decompression enqueue\n"
     592                 :            :                 "    [D-d] - decompression dequeue\n\n");
     593                 :            : 
     594                 :            :                 printf("\n%12s%6s%12s%17s",
     595                 :            :                         "lcore id", "Level", "Comp size", "Comp ratio [%]");
     596                 :            : 
     597                 :            :                 printf("  |%10s %6s %8s %6s %8s",
     598                 :            :                         " Retries:",
     599                 :            :                         "[C-e]", "[C-d]",
     600                 :            :                         "[D-e]", "[D-d]");
     601                 :            : 
     602                 :            :                 printf("  |%9s %9s %9s %9s %9s %9s\n",
     603                 :            :                         " Cycles:",
     604                 :            :                         "setup/op",
     605                 :            :                         "[C-e]", "[C-d]",
     606                 :            :                         "[D-e]", "[D-d]");
     607                 :            :         }
     608                 :            : 
     609                 :          0 :         printf("%12u"
     610                 :            :                "%6u"
     611                 :            :                "%12zu"
     612                 :            :                "%17.2f",
     613                 :          0 :                 ctx->ver.mem.lcore_id,
     614                 :          0 :                 test_data->level,
     615                 :            :                 ctx->ver.comp_data_sz,
     616                 :            :                 ctx->ver.ratio);
     617                 :            : 
     618                 :            :         printf("  |%10s %6u %8u %6u %8u",
     619                 :            :                " ",
     620                 :            :                 ops_enq_retries_comp,
     621                 :            :                 ops_deq_retries_comp,
     622                 :            :                 ops_enq_retries_decomp,
     623                 :            :                 ops_deq_retries_decomp);
     624                 :            : 
     625                 :            :         printf("  |%9s %9u %9u %9u %9u %9u\n",
     626                 :            :                " ",
     627                 :            :                 duration_setup_per_op,
     628                 :            :                 duration_enq_per_op_comp,
     629                 :            :                 duration_deq_per_op_comp,
     630                 :            :                 duration_enq_per_op_decomp,
     631                 :            :                 duration_deq_per_op_decomp);
     632                 :            : 
     633                 :            :         rte_spinlock_unlock(&print_spinlock);
     634                 :            : 
     635                 :          0 :         return EXIT_SUCCESS;
     636                 :            : }

Generated by: LCOV version 1.14