Thread (21 messages) flat view 21 messages, 2 authors, 2016-03-23

Re: [PATCH v2 0/2] crypto: asynchronous compression api

From: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Date: 2016-02-24 17:47:30

Hi Herbert,

On Tue, Feb 16, 2016 at 07:57:17PM +0000, Herbert Xu wrote:
Can you give an example on how to use the noctx support with
your acomp interface?
In this version of the acomp api an algorithm can specify different sizes for
the compression and the decompression contexts by setting the comp_reqsize and
the decomp_reqsize fields in the acomp_alg structure.
The api also provides two new function calls to allocate the request:
	struct acomp_req *acomp_compression_request_alloc(
					struct crypto_acomp *acomp, gfp_t gfp)
	struct acomp_req *acomp_decompression_request_alloc(
					struct crypto_acomp *acomp, gfp_t gfp)
The implementation of these calls use comp_reqsize and decomp_reqsize to 
allocate the context and therefore, if an algorithm supports it, it is possible
to have requests with no context.

Here is a simple example that shows how to use the api from a user prospective:

	struct crypto_acomp *tfm;
	struct acomp_req *req = NULL;
	struct scatterlist src;
	struct scatterlist dst;
	tfm = crypto_alloc_acomp("deflate", 0, 0);
	req = acomp_compression_request_alloc(tfm, GFP_KERNEL);
	/* Prepare src and dst sgls */
	acomp_request_set_params(req, &src, &dst, slen, dlen);
	acomp_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, cb_func,
				   cb_data);
	ret = crypto_acomp_compress(req);

Regarding the SCOMP backends, when an algorithm registers as
CRYPTO_ALG_TYPE_SCOMPRESS, requests allocated with both
acomp_compression_request_alloc and acomp_decompression_request_alloc have 
the same size (sizeof (struct acomp_req) + sizeof(void *)).
The request context stores a pointer to the scomp context allocated 
using crypto_scomp_alloc_ctx().
If the algorithm specifies the CRYPTO_SCOMP_DECOMP_NOCTX flag,
acomp_decompression_request_alloc does not call crypto_scomp_alloc_ctx() and
stores NULL into the request context.
This way the scomp context is not allocated and decompression requests are
called without context. See patch v3.

Regards,

-- 
Giovanni
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help