DPDK patches and discussions
 help / color / mirror / Atom feed
From: Lee Daly <lee.daly@intel.com>
To: akhil.goyal@nxp.com
Cc: dev@dpdk.org, Lee Daly <lee.daly@intel.com>
Subject: [dpdk-dev] [PATCH 2/3] test/compress: add checksum tests
Date: Tue,  9 Oct 2018 17:21:48 +0100	[thread overview]
Message-ID: <1539102109-9311-2-git-send-email-lee.daly@intel.com> (raw)
In-Reply-To: <1539102109-9311-1-git-send-email-lee.daly@intel.com>

This patch adds a test which examines what type of checksum the PMD
supports, adler, crc32 or alder32_crc32
and tests that feature if the PMD supports it.

Signed-off-by: Lee Daly <lee.daly@intel.com>
---
 test/test/test_compressdev.c | 205 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 202 insertions(+), 3 deletions(-)

diff --git a/test/test/test_compressdev.c b/test/test/test_compressdev.c
index 8645388..7ee670f 100644
--- a/test/test/test_compressdev.c
+++ b/test/test/test_compressdev.c
@@ -312,11 +312,16 @@ compress_zlib(struct rte_comp_op *op,
 	else
 		strategy = Z_DEFAULT_STRATEGY;
 
+
 	/*
 	 * Window bits is the base two logarithm of the window size (in bytes).
 	 * When doing raw DEFLATE, this number will be negative.
 	 */
 	window_bits = -(xform->compress.window_size);
+	if (xform->compress.chksum == RTE_COMP_CHECKSUM_ADLER32)
+		window_bits *= -1;
+	else if (xform->compress.chksum == RTE_COMP_CHECKSUM_CRC32)
+		window_bits += 46;
 
 	comp_level = xform->compress.level;
 
@@ -369,6 +374,11 @@ compress_zlib(struct rte_comp_op *op,
 	zlib_flush = map_zlib_flush_flag(op->flush_flag);
 	ret = deflate(&stream, zlib_flush);
 
+	if (xform->compress.chksum == RTE_COMP_CHECKSUM_ADLER32)
+		op->m_dst->buf_addr += 2;
+	else if (xform->compress.chksum == RTE_COMP_CHECKSUM_CRC32)
+		op->m_dst->buf_addr += 10;
+
 	if (stream.avail_in != 0) {
 		RTE_LOG(ERR, USER1, "Buffer could not be read entirely\n");
 		goto exit;
@@ -400,8 +410,14 @@ compress_zlib(struct rte_comp_op *op,
 	}
 
 	op->consumed = stream.total_in;
-	op->produced = stream.total_out;
+	if (xform->compress.chksum == RTE_COMP_CHECKSUM_ADLER32)
+		op->produced = stream.total_out - 6;
+	else if (xform->compress.chksum == RTE_COMP_CHECKSUM_CRC32)
+		op->produced = stream.total_out - 18;
+	else
+		op->produced = stream.total_out;
 	op->status = RTE_COMP_OP_STATUS_SUCCESS;
+	op->output_chksum = stream.adler;
 
 	deflateReset(&stream);
 
@@ -435,7 +451,6 @@ decompress_zlib(struct rte_comp_op *op,
 	 * When doing raw DEFLATE, this number will be negative.
 	 */
 	window_bits = -(xform->decompress.window_size);
-
 	ret = inflateInit2(&stream, window_bits);
 
 	if (ret != Z_OK) {
@@ -651,6 +666,7 @@ test_deflate_comp_decomp(const char * const test_bufs[],
 	const struct rte_compressdev_capabilities *capa =
 		rte_compressdev_capability_get(0, RTE_COMP_ALGO_DEFLATE);
 	char *contig_buf = NULL;
+	uint64_t compress_checksum[num_bufs];
 
 	/* Initialize all arrays to NULL */
 	memset(uncomp_bufs, 0, sizeof(struct rte_mbuf *) * num_bufs);
@@ -837,6 +853,7 @@ test_deflate_comp_decomp(const char * const test_bufs[],
 					&ops_processed[num_total_deqd], num_bufs);
 			num_total_deqd += num_deqd;
 			deqd_retries++;
+
 		} while (num_total_deqd < num_enqd);
 
 		deqd_retries = 0;
@@ -865,6 +882,8 @@ test_deflate_comp_decomp(const char * const test_bufs[],
 		RTE_LOG(DEBUG, USER1, "Compression ratio = %.2f",
 			(float)ops_processed[i]->produced /
 			ops_processed[i]->consumed * 100);
+		if (compress_xform->chksum != RTE_COMP_CHECKSUM_NONE)
+			compress_checksum[i] = ops_processed[i]->output_chksum;
 		ops[i] = NULL;
 	}
 
@@ -1094,9 +1113,18 @@ test_deflate_comp_decomp(const char * const test_bufs[],
 			goto exit;
 		}
 
+		/* Test checksums */
+		if (compress_xforms[0]->compress.chksum !=
+				RTE_COMP_CHECKSUM_NONE) {
+			if (ops_processed[i]->output_chksum !=
+					compress_checksum[i]) {
+				RTE_LOG(ERR, USER1, "The checksums differ\n");
+				goto exit;
+			}
+		}
+
 		buf2 = rte_pktmbuf_read(ops_processed[i]->m_dst, 0,
 				ops_processed[i]->produced, contig_buf);
-
 		if (compare_buffers(buf1, strlen(buf1) + 1,
 				buf2, ops_processed[i]->produced) < 0)
 			goto exit;
@@ -1452,6 +1480,175 @@ test_compressdev_deflate_stateless_sgl(void)
 	}
 
 	return TEST_SUCCESS;
+
+}
+
+static int
+test_compressdev_deflate_stateless_checksum(void)
+{
+	struct comp_testsuite_params *ts_params = &testsuite_params;
+	const char *test_buffer;
+	uint16_t i;
+	int ret;
+	const struct rte_compressdev_capabilities *capab;
+
+	capab = rte_compressdev_capability_get(0, RTE_COMP_ALGO_DEFLATE);
+	TEST_ASSERT(capab != NULL, "Failed to retrieve device capabilities");
+
+	/* Check if driver supports any checksum */
+	if ((capab->comp_feature_flags & RTE_COMP_FF_CRC32_CHECKSUM) == 0 &&
+		(capab->comp_feature_flags & RTE_COMP_FF_ADLER32_CHECKSUM) == 0 &&
+		(capab->comp_feature_flags & RTE_COMP_FF_CRC32_ADLER32_CHECKSUM) == 0)
+		return -ENOTSUP;
+
+	struct rte_comp_xform *compress_xform =
+			rte_malloc(NULL, sizeof(struct rte_comp_xform), 0);
+	if (compress_xform == NULL) {
+		RTE_LOG(ERR, USER1, "Compress xform could not be created\n");
+		ret = TEST_FAILED;
+		goto exit;
+	}
+
+	memcpy(compress_xform, ts_params->def_comp_xform,
+			sizeof(struct rte_comp_xform));
+
+	struct rte_comp_xform *decompress_xform =
+			rte_malloc(NULL, sizeof(struct rte_comp_xform), 0);
+	if (decompress_xform == NULL) {
+		RTE_LOG(ERR, USER1, "Decompress xform could not be created\n");
+		ret = TEST_FAILED;
+		goto exit;
+	}
+
+	memcpy(decompress_xform, ts_params->def_decomp_xform,
+			sizeof(struct rte_comp_xform));
+
+	/* Check if driver supports crc32 checksum and test */
+	if ((capab->comp_feature_flags & RTE_COMP_FF_CRC32_CHECKSUM)) {
+		compress_xform->compress.chksum = RTE_COMP_CHECKSUM_CRC32;
+		decompress_xform->decompress.chksum = RTE_COMP_CHECKSUM_CRC32;
+
+		for (i = 0; i < RTE_DIM(compress_test_bufs); i++) {
+			test_buffer = compress_test_bufs[i];
+
+			/* Generate zlib checksum and test against selected
+			 * drivers decompression checksum
+			 */
+			if (test_deflate_comp_decomp(&test_buffer, 1,
+					&i,
+					&compress_xform,
+					&decompress_xform,
+					1,
+					RTE_COMP_OP_STATELESS,
+					0,
+					ZLIB_COMPRESS) < 0) {
+				ret = TEST_FAILED;
+				goto exit;
+			}
+
+			/* Generate compression and decompression
+			 * checksum of selected driver
+			 */
+			if (test_deflate_comp_decomp(&test_buffer, 1,
+					&i,
+					&compress_xform,
+					&decompress_xform,
+					1,
+					RTE_COMP_OP_STATELESS,
+					0,
+					ZLIB_NONE) < 0) {
+				ret = TEST_FAILED;
+				goto exit;
+			}
+		}
+	}
+
+	/* Check if driver supports adler32 checksum and test */
+	if ((capab->comp_feature_flags & RTE_COMP_FF_ADLER32_CHECKSUM)) {
+		compress_xform->compress.chksum = RTE_COMP_CHECKSUM_ADLER32;
+		decompress_xform->decompress.chksum = RTE_COMP_CHECKSUM_ADLER32;
+
+		for (i = 0; i < RTE_DIM(compress_test_bufs); i++) {
+			test_buffer = compress_test_bufs[i];
+
+			/* Generate zlib checksum and test against selected
+			 * drivers decompression checksum
+			 */
+			if (test_deflate_comp_decomp(&test_buffer, 1,
+					&i,
+					&compress_xform,
+					&decompress_xform,
+					1,
+					RTE_COMP_OP_STATELESS,
+					0,
+					ZLIB_COMPRESS) < 0) {
+				ret = TEST_FAILED;
+				goto exit;
+			}
+			/* Generate compression and decompression
+			 * checksum of selected driver
+			 */
+			if (test_deflate_comp_decomp(&test_buffer, 1,
+					&i,
+					&compress_xform,
+					&decompress_xform,
+					1,
+					RTE_COMP_OP_STATELESS,
+					0,
+					ZLIB_NONE) < 0) {
+				ret = TEST_FAILED;
+				goto exit;
+			}
+		}
+	}
+
+	/* Check if driver supports combined crc and adler checksum and test */
+	if ((capab->comp_feature_flags & RTE_COMP_FF_CRC32_ADLER32_CHECKSUM)) {
+		compress_xform->compress.chksum =
+				RTE_COMP_CHECKSUM_CRC32_ADLER32;
+		decompress_xform->decompress.chksum =
+				RTE_COMP_CHECKSUM_CRC32_ADLER32;
+
+		for (i = 0; i < RTE_DIM(compress_test_bufs); i++) {
+			test_buffer = compress_test_bufs[i];
+
+			/* Generate zlib checksum and test against selected
+			 * drivers decompression checksum
+			 */
+			if (test_deflate_comp_decomp(&test_buffer, 1,
+					&i,
+					&compress_xform,
+					&decompress_xform,
+					1,
+					RTE_COMP_OP_STATELESS,
+					0,
+					ZLIB_COMPRESS) < 0) {
+				ret = TEST_FAILED;
+				goto exit;
+			}
+			/* Generate compression and decompression
+			 * checksum of selected driver
+			 */
+			if (test_deflate_comp_decomp(&test_buffer, 1,
+					&i,
+					&compress_xform,
+					&decompress_xform,
+					1,
+					RTE_COMP_OP_STATELESS,
+					0,
+					ZLIB_NONE) < 0) {
+				ret = TEST_FAILED;
+				goto exit;
+			}
+		}
+	}
+
+	ret = TEST_SUCCESS;
+
+exit:
+	rte_free(compress_xform);
+	rte_free(decompress_xform);
+	return ret;
 }
 
 static struct unit_test_suite compressdev_testsuite  = {
@@ -1473,6 +1670,8 @@ static struct unit_test_suite compressdev_testsuite  = {
 			test_compressdev_deflate_stateless_multi_xform),
 		TEST_CASE_ST(generic_ut_setup, generic_ut_teardown,
 			test_compressdev_deflate_stateless_sgl),
+		TEST_CASE_ST(generic_ut_setup, generic_ut_teardown,
+			test_compressdev_deflate_stateless_checksum),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
-- 
2.7.4

  reply	other threads:[~2018-10-09 16:21 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-09 16:21 [dpdk-dev] [PATCH 1/3] compress/isal: enable checksum support in driver Lee Daly
2018-10-09 16:21 ` Lee Daly [this message]
2018-10-11 10:37   ` [dpdk-dev] [PATCH 2/3] test/compress: add checksum tests Trahe, Fiona
2018-10-09 16:21 ` [dpdk-dev] [PATCH 3/3] doc: update ISA-L guide to reflect checksum support Lee Daly
2018-10-11 10:04   ` Trahe, Fiona
2018-11-28 10:41 ` [dpdk-dev] [PATCH v2 1/3] compress/isal: enable checksum support in driver Lee Daly
2018-11-28 10:41   ` [dpdk-dev] [PATCH v2 2/3] test/compress: add checksum tests Lee Daly
2018-12-05 13:57     ` Jozwiak, TomaszX
2018-12-12  0:25     ` Trahe, Fiona
2018-11-28 10:41   ` [dpdk-dev] [PATCH v2 3/3] doc: update ISA-L guide to reflect checksum support Lee Daly
2018-12-12  0:27     ` Trahe, Fiona
2018-12-12  0:10   ` [dpdk-dev] [PATCH v2 1/3] compress/isal: enable checksum support in driver Trahe, Fiona
2018-12-13 10:42   ` [dpdk-dev] [PATCH v3 " Lee Daly
2018-12-13 10:42     ` [dpdk-dev] [PATCH v3 2/3] test/compress: add checksum tests Lee Daly
2018-12-13 10:42     ` [dpdk-dev] [PATCH v3 3/3] doc: update ISA-L guide to reflect checksum support Lee Daly
2018-12-28  5:04       ` Varghese, Vipin
2019-01-07 10:37         ` Daly, Lee
2019-01-07 13:31           ` Varghese, Vipin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1539102109-9311-2-git-send-email-lee.daly@intel.com \
    --to=lee.daly@intel.com \
    --cc=akhil.goyal@nxp.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).