From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by dpdk.org (Postfix) with ESMTP id 930985B1E for ; Mon, 30 Jul 2018 18:21:51 +0200 (CEST) Received: from 1.general.paelzer.uk.vpn ([10.172.196.172] helo=lap.fritz.box) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1fkArh-00009D-NZ; Mon, 30 Jul 2018 16:17:45 +0000 From: Christian Ehrhardt To: Lee Daly Cc: Pablo de Lara , dpdk stable Date: Mon, 30 Jul 2018 18:12:50 +0200 Message-Id: <20180730161342.16566-125-christian.ehrhardt@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180730161342.16566-1-christian.ehrhardt@canonical.com> References: <20180730161342.16566-1-christian.ehrhardt@canonical.com> Subject: [dpdk-stable] patch 'compress/isal: fix offset usage' has been queued to stable release 18.05.1 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Jul 2018 16:21:51 -0000 Hi, FYI, your patch has been queued to stable release 18.05.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 08/01/18. So please shout if anyone has objections. Thanks. Christian Ehrhardt --- >>From 543765d49e80314be3ffd5f028b5360c4d280006 Mon Sep 17 00:00:00 2001 From: Lee Daly Date: Wed, 11 Jul 2018 15:21:45 +0100 Subject: [PATCH] compress/isal: fix offset usage [ upstream commit 6a000343ed2be981337e990cff717e9cb7de13f2 ] This patch allows the ISA-L compression PMD, to be used with offsets in the mbuf. Offsets can now be used for source and destination buffers, during compression or decompression. Fixes: 7bf4f0630af6 ("compress/isal: add ISA-L decomp functionality") Fixes: dc49e6aa4879 ("compress/isal: add ISA-L compression functionality") Signed-off-by: Lee Daly Acked-by: Pablo de Lara --- drivers/compress/isal/isal_compress_pmd.c | 66 +++++++++++++++++------ 1 file changed, 49 insertions(+), 17 deletions(-) diff --git a/drivers/compress/isal/isal_compress_pmd.c b/drivers/compress/isal/isal_compress_pmd.c index 0f025a3bf..78051f1c5 100644 --- a/drivers/compress/isal/isal_compress_pmd.c +++ b/drivers/compress/isal/isal_compress_pmd.c @@ -211,19 +211,6 @@ process_isal_deflate(struct rte_comp_op *op, struct isal_comp_qp *qp, qp->stream->level = priv_xform->compress.level; qp->stream->level_buf_size = priv_xform->level_buffer_size; - /* Point compression stream structure to input/output buffers */ - qp->stream->avail_in = op->src.length; - qp->stream->next_in = rte_pktmbuf_mtod(op->m_src, uint8_t *); - qp->stream->avail_out = op->m_dst->data_len; - qp->stream->next_out = rte_pktmbuf_mtod(op->m_dst, uint8_t *); - qp->stream->end_of_stream = 1; /* All input consumed in one go */ - - if (unlikely(!qp->stream->next_in || !qp->stream->next_out)) { - ISAL_PMD_LOG(ERR, "Invalid source or destination buffers\n"); - op->status = RTE_COMP_OP_STATUS_INVALID_ARGS; - return -1; - } - /* Set op huffman code */ if (priv_xform->compress.deflate.huffman == RTE_COMP_HUFFMAN_FIXED) isal_deflate_set_hufftables(qp->stream, NULL, @@ -238,6 +225,35 @@ 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"); + 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); @@ -277,11 +293,27 @@ process_isal_inflate(struct rte_comp_op *op, struct isal_comp_qp *qp) /* Initialize decompression state */ isal_inflate_init(qp->state); - /* Point decompression state structure to input/output buffers */ + 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(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 *); + 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"); + 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"); -- 2.17.1