All of lore.kernel.org
 help / color / mirror / Atom feed
From: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: <linux-crypto@vger.kernel.org>, <qat-linux@intel.com>,
	Vlad Dronov <vdronov@redhat.com>,
	Wojciech Ziemba <wojciech.ziemba@intel.com>,
	"Adam Guerin" <adam.guerin@intel.com>
Subject: Re: [PATCH 8/9] crypto: qat - expose deflate through acomp api for QAT GEN2
Date: Fri, 26 Aug 2022 15:21:15 +0100	[thread overview]
Message-ID: <YwjW2x/uT9ST8+8i@gcabiddu-mobl1.ger.corp.intel.com> (raw)
In-Reply-To: <YwigYBNM7O/J6gO1@gondor.apana.org.au>

On Fri, Aug 26, 2022 at 06:28:48PM +0800, Herbert Xu wrote:
> On Thu, Aug 18, 2022 at 07:01:19PM +0100, Giovanni Cabiddu wrote:
> >
> > +	/* Handle acomp requests that require the allocation of a destination
> > +	 * buffer. The size of the destination buffer is double the source
> > +	 * buffer to fit the decompressed output or an expansion on the
> > +	 * data for compression.
> > +	 */
> > +	if (!areq->dst) {
> > +		dlen = 2 * slen;
> > +		areq->dst = sgl_alloc(dlen, f, NULL);
> > +		if (!areq->dst)
> > +			return -ENOMEM;
> > +	}
> 
> So what happens if the decompressed result is more than twice as
> long as the source?
The QAT HW will report that the destination buffer is not sufficiently
large to store the decompressed result and the job will fail with an
error and with dlen=0.

From the use case described in this thread [1], an option would be to
allocate always 64KB, i.e. IPCOMP_SCRATCH_SIZE [2].
Alternatively, allocate twice the source rounded up to 64KB:

#define MIN_DST_BUFFER_SZ 65536
    if (!areq->dst) {
        dlen = 2 * slen;
	dlen = dlen < MIN_DST_BUFFER_SZ ? MIN_DST_BUFFER_SZ : dlen;
	...
    }

What do you think?

It would be nice if the user of the api could provide a hint for the
size of the destination buffer in acomp_req.dlen.

Regards,

-- 
Giovanni

[1] https://lore.kernel.org/all/20160923150518.GA20384@gondor.apana.org.au/
[2] https://elixir.bootlin.com/linux/latest/source/include/net/ipcomp.h#L7

  reply	other threads:[~2022-08-26 14:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-18 18:01 [PATCH 0/9] crypto: qat - enable compression deflate algorithm Giovanni Cabiddu
2022-08-18 18:01 ` [PATCH 1/9] crypto: qat - relocate bufferlist logic Giovanni Cabiddu
2022-08-18 18:01 ` [PATCH 2/9] crypto: qat - change bufferlist logic interface Giovanni Cabiddu
2022-08-18 18:01 ` [PATCH 3/9] crypto: qat - generalize crypto request buffers Giovanni Cabiddu
2022-08-18 18:01 ` [PATCH 4/9] crypto: qat - extend buffer list interface Giovanni Cabiddu
2022-08-18 18:01 ` [PATCH 5/9] crypto: qat - relocate backlog related structures Giovanni Cabiddu
2022-08-18 18:01 ` [PATCH 6/9] crypto: qat - relocate qat_algs_alloc_flags() Giovanni Cabiddu
2022-08-18 18:01 ` [PATCH 7/9] crypto: qat - rename and relocate GEN2 config function Giovanni Cabiddu
2022-08-18 18:01 ` [PATCH 8/9] crypto: qat - expose deflate through acomp api for QAT GEN2 Giovanni Cabiddu
2022-08-26 10:28   ` Herbert Xu
2022-08-26 14:21     ` Giovanni Cabiddu [this message]
2022-08-30  9:08       ` Herbert Xu
2022-09-15 13:09         ` Giovanni Cabiddu
2022-09-16  9:41           ` Herbert Xu
2022-08-18 18:01 ` [PATCH 9/9] crypto: qat - enable deflate for QAT GEN4 Giovanni Cabiddu

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=YwjW2x/uT9ST8+8i@gcabiddu-mobl1.ger.corp.intel.com \
    --to=giovanni.cabiddu@intel.com \
    --cc=adam.guerin@intel.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=qat-linux@intel.com \
    --cc=vdronov@redhat.com \
    --cc=wojciech.ziemba@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.