[dpdk-dev,v3,09/11] compress/isal: add ISA-L decomp functionality
Checks
Commit Message
Signed-off-by: Lee Daly <lee.daly@intel.com>
---
drivers/compress/isal/isal_compress_pmd.c | 58 +++++++++++++++++++++++
drivers/compress/isal/isal_compress_pmd_ops.c | 8 ++++
drivers/compress/isal/isal_compress_pmd_private.h | 2 +
3 files changed, 68 insertions(+)
Comments
> -----Original Message-----
> From: Daly, Lee
> Sent: Tuesday, April 17, 2018 2:36 PM
> To: dev@dpdk.org
> Cc: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>; Tucker, Greg B
> <greg.b.tucker@intel.com>; Jain, Deepak K <deepak.k.jain@intel.com>; Trahe,
> Fiona <fiona.trahe@intel.com>; Daly, Lee <lee.daly@intel.com>
> Subject: [PATCH v3 09/11] compress/isal: add ISA-L decomp functionality
>
> Signed-off-by: Lee Daly <lee.daly@intel.com>
> ---
> drivers/compress/isal/isal_compress_pmd.c | 58
> +++++++++++++++++++++++
> drivers/compress/isal/isal_compress_pmd_ops.c | 8 ++++
> drivers/compress/isal/isal_compress_pmd_private.h | 2 +
> 3 files changed, 68 insertions(+)
>
> diff --git a/drivers/compress/isal/isal_compress_pmd.c
> b/drivers/compress/isal/isal_compress_pmd.c
> index 379e0a6..39674ec 100644
> --- a/drivers/compress/isal/isal_compress_pmd.c
> +++ b/drivers/compress/isal/isal_compress_pmd.c
> @@ -302,6 +302,63 @@ process_isal_deflate(struct rte_comp_op *op, struct
> isal_comp_qp *qp,
> return ret;
> }
>
> +/* Stateless Decompression Function */
> +static int
> +process_isal_inflate(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;
> +
> + /* Initialize decompression state */
> + isal_inflate_init(qp->state);
> +
> + /* Set op checksum, none by default */
> + if (priv_xform->decompress.chksum == RTE_COMP_CHECKSUM_CRC32)
> + qp->state->crc_flag = ISAL_GZIP;
> + else if (priv_xform->decompress.chksum ==
> RTE_COMP_CHECKSUM_ADLER32)
> + qp->state->crc_flag = ISAL_ZLIB;
Same comment as in patch 8, you can store this information in priv_xform.
@@ -302,6 +302,63 @@ process_isal_deflate(struct rte_comp_op *op, struct isal_comp_qp *qp,
return ret;
}
+/* Stateless Decompression Function */
+static int
+process_isal_inflate(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;
+
+ /* Initialize decompression state */
+ isal_inflate_init(qp->state);
+
+ /* Set op checksum, none by default */
+ if (priv_xform->decompress.chksum == RTE_COMP_CHECKSUM_CRC32)
+ qp->state->crc_flag = ISAL_GZIP;
+ else if (priv_xform->decompress.chksum == RTE_COMP_CHECKSUM_ADLER32)
+ qp->state->crc_flag = ISAL_ZLIB;
+
+ /* Point decompression state structure to input/output buffers */
+ qp->state->avail_in = op->src.length;
+ qp->state->next_in = rte_pktmbuf_mtod(op->m_src, uint8_t *);
+ qp->state->avail_out = op->m_dst->data_len;
+ qp->state->next_out = rte_pktmbuf_mtod(op->m_dst, uint8_t *);
+
+ if (unlikely(!qp->state->next_in || !qp->state->next_out)) {
+ ISAL_PMD_LOG(ERR, "Invalid source or destination buffers\n");
+ op->status = RTE_COMP_OP_STATUS_INVALID_ARGS;
+ return -1;
+ }
+
+ /* Execute decompression operation */
+ ret = isal_inflate_stateless(qp->state);
+
+ if (ret == ISAL_OUT_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->state->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 != ISAL_DECOMP_OK) {
+ op->status = RTE_COMP_OP_STATUS_ERROR;
+ return ret;
+ }
+
+ op->consumed = op->src.length - qp->state->avail_in;
+ op->produced = qp->state->total_out;
+
+return ret;
+}
+
/* Process compression operation */
static int
process_op(struct isal_comp_qp *qp, struct rte_comp_op *op,
@@ -312,6 +369,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, priv_xform);
break;
default:
ISAL_PMD_LOG(ERR, "Operation Not Supported\n");
@@ -157,6 +157,9 @@ struct isal_comp_qp *qp = dev->data->queue_pairs[qp_id];
if (qp->stream != NULL)
rte_free(qp->stream);
+ if (qp->state != NULL)
+ rte_free(qp->state);
+
if (dev->data->queue_pairs[qp_id] != NULL)
rte_free(dev->data->queue_pairs[qp_id]);
@@ -234,6 +237,11 @@ isal_comp_pmd_qp_setup(struct rte_compressdev *dev, uint16_t qp_id,
ISAL_DEF_LVL3_DEFAULT, RTE_CACHE_LINE_SIZE,
socket_id);
+ /* Initialize memory for decompression state structure */
+ qp->state = rte_zmalloc_socket("Isa-l decompression state",
+ sizeof(struct inflate_state), RTE_CACHE_LINE_SIZE,
+ socket_id);
+
qp->id = qp_id;
dev->data->queue_pairs[qp_id] = qp;
@@ -30,6 +30,8 @@ struct isal_comp_qp {
struct rte_compressdev_stats qp_stats;
/* Compression stream information*/
struct isal_zstream *stream;
+ /* Decompression state information*/
+ struct inflate_state *state;
/* Number of free elements on ring */
uint16_t num_free_elements;
} __rte_cache_aligned;