From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 7573E8E1C for ; Fri, 27 Apr 2018 16:14:59 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Apr 2018 07:14:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,335,1520924400"; d="scan'208";a="51330950" Received: from silpixa00399464.ir.intel.com (HELO silpixa00399464.ger.corp.intel.com) ([10.237.222.157]) by orsmga001.jf.intel.com with ESMTP; 27 Apr 2018 07:14:57 -0700 From: Pablo de Lara To: dev@dpdk.org Cc: fiona.trahe@intel.com, shally.verma@cavium.com, ahmed.mansour@nxp.com, Ashish.Gupta@cavium.com, Pablo de Lara Date: Fri, 27 Apr 2018 15:15:01 +0100 Message-Id: <20180427141502.4288-5-pablo.de.lara.guarch@intel.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180427141502.4288-1-pablo.de.lara.guarch@intel.com> References: <20180228140010.27251-1-pablo.de.lara.guarch@intel.com> <20180427141502.4288-1-pablo.de.lara.guarch@intel.com> Subject: [dpdk-dev] [PATCH v3 4/5] test/compress: add multi xform test X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Apr 2018 14:15:00 -0000 Add test that checks if multiple xforms can be handled on a single enqueue call. Signed-off-by: Pablo de Lara --- test/test/test_compressdev.c | 257 ++++++++++++++++++++++++++++++++----------- 1 file changed, 191 insertions(+), 66 deletions(-) diff --git a/test/test/test_compressdev.c b/test/test/test_compressdev.c index bb026d74f..0253d12ea 100644 --- a/test/test/test_compressdev.c +++ b/test/test/test_compressdev.c @@ -27,7 +27,7 @@ #define COMPRESS_BUF_SIZE_RATIO 1.3 #define NUM_MBUFS 16 #define NUM_OPS 16 -#define NUM_MAX_XFORMS 1 +#define NUM_MAX_XFORMS 16 #define NUM_MAX_INFLIGHT_OPS 128 #define CACHE_SIZE 0 @@ -52,8 +52,8 @@ struct priv_op_data { struct comp_testsuite_params { struct rte_mempool *mbuf_pool; struct rte_mempool *op_pool; - struct rte_comp_xform def_comp_xform; - struct rte_comp_xform def_decomp_xform; + struct rte_comp_xform *def_comp_xform; + struct rte_comp_xform *def_decomp_xform; }; static struct comp_testsuite_params testsuite_params = { 0 }; @@ -65,6 +65,8 @@ testsuite_teardown(void) rte_mempool_free(ts_params->mbuf_pool); rte_mempool_free(ts_params->op_pool); + rte_free(ts_params->def_comp_xform); + rte_free(ts_params->def_decomp_xform); } static int @@ -108,19 +110,24 @@ testsuite_setup(void) goto exit; } + ts_params->def_comp_xform = + rte_malloc(NULL, sizeof(struct rte_comp_xform), 0); + ts_params->def_decomp_xform = + rte_malloc(NULL, sizeof(struct rte_comp_xform), 0); + /* Initializes default values for compress/decompress xforms */ - ts_params->def_comp_xform.type = RTE_COMP_COMPRESS; - ts_params->def_comp_xform.compress.algo = RTE_COMP_ALGO_DEFLATE, - ts_params->def_comp_xform.compress.deflate.huffman = + ts_params->def_comp_xform->type = RTE_COMP_COMPRESS; + ts_params->def_comp_xform->compress.algo = RTE_COMP_ALGO_DEFLATE, + ts_params->def_comp_xform->compress.deflate.huffman = RTE_COMP_HUFFMAN_DEFAULT; - ts_params->def_comp_xform.compress.level = RTE_COMP_LEVEL_PMD_DEFAULT; - ts_params->def_comp_xform.compress.chksum = RTE_COMP_CHECKSUM_NONE; - ts_params->def_comp_xform.compress.window_size = DEFAULT_WINDOW_SIZE; + ts_params->def_comp_xform->compress.level = RTE_COMP_LEVEL_PMD_DEFAULT; + ts_params->def_comp_xform->compress.chksum = RTE_COMP_CHECKSUM_NONE; + ts_params->def_comp_xform->compress.window_size = DEFAULT_WINDOW_SIZE; - ts_params->def_decomp_xform.type = RTE_COMP_DECOMPRESS; - ts_params->def_decomp_xform.decompress.algo = RTE_COMP_ALGO_DEFLATE, - ts_params->def_decomp_xform.decompress.chksum = RTE_COMP_CHECKSUM_NONE; - ts_params->def_decomp_xform.decompress.window_size = DEFAULT_WINDOW_SIZE; + ts_params->def_decomp_xform->type = RTE_COMP_DECOMPRESS; + ts_params->def_decomp_xform->decompress.algo = RTE_COMP_ALGO_DEFLATE, + ts_params->def_decomp_xform->decompress.chksum = RTE_COMP_CHECKSUM_NONE; + ts_params->def_decomp_xform->decompress.window_size = DEFAULT_WINDOW_SIZE; return TEST_SUCCESS; @@ -345,8 +352,9 @@ static int test_deflate_comp_decomp(const char * const test_bufs[], unsigned int num_bufs, uint16_t buf_idx[], - struct rte_comp_xform *compress_xform, - struct rte_comp_xform *decompress_xform, + struct rte_comp_xform *compress_xforms[], + struct rte_comp_xform *decompress_xforms[], + unsigned int num_xforms, enum rte_comp_op_type state, enum zlib_direction zlib_dir) { @@ -441,8 +449,9 @@ test_deflate_comp_decomp(const char * const test_bufs[], /* Compress data (either with Zlib API or compressdev API */ if (zlib_dir == ZLIB_COMPRESS || zlib_dir == ZLIB_ALL) { for (i = 0; i < num_bufs; i++) { - ret = compress_zlib(ops[i], - (const struct rte_comp_xform *)compress_xform, + const struct rte_comp_xform *compress_xform = + compress_xforms[i % num_xforms]; + ret = compress_zlib(ops[i], compress_xform, DEFAULT_MEM_LEVEL); if (ret < 0) goto exit; @@ -450,11 +459,11 @@ test_deflate_comp_decomp(const char * const test_bufs[], ops_processed[i] = ops[i]; } } else { - if (capa->comp_feature_flags & RTE_COMP_FF_SHAREABLE_PRIV_XFORM) { - /* Create single compress private xform data */ + /* Create compress private xform data */ + for (i = 0; i < num_xforms; i++) { ret = rte_compressdev_private_xform_create(0, - (const struct rte_comp_xform *)compress_xform, - &priv_xforms[0]); + (const struct rte_comp_xform *)compress_xforms[i], + &priv_xforms[i]); if (ret < 0) { RTE_LOG(ERR, USER1, "Compression private xform " @@ -462,14 +471,18 @@ test_deflate_comp_decomp(const char * const test_bufs[], goto exit; } num_priv_xforms++; + } + + if (capa->comp_feature_flags & RTE_COMP_FF_SHAREABLE_PRIV_XFORM) { /* Attach shareable private xform data to ops */ for (i = 0; i < num_bufs; i++) - ops[i]->private_xform = priv_xforms[0]; + ops[i]->private_xform = priv_xforms[i % num_xforms]; } else { - /* Create compress private xform data per op */ - for (i = 0; i < num_bufs; i++) { + /* Create rest of the private xforms for the other ops */ + for (i = num_xforms; i < num_bufs; i++) { ret = rte_compressdev_private_xform_create(0, - compress_xform, &priv_xforms[i]); + compress_xforms[i % num_xforms], + &priv_xforms[i]); if (ret < 0) { RTE_LOG(ERR, USER1, "Compression private xform " @@ -527,15 +540,18 @@ test_deflate_comp_decomp(const char * const test_bufs[], num_priv_xforms = 0; } - enum rte_comp_huffman huffman_type = - compress_xform->compress.deflate.huffman; for (i = 0; i < num_bufs; i++) { priv_data = (struct priv_op_data *)(ops_processed[i] + 1); + uint16_t xform_idx = priv_data->orig_idx % num_xforms; + const struct rte_comp_compress_xform *compress_xform = + &compress_xforms[xform_idx]->compress; + enum rte_comp_huffman huffman_type = + compress_xform->deflate.huffman; RTE_LOG(DEBUG, USER1, "Buffer %u compressed from %u to %u bytes " - "(level = %u, huffman = %s)\n", + "(level = %d, huffman = %s)\n", buf_idx[priv_data->orig_idx], ops_processed[i]->consumed, ops_processed[i]->produced, - compress_xform->compress.level, + compress_xform->level, huffman_type_strings[huffman_type]); RTE_LOG(DEBUG, USER1, "Compression ratio = %.2f", (float)ops_processed[i]->produced / @@ -623,19 +639,23 @@ test_deflate_comp_decomp(const char * const test_bufs[], /* Decompress data (either with Zlib API or compressdev API */ if (zlib_dir == ZLIB_DECOMPRESS || zlib_dir == ZLIB_ALL) { for (i = 0; i < num_bufs; i++) { - ret = decompress_zlib(ops[i], - (const struct rte_comp_xform *)decompress_xform); + priv_data = (struct priv_op_data *)(ops[i] + 1); + uint16_t xform_idx = priv_data->orig_idx % num_xforms; + const struct rte_comp_xform *decompress_xform = + decompress_xforms[xform_idx]; + + ret = decompress_zlib(ops[i], decompress_xform); if (ret < 0) goto exit; ops_processed[i] = ops[i]; } } else { - if (capa->comp_feature_flags & RTE_COMP_FF_SHAREABLE_PRIV_XFORM) { - /* Create single decompress private xform data */ + /* Create decompress private xform data */ + for (i = 0; i < num_xforms; i++) { ret = rte_compressdev_private_xform_create(0, - (const struct rte_comp_xform *)decompress_xform, - &priv_xforms[0]); + (const struct rte_comp_xform *)decompress_xforms[i], + &priv_xforms[i]); if (ret < 0) { RTE_LOG(ERR, USER1, "Decompression private xform " @@ -643,17 +663,25 @@ test_deflate_comp_decomp(const char * const test_bufs[], goto exit; } num_priv_xforms++; + } + + if (capa->comp_feature_flags & RTE_COMP_FF_SHAREABLE_PRIV_XFORM) { /* Attach shareable private xform data to ops */ - for (i = 0; i < num_bufs; i++) - ops[i]->private_xform = priv_xforms[0]; - } else { - /* Create decompress private xform data per op */ for (i = 0; i < num_bufs; i++) { + priv_data = (struct priv_op_data *)(ops[i] + 1); + uint16_t xform_idx = priv_data->orig_idx % + num_xforms; + ops[i]->private_xform = priv_xforms[xform_idx]; + } + } else { + /* Create rest of the private xforms for the other ops */ + for (i = num_xforms; i < num_bufs; i++) { ret = rte_compressdev_private_xform_create(0, - decompress_xform, &priv_xforms[i]); + decompress_xforms[i % num_xforms], + &priv_xforms[i]); if (ret < 0) { RTE_LOG(ERR, USER1, - "Deompression private xform " + "Decompression private xform " "could not be created\n"); goto exit; } @@ -661,8 +689,11 @@ test_deflate_comp_decomp(const char * const test_bufs[], } /* Attach non shareable private xform data to ops */ - for (i = 0; i < num_bufs; i++) - ops[i]->private_xform = priv_xforms[i]; + for (i = 0; i < num_bufs; i++) { + priv_data = (struct priv_op_data *) (ops[i] + 1); + uint16_t xform_idx = priv_data->orig_idx; + ops[i]->private_xform = priv_xforms[xform_idx]; + } } /* Enqueue and dequeue all operations */ @@ -763,11 +794,13 @@ test_compressdev_deflate_stateless_fixed(void) struct comp_testsuite_params *ts_params = &testsuite_params; const char *test_buffer; uint16_t i; - struct rte_comp_xform compress_xform; + int ret; + struct rte_comp_xform *compress_xform = + rte_malloc(NULL, sizeof(struct rte_comp_xform), 0); - memcpy(&compress_xform, &ts_params->def_comp_xform, + memcpy(compress_xform, ts_params->def_comp_xform, sizeof(struct rte_comp_xform)); - compress_xform.compress.deflate.huffman = RTE_COMP_HUFFMAN_FIXED; + compress_xform->compress.deflate.huffman = RTE_COMP_HUFFMAN_FIXED; for (i = 0; i < RTE_DIM(compress_test_bufs); i++) { test_buffer = compress_test_bufs[i]; @@ -777,21 +810,31 @@ test_compressdev_deflate_stateless_fixed(void) &i, &compress_xform, &ts_params->def_decomp_xform, + 1, RTE_COMP_OP_STATELESS, - ZLIB_DECOMPRESS) < 0) - return TEST_FAILED; + ZLIB_DECOMPRESS) < 0) { + ret = TEST_FAILED; + goto exit; + } /* Compress with Zlib, decompress with compressdev */ if (test_deflate_comp_decomp(&test_buffer, 1, &i, &compress_xform, &ts_params->def_decomp_xform, + 1, RTE_COMP_OP_STATELESS, - ZLIB_COMPRESS) < 0) - return TEST_FAILED; + ZLIB_COMPRESS) < 0) { + ret = TEST_FAILED; + goto exit; + } } - return TEST_SUCCESS; + ret = TEST_SUCCESS; + +exit: + rte_free(compress_xform); + return ret; } static int @@ -800,11 +843,13 @@ test_compressdev_deflate_stateless_dynamic(void) struct comp_testsuite_params *ts_params = &testsuite_params; const char *test_buffer; uint16_t i; - struct rte_comp_xform compress_xform; + int ret; + struct rte_comp_xform *compress_xform = + rte_malloc(NULL, sizeof(struct rte_comp_xform), 0); - memcpy(&compress_xform, &ts_params->def_comp_xform, + memcpy(compress_xform, ts_params->def_comp_xform, sizeof(struct rte_comp_xform)); - compress_xform.compress.deflate.huffman = RTE_COMP_HUFFMAN_DYNAMIC; + compress_xform->compress.deflate.huffman = RTE_COMP_HUFFMAN_DYNAMIC; for (i = 0; i < RTE_DIM(compress_test_bufs); i++) { test_buffer = compress_test_bufs[i]; @@ -814,21 +859,31 @@ test_compressdev_deflate_stateless_dynamic(void) &i, &compress_xform, &ts_params->def_decomp_xform, + 1, RTE_COMP_OP_STATELESS, - ZLIB_DECOMPRESS) < 0) - return TEST_FAILED; + ZLIB_DECOMPRESS) < 0) { + ret = TEST_FAILED; + goto exit; + } /* Compress with Zlib, decompress with compressdev */ if (test_deflate_comp_decomp(&test_buffer, 1, &i, &compress_xform, &ts_params->def_decomp_xform, + 1, RTE_COMP_OP_STATELESS, - ZLIB_COMPRESS) < 0) - return TEST_FAILED; + ZLIB_COMPRESS) < 0) { + ret = TEST_FAILED; + goto exit; + } } - return TEST_SUCCESS; + ret = TEST_SUCCESS; + +exit: + rte_free(compress_xform); + return ret; } static int @@ -847,6 +902,7 @@ test_compressdev_deflate_stateless_multi_op(void) buf_idx, &ts_params->def_comp_xform, &ts_params->def_decomp_xform, + 1, RTE_COMP_OP_STATELESS, ZLIB_DECOMPRESS) < 0) return TEST_FAILED; @@ -856,6 +912,7 @@ test_compressdev_deflate_stateless_multi_op(void) buf_idx, &ts_params->def_comp_xform, &ts_params->def_decomp_xform, + 1, RTE_COMP_OP_STATELESS, ZLIB_COMPRESS) < 0) return TEST_FAILED; @@ -863,7 +920,6 @@ test_compressdev_deflate_stateless_multi_op(void) return TEST_SUCCESS; } - static int test_compressdev_deflate_stateless_multi_level(void) { @@ -871,29 +927,96 @@ test_compressdev_deflate_stateless_multi_level(void) const char *test_buffer; unsigned int level; uint16_t i; - struct rte_comp_xform compress_xform; + int ret; + struct rte_comp_xform *compress_xform = + rte_malloc(NULL, sizeof(struct rte_comp_xform), 0); - memcpy(&compress_xform, &ts_params->def_comp_xform, + memcpy(compress_xform, ts_params->def_comp_xform, sizeof(struct rte_comp_xform)); for (i = 0; i < RTE_DIM(compress_test_bufs); i++) { test_buffer = compress_test_bufs[i]; for (level = RTE_COMP_LEVEL_MIN; level <= RTE_COMP_LEVEL_MAX; level++) { - compress_xform.compress.level = level; + compress_xform->compress.level = level; /* Compress with compressdev, decompress with Zlib */ if (test_deflate_comp_decomp(&test_buffer, 1, &i, &compress_xform, &ts_params->def_decomp_xform, + 1, RTE_COMP_OP_STATELESS, - ZLIB_DECOMPRESS) < 0) - return TEST_FAILED; + ZLIB_DECOMPRESS) < 0) { + ret = TEST_FAILED; + goto exit; + } } } - return TEST_SUCCESS; + ret = TEST_SUCCESS; + +exit: + rte_free(compress_xform); + return ret; } + +#define NUM_XFORMS 3 +static int +test_compressdev_deflate_stateless_multi_xform(void) +{ + struct comp_testsuite_params *ts_params = &testsuite_params; + uint16_t num_bufs = NUM_XFORMS; + struct rte_comp_xform *compress_xforms[NUM_XFORMS] = {NULL}; + struct rte_comp_xform *decompress_xforms[NUM_XFORMS] = {NULL}; + const char *test_buffers[NUM_XFORMS]; + uint16_t i; + unsigned int level = RTE_COMP_LEVEL_MIN; + uint16_t buf_idx[num_bufs]; + + int ret; + + /* Create multiple xforms with various levels */ + for (i = 0; i < NUM_XFORMS; i++) { + compress_xforms[i] = rte_malloc(NULL, + sizeof(struct rte_comp_xform), 0); + memcpy(compress_xforms[i], ts_params->def_comp_xform, + sizeof(struct rte_comp_xform)); + compress_xforms[i]->compress.level = level; + level++; + + decompress_xforms[i] = rte_malloc(NULL, + sizeof(struct rte_comp_xform), 0); + memcpy(decompress_xforms[i], ts_params->def_decomp_xform, + sizeof(struct rte_comp_xform)); + } + + for (i = 0; i < NUM_XFORMS; i++) { + buf_idx[i] = 0; + /* Use the same buffer in all sessions */ + test_buffers[i] = compress_test_bufs[0]; + } + /* Compress with compressdev, decompress with Zlib */ + if (test_deflate_comp_decomp(test_buffers, num_bufs, + buf_idx, + compress_xforms, + decompress_xforms, + NUM_XFORMS, + RTE_COMP_OP_STATELESS, + ZLIB_DECOMPRESS) < 0) { + ret = TEST_FAILED; + goto exit; + } + + ret = TEST_SUCCESS; +exit: + for (i = 0; i < NUM_XFORMS; i++) { + rte_free(compress_xforms[i]); + rte_free(decompress_xforms[i]); + } + + return ret; +} + static struct unit_test_suite compressdev_testsuite = { .suite_name = "compressdev unit test suite", .setup = testsuite_setup, @@ -907,6 +1030,8 @@ static struct unit_test_suite compressdev_testsuite = { test_compressdev_deflate_stateless_multi_op), TEST_CASE_ST(generic_ut_setup, generic_ut_teardown, test_compressdev_deflate_stateless_multi_level), + TEST_CASE_ST(generic_ut_setup, generic_ut_teardown, + test_compressdev_deflate_stateless_multi_xform), TEST_CASES_END() /**< NULL terminate unit test array */ } }; -- 2.14.3