DPDK patches and discussions
 help / color / mirror / Atom feed
From: Lee Daly <lee.daly@intel.com>
To: akhil.goyal@nxp.com, pablo.de.lara.guarch@intel.com
Cc: dev@dpdk.org, Lee Daly <lee.daly@intel.com>
Subject: [dpdk-dev] [PATCH v7 2/2] compress/isal: enable checksum support in driver
Date: Tue,  8 Jan 2019 16:20:44 +0000	[thread overview]
Message-ID: <1546964444-193641-2-git-send-email-lee.daly@intel.com> (raw)
In-Reply-To: <1546964444-193641-1-git-send-email-lee.daly@intel.com>

This patch adds checksum support in the ISA-L  PMD for both compression
and decompression.
CRC32 is supported as well as Adler32.

V2:
Documentation Changes
V3:
Added Release note
V4:
Removed dependency on offset unit test
V5:
If checksum type is incorrect, compression will continue without checksum,
rather than failing now.
V6:
Include documentation in this patch rather than separate doc patch.

Signed-off-by: Lee Daly <lee.daly@intel.com>
Acked-by: Fiona Trahe <fiona.trahe@intel.com>
---
 doc/guides/compressdevs/features/isal.ini     |  2 +
 doc/guides/compressdevs/isal.rst              | 30 +++++++++-
 doc/guides/rel_notes/release_19_02.rst        |  4 ++
 drivers/compress/isal/isal_compress_pmd.c     | 82 ++++++++++++++++++++++-----
 drivers/compress/isal/isal_compress_pmd_ops.c |  4 +-
 5 files changed, 105 insertions(+), 17 deletions(-)

diff --git a/doc/guides/compressdevs/features/isal.ini b/doc/guides/compressdevs/features/isal.ini
index 919cf70..e705031 100644
--- a/doc/guides/compressdevs/features/isal.ini
+++ b/doc/guides/compressdevs/features/isal.ini
@@ -12,5 +12,7 @@ OOP SGL In SGL Out = Y
 OOP SGL In LB  Out = Y
 OOP LB  In SGL Out = Y
 Deflate            = Y
+Adler32            = Y
+Crc32              = Y
 Fixed              = Y
 Dynamic            = Y
diff --git a/doc/guides/compressdevs/isal.rst b/doc/guides/compressdevs/isal.rst
index 3bc3022..af1f41f 100644
--- a/doc/guides/compressdevs/isal.rst
+++ b/doc/guides/compressdevs/isal.rst
@@ -27,6 +27,33 @@ Window size support:
 
     * 32K
 
+Checksum:
+
+    * CRC32
+    * ADLER32
+
+To enable a checksum in the driver, the compression and/or decompression xform
+structure, rte_comp_xform, must be filled with either of the CompressDev
+checksum flags supported. ::
+
+ compress_xform->compress.chksum = RTE_COMP_CHECKSUM_CRC32
+
+ decompress_xform->decompress.chksum = RTE_COMP_CHECKSUM_CRC32
+
+::
+
+ compress_xform->compress.chksum = RTE_COMP_CHECKSUM_ADLER32
+
+ decompress_xform->decompress.chksum = RTE_COMP_CHECKSUM_ADLER32
+
+If you request a checksum for compression or decompression,
+the checksum field in the operation structure,  ``op->output_chksum``,
+will be filled with the checksum.
+
+.. Note::
+
+ For the compression case above, your output buffer will need to be large enough to hold the compressed data plus a scratchpad for the checksum at the end, the scratchpad is 8 bytes for CRC32 and 4 bytes for Adler32.
+
 Level guide:
 
 The ISA-L levels have been mapped to somewhat correspond to the same ZLIB level,
@@ -75,13 +102,12 @@ As a result the level mappings from the API to the PMD are shown below.
  The above table only shows mapping when API calls for dynamic compression.
  For fixed compression, regardless of API level, internally ISA-L level 0 is always used.
 
+
 Limitations
 -----------
 
 * Compressdev level 0, no compression, is not supported.
 
-* Checksums will not be supported until future release.
-
 Installation
 ------------
 
diff --git a/doc/guides/rel_notes/release_19_02.rst b/doc/guides/rel_notes/release_19_02.rst
index 8deb68b..286c060 100644
--- a/doc/guides/rel_notes/release_19_02.rst
+++ b/doc/guides/rel_notes/release_19_02.rst
@@ -60,6 +60,10 @@ New Features
   * Added the handler to get firmware version string.
   * Added support for multicast filtering.
 
+  * **Enabled checksum support in the ISA-L compressdev driver.**
+
+    Added support for both adler and crc32 checksums in the ISA-L PMD.
+    This aids data integrity across both compression and decompression.
 
 Removed Items
 -------------
diff --git a/drivers/compress/isal/isal_compress_pmd.c b/drivers/compress/isal/isal_compress_pmd.c
index 9f1e968..b610e90 100644
--- a/drivers/compress/isal/isal_compress_pmd.c
+++ b/drivers/compress/isal/isal_compress_pmd.c
@@ -16,6 +16,8 @@
 #define RTE_COMP_ISAL_LEVEL_ONE 1
 #define RTE_COMP_ISAL_LEVEL_TWO 2
 #define RTE_COMP_ISAL_LEVEL_THREE 3 /* Optimised for AVX512 & AVX2 only */
+#define CHKSUM_SZ_CRC 8
+#define CHKSUM_SZ_ADLER 4
 
 int isal_logtype_driver;
 
@@ -43,12 +45,6 @@ isal_comp_set_priv_xform_parameters(struct isal_priv_xform *priv_xform,
 		}
 		priv_xform->compress.algo = RTE_COMP_ALGO_DEFLATE;
 
-		/* Set private xform checksum - raw deflate by default */
-		if (xform->compress.chksum != RTE_COMP_CHECKSUM_NONE) {
-			ISAL_PMD_LOG(ERR, "Checksum not supported\n");
-			return -ENOTSUP;
-		}
-
 		/* Set private xform window size, 32K supported */
 		if (xform->compress.window_size == RTE_COMP_ISAL_WINDOW_SIZE)
 			priv_xform->compress.window_size =
@@ -77,6 +73,28 @@ isal_comp_set_priv_xform_parameters(struct isal_priv_xform *priv_xform,
 			return -ENOTSUP;
 		}
 
+		/* Set private xform checksum */
+		switch (xform->compress.chksum) {
+		/* Raw deflate by default */
+		case(RTE_COMP_CHECKSUM_NONE):
+			priv_xform->compress.chksum = IGZIP_DEFLATE;
+			break;
+		case(RTE_COMP_CHECKSUM_CRC32):
+			priv_xform->compress.chksum = IGZIP_GZIP_NO_HDR;
+			break;
+		case(RTE_COMP_CHECKSUM_ADLER32):
+			priv_xform->compress.chksum = IGZIP_ZLIB_NO_HDR;
+			break;
+		case(RTE_COMP_CHECKSUM_CRC32_ADLER32):
+			ISAL_PMD_LOG(ERR, "Combined CRC and ADLER checksum not"
+					" supported\n");
+			return -ENOTSUP;
+		default:
+			ISAL_PMD_LOG(ERR, "Checksum type not supported\n");
+			priv_xform->compress.chksum = IGZIP_DEFLATE;
+			break;
+		}
+
 		/* Set private xform level.
 		 * Checking compliance with compressdev API, -1 <= level => 9
 		 */
@@ -170,10 +188,26 @@ isal_comp_set_priv_xform_parameters(struct isal_priv_xform *priv_xform,
 		}
 		priv_xform->decompress.algo = RTE_COMP_ALGO_DEFLATE;
 
-		/* Set private xform checksum - raw deflate by default */
-		if (xform->compress.chksum != RTE_COMP_CHECKSUM_NONE) {
-			ISAL_PMD_LOG(ERR, "Checksum not supported\n");
+		/* Set private xform checksum */
+		switch (xform->decompress.chksum) {
+		/* Raw deflate by default */
+		case(RTE_COMP_CHECKSUM_NONE):
+			priv_xform->decompress.chksum = ISAL_DEFLATE;
+			break;
+		case(RTE_COMP_CHECKSUM_CRC32):
+			priv_xform->decompress.chksum = ISAL_GZIP_NO_HDR_VER;
+			break;
+		case(RTE_COMP_CHECKSUM_ADLER32):
+			priv_xform->decompress.chksum = ISAL_ZLIB_NO_HDR_VER;
+			break;
+		case(RTE_COMP_CHECKSUM_CRC32_ADLER32):
+			ISAL_PMD_LOG(ERR, "Combined CRC and ADLER checksum not"
+					" supported\n");
 			return -ENOTSUP;
+		default:
+			ISAL_PMD_LOG(ERR, "Checksum type not supported\n");
+			priv_xform->decompress.chksum = ISAL_DEFLATE;
+			break;
 		}
 
 		/* Set private xform window size, 32K supported */
@@ -376,6 +410,9 @@ process_isal_deflate(struct rte_comp_op *op, struct isal_comp_qp *qp,
 
 	qp->stream->level_buf = temp_level_buf;
 
+	/* Set Checksum flag */
+	qp->stream->gzip_flag = priv_xform->compress.chksum;
+
 	/* Stateless operation, input will be consumed in one go */
 	qp->stream->flush = NO_FLUSH;
 
@@ -459,8 +496,18 @@ process_isal_deflate(struct rte_comp_op *op, struct isal_comp_qp *qp,
 			return ret;
 		}
 	}
+
 	op->consumed = qp->stream->total_in;
-	op->produced = qp->stream->total_out;
+	if (qp->stream->gzip_flag == IGZIP_DEFLATE) {
+		op->produced = qp->stream->total_out;
+	} else if (qp->stream->gzip_flag == IGZIP_ZLIB_NO_HDR) {
+		op->produced = qp->stream->total_out - CHKSUM_SZ_ADLER;
+		op->output_chksum = qp->stream->internal_state.crc + 1;
+	} else {
+		op->produced = qp->stream->total_out - CHKSUM_SZ_CRC;
+		op->output_chksum = qp->stream->internal_state.crc;
+	}
+
 	isal_deflate_reset(qp->stream);
 
 	return ret;
@@ -468,7 +515,8 @@ process_isal_deflate(struct rte_comp_op *op, struct isal_comp_qp *qp,
 
 /* Stateless Decompression Function */
 static int
-process_isal_inflate(struct rte_comp_op *op, struct isal_comp_qp *qp)
+process_isal_inflate(struct rte_comp_op *op, struct isal_comp_qp *qp,
+		struct isal_priv_xform *priv_xform)
 {
 	int ret = 0;
 
@@ -477,6 +525,9 @@ process_isal_inflate(struct rte_comp_op *op, struct isal_comp_qp *qp)
 	/* Initialize decompression state */
 	isal_inflate_init(qp->state);
 
+	/* Set Checksum flag */
+	qp->state->crc_flag = priv_xform->decompress.chksum;
+
 	if (op->m_src->pkt_len < (op->src.length + op->src.offset)) {
 		ISAL_PMD_LOG(ERR, "Input mbuf(s) not big enough.\n");
 		op->status = RTE_COMP_OP_STATUS_INVALID_ARGS;
@@ -531,13 +582,16 @@ process_isal_inflate(struct rte_comp_op *op, struct isal_comp_qp *qp)
 			return -1;
 		}
 
-		if (ret != ISAL_DECOMP_OK) {
+		if (ret != ISAL_DECOMP_OK && ret != ISAL_END_INPUT) {
+			ISAL_PMD_LOG(ERR, "Decompression operation failed\n");
 			op->status = RTE_COMP_OP_STATUS_ERROR;
 			return ret;
 		}
 		op->consumed = op->src.length - qp->state->avail_in;
 	}
-		op->produced = qp->state->total_out;
+	op->produced = qp->state->total_out;
+	op->output_chksum = qp->state->crc;
+
 	isal_inflate_reset(qp->state);
 
 	return ret;
@@ -553,7 +607,7 @@ process_op(struct isal_comp_qp *qp, struct rte_comp_op *op,
 		process_isal_deflate(op, qp, priv_xform);
 		break;
 	case RTE_COMP_DECOMPRESS:
-		process_isal_inflate(op, qp);
+		process_isal_inflate(op, qp, priv_xform);
 		break;
 	default:
 		ISAL_PMD_LOG(ERR, "Operation Not Supported\n");
diff --git a/drivers/compress/isal/isal_compress_pmd_ops.c b/drivers/compress/isal/isal_compress_pmd_ops.c
index 41cade8..7b91849 100644
--- a/drivers/compress/isal/isal_compress_pmd_ops.c
+++ b/drivers/compress/isal/isal_compress_pmd_ops.c
@@ -17,7 +17,9 @@ static const struct rte_compressdev_capabilities isal_pmd_capabilities[] = {
 					RTE_COMP_FF_OOP_LB_IN_SGL_OUT |
 					RTE_COMP_FF_SHAREABLE_PRIV_XFORM |
 					RTE_COMP_FF_HUFFMAN_FIXED |
-					RTE_COMP_FF_HUFFMAN_DYNAMIC,
+					RTE_COMP_FF_HUFFMAN_DYNAMIC |
+					RTE_COMP_FF_CRC32_CHECKSUM |
+					RTE_COMP_FF_ADLER32_CHECKSUM,
 		.window_size = {
 			.min = 15,
 			.max = 15,
-- 
2.7.4

  reply	other threads:[~2019-01-08 16:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <11544697752-156863-1-git-send-email-lee.daly@intel.com>
2018-12-14  9:59 ` [dpdk-dev] [PATCH v4 1/3] " Lee Daly
2018-12-14  9:59   ` [dpdk-dev] [PATCH v4 2/3] test/compress: add checksum tests Lee Daly
2018-12-14  9:59   ` [dpdk-dev] [PATCH v4 3/3] doc: update ISA-L guide to reflect checksum support Lee Daly
2018-12-17  8:19   ` [dpdk-dev] [PATCH v4 1/3] compress/isal: enable checksum support in driver Varghese, Vipin
2018-12-17  9:20     ` Daly, Lee
2018-12-17 12:33       ` Varghese, Vipin
2018-12-19 15:48   ` [dpdk-dev] [PATCH v5 " Lee Daly
2018-12-19 15:48     ` [dpdk-dev] [PATCH v5 2/3] test/compress: add checksum tests Lee Daly
2018-12-19 15:48     ` [dpdk-dev] [PATCH v5 3/3] doc: update ISA-L guide to reflect checksum support Lee Daly
2019-01-08 10:29     ` [dpdk-dev] [PATCH v6 1/2] test/compress: add checksum tests Lee Daly
2019-01-08 10:29       ` [dpdk-dev] [PATCH v6 2/2] compress/isal: enable checksum support in driver Lee Daly
2019-01-08 14:58       ` [dpdk-dev] [PATCH v6 1/2] test/compress: add checksum tests De Lara Guarch, Pablo
2019-01-08 16:20       ` [dpdk-dev] [PATCH v7 " Lee Daly
2019-01-08 16:20         ` Lee Daly [this message]
2019-01-08 17:19         ` De Lara Guarch, Pablo

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=1546964444-193641-2-git-send-email-lee.daly@intel.com \
    --to=lee.daly@intel.com \
    --cc=akhil.goyal@nxp.com \
    --cc=dev@dpdk.org \
    --cc=pablo.de.lara.guarch@intel.com \
    /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).