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
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to