DPDK patches and discussions
 help / color / mirror / Atom feed
From: Lee Daly <lee.daly@intel.com>
To: dev@dpdk.org
Cc: pablo.de.lara.guarch@intel.com, greg.b.tucker@intel.com,
	deepak.k.jain@intel.com, fiona.trahe@intel.com,
	Lee Daly <lee.daly@intel.com>
Subject: [dpdk-dev] [PATCH v4 08/10] compress/isal: add ISA-L compression functionality
Date: Sat, 28 Apr 2018 00:38:31 +0100	[thread overview]
Message-ID: <1524872313-196340-9-git-send-email-lee.daly@intel.com> (raw)
In-Reply-To: <1524872313-196340-1-git-send-email-lee.daly@intel.com>

Adds compression functionality, this sets internal ISA-L structures, provides
input & output mbuf addresses, executes compression, which ISA-L calls deflate,
and finally error checks.

Signed-off-by: Lee Daly <lee.daly@intel.com>
---
 drivers/compress/isal/isal_compress_pmd.c         | 93 ++++++++++++++++++++++-
 drivers/compress/isal/isal_compress_pmd_ops.c     | 28 +++++++
 drivers/compress/isal/isal_compress_pmd_private.h |  2 +
 3 files changed, 121 insertions(+), 2 deletions(-)

diff --git a/drivers/compress/isal/isal_compress_pmd.c b/drivers/compress/isal/isal_compress_pmd.c
index b13822a..e09fd3f 100644
--- a/drivers/compress/isal/isal_compress_pmd.c
+++ b/drivers/compress/isal/isal_compress_pmd.c
@@ -6,6 +6,7 @@
 #include <rte_bus_vdev.h>
 #include <rte_common.h>
 #include <rte_malloc.h>
+#include <rte_mbuf.h>
 #include <rte_compressdev_pmd.h>
 
 #include "isal_compress_pmd_private.h"
@@ -208,14 +209,102 @@ isal_comp_set_priv_xform_parameters(struct isal_priv_xform *priv_xform,
 	return 0;
 }
 
+/* Stateless Compression Function */
+static int
+process_isal_deflate(struct rte_comp_op *op, struct isal_comp_qp *qp,
+		struct isal_priv_xform *priv_xform)
+{
+	int ret = 0;
+	op->status = RTE_COMP_OP_STATUS_SUCCESS;
+
+	/* Required due to init clearing level_buf */
+	uint8_t *temp_level_buf = qp->stream->level_buf;
+
+	/* Initialize compression stream */
+	isal_deflate_stateless_init(qp->stream);
+
+	qp->stream->level_buf = temp_level_buf;
+
+	qp->stream->flush = NO_FLUSH;
+
+	/* Set op checksum, none by default */
+	qp->stream->gzip_flag = priv_xform->compress.chksum;
+
+	/* set op level & intermediate level buffer */
+	qp->stream->level = priv_xform->compress.level;
+	qp->stream->level_buf_size = priv_xform->level_buffer_size;
+
+	/* Point compression stream structure to input/output buffers */
+	qp->stream->avail_in = op->src.length;
+	qp->stream->next_in = rte_pktmbuf_mtod(op->m_src, uint8_t *);
+	qp->stream->avail_out = op->m_dst->data_len;
+	qp->stream->next_out  = rte_pktmbuf_mtod(op->m_dst, uint8_t *);
+	qp->stream->end_of_stream = 1; /* All input consumed in one go */
+
+	if (unlikely(!qp->stream->next_in || !qp->stream->next_out)) {
+		ISAL_PMD_LOG(ERR, "Invalid source or destination buffers\n");
+		op->status = RTE_COMP_OP_STATUS_INVALID_ARGS;
+		return -1;
+	}
+
+	/* Set op huffman code */
+	if (priv_xform->compress.deflate.huffman == RTE_COMP_HUFFMAN_FIXED)
+		isal_deflate_set_hufftables(qp->stream, NULL,
+				IGZIP_HUFFTABLE_STATIC);
+	else if (priv_xform->compress.deflate.huffman ==
+			RTE_COMP_HUFFMAN_DEFAULT)
+		isal_deflate_set_hufftables(qp->stream, NULL,
+			IGZIP_HUFFTABLE_DEFAULT);
+	/* Dynamically change the huffman code to suit the input data */
+	else if (priv_xform->compress.deflate.huffman ==
+			RTE_COMP_HUFFMAN_DYNAMIC) {
+		struct isal_hufftables     hufftable;
+		struct isal_huff_histogram histogram;
+		memset(&histogram, 0, sizeof(struct isal_huff_histogram));
+
+		isal_update_histogram(qp->stream->next_in, qp->stream->avail_in,
+				&histogram);
+		isal_create_hufftables(&hufftable, &histogram);
+		isal_deflate_set_hufftables(qp->stream, &hufftable,
+				IGZIP_HUFFTABLE_CUSTOM);
+	}
+
+	/* Execute compression operation */
+	ret =  isal_deflate_stateless(qp->stream);
+
+	/* Check that output buffer did not run out of space */
+	if (ret == STATELESS_OVERFLOW) {
+		ISAL_PMD_LOG(ERR, "Output buffer not big enough\n");
+		op->status = RTE_COMP_OP_STATUS_OUT_OF_SPACE_TERMINATED;
+		return ret;
+	}
+
+	/* Check that input buffer has been fully consumed */
+	if (qp->stream->avail_in != (uint32_t)0) {
+		ISAL_PMD_LOG(ERR, "Input buffer could not be read entirely\n");
+		op->status = RTE_COMP_OP_STATUS_ERROR;
+		return -1;
+	}
+
+	if (ret != COMP_OK) {
+		op->status = RTE_COMP_OP_STATUS_ERROR;
+		return ret;
+	}
+
+	op->consumed = op->src.length - qp->stream->avail_in;
+	op->produced = qp->stream->total_out;
+
+	return ret;
+}
+
 /* Process compression/decompression operation */
 static int
-process_op(struct isal_comp_qp *qp __rte_unused,
-		struct rte_comp_op *op __rte_unused,
+process_op(struct isal_comp_qp *qp, struct rte_comp_op *op,
 		struct isal_priv_xform *priv_xform)
 {
 	switch (priv_xform->type) {
 	case RTE_COMP_COMPRESS:
+		process_isal_deflate(op, qp, priv_xform);
 		break;
 	case RTE_COMP_DECOMPRESS:
 		break;
diff --git a/drivers/compress/isal/isal_compress_pmd_ops.c b/drivers/compress/isal/isal_compress_pmd_ops.c
index dcf79bf..a72a886 100644
--- a/drivers/compress/isal/isal_compress_pmd_ops.c
+++ b/drivers/compress/isal/isal_compress_pmd_ops.c
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright(c) 2018 Intel Corporation
  */
+#include <isa-l.h>
 
 #include <rte_common.h>
 #include <rte_compressdev_pmd.h>
@@ -9,6 +10,17 @@
 #include "isal_compress_pmd_private.h"
 
 static const struct rte_compressdev_capabilities isal_pmd_capabilities[] = {
+	{
+		.algo = RTE_COMP_ALGO_DEFLATE,
+		.comp_feature_flags =	RTE_COMP_FF_ADLER32_CHECKSUM |
+					RTE_COMP_FF_CRC32_CHECKSUM |
+					RTE_COMP_FF_SHAREABLE_PRIV_XFORM,
+		.window_size = {
+			.min = 15,
+			.max = 15,
+			.increment = 0
+		},
+	},
 	RTE_COMP_END_OF_CAPABILITIES_LIST()
 };
 
@@ -146,6 +158,12 @@ isal_comp_pmd_qp_release(struct rte_compressdev *dev, uint16_t qp_id)
 	if (qp == NULL)
 		return -EINVAL;
 
+	if (qp->stream != NULL)
+		rte_free(qp->stream);
+
+	if (qp->stream->level_buf != NULL)
+		rte_free(qp->stream->level_buf);
+
 	if (dev->data->queue_pairs[qp_id] != NULL)
 		rte_free(dev->data->queue_pairs[qp_id]);
 
@@ -214,6 +232,16 @@ isal_comp_pmd_qp_setup(struct rte_compressdev *dev, uint16_t qp_id,
 		return (-ENOMEM);
 	}
 
+	/* Initialize memory for compression stream structure */
+	qp->stream = rte_zmalloc_socket("Isa-l compression stream ",
+			sizeof(struct isal_zstream),  RTE_CACHE_LINE_SIZE,
+			socket_id);
+
+	/* Initialize memory for compression level buffer */
+	qp->stream->level_buf = rte_zmalloc_socket("Isa-l compression lev_buf",
+			ISAL_DEF_LVL3_DEFAULT, RTE_CACHE_LINE_SIZE,
+			socket_id);
+
 	qp->id = qp_id;
 	dev->data->queue_pairs[qp_id] = qp;
 
diff --git a/drivers/compress/isal/isal_compress_pmd_private.h b/drivers/compress/isal/isal_compress_pmd_private.h
index 7505c76..6ba34a6 100644
--- a/drivers/compress/isal/isal_compress_pmd_private.h
+++ b/drivers/compress/isal/isal_compress_pmd_private.h
@@ -28,6 +28,8 @@ struct isal_comp_qp {
 	struct rte_ring *processed_pkts;
 	/* Queue pair statistics */
 	struct rte_compressdev_stats qp_stats;
+	/* Compression stream information*/
+	struct isal_zstream *stream;
 	/* Number of free elements on ring */
 	uint16_t num_free_elements;
 } __rte_cache_aligned;
-- 
2.7.4

  parent reply	other threads:[~2018-04-27 23:39 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-09 16:50 [dpdk-dev] [PATCH] compress/isal: ISA-L compression PMD Lee Daly
2018-04-06 18:13 ` [dpdk-dev] [PATCH v2] " Lee Daly
2018-04-17 13:35   ` [dpdk-dev] [PATCH v3 00/11] add " Lee Daly
2018-04-17 13:35     ` [dpdk-dev] [PATCH v3 01/11] compress/isal: add skeleton " Lee Daly
2018-04-24  8:56       ` De Lara Guarch, Pablo
2018-04-17 13:35     ` [dpdk-dev] [PATCH v3 02/11] compress/isal: add pmd device init and de-init Lee Daly
2018-04-24  9:21       ` De Lara Guarch, Pablo
2018-04-17 13:35     ` [dpdk-dev] [PATCH v3 03/11] compress/isal: add basic pmd ops Lee Daly
2018-04-24  9:28       ` De Lara Guarch, Pablo
2018-04-17 13:35     ` [dpdk-dev] [PATCH v3 04/11] compress/isal: add private xform related ops Lee Daly
2018-04-24  9:45       ` De Lara Guarch, Pablo
2018-04-17 13:35     ` [dpdk-dev] [PATCH v3 05/11] compress/isal: add queue pair " Lee Daly
2018-04-24  9:56       ` De Lara Guarch, Pablo
2018-04-26 16:44         ` Daly, Lee
2018-04-17 13:35     ` [dpdk-dev] [PATCH v3 06/11] compress/isal: support enqueue/dequeue api Lee Daly
2018-04-17 13:35     ` [dpdk-dev] [PATCH v3 07/11] compress/isal: add stats related ops Lee Daly
2018-04-17 13:35     ` [dpdk-dev] [PATCH v3 08/11] compress/isal: add ISA-L compression functionality Lee Daly
2018-04-24 10:05       ` De Lara Guarch, Pablo
2018-04-17 13:35     ` [dpdk-dev] [PATCH v3 09/11] compress/isal: add ISA-L decomp functionality Lee Daly
2018-04-24 10:09       ` De Lara Guarch, Pablo
2018-04-17 13:35     ` [dpdk-dev] [PATCH v3 10/11] compress/isal: add generic compression driver docs Lee Daly
2018-04-23 14:47       ` Kovacevic, Marko
2018-04-24 10:47       ` De Lara Guarch, Pablo
2018-04-24 11:06       ` De Lara Guarch, Pablo
2018-04-25 14:25         ` Daly, Lee
2018-04-17 13:35     ` [dpdk-dev] [PATCH v3 11/11] compress/isal: add ISA-L compression PMD docs Lee Daly
2018-04-23 14:53       ` Kovacevic, Marko
2018-04-23 15:33       ` Kovacevic, Marko
2018-04-23 15:51         ` Daly, Lee
2018-04-24 11:04       ` De Lara Guarch, Pablo
2018-04-27 23:38       ` [dpdk-dev] [PATCH v4 00/10] add ISA-L compression PMD Lee Daly
2018-04-27 23:38         ` [dpdk-dev] [PATCH v4 01/10] compress/isal: add skeleton " Lee Daly
2018-05-08 12:32           ` [dpdk-dev] [PATCH v5 00/10] add " Lee Daly
2018-05-08 12:32             ` [dpdk-dev] [PATCH v5 01/10] compress/isal: add skeleton " Lee Daly
2018-05-09 16:14               ` [dpdk-dev] [PATCH v6 00/10] add " Lee Daly
2018-05-09 16:14                 ` [dpdk-dev] [PATCH v6 01/10] compress/isal: add skeleton " Lee Daly
2018-05-09 16:14                 ` [dpdk-dev] [PATCH v6 02/10] compress/isal: add pmd device init and de-init Lee Daly
2018-05-09 16:14                 ` [dpdk-dev] [PATCH v6 03/10] compress/isal: add basic pmd ops Lee Daly
2018-05-09 16:14                 ` [dpdk-dev] [PATCH v6 04/10] compress/isal: add private xform related ops Lee Daly
2018-05-09 16:14                 ` [dpdk-dev] [PATCH v6 05/10] compress/isal: add queue pair " Lee Daly
2018-05-09 16:14                 ` [dpdk-dev] [PATCH v6 06/10] compress/isal: support enqueue/dequeue api Lee Daly
2018-05-09 16:14                 ` [dpdk-dev] [PATCH v6 07/10] compress/isal: add stats related ops Lee Daly
2018-05-09 16:14                 ` [dpdk-dev] [PATCH v6 08/10] compress/isal: add ISA-L compression functionality Lee Daly
2018-05-09 17:39                   ` Tucker, Greg B
2018-05-09 16:14                 ` [dpdk-dev] [PATCH v6 09/10] compress/isal: add ISA-L decomp functionality Lee Daly
2018-05-09 17:41                   ` Tucker, Greg B
2018-05-09 16:14                 ` [dpdk-dev] [PATCH v6 10/10] doc: add compression driver and ISA-L PMD docs Lee Daly
2018-05-09 20:56                 ` [dpdk-dev] [PATCH v6 00/10] add ISA-L compression PMD De Lara Guarch, Pablo
2018-05-09 21:36                   ` De Lara Guarch, Pablo
2018-05-08 12:32             ` [dpdk-dev] [PATCH v5 02/10] compress/isal: add pmd device init and de-init Lee Daly
2018-05-08 12:32             ` [dpdk-dev] [PATCH v5 03/10] compress/isal: add basic pmd ops Lee Daly
2018-05-08 12:32             ` [dpdk-dev] [PATCH v5 04/10] compress/isal: add private xform related ops Lee Daly
2018-05-08 12:32             ` [dpdk-dev] [PATCH v5 05/10] compress/isal: add queue pair " Lee Daly
2018-05-08 12:32             ` [dpdk-dev] [PATCH v5 06/10] compress/isal: support enqueue/dequeue api Lee Daly
2018-05-08 12:32             ` [dpdk-dev] [PATCH v5 07/10] compress/isal: add stats related ops Lee Daly
2018-05-08 12:32             ` [dpdk-dev] [PATCH v5 08/10] compress/isal: add ISA-L compression functionality Lee Daly
2018-05-08 12:32             ` [dpdk-dev] [PATCH v5 09/10] compress/isal: add ISA-L decomp functionality Lee Daly
2018-05-08 12:32             ` [dpdk-dev] [PATCH v5 10/10] doc: add compression driver and ISA-L PMD docs Lee Daly
2018-04-27 23:38         ` [dpdk-dev] [PATCH v4 02/10] compress/isal: add pmd device init and de-init Lee Daly
2018-04-27 23:38         ` [dpdk-dev] [PATCH v4 03/10] compress/isal: add basic pmd ops Lee Daly
2018-04-27 23:38         ` [dpdk-dev] [PATCH v4 04/10] compress/isal: add private xform related ops Lee Daly
2018-04-27 23:38         ` [dpdk-dev] [PATCH v4 05/10] compress/isal: add queue pair " Lee Daly
2018-04-27 23:38         ` [dpdk-dev] [PATCH v4 06/10] compress/isal: support enqueue/dequeue api Lee Daly
2018-05-03 21:46           ` De Lara Guarch, Pablo
2018-04-27 23:38         ` [dpdk-dev] [PATCH v4 07/10] compress/isal: add stats related ops Lee Daly
2018-04-27 23:38         ` Lee Daly [this message]
2018-05-03 21:37           ` [dpdk-dev] [PATCH v4 08/10] compress/isal: add ISA-L compression functionality De Lara Guarch, Pablo
2018-04-27 23:38         ` [dpdk-dev] [PATCH v4 09/10] compress/isal: add ISA-L decomp functionality Lee Daly
2018-04-27 23:38         ` [dpdk-dev] [PATCH v4 10/10] doc: add compression driver and ISA-L PMD docs Lee Daly
2018-05-03 21:49           ` 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=1524872313-196340-9-git-send-email-lee.daly@intel.com \
    --to=lee.daly@intel.com \
    --cc=deepak.k.jain@intel.com \
    --cc=dev@dpdk.org \
    --cc=fiona.trahe@intel.com \
    --cc=greg.b.tucker@intel.com \
    --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).