From: "De Lara Guarch, Pablo" <pablo.de.lara.guarch@intel.com>
To: "Daly, Lee" <lee.daly@intel.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>, "Daly, Lee" <lee.daly@intel.com>
Subject: Re: [dpdk-dev] [PATCH v3] compress/isal: add chained mbuf support
Date: Mon, 23 Jul 2018 21:14:26 +0000 [thread overview]
Message-ID: <E115CCD9D858EF4F90C690B0DCB4D8977F8FFBE2@IRSMSX107.ger.corp.intel.com> (raw)
In-Reply-To: <1532368945-23909-1-git-send-email-lee.daly@intel.com>
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.
next prev parent reply other threads:[~2018-07-23 21:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-05 11:03 [dpdk-dev] [PATCH] " 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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E115CCD9D858EF4F90C690B0DCB4D8977F8FFBE2@IRSMSX107.ger.corp.intel.com \
--to=pablo.de.lara.guarch@intel.com \
--cc=dev@dpdk.org \
--cc=lee.daly@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).