Re: [PATCH 08/12] crypto: caam - support crypto_engine framework for SKCIPHER algorithms

From: Iuliana Prodan
Date: Fri Nov 22 2019 - 06:06:06 EST


On 11/22/2019 12:33 PM, Herbert Xu wrote:
> On Mon, Nov 18, 2019 at 12:30:41AM +0200, Iuliana Prodan wrote:
>>
>> +static int transfer_request_to_engine(struct crypto_engine *engine,
>> + struct crypto_async_request *req)
>> +{
>> + switch (crypto_tfm_alg_type(req->tfm)) {
>> + case CRYPTO_ALG_TYPE_SKCIPHER:
>> + return crypto_transfer_skcipher_request_to_engine(engine,
>> + skcipher_request_cast(req));
>> + default:
>> + return -EINVAL;
>> + }
>> +}
>
> Please don't do this. As you can see the crypto engine interface
> wants to you to use the correct type for the request object. That's
> what you should do to.

Sorry, but I don't understand what is wrong here? I'm using the correct
type, the specific type, for the request when sending it to crypto engine.
This transfer_request_to_engine function is called from caam_jr_enqueue,
where I have all types of request, so I'm using the async_request, and
when transferring to crypto engine I cast it to the specific type.


> In fact I don't understand why you're only using the crypto engine
> for the backlog case. Wouldn't it be much simpler if you used the
> engine unconditionally?

I believe is an overhead to sent all request to crypto engine since most
of them can be directly executed by hw.
Also, in case there is no need for backlog and the hw is busy we can
drop the request.

Thanks,
Iulia