From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id C6BC4160 for ; Mon, 23 Jul 2018 23:14:29 +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 fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Jul 2018 14:14:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,394,1526367600"; d="scan'208";a="60044970" Received: from irsmsx103.ger.corp.intel.com ([163.33.3.157]) by orsmga006.jf.intel.com with ESMTP; 23 Jul 2018 14:14:27 -0700 Received: from irsmsx107.ger.corp.intel.com ([169.254.10.193]) by IRSMSX103.ger.corp.intel.com ([169.254.3.208]) with mapi id 14.03.0319.002; Mon, 23 Jul 2018 22:14:26 +0100 From: "De Lara Guarch, Pablo" To: "Daly, Lee" CC: "dev@dpdk.org" , "Daly, Lee" Thread-Topic: [dpdk-dev] [PATCH v3] compress/isal: add chained mbuf support Thread-Index: AQHUIq+Gg2kFMNTq30uoVd+UgmJmC6SdHGig Date: Mon, 23 Jul 2018 21:14:26 +0000 Message-ID: References: <1531312811-177746-1-git-send-email-lee.daly@intel.com> <1532368945-23909-1-git-send-email-lee.daly@intel.com> In-Reply-To: <1532368945-23909-1-git-send-email-lee.daly@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMjk3YmM5ZGEtNzE2Mi00ZTRkLTkwMDktZTA1MzEzNzMzM2QzIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiTVdhUDVMTGFoNkI2dVNcL21ldFhrYmp4UkhrR0lHY1NWVVM2N2pwQ1NQSlZGVldHTDlnXC9UcXBCRzZpRTExRDZGIn0= x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.200.100 dlp-reaction: no-action x-originating-ip: [163.33.239.181] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v3] compress/isal: add chained mbuf support 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: , X-List-Received-Date: Mon, 23 Jul 2018 21:14:30 -0000 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 > Cc: dev@dpdk.org; Daly, Lee > Subject: [dpdk-dev] [PATCH v3] compress/isal: add chained mbuf support >=20 > This patch adds chained mbuf support for input or output buffers during > compression/decompression operations. >=20 > Signed-off-by: Lee Daly > --- > 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; > } >=20 > +/* 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 =3D op->src.length; > + struct rte_mbuf *src =3D op->m_src; > + struct rte_mbuf *dst =3D 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 >=3D data_len). In that case, you need to get the next segment and start from byte 0 there. > + remaining_offset =3D op->src.offset; > + while (remaining_offset > src->data_len) { Same here, check for equal too. > + remaining_offset -=3D src->data_len; > + src =3D src->next; > + } > + > + > + qp->stream->avail_in =3D src->data_len - remaining_offset; I think we need to check for minimum value between "data_len - remaining_of= fset" and src.length. > + qp->stream->next_in =3D rte_pktmbuf_mtod_offset(src, uint8_t *, > + (op->src.offset % src->data_len)); Use remaining_offset here. > + } else { > + qp->stream->avail_in =3D 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 (re= move the code under else). It should work for both cases, and you save one extra condition. > + qp->stream->next_in =3D rte_pktmbuf_mtod_offset(src, uint8_t *, > + op->src.offset); > + } > + > + if (op->dst.offset > dst->data_len) { > + remaining_offset =3D op->dst.offset; > + while (remaining_offset > dst->data_len) { > + remaining_offset -=3D dst->data_len; > + dst =3D dst->next; > + } > + > + qp->stream->avail_out =3D dst->data_len - remaining_offset; > + qp->stream->next_out =3D rte_pktmbuf_mtod_offset(dst, uint8_t > *, > + (op->dst.offset % dst->data_len)); > + } else { > + qp->stream->avail_out =3D dst->data_len - op->dst.offset; > + qp->stream->next_out =3D rte_pktmbuf_mtod_offset(dst, uint8_t > *, > + op->dst.offset); > + } Same comments apply for the destination buffer (except for the src.length o= nes). > + > + if (unlikely(!qp->stream->next_in || !qp->stream->next_out)) { > + ISAL_PMD_LOG(ERR, "Invalid source or destination buffer\n"); > + op->status =3D 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 =3D op->src.length; > + struct rte_mbuf *src =3D op->m_src; > + struct rte_mbuf *dst =3D 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 =3D op->src.offset; > + while (remaining_offset > src->data_len) { > + remaining_offset -=3D src->data_len; > + src =3D src->next; > + } > + > + qp->state->avail_in =3D src->data_len - remaining_offset; > + qp->state->next_in =3D rte_pktmbuf_mtod_offset(src, > + uint8_t *, (op->src.offset % src->data_len)); > + } else { > + qp->state->avail_in =3D src->data_len - op->src.offset; > + qp->state->next_in =3D rte_pktmbuf_mtod_offset(src, uint8_t *, > + op->src.offset); > + } > + if (op->dst.offset > dst->data_len) { > + remaining_offset =3D op->dst.offset; > + while (remaining_offset > dst->data_len) { > + remaining_offset -=3D dst->data_len; > + dst =3D dst->next; > + } > + > + qp->state->avail_out =3D dst->data_len - remaining_offset; > + qp->state->next_out =3D rte_pktmbuf_mtod_offset(dst, uint8_t *, > + (op->dst.offset % dst->data_len)); > + } else { > + qp->state->avail_out =3D dst->data_len - op->dst.offset; > + qp->state->next_out =3D rte_pktmbuf_mtod_offset(dst, uint8_t *, > + op->dst.offset); > + } Same comments as above (compression). > + while (qp->state->block_state !=3D ISAL_BLOCK_FINISH) { > + > + ret =3D isal_inflate(qp->state); > + > + if (remaining_data =3D=3D op->src.length) { I would put a comment before this if saying that this is checking for the f= irst segment to compress, so offset needs to be taken into account. > + consumed_data =3D src->data_len - qp->state->avail_in - > + (op->src.offset % src->data_len); Better to use "remaining_offset". > + } else > + consumed_data =3D src->data_len - qp->state->avail_in; > + > + op->consumed +=3D consumed_data; > + remaining_data -=3D consumed_data; > + > + if (ret !=3D ISAL_DECOMP_OK) { > + ISAL_PMD_LOG(ERR, "Decompression operation > failed\n"); > + op->status =3D 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 =3D NO_FLUSH; >=20 > - /* set op level & intermediate level buffer */ > + /* set compression level & intermediate level buffer size */ > qp->stream->level =3D priv_xform->compress.level; > qp->stream->level_buf_size =3D priv_xform->level_buffer_size; >=20 > @@ -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); >=20 > - qp->stream->end_of_stream =3D 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 =3D RTE_COMP_OP_STATUS_INVALID_ARGS; > - return -1; > - } > - /* Point compression stream to input buffer */ > - qp->stream->avail_in =3D op->src.length; > - qp->stream->next_in =3D 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 =3D RTE_COMP_OP_STATUS_INVALID_ARGS; > return -1; > } > - /* Point compression stream to output buffer */ > - qp->stream->avail_out =3D op->m_dst->data_len - op->dst.offset; > - qp->stream->next_out =3D rte_pktmbuf_mtod_offset(op->m_dst, uint8_t > *, > - op->dst.offset); >=20 > - if (unlikely(!qp->stream->next_in || !qp->stream->next_out)) { > - ISAL_PMD_LOG(ERR, "Invalid source or destination buffers\n"); > - op->status =3D RTE_COMP_OP_STATUS_INVALID_ARGS; > - return -1; > - } > + /* Chained mbufs */ > + if (op->m_src->nb_segs > 1 || op->m_dst->nb_segs > 1) { > + ret =3D chained_mbuf_compression(op, qp); > + if (ret < 0) > + return ret; > + } else { > + /* Linear buffer */ > + qp->stream->end_of_stream =3D 1; /* All input consumed in one > */ > + /* Point compression stream to input buffer */ > + qp->stream->avail_in =3D op->src.length; > + qp->stream->next_in =3D 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 =3D 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. =20 ... > @@ -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 =3D RTE_COMP_OP_STATUS_INVALID_ARGS; > + return -1; > + } Same comment as the previous one.