+ return 0;
+}
+
+/**
+ * Data size calculation (for both compression and decompression).
+ *
+ * Calculate size of anticipated output buffer required for both
+ * compression and decompression operations based on input int_data.
+ *
+ * @param op_type
+ * Operation type: compress or decompress
+ * @param out_of_space_and_zlib
+ * Boolean value to switch into "out of space" buffer if set.
+ * To test "out-of-space" data size, zlib_decompress must be set as well.
+ * @param test_priv_data
+ * A container used for aggregation all the private test arrays.
+ * @param int_data
+ * Interim data containing session/transformation objects.
+ * @param test_data
+ * The test parameters set by users (command line parameters).
+ * @param i
+ * current buffer index
+ * @return
+ * data size
+ */
+static inline uint32_t
+test_mbufs_calculate_data_size(
+ enum operation_type op_type,
+ unsigned int out_of_space_and_zlib,
+ const struct test_private_arrays *test_priv_data,
+ const struct interim_data_params *int_data,
+ const struct test_data_params *test_data,
+ unsigned int i)
+{
+ /* local variables: */
+ uint32_t data_size;
+ struct priv_op_data *priv_data;
+ float ratio;
+ uint8_t not_zlib_compr; /* true if zlib isn't current compression dev */
+ enum overflow_test overflow = test_data->overflow;
+
+ /* from test_priv_data: */
+ struct rte_comp_op **ops_processed = test_priv_data->ops_processed;
+
+ /* from int_data: */
+ const char * const *test_bufs = int_data->test_bufs;
+
+ if (out_of_space_and_zlib)
+ data_size = OUT_OF_SPACE_BUF;
+ else {
+ if (op_type == OPERATION_COMPRESSION) {
+ not_zlib_compr = (test_data->zlib_dir == ZLIB_DECOMPRESS
+ || test_data->zlib_dir == ZLIB_NONE);
+
+ ratio = (not_zlib_compr &&
+ (overflow == OVERFLOW_ENABLED)) ?
+ COMPRESS_BUF_SIZE_RATIO_OVERFLOW :
+ COMPRESS_BUF_SIZE_RATIO;
+
+ data_size = strlen(test_bufs[i]) * ratio;
+
+ } else {
+ priv_data = (struct priv_op_data *)
+ (ops_processed[i] + 1);
+ data_size = strlen(test_bufs[priv_data->orig_idx]) + 1;
+ }
+ }
+
+ return data_size;
+}
+
+
+/**
+ * Memory buffers preparation (for both compression and decompression).
+ *
+ * Function allocates output buffers to perform compression
+ * or decompression operations depending on value of op_type.
+ *
+ * @param op_type
+ * Operation type: compress or decompress
+ * @param out_of_space_and_zlib
+ * Boolean value to switch into "out of space" buffer if set.
+ * To test "out-of-space" data size, zlib_decompress must be set as well.
+ * @param test_priv_data
+ * A container used for aggregation all the private test arrays.
+ * @param int_data
+ * Interim data containing session/transformation objects.
+ * @param test_data
+ * The test parameters set by users (command line parameters).
+ * @param current_extbuf_info,
+ * The structure containing all the information related to external mbufs
+ * @return
+ * - 0: On success.
+ * - -1: On error.
+ */
+static int
+test_setup_output_bufs(
+ enum operation_type op_type,
+ unsigned int out_of_space_and_zlib,
+ const struct test_private_arrays *test_priv_data,
+ const struct interim_data_params *int_data,
+ const struct test_data_params *test_data,
+ struct rte_mbuf_ext_shared_info *current_extbuf_info)
+{
+ /* local variables: */
+ unsigned int i;
+ uint32_t data_size;
+ int ret;
+ char *buf_ptr;
+
+ /* from test_priv_data: */
+ struct rte_mbuf **current_bufs;
+
+ /* from int_data: */
+ unsigned int num_bufs = int_data->num_bufs;
+
+ /* from test_data: */
+ unsigned int buff_type = test_data->buff_type;
+ unsigned int big_data = test_data->big_data;
+ const struct rte_memzone *current_memzone;
+
+ struct comp_testsuite_params *ts_params = &testsuite_params;
+ struct rte_mempool *buf_pool;
+
+ if (big_data)
+ buf_pool = ts_params->big_mbuf_pool;
+ else if (buff_type == SGL_BOTH)
+ buf_pool = ts_params->small_mbuf_pool;
+ else
+ buf_pool = ts_params->large_mbuf_pool;
+
+ if (op_type == OPERATION_COMPRESSION)
+ current_bufs = test_priv_data->comp_bufs;
+ else
+ current_bufs = test_priv_data->uncomp_bufs;
+
+ /* the mbufs allocation*/
+ ret = rte_pktmbuf_alloc_bulk(buf_pool, current_bufs, num_bufs);