Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2018 - 2019 Intel Corporation
3 : : */
4 : : #include <string.h>
5 : : #include <zlib.h>
6 : : #include <math.h>
7 : : #include <stdlib.h>
8 : : #include <unistd.h>
9 : : #include <stdio.h>
10 : :
11 : : #include <rte_cycles.h>
12 : : #include <rte_malloc.h>
13 : : #include <rte_mempool.h>
14 : : #include <rte_mbuf.h>
15 : : #include <rte_compressdev.h>
16 : : #include <rte_string_fns.h>
17 : : #include <rte_common.h>
18 : :
19 : : #include "test_compressdev_test_buffer.h"
20 : : #include "test.h"
21 : :
22 : : #define DEFAULT_WINDOW_SIZE 15
23 : : #define DEFAULT_MEM_LEVEL 8
24 : : #define MAX_DEQD_RETRIES 10
25 : : #define DEQUEUE_WAIT_TIME 10000
26 : :
27 : : /*
28 : : * 30% extra size for compressed data compared to original data,
29 : : * in case data size cannot be reduced and it is actually bigger
30 : : * due to the compress block headers
31 : : */
32 : : #define COMPRESS_BUF_SIZE_RATIO 1.3
33 : : #define COMPRESS_BUF_SIZE_RATIO_DISABLED 1.0
34 : : #define COMPRESS_BUF_SIZE_RATIO_OVERFLOW 0.2
35 : : #define NUM_LARGE_MBUFS 16
36 : : #define SMALL_SEG_SIZE 256
37 : : #define MAX_SEGS 16
38 : : #define NUM_OPS 16
39 : : #define NUM_MAX_XFORMS 16
40 : : #define NUM_MAX_INFLIGHT_OPS 128
41 : : #define CACHE_SIZE 0
42 : :
43 : : #define ZLIB_CRC_CHECKSUM_WINDOW_BITS 31
44 : : #define ZLIB_HEADER_SIZE 2
45 : : #define ZLIB_TRAILER_SIZE 4
46 : : #define GZIP_HEADER_SIZE 10
47 : : #define GZIP_TRAILER_SIZE 8
48 : :
49 : : #define OUT_OF_SPACE_BUF 1
50 : :
51 : : #define MAX_MBUF_SEGMENT_SIZE 65535
52 : : #define MAX_DATA_MBUF_SIZE (MAX_MBUF_SEGMENT_SIZE - RTE_PKTMBUF_HEADROOM)
53 : : #define NUM_BIG_MBUFS (512 + 1)
54 : : #define BIG_DATA_TEST_SIZE (MAX_DATA_MBUF_SIZE * 2)
55 : :
56 : : /* constants for "im buffer" tests start here */
57 : :
58 : : /* number of mbufs lower than number of inflight ops */
59 : : #define IM_BUF_NUM_MBUFS 3
60 : : /* above threshold (QAT_FALLBACK_THLD) and below max mbuf size */
61 : : #define IM_BUF_DATA_TEST_SIZE_LB 59600
62 : : /* data size smaller than the queue capacity */
63 : : #define IM_BUF_DATA_TEST_SIZE_SGL (MAX_DATA_MBUF_SIZE * IM_BUF_NUM_MBUFS)
64 : : /* number of mbufs bigger than number of inflight ops */
65 : : #define IM_BUF_NUM_MBUFS_OVER (NUM_MAX_INFLIGHT_OPS + 1)
66 : : /* data size bigger than the queue capacity */
67 : : #define IM_BUF_DATA_TEST_SIZE_OVER (MAX_DATA_MBUF_SIZE * IM_BUF_NUM_MBUFS_OVER)
68 : : /* number of mid-size mbufs */
69 : : #define IM_BUF_NUM_MBUFS_MID ((NUM_MAX_INFLIGHT_OPS / 3) + 1)
70 : : /* capacity of mid-size mbufs */
71 : : #define IM_BUF_DATA_TEST_SIZE_MID (MAX_DATA_MBUF_SIZE * IM_BUF_NUM_MBUFS_MID)
72 : :
73 : :
74 : : const char *
75 : : huffman_type_strings[] = {
76 : : [RTE_COMP_HUFFMAN_DEFAULT] = "PMD default",
77 : : [RTE_COMP_HUFFMAN_FIXED] = "Fixed",
78 : : [RTE_COMP_HUFFMAN_DYNAMIC] = "Dynamic"
79 : : };
80 : :
81 : : enum zlib_direction {
82 : : ZLIB_NONE,
83 : : ZLIB_COMPRESS,
84 : : ZLIB_DECOMPRESS,
85 : : ZLIB_ALL
86 : : };
87 : :
88 : : enum varied_buff {
89 : : LB_BOTH = 0, /* both input and output are linear*/
90 : : SGL_BOTH, /* both input and output are chained */
91 : : SGL_TO_LB, /* input buffer is chained */
92 : : LB_TO_SGL /* output buffer is chained */
93 : : };
94 : :
95 : : enum overflow_test {
96 : : OVERFLOW_DISABLED,
97 : : OVERFLOW_ENABLED
98 : : };
99 : :
100 : : enum ratio_switch {
101 : : RATIO_DISABLED,
102 : : RATIO_ENABLED
103 : : };
104 : :
105 : : enum operation_type {
106 : : OPERATION_COMPRESSION,
107 : : OPERATION_DECOMPRESSION
108 : : };
109 : :
110 : : struct priv_op_data {
111 : : uint16_t orig_idx;
112 : : };
113 : :
114 : : struct comp_testsuite_params {
115 : : struct rte_mempool *large_mbuf_pool;
116 : : struct rte_mempool *small_mbuf_pool;
117 : : struct rte_mempool *big_mbuf_pool;
118 : : struct rte_mempool *op_pool;
119 : : struct rte_comp_xform *def_comp_xform;
120 : : struct rte_comp_xform *def_decomp_xform;
121 : : };
122 : :
123 : : struct interim_data_params {
124 : : const char * const *test_bufs;
125 : : unsigned int num_bufs;
126 : : uint16_t *buf_idx;
127 : : struct rte_comp_xform **compress_xforms;
128 : : struct rte_comp_xform **decompress_xforms;
129 : : unsigned int num_xforms;
130 : : };
131 : :
132 : : struct test_data_params {
133 : : enum rte_comp_op_type compress_state;
134 : : enum rte_comp_op_type decompress_state;
135 : : enum varied_buff buff_type;
136 : : enum zlib_direction zlib_dir;
137 : : unsigned int out_of_space;
138 : : unsigned int big_data;
139 : : /* stateful decompression specific parameters */
140 : : unsigned int decompress_output_block_size;
141 : : unsigned int decompress_steps_max;
142 : : /* external mbufs specific parameters */
143 : : unsigned int use_external_mbufs;
144 : : unsigned int inbuf_data_size;
145 : : const struct rte_memzone *inbuf_memzone;
146 : : const struct rte_memzone *compbuf_memzone;
147 : : const struct rte_memzone *uncompbuf_memzone;
148 : : /* overflow test activation */
149 : : enum overflow_test overflow;
150 : : enum ratio_switch ratio;
151 : : };
152 : :
153 : : struct test_private_arrays {
154 : : struct rte_mbuf **uncomp_bufs;
155 : : struct rte_mbuf **comp_bufs;
156 : : struct rte_comp_op **ops;
157 : : struct rte_comp_op **ops_processed;
158 : : void **priv_xforms;
159 : : uint64_t *compress_checksum;
160 : : uint32_t *compressed_data_size;
161 : : void **stream;
162 : : char **all_decomp_data;
163 : : unsigned int *decomp_produced_data_size;
164 : : uint16_t num_priv_xforms;
165 : : };
166 : :
167 : : static struct comp_testsuite_params testsuite_params = { 0 };
168 : :
169 : :
170 : : static void
171 : 0 : testsuite_teardown(void)
172 : : {
173 : : struct comp_testsuite_params *ts_params = &testsuite_params;
174 : :
175 [ # # ]: 0 : if (rte_mempool_in_use_count(ts_params->large_mbuf_pool))
176 : 0 : RTE_LOG(ERR, USER1, "Large mbuf pool still has unfreed bufs\n");
177 [ # # ]: 0 : if (rte_mempool_in_use_count(ts_params->small_mbuf_pool))
178 : 0 : RTE_LOG(ERR, USER1, "Small mbuf pool still has unfreed bufs\n");
179 [ # # ]: 0 : if (rte_mempool_in_use_count(ts_params->big_mbuf_pool))
180 : 0 : RTE_LOG(ERR, USER1, "Big mbuf pool still has unfreed bufs\n");
181 [ # # ]: 0 : if (rte_mempool_in_use_count(ts_params->op_pool))
182 : 0 : RTE_LOG(ERR, USER1, "op pool still has unfreed ops\n");
183 : :
184 : 0 : rte_mempool_free(ts_params->large_mbuf_pool);
185 : 0 : rte_mempool_free(ts_params->small_mbuf_pool);
186 : 0 : rte_mempool_free(ts_params->big_mbuf_pool);
187 : 0 : rte_mempool_free(ts_params->op_pool);
188 : 0 : rte_free(ts_params->def_comp_xform);
189 : 0 : rte_free(ts_params->def_decomp_xform);
190 : 0 : }
191 : :
192 : : static int
193 : 1 : testsuite_setup(void)
194 : : {
195 : : struct comp_testsuite_params *ts_params = &testsuite_params;
196 : : uint32_t max_buf_size = 0;
197 : : unsigned int i;
198 : :
199 [ + - ]: 1 : if (rte_compressdev_count() == 0) {
200 : 1 : RTE_LOG(WARNING, USER1, "Need at least one compress device\n");
201 : 1 : return TEST_SKIPPED;
202 : : }
203 : :
204 : 0 : RTE_LOG(NOTICE, USER1, "Running tests on device %s\n",
205 : : rte_compressdev_name_get(0));
206 : :
207 [ # # ]: 0 : for (i = 0; i < RTE_DIM(compress_test_bufs); i++)
208 : 0 : max_buf_size = RTE_MAX(max_buf_size,
209 : : strlen(compress_test_bufs[i]) + 1);
210 : :
211 : : /*
212 : : * Buffers to be used in compression and decompression.
213 : : * Since decompressed data might be larger than
214 : : * compressed data (due to block header),
215 : : * buffers should be big enough for both cases.
216 : : */
217 : 0 : max_buf_size *= COMPRESS_BUF_SIZE_RATIO;
218 : 0 : ts_params->large_mbuf_pool = rte_pktmbuf_pool_create("large_mbuf_pool",
219 : : NUM_LARGE_MBUFS,
220 : : CACHE_SIZE, 0,
221 : 0 : max_buf_size + RTE_PKTMBUF_HEADROOM,
222 : 0 : rte_socket_id());
223 [ # # ]: 0 : if (ts_params->large_mbuf_pool == NULL) {
224 : 0 : RTE_LOG(ERR, USER1, "Large mbuf pool could not be created\n");
225 : 0 : return TEST_FAILED;
226 : : }
227 : :
228 : : /* Create mempool with smaller buffers for SGL testing */
229 : 0 : ts_params->small_mbuf_pool = rte_pktmbuf_pool_create("small_mbuf_pool",
230 : : NUM_LARGE_MBUFS * MAX_SEGS,
231 : : CACHE_SIZE, 0,
232 : : SMALL_SEG_SIZE + RTE_PKTMBUF_HEADROOM,
233 : 0 : rte_socket_id());
234 [ # # ]: 0 : if (ts_params->small_mbuf_pool == NULL) {
235 : 0 : RTE_LOG(ERR, USER1, "Small mbuf pool could not be created\n");
236 : 0 : goto exit;
237 : : }
238 : :
239 : : /* Create mempool with big buffers for SGL testing */
240 : 0 : ts_params->big_mbuf_pool = rte_pktmbuf_pool_create("big_mbuf_pool",
241 : : NUM_BIG_MBUFS + 1,
242 : : CACHE_SIZE, 0,
243 : : MAX_MBUF_SEGMENT_SIZE,
244 : 0 : rte_socket_id());
245 [ # # ]: 0 : if (ts_params->big_mbuf_pool == NULL) {
246 : 0 : RTE_LOG(ERR, USER1, "Big mbuf pool could not be created\n");
247 : 0 : goto exit;
248 : : }
249 : :
250 : 0 : ts_params->op_pool = rte_comp_op_pool_create("op_pool", NUM_OPS,
251 : : 0, sizeof(struct priv_op_data),
252 : 0 : rte_socket_id());
253 [ # # ]: 0 : if (ts_params->op_pool == NULL) {
254 : 0 : RTE_LOG(ERR, USER1, "Operation pool could not be created\n");
255 : 0 : goto exit;
256 : : }
257 : :
258 : 0 : ts_params->def_comp_xform =
259 : 0 : rte_malloc(NULL, sizeof(struct rte_comp_xform), 0);
260 [ # # ]: 0 : if (ts_params->def_comp_xform == NULL) {
261 : 0 : RTE_LOG(ERR, USER1,
262 : : "Default compress xform could not be created\n");
263 : 0 : goto exit;
264 : : }
265 : 0 : ts_params->def_decomp_xform =
266 : 0 : rte_malloc(NULL, sizeof(struct rte_comp_xform), 0);
267 [ # # ]: 0 : if (ts_params->def_decomp_xform == NULL) {
268 : 0 : RTE_LOG(ERR, USER1,
269 : : "Default decompress xform could not be created\n");
270 : 0 : goto exit;
271 : : }
272 : :
273 : : /* Initializes default values for compress/decompress xforms */
274 : 0 : ts_params->def_comp_xform->type = RTE_COMP_COMPRESS;
275 : 0 : ts_params->def_comp_xform->compress.algo = RTE_COMP_ALGO_DEFLATE;
276 : 0 : ts_params->def_comp_xform->compress.deflate.huffman =
277 : : RTE_COMP_HUFFMAN_DEFAULT;
278 : 0 : ts_params->def_comp_xform->compress.level = RTE_COMP_LEVEL_PMD_DEFAULT;
279 : 0 : ts_params->def_comp_xform->compress.chksum = RTE_COMP_CHECKSUM_NONE;
280 : 0 : ts_params->def_comp_xform->compress.window_size = DEFAULT_WINDOW_SIZE;
281 : :
282 : 0 : ts_params->def_decomp_xform->type = RTE_COMP_DECOMPRESS;
283 : 0 : ts_params->def_decomp_xform->decompress.algo = RTE_COMP_ALGO_DEFLATE;
284 : 0 : ts_params->def_decomp_xform->decompress.chksum = RTE_COMP_CHECKSUM_NONE;
285 : 0 : ts_params->def_decomp_xform->decompress.window_size = DEFAULT_WINDOW_SIZE;
286 : :
287 : 0 : return TEST_SUCCESS;
288 : :
289 : 0 : exit:
290 : 0 : testsuite_teardown();
291 : :
292 : 0 : return TEST_FAILED;
293 : : }
294 : :
295 : : static int
296 : 0 : generic_ut_setup(void)
297 : : {
298 : : /* Configure compressdev (one device, one queue pair) */
299 : 0 : struct rte_compressdev_config config = {
300 : 0 : .socket_id = rte_socket_id(),
301 : : .nb_queue_pairs = 1,
302 : : .max_nb_priv_xforms = NUM_MAX_XFORMS,
303 : : .max_nb_streams = 1
304 : : };
305 : :
306 [ # # ]: 0 : if (rte_compressdev_configure(0, &config) < 0) {
307 : 0 : RTE_LOG(ERR, USER1, "Device configuration failed\n");
308 : 0 : return -1;
309 : : }
310 : :
311 [ # # ]: 0 : if (rte_compressdev_queue_pair_setup(0, 0, NUM_MAX_INFLIGHT_OPS,
312 : 0 : rte_socket_id()) < 0) {
313 : 0 : RTE_LOG(ERR, USER1, "Queue pair setup failed\n");
314 : 0 : return -1;
315 : : }
316 : :
317 [ # # ]: 0 : if (rte_compressdev_start(0) < 0) {
318 : 0 : RTE_LOG(ERR, USER1, "Device could not be started\n");
319 : 0 : return -1;
320 : : }
321 : :
322 : : return 0;
323 : : }
324 : :
325 : : static void
326 : 0 : generic_ut_teardown(void)
327 : : {
328 : 0 : rte_compressdev_stop(0);
329 [ # # ]: 0 : if (rte_compressdev_close(0) < 0)
330 : 0 : RTE_LOG(ERR, USER1, "Device could not be closed\n");
331 : 0 : }
332 : :
333 : : static int
334 : 0 : test_compressdev_invalid_configuration(void)
335 : : {
336 : : struct rte_compressdev_config invalid_config;
337 : : struct rte_compressdev_config valid_config = {
338 : 0 : .socket_id = rte_socket_id(),
339 : : .nb_queue_pairs = 1,
340 : : .max_nb_priv_xforms = NUM_MAX_XFORMS,
341 : : .max_nb_streams = 1
342 : : };
343 : : struct rte_compressdev_info dev_info;
344 : :
345 : 0 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
346 : :
347 : : /* Invalid configuration with 0 queue pairs */
348 : 0 : invalid_config = valid_config;
349 : 0 : invalid_config.nb_queue_pairs = 0;
350 : :
351 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_compressdev_configure(0, &invalid_config),
352 : : "Device configuration was successful "
353 : : "with no queue pairs (invalid)\n");
354 : :
355 : : /*
356 : : * Invalid configuration with too many queue pairs
357 : : * (if there is an actual maximum number of queue pairs)
358 : : */
359 : 0 : rte_compressdev_info_get(0, &dev_info);
360 [ # # ]: 0 : if (dev_info.max_nb_queue_pairs != 0) {
361 : 0 : invalid_config = valid_config;
362 : 0 : invalid_config.nb_queue_pairs = dev_info.max_nb_queue_pairs + 1;
363 : :
364 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_compressdev_configure(0, &invalid_config),
365 : : "Device configuration was successful "
366 : : "with too many queue pairs (invalid)\n");
367 : : }
368 : :
369 : : /* Invalid queue pair setup, with no number of queue pairs set */
370 [ # # ]: 0 : TEST_ASSERT_FAIL(rte_compressdev_queue_pair_setup(0, 0,
371 : : NUM_MAX_INFLIGHT_OPS, rte_socket_id()),
372 : : "Queue pair setup was successful "
373 : : "with no queue pairs set (invalid)\n");
374 : :
375 : : return TEST_SUCCESS;
376 : : }
377 : :
378 : : static int
379 : 0 : compare_buffers(const char *buffer1, uint32_t buffer1_len,
380 : : const char *buffer2, uint32_t buffer2_len)
381 : : {
382 [ # # ]: 0 : if (buffer1_len != buffer2_len) {
383 : 0 : RTE_LOG(ERR, USER1, "Buffer lengths are different\n");
384 : 0 : return -1;
385 : : }
386 : :
387 [ # # ]: 0 : if (memcmp(buffer1, buffer2, buffer1_len) != 0) {
388 : 0 : RTE_LOG(ERR, USER1, "Buffers are different\n");
389 : 0 : return -1;
390 : : }
391 : :
392 : : return 0;
393 : : }
394 : :
395 : : /*
396 : : * Maps compressdev and Zlib flush flags
397 : : */
398 : : static int
399 : : map_zlib_flush_flag(enum rte_comp_flush_flag flag)
400 : : {
401 : : switch (flag) {
402 : : case RTE_COMP_FLUSH_NONE:
403 : : return Z_NO_FLUSH;
404 : : case RTE_COMP_FLUSH_SYNC:
405 : : return Z_SYNC_FLUSH;
406 : : case RTE_COMP_FLUSH_FULL:
407 : : return Z_FULL_FLUSH;
408 : : case RTE_COMP_FLUSH_FINAL:
409 : : return Z_FINISH;
410 : : /*
411 : : * There should be only the values above,
412 : : * so this should never happen
413 : : */
414 : : default:
415 : : return -1;
416 : : }
417 : : }
418 : :
419 : : static int
420 : 0 : compress_zlib(struct rte_comp_op *op,
421 : : const struct rte_comp_xform *xform, int mem_level)
422 : : {
423 : : z_stream stream;
424 : : int zlib_flush;
425 : : int strategy, window_bits, comp_level;
426 : : int ret = TEST_FAILED;
427 : : uint8_t *single_src_buf = NULL;
428 : : uint8_t *single_dst_buf = NULL;
429 : :
430 : : /* initialize zlib stream */
431 : 0 : stream.zalloc = Z_NULL;
432 : 0 : stream.zfree = Z_NULL;
433 : 0 : stream.opaque = Z_NULL;
434 : :
435 [ # # ]: 0 : if (xform->compress.deflate.huffman == RTE_COMP_HUFFMAN_FIXED)
436 : : strategy = Z_FIXED;
437 : : else
438 : : strategy = Z_DEFAULT_STRATEGY;
439 : :
440 : : /*
441 : : * Window bits is the base two logarithm of the window size (in bytes).
442 : : * When doing raw DEFLATE, this number will be negative.
443 : : */
444 : 0 : window_bits = -(xform->compress.window_size);
445 [ # # ]: 0 : if (xform->compress.chksum == RTE_COMP_CHECKSUM_ADLER32)
446 : : window_bits *= -1;
447 [ # # ]: 0 : else if (xform->compress.chksum == RTE_COMP_CHECKSUM_CRC32)
448 : : window_bits = ZLIB_CRC_CHECKSUM_WINDOW_BITS;
449 : :
450 : 0 : comp_level = xform->compress.level;
451 : :
452 [ # # ]: 0 : if (comp_level != RTE_COMP_LEVEL_NONE)
453 : 0 : ret = deflateInit2(&stream, comp_level, Z_DEFLATED,
454 : : window_bits, mem_level, strategy);
455 : : else
456 : 0 : ret = deflateInit(&stream, Z_NO_COMPRESSION);
457 : :
458 [ # # ]: 0 : if (ret != Z_OK) {
459 : : printf("Zlib deflate could not be initialized\n");
460 : 0 : goto exit;
461 : : }
462 : :
463 : : /* Assuming stateless operation */
464 : : /* SGL Input */
465 [ # # ]: 0 : if (op->m_src->nb_segs > 1) {
466 : 0 : single_src_buf = rte_malloc(NULL,
467 : 0 : rte_pktmbuf_pkt_len(op->m_src), 0);
468 [ # # ]: 0 : if (single_src_buf == NULL) {
469 : 0 : RTE_LOG(ERR, USER1, "Buffer could not be allocated\n");
470 : 0 : goto exit;
471 : : }
472 : :
473 [ # # ]: 0 : if (rte_pktmbuf_read(op->m_src, op->src.offset,
474 : 0 : rte_pktmbuf_pkt_len(op->m_src) -
475 [ # # ]: 0 : op->src.offset,
476 : : single_src_buf) == NULL) {
477 : 0 : RTE_LOG(ERR, USER1,
478 : : "Buffer could not be read entirely\n");
479 : 0 : goto exit;
480 : : }
481 : :
482 : 0 : stream.avail_in = op->src.length;
483 : 0 : stream.next_in = single_src_buf;
484 : :
485 : : } else {
486 : 0 : stream.avail_in = op->src.length;
487 : 0 : stream.next_in = rte_pktmbuf_mtod_offset(op->m_src, uint8_t *,
488 : : op->src.offset);
489 : : }
490 : : /* SGL output */
491 [ # # ]: 0 : if (op->m_dst->nb_segs > 1) {
492 : :
493 : 0 : single_dst_buf = rte_malloc(NULL,
494 : 0 : rte_pktmbuf_pkt_len(op->m_dst), 0);
495 [ # # ]: 0 : if (single_dst_buf == NULL) {
496 : 0 : RTE_LOG(ERR, USER1,
497 : : "Buffer could not be allocated\n");
498 : 0 : goto exit;
499 : : }
500 : :
501 : 0 : stream.avail_out = op->m_dst->pkt_len;
502 : 0 : stream.next_out = single_dst_buf;
503 : :
504 : : } else {/* linear output */
505 : 0 : stream.avail_out = op->m_dst->data_len;
506 : 0 : stream.next_out = rte_pktmbuf_mtod_offset(op->m_dst, uint8_t *,
507 : : op->dst.offset);
508 : : }
509 : :
510 : : /* Stateless operation, all buffer will be compressed in one go */
511 [ # # ]: 0 : zlib_flush = map_zlib_flush_flag(op->flush_flag);
512 : 0 : ret = deflate(&stream, zlib_flush);
513 : :
514 [ # # ]: 0 : if (stream.avail_in != 0) {
515 : 0 : RTE_LOG(ERR, USER1, "Buffer could not be read entirely\n");
516 : 0 : goto exit;
517 : : }
518 : :
519 [ # # ]: 0 : if (ret != Z_STREAM_END)
520 : 0 : goto exit;
521 : :
522 : : /* Copy data to destination SGL */
523 [ # # ]: 0 : if (op->m_dst->nb_segs > 1) {
524 : 0 : uint32_t remaining_data = stream.total_out;
525 : : uint8_t *src_data = single_dst_buf;
526 : : struct rte_mbuf *dst_buf = op->m_dst;
527 : :
528 [ # # ]: 0 : while (remaining_data > 0) {
529 : 0 : uint8_t *dst_data = rte_pktmbuf_mtod_offset(dst_buf,
530 : : uint8_t *, op->dst.offset);
531 : : /* Last segment */
532 [ # # ]: 0 : if (remaining_data < dst_buf->data_len) {
533 : 0 : memcpy(dst_data, src_data, remaining_data);
534 : : remaining_data = 0;
535 : : } else {
536 : 0 : memcpy(dst_data, src_data, dst_buf->data_len);
537 : 0 : remaining_data -= dst_buf->data_len;
538 : 0 : src_data += dst_buf->data_len;
539 : 0 : dst_buf = dst_buf->next;
540 : : }
541 : : }
542 : : }
543 : :
544 : 0 : op->consumed = stream.total_in;
545 [ # # ]: 0 : if (xform->compress.chksum == RTE_COMP_CHECKSUM_ADLER32) {
546 [ # # ]: 0 : rte_pktmbuf_adj(op->m_dst, ZLIB_HEADER_SIZE);
547 : 0 : rte_pktmbuf_trim(op->m_dst, ZLIB_TRAILER_SIZE);
548 : 0 : op->produced = stream.total_out - (ZLIB_HEADER_SIZE +
549 : : ZLIB_TRAILER_SIZE);
550 [ # # ]: 0 : } else if (xform->compress.chksum == RTE_COMP_CHECKSUM_CRC32) {
551 [ # # ]: 0 : rte_pktmbuf_adj(op->m_dst, GZIP_HEADER_SIZE);
552 : 0 : rte_pktmbuf_trim(op->m_dst, GZIP_TRAILER_SIZE);
553 : 0 : op->produced = stream.total_out - (GZIP_HEADER_SIZE +
554 : : GZIP_TRAILER_SIZE);
555 : : } else
556 : 0 : op->produced = stream.total_out;
557 : :
558 : 0 : op->status = RTE_COMP_OP_STATUS_SUCCESS;
559 : 0 : op->output_chksum = stream.adler;
560 : :
561 : 0 : deflateReset(&stream);
562 : :
563 : : ret = 0;
564 : 0 : exit:
565 : 0 : deflateEnd(&stream);
566 : 0 : rte_free(single_src_buf);
567 : 0 : rte_free(single_dst_buf);
568 : :
569 : 0 : return ret;
570 : : }
571 : :
572 : : static int
573 : 0 : decompress_zlib(struct rte_comp_op *op,
574 : : const struct rte_comp_xform *xform)
575 : : {
576 : : z_stream stream;
577 : : int window_bits;
578 : : int zlib_flush;
579 : : int ret = TEST_FAILED;
580 : : uint8_t *single_src_buf = NULL;
581 : : uint8_t *single_dst_buf = NULL;
582 : :
583 : : /* initialize zlib stream */
584 : 0 : stream.zalloc = Z_NULL;
585 : 0 : stream.zfree = Z_NULL;
586 : 0 : stream.opaque = Z_NULL;
587 : :
588 : : /*
589 : : * Window bits is the base two logarithm of the window size (in bytes).
590 : : * When doing raw DEFLATE, this number will be negative.
591 : : */
592 : 0 : window_bits = -(xform->decompress.window_size);
593 : 0 : ret = inflateInit2(&stream, window_bits);
594 : :
595 [ # # ]: 0 : if (ret != Z_OK) {
596 : : printf("Zlib deflate could not be initialized\n");
597 : 0 : goto exit;
598 : : }
599 : :
600 : : /* Assuming stateless operation */
601 : : /* SGL */
602 [ # # ]: 0 : if (op->m_src->nb_segs > 1) {
603 : 0 : single_src_buf = rte_malloc(NULL,
604 : 0 : rte_pktmbuf_pkt_len(op->m_src), 0);
605 [ # # ]: 0 : if (single_src_buf == NULL) {
606 : 0 : RTE_LOG(ERR, USER1, "Buffer could not be allocated\n");
607 : 0 : goto exit;
608 : : }
609 : 0 : single_dst_buf = rte_malloc(NULL,
610 : 0 : rte_pktmbuf_pkt_len(op->m_dst), 0);
611 [ # # ]: 0 : if (single_dst_buf == NULL) {
612 : 0 : RTE_LOG(ERR, USER1, "Buffer could not be allocated\n");
613 : 0 : goto exit;
614 : : }
615 [ # # ]: 0 : if (rte_pktmbuf_read(op->m_src, 0,
616 [ # # ]: 0 : rte_pktmbuf_pkt_len(op->m_src),
617 : : single_src_buf) == NULL) {
618 : 0 : RTE_LOG(ERR, USER1,
619 : : "Buffer could not be read entirely\n");
620 : 0 : goto exit;
621 : : }
622 : :
623 : 0 : stream.avail_in = op->src.length;
624 : 0 : stream.next_in = single_src_buf;
625 : 0 : stream.avail_out = rte_pktmbuf_pkt_len(op->m_dst);
626 : 0 : stream.next_out = single_dst_buf;
627 : :
628 : : } else {
629 : 0 : stream.avail_in = op->src.length;
630 : 0 : stream.next_in = rte_pktmbuf_mtod(op->m_src, uint8_t *);
631 : 0 : stream.avail_out = op->m_dst->data_len;
632 : 0 : stream.next_out = rte_pktmbuf_mtod(op->m_dst, uint8_t *);
633 : : }
634 : :
635 : : /* Stateless operation, all buffer will be compressed in one go */
636 [ # # ]: 0 : zlib_flush = map_zlib_flush_flag(op->flush_flag);
637 : 0 : ret = inflate(&stream, zlib_flush);
638 : :
639 [ # # ]: 0 : if (stream.avail_in != 0) {
640 : 0 : RTE_LOG(ERR, USER1, "Buffer could not be read entirely\n");
641 : 0 : goto exit;
642 : : }
643 : :
644 [ # # ]: 0 : if (ret != Z_STREAM_END)
645 : 0 : goto exit;
646 : :
647 [ # # ]: 0 : if (op->m_src->nb_segs > 1) {
648 : 0 : uint32_t remaining_data = stream.total_out;
649 : : uint8_t *src_data = single_dst_buf;
650 : 0 : struct rte_mbuf *dst_buf = op->m_dst;
651 : :
652 [ # # ]: 0 : while (remaining_data > 0) {
653 : 0 : uint8_t *dst_data = rte_pktmbuf_mtod(dst_buf,
654 : : uint8_t *);
655 : : /* Last segment */
656 [ # # ]: 0 : if (remaining_data < dst_buf->data_len) {
657 : 0 : memcpy(dst_data, src_data, remaining_data);
658 : : remaining_data = 0;
659 : : } else {
660 : 0 : memcpy(dst_data, src_data, dst_buf->data_len);
661 : 0 : remaining_data -= dst_buf->data_len;
662 : 0 : src_data += dst_buf->data_len;
663 : 0 : dst_buf = dst_buf->next;
664 : : }
665 : : }
666 : : }
667 : :
668 : 0 : op->consumed = stream.total_in;
669 : 0 : op->produced = stream.total_out;
670 : 0 : op->status = RTE_COMP_OP_STATUS_SUCCESS;
671 : :
672 : 0 : inflateReset(&stream);
673 : :
674 : : ret = 0;
675 : 0 : exit:
676 : 0 : inflateEnd(&stream);
677 : :
678 : 0 : return ret;
679 : : }
680 : :
681 : : static int
682 : 0 : prepare_sgl_bufs(const char *test_buf, struct rte_mbuf *head_buf,
683 : : uint32_t total_data_size,
684 : : struct rte_mempool *small_mbuf_pool,
685 : : struct rte_mempool *large_mbuf_pool,
686 : : uint8_t limit_segs_in_sgl,
687 : : uint16_t seg_size)
688 : : {
689 : : uint32_t remaining_data = total_data_size;
690 : 0 : uint16_t num_remaining_segs = RTE_DIV_ROUND_UP(remaining_data, seg_size);
691 : : struct rte_mempool *pool;
692 : : struct rte_mbuf *next_seg;
693 : : uint32_t data_size;
694 : : char *buf_ptr;
695 : : const char *data_ptr = test_buf;
696 : : uint16_t i;
697 : : int ret;
698 : :
699 [ # # # # ]: 0 : if (limit_segs_in_sgl != 0 && num_remaining_segs > limit_segs_in_sgl)
700 : 0 : num_remaining_segs = limit_segs_in_sgl - 1;
701 : :
702 : : /*
703 : : * Allocate data in the first segment (header) and
704 : : * copy data if test buffer is provided
705 : : */
706 : : if (remaining_data < seg_size)
707 : : data_size = remaining_data;
708 : : else
709 : : data_size = seg_size;
710 : :
711 : 0 : buf_ptr = rte_pktmbuf_append(head_buf, data_size);
712 [ # # ]: 0 : if (buf_ptr == NULL) {
713 : 0 : RTE_LOG(ERR, USER1,
714 : : "Not enough space in the 1st buffer\n");
715 : 0 : return -1;
716 : : }
717 : :
718 [ # # ]: 0 : if (data_ptr != NULL) {
719 : : /* Copy characters without NULL terminator */
720 : 0 : memcpy(buf_ptr, data_ptr, data_size);
721 : 0 : data_ptr += data_size;
722 : : }
723 : 0 : remaining_data -= data_size;
724 : 0 : num_remaining_segs--;
725 : :
726 : : /*
727 : : * Allocate the rest of the segments,
728 : : * copy the rest of the data and chain the segments.
729 : : */
730 [ # # ]: 0 : for (i = 0; i < num_remaining_segs; i++) {
731 : :
732 [ # # ]: 0 : if (i == (num_remaining_segs - 1)) {
733 : : /* last segment */
734 [ # # ]: 0 : if (remaining_data > seg_size)
735 : : pool = large_mbuf_pool;
736 : : else
737 : : pool = small_mbuf_pool;
738 : : data_size = remaining_data;
739 : : } else {
740 : : data_size = seg_size;
741 : : pool = small_mbuf_pool;
742 : : }
743 : :
744 : 0 : next_seg = rte_pktmbuf_alloc(pool);
745 [ # # ]: 0 : if (next_seg == NULL) {
746 : 0 : RTE_LOG(ERR, USER1,
747 : : "New segment could not be allocated "
748 : : "from the mempool\n");
749 : 0 : return -1;
750 : : }
751 : 0 : buf_ptr = rte_pktmbuf_append(next_seg, data_size);
752 [ # # ]: 0 : if (buf_ptr == NULL) {
753 : 0 : RTE_LOG(ERR, USER1,
754 : : "Not enough space in the buffer\n");
755 : 0 : rte_pktmbuf_free(next_seg);
756 : 0 : return -1;
757 : : }
758 [ # # ]: 0 : if (data_ptr != NULL) {
759 : : /* Copy characters without NULL terminator */
760 : 0 : memcpy(buf_ptr, data_ptr, data_size);
761 : 0 : data_ptr += data_size;
762 : : }
763 [ # # ]: 0 : remaining_data -= data_size;
764 : :
765 : : ret = rte_pktmbuf_chain(head_buf, next_seg);
766 : : if (ret != 0) {
767 : 0 : rte_pktmbuf_free(next_seg);
768 : 0 : RTE_LOG(ERR, USER1,
769 : : "Segment could not chained\n");
770 : 0 : return -1;
771 : : }
772 : : }
773 : :
774 : : return 0;
775 : : }
776 : :
777 : : static void
778 : 0 : extbuf_free_callback(void *addr __rte_unused, void *opaque __rte_unused)
779 : : {
780 : 0 : }
781 : :
782 : : static int
783 : 0 : test_run_enqueue_dequeue(struct rte_comp_op **ops,
784 : : struct rte_comp_op **ops_processed,
785 : : unsigned int num_bufs)
786 : : {
787 : : uint16_t num_enqd, num_deqd, num_total_deqd;
788 : : unsigned int deqd_retries = 0;
789 : : int res = 0;
790 : :
791 : : /* Enqueue and dequeue all operations */
792 : 0 : num_enqd = rte_compressdev_enqueue_burst(0, 0, ops, num_bufs);
793 [ # # ]: 0 : if (num_enqd < num_bufs) {
794 : 0 : RTE_LOG(ERR, USER1,
795 : : "Some operations could not be enqueued\n");
796 : : res = -1;
797 : : }
798 : :
799 : : /* dequeue ops even on error (same number of ops as was enqueued) */
800 : :
801 : : num_total_deqd = 0;
802 [ # # ]: 0 : while (num_total_deqd < num_enqd) {
803 : : /*
804 : : * If retrying a dequeue call, wait for 10 ms to allow
805 : : * enough time to the driver to process the operations
806 : : */
807 [ # # ]: 0 : if (deqd_retries != 0) {
808 : : /*
809 : : * Avoid infinite loop if not all the
810 : : * operations get out of the device
811 : : */
812 [ # # ]: 0 : if (deqd_retries == MAX_DEQD_RETRIES) {
813 : 0 : RTE_LOG(ERR, USER1,
814 : : "Not all operations could be dequeued\n");
815 : : res = -1;
816 : 0 : break;
817 : : }
818 : 0 : usleep(DEQUEUE_WAIT_TIME);
819 : : }
820 : 0 : num_deqd = rte_compressdev_dequeue_burst(0, 0,
821 : 0 : &ops_processed[num_total_deqd], num_bufs);
822 : 0 : num_total_deqd += num_deqd;
823 : 0 : deqd_retries++;
824 : :
825 : : }
826 : :
827 : 0 : return res;
828 : : }
829 : :
830 : : /**
831 : : * Arrays initialization. Input buffers preparation for compression.
832 : : *
833 : : * API that initializes all the private arrays to NULL
834 : : * and allocates input buffers to perform compression operations.
835 : : *
836 : : * @param int_data
837 : : * Interim data containing session/transformation objects.
838 : : * @param test_data
839 : : * The test parameters set by users (command line parameters).
840 : : * @param test_priv_data
841 : : * A container used for aggregation all the private test arrays.
842 : : * @return
843 : : * - 0: On success.
844 : : * - -1: On error.
845 : : */
846 : : static int
847 : 0 : test_setup_com_bufs(const struct interim_data_params *int_data,
848 : : const struct test_data_params *test_data,
849 : : const struct test_private_arrays *test_priv_data)
850 : : {
851 : : /* local variables: */
852 : : unsigned int i;
853 : : uint32_t data_size;
854 : : char *buf_ptr;
855 : : int ret;
856 : 0 : char **all_decomp_data = test_priv_data->all_decomp_data;
857 : :
858 : : struct comp_testsuite_params *ts_params = &testsuite_params;
859 : :
860 : : /* from int_data: */
861 : 0 : const char * const *test_bufs = int_data->test_bufs;
862 : 0 : unsigned int num_bufs = int_data->num_bufs;
863 : :
864 : : /* from test_data: */
865 : 0 : unsigned int buff_type = test_data->buff_type;
866 : 0 : unsigned int big_data = test_data->big_data;
867 : :
868 : : /* from test_priv_data: */
869 : 0 : struct rte_mbuf **uncomp_bufs = test_priv_data->uncomp_bufs;
870 : : struct rte_mempool *buf_pool;
871 : :
872 : : static struct rte_mbuf_ext_shared_info inbuf_info;
873 : :
874 [ # # ]: 0 : size_t array_size = sizeof(void *) * num_bufs;
875 : :
876 : : /* Initialize all arrays to NULL */
877 : : memset(test_priv_data->uncomp_bufs, 0, array_size);
878 : 0 : memset(test_priv_data->comp_bufs, 0, array_size);
879 : 0 : memset(test_priv_data->ops, 0, array_size);
880 : 0 : memset(test_priv_data->ops_processed, 0, array_size);
881 : 0 : memset(test_priv_data->priv_xforms, 0, array_size);
882 : 0 : memset(test_priv_data->compressed_data_size,
883 : : 0, sizeof(uint32_t) * num_bufs);
884 : :
885 [ # # ]: 0 : if (test_data->decompress_state == RTE_COMP_OP_STATEFUL) {
886 : 0 : data_size = strlen(test_bufs[0]) + 1;
887 : 0 : *all_decomp_data = rte_malloc(NULL, data_size,
888 : : RTE_CACHE_LINE_SIZE);
889 : : }
890 : :
891 [ # # ]: 0 : if (big_data)
892 : 0 : buf_pool = ts_params->big_mbuf_pool;
893 [ # # ]: 0 : else if (buff_type == SGL_BOTH)
894 : 0 : buf_pool = ts_params->small_mbuf_pool;
895 : : else
896 : 0 : buf_pool = ts_params->large_mbuf_pool;
897 : :
898 : : /* for compression uncomp_bufs is used as a source buffer */
899 : : /* allocation from buf_pool (mempool type) */
900 : 0 : ret = rte_pktmbuf_alloc_bulk(buf_pool,
901 : : uncomp_bufs, num_bufs);
902 [ # # ]: 0 : if (ret < 0) {
903 : 0 : RTE_LOG(ERR, USER1,
904 : : "Source mbufs could not be allocated "
905 : : "from the mempool\n");
906 : 0 : return -1;
907 : : }
908 : :
909 [ # # ]: 0 : if (test_data->use_external_mbufs) {
910 : 0 : inbuf_info.free_cb = extbuf_free_callback;
911 : 0 : inbuf_info.fcb_opaque = NULL;
912 : : rte_mbuf_ext_refcnt_set(&inbuf_info, 1);
913 [ # # ]: 0 : for (i = 0; i < num_bufs; i++) {
914 : 0 : rte_pktmbuf_attach_extbuf(uncomp_bufs[i],
915 : 0 : test_data->inbuf_memzone->addr,
916 : 0 : test_data->inbuf_memzone->iova,
917 : 0 : test_data->inbuf_data_size,
918 : : &inbuf_info);
919 : 0 : buf_ptr = rte_pktmbuf_append(uncomp_bufs[i],
920 : 0 : test_data->inbuf_data_size);
921 [ # # ]: 0 : if (buf_ptr == NULL) {
922 : 0 : RTE_LOG(ERR, USER1,
923 : : "Append extra bytes to the source mbuf failed\n");
924 : 0 : return -1;
925 : : }
926 : : }
927 [ # # ]: 0 : } else if (buff_type == SGL_BOTH || buff_type == SGL_TO_LB) {
928 [ # # ]: 0 : for (i = 0; i < num_bufs; i++) {
929 : 0 : data_size = strlen(test_bufs[i]) + 1;
930 [ # # # # : 0 : if (prepare_sgl_bufs(test_bufs[i], uncomp_bufs[i],
# # # # #
# ]
931 : : data_size,
932 : : big_data ? buf_pool : ts_params->small_mbuf_pool,
933 : : big_data ? buf_pool : ts_params->large_mbuf_pool,
934 : : big_data ? 0 : MAX_SEGS,
935 : : big_data ? MAX_DATA_MBUF_SIZE : SMALL_SEG_SIZE) < 0)
936 : : return -1;
937 : : }
938 : : } else {
939 [ # # ]: 0 : for (i = 0; i < num_bufs; i++) {
940 : 0 : data_size = strlen(test_bufs[i]) + 1;
941 : :
942 : 0 : buf_ptr = rte_pktmbuf_append(uncomp_bufs[i], data_size);
943 [ # # ]: 0 : if (buf_ptr == NULL) {
944 : 0 : RTE_LOG(ERR, USER1,
945 : : "Append extra bytes to the source mbuf failed\n");
946 : 0 : return -1;
947 : : }
948 : 0 : strlcpy(buf_ptr, test_bufs[i], data_size);
949 : : }
950 : : }
951 : :
952 : : return 0;
953 : : }
954 : :
955 : : /**
956 : : * Data size calculation (for both compression and decompression).
957 : : *
958 : : * Calculate size of anticipated output buffer required for both
959 : : * compression and decompression operations based on input int_data.
960 : : *
961 : : * @param op_type
962 : : * Operation type: compress or decompress
963 : : * @param out_of_space_and_zlib
964 : : * Boolean value to switch into "out of space" buffer if set.
965 : : * To test "out-of-space" data size, zlib_decompress must be set as well.
966 : : * @param test_priv_data
967 : : * A container used for aggregation all the private test arrays.
968 : : * @param int_data
969 : : * Interim data containing session/transformation objects.
970 : : * @param test_data
971 : : * The test parameters set by users (command line parameters).
972 : : * @param i
973 : : * current buffer index
974 : : * @return
975 : : * data size
976 : : */
977 : : static inline uint32_t
978 : 0 : test_mbufs_calculate_data_size(
979 : : enum operation_type op_type,
980 : : unsigned int out_of_space_and_zlib,
981 : : const struct test_private_arrays *test_priv_data,
982 : : const struct interim_data_params *int_data,
983 : : const struct test_data_params *test_data,
984 : : unsigned int i)
985 : : {
986 : : /* local variables: */
987 : : uint32_t data_size;
988 : : struct priv_op_data *priv_data;
989 : : float ratio_val;
990 : 0 : enum ratio_switch ratio = test_data->ratio;
991 : :
992 : : uint8_t not_zlib_compr; /* true if zlib isn't current compression dev */
993 : 0 : enum overflow_test overflow = test_data->overflow;
994 : :
995 : : /* from test_priv_data: */
996 : 0 : struct rte_comp_op **ops_processed = test_priv_data->ops_processed;
997 : :
998 : : /* from int_data: */
999 : 0 : const char * const *test_bufs = int_data->test_bufs;
1000 : :
1001 [ # # ]: 0 : if (out_of_space_and_zlib)
1002 : : data_size = OUT_OF_SPACE_BUF;
1003 : : else {
1004 [ # # ]: 0 : if (op_type == OPERATION_COMPRESSION) {
1005 : 0 : not_zlib_compr = (test_data->zlib_dir == ZLIB_DECOMPRESS
1006 : 0 : || test_data->zlib_dir == ZLIB_NONE);
1007 : :
1008 : : ratio_val = (ratio == RATIO_ENABLED) ?
1009 [ # # ]: 0 : COMPRESS_BUF_SIZE_RATIO :
1010 : : COMPRESS_BUF_SIZE_RATIO_DISABLED;
1011 : :
1012 : 0 : ratio_val = (not_zlib_compr &&
1013 : 0 : (overflow == OVERFLOW_ENABLED)) ?
1014 [ # # ]: 0 : COMPRESS_BUF_SIZE_RATIO_OVERFLOW :
1015 : : ratio_val;
1016 : :
1017 : 0 : data_size = strlen(test_bufs[i]) * ratio_val;
1018 : : } else {
1019 : : priv_data = (struct priv_op_data *)
1020 : 0 : (ops_processed[i] + 1);
1021 : 0 : data_size = strlen(test_bufs[priv_data->orig_idx]) + 1;
1022 : : }
1023 : : }
1024 : :
1025 : 0 : return data_size;
1026 : : }
1027 : :
1028 : :
1029 : : /**
1030 : : * Memory buffers preparation (for both compression and decompression).
1031 : : *
1032 : : * Function allocates output buffers to perform compression
1033 : : * or decompression operations depending on value of op_type.
1034 : : *
1035 : : * @param op_type
1036 : : * Operation type: compress or decompress
1037 : : * @param out_of_space_and_zlib
1038 : : * Boolean value to switch into "out of space" buffer if set.
1039 : : * To test "out-of-space" data size, zlib_decompress must be set as well.
1040 : : * @param test_priv_data
1041 : : * A container used for aggregation all the private test arrays.
1042 : : * @param int_data
1043 : : * Interim data containing session/transformation objects.
1044 : : * @param test_data
1045 : : * The test parameters set by users (command line parameters).
1046 : : * @param current_extbuf_info,
1047 : : * The structure containing all the information related to external mbufs
1048 : : * @return
1049 : : * - 0: On success.
1050 : : * - -1: On error.
1051 : : */
1052 : : static int
1053 : 0 : test_setup_output_bufs(
1054 : : enum operation_type op_type,
1055 : : unsigned int out_of_space_and_zlib,
1056 : : const struct test_private_arrays *test_priv_data,
1057 : : const struct interim_data_params *int_data,
1058 : : const struct test_data_params *test_data,
1059 : : struct rte_mbuf_ext_shared_info *current_extbuf_info)
1060 : : {
1061 : : /* local variables: */
1062 : : unsigned int i;
1063 : : uint32_t data_size;
1064 : : int ret;
1065 : : char *buf_ptr;
1066 : :
1067 : : /* from test_priv_data: */
1068 : : struct rte_mbuf **current_bufs;
1069 : :
1070 : : /* from int_data: */
1071 : 0 : unsigned int num_bufs = int_data->num_bufs;
1072 : :
1073 : : /* from test_data: */
1074 : 0 : unsigned int buff_type = test_data->buff_type;
1075 : 0 : unsigned int big_data = test_data->big_data;
1076 : : const struct rte_memzone *current_memzone;
1077 : :
1078 : : struct comp_testsuite_params *ts_params = &testsuite_params;
1079 : : struct rte_mempool *buf_pool;
1080 : :
1081 [ # # ]: 0 : if (big_data)
1082 : 0 : buf_pool = ts_params->big_mbuf_pool;
1083 [ # # ]: 0 : else if (buff_type == SGL_BOTH)
1084 : 0 : buf_pool = ts_params->small_mbuf_pool;
1085 : : else
1086 : 0 : buf_pool = ts_params->large_mbuf_pool;
1087 : :
1088 [ # # ]: 0 : if (op_type == OPERATION_COMPRESSION)
1089 : 0 : current_bufs = test_priv_data->comp_bufs;
1090 : : else
1091 : 0 : current_bufs = test_priv_data->uncomp_bufs;
1092 : :
1093 : : /* the mbufs allocation*/
1094 : 0 : ret = rte_pktmbuf_alloc_bulk(buf_pool, current_bufs, num_bufs);
1095 [ # # ]: 0 : if (ret < 0) {
1096 : 0 : RTE_LOG(ERR, USER1,
1097 : : "Destination mbufs could not be allocated "
1098 : : "from the mempool\n");
1099 : 0 : return -1;
1100 : : }
1101 : :
1102 [ # # ]: 0 : if (test_data->use_external_mbufs) {
1103 : 0 : current_extbuf_info->free_cb = extbuf_free_callback;
1104 [ # # ]: 0 : current_extbuf_info->fcb_opaque = NULL;
1105 : : rte_mbuf_ext_refcnt_set(current_extbuf_info, 1);
1106 [ # # ]: 0 : if (op_type == OPERATION_COMPRESSION)
1107 : 0 : current_memzone = test_data->compbuf_memzone;
1108 : : else
1109 : 0 : current_memzone = test_data->uncompbuf_memzone;
1110 : :
1111 [ # # ]: 0 : for (i = 0; i < num_bufs; i++) {
1112 : 0 : rte_pktmbuf_attach_extbuf(current_bufs[i],
1113 : 0 : current_memzone->addr,
1114 : 0 : current_memzone->iova,
1115 : 0 : current_memzone->len,
1116 : : current_extbuf_info);
1117 : 0 : rte_pktmbuf_append(current_bufs[i],
1118 : 0 : current_memzone->len);
1119 : : }
1120 : : } else {
1121 [ # # ]: 0 : for (i = 0; i < num_bufs; i++) {
1122 : :
1123 : 0 : enum rte_comp_huffman comp_huffman =
1124 : 0 : ts_params->def_comp_xform->compress.deflate.huffman;
1125 : :
1126 : : /* data size calculation */
1127 : 0 : data_size = test_mbufs_calculate_data_size(
1128 : : op_type,
1129 : : out_of_space_and_zlib,
1130 : : test_priv_data,
1131 : : int_data,
1132 : : test_data,
1133 : : i);
1134 : :
1135 [ # # ]: 0 : if (comp_huffman != RTE_COMP_HUFFMAN_DYNAMIC) {
1136 [ # # ]: 0 : if (op_type == OPERATION_DECOMPRESSION)
1137 : 0 : data_size *= COMPRESS_BUF_SIZE_RATIO;
1138 : : }
1139 : :
1140 : : /* data allocation */
1141 [ # # ]: 0 : if (buff_type == SGL_BOTH || buff_type == LB_TO_SGL) {
1142 [ # # # # : 0 : ret = prepare_sgl_bufs(NULL, current_bufs[i],
# # # # ]
1143 : : data_size,
1144 : : big_data ? buf_pool :
1145 : : ts_params->small_mbuf_pool,
1146 : : big_data ? buf_pool :
1147 : : ts_params->large_mbuf_pool,
1148 : : big_data ? 0 : MAX_SEGS,
1149 : : big_data ? MAX_DATA_MBUF_SIZE :
1150 : : SMALL_SEG_SIZE);
1151 [ # # ]: 0 : if (ret < 0)
1152 : : return -1;
1153 : : } else {
1154 : 0 : buf_ptr = rte_pktmbuf_append(current_bufs[i],
1155 : : data_size);
1156 [ # # ]: 0 : if (buf_ptr == NULL) {
1157 : 0 : RTE_LOG(ERR, USER1,
1158 : : "Append extra bytes to the destination mbuf failed\n");
1159 : 0 : return -1;
1160 : : }
1161 : : }
1162 : : }
1163 : : }
1164 : :
1165 : : return 0;
1166 : : }
1167 : :
1168 : : /**
1169 : : * The main compression function.
1170 : : *
1171 : : * Function performs compression operation.
1172 : : * Operation(s) configuration, depending on CLI parameters.
1173 : : * Operation(s) processing.
1174 : : *
1175 : : * @param int_data
1176 : : * Interim data containing session/transformation objects.
1177 : : * @param test_data
1178 : : * The test parameters set by users (command line parameters).
1179 : : * @param test_priv_data
1180 : : * A container used for aggregation all the private test arrays.
1181 : : * @return
1182 : : * - 0: On success.
1183 : : * - -1: On error.
1184 : : */
1185 : : static int
1186 : 0 : test_deflate_comp_run(const struct interim_data_params *int_data,
1187 : : const struct test_data_params *test_data,
1188 : : const struct test_private_arrays *test_priv_data)
1189 : : {
1190 : : /* local variables: */
1191 : : struct priv_op_data *priv_data;
1192 : : unsigned int i;
1193 : : uint16_t num_priv_xforms = 0;
1194 : : int ret;
1195 : : int ret_status = 0;
1196 : : char *buf_ptr;
1197 : :
1198 : : struct comp_testsuite_params *ts_params = &testsuite_params;
1199 : :
1200 : : /* from test_data: */
1201 : 0 : enum rte_comp_op_type operation_type = test_data->compress_state;
1202 : : unsigned int zlib_compress =
1203 : 0 : (test_data->zlib_dir == ZLIB_ALL ||
1204 : : test_data->zlib_dir == ZLIB_COMPRESS);
1205 : :
1206 : : /* from int_data: */
1207 : 0 : struct rte_comp_xform **compress_xforms = int_data->compress_xforms;
1208 : 0 : unsigned int num_xforms = int_data->num_xforms;
1209 : 0 : unsigned int num_bufs = int_data->num_bufs;
1210 : :
1211 : : /* from test_priv_data: */
1212 : 0 : struct rte_mbuf **comp_bufs = test_priv_data->comp_bufs;
1213 : 0 : struct rte_mbuf **uncomp_bufs = test_priv_data->uncomp_bufs;
1214 : 0 : struct rte_comp_op **ops = test_priv_data->ops;
1215 : 0 : struct rte_comp_op **ops_processed = test_priv_data->ops_processed;
1216 : 0 : void **priv_xforms = test_priv_data->priv_xforms;
1217 : :
1218 : : const struct rte_compressdev_capabilities *capa =
1219 : 0 : rte_compressdev_capability_get(0, RTE_COMP_ALGO_DEFLATE);
1220 : :
1221 : : /* Build the compression operations */
1222 : 0 : ret = rte_comp_op_bulk_alloc(ts_params->op_pool, ops, num_bufs);
1223 [ # # ]: 0 : if (ret < 0) {
1224 : 0 : RTE_LOG(ERR, USER1,
1225 : : "Compress operations could not be allocated "
1226 : : "from the mempool\n");
1227 : : ret_status = -1;
1228 : 0 : goto exit;
1229 : : }
1230 : :
1231 [ # # ]: 0 : for (i = 0; i < num_bufs; i++) {
1232 : 0 : ops[i]->m_src = uncomp_bufs[i];
1233 : 0 : ops[i]->m_dst = comp_bufs[i];
1234 : 0 : ops[i]->src.offset = 0;
1235 : 0 : ops[i]->src.length = rte_pktmbuf_pkt_len(uncomp_bufs[i]);
1236 : 0 : ops[i]->dst.offset = 0;
1237 : :
1238 : 0 : RTE_LOG(DEBUG, USER1,
1239 : : "Uncompressed buffer length = %u compressed buffer length = %u",
1240 : : rte_pktmbuf_pkt_len(uncomp_bufs[i]),
1241 : : rte_pktmbuf_pkt_len(comp_bufs[i]));
1242 : :
1243 [ # # ]: 0 : if (operation_type == RTE_COMP_OP_STATELESS) {
1244 : 0 : ops[i]->flush_flag = RTE_COMP_FLUSH_FINAL;
1245 : : } else {
1246 : 0 : RTE_LOG(ERR, USER1,
1247 : : "Compression: stateful operations are not "
1248 : : "supported in these tests yet\n");
1249 : : ret_status = -1;
1250 : 0 : goto exit;
1251 : : }
1252 : 0 : ops[i]->input_chksum = 0;
1253 : : /*
1254 : : * Store original operation index in private data,
1255 : : * since ordering does not have to be maintained,
1256 : : * when dequeuing from compressdev, so a comparison
1257 : : * at the end of the test can be done.
1258 : : */
1259 : 0 : priv_data = (struct priv_op_data *) (ops[i] + 1);
1260 : 0 : priv_data->orig_idx = i;
1261 : : }
1262 : :
1263 : : /* Compress data (either with Zlib API or compressdev API */
1264 [ # # ]: 0 : if (zlib_compress) {
1265 [ # # ]: 0 : for (i = 0; i < num_bufs; i++) {
1266 : 0 : const struct rte_comp_xform *compress_xform =
1267 : 0 : compress_xforms[i % num_xforms];
1268 : 0 : ret = compress_zlib(ops[i], compress_xform,
1269 : : DEFAULT_MEM_LEVEL);
1270 [ # # ]: 0 : if (ret < 0) {
1271 : : ret_status = -1;
1272 : 0 : goto exit;
1273 : : }
1274 : :
1275 : 0 : ops_processed[i] = ops[i];
1276 : : }
1277 : : } else {
1278 : : /* Create compress private xform data */
1279 [ # # ]: 0 : for (i = 0; i < num_xforms; i++) {
1280 : 0 : ret = rte_compressdev_private_xform_create(0,
1281 : : (const struct rte_comp_xform *)
1282 : 0 : compress_xforms[i],
1283 : 0 : &priv_xforms[i]);
1284 [ # # ]: 0 : if (ret < 0) {
1285 : 0 : RTE_LOG(ERR, USER1,
1286 : : "Compression private xform "
1287 : : "could not be created\n");
1288 : : ret_status = -1;
1289 : 0 : goto exit;
1290 : : }
1291 : 0 : num_priv_xforms++;
1292 : : }
1293 [ # # ]: 0 : if (capa->comp_feature_flags &
1294 : : RTE_COMP_FF_SHAREABLE_PRIV_XFORM) {
1295 : : /* Attach shareable private xform data to ops */
1296 [ # # ]: 0 : for (i = 0; i < num_bufs; i++)
1297 : 0 : ops[i]->private_xform =
1298 : 0 : priv_xforms[i % num_xforms];
1299 : : } else {
1300 : : /* Create rest of the private xforms for the other ops */
1301 [ # # ]: 0 : for (i = num_xforms; i < num_bufs; i++) {
1302 : 0 : ret = rte_compressdev_private_xform_create(0,
1303 : 0 : compress_xforms[i % num_xforms],
1304 : 0 : &priv_xforms[i]);
1305 [ # # ]: 0 : if (ret < 0) {
1306 : 0 : RTE_LOG(ERR, USER1,
1307 : : "Compression private xform "
1308 : : "could not be created\n");
1309 : : ret_status = -1;
1310 : 0 : goto exit;
1311 : : }
1312 : 0 : num_priv_xforms++;
1313 : : }
1314 : : /* Attach non shareable private xform data to ops */
1315 [ # # ]: 0 : for (i = 0; i < num_bufs; i++)
1316 : 0 : ops[i]->private_xform = priv_xforms[i];
1317 : : }
1318 : :
1319 : 0 : recovery_lb:
1320 : 0 : ret = test_run_enqueue_dequeue(ops, ops_processed, num_bufs);
1321 [ # # ]: 0 : if (ret < 0) {
1322 : 0 : RTE_LOG(ERR, USER1,
1323 : : "Compression: enqueue/dequeue operation failed\n");
1324 : : ret_status = -1;
1325 : 0 : goto exit;
1326 : : }
1327 : :
1328 [ # # ]: 0 : for (i = 0; i < num_bufs; i++) {
1329 : 0 : test_priv_data->compressed_data_size[i] +=
1330 : 0 : ops_processed[i]->produced;
1331 : :
1332 [ # # ]: 0 : if (ops_processed[i]->status ==
1333 : : RTE_COMP_OP_STATUS_OUT_OF_SPACE_RECOVERABLE) {
1334 : :
1335 : 0 : ops[i]->status =
1336 : : RTE_COMP_OP_STATUS_NOT_PROCESSED;
1337 : 0 : ops[i]->src.offset +=
1338 : 0 : ops_processed[i]->consumed;
1339 : 0 : ops[i]->src.length -=
1340 : 0 : ops_processed[i]->consumed;
1341 : 0 : ops[i]->dst.offset +=
1342 : 0 : ops_processed[i]->produced;
1343 : :
1344 : 0 : buf_ptr = rte_pktmbuf_append(
1345 : 0 : ops[i]->m_dst,
1346 : 0 : ops_processed[i]->produced);
1347 : :
1348 [ # # ]: 0 : if (buf_ptr == NULL) {
1349 : 0 : RTE_LOG(ERR, USER1,
1350 : : "Data recovery: append extra bytes to the current mbuf failed\n");
1351 : : ret_status = -1;
1352 : 0 : goto exit;
1353 : : }
1354 : 0 : goto recovery_lb;
1355 : : }
1356 : : }
1357 : : }
1358 : :
1359 : 0 : exit:
1360 : : /* Free resources */
1361 : : if (ret_status < 0)
1362 [ # # ]: 0 : for (i = 0; i < num_bufs; i++) {
1363 : 0 : rte_comp_op_free(ops[i]);
1364 : 0 : ops[i] = NULL;
1365 : 0 : ops_processed[i] = NULL;
1366 : : }
1367 : :
1368 : : /* Free compress private xforms */
1369 [ # # ]: 0 : for (i = 0; i < num_priv_xforms; i++) {
1370 [ # # ]: 0 : if (priv_xforms[i] != NULL) {
1371 : 0 : rte_compressdev_private_xform_free(0, priv_xforms[i]);
1372 : 0 : priv_xforms[i] = NULL;
1373 : : }
1374 : : }
1375 : :
1376 : 0 : return ret_status;
1377 : : }
1378 : :
1379 : : /**
1380 : : * Prints out the test report. Memory freeing.
1381 : : *
1382 : : * Called after successful compression.
1383 : : * Operation(s) status validation and decompression buffers freeing.
1384 : :
1385 : : * -1 returned if function fail.
1386 : : *
1387 : : * @param int_data
1388 : : * Interim data containing session/transformation objects.
1389 : : * @param test_data
1390 : : * The test parameters set by users (command line parameters).
1391 : : * @param test_priv_data
1392 : : * A container used for aggregation all the private test arrays.
1393 : : * @return
1394 : : * - 2: Some operation is not supported
1395 : : * - 1: Decompression should be skipped
1396 : : * - 0: On success.
1397 : : * - -1: On error.
1398 : : */
1399 : : static int
1400 : 0 : test_deflate_comp_finalize(const struct interim_data_params *int_data,
1401 : : const struct test_data_params *test_data,
1402 : : const struct test_private_arrays *test_priv_data)
1403 : : {
1404 : : /* local variables: */
1405 : : unsigned int i;
1406 : : struct priv_op_data *priv_data;
1407 : :
1408 : : /* from int_data: */
1409 : 0 : unsigned int num_xforms = int_data->num_xforms;
1410 : 0 : struct rte_comp_xform **compress_xforms = int_data->compress_xforms;
1411 : 0 : unsigned int num_bufs = int_data->num_bufs;
1412 : :
1413 : : /* from test_priv_data: */
1414 : 0 : struct rte_comp_op **ops_processed = test_priv_data->ops_processed;
1415 : 0 : uint64_t *compress_checksum = test_priv_data->compress_checksum;
1416 : 0 : struct rte_mbuf **uncomp_bufs = test_priv_data->uncomp_bufs;
1417 : 0 : struct rte_comp_op **ops = test_priv_data->ops;
1418 : :
1419 : : /* from test_data: */
1420 : 0 : unsigned int out_of_space = test_data->out_of_space;
1421 : : unsigned int zlib_compress =
1422 : 0 : (test_data->zlib_dir == ZLIB_ALL ||
1423 : : test_data->zlib_dir == ZLIB_COMPRESS);
1424 : : unsigned int zlib_decompress =
1425 : 0 : (test_data->zlib_dir == ZLIB_ALL ||
1426 : : test_data->zlib_dir == ZLIB_DECOMPRESS);
1427 : :
1428 [ # # ]: 0 : for (i = 0; i < num_bufs; i++) {
1429 : 0 : priv_data = (struct priv_op_data *)(ops_processed[i] + 1);
1430 : 0 : uint16_t xform_idx = priv_data->orig_idx % num_xforms;
1431 : : const struct rte_comp_compress_xform *compress_xform =
1432 : 0 : &compress_xforms[xform_idx]->compress;
1433 : 0 : enum rte_comp_huffman huffman_type =
1434 : : compress_xform->deflate.huffman;
1435 : 0 : char engine[] = "zlib (directly, not PMD)";
1436 [ # # ]: 0 : if (zlib_decompress)
1437 : : strlcpy(engine, "PMD", sizeof(engine));
1438 : :
1439 : 0 : RTE_LOG(DEBUG, USER1, "Buffer %u compressed by %s from %u to"
1440 : : " %u bytes (level = %d, huffman = %s)\n",
1441 : : i, engine,
1442 : : ops_processed[i]->consumed, ops_processed[i]->produced,
1443 : : compress_xform->level,
1444 : : huffman_type_strings[huffman_type]);
1445 [ # # ]: 0 : RTE_LOG(DEBUG, USER1, "Compression ratio = %.2f\n",
1446 : : ops_processed[i]->consumed == 0 ? 0 :
1447 : : (float)ops_processed[i]->produced /
1448 : : ops_processed[i]->consumed * 100);
1449 [ # # ]: 0 : if (compress_xform->chksum != RTE_COMP_CHECKSUM_NONE)
1450 : 0 : compress_checksum[i] = ops_processed[i]->output_chksum;
1451 : 0 : ops[i] = NULL;
1452 : : }
1453 : :
1454 : : /*
1455 : : * Check operation status and free source mbufs (destination mbuf and
1456 : : * compress operation information is needed for the decompression stage)
1457 : : */
1458 [ # # ]: 0 : for (i = 0; i < num_bufs; i++) {
1459 [ # # ]: 0 : if (out_of_space && !zlib_compress) {
1460 [ # # ]: 0 : if (ops_processed[i]->status !=
1461 : : RTE_COMP_OP_STATUS_OUT_OF_SPACE_TERMINATED) {
1462 : 0 : RTE_LOG(ERR, USER1,
1463 : : "Operation without expected out of "
1464 : : "space status error\n");
1465 : 0 : return -1;
1466 : : } else
1467 : 0 : continue;
1468 : : }
1469 : :
1470 [ # # ]: 0 : if (ops_processed[i]->status != RTE_COMP_OP_STATUS_SUCCESS) {
1471 [ # # ]: 0 : if (test_data->overflow == OVERFLOW_ENABLED) {
1472 [ # # ]: 0 : if (ops_processed[i]->status ==
1473 : : RTE_COMP_OP_STATUS_OUT_OF_SPACE_TERMINATED) {
1474 : 0 : RTE_LOG(INFO, USER1,
1475 : : "Out-of-space-recoverable functionality"
1476 : : " is not supported on this device\n");
1477 : 0 : return 2;
1478 : : }
1479 : : }
1480 : :
1481 : 0 : RTE_LOG(ERR, USER1,
1482 : : "Comp: Some operations were not successful\n");
1483 : 0 : return -1;
1484 : : }
1485 : : priv_data = (struct priv_op_data *)(ops_processed[i] + 1);
1486 : 0 : rte_pktmbuf_free(uncomp_bufs[priv_data->orig_idx]);
1487 : 0 : uncomp_bufs[priv_data->orig_idx] = NULL;
1488 : : }
1489 : :
1490 [ # # ]: 0 : if (out_of_space && !zlib_compress)
1491 : 0 : return 1;
1492 : :
1493 : : return 0;
1494 : : }
1495 : :
1496 : : /**
1497 : : * The main decompression function.
1498 : : *
1499 : : * Function performs decompression operation.
1500 : : * Operation(s) configuration, depending on CLI parameters.
1501 : : * Operation(s) processing.
1502 : : *
1503 : : * @param int_data
1504 : : * Interim data containing session/transformation objects.
1505 : : * @param test_data
1506 : : * The test parameters set by users (command line parameters).
1507 : : * @param test_priv_data
1508 : : * A container used for aggregation all the private test arrays.
1509 : : * @return
1510 : : * - 0: On success.
1511 : : * - -1: On error.
1512 : : */
1513 : : static int
1514 : 0 : test_deflate_decomp_run(const struct interim_data_params *int_data,
1515 : : const struct test_data_params *test_data,
1516 : : struct test_private_arrays *test_priv_data)
1517 : : {
1518 : :
1519 : : /* local variables: */
1520 : : struct priv_op_data *priv_data;
1521 : : unsigned int i;
1522 : : uint16_t num_priv_xforms = 0;
1523 : : int ret;
1524 : : int ret_status = 0;
1525 : :
1526 : : struct comp_testsuite_params *ts_params = &testsuite_params;
1527 : :
1528 : : /* from test_data: */
1529 : 0 : enum rte_comp_op_type operation_type = test_data->decompress_state;
1530 : : unsigned int zlib_decompress =
1531 : 0 : (test_data->zlib_dir == ZLIB_ALL ||
1532 : : test_data->zlib_dir == ZLIB_DECOMPRESS);
1533 : :
1534 : : /* from int_data: */
1535 : 0 : struct rte_comp_xform **decompress_xforms = int_data->decompress_xforms;
1536 : 0 : unsigned int num_xforms = int_data->num_xforms;
1537 : 0 : unsigned int num_bufs = int_data->num_bufs;
1538 : :
1539 : : /* from test_priv_data: */
1540 : 0 : struct rte_mbuf **uncomp_bufs = test_priv_data->uncomp_bufs;
1541 : 0 : struct rte_mbuf **comp_bufs = test_priv_data->comp_bufs;
1542 : 0 : struct rte_comp_op **ops = test_priv_data->ops;
1543 : 0 : struct rte_comp_op **ops_processed = test_priv_data->ops_processed;
1544 : 0 : void **priv_xforms = test_priv_data->priv_xforms;
1545 : 0 : uint32_t *compressed_data_size = test_priv_data->compressed_data_size;
1546 : 0 : void **stream = test_priv_data->stream;
1547 : :
1548 : : const struct rte_compressdev_capabilities *capa =
1549 : 0 : rte_compressdev_capability_get(0, RTE_COMP_ALGO_DEFLATE);
1550 : :
1551 : 0 : ret = rte_comp_op_bulk_alloc(ts_params->op_pool, ops, num_bufs);
1552 [ # # ]: 0 : if (ret < 0) {
1553 : 0 : RTE_LOG(ERR, USER1,
1554 : : "Decompress operations could not be allocated "
1555 : : "from the mempool\n");
1556 : : ret_status = -1;
1557 : 0 : goto exit;
1558 : : }
1559 : :
1560 : : /* Source buffer is the compressed data from the previous operations */
1561 [ # # ]: 0 : for (i = 0; i < num_bufs; i++) {
1562 : 0 : ops[i]->m_src = comp_bufs[i];
1563 : 0 : ops[i]->m_dst = uncomp_bufs[i];
1564 : 0 : ops[i]->src.offset = 0;
1565 : : /*
1566 : : * Set the length of the compressed data to the
1567 : : * number of bytes that were produced in the previous stage
1568 : : */
1569 : :
1570 [ # # ]: 0 : if (compressed_data_size[i])
1571 : 0 : ops[i]->src.length = compressed_data_size[i];
1572 : : else
1573 : 0 : ops[i]->src.length = ops_processed[i]->produced;
1574 : :
1575 : 0 : ops[i]->dst.offset = 0;
1576 : :
1577 [ # # ]: 0 : if (operation_type == RTE_COMP_OP_STATELESS) {
1578 : 0 : ops[i]->flush_flag = RTE_COMP_FLUSH_FINAL;
1579 : 0 : ops[i]->op_type = RTE_COMP_OP_STATELESS;
1580 [ # # ]: 0 : } else if (!zlib_decompress) {
1581 : 0 : ops[i]->flush_flag = RTE_COMP_FLUSH_SYNC;
1582 : 0 : ops[i]->op_type = RTE_COMP_OP_STATEFUL;
1583 : : } else {
1584 : 0 : RTE_LOG(ERR, USER1,
1585 : : "Decompression: stateful operations are"
1586 : : " not supported in these tests yet\n");
1587 : : ret_status = -1;
1588 : 0 : goto exit;
1589 : : }
1590 : 0 : ops[i]->input_chksum = 0;
1591 : : /*
1592 : : * Copy private data from previous operations,
1593 : : * to keep the pointer to the original buffer
1594 : : */
1595 : 0 : memcpy(ops[i] + 1, ops_processed[i] + 1,
1596 : : sizeof(struct priv_op_data));
1597 : : }
1598 : :
1599 : : /*
1600 : : * Free the previous compress operations,
1601 : : * as they are not needed anymore
1602 : : */
1603 : 0 : rte_comp_op_bulk_free(ops_processed, num_bufs);
1604 : :
1605 : : /* Decompress data (either with Zlib API or compressdev API */
1606 [ # # ]: 0 : if (zlib_decompress) {
1607 [ # # ]: 0 : for (i = 0; i < num_bufs; i++) {
1608 : 0 : priv_data = (struct priv_op_data *)(ops[i] + 1);
1609 : 0 : uint16_t xform_idx = priv_data->orig_idx % num_xforms;
1610 : 0 : const struct rte_comp_xform *decompress_xform =
1611 : 0 : decompress_xforms[xform_idx];
1612 : :
1613 : 0 : ret = decompress_zlib(ops[i], decompress_xform);
1614 [ # # ]: 0 : if (ret < 0) {
1615 : : ret_status = -1;
1616 : 0 : goto exit;
1617 : : }
1618 : :
1619 : 0 : ops_processed[i] = ops[i];
1620 : : }
1621 : : } else {
1622 [ # # ]: 0 : if (operation_type == RTE_COMP_OP_STATELESS) {
1623 : : /* Create decompress private xform data */
1624 [ # # ]: 0 : for (i = 0; i < num_xforms; i++) {
1625 : 0 : ret = rte_compressdev_private_xform_create(0,
1626 : : (const struct rte_comp_xform *)
1627 : 0 : decompress_xforms[i],
1628 : 0 : &priv_xforms[i]);
1629 [ # # ]: 0 : if (ret < 0) {
1630 : 0 : RTE_LOG(ERR, USER1,
1631 : : "Decompression private xform "
1632 : : "could not be created\n");
1633 : : ret_status = -1;
1634 : 0 : goto exit;
1635 : : }
1636 : 0 : num_priv_xforms++;
1637 : : }
1638 : :
1639 [ # # ]: 0 : if (capa->comp_feature_flags &
1640 : : RTE_COMP_FF_SHAREABLE_PRIV_XFORM) {
1641 : : /* Attach shareable private xform data to ops */
1642 [ # # ]: 0 : for (i = 0; i < num_bufs; i++) {
1643 : : priv_data = (struct priv_op_data *)
1644 : 0 : (ops[i] + 1);
1645 : : uint16_t xform_idx =
1646 : 0 : priv_data->orig_idx % num_xforms;
1647 : 0 : ops[i]->private_xform =
1648 : 0 : priv_xforms[xform_idx];
1649 : : }
1650 : : } else {
1651 : : /* Create rest of the private xforms */
1652 : : /* for the other ops */
1653 [ # # ]: 0 : for (i = num_xforms; i < num_bufs; i++) {
1654 : : ret =
1655 : 0 : rte_compressdev_private_xform_create(0,
1656 : 0 : decompress_xforms[i % num_xforms],
1657 : 0 : &priv_xforms[i]);
1658 [ # # ]: 0 : if (ret < 0) {
1659 : 0 : RTE_LOG(ERR, USER1,
1660 : : "Decompression private xform"
1661 : : " could not be created\n");
1662 : : ret_status = -1;
1663 : 0 : goto exit;
1664 : : }
1665 : 0 : num_priv_xforms++;
1666 : : }
1667 : :
1668 : : /* Attach non shareable private xform data */
1669 : : /* to ops */
1670 [ # # ]: 0 : for (i = 0; i < num_bufs; i++) {
1671 : : priv_data = (struct priv_op_data *)
1672 : 0 : (ops[i] + 1);
1673 : 0 : uint16_t xform_idx =
1674 : : priv_data->orig_idx;
1675 : 0 : ops[i]->private_xform =
1676 : 0 : priv_xforms[xform_idx];
1677 : : }
1678 : : }
1679 : : } else {
1680 : : /* Create a stream object for stateful decompression */
1681 : 0 : ret = rte_compressdev_stream_create(0,
1682 : : decompress_xforms[0], stream);
1683 [ # # ]: 0 : if (ret < 0) {
1684 : 0 : RTE_LOG(ERR, USER1,
1685 : : "Decompression stream could not be created, error %d\n",
1686 : : ret);
1687 : : ret_status = -1;
1688 : 0 : goto exit;
1689 : : }
1690 : : /* Attach stream to ops */
1691 [ # # ]: 0 : for (i = 0; i < num_bufs; i++)
1692 : 0 : ops[i]->stream = *stream;
1693 : : }
1694 : :
1695 : 0 : test_priv_data->num_priv_xforms = num_priv_xforms;
1696 : : }
1697 : :
1698 : 0 : exit:
1699 : 0 : return ret_status;
1700 : : }
1701 : :
1702 : : /**
1703 : : * Prints out the test report. Memory freeing.
1704 : : *
1705 : : * Called after successful decompression.
1706 : : * Operation(s) status validation and compression buffers freeing.
1707 : :
1708 : : * -1 returned if function fail.
1709 : : *
1710 : : * @param int_data
1711 : : * Interim data containing session/transformation objects.
1712 : : * @param test_data
1713 : : * The test parameters set by users (command line parameters).
1714 : : * @param test_priv_data
1715 : : * A container used for aggregation all the private test arrays.
1716 : : * @return
1717 : : * - 2: Next step must be executed by the caller (stateful decompression only)
1718 : : * - 1: On success (caller should stop and exit)
1719 : : * - 0: On success.
1720 : : * - -1: On error.
1721 : : */
1722 : : static int
1723 : 0 : test_deflate_decomp_finalize(const struct interim_data_params *int_data,
1724 : : const struct test_data_params *test_data,
1725 : : const struct test_private_arrays *test_priv_data)
1726 : : {
1727 : : /* local variables: */
1728 : : unsigned int i;
1729 : : struct priv_op_data *priv_data;
1730 : : static unsigned int step;
1731 : :
1732 : : /* from int_data: */
1733 : 0 : unsigned int num_bufs = int_data->num_bufs;
1734 : 0 : const char * const *test_bufs = int_data->test_bufs;
1735 : 0 : struct rte_comp_xform **compress_xforms = int_data->compress_xforms;
1736 : :
1737 : : /* from test_priv_data: */
1738 : 0 : struct rte_comp_op **ops_processed = test_priv_data->ops_processed;
1739 : 0 : struct rte_mbuf **comp_bufs = test_priv_data->comp_bufs;
1740 : 0 : struct rte_comp_op **ops = test_priv_data->ops;
1741 : 0 : uint64_t *compress_checksum = test_priv_data->compress_checksum;
1742 : 0 : unsigned int *decomp_produced_data_size =
1743 : : test_priv_data->decomp_produced_data_size;
1744 : 0 : char **all_decomp_data = test_priv_data->all_decomp_data;
1745 : :
1746 : : /* from test_data: */
1747 : 0 : unsigned int out_of_space = test_data->out_of_space;
1748 : 0 : enum rte_comp_op_type operation_type = test_data->decompress_state;
1749 : :
1750 : : unsigned int zlib_compress =
1751 : 0 : (test_data->zlib_dir == ZLIB_ALL ||
1752 : : test_data->zlib_dir == ZLIB_COMPRESS);
1753 : : unsigned int zlib_decompress =
1754 : 0 : (test_data->zlib_dir == ZLIB_ALL ||
1755 : : test_data->zlib_dir == ZLIB_DECOMPRESS);
1756 : :
1757 [ # # ]: 0 : for (i = 0; i < num_bufs; i++) {
1758 : 0 : priv_data = (struct priv_op_data *)(ops_processed[i] + 1);
1759 : 0 : char engine[] = "zlib, (directly, no PMD)";
1760 [ # # ]: 0 : if (zlib_compress)
1761 : : strlcpy(engine, "pmd", sizeof(engine));
1762 : 0 : RTE_LOG(DEBUG, USER1,
1763 : : "Buffer %u decompressed by %s from %u to %u bytes\n",
1764 : : i, engine,
1765 : : ops_processed[i]->consumed, ops_processed[i]->produced);
1766 : 0 : ops[i] = NULL;
1767 : : }
1768 : :
1769 : : /*
1770 : : * Check operation status and free source mbuf (destination mbuf and
1771 : : * compress operation information is still needed)
1772 : : */
1773 [ # # ]: 0 : for (i = 0; i < num_bufs; i++) {
1774 [ # # ]: 0 : if (out_of_space && !zlib_decompress) {
1775 [ # # ]: 0 : if (ops_processed[i]->status !=
1776 : : RTE_COMP_OP_STATUS_OUT_OF_SPACE_TERMINATED) {
1777 : :
1778 : 0 : RTE_LOG(ERR, USER1,
1779 : : "Operation without expected out of "
1780 : : "space status error\n");
1781 : 0 : return -1;
1782 : : } else
1783 : 0 : continue;
1784 : : }
1785 : :
1786 [ # # ]: 0 : if (operation_type == RTE_COMP_OP_STATEFUL
1787 : 0 : && (ops_processed[i]->status ==
1788 : : RTE_COMP_OP_STATUS_OUT_OF_SPACE_RECOVERABLE
1789 [ # # ]: 0 : || ops_processed[i]->status ==
1790 : : RTE_COMP_OP_STATUS_SUCCESS)) {
1791 : :
1792 : 0 : RTE_LOG(DEBUG, USER1,
1793 : : ".............RECOVERABLE\n");
1794 : :
1795 : : /* collect the output into all_decomp_data */
1796 : 0 : const void *ptr = rte_pktmbuf_read(
1797 : 0 : ops_processed[i]->m_dst,
1798 : : ops_processed[i]->dst.offset,
1799 : 0 : ops_processed[i]->produced,
1800 : 0 : *all_decomp_data +
1801 [ # # ]: 0 : *decomp_produced_data_size);
1802 : 0 : if (ptr != *all_decomp_data +
1803 [ # # ]: 0 : *decomp_produced_data_size)
1804 : 0 : rte_memcpy(*all_decomp_data +
1805 : : *decomp_produced_data_size,
1806 [ # # ]: 0 : ptr, ops_processed[i]->produced);
1807 : :
1808 : 0 : *decomp_produced_data_size +=
1809 : 0 : ops_processed[i]->produced;
1810 : 0 : if (ops_processed[i]->src.length >
1811 [ # # ]: 0 : ops_processed[i]->consumed) {
1812 [ # # ]: 0 : if (ops_processed[i]->status ==
1813 : : RTE_COMP_OP_STATUS_SUCCESS) {
1814 : 0 : RTE_LOG(ERR, USER1,
1815 : : "Operation finished too early\n");
1816 : 0 : return -1;
1817 : : }
1818 : 0 : step++;
1819 [ # # ]: 0 : if (step >= test_data->decompress_steps_max) {
1820 : 0 : RTE_LOG(ERR, USER1,
1821 : : "Operation exceeded maximum steps\n");
1822 : 0 : return -1;
1823 : : }
1824 : 0 : ops[i] = ops_processed[i];
1825 : 0 : ops[i]->status =
1826 : : RTE_COMP_OP_STATUS_NOT_PROCESSED;
1827 : 0 : ops[i]->src.offset +=
1828 : 0 : ops_processed[i]->consumed;
1829 : 0 : ops[i]->src.length -=
1830 : 0 : ops_processed[i]->consumed;
1831 : : /* repeat the operation */
1832 : 0 : return 2;
1833 : : } else {
1834 : : /* Compare the original stream with the */
1835 : : /* decompressed stream (in size and the data) */
1836 : : priv_data = (struct priv_op_data *)
1837 : : (ops_processed[i] + 1);
1838 : 0 : const char *buf1 =
1839 : 0 : test_bufs[priv_data->orig_idx];
1840 : 0 : const char *buf2 = *all_decomp_data;
1841 : :
1842 [ # # ]: 0 : if (compare_buffers(buf1, strlen(buf1) + 1,
1843 : : buf2, *decomp_produced_data_size) < 0)
1844 : : return -1;
1845 : : /* Test checksums */
1846 [ # # ]: 0 : if (compress_xforms[0]->compress.chksum
1847 : : != RTE_COMP_CHECKSUM_NONE) {
1848 : 0 : if (ops_processed[i]->output_chksum
1849 [ # # ]: 0 : != compress_checksum[i]) {
1850 : 0 : RTE_LOG(ERR, USER1,
1851 : : "The checksums differ\n"
1852 : : "Compression Checksum: %" PRIu64 "\tDecompression "
1853 : : "Checksum: %" PRIu64 "\n", compress_checksum[i],
1854 : : ops_processed[i]->output_chksum);
1855 : 0 : return -1;
1856 : : }
1857 : : }
1858 : : }
1859 [ # # ]: 0 : } else if (ops_processed[i]->status !=
1860 : : RTE_COMP_OP_STATUS_SUCCESS) {
1861 : 0 : RTE_LOG(ERR, USER1,
1862 : : "Decomp: Some operations were not successful, status = %u\n",
1863 : : ops_processed[i]->status);
1864 : 0 : return -1;
1865 : : }
1866 : 0 : priv_data = (struct priv_op_data *)(ops_processed[i] + 1);
1867 : 0 : rte_pktmbuf_free(comp_bufs[priv_data->orig_idx]);
1868 : 0 : comp_bufs[priv_data->orig_idx] = NULL;
1869 : : }
1870 : :
1871 [ # # ]: 0 : if (out_of_space && !zlib_decompress)
1872 : 0 : return 1;
1873 : :
1874 : : return 0;
1875 : : }
1876 : :
1877 : : /**
1878 : : * Validation of the output (compression/decompression) data.
1879 : : *
1880 : : * The function compares the source stream with the output stream,
1881 : : * after decompression, to check if compression/decompression
1882 : : * was correct.
1883 : : * -1 returned if function fail.
1884 : : *
1885 : : * @param int_data
1886 : : * Interim data containing session/transformation objects.
1887 : : * @param test_data
1888 : : * The test parameters set by users (command line parameters).
1889 : : * @param test_priv_data
1890 : : * A container used for aggregation all the private test arrays.
1891 : : * @return
1892 : : * - 0: On success.
1893 : : * - -1: On error.
1894 : : */
1895 : : static int
1896 : 0 : test_results_validation(const struct interim_data_params *int_data,
1897 : : const struct test_data_params *test_data,
1898 : : const struct test_private_arrays *test_priv_data)
1899 : : {
1900 : : /* local variables: */
1901 : : unsigned int i;
1902 : : struct priv_op_data *priv_data;
1903 : : const char *buf1;
1904 : : const char *buf2;
1905 : : char *contig_buf = NULL;
1906 : : uint32_t data_size;
1907 : :
1908 : : /* from int_data: */
1909 : 0 : struct rte_comp_xform **compress_xforms = int_data->compress_xforms;
1910 : 0 : unsigned int num_bufs = int_data->num_bufs;
1911 : 0 : const char * const *test_bufs = int_data->test_bufs;
1912 : :
1913 : : /* from test_priv_data: */
1914 : 0 : uint64_t *compress_checksum = test_priv_data->compress_checksum;
1915 : 0 : struct rte_comp_op **ops_processed = test_priv_data->ops_processed;
1916 : :
1917 : : /*
1918 : : * Compare the original stream with the decompressed stream
1919 : : * (in size and the data)
1920 : : */
1921 [ # # ]: 0 : for (i = 0; i < num_bufs; i++) {
1922 : 0 : priv_data = (struct priv_op_data *)(ops_processed[i] + 1);
1923 : 0 : buf1 = test_data->use_external_mbufs ?
1924 [ # # ]: 0 : test_data->inbuf_memzone->addr :
1925 : 0 : test_bufs[priv_data->orig_idx];
1926 [ # # ]: 0 : data_size = test_data->use_external_mbufs ?
1927 : : test_data->inbuf_data_size :
1928 : 0 : strlen(buf1) + 1;
1929 : :
1930 : 0 : contig_buf = rte_malloc(NULL, ops_processed[i]->produced, 0);
1931 [ # # ]: 0 : if (contig_buf == NULL) {
1932 : 0 : RTE_LOG(ERR, USER1, "Contiguous buffer could not "
1933 : : "be allocated\n");
1934 : 0 : goto exit;
1935 : : }
1936 : :
1937 : 0 : buf2 = rte_pktmbuf_read(ops_processed[i]->m_dst, 0,
1938 [ # # ]: 0 : ops_processed[i]->produced, contig_buf);
1939 [ # # ]: 0 : if (compare_buffers(buf1, data_size,
1940 : 0 : buf2, ops_processed[i]->produced) < 0)
1941 : 0 : goto exit;
1942 : :
1943 : : /* Test checksums */
1944 [ # # ]: 0 : if (compress_xforms[0]->compress.chksum !=
1945 : : RTE_COMP_CHECKSUM_NONE) {
1946 : 0 : if (ops_processed[i]->output_chksum !=
1947 [ # # ]: 0 : compress_checksum[i]) {
1948 : 0 : RTE_LOG(ERR, USER1, "The checksums differ\n"
1949 : : "Compression Checksum: %" PRIu64 "\tDecompression "
1950 : : "Checksum: %" PRIu64 "\n", compress_checksum[i],
1951 : : ops_processed[i]->output_chksum);
1952 : 0 : goto exit;
1953 : : }
1954 : : }
1955 : :
1956 : 0 : rte_free(contig_buf);
1957 : : contig_buf = NULL;
1958 : : }
1959 : : return 0;
1960 : :
1961 : 0 : exit:
1962 : 0 : rte_free(contig_buf);
1963 : 0 : return -1;
1964 : : }
1965 : :
1966 : : /**
1967 : : * Compresses and decompresses input stream with compressdev API and Zlib API
1968 : : *
1969 : : * Basic test function. Common for all the functional tests.
1970 : : * -1 returned if function fail.
1971 : : *
1972 : : * @param int_data
1973 : : * Interim data containing session/transformation objects.
1974 : : * @param test_data
1975 : : * The test parameters set by users (command line parameters).
1976 : : * @return
1977 : : * - 1: Some operation not supported
1978 : : * - 0: On success.
1979 : : * - -1: On error.
1980 : : */
1981 : :
1982 : : static int
1983 : 0 : test_deflate_comp_decomp(const struct interim_data_params *int_data,
1984 : : const struct test_data_params *test_data)
1985 : 0 : {
1986 : 0 : unsigned int num_bufs = int_data->num_bufs;
1987 : 0 : unsigned int out_of_space = test_data->out_of_space;
1988 : :
1989 : 0 : void *stream = NULL;
1990 : 0 : char *all_decomp_data = NULL;
1991 : 0 : unsigned int decomp_produced_data_size = 0;
1992 : :
1993 : : int ret_status = -1;
1994 : : int ret;
1995 : 0 : struct rte_mbuf *uncomp_bufs[num_bufs];
1996 : 0 : struct rte_mbuf *comp_bufs[num_bufs];
1997 : 0 : struct rte_comp_op *ops[num_bufs];
1998 : 0 : struct rte_comp_op *ops_processed[num_bufs];
1999 : 0 : void *priv_xforms[num_bufs];
2000 : : unsigned int i;
2001 : :
2002 : 0 : uint64_t compress_checksum[num_bufs];
2003 : 0 : uint32_t compressed_data_size[num_bufs];
2004 : : char *contig_buf = NULL;
2005 : :
2006 : : struct rte_mbuf_ext_shared_info compbuf_info;
2007 : : struct rte_mbuf_ext_shared_info decompbuf_info;
2008 : :
2009 : : const struct rte_compressdev_capabilities *capa;
2010 : :
2011 : : /* Compressing with CompressDev */
2012 : : unsigned int zlib_compress =
2013 : 0 : (test_data->zlib_dir == ZLIB_ALL ||
2014 : : test_data->zlib_dir == ZLIB_COMPRESS);
2015 : : unsigned int zlib_decompress =
2016 : 0 : (test_data->zlib_dir == ZLIB_ALL ||
2017 : : test_data->zlib_dir == ZLIB_DECOMPRESS);
2018 : :
2019 : : struct test_private_arrays test_priv_data;
2020 : :
2021 : 0 : test_priv_data.uncomp_bufs = uncomp_bufs;
2022 : 0 : test_priv_data.comp_bufs = comp_bufs;
2023 : 0 : test_priv_data.ops = ops;
2024 : 0 : test_priv_data.ops_processed = ops_processed;
2025 : 0 : test_priv_data.priv_xforms = priv_xforms;
2026 : 0 : test_priv_data.compress_checksum = compress_checksum;
2027 : 0 : test_priv_data.compressed_data_size = compressed_data_size;
2028 : :
2029 : 0 : test_priv_data.stream = &stream;
2030 : 0 : test_priv_data.all_decomp_data = &all_decomp_data;
2031 : 0 : test_priv_data.decomp_produced_data_size = &decomp_produced_data_size;
2032 : :
2033 : 0 : test_priv_data.num_priv_xforms = 0; /* it's used for decompression only */
2034 : :
2035 : 0 : capa = rte_compressdev_capability_get(0, RTE_COMP_ALGO_DEFLATE);
2036 [ # # ]: 0 : if (capa == NULL) {
2037 : 0 : RTE_LOG(ERR, USER1,
2038 : : "Compress device does not support DEFLATE\n");
2039 : 0 : return -1;
2040 : : }
2041 : :
2042 : : /* Prepare the source mbufs with the data */
2043 : 0 : ret = test_setup_com_bufs(int_data, test_data, &test_priv_data);
2044 [ # # ]: 0 : if (ret < 0) {
2045 : : ret_status = -1;
2046 : 0 : goto exit;
2047 : : }
2048 : :
2049 : 0 : RTE_LOG(DEBUG, USER1, "<<< COMPRESSION >>>\n");
2050 : :
2051 : : /* COMPRESSION */
2052 : :
2053 : : /* Prepare output (destination) mbufs for compressed data */
2054 : 0 : ret = test_setup_output_bufs(
2055 : : OPERATION_COMPRESSION,
2056 : 0 : out_of_space == 1 && !zlib_compress,
2057 : : &test_priv_data,
2058 : : int_data,
2059 : : test_data,
2060 : : &compbuf_info);
2061 [ # # ]: 0 : if (ret < 0) {
2062 : : ret_status = -1;
2063 : 0 : goto exit;
2064 : : }
2065 : :
2066 : : /* Run compression */
2067 : 0 : ret = test_deflate_comp_run(int_data, test_data, &test_priv_data);
2068 [ # # ]: 0 : if (ret < 0) {
2069 : : ret_status = -1;
2070 : 0 : goto exit;
2071 : : }
2072 : :
2073 : 0 : ret = test_deflate_comp_finalize(int_data, test_data, &test_priv_data);
2074 [ # # ]: 0 : if (ret < 0) {
2075 : : ret_status = -1;
2076 : 0 : goto exit;
2077 [ # # ]: 0 : } else if (ret == 1) {
2078 : : ret_status = 0;
2079 : 0 : goto exit;
2080 [ # # ]: 0 : } else if (ret == 2) {
2081 : : ret_status = 1; /* some operation not supported */
2082 : 0 : goto exit;
2083 : : }
2084 : :
2085 : : /* DECOMPRESSION */
2086 : :
2087 : 0 : RTE_LOG(DEBUG, USER1, "<<< DECOMPRESSION >>>\n");
2088 : :
2089 : : /* Prepare output (destination) mbufs for decompressed data */
2090 : 0 : ret = test_setup_output_bufs(
2091 : : OPERATION_DECOMPRESSION,
2092 : 0 : out_of_space == 1 && !zlib_decompress,
2093 : : &test_priv_data,
2094 : : int_data,
2095 : : test_data,
2096 : : &decompbuf_info);
2097 [ # # ]: 0 : if (ret < 0) {
2098 : : ret_status = -1;
2099 : 0 : goto exit;
2100 : : }
2101 : :
2102 : : /* Run decompression */
2103 : 0 : ret = test_deflate_decomp_run(int_data, test_data, &test_priv_data);
2104 [ # # ]: 0 : if (ret < 0) {
2105 : : ret_status = -1;
2106 : 0 : goto exit;
2107 : : }
2108 : :
2109 [ # # ]: 0 : if (!zlib_decompress) {
2110 : 0 : next_step: /* next step for stateful decompression only */
2111 : 0 : ret = test_run_enqueue_dequeue(ops, ops_processed, num_bufs);
2112 [ # # ]: 0 : if (ret < 0) {
2113 : : ret_status = -1;
2114 : 0 : RTE_LOG(ERR, USER1,
2115 : : "Decompression: enqueue/dequeue operation failed\n");
2116 : : }
2117 : : }
2118 : :
2119 : 0 : ret = test_deflate_decomp_finalize(int_data, test_data, &test_priv_data);
2120 [ # # ]: 0 : if (ret < 0) {
2121 : : ret_status = -1;
2122 : 0 : goto exit;
2123 [ # # ]: 0 : } else if (ret == 1) {
2124 : : ret_status = 0;
2125 : 0 : goto exit;
2126 [ # # ]: 0 : } else if (ret == 2) {
2127 : 0 : goto next_step;
2128 : : }
2129 : :
2130 : : /* FINAL PROCESSING */
2131 : :
2132 : 0 : ret = test_results_validation(int_data, test_data, &test_priv_data);
2133 [ # # ]: 0 : if (ret < 0) {
2134 : : ret_status = -1;
2135 : 0 : goto exit;
2136 : : }
2137 : : ret_status = 0;
2138 : :
2139 : 0 : exit:
2140 : : /* Free resources */
2141 : :
2142 [ # # ]: 0 : if (stream != NULL)
2143 : 0 : rte_compressdev_stream_free(0, stream);
2144 : 0 : rte_free(all_decomp_data);
2145 : :
2146 : : /* Free compress private xforms */
2147 [ # # ]: 0 : for (i = 0; i < test_priv_data.num_priv_xforms; i++) {
2148 [ # # ]: 0 : if (priv_xforms[i] != NULL) {
2149 : 0 : rte_compressdev_private_xform_free(0, priv_xforms[i]);
2150 : 0 : priv_xforms[i] = NULL;
2151 : : }
2152 : : }
2153 [ # # ]: 0 : for (i = 0; i < num_bufs; i++) {
2154 : 0 : rte_pktmbuf_free(uncomp_bufs[i]);
2155 : 0 : rte_pktmbuf_free(comp_bufs[i]);
2156 : 0 : rte_comp_op_free(ops[i]);
2157 : 0 : rte_comp_op_free(ops_processed[i]);
2158 : : }
2159 : 0 : rte_free(contig_buf);
2160 : :
2161 : 0 : return ret_status;
2162 : : }
2163 : :
2164 : : static int
2165 : 0 : test_compressdev_deflate_stateless_fixed(void)
2166 : : {
2167 : : struct comp_testsuite_params *ts_params = &testsuite_params;
2168 : : uint16_t i;
2169 : : int ret;
2170 : : const struct rte_compressdev_capabilities *capab;
2171 : :
2172 : 0 : capab = rte_compressdev_capability_get(0, RTE_COMP_ALGO_DEFLATE);
2173 [ # # ]: 0 : TEST_ASSERT(capab != NULL, "Failed to retrieve device capabilities");
2174 : :
2175 [ # # ]: 0 : if ((capab->comp_feature_flags & RTE_COMP_FF_HUFFMAN_FIXED) == 0)
2176 : : return -ENOTSUP;
2177 : :
2178 : 0 : struct rte_comp_xform *compress_xform =
2179 : 0 : rte_malloc(NULL, sizeof(struct rte_comp_xform), 0);
2180 : :
2181 [ # # ]: 0 : if (compress_xform == NULL) {
2182 : 0 : RTE_LOG(ERR, USER1,
2183 : : "Compress xform could not be created\n");
2184 : : ret = TEST_FAILED;
2185 : 0 : goto exit;
2186 : : }
2187 : :
2188 : 0 : *compress_xform = *ts_params->def_comp_xform;
2189 : 0 : compress_xform->compress.deflate.huffman = RTE_COMP_HUFFMAN_FIXED;
2190 : :
2191 : 0 : struct interim_data_params int_data = {
2192 : : NULL,
2193 : : 1,
2194 : : NULL,
2195 : : &compress_xform,
2196 : : &ts_params->def_decomp_xform,
2197 : : 1
2198 : : };
2199 : :
2200 : 0 : struct test_data_params test_data = {
2201 : : .compress_state = RTE_COMP_OP_STATELESS,
2202 : : .decompress_state = RTE_COMP_OP_STATELESS,
2203 : : .buff_type = LB_BOTH,
2204 : : .zlib_dir = ZLIB_DECOMPRESS,
2205 : : .out_of_space = 0,
2206 : : .big_data = 0,
2207 : : .overflow = OVERFLOW_DISABLED,
2208 : : .ratio = RATIO_ENABLED
2209 : : };
2210 : :
2211 [ # # ]: 0 : for (i = 0; i < RTE_DIM(compress_test_bufs); i++) {
2212 : 0 : int_data.test_bufs = &compress_test_bufs[i];
2213 : 0 : int_data.buf_idx = &i;
2214 : :
2215 : : /* Compress with compressdev, decompress with Zlib */
2216 : 0 : test_data.zlib_dir = ZLIB_DECOMPRESS;
2217 : 0 : ret = test_deflate_comp_decomp(&int_data, &test_data);
2218 [ # # ]: 0 : if (ret < 0)
2219 : 0 : goto exit;
2220 : :
2221 : : /* Compress with Zlib, decompress with compressdev */
2222 : 0 : test_data.zlib_dir = ZLIB_COMPRESS;
2223 : 0 : ret = test_deflate_comp_decomp(&int_data, &test_data);
2224 [ # # ]: 0 : if (ret < 0)
2225 : 0 : goto exit;
2226 : : }
2227 : :
2228 : : ret = TEST_SUCCESS;
2229 : :
2230 : 0 : exit:
2231 : 0 : rte_free(compress_xform);
2232 : 0 : return ret;
2233 : : }
2234 : :
2235 : : static int
2236 : 0 : test_compressdev_deflate_stateless_dynamic(void)
2237 : : {
2238 : : struct comp_testsuite_params *ts_params = &testsuite_params;
2239 : : uint16_t i;
2240 : : int ret;
2241 : 0 : struct rte_comp_xform *compress_xform =
2242 : 0 : rte_malloc(NULL, sizeof(struct rte_comp_xform), 0);
2243 : :
2244 : : const struct rte_compressdev_capabilities *capab;
2245 : :
2246 : 0 : capab = rte_compressdev_capability_get(0, RTE_COMP_ALGO_DEFLATE);
2247 [ # # ]: 0 : TEST_ASSERT(capab != NULL, "Failed to retrieve device capabilities");
2248 : :
2249 [ # # ]: 0 : if ((capab->comp_feature_flags & RTE_COMP_FF_HUFFMAN_DYNAMIC) == 0)
2250 : : return -ENOTSUP;
2251 : :
2252 [ # # ]: 0 : if (compress_xform == NULL) {
2253 : 0 : RTE_LOG(ERR, USER1,
2254 : : "Compress xform could not be created\n");
2255 : : ret = TEST_FAILED;
2256 : 0 : goto exit;
2257 : : }
2258 : :
2259 : 0 : *compress_xform = *ts_params->def_comp_xform;
2260 : 0 : compress_xform->compress.deflate.huffman = RTE_COMP_HUFFMAN_DYNAMIC;
2261 : :
2262 : 0 : struct interim_data_params int_data = {
2263 : : NULL,
2264 : : 1,
2265 : : NULL,
2266 : : &compress_xform,
2267 : : &ts_params->def_decomp_xform,
2268 : : 1
2269 : : };
2270 : :
2271 : 0 : struct test_data_params test_data = {
2272 : : .compress_state = RTE_COMP_OP_STATELESS,
2273 : : .decompress_state = RTE_COMP_OP_STATELESS,
2274 : : .buff_type = LB_BOTH,
2275 : : .zlib_dir = ZLIB_DECOMPRESS,
2276 : : .out_of_space = 0,
2277 : : .big_data = 0,
2278 : : .overflow = OVERFLOW_DISABLED,
2279 : : .ratio = RATIO_ENABLED
2280 : : };
2281 : :
2282 [ # # ]: 0 : for (i = 0; i < RTE_DIM(compress_test_bufs); i++) {
2283 : 0 : int_data.test_bufs = &compress_test_bufs[i];
2284 : 0 : int_data.buf_idx = &i;
2285 : :
2286 : : /* Compress with compressdev, decompress with Zlib */
2287 : 0 : test_data.zlib_dir = ZLIB_DECOMPRESS;
2288 : 0 : ret = test_deflate_comp_decomp(&int_data, &test_data);
2289 [ # # ]: 0 : if (ret < 0)
2290 : 0 : goto exit;
2291 : :
2292 : : /* Compress with Zlib, decompress with compressdev */
2293 : 0 : test_data.zlib_dir = ZLIB_COMPRESS;
2294 : 0 : ret = test_deflate_comp_decomp(&int_data, &test_data);
2295 [ # # ]: 0 : if (ret < 0)
2296 : 0 : goto exit;
2297 : : }
2298 : :
2299 : : ret = TEST_SUCCESS;
2300 : :
2301 : 0 : exit:
2302 : 0 : rte_free(compress_xform);
2303 : 0 : return ret;
2304 : : }
2305 : :
2306 : : static int
2307 : 0 : test_compressdev_deflate_stateless_multi_op(void)
2308 : 0 : {
2309 : : struct comp_testsuite_params *ts_params = &testsuite_params;
2310 : : uint16_t num_bufs = RTE_DIM(compress_test_bufs);
2311 : : uint16_t buf_idx[num_bufs];
2312 : : uint16_t i;
2313 : : int ret;
2314 : :
2315 [ # # ]: 0 : for (i = 0; i < num_bufs; i++)
2316 : 0 : buf_idx[i] = i;
2317 : :
2318 : 0 : struct interim_data_params int_data = {
2319 : : compress_test_bufs,
2320 : : num_bufs,
2321 : : buf_idx,
2322 : : &ts_params->def_comp_xform,
2323 : : &ts_params->def_decomp_xform,
2324 : : 1
2325 : : };
2326 : :
2327 : 0 : struct test_data_params test_data = {
2328 : : .compress_state = RTE_COMP_OP_STATELESS,
2329 : : .decompress_state = RTE_COMP_OP_STATELESS,
2330 : : .buff_type = LB_BOTH,
2331 : : .zlib_dir = ZLIB_DECOMPRESS,
2332 : : .out_of_space = 0,
2333 : : .big_data = 0,
2334 : : .overflow = OVERFLOW_DISABLED,
2335 : : .ratio = RATIO_ENABLED
2336 : : };
2337 : :
2338 : : /* Compress with compressdev, decompress with Zlib */
2339 : : test_data.zlib_dir = ZLIB_DECOMPRESS;
2340 : 0 : ret = test_deflate_comp_decomp(&int_data, &test_data);
2341 [ # # ]: 0 : if (ret < 0)
2342 : : return ret;
2343 : :
2344 : : /* Compress with Zlib, decompress with compressdev */
2345 : 0 : test_data.zlib_dir = ZLIB_COMPRESS;
2346 : 0 : ret = test_deflate_comp_decomp(&int_data, &test_data);
2347 : : if (ret < 0)
2348 : : return ret;
2349 : :
2350 : : return TEST_SUCCESS;
2351 : : }
2352 : :
2353 : : static int
2354 : 0 : test_compressdev_deflate_stateless_multi_level(void)
2355 : : {
2356 : : struct comp_testsuite_params *ts_params = &testsuite_params;
2357 : : unsigned int level;
2358 : : uint16_t i;
2359 : : int ret;
2360 : 0 : struct rte_comp_xform *compress_xform =
2361 : 0 : rte_malloc(NULL, sizeof(struct rte_comp_xform), 0);
2362 : :
2363 [ # # ]: 0 : if (compress_xform == NULL) {
2364 : 0 : RTE_LOG(ERR, USER1,
2365 : : "Compress xform could not be created\n");
2366 : : ret = TEST_FAILED;
2367 : 0 : goto exit;
2368 : : }
2369 : :
2370 : 0 : *compress_xform = *ts_params->def_comp_xform;
2371 : :
2372 : 0 : struct interim_data_params int_data = {
2373 : : NULL,
2374 : : 1,
2375 : : NULL,
2376 : : &compress_xform,
2377 : : &ts_params->def_decomp_xform,
2378 : : 1
2379 : : };
2380 : :
2381 : 0 : struct test_data_params test_data = {
2382 : : .compress_state = RTE_COMP_OP_STATELESS,
2383 : : .decompress_state = RTE_COMP_OP_STATELESS,
2384 : : .buff_type = LB_BOTH,
2385 : : .zlib_dir = ZLIB_DECOMPRESS,
2386 : : .out_of_space = 0,
2387 : : .big_data = 0,
2388 : : .overflow = OVERFLOW_DISABLED,
2389 : : .ratio = RATIO_ENABLED
2390 : : };
2391 : :
2392 [ # # ]: 0 : for (i = 0; i < RTE_DIM(compress_test_bufs); i++) {
2393 : 0 : int_data.test_bufs = &compress_test_bufs[i];
2394 : 0 : int_data.buf_idx = &i;
2395 : :
2396 [ # # ]: 0 : for (level = RTE_COMP_LEVEL_MIN; level <= RTE_COMP_LEVEL_MAX;
2397 : 0 : level++) {
2398 : 0 : compress_xform->compress.level = level;
2399 : : /* Compress with compressdev, decompress with Zlib */
2400 : 0 : test_data.zlib_dir = ZLIB_DECOMPRESS;
2401 : 0 : ret = test_deflate_comp_decomp(&int_data, &test_data);
2402 [ # # ]: 0 : if (ret < 0)
2403 : 0 : goto exit;
2404 : : }
2405 : : }
2406 : :
2407 : : ret = TEST_SUCCESS;
2408 : :
2409 : 0 : exit:
2410 : 0 : rte_free(compress_xform);
2411 : 0 : return ret;
2412 : : }
2413 : :
2414 : : #define NUM_XFORMS 3
2415 : : static int
2416 : 0 : test_compressdev_deflate_stateless_multi_xform(void)
2417 : 0 : {
2418 : : struct comp_testsuite_params *ts_params = &testsuite_params;
2419 : : uint16_t num_bufs = NUM_XFORMS;
2420 : 0 : struct rte_comp_xform *compress_xforms[NUM_XFORMS] = {NULL};
2421 : 0 : struct rte_comp_xform *decompress_xforms[NUM_XFORMS] = {NULL};
2422 : : const char *test_buffers[NUM_XFORMS];
2423 : : uint16_t i;
2424 : : unsigned int level = RTE_COMP_LEVEL_MIN;
2425 : : uint16_t buf_idx[num_bufs];
2426 : : int ret;
2427 : :
2428 : : /* Create multiple xforms with various levels */
2429 [ # # ]: 0 : for (i = 0; i < NUM_XFORMS; i++) {
2430 : 0 : compress_xforms[i] = rte_malloc(NULL,
2431 : : sizeof(struct rte_comp_xform), 0);
2432 [ # # ]: 0 : if (compress_xforms[i] == NULL) {
2433 : 0 : RTE_LOG(ERR, USER1,
2434 : : "Compress xform could not be created\n");
2435 : : ret = TEST_FAILED;
2436 : 0 : goto exit;
2437 : : }
2438 : :
2439 : 0 : *compress_xforms[i] = *ts_params->def_comp_xform;
2440 : 0 : compress_xforms[i]->compress.level = level;
2441 : 0 : level++;
2442 : :
2443 : 0 : decompress_xforms[i] = rte_malloc(NULL,
2444 : : sizeof(struct rte_comp_xform), 0);
2445 [ # # ]: 0 : if (decompress_xforms[i] == NULL) {
2446 : 0 : RTE_LOG(ERR, USER1,
2447 : : "Decompress xform could not be created\n");
2448 : : ret = TEST_FAILED;
2449 : 0 : goto exit;
2450 : : }
2451 : :
2452 : 0 : *decompress_xforms[i] = *ts_params->def_decomp_xform;
2453 : : }
2454 : :
2455 [ # # ]: 0 : for (i = 0; i < NUM_XFORMS; i++) {
2456 : 0 : buf_idx[i] = 0;
2457 : : /* Use the same buffer in all sessions */
2458 : 0 : test_buffers[i] = compress_test_bufs[0];
2459 : : }
2460 : :
2461 : 0 : struct interim_data_params int_data = {
2462 : : test_buffers,
2463 : : num_bufs,
2464 : : buf_idx,
2465 : : compress_xforms,
2466 : : decompress_xforms,
2467 : : NUM_XFORMS
2468 : : };
2469 : :
2470 : 0 : struct test_data_params test_data = {
2471 : : .compress_state = RTE_COMP_OP_STATELESS,
2472 : : .decompress_state = RTE_COMP_OP_STATELESS,
2473 : : .buff_type = LB_BOTH,
2474 : : .zlib_dir = ZLIB_DECOMPRESS,
2475 : : .out_of_space = 0,
2476 : : .big_data = 0,
2477 : : .overflow = OVERFLOW_DISABLED,
2478 : : .ratio = RATIO_ENABLED
2479 : : };
2480 : :
2481 : : /* Compress with compressdev, decompress with Zlib */
2482 : 0 : ret = test_deflate_comp_decomp(&int_data, &test_data);
2483 : : if (ret < 0)
2484 : : goto exit;
2485 : :
2486 : : ret = TEST_SUCCESS;
2487 : :
2488 : 0 : exit:
2489 [ # # ]: 0 : for (i = 0; i < NUM_XFORMS; i++) {
2490 : 0 : rte_free(compress_xforms[i]);
2491 : 0 : rte_free(decompress_xforms[i]);
2492 : : }
2493 : :
2494 : 0 : return ret;
2495 : : }
2496 : :
2497 : : static int
2498 : 0 : test_compressdev_deflate_stateless_sgl(void)
2499 : : {
2500 : : struct comp_testsuite_params *ts_params = &testsuite_params;
2501 : : uint16_t i;
2502 : : int ret;
2503 : : const struct rte_compressdev_capabilities *capab;
2504 : :
2505 : 0 : capab = rte_compressdev_capability_get(0, RTE_COMP_ALGO_DEFLATE);
2506 [ # # ]: 0 : TEST_ASSERT(capab != NULL, "Failed to retrieve device capabilities");
2507 : :
2508 [ # # ]: 0 : if ((capab->comp_feature_flags & RTE_COMP_FF_OOP_SGL_IN_SGL_OUT) == 0)
2509 : : return -ENOTSUP;
2510 : :
2511 : 0 : struct interim_data_params int_data = {
2512 : : NULL,
2513 : : 1,
2514 : : NULL,
2515 : : &ts_params->def_comp_xform,
2516 : : &ts_params->def_decomp_xform,
2517 : : 1
2518 : : };
2519 : :
2520 : 0 : struct test_data_params test_data = {
2521 : : .compress_state = RTE_COMP_OP_STATELESS,
2522 : : .decompress_state = RTE_COMP_OP_STATELESS,
2523 : : .buff_type = SGL_BOTH,
2524 : : .zlib_dir = ZLIB_DECOMPRESS,
2525 : : .out_of_space = 0,
2526 : : .big_data = 0,
2527 : : .overflow = OVERFLOW_DISABLED,
2528 : : .ratio = RATIO_ENABLED
2529 : : };
2530 : :
2531 [ # # ]: 0 : for (i = 0; i < RTE_DIM(compress_test_bufs); i++) {
2532 : 0 : int_data.test_bufs = &compress_test_bufs[i];
2533 : 0 : int_data.buf_idx = &i;
2534 : :
2535 : : /* Compress with compressdev, decompress with Zlib */
2536 : 0 : test_data.zlib_dir = ZLIB_DECOMPRESS;
2537 : 0 : ret = test_deflate_comp_decomp(&int_data, &test_data);
2538 [ # # ]: 0 : if (ret < 0)
2539 : 0 : return ret;
2540 : :
2541 : : /* Compress with Zlib, decompress with compressdev */
2542 : 0 : test_data.zlib_dir = ZLIB_COMPRESS;
2543 : 0 : ret = test_deflate_comp_decomp(&int_data, &test_data);
2544 [ # # ]: 0 : if (ret < 0)
2545 : 0 : return ret;
2546 : :
2547 [ # # ]: 0 : if (capab->comp_feature_flags & RTE_COMP_FF_OOP_SGL_IN_LB_OUT) {
2548 : : /* Compress with compressdev, decompress with Zlib */
2549 : 0 : test_data.zlib_dir = ZLIB_DECOMPRESS;
2550 : 0 : test_data.buff_type = SGL_TO_LB;
2551 : 0 : ret = test_deflate_comp_decomp(&int_data, &test_data);
2552 [ # # ]: 0 : if (ret < 0)
2553 : 0 : return ret;
2554 : :
2555 : : /* Compress with Zlib, decompress with compressdev */
2556 : 0 : test_data.zlib_dir = ZLIB_COMPRESS;
2557 : 0 : test_data.buff_type = SGL_TO_LB;
2558 : 0 : ret = test_deflate_comp_decomp(&int_data, &test_data);
2559 [ # # ]: 0 : if (ret < 0)
2560 : 0 : return ret;
2561 : : }
2562 : :
2563 [ # # ]: 0 : if (capab->comp_feature_flags & RTE_COMP_FF_OOP_LB_IN_SGL_OUT) {
2564 : : /* Compress with compressdev, decompress with Zlib */
2565 : 0 : test_data.zlib_dir = ZLIB_DECOMPRESS;
2566 : 0 : test_data.buff_type = LB_TO_SGL;
2567 : 0 : ret = test_deflate_comp_decomp(&int_data, &test_data);
2568 [ # # ]: 0 : if (ret < 0)
2569 : 0 : return ret;
2570 : :
2571 : : /* Compress with Zlib, decompress with compressdev */
2572 : 0 : test_data.zlib_dir = ZLIB_COMPRESS;
2573 : 0 : test_data.buff_type = LB_TO_SGL;
2574 : 0 : ret = test_deflate_comp_decomp(&int_data, &test_data);
2575 [ # # ]: 0 : if (ret < 0)
2576 : 0 : return ret;
2577 : : }
2578 : : }
2579 : :
2580 : : return TEST_SUCCESS;
2581 : : }
2582 : :
2583 : : static int
2584 : 0 : test_compressdev_deflate_stateless_checksum(void)
2585 : : {
2586 : : struct comp_testsuite_params *ts_params = &testsuite_params;
2587 : : uint16_t i;
2588 : : int ret;
2589 : : const struct rte_compressdev_capabilities *capab;
2590 : :
2591 : 0 : capab = rte_compressdev_capability_get(0, RTE_COMP_ALGO_DEFLATE);
2592 [ # # ]: 0 : TEST_ASSERT(capab != NULL, "Failed to retrieve device capabilities");
2593 : :
2594 : : /* Check if driver supports any checksum */
2595 : 0 : if ((capab->comp_feature_flags & RTE_COMP_FF_CRC32_CHECKSUM) == 0 &&
2596 : : (capab->comp_feature_flags &
2597 [ # # ]: 0 : RTE_COMP_FF_ADLER32_CHECKSUM) == 0 &&
2598 : : (capab->comp_feature_flags &
2599 : : RTE_COMP_FF_CRC32_ADLER32_CHECKSUM) == 0)
2600 : : return -ENOTSUP;
2601 : :
2602 : 0 : struct rte_comp_xform *compress_xform =
2603 : 0 : rte_malloc(NULL, sizeof(struct rte_comp_xform), 0);
2604 [ # # ]: 0 : if (compress_xform == NULL) {
2605 : 0 : RTE_LOG(ERR, USER1, "Compress xform could not be created\n");
2606 : 0 : return TEST_FAILED;
2607 : : }
2608 : :
2609 : 0 : *compress_xform = *ts_params->def_comp_xform;
2610 : :
2611 : 0 : struct rte_comp_xform *decompress_xform =
2612 : 0 : rte_malloc(NULL, sizeof(struct rte_comp_xform), 0);
2613 [ # # ]: 0 : if (decompress_xform == NULL) {
2614 : 0 : RTE_LOG(ERR, USER1, "Decompress xform could not be created\n");
2615 : 0 : rte_free(compress_xform);
2616 : 0 : return TEST_FAILED;
2617 : : }
2618 : :
2619 : 0 : *decompress_xform = *ts_params->def_decomp_xform;
2620 : :
2621 : 0 : struct interim_data_params int_data = {
2622 : : NULL,
2623 : : 1,
2624 : : NULL,
2625 : : &compress_xform,
2626 : : &decompress_xform,
2627 : : 1
2628 : : };
2629 : :
2630 : 0 : struct test_data_params test_data = {
2631 : : .compress_state = RTE_COMP_OP_STATELESS,
2632 : : .decompress_state = RTE_COMP_OP_STATELESS,
2633 : : .buff_type = LB_BOTH,
2634 : : .zlib_dir = ZLIB_DECOMPRESS,
2635 : : .out_of_space = 0,
2636 : : .big_data = 0,
2637 : : .overflow = OVERFLOW_DISABLED,
2638 : : .ratio = RATIO_ENABLED
2639 : : };
2640 : :
2641 : : /* Check if driver supports crc32 checksum and test */
2642 [ # # ]: 0 : if ((capab->comp_feature_flags & RTE_COMP_FF_CRC32_CHECKSUM)) {
2643 : 0 : compress_xform->compress.chksum = RTE_COMP_CHECKSUM_CRC32;
2644 : 0 : decompress_xform->decompress.chksum = RTE_COMP_CHECKSUM_CRC32;
2645 : :
2646 [ # # ]: 0 : for (i = 0; i < RTE_DIM(compress_test_bufs); i++) {
2647 : : /* Compress with compressdev, decompress with Zlib */
2648 : 0 : int_data.test_bufs = &compress_test_bufs[i];
2649 : 0 : int_data.buf_idx = &i;
2650 : :
2651 : : /* Generate zlib checksum and test against selected
2652 : : * drivers decompression checksum
2653 : : */
2654 : 0 : test_data.zlib_dir = ZLIB_COMPRESS;
2655 : 0 : ret = test_deflate_comp_decomp(&int_data, &test_data);
2656 [ # # ]: 0 : if (ret < 0)
2657 : 0 : goto exit;
2658 : :
2659 : : /* Generate compression and decompression
2660 : : * checksum of selected driver
2661 : : */
2662 : 0 : test_data.zlib_dir = ZLIB_NONE;
2663 : 0 : ret = test_deflate_comp_decomp(&int_data, &test_data);
2664 [ # # ]: 0 : if (ret < 0)
2665 : 0 : goto exit;
2666 : : }
2667 : : }
2668 : :
2669 : : /* Check if driver supports adler32 checksum and test */
2670 [ # # ]: 0 : if ((capab->comp_feature_flags & RTE_COMP_FF_ADLER32_CHECKSUM)) {
2671 : 0 : compress_xform->compress.chksum = RTE_COMP_CHECKSUM_ADLER32;
2672 : 0 : decompress_xform->decompress.chksum = RTE_COMP_CHECKSUM_ADLER32;
2673 : :
2674 [ # # ]: 0 : for (i = 0; i < RTE_DIM(compress_test_bufs); i++) {
2675 : 0 : int_data.test_bufs = &compress_test_bufs[i];
2676 : 0 : int_data.buf_idx = &i;
2677 : :
2678 : : /* Generate zlib checksum and test against selected
2679 : : * drivers decompression checksum
2680 : : */
2681 : 0 : test_data.zlib_dir = ZLIB_COMPRESS;
2682 : 0 : ret = test_deflate_comp_decomp(&int_data, &test_data);
2683 [ # # ]: 0 : if (ret < 0)
2684 : 0 : goto exit;
2685 : : /* Generate compression and decompression
2686 : : * checksum of selected driver
2687 : : */
2688 : 0 : test_data.zlib_dir = ZLIB_NONE;
2689 : 0 : ret = test_deflate_comp_decomp(&int_data, &test_data);
2690 [ # # ]: 0 : if (ret < 0)
2691 : 0 : goto exit;
2692 : : }
2693 : : }
2694 : :
2695 : : /* Check if driver supports combined crc and adler checksum and test */
2696 [ # # ]: 0 : if ((capab->comp_feature_flags & RTE_COMP_FF_CRC32_ADLER32_CHECKSUM)) {
2697 : 0 : compress_xform->compress.chksum =
2698 : : RTE_COMP_CHECKSUM_CRC32_ADLER32;
2699 : 0 : decompress_xform->decompress.chksum =
2700 : : RTE_COMP_CHECKSUM_CRC32_ADLER32;
2701 : :
2702 [ # # ]: 0 : for (i = 0; i < RTE_DIM(compress_test_bufs); i++) {
2703 : 0 : int_data.test_bufs = &compress_test_bufs[i];
2704 : 0 : int_data.buf_idx = &i;
2705 : :
2706 : : /* Generate compression and decompression
2707 : : * checksum of selected driver
2708 : : */
2709 : 0 : test_data.zlib_dir = ZLIB_NONE;
2710 : 0 : ret = test_deflate_comp_decomp(&int_data, &test_data);
2711 [ # # ]: 0 : if (ret < 0)
2712 : 0 : goto exit;
2713 : : }
2714 : : }
2715 : :
2716 : : ret = TEST_SUCCESS;
2717 : :
2718 : 0 : exit:
2719 : 0 : rte_free(compress_xform);
2720 : 0 : rte_free(decompress_xform);
2721 : 0 : return ret;
2722 : : }
2723 : :
2724 : : static int
2725 : 0 : test_compressdev_out_of_space_buffer(void)
2726 : : {
2727 : : struct comp_testsuite_params *ts_params = &testsuite_params;
2728 : : int ret;
2729 : : uint16_t i;
2730 : : const struct rte_compressdev_capabilities *capab;
2731 : :
2732 : 0 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
2733 : :
2734 : 0 : capab = rte_compressdev_capability_get(0, RTE_COMP_ALGO_DEFLATE);
2735 [ # # ]: 0 : TEST_ASSERT(capab != NULL, "Failed to retrieve device capabilities");
2736 : :
2737 [ # # ]: 0 : if ((capab->comp_feature_flags & RTE_COMP_FF_HUFFMAN_FIXED) == 0)
2738 : : return -ENOTSUP;
2739 : :
2740 : 0 : struct interim_data_params int_data = {
2741 : : &compress_test_bufs[0],
2742 : : 1,
2743 : : &i,
2744 : : &ts_params->def_comp_xform,
2745 : : &ts_params->def_decomp_xform,
2746 : : 1
2747 : : };
2748 : :
2749 : 0 : struct test_data_params test_data = {
2750 : : .compress_state = RTE_COMP_OP_STATELESS,
2751 : : .decompress_state = RTE_COMP_OP_STATELESS,
2752 : : .buff_type = LB_BOTH,
2753 : : .zlib_dir = ZLIB_DECOMPRESS,
2754 : : .out_of_space = 1, /* run out-of-space test */
2755 : : .big_data = 0,
2756 : : .overflow = OVERFLOW_DISABLED,
2757 : : .ratio = RATIO_ENABLED
2758 : : };
2759 : : /* Compress with compressdev, decompress with Zlib */
2760 : : test_data.zlib_dir = ZLIB_DECOMPRESS;
2761 : 0 : ret = test_deflate_comp_decomp(&int_data, &test_data);
2762 [ # # ]: 0 : if (ret < 0)
2763 : 0 : goto exit;
2764 : :
2765 : : /* Compress with Zlib, decompress with compressdev */
2766 : 0 : test_data.zlib_dir = ZLIB_COMPRESS;
2767 : 0 : ret = test_deflate_comp_decomp(&int_data, &test_data);
2768 [ # # ]: 0 : if (ret < 0)
2769 : 0 : goto exit;
2770 : :
2771 [ # # ]: 0 : if (capab->comp_feature_flags & RTE_COMP_FF_OOP_SGL_IN_SGL_OUT) {
2772 : : /* Compress with compressdev, decompress with Zlib */
2773 : 0 : test_data.zlib_dir = ZLIB_DECOMPRESS;
2774 : 0 : test_data.buff_type = SGL_BOTH;
2775 : 0 : ret = test_deflate_comp_decomp(&int_data, &test_data);
2776 [ # # ]: 0 : if (ret < 0)
2777 : 0 : goto exit;
2778 : :
2779 : : /* Compress with Zlib, decompress with compressdev */
2780 : 0 : test_data.zlib_dir = ZLIB_COMPRESS;
2781 : 0 : test_data.buff_type = SGL_BOTH;
2782 : 0 : ret = test_deflate_comp_decomp(&int_data, &test_data);
2783 : : if (ret < 0)
2784 : : goto exit;
2785 : : }
2786 : :
2787 : : ret = TEST_SUCCESS;
2788 : :
2789 : : exit:
2790 : : return ret;
2791 : : }
2792 : :
2793 : : static int
2794 : 0 : test_compressdev_deflate_stateless_dynamic_big(void)
2795 : : {
2796 : : struct comp_testsuite_params *ts_params = &testsuite_params;
2797 : 0 : uint16_t i = 0;
2798 : : int ret;
2799 : : unsigned int j;
2800 : : const struct rte_compressdev_capabilities *capab;
2801 : 0 : char *test_buffer = NULL;
2802 : :
2803 : 0 : capab = rte_compressdev_capability_get(0, RTE_COMP_ALGO_DEFLATE);
2804 [ # # ]: 0 : TEST_ASSERT(capab != NULL, "Failed to retrieve device capabilities");
2805 : :
2806 [ # # ]: 0 : if ((capab->comp_feature_flags & RTE_COMP_FF_HUFFMAN_DYNAMIC) == 0)
2807 : : return -ENOTSUP;
2808 : :
2809 [ # # ]: 0 : if ((capab->comp_feature_flags & RTE_COMP_FF_OOP_SGL_IN_SGL_OUT) == 0)
2810 : : return -ENOTSUP;
2811 : :
2812 : 0 : test_buffer = rte_malloc(NULL, BIG_DATA_TEST_SIZE, 0);
2813 [ # # ]: 0 : if (test_buffer == NULL) {
2814 : 0 : RTE_LOG(ERR, USER1,
2815 : : "Can't allocate buffer for big-data\n");
2816 : 0 : return TEST_FAILED;
2817 : : }
2818 : :
2819 : 0 : struct interim_data_params int_data = {
2820 : : (const char * const *)&test_buffer,
2821 : : 1,
2822 : : &i,
2823 : : &ts_params->def_comp_xform,
2824 : : &ts_params->def_decomp_xform,
2825 : : 1
2826 : : };
2827 : :
2828 : 0 : struct test_data_params test_data = {
2829 : : .compress_state = RTE_COMP_OP_STATELESS,
2830 : : .decompress_state = RTE_COMP_OP_STATELESS,
2831 : : .buff_type = SGL_BOTH,
2832 : : .zlib_dir = ZLIB_DECOMPRESS,
2833 : : .out_of_space = 0,
2834 : : .big_data = 1,
2835 : : .overflow = OVERFLOW_DISABLED,
2836 : : .ratio = RATIO_DISABLED
2837 : : };
2838 : :
2839 : 0 : ts_params->def_comp_xform->compress.deflate.huffman =
2840 : : RTE_COMP_HUFFMAN_DYNAMIC;
2841 : :
2842 : : /* fill the buffer with data based on rand. data */
2843 : 0 : srand(BIG_DATA_TEST_SIZE);
2844 [ # # ]: 0 : for (j = 0; j < BIG_DATA_TEST_SIZE - 1; ++j)
2845 : 0 : test_buffer[j] = (uint8_t)(rand() % ((uint8_t)-1)) | 1;
2846 : 0 : test_buffer[BIG_DATA_TEST_SIZE - 1] = 0;
2847 : :
2848 : : /* Compress with compressdev, decompress with Zlib */
2849 : 0 : test_data.zlib_dir = ZLIB_DECOMPRESS;
2850 : 0 : ret = test_deflate_comp_decomp(&int_data, &test_data);
2851 [ # # ]: 0 : if (ret < 0)
2852 : 0 : goto exit;
2853 : :
2854 : : /* Compress with Zlib, decompress with compressdev */
2855 : 0 : test_data.zlib_dir = ZLIB_COMPRESS;
2856 : 0 : ret = test_deflate_comp_decomp(&int_data, &test_data);
2857 : : if (ret < 0)
2858 : : goto exit;
2859 : :
2860 : : ret = TEST_SUCCESS;
2861 : :
2862 : 0 : exit:
2863 : 0 : ts_params->def_comp_xform->compress.deflate.huffman =
2864 : : RTE_COMP_HUFFMAN_DEFAULT;
2865 : 0 : rte_free(test_buffer);
2866 : 0 : return ret;
2867 : : }
2868 : :
2869 : : static int
2870 : 0 : test_compressdev_deflate_stateful_decomp(void)
2871 : : {
2872 : : struct comp_testsuite_params *ts_params = &testsuite_params;
2873 : : int ret;
2874 : : uint16_t i;
2875 : : const struct rte_compressdev_capabilities *capab;
2876 : :
2877 : 0 : capab = rte_compressdev_capability_get(0, RTE_COMP_ALGO_DEFLATE);
2878 [ # # ]: 0 : TEST_ASSERT(capab != NULL, "Failed to retrieve device capabilities");
2879 : :
2880 [ # # ]: 0 : if (!(capab->comp_feature_flags & RTE_COMP_FF_STATEFUL_DECOMPRESSION))
2881 : : return -ENOTSUP;
2882 : :
2883 : 0 : struct interim_data_params int_data = {
2884 : : &compress_test_bufs[0],
2885 : : 1,
2886 : : &i,
2887 : : &ts_params->def_comp_xform,
2888 : : &ts_params->def_decomp_xform,
2889 : : 1
2890 : : };
2891 : :
2892 : 0 : struct test_data_params test_data = {
2893 : : .compress_state = RTE_COMP_OP_STATELESS,
2894 : : .decompress_state = RTE_COMP_OP_STATEFUL,
2895 : : .buff_type = LB_BOTH,
2896 : : .zlib_dir = ZLIB_COMPRESS,
2897 : : .out_of_space = 0,
2898 : : .big_data = 0,
2899 : : .decompress_output_block_size = 2000,
2900 : : .decompress_steps_max = 4,
2901 : : .overflow = OVERFLOW_DISABLED,
2902 : : .ratio = RATIO_ENABLED
2903 : : };
2904 : :
2905 : : /* Compress with Zlib, decompress with compressdev */
2906 [ # # ]: 0 : if (test_deflate_comp_decomp(&int_data, &test_data) < 0) {
2907 : : ret = TEST_FAILED;
2908 : 0 : goto exit;
2909 : : }
2910 : :
2911 [ # # ]: 0 : if (capab->comp_feature_flags & RTE_COMP_FF_OOP_SGL_IN_SGL_OUT) {
2912 : : /* Now test with SGL buffers */
2913 : 0 : test_data.buff_type = SGL_BOTH;
2914 [ # # ]: 0 : if (test_deflate_comp_decomp(&int_data, &test_data) < 0) {
2915 : : ret = TEST_FAILED;
2916 : 0 : goto exit;
2917 : : }
2918 : : }
2919 : :
2920 : : ret = TEST_SUCCESS;
2921 : :
2922 : : exit:
2923 : : return ret;
2924 : : }
2925 : :
2926 : : static int
2927 : 0 : test_compressdev_deflate_stateful_decomp_checksum(void)
2928 : : {
2929 : : struct comp_testsuite_params *ts_params = &testsuite_params;
2930 : : int ret;
2931 : : uint16_t i;
2932 : : const struct rte_compressdev_capabilities *capab;
2933 : :
2934 : 0 : capab = rte_compressdev_capability_get(0, RTE_COMP_ALGO_DEFLATE);
2935 [ # # ]: 0 : TEST_ASSERT(capab != NULL, "Failed to retrieve device capabilities");
2936 : :
2937 [ # # ]: 0 : if (!(capab->comp_feature_flags & RTE_COMP_FF_STATEFUL_DECOMPRESSION))
2938 : : return -ENOTSUP;
2939 : :
2940 : : /* Check if driver supports any checksum */
2941 [ # # ]: 0 : if (!(capab->comp_feature_flags &
2942 : : (RTE_COMP_FF_CRC32_CHECKSUM | RTE_COMP_FF_ADLER32_CHECKSUM |
2943 : : RTE_COMP_FF_CRC32_ADLER32_CHECKSUM)))
2944 : : return -ENOTSUP;
2945 : :
2946 : 0 : struct rte_comp_xform *compress_xform =
2947 : 0 : rte_malloc(NULL, sizeof(struct rte_comp_xform), 0);
2948 [ # # ]: 0 : if (compress_xform == NULL) {
2949 : 0 : RTE_LOG(ERR, USER1, "Compress xform could not be created\n");
2950 : 0 : return TEST_FAILED;
2951 : : }
2952 : :
2953 : 0 : *compress_xform = *ts_params->def_comp_xform;
2954 : :
2955 : 0 : struct rte_comp_xform *decompress_xform =
2956 : 0 : rte_malloc(NULL, sizeof(struct rte_comp_xform), 0);
2957 [ # # ]: 0 : if (decompress_xform == NULL) {
2958 : 0 : RTE_LOG(ERR, USER1, "Decompress xform could not be created\n");
2959 : 0 : rte_free(compress_xform);
2960 : 0 : return TEST_FAILED;
2961 : : }
2962 : :
2963 : 0 : *decompress_xform = *ts_params->def_decomp_xform;
2964 : :
2965 : 0 : struct interim_data_params int_data = {
2966 : : &compress_test_bufs[0],
2967 : : 1,
2968 : : &i,
2969 : : &compress_xform,
2970 : : &decompress_xform,
2971 : : 1
2972 : : };
2973 : :
2974 : 0 : struct test_data_params test_data = {
2975 : : .compress_state = RTE_COMP_OP_STATELESS,
2976 : : .decompress_state = RTE_COMP_OP_STATEFUL,
2977 : : .buff_type = LB_BOTH,
2978 : : .zlib_dir = ZLIB_COMPRESS,
2979 : : .out_of_space = 0,
2980 : : .big_data = 0,
2981 : : .decompress_output_block_size = 2000,
2982 : : .decompress_steps_max = 4,
2983 : : .overflow = OVERFLOW_DISABLED,
2984 : : .ratio = RATIO_ENABLED
2985 : : };
2986 : :
2987 : : /* Check if driver supports crc32 checksum and test */
2988 [ # # ]: 0 : if (capab->comp_feature_flags & RTE_COMP_FF_CRC32_CHECKSUM) {
2989 : 0 : compress_xform->compress.chksum = RTE_COMP_CHECKSUM_CRC32;
2990 : 0 : decompress_xform->decompress.chksum = RTE_COMP_CHECKSUM_CRC32;
2991 : : /* Compress with Zlib, decompress with compressdev */
2992 : : test_data.buff_type = LB_BOTH;
2993 [ # # ]: 0 : if (test_deflate_comp_decomp(&int_data, &test_data) < 0) {
2994 : : ret = TEST_FAILED;
2995 : 0 : goto exit;
2996 : : }
2997 [ # # ]: 0 : if (capab->comp_feature_flags &
2998 : : RTE_COMP_FF_OOP_SGL_IN_SGL_OUT) {
2999 : : /* Now test with SGL buffers */
3000 : 0 : test_data.buff_type = SGL_BOTH;
3001 [ # # ]: 0 : if (test_deflate_comp_decomp(&int_data,
3002 : : &test_data) < 0) {
3003 : : ret = TEST_FAILED;
3004 : 0 : goto exit;
3005 : : }
3006 : : }
3007 : : }
3008 : :
3009 : : /* Check if driver supports adler32 checksum and test */
3010 [ # # ]: 0 : if (capab->comp_feature_flags & RTE_COMP_FF_ADLER32_CHECKSUM) {
3011 : 0 : compress_xform->compress.chksum = RTE_COMP_CHECKSUM_ADLER32;
3012 : 0 : decompress_xform->decompress.chksum = RTE_COMP_CHECKSUM_ADLER32;
3013 : : /* Compress with Zlib, decompress with compressdev */
3014 : 0 : test_data.buff_type = LB_BOTH;
3015 [ # # ]: 0 : if (test_deflate_comp_decomp(&int_data, &test_data) < 0) {
3016 : : ret = TEST_FAILED;
3017 : 0 : goto exit;
3018 : : }
3019 [ # # ]: 0 : if (capab->comp_feature_flags &
3020 : : RTE_COMP_FF_OOP_SGL_IN_SGL_OUT) {
3021 : : /* Now test with SGL buffers */
3022 : 0 : test_data.buff_type = SGL_BOTH;
3023 [ # # ]: 0 : if (test_deflate_comp_decomp(&int_data,
3024 : : &test_data) < 0) {
3025 : : ret = TEST_FAILED;
3026 : 0 : goto exit;
3027 : : }
3028 : : }
3029 : : }
3030 : :
3031 : : /* Check if driver supports combined crc and adler checksum and test */
3032 [ # # ]: 0 : if (capab->comp_feature_flags & RTE_COMP_FF_CRC32_ADLER32_CHECKSUM) {
3033 : 0 : compress_xform->compress.chksum =
3034 : : RTE_COMP_CHECKSUM_CRC32_ADLER32;
3035 : 0 : decompress_xform->decompress.chksum =
3036 : : RTE_COMP_CHECKSUM_CRC32_ADLER32;
3037 : : /* Zlib doesn't support combined checksum */
3038 : 0 : test_data.zlib_dir = ZLIB_NONE;
3039 : : /* Compress stateless, decompress stateful with compressdev */
3040 : 0 : test_data.buff_type = LB_BOTH;
3041 [ # # ]: 0 : if (test_deflate_comp_decomp(&int_data, &test_data) < 0) {
3042 : : ret = TEST_FAILED;
3043 : 0 : goto exit;
3044 : : }
3045 [ # # ]: 0 : if (capab->comp_feature_flags &
3046 : : RTE_COMP_FF_OOP_SGL_IN_SGL_OUT) {
3047 : : /* Now test with SGL buffers */
3048 : 0 : test_data.buff_type = SGL_BOTH;
3049 [ # # ]: 0 : if (test_deflate_comp_decomp(&int_data,
3050 : : &test_data) < 0) {
3051 : : ret = TEST_FAILED;
3052 : 0 : goto exit;
3053 : : }
3054 : : }
3055 : : }
3056 : :
3057 : : ret = TEST_SUCCESS;
3058 : :
3059 : 0 : exit:
3060 : 0 : rte_free(compress_xform);
3061 : 0 : rte_free(decompress_xform);
3062 : 0 : return ret;
3063 : : }
3064 : :
3065 : : static const struct rte_memzone *
3066 : 0 : make_memzone(const char *name, size_t size)
3067 : : {
3068 : 0 : unsigned int socket_id = rte_socket_id();
3069 : : char mz_name[RTE_MEMZONE_NAMESIZE];
3070 : : const struct rte_memzone *memzone;
3071 : :
3072 : : snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "%s_%u", name, socket_id);
3073 : 0 : memzone = rte_memzone_lookup(mz_name);
3074 [ # # # # ]: 0 : if (memzone != NULL && memzone->len != size) {
3075 : 0 : rte_memzone_free(memzone);
3076 : : memzone = NULL;
3077 : : }
3078 [ # # ]: 0 : if (memzone == NULL) {
3079 : 0 : memzone = rte_memzone_reserve_aligned(mz_name, size, socket_id,
3080 : : RTE_MEMZONE_IOVA_CONTIG, RTE_CACHE_LINE_SIZE);
3081 [ # # ]: 0 : if (memzone == NULL)
3082 : 0 : RTE_LOG(ERR, USER1, "Can't allocate memory zone %s",
3083 : : mz_name);
3084 : : }
3085 : 0 : return memzone;
3086 : : }
3087 : :
3088 : : static int
3089 : 0 : test_compressdev_external_mbufs(void)
3090 : : {
3091 : : struct comp_testsuite_params *ts_params = &testsuite_params;
3092 : : size_t data_len = 0;
3093 : : uint16_t i;
3094 : : int ret = TEST_FAILED;
3095 : :
3096 [ # # ]: 0 : for (i = 0; i < RTE_DIM(compress_test_bufs); i++)
3097 : 0 : data_len = RTE_MAX(data_len, strlen(compress_test_bufs[i]) + 1);
3098 : :
3099 : 0 : struct interim_data_params int_data = {
3100 : : NULL,
3101 : : 1,
3102 : : NULL,
3103 : : &ts_params->def_comp_xform,
3104 : : &ts_params->def_decomp_xform,
3105 : : 1
3106 : : };
3107 : :
3108 : 0 : struct test_data_params test_data = {
3109 : : .compress_state = RTE_COMP_OP_STATELESS,
3110 : : .decompress_state = RTE_COMP_OP_STATELESS,
3111 : : .buff_type = LB_BOTH,
3112 : : .zlib_dir = ZLIB_DECOMPRESS,
3113 : : .out_of_space = 0,
3114 : : .big_data = 0,
3115 : : .use_external_mbufs = 1,
3116 : : .inbuf_data_size = data_len,
3117 : 0 : .inbuf_memzone = make_memzone("inbuf", data_len),
3118 : 0 : .compbuf_memzone = make_memzone("compbuf", data_len *
3119 : : COMPRESS_BUF_SIZE_RATIO),
3120 : 0 : .uncompbuf_memzone = make_memzone("decompbuf", data_len),
3121 : : .overflow = OVERFLOW_DISABLED
3122 : : };
3123 : :
3124 [ # # ]: 0 : for (i = 0; i < RTE_DIM(compress_test_bufs); i++) {
3125 : : /* prepare input data */
3126 : 0 : data_len = strlen(compress_test_bufs[i]) + 1;
3127 [ # # ]: 0 : rte_memcpy(test_data.inbuf_memzone->addr, compress_test_bufs[i],
3128 : : data_len);
3129 : 0 : test_data.inbuf_data_size = data_len;
3130 : 0 : int_data.buf_idx = &i;
3131 : :
3132 : : /* Compress with compressdev, decompress with Zlib */
3133 : 0 : test_data.zlib_dir = ZLIB_DECOMPRESS;
3134 [ # # ]: 0 : if (test_deflate_comp_decomp(&int_data, &test_data) < 0)
3135 : 0 : goto exit;
3136 : :
3137 : : /* Compress with Zlib, decompress with compressdev */
3138 : 0 : test_data.zlib_dir = ZLIB_COMPRESS;
3139 [ # # ]: 0 : if (test_deflate_comp_decomp(&int_data, &test_data) < 0)
3140 : 0 : goto exit;
3141 : : }
3142 : :
3143 : : ret = TEST_SUCCESS;
3144 : :
3145 : 0 : exit:
3146 : 0 : rte_memzone_free(test_data.inbuf_memzone);
3147 : 0 : rte_memzone_free(test_data.compbuf_memzone);
3148 : 0 : rte_memzone_free(test_data.uncompbuf_memzone);
3149 : 0 : return ret;
3150 : : }
3151 : :
3152 : : static int
3153 : 0 : test_compressdev_deflate_stateless_fixed_oos_recoverable(void)
3154 : : {
3155 : : struct comp_testsuite_params *ts_params = &testsuite_params;
3156 : : uint16_t i;
3157 : : int ret;
3158 : : int comp_result;
3159 : : const struct rte_compressdev_capabilities *capab;
3160 : :
3161 : 0 : capab = rte_compressdev_capability_get(0, RTE_COMP_ALGO_DEFLATE);
3162 [ # # ]: 0 : TEST_ASSERT(capab != NULL, "Failed to retrieve device capabilities");
3163 : :
3164 [ # # ]: 0 : if ((capab->comp_feature_flags & RTE_COMP_FF_HUFFMAN_FIXED) == 0)
3165 : : return -ENOTSUP;
3166 : :
3167 : 0 : struct rte_comp_xform *compress_xform =
3168 : 0 : rte_malloc(NULL, sizeof(struct rte_comp_xform), 0);
3169 : :
3170 [ # # ]: 0 : if (compress_xform == NULL) {
3171 : 0 : RTE_LOG(ERR, USER1,
3172 : : "Compress xform could not be created\n");
3173 : : ret = TEST_FAILED;
3174 : 0 : goto exit;
3175 : : }
3176 : :
3177 : 0 : *compress_xform = *ts_params->def_comp_xform;
3178 : 0 : compress_xform->compress.deflate.huffman = RTE_COMP_HUFFMAN_FIXED;
3179 : :
3180 : 0 : struct interim_data_params int_data = {
3181 : : NULL,
3182 : : 1,
3183 : : NULL,
3184 : : &compress_xform,
3185 : : &ts_params->def_decomp_xform,
3186 : : 1
3187 : : };
3188 : :
3189 : 0 : struct test_data_params test_data = {
3190 : : .compress_state = RTE_COMP_OP_STATELESS,
3191 : : .decompress_state = RTE_COMP_OP_STATELESS,
3192 : : .buff_type = LB_BOTH,
3193 : : .zlib_dir = ZLIB_DECOMPRESS,
3194 : : .out_of_space = 0,
3195 : : .big_data = 0,
3196 : : .overflow = OVERFLOW_ENABLED,
3197 : : .ratio = RATIO_ENABLED
3198 : : };
3199 : :
3200 [ # # ]: 0 : for (i = 0; i < RTE_DIM(compress_test_bufs); i++) {
3201 : 0 : int_data.test_bufs = &compress_test_bufs[i];
3202 : 0 : int_data.buf_idx = &i;
3203 : :
3204 : : /* Compress with compressdev, decompress with Zlib */
3205 : 0 : test_data.zlib_dir = ZLIB_DECOMPRESS;
3206 : 0 : comp_result = test_deflate_comp_decomp(&int_data, &test_data);
3207 [ # # ]: 0 : if (comp_result < 0) {
3208 : : ret = TEST_FAILED;
3209 : 0 : goto exit;
3210 [ # # ]: 0 : } else if (comp_result > 0) {
3211 : : ret = -ENOTSUP;
3212 : 0 : goto exit;
3213 : : }
3214 : :
3215 : : /* Compress with Zlib, decompress with compressdev */
3216 : 0 : test_data.zlib_dir = ZLIB_COMPRESS;
3217 : 0 : comp_result = test_deflate_comp_decomp(&int_data, &test_data);
3218 [ # # ]: 0 : if (comp_result < 0) {
3219 : : ret = TEST_FAILED;
3220 : 0 : goto exit;
3221 [ # # ]: 0 : } else if (comp_result > 0) {
3222 : : ret = -ENOTSUP;
3223 : 0 : goto exit;
3224 : : }
3225 : : }
3226 : :
3227 : : ret = TEST_SUCCESS;
3228 : :
3229 : 0 : exit:
3230 : 0 : rte_free(compress_xform);
3231 : 0 : return ret;
3232 : : }
3233 : :
3234 : : static int
3235 : 0 : test_compressdev_deflate_im_buffers_LB_1op(void)
3236 : : {
3237 : : struct comp_testsuite_params *ts_params = &testsuite_params;
3238 : 0 : uint16_t i = 0;
3239 : : int ret = TEST_SUCCESS;
3240 : : int j;
3241 : : const struct rte_compressdev_capabilities *capab;
3242 : 0 : char *test_buffer = NULL;
3243 : :
3244 : 0 : capab = rte_compressdev_capability_get(0, RTE_COMP_ALGO_DEFLATE);
3245 [ # # ]: 0 : TEST_ASSERT(capab != NULL, "Failed to retrieve device capabilities");
3246 : :
3247 [ # # ]: 0 : if ((capab->comp_feature_flags & RTE_COMP_FF_HUFFMAN_DYNAMIC) == 0)
3248 : : return -ENOTSUP;
3249 : :
3250 [ # # ]: 0 : if ((capab->comp_feature_flags & RTE_COMP_FF_OOP_SGL_IN_SGL_OUT) == 0)
3251 : : return -ENOTSUP;
3252 : :
3253 : 0 : test_buffer = rte_malloc(NULL, IM_BUF_DATA_TEST_SIZE_LB, 0);
3254 [ # # ]: 0 : if (test_buffer == NULL) {
3255 : 0 : RTE_LOG(ERR, USER1,
3256 : : "Can't allocate buffer for 'im buffer' test\n");
3257 : 0 : return TEST_FAILED;
3258 : : }
3259 : :
3260 : 0 : struct interim_data_params int_data = {
3261 : : (const char * const *)&test_buffer,
3262 : : 1,
3263 : : &i,
3264 : : &ts_params->def_comp_xform,
3265 : : &ts_params->def_decomp_xform,
3266 : : 1
3267 : : };
3268 : :
3269 : 0 : struct test_data_params test_data = {
3270 : : .compress_state = RTE_COMP_OP_STATELESS,
3271 : : .decompress_state = RTE_COMP_OP_STATELESS,
3272 : : /* must be LB to SGL,
3273 : : * input LB buffer reaches its maximum,
3274 : : * if ratio 1.3 than another mbuf must be
3275 : : * created and attached
3276 : : */
3277 : : .buff_type = LB_BOTH,
3278 : : .zlib_dir = ZLIB_NONE,
3279 : : .out_of_space = 0,
3280 : : .big_data = 1,
3281 : : .overflow = OVERFLOW_DISABLED,
3282 : : .ratio = RATIO_DISABLED
3283 : : };
3284 : :
3285 : 0 : ts_params->def_comp_xform->compress.deflate.huffman =
3286 : : RTE_COMP_HUFFMAN_DYNAMIC;
3287 : :
3288 : : /* fill the buffer with data based on rand. data */
3289 : 0 : srand(IM_BUF_DATA_TEST_SIZE_LB);
3290 [ # # ]: 0 : for (j = 0; j < IM_BUF_DATA_TEST_SIZE_LB - 1; ++j)
3291 : 0 : test_buffer[j] = (uint8_t)(rand() % ((uint8_t)-1)) | 1;
3292 : :
3293 : : /* Compress with compressdev, decompress with compressdev */
3294 [ # # ]: 0 : if (test_deflate_comp_decomp(&int_data, &test_data) < 0) {
3295 : : ret = TEST_FAILED;
3296 : 0 : goto end;
3297 : : }
3298 : :
3299 : 0 : end:
3300 : 0 : ts_params->def_comp_xform->compress.deflate.huffman =
3301 : : RTE_COMP_HUFFMAN_DEFAULT;
3302 : 0 : rte_free(test_buffer);
3303 : 0 : return ret;
3304 : : }
3305 : :
3306 : : static int
3307 : 0 : test_compressdev_deflate_im_buffers_LB_2ops_first(void)
3308 : : {
3309 : : struct comp_testsuite_params *ts_params = &testsuite_params;
3310 : 0 : uint16_t i = 0;
3311 : : int ret = TEST_SUCCESS;
3312 : : int j;
3313 : : const struct rte_compressdev_capabilities *capab;
3314 : : char *test_buffer = NULL;
3315 : : const char *test_buffers[2];
3316 : :
3317 : 0 : capab = rte_compressdev_capability_get(0, RTE_COMP_ALGO_DEFLATE);
3318 [ # # ]: 0 : TEST_ASSERT(capab != NULL, "Failed to retrieve device capabilities");
3319 : :
3320 [ # # ]: 0 : if ((capab->comp_feature_flags & RTE_COMP_FF_HUFFMAN_DYNAMIC) == 0)
3321 : : return -ENOTSUP;
3322 : :
3323 [ # # ]: 0 : if ((capab->comp_feature_flags & RTE_COMP_FF_OOP_SGL_IN_SGL_OUT) == 0)
3324 : : return -ENOTSUP;
3325 : :
3326 : 0 : test_buffer = rte_malloc(NULL, IM_BUF_DATA_TEST_SIZE_LB, 0);
3327 [ # # ]: 0 : if (test_buffer == NULL) {
3328 : 0 : RTE_LOG(ERR, USER1,
3329 : : "Can't allocate buffer for 'im buffer' test\n");
3330 : 0 : return TEST_FAILED;
3331 : : }
3332 : :
3333 : 0 : test_buffers[0] = test_buffer;
3334 : 0 : test_buffers[1] = compress_test_bufs[0];
3335 : :
3336 : 0 : struct interim_data_params int_data = {
3337 : : (const char * const *)test_buffers,
3338 : : 2,
3339 : : &i,
3340 : : &ts_params->def_comp_xform,
3341 : : &ts_params->def_decomp_xform,
3342 : : 1
3343 : : };
3344 : :
3345 : 0 : struct test_data_params test_data = {
3346 : : .compress_state = RTE_COMP_OP_STATELESS,
3347 : : .decompress_state = RTE_COMP_OP_STATELESS,
3348 : : .buff_type = LB_BOTH,
3349 : : .zlib_dir = ZLIB_NONE,
3350 : : .out_of_space = 0,
3351 : : .big_data = 1,
3352 : : .overflow = OVERFLOW_DISABLED,
3353 : : .ratio = RATIO_DISABLED
3354 : : };
3355 : :
3356 : 0 : ts_params->def_comp_xform->compress.deflate.huffman =
3357 : : RTE_COMP_HUFFMAN_DYNAMIC;
3358 : :
3359 : : /* fill the buffer with data based on rand. data */
3360 : 0 : srand(IM_BUF_DATA_TEST_SIZE_LB);
3361 [ # # ]: 0 : for (j = 0; j < IM_BUF_DATA_TEST_SIZE_LB - 1; ++j)
3362 : 0 : test_buffer[j] = (uint8_t)(rand() % ((uint8_t)-1)) | 1;
3363 : :
3364 : : /* Compress with compressdev, decompress with compressdev */
3365 [ # # ]: 0 : if (test_deflate_comp_decomp(&int_data, &test_data) < 0) {
3366 : : ret = TEST_FAILED;
3367 : 0 : goto end;
3368 : : }
3369 : :
3370 : 0 : end:
3371 : 0 : ts_params->def_comp_xform->compress.deflate.huffman =
3372 : : RTE_COMP_HUFFMAN_DEFAULT;
3373 : 0 : rte_free(test_buffer);
3374 : 0 : return ret;
3375 : : }
3376 : :
3377 : : static int
3378 : 0 : test_compressdev_deflate_im_buffers_LB_2ops_second(void)
3379 : : {
3380 : : struct comp_testsuite_params *ts_params = &testsuite_params;
3381 : 0 : uint16_t i = 0;
3382 : : int ret = TEST_SUCCESS;
3383 : : int j;
3384 : : const struct rte_compressdev_capabilities *capab;
3385 : : char *test_buffer = NULL;
3386 : : const char *test_buffers[2];
3387 : :
3388 : 0 : capab = rte_compressdev_capability_get(0, RTE_COMP_ALGO_DEFLATE);
3389 [ # # ]: 0 : TEST_ASSERT(capab != NULL, "Failed to retrieve device capabilities");
3390 : :
3391 [ # # ]: 0 : if ((capab->comp_feature_flags & RTE_COMP_FF_HUFFMAN_DYNAMIC) == 0)
3392 : : return -ENOTSUP;
3393 : :
3394 [ # # ]: 0 : if ((capab->comp_feature_flags & RTE_COMP_FF_OOP_SGL_IN_SGL_OUT) == 0)
3395 : : return -ENOTSUP;
3396 : :
3397 : 0 : test_buffer = rte_malloc(NULL, IM_BUF_DATA_TEST_SIZE_LB, 0);
3398 [ # # ]: 0 : if (test_buffer == NULL) {
3399 : 0 : RTE_LOG(ERR, USER1,
3400 : : "Can't allocate buffer for 'im buffer' test\n");
3401 : 0 : return TEST_FAILED;
3402 : : }
3403 : :
3404 : 0 : test_buffers[0] = compress_test_bufs[0];
3405 : 0 : test_buffers[1] = test_buffer;
3406 : :
3407 : 0 : struct interim_data_params int_data = {
3408 : : (const char * const *)test_buffers,
3409 : : 2,
3410 : : &i,
3411 : : &ts_params->def_comp_xform,
3412 : : &ts_params->def_decomp_xform,
3413 : : 1
3414 : : };
3415 : :
3416 : 0 : struct test_data_params test_data = {
3417 : : .compress_state = RTE_COMP_OP_STATELESS,
3418 : : .decompress_state = RTE_COMP_OP_STATELESS,
3419 : : .buff_type = LB_BOTH,
3420 : : .zlib_dir = ZLIB_NONE,
3421 : : .out_of_space = 0,
3422 : : .big_data = 1,
3423 : : .overflow = OVERFLOW_DISABLED,
3424 : : .ratio = RATIO_DISABLED
3425 : : };
3426 : :
3427 : 0 : ts_params->def_comp_xform->compress.deflate.huffman =
3428 : : RTE_COMP_HUFFMAN_DYNAMIC;
3429 : :
3430 : : /* fill the buffer with data based on rand. data */
3431 : 0 : srand(IM_BUF_DATA_TEST_SIZE_LB);
3432 [ # # ]: 0 : for (j = 0; j < IM_BUF_DATA_TEST_SIZE_LB - 1; ++j)
3433 : 0 : test_buffer[j] = (uint8_t)(rand() % ((uint8_t)-1)) | 1;
3434 : :
3435 : : /* Compress with compressdev, decompress with compressdev */
3436 [ # # ]: 0 : if (test_deflate_comp_decomp(&int_data, &test_data) < 0) {
3437 : : ret = TEST_FAILED;
3438 : 0 : goto end;
3439 : : }
3440 : :
3441 : 0 : end:
3442 : 0 : ts_params->def_comp_xform->compress.deflate.huffman =
3443 : : RTE_COMP_HUFFMAN_DEFAULT;
3444 : 0 : rte_free(test_buffer);
3445 : 0 : return ret;
3446 : : }
3447 : :
3448 : : static int
3449 : 0 : test_compressdev_deflate_im_buffers_LB_3ops(void)
3450 : : {
3451 : : struct comp_testsuite_params *ts_params = &testsuite_params;
3452 : 0 : uint16_t i = 0;
3453 : : int ret = TEST_SUCCESS;
3454 : : int j;
3455 : : const struct rte_compressdev_capabilities *capab;
3456 : : char *test_buffer = NULL;
3457 : : const char *test_buffers[3];
3458 : :
3459 : 0 : capab = rte_compressdev_capability_get(0, RTE_COMP_ALGO_DEFLATE);
3460 [ # # ]: 0 : TEST_ASSERT(capab != NULL, "Failed to retrieve device capabilities");
3461 : :
3462 [ # # ]: 0 : if ((capab->comp_feature_flags & RTE_COMP_FF_HUFFMAN_DYNAMIC) == 0)
3463 : : return -ENOTSUP;
3464 : :
3465 [ # # ]: 0 : if ((capab->comp_feature_flags & RTE_COMP_FF_OOP_SGL_IN_SGL_OUT) == 0)
3466 : : return -ENOTSUP;
3467 : :
3468 : 0 : test_buffer = rte_malloc(NULL, IM_BUF_DATA_TEST_SIZE_LB, 0);
3469 [ # # ]: 0 : if (test_buffer == NULL) {
3470 : 0 : RTE_LOG(ERR, USER1,
3471 : : "Can't allocate buffer for 'im buffer' test\n");
3472 : 0 : return TEST_FAILED;
3473 : : }
3474 : :
3475 : 0 : test_buffers[0] = compress_test_bufs[0];
3476 : 0 : test_buffers[1] = test_buffer;
3477 : 0 : test_buffers[2] = compress_test_bufs[1];
3478 : :
3479 : 0 : struct interim_data_params int_data = {
3480 : : (const char * const *)test_buffers,
3481 : : 3,
3482 : : &i,
3483 : : &ts_params->def_comp_xform,
3484 : : &ts_params->def_decomp_xform,
3485 : : 1
3486 : : };
3487 : :
3488 : 0 : struct test_data_params test_data = {
3489 : : .compress_state = RTE_COMP_OP_STATELESS,
3490 : : .decompress_state = RTE_COMP_OP_STATELESS,
3491 : : .buff_type = LB_BOTH,
3492 : : .zlib_dir = ZLIB_NONE,
3493 : : .out_of_space = 0,
3494 : : .big_data = 1,
3495 : : .overflow = OVERFLOW_DISABLED,
3496 : : .ratio = RATIO_DISABLED
3497 : : };
3498 : :
3499 : 0 : ts_params->def_comp_xform->compress.deflate.huffman =
3500 : : RTE_COMP_HUFFMAN_DYNAMIC;
3501 : :
3502 : : /* fill the buffer with data based on rand. data */
3503 : 0 : srand(IM_BUF_DATA_TEST_SIZE_LB);
3504 [ # # ]: 0 : for (j = 0; j < IM_BUF_DATA_TEST_SIZE_LB - 1; ++j)
3505 : 0 : test_buffer[j] = (uint8_t)(rand() % ((uint8_t)-1)) | 1;
3506 : :
3507 : : /* Compress with compressdev, decompress with compressdev */
3508 [ # # ]: 0 : if (test_deflate_comp_decomp(&int_data, &test_data) < 0) {
3509 : : ret = TEST_FAILED;
3510 : 0 : goto end;
3511 : : }
3512 : :
3513 : 0 : end:
3514 : 0 : ts_params->def_comp_xform->compress.deflate.huffman =
3515 : : RTE_COMP_HUFFMAN_DEFAULT;
3516 : 0 : rte_free(test_buffer);
3517 : 0 : return ret;
3518 : : }
3519 : :
3520 : : static int
3521 : 0 : test_compressdev_deflate_im_buffers_LB_4ops(void)
3522 : : {
3523 : : struct comp_testsuite_params *ts_params = &testsuite_params;
3524 : 0 : uint16_t i = 0;
3525 : : int ret = TEST_SUCCESS;
3526 : : int j;
3527 : : const struct rte_compressdev_capabilities *capab;
3528 : : char *test_buffer = NULL;
3529 : : const char *test_buffers[4];
3530 : :
3531 : 0 : capab = rte_compressdev_capability_get(0, RTE_COMP_ALGO_DEFLATE);
3532 [ # # ]: 0 : TEST_ASSERT(capab != NULL, "Failed to retrieve device capabilities");
3533 : :
3534 [ # # ]: 0 : if ((capab->comp_feature_flags & RTE_COMP_FF_HUFFMAN_DYNAMIC) == 0)
3535 : : return -ENOTSUP;
3536 : :
3537 [ # # ]: 0 : if ((capab->comp_feature_flags & RTE_COMP_FF_OOP_SGL_IN_SGL_OUT) == 0)
3538 : : return -ENOTSUP;
3539 : :
3540 : 0 : test_buffer = rte_malloc(NULL, IM_BUF_DATA_TEST_SIZE_LB, 0);
3541 [ # # ]: 0 : if (test_buffer == NULL) {
3542 : 0 : RTE_LOG(ERR, USER1,
3543 : : "Can't allocate buffer for 'im buffer' test\n");
3544 : 0 : return TEST_FAILED;
3545 : : }
3546 : :
3547 : 0 : test_buffers[0] = compress_test_bufs[0];
3548 : 0 : test_buffers[1] = test_buffer;
3549 : 0 : test_buffers[2] = compress_test_bufs[1];
3550 : 0 : test_buffers[3] = test_buffer;
3551 : :
3552 : 0 : struct interim_data_params int_data = {
3553 : : (const char * const *)test_buffers,
3554 : : 4,
3555 : : &i,
3556 : : &ts_params->def_comp_xform,
3557 : : &ts_params->def_decomp_xform,
3558 : : 1
3559 : : };
3560 : :
3561 : 0 : struct test_data_params test_data = {
3562 : : .compress_state = RTE_COMP_OP_STATELESS,
3563 : : .decompress_state = RTE_COMP_OP_STATELESS,
3564 : : .buff_type = LB_BOTH,
3565 : : .zlib_dir = ZLIB_NONE,
3566 : : .out_of_space = 0,
3567 : : .big_data = 1,
3568 : : .overflow = OVERFLOW_DISABLED,
3569 : : .ratio = RATIO_DISABLED
3570 : : };
3571 : :
3572 : 0 : ts_params->def_comp_xform->compress.deflate.huffman =
3573 : : RTE_COMP_HUFFMAN_DYNAMIC;
3574 : :
3575 : : /* fill the buffer with data based on rand. data */
3576 : 0 : srand(IM_BUF_DATA_TEST_SIZE_LB);
3577 [ # # ]: 0 : for (j = 0; j < IM_BUF_DATA_TEST_SIZE_LB - 1; ++j)
3578 : 0 : test_buffer[j] = (uint8_t)(rand() % ((uint8_t)-1)) | 1;
3579 : :
3580 : : /* Compress with compressdev, decompress with compressdev */
3581 [ # # ]: 0 : if (test_deflate_comp_decomp(&int_data, &test_data) < 0) {
3582 : : ret = TEST_FAILED;
3583 : 0 : goto end;
3584 : : }
3585 : :
3586 : 0 : end:
3587 : 0 : ts_params->def_comp_xform->compress.deflate.huffman =
3588 : : RTE_COMP_HUFFMAN_DEFAULT;
3589 : 0 : rte_free(test_buffer);
3590 : 0 : return ret;
3591 : : }
3592 : :
3593 : :
3594 : : static int
3595 : 0 : test_compressdev_deflate_im_buffers_SGL_1op(void)
3596 : : {
3597 : : struct comp_testsuite_params *ts_params = &testsuite_params;
3598 : 0 : uint16_t i = 0;
3599 : : int ret = TEST_SUCCESS;
3600 : : int j;
3601 : : const struct rte_compressdev_capabilities *capab;
3602 : 0 : char *test_buffer = NULL;
3603 : :
3604 : 0 : capab = rte_compressdev_capability_get(0, RTE_COMP_ALGO_DEFLATE);
3605 [ # # ]: 0 : TEST_ASSERT(capab != NULL, "Failed to retrieve device capabilities");
3606 : :
3607 [ # # ]: 0 : if ((capab->comp_feature_flags & RTE_COMP_FF_HUFFMAN_DYNAMIC) == 0)
3608 : : return -ENOTSUP;
3609 : :
3610 [ # # ]: 0 : if ((capab->comp_feature_flags & RTE_COMP_FF_OOP_SGL_IN_SGL_OUT) == 0)
3611 : : return -ENOTSUP;
3612 : :
3613 : 0 : test_buffer = rte_malloc(NULL, IM_BUF_DATA_TEST_SIZE_SGL, 0);
3614 [ # # ]: 0 : if (test_buffer == NULL) {
3615 : 0 : RTE_LOG(ERR, USER1,
3616 : : "Can't allocate buffer for big-data\n");
3617 : 0 : return TEST_FAILED;
3618 : : }
3619 : :
3620 : 0 : struct interim_data_params int_data = {
3621 : : (const char * const *)&test_buffer,
3622 : : 1,
3623 : : &i,
3624 : : &ts_params->def_comp_xform,
3625 : : &ts_params->def_decomp_xform,
3626 : : 1
3627 : : };
3628 : :
3629 : 0 : struct test_data_params test_data = {
3630 : : .compress_state = RTE_COMP_OP_STATELESS,
3631 : : .decompress_state = RTE_COMP_OP_STATELESS,
3632 : : .buff_type = SGL_BOTH,
3633 : : .zlib_dir = ZLIB_NONE,
3634 : : .out_of_space = 0,
3635 : : .big_data = 1,
3636 : : .overflow = OVERFLOW_DISABLED,
3637 : : .ratio = RATIO_DISABLED
3638 : : };
3639 : :
3640 : 0 : ts_params->def_comp_xform->compress.deflate.huffman =
3641 : : RTE_COMP_HUFFMAN_DYNAMIC;
3642 : :
3643 : : /* fill the buffer with data based on rand. data */
3644 : 0 : srand(IM_BUF_DATA_TEST_SIZE_SGL);
3645 [ # # ]: 0 : for (j = 0; j < IM_BUF_DATA_TEST_SIZE_SGL - 1; ++j)
3646 : 0 : test_buffer[j] = (uint8_t)(rand() % ((uint8_t)-1)) | 1;
3647 : :
3648 : : /* Compress with compressdev, decompress with compressdev */
3649 [ # # ]: 0 : if (test_deflate_comp_decomp(&int_data, &test_data) < 0) {
3650 : : ret = TEST_FAILED;
3651 : 0 : goto end;
3652 : : }
3653 : :
3654 : 0 : end:
3655 : 0 : ts_params->def_comp_xform->compress.deflate.huffman =
3656 : : RTE_COMP_HUFFMAN_DEFAULT;
3657 : 0 : rte_free(test_buffer);
3658 : 0 : return ret;
3659 : : }
3660 : :
3661 : : static int
3662 : 0 : test_compressdev_deflate_im_buffers_SGL_2ops_first(void)
3663 : : {
3664 : : struct comp_testsuite_params *ts_params = &testsuite_params;
3665 : 0 : uint16_t i = 0;
3666 : : int ret = TEST_SUCCESS;
3667 : : int j;
3668 : : const struct rte_compressdev_capabilities *capab;
3669 : : char *test_buffer = NULL;
3670 : : const char *test_buffers[2];
3671 : :
3672 : 0 : capab = rte_compressdev_capability_get(0, RTE_COMP_ALGO_DEFLATE);
3673 [ # # ]: 0 : TEST_ASSERT(capab != NULL, "Failed to retrieve device capabilities");
3674 : :
3675 [ # # ]: 0 : if ((capab->comp_feature_flags & RTE_COMP_FF_HUFFMAN_DYNAMIC) == 0)
3676 : : return -ENOTSUP;
3677 : :
3678 [ # # ]: 0 : if ((capab->comp_feature_flags & RTE_COMP_FF_OOP_SGL_IN_SGL_OUT) == 0)
3679 : : return -ENOTSUP;
3680 : :
3681 : 0 : test_buffer = rte_malloc(NULL, IM_BUF_DATA_TEST_SIZE_SGL, 0);
3682 [ # # ]: 0 : if (test_buffer == NULL) {
3683 : 0 : RTE_LOG(ERR, USER1,
3684 : : "Can't allocate buffer for big-data\n");
3685 : 0 : return TEST_FAILED;
3686 : : }
3687 : :
3688 : 0 : test_buffers[0] = test_buffer;
3689 : 0 : test_buffers[1] = compress_test_bufs[0];
3690 : :
3691 : 0 : struct interim_data_params int_data = {
3692 : : (const char * const *)test_buffers,
3693 : : 2,
3694 : : &i,
3695 : : &ts_params->def_comp_xform,
3696 : : &ts_params->def_decomp_xform,
3697 : : 1
3698 : : };
3699 : :
3700 : 0 : struct test_data_params test_data = {
3701 : : .compress_state = RTE_COMP_OP_STATELESS,
3702 : : .decompress_state = RTE_COMP_OP_STATELESS,
3703 : : .buff_type = SGL_BOTH,
3704 : : .zlib_dir = ZLIB_NONE,
3705 : : .out_of_space = 0,
3706 : : .big_data = 1,
3707 : : .overflow = OVERFLOW_DISABLED,
3708 : : .ratio = RATIO_DISABLED
3709 : : };
3710 : :
3711 : 0 : ts_params->def_comp_xform->compress.deflate.huffman =
3712 : : RTE_COMP_HUFFMAN_DYNAMIC;
3713 : :
3714 : : /* fill the buffer with data based on rand. data */
3715 : 0 : srand(IM_BUF_DATA_TEST_SIZE_SGL);
3716 [ # # ]: 0 : for (j = 0; j < IM_BUF_DATA_TEST_SIZE_SGL - 1; ++j)
3717 : 0 : test_buffer[j] = (uint8_t)(rand() % ((uint8_t)-1)) | 1;
3718 : :
3719 : : /* Compress with compressdev, decompress with compressdev */
3720 [ # # ]: 0 : if (test_deflate_comp_decomp(&int_data, &test_data) < 0) {
3721 : : ret = TEST_FAILED;
3722 : 0 : goto end;
3723 : : }
3724 : :
3725 : 0 : end:
3726 : 0 : ts_params->def_comp_xform->compress.deflate.huffman =
3727 : : RTE_COMP_HUFFMAN_DEFAULT;
3728 : 0 : rte_free(test_buffer);
3729 : 0 : return ret;
3730 : : }
3731 : :
3732 : : static int
3733 : 0 : test_compressdev_deflate_im_buffers_SGL_2ops_second(void)
3734 : : {
3735 : : struct comp_testsuite_params *ts_params = &testsuite_params;
3736 : 0 : uint16_t i = 0;
3737 : : int ret = TEST_SUCCESS;
3738 : : int j;
3739 : : const struct rte_compressdev_capabilities *capab;
3740 : : char *test_buffer = NULL;
3741 : : const char *test_buffers[2];
3742 : :
3743 : 0 : capab = rte_compressdev_capability_get(0, RTE_COMP_ALGO_DEFLATE);
3744 [ # # ]: 0 : TEST_ASSERT(capab != NULL, "Failed to retrieve device capabilities");
3745 : :
3746 [ # # ]: 0 : if ((capab->comp_feature_flags & RTE_COMP_FF_HUFFMAN_DYNAMIC) == 0)
3747 : : return -ENOTSUP;
3748 : :
3749 [ # # ]: 0 : if ((capab->comp_feature_flags & RTE_COMP_FF_OOP_SGL_IN_SGL_OUT) == 0)
3750 : : return -ENOTSUP;
3751 : :
3752 : 0 : test_buffer = rte_malloc(NULL, IM_BUF_DATA_TEST_SIZE_SGL, 0);
3753 [ # # ]: 0 : if (test_buffer == NULL) {
3754 : 0 : RTE_LOG(ERR, USER1,
3755 : : "Can't allocate buffer for big-data\n");
3756 : 0 : return TEST_FAILED;
3757 : : }
3758 : :
3759 : 0 : test_buffers[0] = compress_test_bufs[0];
3760 : 0 : test_buffers[1] = test_buffer;
3761 : :
3762 : 0 : struct interim_data_params int_data = {
3763 : : (const char * const *)test_buffers,
3764 : : 2,
3765 : : &i,
3766 : : &ts_params->def_comp_xform,
3767 : : &ts_params->def_decomp_xform,
3768 : : 1
3769 : : };
3770 : :
3771 : 0 : struct test_data_params test_data = {
3772 : : .compress_state = RTE_COMP_OP_STATELESS,
3773 : : .decompress_state = RTE_COMP_OP_STATELESS,
3774 : : .buff_type = SGL_BOTH,
3775 : : .zlib_dir = ZLIB_NONE,
3776 : : .out_of_space = 0,
3777 : : .big_data = 1,
3778 : : .overflow = OVERFLOW_DISABLED,
3779 : : .ratio = RATIO_DISABLED
3780 : : };
3781 : :
3782 : 0 : ts_params->def_comp_xform->compress.deflate.huffman =
3783 : : RTE_COMP_HUFFMAN_DYNAMIC;
3784 : :
3785 : : /* fill the buffer with data based on rand. data */
3786 : 0 : srand(IM_BUF_DATA_TEST_SIZE_SGL);
3787 [ # # ]: 0 : for (j = 0; j < IM_BUF_DATA_TEST_SIZE_SGL - 1; ++j)
3788 : 0 : test_buffer[j] = (uint8_t)(rand() % ((uint8_t)-1)) | 1;
3789 : :
3790 : : /* Compress with compressdev, decompress with compressdev */
3791 [ # # ]: 0 : if (test_deflate_comp_decomp(&int_data, &test_data) < 0) {
3792 : : ret = TEST_FAILED;
3793 : 0 : goto end;
3794 : : }
3795 : :
3796 : 0 : end:
3797 : 0 : ts_params->def_comp_xform->compress.deflate.huffman =
3798 : : RTE_COMP_HUFFMAN_DEFAULT;
3799 : 0 : rte_free(test_buffer);
3800 : 0 : return ret;
3801 : : }
3802 : :
3803 : : static int
3804 : 0 : test_compressdev_deflate_im_buffers_SGL_3ops(void)
3805 : : {
3806 : : struct comp_testsuite_params *ts_params = &testsuite_params;
3807 : 0 : uint16_t i = 0;
3808 : : int ret = TEST_SUCCESS;
3809 : : int j;
3810 : : const struct rte_compressdev_capabilities *capab;
3811 : : char *test_buffer = NULL;
3812 : : const char *test_buffers[3];
3813 : :
3814 : 0 : capab = rte_compressdev_capability_get(0, RTE_COMP_ALGO_DEFLATE);
3815 [ # # ]: 0 : TEST_ASSERT(capab != NULL, "Failed to retrieve device capabilities");
3816 : :
3817 [ # # ]: 0 : if ((capab->comp_feature_flags & RTE_COMP_FF_HUFFMAN_DYNAMIC) == 0)
3818 : : return -ENOTSUP;
3819 : :
3820 [ # # ]: 0 : if ((capab->comp_feature_flags & RTE_COMP_FF_OOP_SGL_IN_SGL_OUT) == 0)
3821 : : return -ENOTSUP;
3822 : :
3823 : 0 : test_buffer = rte_malloc(NULL, IM_BUF_DATA_TEST_SIZE_SGL, 0);
3824 [ # # ]: 0 : if (test_buffer == NULL) {
3825 : 0 : RTE_LOG(ERR, USER1,
3826 : : "Can't allocate buffer for big-data\n");
3827 : 0 : return TEST_FAILED;
3828 : : }
3829 : :
3830 : 0 : test_buffers[0] = compress_test_bufs[0];
3831 : 0 : test_buffers[1] = test_buffer;
3832 : 0 : test_buffers[2] = compress_test_bufs[1];
3833 : :
3834 : 0 : struct interim_data_params int_data = {
3835 : : (const char * const *)test_buffers,
3836 : : 3,
3837 : : &i,
3838 : : &ts_params->def_comp_xform,
3839 : : &ts_params->def_decomp_xform,
3840 : : 1
3841 : : };
3842 : :
3843 : 0 : struct test_data_params test_data = {
3844 : : .compress_state = RTE_COMP_OP_STATELESS,
3845 : : .decompress_state = RTE_COMP_OP_STATELESS,
3846 : : .buff_type = SGL_BOTH,
3847 : : .zlib_dir = ZLIB_NONE,
3848 : : .out_of_space = 0,
3849 : : .big_data = 1,
3850 : : .overflow = OVERFLOW_DISABLED,
3851 : : .ratio = RATIO_DISABLED
3852 : : };
3853 : :
3854 : 0 : ts_params->def_comp_xform->compress.deflate.huffman =
3855 : : RTE_COMP_HUFFMAN_DYNAMIC;
3856 : :
3857 : : /* fill the buffer with data based on rand. data */
3858 : 0 : srand(IM_BUF_DATA_TEST_SIZE_SGL);
3859 [ # # ]: 0 : for (j = 0; j < IM_BUF_DATA_TEST_SIZE_SGL - 1; ++j)
3860 : 0 : test_buffer[j] = (uint8_t)(rand() % ((uint8_t)-1)) | 1;
3861 : :
3862 : : /* Compress with compressdev, decompress with compressdev */
3863 [ # # ]: 0 : if (test_deflate_comp_decomp(&int_data, &test_data) < 0) {
3864 : : ret = TEST_FAILED;
3865 : 0 : goto end;
3866 : : }
3867 : :
3868 : 0 : end:
3869 : 0 : ts_params->def_comp_xform->compress.deflate.huffman =
3870 : : RTE_COMP_HUFFMAN_DEFAULT;
3871 : 0 : rte_free(test_buffer);
3872 : 0 : return ret;
3873 : : }
3874 : :
3875 : :
3876 : : static int
3877 : 0 : test_compressdev_deflate_im_buffers_SGL_4ops(void)
3878 : : {
3879 : : struct comp_testsuite_params *ts_params = &testsuite_params;
3880 : 0 : uint16_t i = 0;
3881 : : int ret = TEST_SUCCESS;
3882 : : int j;
3883 : : const struct rte_compressdev_capabilities *capab;
3884 : : char *test_buffer = NULL;
3885 : : const char *test_buffers[4];
3886 : :
3887 : 0 : capab = rte_compressdev_capability_get(0, RTE_COMP_ALGO_DEFLATE);
3888 [ # # ]: 0 : TEST_ASSERT(capab != NULL, "Failed to retrieve device capabilities");
3889 : :
3890 [ # # ]: 0 : if ((capab->comp_feature_flags & RTE_COMP_FF_HUFFMAN_DYNAMIC) == 0)
3891 : : return -ENOTSUP;
3892 : :
3893 [ # # ]: 0 : if ((capab->comp_feature_flags & RTE_COMP_FF_OOP_SGL_IN_SGL_OUT) == 0)
3894 : : return -ENOTSUP;
3895 : :
3896 : 0 : test_buffer = rte_malloc(NULL, IM_BUF_DATA_TEST_SIZE_SGL, 0);
3897 [ # # ]: 0 : if (test_buffer == NULL) {
3898 : 0 : RTE_LOG(ERR, USER1,
3899 : : "Can't allocate buffer for big-data\n");
3900 : 0 : return TEST_FAILED;
3901 : : }
3902 : :
3903 : 0 : test_buffers[0] = compress_test_bufs[0];
3904 : 0 : test_buffers[1] = test_buffer;
3905 : 0 : test_buffers[2] = compress_test_bufs[1];
3906 : 0 : test_buffers[3] = test_buffer;
3907 : :
3908 : 0 : struct interim_data_params int_data = {
3909 : : (const char * const *)test_buffers,
3910 : : 4,
3911 : : &i,
3912 : : &ts_params->def_comp_xform,
3913 : : &ts_params->def_decomp_xform,
3914 : : 1
3915 : : };
3916 : :
3917 : 0 : struct test_data_params test_data = {
3918 : : .compress_state = RTE_COMP_OP_STATELESS,
3919 : : .decompress_state = RTE_COMP_OP_STATELESS,
3920 : : .buff_type = SGL_BOTH,
3921 : : .zlib_dir = ZLIB_NONE,
3922 : : .out_of_space = 0,
3923 : : .big_data = 1,
3924 : : .overflow = OVERFLOW_DISABLED,
3925 : : .ratio = RATIO_DISABLED
3926 : : };
3927 : :
3928 : 0 : ts_params->def_comp_xform->compress.deflate.huffman =
3929 : : RTE_COMP_HUFFMAN_DYNAMIC;
3930 : :
3931 : : /* fill the buffer with data based on rand. data */
3932 : 0 : srand(IM_BUF_DATA_TEST_SIZE_SGL);
3933 [ # # ]: 0 : for (j = 0; j < IM_BUF_DATA_TEST_SIZE_SGL - 1; ++j)
3934 : 0 : test_buffer[j] = (uint8_t)(rand() % ((uint8_t)-1)) | 1;
3935 : :
3936 : : /* Compress with compressdev, decompress with compressdev */
3937 [ # # ]: 0 : if (test_deflate_comp_decomp(&int_data, &test_data) < 0) {
3938 : : ret = TEST_FAILED;
3939 : 0 : goto end;
3940 : : }
3941 : :
3942 : 0 : end:
3943 : 0 : ts_params->def_comp_xform->compress.deflate.huffman =
3944 : : RTE_COMP_HUFFMAN_DEFAULT;
3945 : 0 : rte_free(test_buffer);
3946 : 0 : return ret;
3947 : : }
3948 : :
3949 : : static int
3950 : 0 : test_compressdev_deflate_im_buffers_SGL_over_1op(void)
3951 : : {
3952 : : struct comp_testsuite_params *ts_params = &testsuite_params;
3953 : 0 : uint16_t i = 0;
3954 : : int ret = TEST_SUCCESS;
3955 : : int j;
3956 : : const struct rte_compressdev_capabilities *capab;
3957 : 0 : char *test_buffer = NULL;
3958 : :
3959 : 0 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
3960 : :
3961 : 0 : capab = rte_compressdev_capability_get(0, RTE_COMP_ALGO_DEFLATE);
3962 [ # # ]: 0 : TEST_ASSERT(capab != NULL, "Failed to retrieve device capabilities");
3963 : :
3964 [ # # ]: 0 : if ((capab->comp_feature_flags & RTE_COMP_FF_HUFFMAN_DYNAMIC) == 0)
3965 : : return -ENOTSUP;
3966 : :
3967 [ # # ]: 0 : if ((capab->comp_feature_flags & RTE_COMP_FF_OOP_SGL_IN_SGL_OUT) == 0)
3968 : : return -ENOTSUP;
3969 : :
3970 : 0 : test_buffer = rte_malloc(NULL, IM_BUF_DATA_TEST_SIZE_OVER, 0);
3971 [ # # ]: 0 : if (test_buffer == NULL) {
3972 : 0 : RTE_LOG(ERR, USER1,
3973 : : "Can't allocate buffer for big-data\n");
3974 : 0 : return TEST_FAILED;
3975 : : }
3976 : :
3977 : 0 : struct interim_data_params int_data = {
3978 : : (const char * const *)&test_buffer,
3979 : : 1,
3980 : : &i,
3981 : : &ts_params->def_comp_xform,
3982 : : &ts_params->def_decomp_xform,
3983 : : 1
3984 : : };
3985 : :
3986 : 0 : struct test_data_params test_data = {
3987 : : .compress_state = RTE_COMP_OP_STATELESS,
3988 : : .decompress_state = RTE_COMP_OP_STATELESS,
3989 : : .buff_type = SGL_BOTH,
3990 : : .zlib_dir = ZLIB_NONE,
3991 : : .out_of_space = 0,
3992 : : .big_data = 1,
3993 : : .overflow = OVERFLOW_DISABLED,
3994 : : .ratio = RATIO_DISABLED
3995 : : };
3996 : :
3997 : 0 : ts_params->def_comp_xform->compress.deflate.huffman =
3998 : : RTE_COMP_HUFFMAN_DYNAMIC;
3999 : :
4000 : : /* fill the buffer with data based on rand. data */
4001 : 0 : srand(IM_BUF_DATA_TEST_SIZE_OVER);
4002 [ # # ]: 0 : for (j = 0; j < IM_BUF_DATA_TEST_SIZE_OVER - 1; ++j)
4003 : 0 : test_buffer[j] = (uint8_t)(rand() % ((uint8_t)-1)) | 1;
4004 : :
4005 : : /* Compress with compressdev, decompress with compressdev */
4006 : 0 : if (test_deflate_comp_decomp(&int_data, &test_data) < 0) {
4007 : : ret = TEST_SUCCESS;
4008 : : goto end;
4009 : : }
4010 : :
4011 : : end:
4012 : 0 : ts_params->def_comp_xform->compress.deflate.huffman =
4013 : : RTE_COMP_HUFFMAN_DEFAULT;
4014 : 0 : rte_free(test_buffer);
4015 : :
4016 : 0 : return ret;
4017 : : }
4018 : :
4019 : :
4020 : : static int
4021 : 0 : test_compressdev_deflate_im_buffers_SGL_over_2ops_first(void)
4022 : : {
4023 : : struct comp_testsuite_params *ts_params = &testsuite_params;
4024 : 0 : uint16_t i = 0;
4025 : : int ret = TEST_SUCCESS;
4026 : : int j;
4027 : : const struct rte_compressdev_capabilities *capab;
4028 : : char *test_buffer = NULL;
4029 : : const char *test_buffers[2];
4030 : :
4031 : 0 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
4032 : :
4033 : 0 : capab = rte_compressdev_capability_get(0, RTE_COMP_ALGO_DEFLATE);
4034 [ # # ]: 0 : TEST_ASSERT(capab != NULL, "Failed to retrieve device capabilities");
4035 : :
4036 [ # # ]: 0 : if ((capab->comp_feature_flags & RTE_COMP_FF_HUFFMAN_DYNAMIC) == 0)
4037 : : return -ENOTSUP;
4038 : :
4039 [ # # ]: 0 : if ((capab->comp_feature_flags & RTE_COMP_FF_OOP_SGL_IN_SGL_OUT) == 0)
4040 : : return -ENOTSUP;
4041 : :
4042 : 0 : test_buffer = rte_malloc(NULL, IM_BUF_DATA_TEST_SIZE_OVER, 0);
4043 [ # # ]: 0 : if (test_buffer == NULL) {
4044 : 0 : RTE_LOG(ERR, USER1,
4045 : : "Can't allocate buffer for big-data\n");
4046 : 0 : return TEST_FAILED;
4047 : : }
4048 : :
4049 : 0 : test_buffers[0] = test_buffer;
4050 : 0 : test_buffers[1] = compress_test_bufs[0];
4051 : :
4052 : 0 : struct interim_data_params int_data = {
4053 : : (const char * const *)test_buffers,
4054 : : 2,
4055 : : &i,
4056 : : &ts_params->def_comp_xform,
4057 : : &ts_params->def_decomp_xform,
4058 : : 1
4059 : : };
4060 : :
4061 : 0 : struct test_data_params test_data = {
4062 : : .compress_state = RTE_COMP_OP_STATELESS,
4063 : : .decompress_state = RTE_COMP_OP_STATELESS,
4064 : : .buff_type = SGL_BOTH,
4065 : : .zlib_dir = ZLIB_NONE,
4066 : : .out_of_space = 0,
4067 : : .big_data = 1,
4068 : : .overflow = OVERFLOW_DISABLED,
4069 : : .ratio = RATIO_DISABLED
4070 : : };
4071 : :
4072 : 0 : ts_params->def_comp_xform->compress.deflate.huffman =
4073 : : RTE_COMP_HUFFMAN_DYNAMIC;
4074 : :
4075 : : /* fill the buffer with data based on rand. data */
4076 : 0 : srand(IM_BUF_DATA_TEST_SIZE_OVER);
4077 [ # # ]: 0 : for (j = 0; j < IM_BUF_DATA_TEST_SIZE_OVER - 1; ++j)
4078 : 0 : test_buffer[j] = (uint8_t)(rand() % ((uint8_t)-1)) | 1;
4079 : :
4080 : : /* Compress with compressdev, decompress with compressdev */
4081 : 0 : if (test_deflate_comp_decomp(&int_data, &test_data) < 0) {
4082 : : ret = TEST_SUCCESS;
4083 : : goto end;
4084 : : }
4085 : :
4086 : : end:
4087 : 0 : ts_params->def_comp_xform->compress.deflate.huffman =
4088 : : RTE_COMP_HUFFMAN_DEFAULT;
4089 : 0 : rte_free(test_buffer);
4090 : 0 : return ret;
4091 : : }
4092 : :
4093 : : static int
4094 : 0 : test_compressdev_deflate_im_buffers_SGL_over_2ops_second(void)
4095 : : {
4096 : : struct comp_testsuite_params *ts_params = &testsuite_params;
4097 : 0 : uint16_t i = 0;
4098 : : int ret = TEST_SUCCESS;
4099 : : int j;
4100 : : const struct rte_compressdev_capabilities *capab;
4101 : : char *test_buffer = NULL;
4102 : : const char *test_buffers[2];
4103 : :
4104 : 0 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
4105 : :
4106 : 0 : capab = rte_compressdev_capability_get(0, RTE_COMP_ALGO_DEFLATE);
4107 [ # # ]: 0 : TEST_ASSERT(capab != NULL, "Failed to retrieve device capabilities");
4108 : :
4109 [ # # ]: 0 : if ((capab->comp_feature_flags & RTE_COMP_FF_HUFFMAN_DYNAMIC) == 0)
4110 : : return -ENOTSUP;
4111 : :
4112 [ # # ]: 0 : if ((capab->comp_feature_flags & RTE_COMP_FF_OOP_SGL_IN_SGL_OUT) == 0)
4113 : : return -ENOTSUP;
4114 : :
4115 : 0 : test_buffer = rte_malloc(NULL, IM_BUF_DATA_TEST_SIZE_OVER, 0);
4116 [ # # ]: 0 : if (test_buffer == NULL) {
4117 : 0 : RTE_LOG(ERR, USER1,
4118 : : "Can't allocate buffer for big-data\n");
4119 : 0 : return TEST_FAILED;
4120 : : }
4121 : :
4122 : 0 : test_buffers[0] = compress_test_bufs[0];
4123 : 0 : test_buffers[1] = test_buffer;
4124 : :
4125 : 0 : struct interim_data_params int_data = {
4126 : : (const char * const *)test_buffers,
4127 : : 2,
4128 : : &i,
4129 : : &ts_params->def_comp_xform,
4130 : : &ts_params->def_decomp_xform,
4131 : : 1
4132 : : };
4133 : :
4134 : 0 : struct test_data_params test_data = {
4135 : : .compress_state = RTE_COMP_OP_STATELESS,
4136 : : .decompress_state = RTE_COMP_OP_STATELESS,
4137 : : .buff_type = SGL_BOTH,
4138 : : .zlib_dir = ZLIB_NONE,
4139 : : .out_of_space = 0,
4140 : : .big_data = 1,
4141 : : .overflow = OVERFLOW_DISABLED,
4142 : : .ratio = RATIO_DISABLED
4143 : : };
4144 : :
4145 : 0 : ts_params->def_comp_xform->compress.deflate.huffman =
4146 : : RTE_COMP_HUFFMAN_DYNAMIC;
4147 : :
4148 : : /* fill the buffer with data based on rand. data */
4149 : 0 : srand(IM_BUF_DATA_TEST_SIZE_OVER);
4150 [ # # ]: 0 : for (j = 0; j < IM_BUF_DATA_TEST_SIZE_OVER - 1; ++j)
4151 : 0 : test_buffer[j] = (uint8_t)(rand() % ((uint8_t)-1)) | 1;
4152 : :
4153 : : /* Compress with compressdev, decompress with compressdev */
4154 : 0 : if (test_deflate_comp_decomp(&int_data, &test_data) < 0) {
4155 : : ret = TEST_SUCCESS;
4156 : : goto end;
4157 : : }
4158 : :
4159 : : end:
4160 : 0 : ts_params->def_comp_xform->compress.deflate.huffman =
4161 : : RTE_COMP_HUFFMAN_DEFAULT;
4162 : 0 : rte_free(test_buffer);
4163 : 0 : return ret;
4164 : : }
4165 : :
4166 : : static struct unit_test_suite compressdev_testsuite = {
4167 : : .suite_name = "compressdev unit test suite",
4168 : : .setup = testsuite_setup,
4169 : : .teardown = testsuite_teardown,
4170 : : .unit_test_cases = {
4171 : : TEST_CASE_ST(NULL, NULL,
4172 : : test_compressdev_invalid_configuration),
4173 : : TEST_CASE_ST(generic_ut_setup, generic_ut_teardown,
4174 : : test_compressdev_deflate_stateless_fixed),
4175 : : TEST_CASE_ST(generic_ut_setup, generic_ut_teardown,
4176 : : test_compressdev_deflate_stateless_dynamic),
4177 : : TEST_CASE_ST(generic_ut_setup, generic_ut_teardown,
4178 : : test_compressdev_deflate_stateless_dynamic_big),
4179 : : TEST_CASE_ST(generic_ut_setup, generic_ut_teardown,
4180 : : test_compressdev_deflate_stateless_multi_op),
4181 : : TEST_CASE_ST(generic_ut_setup, generic_ut_teardown,
4182 : : test_compressdev_deflate_stateless_multi_level),
4183 : : TEST_CASE_ST(generic_ut_setup, generic_ut_teardown,
4184 : : test_compressdev_deflate_stateless_multi_xform),
4185 : : TEST_CASE_ST(generic_ut_setup, generic_ut_teardown,
4186 : : test_compressdev_deflate_stateless_sgl),
4187 : : TEST_CASE_ST(generic_ut_setup, generic_ut_teardown,
4188 : : test_compressdev_deflate_stateless_checksum),
4189 : : TEST_CASE_ST(generic_ut_setup, generic_ut_teardown,
4190 : : test_compressdev_out_of_space_buffer),
4191 : : TEST_CASE_ST(generic_ut_setup, generic_ut_teardown,
4192 : : test_compressdev_deflate_stateful_decomp),
4193 : : TEST_CASE_ST(generic_ut_setup, generic_ut_teardown,
4194 : : test_compressdev_deflate_stateful_decomp_checksum),
4195 : : TEST_CASE_ST(generic_ut_setup, generic_ut_teardown,
4196 : : test_compressdev_external_mbufs),
4197 : : TEST_CASE_ST(generic_ut_setup, generic_ut_teardown,
4198 : : test_compressdev_deflate_stateless_fixed_oos_recoverable),
4199 : :
4200 : : /* Positive test cases for IM buffer handling verification */
4201 : : TEST_CASE_ST(generic_ut_setup, generic_ut_teardown,
4202 : : test_compressdev_deflate_im_buffers_LB_1op),
4203 : : TEST_CASE_ST(generic_ut_setup, generic_ut_teardown,
4204 : : test_compressdev_deflate_im_buffers_LB_2ops_first),
4205 : : TEST_CASE_ST(generic_ut_setup, generic_ut_teardown,
4206 : : test_compressdev_deflate_im_buffers_LB_2ops_second),
4207 : : TEST_CASE_ST(generic_ut_setup, generic_ut_teardown,
4208 : : test_compressdev_deflate_im_buffers_LB_3ops),
4209 : :
4210 : : TEST_CASE_ST(generic_ut_setup, generic_ut_teardown,
4211 : : test_compressdev_deflate_im_buffers_LB_4ops),
4212 : : TEST_CASE_ST(generic_ut_setup, generic_ut_teardown,
4213 : : test_compressdev_deflate_im_buffers_SGL_1op),
4214 : :
4215 : : TEST_CASE_ST(generic_ut_setup, generic_ut_teardown,
4216 : : test_compressdev_deflate_im_buffers_SGL_2ops_first),
4217 : : TEST_CASE_ST(generic_ut_setup, generic_ut_teardown,
4218 : : test_compressdev_deflate_im_buffers_SGL_2ops_second),
4219 : : TEST_CASE_ST(generic_ut_setup, generic_ut_teardown,
4220 : : test_compressdev_deflate_im_buffers_SGL_3ops),
4221 : : TEST_CASE_ST(generic_ut_setup, generic_ut_teardown,
4222 : : test_compressdev_deflate_im_buffers_SGL_4ops),
4223 : :
4224 : : /* Negative test cases for IM buffer handling verification */
4225 : :
4226 : : /* For this test huge mempool is necessary.
4227 : : * It tests one case:
4228 : : * only one op containing big amount of data, so that
4229 : : * number of requested descriptors higher than number
4230 : : * of available descriptors (128)
4231 : : */
4232 : : TEST_CASE_ST(generic_ut_setup, generic_ut_teardown,
4233 : : test_compressdev_deflate_im_buffers_SGL_over_1op),
4234 : :
4235 : : /* For this test huge mempool is necessary.
4236 : : * 2 ops. First op contains big amount of data:
4237 : : * number of requested descriptors higher than number
4238 : : * of available descriptors (128), the second op is
4239 : : * relatively small. In this case both ops are rejected
4240 : : */
4241 : : TEST_CASE_ST(generic_ut_setup, generic_ut_teardown,
4242 : : test_compressdev_deflate_im_buffers_SGL_over_2ops_first),
4243 : :
4244 : : TEST_CASE_ST(generic_ut_setup, generic_ut_teardown,
4245 : : test_compressdev_deflate_im_buffers_SGL_over_2ops_second),
4246 : :
4247 : : TEST_CASES_END() /**< NULL terminate unit test array */
4248 : : }
4249 : : };
4250 : :
4251 : : static int
4252 : 1 : test_compressdev(void)
4253 : : {
4254 : 1 : return unit_test_suite_runner(&compressdev_testsuite);
4255 : : }
4256 : :
4257 : 305 : REGISTER_FAST_TEST(compressdev_autotest, NOHUGE_SKIP, ASAN_OK, test_compressdev);
|