Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2018 Intel Corporation
3 : : */
4 : :
5 : : #include <stdlib.h>
6 : : #include <signal.h>
7 : : #include <sys/types.h>
8 : : #include <unistd.h>
9 : :
10 : : #include <rte_malloc.h>
11 : : #include <rte_eal.h>
12 : : #include <rte_log.h>
13 : : #include <rte_compressdev.h>
14 : :
15 : : #include "comp_perf.h"
16 : : #include "comp_perf_options.h"
17 : : #include "comp_perf_test_common.h"
18 : : #include "comp_perf_test_cyclecount.h"
19 : : #include "comp_perf_test_throughput.h"
20 : : #include "comp_perf_test_verify.h"
21 : :
22 : : #define NUM_MAX_XFORMS 16
23 : : #define NUM_MAX_INFLIGHT_OPS 512
24 : :
25 : : __extension__
26 : : const char *comp_perf_test_type_strs[] = {
27 : : [CPERF_TEST_TYPE_THROUGHPUT] = "throughput",
28 : : [CPERF_TEST_TYPE_VERIFY] = "verify",
29 : : [CPERF_TEST_TYPE_PMDCC] = "pmd-cyclecount"
30 : : };
31 : :
32 : : __extension__
33 : : static const struct cperf_test cperf_testmap[] = {
34 : : [CPERF_TEST_TYPE_THROUGHPUT] = {
35 : : cperf_throughput_test_constructor,
36 : : cperf_throughput_test_runner,
37 : : cperf_throughput_test_destructor
38 : :
39 : : },
40 : : [CPERF_TEST_TYPE_VERIFY] = {
41 : : cperf_verify_test_constructor,
42 : : cperf_verify_test_runner,
43 : : cperf_verify_test_destructor
44 : : },
45 : :
46 : : [CPERF_TEST_TYPE_PMDCC] = {
47 : : cperf_cyclecount_test_constructor,
48 : : cperf_cyclecount_test_runner,
49 : : cperf_cyclecount_test_destructor
50 : : }
51 : : };
52 : :
53 : : static struct comp_test_data *test_data;
54 : :
55 : : static int
56 : 0 : comp_perf_check_capabilities(struct comp_test_data *test_data, uint8_t cdev_id)
57 : : {
58 : : const struct rte_compressdev_capabilities *cap;
59 : :
60 : 0 : cap = rte_compressdev_capability_get(cdev_id, test_data->test_algo);
61 : :
62 : 0 : if (cap == NULL) {
63 : 0 : RTE_LOG(ERR, USER1,
64 : : "Compress device does not support %u algorithm\n",
65 : : test_data->test_algo);
66 : 0 : return -1;
67 : : }
68 : :
69 : 0 : uint64_t comp_flags = cap->comp_feature_flags;
70 : :
71 : : /* Algorithm type */
72 : 0 : switch (test_data->test_algo) {
73 : 0 : case RTE_COMP_ALGO_DEFLATE:
74 : : /* Huffman encoding */
75 : 0 : if (test_data->huffman_enc == RTE_COMP_HUFFMAN_FIXED &&
76 : 0 : (comp_flags & RTE_COMP_FF_HUFFMAN_FIXED) == 0) {
77 : 0 : RTE_LOG(ERR, USER1,
78 : : "Compress device does not supported Fixed Huffman\n");
79 : 0 : return -1;
80 : : }
81 : :
82 : 0 : if (test_data->huffman_enc == RTE_COMP_HUFFMAN_DYNAMIC &&
83 : 0 : (comp_flags & RTE_COMP_FF_HUFFMAN_DYNAMIC) == 0) {
84 : 0 : RTE_LOG(ERR, USER1,
85 : : "Compress device does not supported Dynamic Huffman\n");
86 : 0 : return -1;
87 : : }
88 : : break;
89 : 0 : case RTE_COMP_ALGO_LZ4:
90 : : /* LZ4 flags */
91 : 0 : if ((test_data->lz4_flags & RTE_COMP_LZ4_FLAG_BLOCK_CHECKSUM) &&
92 : 0 : (comp_flags & RTE_COMP_FF_LZ4_BLOCK_WITH_CHECKSUM) == 0) {
93 : 0 : RTE_LOG(ERR, USER1,
94 : : "Compress device does not support LZ4 block with checksum\n");
95 : 0 : return -1;
96 : : }
97 : :
98 : 0 : if ((test_data->lz4_flags &
99 : 0 : RTE_COMP_LZ4_FLAG_BLOCK_INDEPENDENCE) &&
100 : 0 : (comp_flags & RTE_COMP_FF_LZ4_BLOCK_INDEPENDENCE) == 0) {
101 : 0 : RTE_LOG(ERR, USER1,
102 : : "Compress device does not support LZ4 independent blocks\n");
103 : 0 : return -1;
104 : : }
105 : : break;
106 : : case RTE_COMP_ALGO_LZS:
107 : : case RTE_COMP_ALGO_NULL:
108 : : break;
109 : : default:
110 : : return -1;
111 : : }
112 : :
113 : : /* Window size */
114 : 0 : if (test_data->window_sz != -1) {
115 : 0 : if (param_range_check(test_data->window_sz, &cap->window_size)
116 : : < 0) {
117 : 0 : RTE_LOG(ERR, USER1,
118 : : "Compress device does not support "
119 : : "this window size\n");
120 : 0 : return -1;
121 : : }
122 : : } else
123 : : /* Set window size to PMD maximum if none was specified */
124 : 0 : test_data->window_sz = cap->window_size.max;
125 : :
126 : : /* Check if chained mbufs is supported */
127 : 0 : if (test_data->max_sgl_segs > 1 &&
128 : 0 : (comp_flags & RTE_COMP_FF_OOP_SGL_IN_SGL_OUT) == 0) {
129 : 0 : RTE_LOG(INFO, USER1, "Compress device does not support "
130 : : "chained mbufs. Max SGL segments set to 1\n");
131 : 0 : test_data->max_sgl_segs = 1;
132 : : }
133 : :
134 : : /* Level 0 support */
135 : 0 : if (test_data->level_lst.min == 0 &&
136 : 0 : (comp_flags & RTE_COMP_FF_NONCOMPRESSED_BLOCKS) == 0) {
137 : 0 : RTE_LOG(ERR, USER1, "Compress device does not support "
138 : : "level 0 (no compression)\n");
139 : 0 : return -1;
140 : : }
141 : :
142 : : return 0;
143 : : }
144 : :
145 : : static int
146 : 0 : comp_perf_initialize_compressdev(struct comp_test_data *test_data,
147 : : uint8_t *enabled_cdevs)
148 : : {
149 : : uint8_t enabled_cdev_count, nb_lcores, cdev_id;
150 : : unsigned int i, j;
151 : : int ret;
152 : :
153 : 0 : enabled_cdev_count = rte_compressdev_devices_get(test_data->driver_name,
154 : : enabled_cdevs, RTE_COMPRESS_MAX_DEVS);
155 : 0 : if (enabled_cdev_count == 0) {
156 : 0 : RTE_LOG(ERR, USER1, "No compress devices type %s available,"
157 : : " please check the list of specified devices in EAL section\n",
158 : : test_data->driver_name);
159 : 0 : return -EINVAL;
160 : : }
161 : :
162 : 0 : nb_lcores = rte_lcore_count() - 1;
163 : : /*
164 : : * Use fewer devices,
165 : : * if there are more available than cores.
166 : : */
167 : 0 : if (enabled_cdev_count > nb_lcores) {
168 : 0 : if (nb_lcores == 0) {
169 : 0 : RTE_LOG(ERR, USER1, "Cannot run with 0 cores! Increase the number of cores\n");
170 : 0 : return -EINVAL;
171 : : }
172 : : enabled_cdev_count = nb_lcores;
173 : 0 : RTE_LOG(INFO, USER1,
174 : : "There's more available devices than cores!"
175 : : " The number of devices has been aligned to %d cores\n",
176 : : nb_lcores);
177 : : }
178 : :
179 : : /*
180 : : * Calculate number of needed queue pairs, based on the amount
181 : : * of available number of logical cores and compression devices.
182 : : * For instance, if there are 4 cores and 2 compression devices,
183 : : * 2 queue pairs will be set up per device.
184 : : * One queue pair per one core.
185 : : * if e.g.: there're 3 cores and 2 compression devices,
186 : : * 2 queue pairs will be set up per device but one queue pair
187 : : * will left unused in the last one device
188 : : */
189 : 0 : test_data->nb_qps = (nb_lcores % enabled_cdev_count) ?
190 : 0 : (nb_lcores / enabled_cdev_count) + 1 :
191 : : nb_lcores / enabled_cdev_count;
192 : :
193 : 0 : for (i = 0; i < enabled_cdev_count &&
194 : 0 : i < RTE_COMPRESS_MAX_DEVS; i++,
195 : 0 : nb_lcores -= test_data->nb_qps) {
196 : 0 : cdev_id = enabled_cdevs[i];
197 : :
198 : : struct rte_compressdev_info cdev_info;
199 : 0 : int socket_id = rte_compressdev_socket_id(cdev_id);
200 : :
201 : 0 : rte_compressdev_info_get(cdev_id, &cdev_info);
202 : 0 : if (cdev_info.max_nb_queue_pairs &&
203 : 0 : test_data->nb_qps > cdev_info.max_nb_queue_pairs) {
204 : 0 : RTE_LOG(ERR, USER1,
205 : : "Number of needed queue pairs is higher "
206 : : "than the maximum number of queue pairs "
207 : : "per device.\n");
208 : 0 : RTE_LOG(ERR, USER1,
209 : : "Lower the number of cores or increase "
210 : : "the number of crypto devices\n");
211 : 0 : return -EINVAL;
212 : : }
213 : :
214 : 0 : if (comp_perf_check_capabilities(test_data, cdev_id) < 0)
215 : : return -EINVAL;
216 : :
217 : : /* Configure compressdev */
218 : 0 : struct rte_compressdev_config config = {
219 : : .socket_id = socket_id,
220 : 0 : .nb_queue_pairs = nb_lcores > test_data->nb_qps
221 : : ? test_data->nb_qps : nb_lcores,
222 : : .max_nb_priv_xforms = NUM_MAX_XFORMS,
223 : : .max_nb_streams = 0
224 : : };
225 : 0 : test_data->nb_qps = config.nb_queue_pairs;
226 : :
227 : 0 : if (rte_compressdev_configure(cdev_id, &config) < 0) {
228 : 0 : RTE_LOG(ERR, USER1, "Device configuration failed\n");
229 : 0 : return -EINVAL;
230 : : }
231 : :
232 : 0 : for (j = 0; j < test_data->nb_qps; j++) {
233 : 0 : ret = rte_compressdev_queue_pair_setup(cdev_id, j,
234 : : NUM_MAX_INFLIGHT_OPS, socket_id);
235 : 0 : if (ret < 0) {
236 : 0 : RTE_LOG(ERR, USER1,
237 : : "Failed to setup queue pair %u on compressdev %u",
238 : : j, cdev_id);
239 : 0 : return -EINVAL;
240 : : }
241 : : }
242 : :
243 : 0 : ret = rte_compressdev_start(cdev_id);
244 : 0 : if (ret < 0) {
245 : 0 : RTE_LOG(ERR, USER1,
246 : : "Failed to start device %u: error %d\n",
247 : : cdev_id, ret);
248 : 0 : return -EPERM;
249 : : }
250 : : }
251 : :
252 : 0 : return enabled_cdev_count;
253 : : }
254 : :
255 : : static int
256 : 0 : comp_perf_dump_input_data(struct comp_test_data *test_data)
257 : : {
258 : 0 : FILE *f = fopen(test_data->input_file, "r");
259 : : int ret = -1;
260 : : size_t actual_file_sz, remaining_data;
261 : : uint8_t *data = NULL;
262 : :
263 : 0 : if (f == NULL) {
264 : 0 : RTE_LOG(ERR, USER1, "Input file could not be opened\n");
265 : 0 : return -1;
266 : : }
267 : :
268 : 0 : if (fseek(f, 0, SEEK_END) != 0) {
269 : 0 : RTE_LOG(ERR, USER1, "Size of input could not be calculated\n");
270 : 0 : goto end;
271 : : }
272 : 0 : actual_file_sz = ftell(f);
273 : : /* If extended input data size has not been set,
274 : : * input data size = file size
275 : : */
276 : :
277 : 0 : if (test_data->input_data_sz == 0)
278 : 0 : test_data->input_data_sz = actual_file_sz;
279 : :
280 : 0 : if (test_data->input_data_sz <= 0 || actual_file_sz <= 0 ||
281 : 0 : fseek(f, 0, SEEK_SET) != 0) {
282 : 0 : RTE_LOG(ERR, USER1, "Size of input could not be calculated\n");
283 : 0 : goto end;
284 : : }
285 : :
286 : 0 : if (!(test_data->test_op & COMPRESS) &&
287 : 0 : test_data->input_data_sz >
288 : 0 : (size_t) test_data->seg_sz * (size_t) test_data->max_sgl_segs) {
289 : 0 : RTE_LOG(ERR, USER1,
290 : : "Size of input must be less than total segments\n");
291 : 0 : goto end;
292 : : }
293 : :
294 : 0 : test_data->input_data = rte_zmalloc_socket(NULL,
295 : 0 : test_data->input_data_sz, 0, rte_socket_id());
296 : :
297 : 0 : if (test_data->input_data == NULL) {
298 : 0 : RTE_LOG(ERR, USER1, "Memory to hold the data from the input "
299 : : "file could not be allocated\n");
300 : 0 : goto end;
301 : : }
302 : :
303 : 0 : remaining_data = test_data->input_data_sz;
304 : : data = test_data->input_data;
305 : :
306 : 0 : while (remaining_data > 0) {
307 : 0 : size_t data_to_read = RTE_MIN(remaining_data, actual_file_sz);
308 : :
309 : 0 : if (fread(data, data_to_read, 1, f) != 1) {
310 : 0 : RTE_LOG(ERR, USER1, "Input file could not be read\n");
311 : 0 : goto end;
312 : : }
313 : 0 : if (fseek(f, 0, SEEK_SET) != 0) {
314 : 0 : RTE_LOG(ERR, USER1,
315 : : "Size of input could not be calculated\n");
316 : 0 : goto end;
317 : : }
318 : 0 : remaining_data -= data_to_read;
319 : 0 : data += data_to_read;
320 : : }
321 : :
322 : : printf("\n");
323 : 0 : if (test_data->input_data_sz > actual_file_sz)
324 : 0 : RTE_LOG(INFO, USER1,
325 : : "%zu bytes read from file %s, extending the file %.2f times\n",
326 : : test_data->input_data_sz, test_data->input_file,
327 : : (double)test_data->input_data_sz/actual_file_sz);
328 : : else
329 : 0 : RTE_LOG(INFO, USER1,
330 : : "%zu bytes read from file %s\n",
331 : : test_data->input_data_sz, test_data->input_file);
332 : :
333 : : ret = 0;
334 : :
335 : 0 : end:
336 : 0 : fclose(f);
337 : 0 : return ret;
338 : : }
339 : :
340 : : static int
341 : 0 : comp_perf_dump_dictionary_data(struct comp_test_data *test_data)
342 : : {
343 : 0 : FILE *f = fopen(test_data->dictionary_file, "r");
344 : : int ret = -1;
345 : :
346 : 0 : if (f == NULL) {
347 : 0 : RTE_LOG(ERR, USER1, "Dictionary file not specified\n");
348 : 0 : test_data->dictionary_data_sz = 0;
349 : 0 : test_data->dictionary_data = NULL;
350 : : ret = 0;
351 : 0 : goto end;
352 : : }
353 : :
354 : 0 : if (fseek(f, 0, SEEK_END) != 0) {
355 : 0 : RTE_LOG(ERR, USER1, "Size of input could not be calculated\n");
356 : 0 : goto end;
357 : : }
358 : 0 : size_t actual_file_sz = ftell(f);
359 : : /* If extended input data size has not been set,
360 : : * input data size = file size
361 : : */
362 : :
363 : 0 : if (test_data->dictionary_data_sz == 0)
364 : 0 : test_data->dictionary_data_sz = actual_file_sz;
365 : :
366 : 0 : if (test_data->dictionary_data_sz <= 0 || actual_file_sz <= 0 ||
367 : 0 : fseek(f, 0, SEEK_SET) != 0) {
368 : 0 : RTE_LOG(ERR, USER1, "Size of input could not be calculated\n");
369 : 0 : goto end;
370 : : }
371 : :
372 : 0 : test_data->dictionary_data = rte_zmalloc_socket(NULL,
373 : 0 : test_data->dictionary_data_sz, 0, rte_socket_id());
374 : :
375 : 0 : if (test_data->dictionary_data == NULL) {
376 : 0 : RTE_LOG(ERR, USER1, "Memory to hold the data from the dictionary "
377 : : "file could not be allocated\n");
378 : 0 : goto end;
379 : : }
380 : :
381 : 0 : size_t remaining_data = test_data->dictionary_data_sz;
382 : : uint8_t *data = test_data->dictionary_data;
383 : :
384 : 0 : while (remaining_data > 0) {
385 : 0 : size_t data_to_read = RTE_MIN(remaining_data, actual_file_sz);
386 : :
387 : 0 : if (fread(data, data_to_read, 1, f) != 1) {
388 : 0 : RTE_LOG(ERR, USER1, "Input file could not be read\n");
389 : 0 : goto end;
390 : : }
391 : 0 : if (fseek(f, 0, SEEK_SET) != 0) {
392 : 0 : RTE_LOG(ERR, USER1,
393 : : "Size of input could not be calculated\n");
394 : 0 : goto end;
395 : : }
396 : 0 : remaining_data -= data_to_read;
397 : 0 : data += data_to_read;
398 : : }
399 : :
400 : : printf("\n");
401 : 0 : if (test_data->dictionary_data_sz > actual_file_sz)
402 : 0 : RTE_LOG(INFO, USER1,
403 : : "%zu bytes read from file %s, extending the file %.2f times\n",
404 : : test_data->dictionary_data_sz, test_data->dictionary_file,
405 : : (double)test_data->dictionary_data_sz/actual_file_sz);
406 : : else
407 : 0 : RTE_LOG(INFO, USER1,
408 : : "%zu bytes read from file %s\n",
409 : : test_data->dictionary_data_sz, test_data->dictionary_file);
410 : :
411 : : ret = 0;
412 : :
413 : 0 : end:
414 : 0 : if (f)
415 : 0 : fclose(f);
416 : :
417 : 0 : if (test_data->dictionary_data)
418 : 0 : rte_free(test_data->dictionary_data);
419 : :
420 : 0 : return ret;
421 : : }
422 : :
423 : : static void
424 : 0 : comp_perf_cleanup_on_signal(int signalNumber __rte_unused)
425 : : {
426 : 0 : test_data->perf_comp_force_stop = 1;
427 : 0 : }
428 : :
429 : : static void
430 : 0 : comp_perf_register_cleanup_on_signal(void)
431 : : {
432 : 0 : signal(SIGTERM, comp_perf_cleanup_on_signal);
433 : 0 : signal(SIGINT, comp_perf_cleanup_on_signal);
434 : 0 : }
435 : :
436 : : int
437 : 0 : main(int argc, char **argv)
438 : : {
439 : : uint8_t level_idx = 0;
440 : : int ret, i;
441 : 0 : void *ctx[RTE_MAX_LCORE] = {};
442 : : uint8_t enabled_cdevs[RTE_COMPRESS_MAX_DEVS];
443 : : int nb_compressdevs = 0;
444 : : uint16_t total_nb_qps = 0;
445 : : uint8_t cdev_id;
446 : : uint32_t lcore_id;
447 : :
448 : : /* Initialise DPDK EAL */
449 : 0 : ret = rte_eal_init(argc, argv);
450 : 0 : if (ret < 0)
451 : 0 : rte_exit(EXIT_FAILURE, "Invalid EAL arguments!\n");
452 : 0 : argc -= ret;
453 : 0 : argv += ret;
454 : :
455 : 0 : test_data = rte_zmalloc_socket(NULL, sizeof(struct comp_test_data),
456 : 0 : 0, rte_socket_id());
457 : :
458 : 0 : if (test_data == NULL)
459 : 0 : rte_exit(EXIT_FAILURE, "Cannot reserve memory in socket %d\n",
460 : : rte_socket_id());
461 : :
462 : 0 : comp_perf_register_cleanup_on_signal();
463 : :
464 : : ret = EXIT_SUCCESS;
465 : 0 : test_data->cleanup = ST_TEST_DATA;
466 : 0 : comp_perf_options_default(test_data);
467 : :
468 : 0 : if (comp_perf_options_parse(test_data, argc, argv) < 0) {
469 : 0 : RTE_LOG(ERR, USER1,
470 : : "Parsing one or more user options failed\n");
471 : : ret = EXIT_FAILURE;
472 : 0 : goto end;
473 : : }
474 : :
475 : 0 : if (comp_perf_options_check(test_data) < 0) {
476 : : ret = EXIT_FAILURE;
477 : 0 : goto end;
478 : : }
479 : :
480 : : nb_compressdevs =
481 : 0 : comp_perf_initialize_compressdev(test_data, enabled_cdevs);
482 : :
483 : 0 : if (nb_compressdevs < 1) {
484 : : ret = EXIT_FAILURE;
485 : 0 : goto end;
486 : : }
487 : :
488 : 0 : test_data->cleanup = ST_COMPDEV;
489 : 0 : if (comp_perf_dump_input_data(test_data) < 0) {
490 : : ret = EXIT_FAILURE;
491 : 0 : goto end;
492 : : }
493 : :
494 : 0 : test_data->cleanup = ST_INPUT_DATA;
495 : 0 : if (comp_perf_dump_dictionary_data(test_data) < 0) {
496 : : ret = EXIT_FAILURE;
497 : 0 : goto end;
498 : : }
499 : :
500 : 0 : test_data->cleanup = ST_DICTIONARY_DATA;
501 : :
502 : :
503 : 0 : if (test_data->level_lst.inc != 0)
504 : 0 : test_data->level = test_data->level_lst.min;
505 : : else
506 : 0 : test_data->level = test_data->level_lst.list[0];
507 : :
508 : 0 : printf("\nApp uses socket: %u\n", rte_socket_id());
509 : 0 : printf("Burst size = %u\n", test_data->burst_sz);
510 : 0 : printf("Input data size = %zu\n", test_data->input_data_sz);
511 : 0 : if (test_data->test == CPERF_TEST_TYPE_PMDCC)
512 : 0 : printf("Cycle-count delay = %u [us]\n",
513 : : test_data->cyclecount_delay);
514 : :
515 : 0 : test_data->cleanup = ST_DURING_TEST;
516 : 0 : total_nb_qps = nb_compressdevs * test_data->nb_qps;
517 : :
518 : : i = 0;
519 : : uint8_t qp_id = 0, cdev_index = 0;
520 : :
521 : 0 : RTE_LCORE_FOREACH_WORKER(lcore_id) {
522 : :
523 : 0 : if (i == total_nb_qps)
524 : : break;
525 : :
526 : 0 : cdev_id = enabled_cdevs[cdev_index];
527 : 0 : ctx[i] = cperf_testmap[test_data->test].constructor(
528 : : cdev_id, qp_id,
529 : : test_data);
530 : 0 : if (ctx[i] == NULL) {
531 : 0 : RTE_LOG(ERR, USER1, "Test run constructor failed\n");
532 : 0 : goto end;
533 : : }
534 : 0 : qp_id = (qp_id + 1) % test_data->nb_qps;
535 : 0 : if (qp_id == 0)
536 : 0 : cdev_index++;
537 : 0 : i++;
538 : : }
539 : :
540 : 0 : print_test_dynamics(test_data);
541 : :
542 : 0 : while (test_data->level <= test_data->level_lst.max) {
543 : :
544 : : i = 0;
545 : 0 : RTE_LCORE_FOREACH_WORKER(lcore_id) {
546 : :
547 : 0 : if (i == total_nb_qps)
548 : : break;
549 : :
550 : 0 : rte_eal_remote_launch(
551 : 0 : cperf_testmap[test_data->test].runner,
552 : : ctx[i], lcore_id);
553 : 0 : i++;
554 : : }
555 : : i = 0;
556 : 0 : RTE_LCORE_FOREACH_WORKER(lcore_id) {
557 : :
558 : 0 : if (i == total_nb_qps)
559 : : break;
560 : 0 : ret |= rte_eal_wait_lcore(lcore_id);
561 : 0 : i++;
562 : : }
563 : :
564 : 0 : if (ret != EXIT_SUCCESS)
565 : : break;
566 : :
567 : 0 : if (test_data->level_lst.inc != 0)
568 : 0 : test_data->level += test_data->level_lst.inc;
569 : : else {
570 : 0 : if (++level_idx == test_data->level_lst.count)
571 : : break;
572 : 0 : test_data->level = test_data->level_lst.list[level_idx];
573 : : }
574 : : }
575 : :
576 : 0 : end:
577 : 0 : switch (test_data->cleanup) {
578 : :
579 : 0 : case ST_DURING_TEST:
580 : : i = 0;
581 : 0 : RTE_LCORE_FOREACH_WORKER(lcore_id) {
582 : 0 : if (i == total_nb_qps)
583 : : break;
584 : :
585 : 0 : if (ctx[i] && cperf_testmap[test_data->test].destructor)
586 : 0 : cperf_testmap[test_data->test].destructor(
587 : : ctx[i]);
588 : 0 : i++;
589 : : }
590 : : /* fallthrough */
591 : : case ST_DICTIONARY_DATA:
592 : 0 : rte_free(test_data->dictionary_data);
593 : : /* fallthrough */
594 : 0 : case ST_INPUT_DATA:
595 : 0 : rte_free(test_data->input_data);
596 : : /* fallthrough */
597 : : case ST_COMPDEV:
598 : 0 : for (i = 0; i < nb_compressdevs &&
599 : 0 : i < RTE_COMPRESS_MAX_DEVS; i++) {
600 : 0 : rte_compressdev_stop(enabled_cdevs[i]);
601 : 0 : rte_compressdev_close(enabled_cdevs[i]);
602 : : }
603 : : /* fallthrough */
604 : : case ST_TEST_DATA:
605 : 0 : rte_free(test_data);
606 : : /* fallthrough */
607 : 0 : case ST_CLEAR:
608 : : default:
609 : 0 : i = rte_eal_cleanup();
610 : 0 : if (i) {
611 : 0 : RTE_LOG(ERR, USER1,
612 : : "Error from rte_eal_cleanup(), %d\n", i);
613 : : ret = i;
614 : : }
615 : : break;
616 : : }
617 : : return ret;
618 : : }
|