* [dpdk-dev] [PATCH] compress/isal: add chained mbuf support @ 2018-07-05 11:03 Lee Daly 2018-07-11 12:40 ` [dpdk-dev] [PATCH v2] " Lee, Daly 0 siblings, 1 reply; 8+ messages in thread From: Lee Daly @ 2018-07-05 11:03 UTC (permalink / raw) To: pablo.de.lara.guarch; +Cc: dev, Lee Daly This patch adds chained mbuf support for input or output buffers during compression/decompression operations. Signed-off-by: Lee Daly <lee.daly@intel.com> --- doc/guides/compressdevs/features/isal.ini | 2 +- doc/guides/compressdevs/isal.rst | 2 - drivers/compress/isal/isal_compress_pmd.c | 224 +++++++++++++++++++++----- drivers/compress/isal/isal_compress_pmd_ops.c | 3 +- 4 files changed, 187 insertions(+), 44 deletions(-) diff --git a/doc/guides/compressdevs/features/isal.ini b/doc/guides/compressdevs/features/isal.ini index ad2718d..0966e69 100644 --- a/doc/guides/compressdevs/features/isal.ini +++ b/doc/guides/compressdevs/features/isal.ini @@ -12,7 +12,7 @@ CPU AVX512 = Y CPU NEON = Stateful = By-Pass = -Chained mbufs = +Chained mbufs = Y Deflate = Y LZS = Adler32 = diff --git a/doc/guides/compressdevs/isal.rst b/doc/guides/compressdevs/isal.rst index 276ff06..3bc3022 100644 --- a/doc/guides/compressdevs/isal.rst +++ b/doc/guides/compressdevs/isal.rst @@ -78,8 +78,6 @@ As a result the level mappings from the API to the PMD are shown below. Limitations ----------- -* Chained mbufs will not be supported until a future release, meaning max data size being passed to PMD through a single mbuf is 64K - 1. If data is larger than this it will need to be split up and sent as multiple operations. - * Compressdev level 0, no compression, is not supported. * Checksums will not be supported until future release. diff --git a/drivers/compress/isal/isal_compress_pmd.c b/drivers/compress/isal/isal_compress_pmd.c index 0f025a3..1ec2d98 100644 --- a/drivers/compress/isal/isal_compress_pmd.c +++ b/drivers/compress/isal/isal_compress_pmd.c @@ -188,6 +188,120 @@ isal_comp_set_priv_xform_parameters(struct isal_priv_xform *priv_xform, return 0; } +/* Compression using chained mbufs for input/output data */ +static int +chained_mbuf_compression(struct rte_comp_op *op, struct isal_comp_qp *qp) +{ + int ret; + uint32_t consumed_data; + uint32_t remaining_data = op->src.length; + struct rte_mbuf *src = op->m_src; + struct rte_mbuf *dst = op->m_dst; + + qp->stream->avail_in = src->data_len; + while (qp->stream->internal_state.state != ZSTATE_END) { + /* Last segment of data */ + if (remaining_data <= src->data_len) + qp->stream->end_of_stream = 1; + + /* Execute compression operation */ + ret = isal_deflate(qp->stream); + op->produced = qp->stream->total_out; + consumed_data = src->data_len - qp->stream->avail_in; + remaining_data -= consumed_data; + + if (ret != COMP_OK) { + op->status = RTE_COMP_OP_STATUS_ERROR; + return ret; + } + + if (qp->stream->avail_in == 0 && + qp->stream->total_in != op->src.length) { + if (src->next != NULL) { + src = src->next; + qp->stream->next_in = + rte_pktmbuf_mtod(src, uint8_t *); + qp->stream->avail_in = + RTE_MIN(remaining_data, src->data_len); + } + } + + if (qp->stream->avail_out == 0 && + qp->stream->internal_state.state != ZSTATE_END) { + if (dst->next != NULL) { + dst = dst->next; + qp->stream->next_out = + rte_pktmbuf_mtod(dst, uint8_t *); + qp->stream->avail_out = dst->data_len; + } else { + ISAL_PMD_LOG(ERR, + "Not enough output buffer segments\n" + "Output Produced: %d\n", op->produced); + op->status = + RTE_COMP_OP_STATUS_OUT_OF_SPACE_TERMINATED; + return -1; + } + } + } + op->consumed = qp->stream->total_in; + + return 0; +} + +/* Decompression using chained mbufs for input/output data */ +static int +chained_mbuf_decompression(struct rte_comp_op *op, struct isal_comp_qp *qp) +{ + int ret; + uint32_t consumed_data; + uint32_t remaining_data = op->src.length; + struct rte_mbuf *src = op->m_src; + struct rte_mbuf *dst = op->m_dst; + + qp->state->avail_in = src->data_len; + while (qp->state->block_state != ISAL_BLOCK_FINISH) { + + ret = isal_inflate(qp->state); + op->produced = qp->state->total_out; + consumed_data = src->data_len - qp->state->avail_in; + op->consumed += consumed_data; + remaining_data -= consumed_data; + + if (ret != ISAL_DECOMP_OK) { + op->status = RTE_COMP_OP_STATUS_ERROR; + return ret; + } + + if (qp->state->avail_in == 0 && + op->consumed != op->src.length) { + if (src->next != NULL) { + src = src->next; + qp->state->next_in = + rte_pktmbuf_mtod(src, uint8_t *); + qp->state->avail_in = + RTE_MIN(remaining_data, src->data_len); + } + } + + if (qp->state->avail_out == 0) { + if (dst->next != NULL) { + dst = dst->next; + qp->state->next_out = + rte_pktmbuf_mtod(dst, uint8_t *); + qp->state->avail_out = dst->data_len; + } else { + ISAL_PMD_LOG(ERR, + "Not enough output buffer segments\n"); + op->status = + RTE_COMP_OP_STATUS_OUT_OF_SPACE_TERMINATED; + return -1; + } + } + } + + return 0; +} + /* Stateless Compression Function */ static int process_isal_deflate(struct rte_comp_op *op, struct isal_comp_qp *qp, @@ -212,11 +326,9 @@ process_isal_deflate(struct rte_comp_op *op, struct isal_comp_qp *qp, 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"); @@ -224,6 +336,12 @@ process_isal_deflate(struct rte_comp_op *op, struct isal_comp_qp *qp, return -1; } + if (op->m_src->pkt_len < op->src.length) { + ISAL_PMD_LOG(ERR, "Input mbuf(s) not big enough.\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, @@ -238,30 +356,43 @@ process_isal_deflate(struct rte_comp_op *op, struct isal_comp_qp *qp, isal_deflate_set_hufftables(qp->stream, NULL, IGZIP_HUFFTABLE_DEFAULT); - /* 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; - } + /* Chained mbuf input/output */ + if (op->m_src->nb_segs > 1 || op->m_dst->nb_segs > 1) { + ret = chained_mbuf_compression(op, qp); + if (ret < 0) + return ret; + } else { + /* All input consumed in one go */ + qp->stream->end_of_stream = 1; + qp->stream->avail_in = op->src.length; + + /* 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; - } + /* 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; - } + if (ret != COMP_OK) { + op->status = RTE_COMP_OP_STATUS_ERROR; + return ret; + } - op->consumed = qp->stream->total_in; - op->produced = qp->stream->total_out; + op->consumed = qp->stream->total_in; + op->produced = qp->stream->total_out; + } return ret; } @@ -289,31 +420,43 @@ process_isal_inflate(struct rte_comp_op *op, struct isal_comp_qp *qp) 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; + if (op->m_src->pkt_len < op->src.length) { + ISAL_PMD_LOG(ERR, "Input mbuf(s) not big enough.\n"); + op->status = RTE_COMP_OP_STATUS_INVALID_ARGS; return -1; } - if (ret != ISAL_DECOMP_OK) { - op->status = RTE_COMP_OP_STATUS_ERROR; - return ret; - } + /* Chained mbuf input/output */ + if (op->m_src->nb_segs > 1 || op->m_dst->nb_segs > 1) { + ret = chained_mbuf_decompression(op, qp); + if (ret < 0) + return ret; + } else { + /* 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; + return ret; } /* Process compression/decompression operation */ @@ -353,6 +496,7 @@ isal_comp_pmd_enqueue_burst(void *queue_pair, struct rte_comp_op **ops, continue; } retval = process_op(qp, ops[i], ops[i]->private_xform); + if (unlikely(retval < 0) || ops[i]->status != RTE_COMP_OP_STATUS_SUCCESS) { qp->qp_stats.enqueue_err_count++; diff --git a/drivers/compress/isal/isal_compress_pmd_ops.c b/drivers/compress/isal/isal_compress_pmd_ops.c index 970a041..cf7bc6c 100644 --- a/drivers/compress/isal/isal_compress_pmd_ops.c +++ b/drivers/compress/isal/isal_compress_pmd_ops.c @@ -12,7 +12,8 @@ static const struct rte_compressdev_capabilities isal_pmd_capabilities[] = { { .algo = RTE_COMP_ALGO_DEFLATE, - .comp_feature_flags = RTE_COMP_FF_SHAREABLE_PRIV_XFORM, + .comp_feature_flags = RTE_COMP_FF_SHAREABLE_PRIV_XFORM | + RTE_COMP_FF_MBUF_SCATTER_GATHER, .window_size = { .min = 15, .max = 15, -- 2.7.4 ^ permalink raw reply [flat|nested] 8+ messages in thread
* [dpdk-dev] [PATCH v2] compress/isal: add chained mbuf support 2018-07-05 11:03 [dpdk-dev] [PATCH] compress/isal: add chained mbuf support Lee Daly @ 2018-07-11 12:40 ` Lee, Daly 2018-07-20 10:38 ` De Lara Guarch, Pablo 2018-07-23 18:02 ` [dpdk-dev] [PATCH v3] " Daly, Lee 0 siblings, 2 replies; 8+ messages in thread From: Lee, Daly @ 2018-07-11 12:40 UTC (permalink / raw) To: pablo.de.lara.guarch; +Cc: dev, Lee, Daly This patch adds chained mbuf support for input or output buffers during compression/decompression operations. V2 - Fixed using chained mbufs with offsets. Signed-off-by: Lee Daly <lee.daly@intel.com> --- doc/guides/compressdevs/features/isal.ini | 1 + doc/guides/compressdevs/isal.rst | 2 - drivers/compress/isal/isal_compress_pmd.c | 397 ++++++++++++++++++++------ drivers/compress/isal/isal_compress_pmd_ops.c | 5 +- 4 files changed, 321 insertions(+), 84 deletions(-) diff --git a/doc/guides/compressdevs/features/isal.ini b/doc/guides/compressdevs/features/isal.ini index 7183d10..06a95fb 100644 --- a/doc/guides/compressdevs/features/isal.ini +++ b/doc/guides/compressdevs/features/isal.ini @@ -8,6 +8,7 @@ CPU SSE = Y CPU AVX = Y CPU AVX2 = Y CPU AVX512 = Y +Chained mbufs = Y Deflate = Y Fixed = Y Dynamic = Y diff --git a/doc/guides/compressdevs/isal.rst b/doc/guides/compressdevs/isal.rst index 276ff06..3bc3022 100644 --- a/doc/guides/compressdevs/isal.rst +++ b/doc/guides/compressdevs/isal.rst @@ -78,8 +78,6 @@ As a result the level mappings from the API to the PMD are shown below. Limitations ----------- -* Chained mbufs will not be supported until a future release, meaning max data size being passed to PMD through a single mbuf is 64K - 1. If data is larger than this it will need to be split up and sent as multiple operations. - * Compressdev level 0, no compression, is not supported. * Checksums will not be supported until future release. diff --git a/drivers/compress/isal/isal_compress_pmd.c b/drivers/compress/isal/isal_compress_pmd.c index 747ded1..70231c4 100644 --- a/drivers/compress/isal/isal_compress_pmd.c +++ b/drivers/compress/isal/isal_compress_pmd.c @@ -188,6 +188,211 @@ isal_comp_set_priv_xform_parameters(struct isal_priv_xform *priv_xform, return 0; } +/* Compression using chained mbufs for input/output data */ +static int +chained_mbuf_compression(struct rte_comp_op *op, struct isal_comp_qp *qp) +{ + int ret, i; + uint8_t segs; + uint32_t consumed_data; + uint32_t remaining_data = op->src.length; + struct rte_mbuf *src = op->m_src; + struct rte_mbuf *dst = op->m_dst; + + /* check for offset passing multiple segments + * and point compression stream to input/output buffer + */ + if (op->src.offset > src->data_len) { + segs = op->src.offset / src->data_len; + for (i = 0; i < segs; i++) + src = src->next; + + qp->stream->avail_in = src->data_len - + (op->src.offset % src->data_len); + qp->stream->next_in = rte_pktmbuf_mtod_offset(src, uint8_t *, + (op->src.offset % src->data_len)); + } else { + qp->stream->avail_in = src->data_len - op->src.offset; + qp->stream->next_in = rte_pktmbuf_mtod_offset(src, uint8_t *, + op->src.offset); + } + + if (op->dst.offset > dst->data_len) { + segs = op->dst.offset / dst->data_len; + for (int i = 0; i < segs; i++) + dst = dst->next; + + qp->stream->avail_out = dst->data_len - + (op->dst.offset % dst->data_len); + qp->stream->next_out = rte_pktmbuf_mtod_offset(dst, uint8_t *, + (op->dst.offset % dst->data_len)); + } else { + qp->stream->avail_out = dst->data_len - op->dst.offset; + qp->stream->next_out = rte_pktmbuf_mtod_offset(dst, uint8_t *, + op->dst.offset); + } + + if (unlikely(!qp->stream->next_in || !qp->stream->next_out)) { + ISAL_PMD_LOG(ERR, "Invalid source or destination buffer\n"); + op->status = RTE_COMP_OP_STATUS_INVALID_ARGS; + return -1; + } + + while (qp->stream->internal_state.state != ZSTATE_END) { + /* Last segment of data */ + if (remaining_data <= src->data_len) + qp->stream->end_of_stream = 1; + + /* Execute compression operation */ + ret = isal_deflate(qp->stream); + + if (remaining_data == op->src.length) { + consumed_data = src->data_len - qp->stream->avail_in - + (op->src.offset % src->data_len); + } else + consumed_data = src->data_len - qp->stream->avail_in; + + remaining_data -= consumed_data; + + if (ret != COMP_OK) { + ISAL_PMD_LOG(ERR, "Compression operation failed\n"); + op->status = RTE_COMP_OP_STATUS_ERROR; + return ret; + } + + if (qp->stream->avail_in == 0 && + qp->stream->total_in != op->src.length) { + if (src->next != NULL) { + src = src->next; + qp->stream->next_in = + rte_pktmbuf_mtod(src, uint8_t *); + qp->stream->avail_in = + RTE_MIN(remaining_data, src->data_len); + } else { + ISAL_PMD_LOG(ERR, + "Not enough input buffer segments\n" + "Output Produced: %d\n", op->produced); + op->status = RTE_COMP_OP_STATUS_INVALID_ARGS; + return -1; + } + } + + if (qp->stream->avail_out == 0 && + qp->stream->internal_state.state != ZSTATE_END) { + if (dst->next != NULL) { + dst = dst->next; + qp->stream->next_out = + rte_pktmbuf_mtod(dst, uint8_t *); + qp->stream->avail_out = dst->data_len; + } else { + ISAL_PMD_LOG(ERR, + "Not enough output buffer segments\n" + "Output Produced: %d\n", op->produced); + op->status = + RTE_COMP_OP_STATUS_OUT_OF_SPACE_TERMINATED; + return -1; + } + } + } + op->consumed = qp->stream->total_in; + op->produced = qp->stream->total_out; + + return 0; +} + +/* Decompression using chained mbufs for input/output data */ +static int +chained_mbuf_decompression(struct rte_comp_op *op, struct isal_comp_qp *qp) +{ + int ret, i; + uint8_t segs; + uint32_t consumed_data; + uint32_t remaining_data = op->src.length; + struct rte_mbuf *src = op->m_src; + struct rte_mbuf *dst = op->m_dst; + + /* check for offset passing multiple segments + * and point decompression state to input/output buffer + */ + if (op->src.offset > src->data_len) { + segs = op->src.offset / src->data_len; + for (i = 0; i < segs; i++) + src = src->next; + + qp->state->avail_in = + src->data_len - (op->src.offset % src->data_len); + qp->state->next_in = rte_pktmbuf_mtod_offset(src, + uint8_t *, (op->src.offset % src->data_len)); + } else { + qp->state->avail_in = src->data_len - op->src.offset; + qp->state->next_in = rte_pktmbuf_mtod_offset(src, uint8_t *, + op->src.offset); + } + if (op->dst.offset > dst->data_len) { + segs = op->dst.offset / dst->data_len; + for (i = 0; i < segs; i++) + dst = dst->next; + + qp->state->avail_out = + dst->data_len - (op->dst.offset % dst->data_len); + qp->state->next_out = rte_pktmbuf_mtod_offset(dst, uint8_t *, + (op->dst.offset % dst->data_len)); + } else { + qp->state->avail_out = dst->data_len - op->dst.offset; + qp->state->next_out = rte_pktmbuf_mtod_offset(dst, uint8_t *, + op->dst.offset); + } + while (qp->state->block_state != ISAL_BLOCK_FINISH) { + + ret = isal_inflate(qp->state); + + if (remaining_data == op->src.length) { + consumed_data = src->data_len - qp->state->avail_in - + (op->src.offset % src->data_len); + } else + consumed_data = src->data_len - qp->state->avail_in; + + op->consumed += consumed_data; + remaining_data -= consumed_data; + + if (ret != ISAL_DECOMP_OK) { + ISAL_PMD_LOG(ERR, "Decompression operation failed\n"); + op->status = RTE_COMP_OP_STATUS_ERROR; + return ret; + } + + if (qp->state->avail_in == 0 + && op->consumed != op->src.length) { + if (src->next != NULL) { + src = src->next; + qp->state->next_in = + rte_pktmbuf_mtod(src, uint8_t *); + qp->state->avail_in = + RTE_MIN(remaining_data, src->data_len); + } + } + + if (qp->state->avail_out == 0 && + qp->state->block_state != ISAL_BLOCK_FINISH) { + if (dst->next != NULL) { + dst = dst->next; + qp->state->next_out = + rte_pktmbuf_mtod(dst, uint8_t *); + qp->state->avail_out = dst->data_len; + } else { + ISAL_PMD_LOG(ERR, + "Not enough output buffer segments\n"); + op->status = + RTE_COMP_OP_STATUS_OUT_OF_SPACE_TERMINATED; + return -1; + } + } + } + op->produced = qp->state->total_out; + + return 0; +} + /* Stateless Compression Function */ static int process_isal_deflate(struct rte_comp_op *op, struct isal_comp_qp *qp, @@ -207,7 +412,7 @@ process_isal_deflate(struct rte_comp_op *op, struct isal_comp_qp *qp, /* Stateless operation, input will be consumed in one go */ qp->stream->flush = NO_FLUSH; - /* set op level & intermediate level buffer */ + /* set compression level & intermediate level buffer size */ qp->stream->level = priv_xform->compress.level; qp->stream->level_buf_size = priv_xform->level_buffer_size; @@ -225,57 +430,72 @@ process_isal_deflate(struct rte_comp_op *op, struct isal_comp_qp *qp, isal_deflate_set_hufftables(qp->stream, NULL, IGZIP_HUFFTABLE_DEFAULT); - qp->stream->end_of_stream = 1; /* All input consumed in one go */ - if ((op->src.length + op->src.offset) > op->m_src->data_len) { - ISAL_PMD_LOG(ERR, "Input mbuf not big enough for offset.\n"); + 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; return -1; } - /* Point compression stream to input buffer */ - qp->stream->avail_in = op->src.length; - qp->stream->next_in = rte_pktmbuf_mtod_offset(op->m_src, uint8_t *, - op->src.offset); - if (op->dst.offset > op->m_dst->data_len) { - ISAL_PMD_LOG(ERR, "Output mbuf not big enough for offset.\n"); - op->status = RTE_COMP_OP_STATUS_INVALID_ARGS; - return -1; - } - /* Point compression stream to output buffer */ - qp->stream->avail_out = op->m_dst->data_len; - qp->stream->next_out = rte_pktmbuf_mtod_offset(op->m_dst, uint8_t *, - op->dst.offset); + /* Chained mbufs */ + if (op->m_src->nb_segs > 1 || op->m_dst->nb_segs > 1) { + ret = chained_mbuf_compression(op, qp); + if (ret < 0) //check the returns... ensure op status changed. + return ret; + } else { + /* Linear buffer */ + qp->stream->end_of_stream = 1; /* All input consumed in one go */ + if ((op->src.length + op->src.offset) > op->m_src->data_len) { + ISAL_PMD_LOG(ERR, "Input mbuf not big enough for offset.\n"); + op->status = RTE_COMP_OP_STATUS_INVALID_ARGS; + return -1; + } + /* Point compression stream to input buffer */ + qp->stream->avail_in = op->src.length; + qp->stream->next_in = rte_pktmbuf_mtod_offset(op->m_src, uint8_t *, + op->src.offset); + + if (op->dst.offset > op->m_dst->data_len) { + ISAL_PMD_LOG(ERR, "Output mbuf not big enough for offset.\n"); + op->status = RTE_COMP_OP_STATUS_INVALID_ARGS; + return -1; + } + /* Point compression stream to output buffer */ + qp->stream->avail_out = op->m_dst->data_len; + qp->stream->next_out = rte_pktmbuf_mtod_offset(op->m_dst, uint8_t *, + op->dst.offset); - 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; - } + 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; + } - /* Execute compression operation */ - ret = isal_deflate_stateless(qp->stream); + /* 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 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; - } + /* 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; - } + if (ret != COMP_OK) { + ISAL_PMD_LOG(ERR, "Compression operation failed\n"); + op->status = RTE_COMP_OP_STATUS_ERROR; + return ret; + } - op->consumed = qp->stream->total_in; - op->produced = qp->stream->total_out; + op->consumed = qp->stream->total_in; + op->produced = qp->stream->total_out; + } return ret; } @@ -291,57 +511,72 @@ process_isal_inflate(struct rte_comp_op *op, struct isal_comp_qp *qp) /* Initialize decompression state */ isal_inflate_init(qp->state); - if ((op->src.length + op->src.offset) > op->m_src->data_len) { - ISAL_PMD_LOG(ERR, "Input mbuf not big enough for offset.\n"); + 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; return -1; } - /* Point decompression state to input buffer */ - qp->state->avail_in = op->src.length; - qp->state->next_in = rte_pktmbuf_mtod_offset(op->m_src, uint8_t *, - op->src.offset); - if (op->dst.offset > op->m_dst->data_len) { - ISAL_PMD_LOG(ERR, "Output mbuf not big enough for offset.\n"); - op->status = RTE_COMP_OP_STATUS_INVALID_ARGS; + /* Chained mbufs */ + if (op->m_src->nb_segs > 1 || op->m_dst->nb_segs > 1) { + ret = chained_mbuf_decompression(op, qp); + if (ret != 0) + return ret; + } else { + /* Linear buffer */ + if ((op->src.length + op->src.offset) > op->m_src->data_len) { + ISAL_PMD_LOG(ERR, "Input mbuf not big enough for offset.\n"); + op->status = RTE_COMP_OP_STATUS_INVALID_ARGS; return -1; - } - /* Point decompression state to output buffer */ - qp->state->avail_out = op->m_dst->data_len; - qp->state->next_out = rte_pktmbuf_mtod_offset(op->m_dst, uint8_t *, - op->dst.offset); + } + /* Point decompression state to input buffer */ + qp->state->avail_in = op->src.length; + qp->state->next_in = rte_pktmbuf_mtod_offset(op->m_src, uint8_t *, + op->src.offset); + + if (op->dst.offset > op->m_dst->data_len) { + ISAL_PMD_LOG(ERR, "Output mbuf not big enough for offset.\n"); + op->status = RTE_COMP_OP_STATUS_INVALID_ARGS; + return -1; + } + /* Point decompression state to output buffer */ + qp->state->avail_out = op->m_dst->data_len; + qp->state->next_out = rte_pktmbuf_mtod_offset(op->m_dst, uint8_t *, + op->dst.offset); + + 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; + } - 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); - /* 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; + } - 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; + } - /* 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) { + ISAL_PMD_LOG(ERR, "Decompression operation failed\n"); + op->status = RTE_COMP_OP_STATUS_ERROR; + return ret; + } - 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; } - op->consumed = op->src.length - qp->state->avail_in; - op->produced = qp->state->total_out; - -return ret; + return ret; } /* Process compression/decompression operation */ diff --git a/drivers/compress/isal/isal_compress_pmd_ops.c b/drivers/compress/isal/isal_compress_pmd_ops.c index 585f228..b8c0ca1 100644 --- a/drivers/compress/isal/isal_compress_pmd_ops.c +++ b/drivers/compress/isal/isal_compress_pmd_ops.c @@ -12,7 +12,10 @@ static const struct rte_compressdev_capabilities isal_pmd_capabilities[] = { { .algo = RTE_COMP_ALGO_DEFLATE, - .comp_feature_flags = RTE_COMP_FF_SHAREABLE_PRIV_XFORM | + .comp_feature_flags = RTE_COMP_FF_OOP_SGL_IN_SGL_OUT | + RTE_COMP_FF_OOP_SGL_IN_LB_OUT | + RTE_COMP_FF_OOP_LB_IN_SGL_OUT | + RTE_COMP_FF_SHAREABLE_PRIV_XFORM | RTE_COMP_FF_HUFFMAN_FIXED | RTE_COMP_FF_HUFFMAN_DYNAMIC, .window_size = { -- 2.7.4 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [dpdk-dev] [PATCH v2] compress/isal: add chained mbuf support 2018-07-11 12:40 ` [dpdk-dev] [PATCH v2] " Lee, Daly @ 2018-07-20 10:38 ` De Lara Guarch, Pablo 2018-07-23 18:02 ` [dpdk-dev] [PATCH v3] " Daly, Lee 1 sibling, 0 replies; 8+ messages in thread From: De Lara Guarch, Pablo @ 2018-07-20 10:38 UTC (permalink / raw) To: Daly, Lee; +Cc: dev Hi Lee, > -----Original Message----- > From: Daly, Lee > Sent: Wednesday, July 11, 2018 1:40 PM > To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com> > Cc: dev@dpdk.org; Daly, Lee <lee.daly@intel.com> > Subject: [PATCH v2] compress/isal: add chained mbuf support > > This patch adds chained mbuf support for input or output buffers during > compression/decompression operations. > > V2 - Fixed using chained mbufs with offsets. > > Signed-off-by: Lee Daly <lee.daly@intel.com> > --- > doc/guides/compressdevs/features/isal.ini | 1 + > doc/guides/compressdevs/isal.rst | 2 - > drivers/compress/isal/isal_compress_pmd.c | 397 ++++++++++++++++++++--- > --- > drivers/compress/isal/isal_compress_pmd_ops.c | 5 +- > 4 files changed, 321 insertions(+), 84 deletions(-) > > diff --git a/doc/guides/compressdevs/features/isal.ini > b/doc/guides/compressdevs/features/isal.ini > index 7183d10..06a95fb 100644 > --- a/doc/guides/compressdevs/features/isal.ini > +++ b/doc/guides/compressdevs/features/isal.ini > @@ -8,6 +8,7 @@ CPU SSE = Y > CPU AVX = Y > CPU AVX2 = Y > CPU AVX512 = Y > +Chained mbufs = Y There are new feature flags replacing this one. > Deflate = Y > Fixed = Y > Dynamic = Y > diff --git a/doc/guides/compressdevs/isal.rst > b/doc/guides/compressdevs/isal.rst > index 276ff06..3bc3022 100644 > --- a/doc/guides/compressdevs/isal.rst > +++ b/doc/guides/compressdevs/isal.rst > @@ -78,8 +78,6 @@ As a result the level mappings from the API to the PMD are > shown below. > Limitations > ----------- > > -* Chained mbufs will not be supported until a future release, meaning max data > size being passed to PMD through a single mbuf is 64K - 1. If data is larger than > this it will need to be split up and sent as multiple operations. > - > * Compressdev level 0, no compression, is not supported. > > * Checksums will not be supported until future release. > diff --git a/drivers/compress/isal/isal_compress_pmd.c > b/drivers/compress/isal/isal_compress_pmd.c > index 747ded1..70231c4 100644 > --- a/drivers/compress/isal/isal_compress_pmd.c > +++ b/drivers/compress/isal/isal_compress_pmd.c > @@ -188,6 +188,211 @@ isal_comp_set_priv_xform_parameters(struct > isal_priv_xform *priv_xform, > return 0; > } > > +/* Compression using chained mbufs for input/output data */ static int > +chained_mbuf_compression(struct rte_comp_op *op, struct isal_comp_qp > +*qp) { > + int ret, i; "i" should be unsigned int. > + uint8_t segs; > + uint32_t consumed_data; > + uint32_t remaining_data = op->src.length; > + struct rte_mbuf *src = op->m_src; > + struct rte_mbuf *dst = op->m_dst; > + > + /* check for offset passing multiple segments > + * and point compression stream to input/output buffer > + */ > + if (op->src.offset > src->data_len) { >= > + segs = op->src.offset / src->data_len; This is assuming that each segment has the same data length. Better to do a while loop, decreasing the offset (remaining_offset?), and moving to the next segment, until it is less than the current segment. > + for (i = 0; i < segs; i++) > + src = src->next; > + > + qp->stream->avail_in = src->data_len - > + (op->src.offset % src->data_len); Doing what I suggested above simplifies this, as you can substract "remaining_offset" to data_len. > + qp->stream->next_in = rte_pktmbuf_mtod_offset(src, uint8_t *, > + (op->src.offset % src->data_len)); > + } else { > + qp->stream->avail_in = src->data_len - op->src.offset; > + qp->stream->next_in = rte_pktmbuf_mtod_offset(src, uint8_t *, > + op->src.offset); > + } > + > + if (op->dst.offset > dst->data_len) { > + segs = op->dst.offset / dst->data_len; > + for (int i = 0; i < segs; i++) > + dst = dst->next; Same as above. > + > + qp->stream->avail_out = dst->data_len - > + (op->dst.offset % dst->data_len); > + qp->stream->next_out = rte_pktmbuf_mtod_offset(dst, uint8_t > *, > + (op->dst.offset % dst->data_len)); ... > + if (remaining_data == op->src.length) { > + consumed_data = src->data_len - qp->stream->avail_in > - > + (op->src.offset % src->data_len); > + } else > + consumed_data = src->data_len - qp->stream->avail_in; > + > + remaining_data -= consumed_data; What about "remaining_data = op->src.length - qp->stream->total_in"? This way, you don't need the condition (nor "consumed_data"). > + > + if (ret != COMP_OK) { > + ISAL_PMD_LOG(ERR, "Compression operation > failed\n"); > + op->status = RTE_COMP_OP_STATUS_ERROR; > + return ret; > + } ... > + } else { > + ISAL_PMD_LOG(ERR, > + "Not enough input buffer segments\n" > + "Output Produced: %d\n", op- > >produced); This will always be 0, as it is only updated at the end of the function. > + op->status = > RTE_COMP_OP_STATUS_INVALID_ARGS; > + return -1; > + } > + } > + ... > + ISAL_PMD_LOG(ERR, > + "Not enough output buffer segments\n" > + "Output Produced: %d\n", op- > >produced); Same as above. > + op->status = > + > RTE_COMP_OP_STATUS_OUT_OF_SPACE_TERMINATED; > + return -1; > + } > + } > + } > + op->consumed = qp->stream->total_in; > + op->produced = qp->stream->total_out; > + > + return 0; > +} > + > +/* Decompression using chained mbufs for input/output data */ static > +int chained_mbuf_decompression(struct rte_comp_op *op, struct > +isal_comp_qp *qp) { Most comments from the compression function applies to the decompression one. > /* Stateless Compression Function */ > static int > process_isal_deflate(struct rte_comp_op *op, struct isal_comp_qp *qp, @@ - ... > + /* Chained mbufs */ > + if (op->m_src->nb_segs > 1 || op->m_dst->nb_segs > 1) { > + ret = chained_mbuf_compression(op, qp); > + if (ret < 0) //check the returns... ensure op status changed. > + return ret; > + } else { > + /* Linear buffer */ > + qp->stream->end_of_stream = 1; /* All input consumed in one > go */ > + if ((op->src.length + op->src.offset) > op->m_src->data_len) { This is unnecessary, as the check that you are doing above is effectively the same. > + ISAL_PMD_LOG(ERR, "Input mbuf not big enough for > offset.\n"); > + op->status = RTE_COMP_OP_STATUS_INVALID_ARGS; ... > + /* Point compression stream to output buffer */ > + qp->stream->avail_out = op->m_dst->data_len; Data_len - dst.offset? > + qp->stream->next_out = rte_pktmbuf_mtod_offset(op->m_dst, > uint8_t *, > + op->dst.offset); > ... > @@ -291,57 +511,72 @@ process_isal_inflate(struct rte_comp_op *op, struct > isal_comp_qp *qp) ... > + /* Chained mbufs */ > + if (op->m_src->nb_segs > 1 || op->m_dst->nb_segs > 1) { > + ret = chained_mbuf_decompression(op, qp); > + if (ret != 0) > + return ret; > + } else { > + /* Linear buffer */ > + if ((op->src.length + op->src.offset) > op->m_src->data_len) { This is unnecessary, as the check that you are doing above is effectively the same. > + ISAL_PMD_LOG(ERR, "Input mbuf not big enough for > offset.\n"); > + op->status = RTE_COMP_OP_STATUS_INVALID_ARGS; > return -1; > - } ... > + /* Point decompression state to output buffer */ > + qp->state->avail_out = op->m_dst->data_len; Data_len - dst.offset? ... > - if (ret != ISAL_DECOMP_OK) { > - op->status = RTE_COMP_OP_STATUS_ERROR; > - return ret; > + op->consumed = op->src.length - qp->state->avail_in; What about "total_in"? > + op->produced = qp->state->total_out; > } > > - op->consumed = op->src.length - qp->state->avail_in; > - op->produced = qp->state->total_out; > - > -return ret; > + return ret; > } ^ permalink raw reply [flat|nested] 8+ messages in thread
* [dpdk-dev] [PATCH v3] compress/isal: add chained mbuf support 2018-07-11 12:40 ` [dpdk-dev] [PATCH v2] " Lee, Daly 2018-07-20 10:38 ` De Lara Guarch, Pablo @ 2018-07-23 18:02 ` Daly, Lee 2018-07-23 21:14 ` De Lara Guarch, Pablo 2018-07-24 11:19 ` [dpdk-dev] [PATCH v4] " Daly, Lee 1 sibling, 2 replies; 8+ messages in thread From: Daly, Lee @ 2018-07-23 18:02 UTC (permalink / raw) To: pablo.de.lara.guarch; +Cc: dev, Daly, Lee This patch adds chained mbuf support for input or output buffers during compression/decompression operations. Signed-off-by: Lee Daly <lee.daly@intel.com> --- doc/guides/compressdevs/features/isal.ini | 17 +- doc/guides/compressdevs/isal.rst | 2 - drivers/compress/isal/isal_compress_pmd.c | 397 ++++++++++++++++++++------ drivers/compress/isal/isal_compress_pmd_ops.c | 5 +- 4 files changed, 323 insertions(+), 98 deletions(-) diff --git a/doc/guides/compressdevs/features/isal.ini b/doc/guides/compressdevs/features/isal.ini index 7183d10..919cf70 100644 --- a/doc/guides/compressdevs/features/isal.ini +++ b/doc/guides/compressdevs/features/isal.ini @@ -4,10 +4,13 @@ ; Supported features of 'ISA-L' compression driver. ; [Features] -CPU SSE = Y -CPU AVX = Y -CPU AVX2 = Y -CPU AVX512 = Y -Deflate = Y -Fixed = Y -Dynamic = Y +CPU SSE = Y +CPU AVX = Y +CPU AVX2 = Y +CPU AVX512 = Y +OOP SGL In SGL Out = Y +OOP SGL In LB Out = Y +OOP LB In SGL Out = Y +Deflate = Y +Fixed = Y +Dynamic = Y diff --git a/doc/guides/compressdevs/isal.rst b/doc/guides/compressdevs/isal.rst index 276ff06..3bc3022 100644 --- a/doc/guides/compressdevs/isal.rst +++ b/doc/guides/compressdevs/isal.rst @@ -78,8 +78,6 @@ As a result the level mappings from the API to the PMD are shown below. Limitations ----------- -* Chained mbufs will not be supported until a future release, meaning max data size being passed to PMD through a single mbuf is 64K - 1. If data is larger than this it will need to be split up and sent as multiple operations. - * Compressdev level 0, no compression, is not supported. * Checksums will not be supported until future release. diff --git a/drivers/compress/isal/isal_compress_pmd.c b/drivers/compress/isal/isal_compress_pmd.c index 5966cc3..a776019 100644 --- a/drivers/compress/isal/isal_compress_pmd.c +++ b/drivers/compress/isal/isal_compress_pmd.c @@ -188,6 +188,206 @@ isal_comp_set_priv_xform_parameters(struct isal_priv_xform *priv_xform, return 0; } +/* Compression using chained mbufs for input/output data */ +static int +chained_mbuf_compression(struct rte_comp_op *op, struct isal_comp_qp *qp) +{ + int ret; + uint32_t remaining_offset; + uint32_t remaining_data = op->src.length; + struct rte_mbuf *src = op->m_src; + struct rte_mbuf *dst = op->m_dst; + + /* check for offset passing multiple segments + * and point compression stream to input/output buffer + */ + if (op->src.offset > src->data_len) { + remaining_offset = op->src.offset; + while (remaining_offset > src->data_len) { + remaining_offset -= src->data_len; + src = src->next; + } + + + qp->stream->avail_in = src->data_len - remaining_offset; + qp->stream->next_in = rte_pktmbuf_mtod_offset(src, uint8_t *, + (op->src.offset % src->data_len)); + } else { + qp->stream->avail_in = src->data_len - op->src.offset; + qp->stream->next_in = rte_pktmbuf_mtod_offset(src, uint8_t *, + op->src.offset); + } + + if (op->dst.offset > dst->data_len) { + remaining_offset = op->dst.offset; + while (remaining_offset > dst->data_len) { + remaining_offset -= dst->data_len; + dst = dst->next; + } + + qp->stream->avail_out = dst->data_len - remaining_offset; + qp->stream->next_out = rte_pktmbuf_mtod_offset(dst, uint8_t *, + (op->dst.offset % dst->data_len)); + } else { + qp->stream->avail_out = dst->data_len - op->dst.offset; + qp->stream->next_out = rte_pktmbuf_mtod_offset(dst, uint8_t *, + op->dst.offset); + } + + if (unlikely(!qp->stream->next_in || !qp->stream->next_out)) { + ISAL_PMD_LOG(ERR, "Invalid source or destination buffer\n"); + op->status = RTE_COMP_OP_STATUS_INVALID_ARGS; + return -1; + } + + while (qp->stream->internal_state.state != ZSTATE_END) { + /* Last segment of data */ + if (remaining_data <= src->data_len) + qp->stream->end_of_stream = 1; + + /* Execute compression operation */ + ret = isal_deflate(qp->stream); + + remaining_data = op->src.length - qp->stream->total_in; + + if (ret != COMP_OK) { + ISAL_PMD_LOG(ERR, "Compression operation failed\n"); + op->status = RTE_COMP_OP_STATUS_ERROR; + return ret; + } + + if (qp->stream->avail_in == 0 && + qp->stream->total_in != op->src.length) { + if (src->next != NULL) { + src = src->next; + qp->stream->next_in = + rte_pktmbuf_mtod(src, uint8_t *); + qp->stream->avail_in = + RTE_MIN(remaining_data, src->data_len); + } else { + ISAL_PMD_LOG(ERR, + "Not enough input buffer segments\n"); + op->status = RTE_COMP_OP_STATUS_INVALID_ARGS; + return -1; + } + } + + if (qp->stream->avail_out == 0 && + qp->stream->internal_state.state != ZSTATE_END) { + if (dst->next != NULL) { + dst = dst->next; + qp->stream->next_out = + rte_pktmbuf_mtod(dst, uint8_t *); + qp->stream->avail_out = dst->data_len; + } else { + ISAL_PMD_LOG(ERR, + "Not enough output buffer segments\n"); + op->status = + RTE_COMP_OP_STATUS_OUT_OF_SPACE_TERMINATED; + return -1; + } + } + } + op->consumed = qp->stream->total_in; + op->produced = qp->stream->total_out; + + return 0; +} + +/* Decompression using chained mbufs for input/output data */ +static int +chained_mbuf_decompression(struct rte_comp_op *op, struct isal_comp_qp *qp) +{ + int ret; + uint32_t consumed_data, remaining_offset; + uint32_t remaining_data = op->src.length; + struct rte_mbuf *src = op->m_src; + struct rte_mbuf *dst = op->m_dst; + + /* check for offset passing multiple segments + * and point decompression state to input/output buffer + */ + if (op->src.offset > src->data_len) { + remaining_offset = op->src.offset; + while (remaining_offset > src->data_len) { + remaining_offset -= src->data_len; + src = src->next; + } + + qp->state->avail_in = src->data_len - remaining_offset; + qp->state->next_in = rte_pktmbuf_mtod_offset(src, + uint8_t *, (op->src.offset % src->data_len)); + } else { + qp->state->avail_in = src->data_len - op->src.offset; + qp->state->next_in = rte_pktmbuf_mtod_offset(src, uint8_t *, + op->src.offset); + } + if (op->dst.offset > dst->data_len) { + remaining_offset = op->dst.offset; + while (remaining_offset > dst->data_len) { + remaining_offset -= dst->data_len; + dst = dst->next; + } + + qp->state->avail_out = dst->data_len - remaining_offset; + qp->state->next_out = rte_pktmbuf_mtod_offset(dst, uint8_t *, + (op->dst.offset % dst->data_len)); + } else { + qp->state->avail_out = dst->data_len - op->dst.offset; + qp->state->next_out = rte_pktmbuf_mtod_offset(dst, uint8_t *, + op->dst.offset); + } + while (qp->state->block_state != ISAL_BLOCK_FINISH) { + + ret = isal_inflate(qp->state); + + if (remaining_data == op->src.length) { + consumed_data = src->data_len - qp->state->avail_in - + (op->src.offset % src->data_len); + } else + consumed_data = src->data_len - qp->state->avail_in; + + op->consumed += consumed_data; + remaining_data -= consumed_data; + + if (ret != ISAL_DECOMP_OK) { + ISAL_PMD_LOG(ERR, "Decompression operation failed\n"); + op->status = RTE_COMP_OP_STATUS_ERROR; + return ret; + } + + if (qp->state->avail_in == 0 + && op->consumed != op->src.length) { + if (src->next != NULL) { + src = src->next; + qp->state->next_in = + rte_pktmbuf_mtod(src, uint8_t *); + qp->state->avail_in = + RTE_MIN(remaining_data, src->data_len); + } + } + + if (qp->state->avail_out == 0 && + qp->state->block_state != ISAL_BLOCK_FINISH) { + if (dst->next != NULL) { + dst = dst->next; + qp->state->next_out = + rte_pktmbuf_mtod(dst, uint8_t *); + qp->state->avail_out = dst->data_len; + } else { + ISAL_PMD_LOG(ERR, + "Not enough output buffer segments\n"); + op->status = + RTE_COMP_OP_STATUS_OUT_OF_SPACE_TERMINATED; + return -1; + } + } + } + op->produced = qp->state->total_out; + + return 0; +} + /* Stateless Compression Function */ static int process_isal_deflate(struct rte_comp_op *op, struct isal_comp_qp *qp, @@ -207,7 +407,7 @@ process_isal_deflate(struct rte_comp_op *op, struct isal_comp_qp *qp, /* Stateless operation, input will be consumed in one go */ qp->stream->flush = NO_FLUSH; - /* set op level & intermediate level buffer */ + /* set compression level & intermediate level buffer size */ qp->stream->level = priv_xform->compress.level; qp->stream->level_buf_size = priv_xform->level_buffer_size; @@ -225,59 +425,70 @@ process_isal_deflate(struct rte_comp_op *op, struct isal_comp_qp *qp, isal_deflate_set_hufftables(qp->stream, NULL, IGZIP_HUFFTABLE_DEFAULT); - qp->stream->end_of_stream = 1; /* All input consumed in one go */ - if ((op->src.length + op->src.offset) > op->m_src->data_len) { - ISAL_PMD_LOG(ERR, "Input mbuf not big enough for the length and" - " offset provided.\n"); - op->status = RTE_COMP_OP_STATUS_INVALID_ARGS; - return -1; - } - /* Point compression stream to input buffer */ - qp->stream->avail_in = op->src.length; - qp->stream->next_in = rte_pktmbuf_mtod_offset(op->m_src, uint8_t *, - op->src.offset); - - if (op->dst.offset > op->m_dst->data_len) { - ISAL_PMD_LOG(ERR, "Output mbuf not big enough for the length" - " and offset provided.\n"); + 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; return -1; } - /* Point compression stream to output buffer */ - qp->stream->avail_out = op->m_dst->data_len - op->dst.offset; - qp->stream->next_out = rte_pktmbuf_mtod_offset(op->m_dst, uint8_t *, - op->dst.offset); - 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; - } + /* Chained mbufs */ + if (op->m_src->nb_segs > 1 || op->m_dst->nb_segs > 1) { + ret = chained_mbuf_compression(op, qp); + if (ret < 0) + return ret; + } else { + /* Linear buffer */ + qp->stream->end_of_stream = 1; /* All input consumed in one */ + /* Point compression stream to input buffer */ + qp->stream->avail_in = op->src.length; + qp->stream->next_in = rte_pktmbuf_mtod_offset(op->m_src, + uint8_t *, op->src.offset); + + if (op->dst.offset > op->m_dst->data_len) { + ISAL_PMD_LOG(ERR, "Output mbuf not big enough for " + "length and offset provided.\n"); + op->status = RTE_COMP_OP_STATUS_INVALID_ARGS; + return -1; + } + /* Point compression stream to output buffer */ + qp->stream->avail_out = op->m_dst->data_len - op->dst.offset; + qp->stream->next_out = rte_pktmbuf_mtod_offset(op->m_dst, + uint8_t *, op->dst.offset); + + 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; + } - /* Execute compression operation */ - ret = isal_deflate_stateless(qp->stream); + /* 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 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; - } + /* 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; - } + if (ret != COMP_OK) { + ISAL_PMD_LOG(ERR, "Compression operation failed\n"); + op->status = RTE_COMP_OP_STATUS_ERROR; + return ret; + } - op->consumed = qp->stream->total_in; - op->produced = qp->stream->total_out; + op->consumed = qp->stream->total_in; + op->produced = qp->stream->total_out; + } return ret; } @@ -293,59 +504,69 @@ process_isal_inflate(struct rte_comp_op *op, struct isal_comp_qp *qp) /* Initialize decompression state */ isal_inflate_init(qp->state); - if ((op->src.length + op->src.offset) > op->m_src->data_len) { - ISAL_PMD_LOG(ERR, "Input mbuf not big enough for the length and" - " offset provided.\n"); - op->status = RTE_COMP_OP_STATUS_INVALID_ARGS; - return -1; - } - /* Point decompression state to input buffer */ - qp->state->avail_in = op->src.length; - qp->state->next_in = rte_pktmbuf_mtod_offset(op->m_src, uint8_t *, - op->src.offset); - - if (op->dst.offset > op->m_dst->data_len) { - ISAL_PMD_LOG(ERR, "Output mbuf not big enough for the length " - "and offset provided.\n"); + 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; return -1; } - /* Point decompression state to output buffer */ - qp->state->avail_out = op->m_dst->data_len - op->dst.offset; - qp->state->next_out = rte_pktmbuf_mtod_offset(op->m_dst, uint8_t *, - op->dst.offset); - 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; - } + /* Chained mbufs */ + if (op->m_src->nb_segs > 1 || op->m_dst->nb_segs > 1) { + ret = chained_mbuf_decompression(op, qp); + if (ret != 0) + return ret; + } else { + /* Linear buffer */ + /* Point decompression state to input buffer */ + qp->state->avail_in = op->src.length; + qp->state->next_in = rte_pktmbuf_mtod_offset(op->m_src, + uint8_t *, op->src.offset); + + if (op->dst.offset > op->m_dst->data_len) { + ISAL_PMD_LOG(ERR, "Output mbuf not big enough for " + "length and offset provided.\n"); + op->status = RTE_COMP_OP_STATUS_INVALID_ARGS; + return -1; + } + /* Point decompression state to output buffer */ + qp->state->avail_out = op->m_dst->data_len - op->dst.offset; + qp->state->next_out = rte_pktmbuf_mtod_offset(op->m_dst, + uint8_t *, op->dst.offset); + + 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); + /* 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; - } + 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; - } + /* 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; - } + 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; + op->consumed = op->src.length - qp->state->avail_in; + op->produced = qp->state->total_out; + } -return ret; + return ret; } /* Process compression/decompression operation */ diff --git a/drivers/compress/isal/isal_compress_pmd_ops.c b/drivers/compress/isal/isal_compress_pmd_ops.c index c61acd4..41cade8 100644 --- a/drivers/compress/isal/isal_compress_pmd_ops.c +++ b/drivers/compress/isal/isal_compress_pmd_ops.c @@ -12,7 +12,10 @@ static const struct rte_compressdev_capabilities isal_pmd_capabilities[] = { { .algo = RTE_COMP_ALGO_DEFLATE, - .comp_feature_flags = RTE_COMP_FF_SHAREABLE_PRIV_XFORM | + .comp_feature_flags = RTE_COMP_FF_OOP_SGL_IN_SGL_OUT | + RTE_COMP_FF_OOP_SGL_IN_LB_OUT | + RTE_COMP_FF_OOP_LB_IN_SGL_OUT | + RTE_COMP_FF_SHAREABLE_PRIV_XFORM | RTE_COMP_FF_HUFFMAN_FIXED | RTE_COMP_FF_HUFFMAN_DYNAMIC, .window_size = { -- 2.7.4 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [dpdk-dev] [PATCH v3] compress/isal: add chained mbuf support 2018-07-23 18:02 ` [dpdk-dev] [PATCH v3] " Daly, Lee @ 2018-07-23 21:14 ` De Lara Guarch, Pablo 2018-07-24 11:19 ` [dpdk-dev] [PATCH v4] " Daly, Lee 1 sibling, 0 replies; 8+ messages in thread From: De Lara Guarch, Pablo @ 2018-07-23 21:14 UTC (permalink / raw) To: Daly, Lee; +Cc: dev, Daly, Lee Hi Lee, > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Daly, Lee > Sent: Monday, July 23, 2018 7:02 PM > To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com> > Cc: dev@dpdk.org; Daly, Lee <lee.daly@intel.com> > Subject: [dpdk-dev] [PATCH v3] compress/isal: add chained mbuf support > > This patch adds chained mbuf support for input or output buffers during > compression/decompression operations. > > Signed-off-by: Lee Daly <lee.daly@intel.com> > --- > doc/guides/compressdevs/features/isal.ini | 17 +- > doc/guides/compressdevs/isal.rst | 2 - > drivers/compress/isal/isal_compress_pmd.c | 397 ++++++++++++++++++++--- > --- ... > +++ b/drivers/compress/isal/isal_compress_pmd.c > @@ -188,6 +188,206 @@ isal_comp_set_priv_xform_parameters(struct > isal_priv_xform *priv_xform, > return 0; > } > > +/* Compression using chained mbufs for input/output data */ static int > +chained_mbuf_compression(struct rte_comp_op *op, struct isal_comp_qp > +*qp) { > + int ret; > + uint32_t remaining_offset; > + uint32_t remaining_data = op->src.length; > + struct rte_mbuf *src = op->m_src; > + struct rte_mbuf *dst = op->m_dst; > + > + /* check for offset passing multiple segments > + * and point compression stream to input/output buffer > + */ > + if (op->src.offset > src->data_len) { Check also for equal here (offset >= data_len). In that case, you need to get the next segment and start from byte 0 there. > + remaining_offset = op->src.offset; > + while (remaining_offset > src->data_len) { Same here, check for equal too. > + remaining_offset -= src->data_len; > + src = src->next; > + } > + > + > + qp->stream->avail_in = src->data_len - remaining_offset; I think we need to check for minimum value between "data_len - remaining_offset" and src.length. > + qp->stream->next_in = rte_pktmbuf_mtod_offset(src, uint8_t *, > + (op->src.offset % src->data_len)); Use remaining_offset here. > + } else { > + qp->stream->avail_in = src->data_len - op->src.offset; Same thing here, about the minimum value with src.length. Actually, I think you can remove the if and just keep the code under if (remove the code under else). It should work for both cases, and you save one extra condition. > + qp->stream->next_in = rte_pktmbuf_mtod_offset(src, uint8_t *, > + op->src.offset); > + } > + > + if (op->dst.offset > dst->data_len) { > + remaining_offset = op->dst.offset; > + while (remaining_offset > dst->data_len) { > + remaining_offset -= dst->data_len; > + dst = dst->next; > + } > + > + qp->stream->avail_out = dst->data_len - remaining_offset; > + qp->stream->next_out = rte_pktmbuf_mtod_offset(dst, uint8_t > *, > + (op->dst.offset % dst->data_len)); > + } else { > + qp->stream->avail_out = dst->data_len - op->dst.offset; > + qp->stream->next_out = rte_pktmbuf_mtod_offset(dst, uint8_t > *, > + op->dst.offset); > + } Same comments apply for the destination buffer (except for the src.length ones). > + > + if (unlikely(!qp->stream->next_in || !qp->stream->next_out)) { > + ISAL_PMD_LOG(ERR, "Invalid source or destination buffer\n"); > + op->status = RTE_COMP_OP_STATUS_INVALID_ARGS; > + return -1; > + } > + ... > +int chained_mbuf_decompression(struct rte_comp_op *op, struct > +isal_comp_qp *qp) { > + int ret; > + uint32_t consumed_data, remaining_offset; > + uint32_t remaining_data = op->src.length; > + struct rte_mbuf *src = op->m_src; > + struct rte_mbuf *dst = op->m_dst; > + > + /* check for offset passing multiple segments > + * and point decompression state to input/output buffer > + */ > + if (op->src.offset > src->data_len) { > + remaining_offset = op->src.offset; > + while (remaining_offset > src->data_len) { > + remaining_offset -= src->data_len; > + src = src->next; > + } > + > + qp->state->avail_in = src->data_len - remaining_offset; > + qp->state->next_in = rte_pktmbuf_mtod_offset(src, > + uint8_t *, (op->src.offset % src->data_len)); > + } else { > + qp->state->avail_in = src->data_len - op->src.offset; > + qp->state->next_in = rte_pktmbuf_mtod_offset(src, uint8_t *, > + op->src.offset); > + } > + if (op->dst.offset > dst->data_len) { > + remaining_offset = op->dst.offset; > + while (remaining_offset > dst->data_len) { > + remaining_offset -= dst->data_len; > + dst = dst->next; > + } > + > + qp->state->avail_out = dst->data_len - remaining_offset; > + qp->state->next_out = rte_pktmbuf_mtod_offset(dst, uint8_t *, > + (op->dst.offset % dst->data_len)); > + } else { > + qp->state->avail_out = dst->data_len - op->dst.offset; > + qp->state->next_out = rte_pktmbuf_mtod_offset(dst, uint8_t *, > + op->dst.offset); > + } Same comments as above (compression). > + while (qp->state->block_state != ISAL_BLOCK_FINISH) { > + > + ret = isal_inflate(qp->state); > + > + if (remaining_data == op->src.length) { I would put a comment before this if saying that this is checking for the first segment to compress, so offset needs to be taken into account. > + consumed_data = src->data_len - qp->state->avail_in - > + (op->src.offset % src->data_len); Better to use "remaining_offset". > + } else > + consumed_data = src->data_len - qp->state->avail_in; > + > + op->consumed += consumed_data; > + remaining_data -= consumed_data; > + > + if (ret != ISAL_DECOMP_OK) { > + ISAL_PMD_LOG(ERR, "Decompression operation > failed\n"); > + op->status = RTE_COMP_OP_STATUS_ERROR; > + return ret; > + } > + ... > process_isal_deflate(struct rte_comp_op *op, struct isal_comp_qp *qp, @@ - > 207,7 +407,7 @@ process_isal_deflate(struct rte_comp_op *op, struct > isal_comp_qp *qp, > /* Stateless operation, input will be consumed in one go */ > qp->stream->flush = NO_FLUSH; > > - /* set op level & intermediate level buffer */ > + /* set compression level & intermediate level buffer size */ > qp->stream->level = priv_xform->compress.level; > qp->stream->level_buf_size = priv_xform->level_buffer_size; > > @@ -225,59 +425,70 @@ process_isal_deflate(struct rte_comp_op *op, struct > isal_comp_qp *qp, > isal_deflate_set_hufftables(qp->stream, NULL, > IGZIP_HUFFTABLE_DEFAULT); > > - qp->stream->end_of_stream = 1; /* All input consumed in one go */ > - if ((op->src.length + op->src.offset) > op->m_src->data_len) { > - ISAL_PMD_LOG(ERR, "Input mbuf not big enough for the length > and" > - " offset provided.\n"); > - op->status = RTE_COMP_OP_STATUS_INVALID_ARGS; > - return -1; > - } > - /* Point compression stream to input buffer */ > - qp->stream->avail_in = op->src.length; > - qp->stream->next_in = rte_pktmbuf_mtod_offset(op->m_src, uint8_t *, > - op->src.offset); > - > - if (op->dst.offset > op->m_dst->data_len) { > - ISAL_PMD_LOG(ERR, "Output mbuf not big enough for the > length" > - " and offset provided.\n"); > + 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; > return -1; > } > - /* Point compression stream to output buffer */ > - qp->stream->avail_out = op->m_dst->data_len - op->dst.offset; > - qp->stream->next_out = rte_pktmbuf_mtod_offset(op->m_dst, uint8_t > *, > - op->dst.offset); > > - 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; > - } > + /* Chained mbufs */ > + if (op->m_src->nb_segs > 1 || op->m_dst->nb_segs > 1) { > + ret = chained_mbuf_compression(op, qp); > + if (ret < 0) > + return ret; > + } else { > + /* Linear buffer */ > + qp->stream->end_of_stream = 1; /* All input consumed in one > */ > + /* Point compression stream to input buffer */ > + qp->stream->avail_in = op->src.length; > + qp->stream->next_in = rte_pktmbuf_mtod_offset(op->m_src, > + uint8_t *, op->src.offset); > + > + if (op->dst.offset > op->m_dst->data_len) { > + ISAL_PMD_LOG(ERR, "Output mbuf not big enough for > " > + "length and offset provided.\n"); > + op->status = RTE_COMP_OP_STATUS_INVALID_ARGS; > + return -1; > + } This if should be done also for SGL case, so I would move it outside this (after the input check), but using pkt_len. ... > @@ -293,59 +504,69 @@ process_isal_inflate(struct rte_comp_op *op, struct ... > + > + if (op->dst.offset > op->m_dst->data_len) { > + ISAL_PMD_LOG(ERR, "Output mbuf not big enough for > " > + "length and offset provided.\n"); > + op->status = RTE_COMP_OP_STATUS_INVALID_ARGS; > + return -1; > + } Same comment as the previous one. ^ permalink raw reply [flat|nested] 8+ messages in thread
* [dpdk-dev] [PATCH v4] compress/isal: add chained mbuf support 2018-07-23 18:02 ` [dpdk-dev] [PATCH v3] " Daly, Lee 2018-07-23 21:14 ` De Lara Guarch, Pablo @ 2018-07-24 11:19 ` Daly, Lee 2018-07-24 13:27 ` De Lara Guarch, Pablo 1 sibling, 1 reply; 8+ messages in thread From: Daly, Lee @ 2018-07-24 11:19 UTC (permalink / raw) To: pablo.de.lara.guarch; +Cc: dev, Daly, Lee This patch adds chained mbuf support for input or output buffers during compression/decompression operations. V2 - split chained mbuf functionality into separate functions. - code optimizations. V3 - bug fixes & optimizations. v4 - bug fixes & optimizations. Signed-off-by: Lee Daly <lee.daly@intel.com> --- doc/guides/compressdevs/features/isal.ini | 17 +- doc/guides/compressdevs/isal.rst | 2 - drivers/compress/isal/isal_compress_pmd.c | 350 ++++++++++++++++++++------ drivers/compress/isal/isal_compress_pmd_ops.c | 5 +- 4 files changed, 286 insertions(+), 88 deletions(-) diff --git a/doc/guides/compressdevs/features/isal.ini b/doc/guides/compressdevs/features/isal.ini index 7183d10..919cf70 100644 --- a/doc/guides/compressdevs/features/isal.ini +++ b/doc/guides/compressdevs/features/isal.ini @@ -4,10 +4,13 @@ ; Supported features of 'ISA-L' compression driver. ; [Features] -CPU SSE = Y -CPU AVX = Y -CPU AVX2 = Y -CPU AVX512 = Y -Deflate = Y -Fixed = Y -Dynamic = Y +CPU SSE = Y +CPU AVX = Y +CPU AVX2 = Y +CPU AVX512 = Y +OOP SGL In SGL Out = Y +OOP SGL In LB Out = Y +OOP LB In SGL Out = Y +Deflate = Y +Fixed = Y +Dynamic = Y diff --git a/doc/guides/compressdevs/isal.rst b/doc/guides/compressdevs/isal.rst index 276ff06..3bc3022 100644 --- a/doc/guides/compressdevs/isal.rst +++ b/doc/guides/compressdevs/isal.rst @@ -78,8 +78,6 @@ As a result the level mappings from the API to the PMD are shown below. Limitations ----------- -* Chained mbufs will not be supported until a future release, meaning max data size being passed to PMD through a single mbuf is 64K - 1. If data is larger than this it will need to be split up and sent as multiple operations. - * Compressdev level 0, no compression, is not supported. * Checksums will not be supported until future release. diff --git a/drivers/compress/isal/isal_compress_pmd.c b/drivers/compress/isal/isal_compress_pmd.c index 5966cc3..c2bcd2d 100644 --- a/drivers/compress/isal/isal_compress_pmd.c +++ b/drivers/compress/isal/isal_compress_pmd.c @@ -188,6 +188,179 @@ isal_comp_set_priv_xform_parameters(struct isal_priv_xform *priv_xform, return 0; } +/* Compression using chained mbufs for input/output data */ +static int +chained_mbuf_compression(struct rte_comp_op *op, struct isal_comp_qp *qp) +{ + int ret; + uint32_t remaining_offset; + uint32_t remaining_data = op->src.length; + struct rte_mbuf *src = op->m_src; + struct rte_mbuf *dst = op->m_dst; + + /* check for source/destination offset passing multiple segments + * and point compression stream to input/output buffer. + */ + remaining_offset = op->src.offset; + while (remaining_offset >= src->data_len) { + remaining_offset -= src->data_len; + src = src->next; + } + qp->stream->avail_in = RTE_MIN(src->data_len - remaining_offset, + op->src.length); + qp->stream->next_in = rte_pktmbuf_mtod_offset(src, uint8_t *, + remaining_offset); + + remaining_offset = op->dst.offset; + while (remaining_offset >= dst->data_len) { + remaining_offset -= dst->data_len; + dst = dst->next; + } + qp->stream->avail_out = dst->data_len - remaining_offset; + qp->stream->next_out = rte_pktmbuf_mtod_offset(dst, uint8_t *, + remaining_offset); + + if (unlikely(!qp->stream->next_in || !qp->stream->next_out)) { + ISAL_PMD_LOG(ERR, "Invalid source or destination buffer\n"); + op->status = RTE_COMP_OP_STATUS_INVALID_ARGS; + return -1; + } + + while (qp->stream->internal_state.state != ZSTATE_END) { + /* Last segment of data */ + if (remaining_data <= src->data_len) + qp->stream->end_of_stream = 1; + + /* Execute compression operation */ + ret = isal_deflate(qp->stream); + + remaining_data = op->src.length - qp->stream->total_in; + + if (ret != COMP_OK) { + ISAL_PMD_LOG(ERR, "Compression operation failed\n"); + op->status = RTE_COMP_OP_STATUS_ERROR; + return ret; + } + + if (qp->stream->avail_in == 0 && + qp->stream->total_in != op->src.length) { + if (src->next != NULL) { + src = src->next; + qp->stream->next_in = + rte_pktmbuf_mtod(src, uint8_t *); + qp->stream->avail_in = + RTE_MIN(remaining_data, src->data_len); + } else { + ISAL_PMD_LOG(ERR, + "Not enough input buffer segments\n"); + op->status = RTE_COMP_OP_STATUS_INVALID_ARGS; + return -1; + } + } + + if (qp->stream->avail_out == 0 && + qp->stream->internal_state.state != ZSTATE_END) { + if (dst->next != NULL) { + dst = dst->next; + qp->stream->next_out = + rte_pktmbuf_mtod(dst, uint8_t *); + qp->stream->avail_out = dst->data_len; + } else { + ISAL_PMD_LOG(ERR, + "Not enough output buffer segments\n"); + op->status = + RTE_COMP_OP_STATUS_OUT_OF_SPACE_TERMINATED; + return -1; + } + } + } + + return 0; +} + +/* Decompression using chained mbufs for input/output data */ +static int +chained_mbuf_decompression(struct rte_comp_op *op, struct isal_comp_qp *qp) +{ + int ret; + uint32_t consumed_data, remaining_offset; + uint32_t remaining_data = op->src.length; + struct rte_mbuf *src = op->m_src; + struct rte_mbuf *dst = op->m_dst; + + /* check for offset passing multiple segments + * and point decompression state to input/output buffer + */ + remaining_offset = op->src.offset; + while (remaining_offset >= src->data_len) { + remaining_offset -= src->data_len; + src = src->next; + } + qp->state->avail_in = RTE_MIN(src->data_len - remaining_offset, + op->src.length); + qp->state->next_in = rte_pktmbuf_mtod_offset(src, uint8_t *, + remaining_offset); + + remaining_offset = op->dst.offset; + while (remaining_offset >= dst->data_len) { + remaining_offset -= dst->data_len; + dst = dst->next; + } + qp->state->avail_out = dst->data_len - remaining_offset; + qp->state->next_out = rte_pktmbuf_mtod_offset(dst, uint8_t *, + remaining_offset); + + while (qp->state->block_state != ISAL_BLOCK_FINISH) { + + ret = isal_inflate(qp->state); + + /* Check for first segment, offset needs to be accounted for */ + if (remaining_data == op->src.length) { + consumed_data = src->data_len - qp->state->avail_in - + (op->src.offset % src->data_len); + } else + consumed_data = src->data_len - qp->state->avail_in; + + op->consumed += consumed_data; + remaining_data -= consumed_data; + + if (ret != ISAL_DECOMP_OK) { + ISAL_PMD_LOG(ERR, "Decompression operation failed\n"); + op->status = RTE_COMP_OP_STATUS_ERROR; + return ret; + } + + if (qp->state->avail_in == 0 + && op->consumed != op->src.length) { + if (src->next != NULL) { + src = src->next; + qp->state->next_in = + rte_pktmbuf_mtod(src, uint8_t *); + qp->state->avail_in = + RTE_MIN(remaining_data, src->data_len); + } + } + + if (qp->state->avail_out == 0 && + qp->state->block_state != ISAL_BLOCK_FINISH) { + if (dst->next != NULL) { + dst = dst->next; + qp->state->next_out = + rte_pktmbuf_mtod(dst, uint8_t *); + qp->state->avail_out = dst->data_len; + } else { + ISAL_PMD_LOG(ERR, + "Not enough output buffer segments\n"); + op->status = + RTE_COMP_OP_STATUS_OUT_OF_SPACE_TERMINATED; + return -1; + } + } + } + + return 0; +} + /* Stateless Compression Function */ static int process_isal_deflate(struct rte_comp_op *op, struct isal_comp_qp *qp, @@ -207,7 +380,7 @@ process_isal_deflate(struct rte_comp_op *op, struct isal_comp_qp *qp, /* Stateless operation, input will be consumed in one go */ qp->stream->flush = NO_FLUSH; - /* set op level & intermediate level buffer */ + /* set compression level & intermediate level buffer size */ qp->stream->level = priv_xform->compress.level; qp->stream->level_buf_size = priv_xform->level_buffer_size; @@ -225,59 +398,70 @@ process_isal_deflate(struct rte_comp_op *op, struct isal_comp_qp *qp, isal_deflate_set_hufftables(qp->stream, NULL, IGZIP_HUFFTABLE_DEFAULT); - qp->stream->end_of_stream = 1; /* All input consumed in one go */ - if ((op->src.length + op->src.offset) > op->m_src->data_len) { - ISAL_PMD_LOG(ERR, "Input mbuf not big enough for the length and" - " offset provided.\n"); + 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; return -1; } - /* Point compression stream to input buffer */ - qp->stream->avail_in = op->src.length; - qp->stream->next_in = rte_pktmbuf_mtod_offset(op->m_src, uint8_t *, - op->src.offset); - if (op->dst.offset > op->m_dst->data_len) { - ISAL_PMD_LOG(ERR, "Output mbuf not big enough for the length" + if (op->dst.offset > op->m_dst->pkt_len) { + ISAL_PMD_LOG(ERR, "Output mbuf(s) not big enough for length" " and offset provided.\n"); op->status = RTE_COMP_OP_STATUS_INVALID_ARGS; return -1; } - /* Point compression stream to output buffer */ - qp->stream->avail_out = op->m_dst->data_len - op->dst.offset; - qp->stream->next_out = rte_pktmbuf_mtod_offset(op->m_dst, uint8_t *, - op->dst.offset); - 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; - } + /* Chained mbufs */ + if (op->m_src->nb_segs > 1 || op->m_dst->nb_segs > 1) { + ret = chained_mbuf_compression(op, qp); + if (ret < 0) + return ret; + } else { + /* Linear buffer */ + qp->stream->end_of_stream = 1; /* All input consumed in one */ + /* Point compression stream to input buffer */ + qp->stream->avail_in = op->src.length; + qp->stream->next_in = rte_pktmbuf_mtod_offset(op->m_src, + uint8_t *, op->src.offset); + + /* Point compression stream to output buffer */ + qp->stream->avail_out = op->m_dst->data_len - op->dst.offset; + qp->stream->next_out = rte_pktmbuf_mtod_offset(op->m_dst, + uint8_t *, op->dst.offset); + + 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; + } - /* Execute compression operation */ - ret = isal_deflate_stateless(qp->stream); + /* 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 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; - } + /* 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; + if (ret != COMP_OK) { + ISAL_PMD_LOG(ERR, "Compression operation failed\n"); + op->status = RTE_COMP_OP_STATUS_ERROR; + return ret; + } } - - op->consumed = qp->stream->total_in; - op->produced = qp->stream->total_out; + op->consumed = qp->stream->total_in; + op->produced = qp->stream->total_out; return ret; } @@ -293,59 +477,69 @@ process_isal_inflate(struct rte_comp_op *op, struct isal_comp_qp *qp) /* Initialize decompression state */ isal_inflate_init(qp->state); - if ((op->src.length + op->src.offset) > op->m_src->data_len) { - ISAL_PMD_LOG(ERR, "Input mbuf not big enough for the length and" - " offset provided.\n"); + 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; return -1; } - /* Point decompression state to input buffer */ - qp->state->avail_in = op->src.length; - qp->state->next_in = rte_pktmbuf_mtod_offset(op->m_src, uint8_t *, - op->src.offset); if (op->dst.offset > op->m_dst->data_len) { - ISAL_PMD_LOG(ERR, "Output mbuf not big enough for the length " - "and offset provided.\n"); + ISAL_PMD_LOG(ERR, "Output mbuf not big enough for length and " + "offset provided.\n"); op->status = RTE_COMP_OP_STATUS_INVALID_ARGS; return -1; } - /* Point decompression state to output buffer */ - qp->state->avail_out = op->m_dst->data_len - op->dst.offset; - qp->state->next_out = rte_pktmbuf_mtod_offset(op->m_dst, uint8_t *, - op->dst.offset); - 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; - } + /* Chained mbufs */ + if (op->m_src->nb_segs > 1 || op->m_dst->nb_segs > 1) { + ret = chained_mbuf_decompression(op, qp); + if (ret != 0) + return ret; + } else { + /* Linear buffer */ + /* Point decompression state to input buffer */ + qp->state->avail_in = op->src.length; + qp->state->next_in = rte_pktmbuf_mtod_offset(op->m_src, + uint8_t *, op->src.offset); + + /* Point decompression state to output buffer */ + qp->state->avail_out = op->m_dst->data_len - op->dst.offset; + qp->state->next_out = rte_pktmbuf_mtod_offset(op->m_dst, + uint8_t *, op->dst.offset); + + 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); + /* 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; - } + 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; - } + /* 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; + 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; - op->consumed = op->src.length - qp->state->avail_in; - op->produced = qp->state->total_out; - -return ret; + return ret; } /* Process compression/decompression operation */ diff --git a/drivers/compress/isal/isal_compress_pmd_ops.c b/drivers/compress/isal/isal_compress_pmd_ops.c index c61acd4..41cade8 100644 --- a/drivers/compress/isal/isal_compress_pmd_ops.c +++ b/drivers/compress/isal/isal_compress_pmd_ops.c @@ -12,7 +12,10 @@ static const struct rte_compressdev_capabilities isal_pmd_capabilities[] = { { .algo = RTE_COMP_ALGO_DEFLATE, - .comp_feature_flags = RTE_COMP_FF_SHAREABLE_PRIV_XFORM | + .comp_feature_flags = RTE_COMP_FF_OOP_SGL_IN_SGL_OUT | + RTE_COMP_FF_OOP_SGL_IN_LB_OUT | + RTE_COMP_FF_OOP_LB_IN_SGL_OUT | + RTE_COMP_FF_SHAREABLE_PRIV_XFORM | RTE_COMP_FF_HUFFMAN_FIXED | RTE_COMP_FF_HUFFMAN_DYNAMIC, .window_size = { -- 2.7.4 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [dpdk-dev] [PATCH v4] compress/isal: add chained mbuf support 2018-07-24 11:19 ` [dpdk-dev] [PATCH v4] " Daly, Lee @ 2018-07-24 13:27 ` De Lara Guarch, Pablo 2018-07-24 13:36 ` De Lara Guarch, Pablo 0 siblings, 1 reply; 8+ messages in thread From: De Lara Guarch, Pablo @ 2018-07-24 13:27 UTC (permalink / raw) To: Daly, Lee; +Cc: dev > -----Original Message----- > From: Daly, Lee > Sent: Tuesday, July 24, 2018 12:19 PM > To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com> > Cc: dev@dpdk.org; Daly, Lee <lee.daly@intel.com> > Subject: [PATCH v4] compress/isal: add chained mbuf support > > This patch adds chained mbuf support for input or output buffers during > compression/decompression operations. > > V2 - split chained mbuf functionality into separate functions. > - code optimizations. > > V3 - bug fixes & optimizations. > > v4 - bug fixes & optimizations. > > Signed-off-by: Lee Daly <lee.daly@intel.com> Reviewed-by: Pablo de Lara <pablo.de.lara.guarch@intel.com> ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [dpdk-dev] [PATCH v4] compress/isal: add chained mbuf support 2018-07-24 13:27 ` De Lara Guarch, Pablo @ 2018-07-24 13:36 ` De Lara Guarch, Pablo 0 siblings, 0 replies; 8+ messages in thread From: De Lara Guarch, Pablo @ 2018-07-24 13:36 UTC (permalink / raw) To: De Lara Guarch, Pablo, Daly, Lee; +Cc: dev > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of De Lara Guarch, Pablo > Sent: Tuesday, July 24, 2018 2:28 PM > To: Daly, Lee <lee.daly@intel.com> > Cc: dev@dpdk.org > Subject: Re: [dpdk-dev] [PATCH v4] compress/isal: add chained mbuf support > > > > > -----Original Message----- > > From: Daly, Lee > > Sent: Tuesday, July 24, 2018 12:19 PM > > To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com> > > Cc: dev@dpdk.org; Daly, Lee <lee.daly@intel.com> > > Subject: [PATCH v4] compress/isal: add chained mbuf support > > > > This patch adds chained mbuf support for input or output buffers > > during compression/decompression operations. > > > > V2 - split chained mbuf functionality into separate functions. > > - code optimizations. > > > > V3 - bug fixes & optimizations. > > > > v4 - bug fixes & optimizations. > > > > Signed-off-by: Lee Daly <lee.daly@intel.com> > > Reviewed-by: Pablo de Lara <pablo.de.lara.guarch@intel.com> Applied to dpdk-next-crypto. Thanks, Pablo ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2018-07-24 13:36 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2018-07-05 11:03 [dpdk-dev] [PATCH] compress/isal: add chained mbuf support Lee Daly 2018-07-11 12:40 ` [dpdk-dev] [PATCH v2] " Lee, Daly 2018-07-20 10:38 ` De Lara Guarch, Pablo 2018-07-23 18:02 ` [dpdk-dev] [PATCH v3] " Daly, Lee 2018-07-23 21:14 ` De Lara Guarch, Pablo 2018-07-24 11:19 ` [dpdk-dev] [PATCH v4] " Daly, Lee 2018-07-24 13:27 ` De Lara Guarch, Pablo 2018-07-24 13:36 ` De Lara Guarch, Pablo
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).