crypto: sun8i-ce - pass task descriptor to cipher prepare/unprepare

To remove some duplicated code, directly pass 'struct skcipher_request' and
'struct ce_task' pointers to sun8i_ce_cipher_{prepare,unprepare}.

Signed-off-by: Ovidiu Panait <ovidiu.panait.oss@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
Ovidiu Panait 2025-09-02 16:21:32 +03:00 committed by Herbert Xu
parent 2dc57f02f2
commit 49034c03b5

View File

@ -131,21 +131,19 @@ static int sun8i_ce_cipher_fallback(struct skcipher_request *areq)
return err;
}
static int sun8i_ce_cipher_prepare(struct crypto_engine *engine, void *async_req)
static int sun8i_ce_cipher_prepare(struct skcipher_request *areq,
struct ce_task *cet)
{
struct skcipher_request *areq = container_of(async_req, struct skcipher_request, base);
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq);
struct sun8i_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm);
struct sun8i_ce_dev *ce = op->ce;
struct sun8i_cipher_req_ctx *rctx = skcipher_request_ctx(areq);
struct skcipher_alg *alg = crypto_skcipher_alg(tfm);
struct sun8i_ce_alg_template *algt;
struct sun8i_ce_flow *chan;
struct ce_task *cet;
struct scatterlist *sg;
unsigned int todo, len, offset, ivsize;
u32 common, sym;
int flow, i;
int i;
int nr_sgs = 0;
int nr_sgd = 0;
int err = 0;
@ -163,14 +161,9 @@ static int sun8i_ce_cipher_prepare(struct crypto_engine *engine, void *async_req
if (IS_ENABLED(CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG))
algt->stat_req++;
flow = rctx->flow;
chan = &ce->chanlist[flow];
cet = chan->tl;
memset(cet, 0, sizeof(struct ce_task));
cet->t_id = cpu_to_le32(flow);
cet->t_id = cpu_to_le32(rctx->flow);
common = ce->variant->alg_cipher[algt->ce_algo_id];
common |= rctx->op_dir | CE_COMM_INT;
cet->t_common_ctl = cpu_to_le32(common);
@ -314,24 +307,17 @@ static int sun8i_ce_cipher_prepare(struct crypto_engine *engine, void *async_req
return err;
}
static void sun8i_ce_cipher_unprepare(struct crypto_engine *engine,
void *async_req)
static void sun8i_ce_cipher_unprepare(struct skcipher_request *areq,
struct ce_task *cet)
{
struct skcipher_request *areq = container_of(async_req, struct skcipher_request, base);
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq);
struct sun8i_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm);
struct sun8i_ce_dev *ce = op->ce;
struct sun8i_cipher_req_ctx *rctx = skcipher_request_ctx(areq);
struct sun8i_ce_flow *chan;
struct ce_task *cet;
unsigned int ivsize, offset;
int nr_sgs = rctx->nr_sgs;
int nr_sgd = rctx->nr_sgd;
int flow;
flow = rctx->flow;
chan = &ce->chanlist[flow];
cet = chan->tl;
ivsize = crypto_skcipher_ivsize(tfm);
if (areq->src == areq->dst) {
@ -367,16 +353,19 @@ int sun8i_ce_cipher_do_one(struct crypto_engine *engine, void *areq)
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
struct sun8i_cipher_tfm_ctx *ctx = crypto_skcipher_ctx(tfm);
struct sun8i_ce_dev *ce = ctx->ce;
struct sun8i_ce_flow *chan;
int err;
err = sun8i_ce_cipher_prepare(engine, areq);
chan = &ce->chanlist[rctx->flow];
err = sun8i_ce_cipher_prepare(req, chan->tl);
if (err)
return err;
err = sun8i_ce_run_task(ce, rctx->flow,
crypto_tfm_alg_name(req->base.tfm));
sun8i_ce_cipher_unprepare(engine, areq);
sun8i_ce_cipher_unprepare(req, chan->tl);
local_bh_disable();
crypto_finalize_skcipher_request(engine, req, err);