From patchwork Tue Jul 10 12:44:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daly, Lee" X-Patchwork-Id: 42706 X-Patchwork-Delegate: pablo.de.lara.guarch@intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3BA1E1B39D; Tue, 10 Jul 2018 14:44:27 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 77E4B1B39B; Tue, 10 Jul 2018 14:44:25 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Jul 2018 05:44:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,334,1526367600"; d="scan'208";a="56515663" Received: from silpixa00399501.ir.intel.com ([10.237.223.69]) by orsmga006.jf.intel.com with ESMTP; 10 Jul 2018 05:44:21 -0700 From: Lee Daly To: pablo.de.lara.guarch@intel.com Cc: dev@dpdk.org, Lee Daly , stable@dpdk.org Date: Tue, 10 Jul 2018 13:44:01 +0100 Message-Id: <1531226641-54158-1-git-send-email-lee.daly@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [dpdk-dev] [PATCH] compress/isal: fixes ISA-L PMD used with offsets in mbuf X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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: dc49e6a "compress/isal: add ISA-L compression functionality" Fixes: 7bf4f06 "compress/isal: add ISA-L decomp functionality" Cc: stable@dpdk.org Signed-off-by: Lee Daly --- drivers/compress/isal/isal_compress_pmd.c | 60 ++++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 16 deletions(-) diff --git a/drivers/compress/isal/isal_compress_pmd.c b/drivers/compress/isal/isal_compress_pmd.c index 0f025a3..747ded1 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,33 @@ 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"); + 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; + } + /* Execute compression operation */ ret = isal_deflate_stateless(qp->stream); @@ -277,11 +291,25 @@ 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 offset.\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->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(op->m_dst, uint8_t *); + 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");