From: Lee Daly Date: Wed, 9 May 2018 16:14:34 +0000 (+0100) Subject: compress/isal: add ISA-L decomp functionality X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=7bf4f0630af6c6a97a7e2d71ef61b837b335dcef;p=dpdk.git compress/isal: add ISA-L decomp functionality Adds decompression functionality, similar to compression, this sets internal ISA-L structures, provides input & output mbuf addresses, executes decompression, which ISA-L calls inflate and finally error checks. Signed-off-by: Lee Daly Acked-by: Greg Tucker Reviewed-by: Pablo de Lara --- diff --git a/drivers/compress/isal/isal_compress_pmd.c b/drivers/compress/isal/isal_compress_pmd.c index dbdee39b54..0f025a3bf2 100644 --- a/drivers/compress/isal/isal_compress_pmd.c +++ b/drivers/compress/isal/isal_compress_pmd.c @@ -266,6 +266,56 @@ 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) +{ + int ret = 0; + + op->status = RTE_COMP_OP_STATUS_SUCCESS; + + /* Initialize decompression state */ + isal_inflate_init(qp->state); + + /* 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/decompression operation */ static int process_op(struct isal_comp_qp *qp, struct rte_comp_op *op, @@ -276,6 +326,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); 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 77d5d4b4b6..970a0413b9 100644 --- a/drivers/compress/isal/isal_compress_pmd_ops.c +++ b/drivers/compress/isal/isal_compress_pmd_ops.c @@ -162,6 +162,9 @@ isal_comp_pmd_qp_release(struct rte_compressdev *dev, uint16_t qp_id) if (qp->stream->level_buf != NULL) rte_free(qp->stream->level_buf); + if (qp->state != NULL) + rte_free(qp->state); + if (dev->data->queue_pairs[qp_id] != NULL) rte_free(dev->data->queue_pairs[qp_id]); @@ -240,6 +243,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; diff --git a/drivers/compress/isal/isal_compress_pmd_private.h b/drivers/compress/isal/isal_compress_pmd_private.h index 6ba34a6376..46e9fcfaab 100644 --- a/drivers/compress/isal/isal_compress_pmd_private.h +++ b/drivers/compress/isal/isal_compress_pmd_private.h @@ -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;