compress/isal: add ISA-L decomp functionality
authorLee Daly <lee.daly@intel.com>
Wed, 9 May 2018 16:14:34 +0000 (17:14 +0100)
committerPablo de Lara <pablo.de.lara.guarch@intel.com>
Thu, 10 May 2018 16:46:20 +0000 (17:46 +0100)
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 <lee.daly@intel.com>
Acked-by: Greg Tucker <greg.b.tucker@intel.com>
Reviewed-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
drivers/compress/isal/isal_compress_pmd.c
drivers/compress/isal/isal_compress_pmd_ops.c
drivers/compress/isal/isal_compress_pmd_private.h

index dbdee39..0f025a3 100644 (file)
@@ -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");
index 77d5d4b..970a041 100644 (file)
@@ -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;
 
index 6ba34a6..46e9fcf 100644 (file)
@@ -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;