drivers/crypto/starfive/jh7110-aes.c

Source file repositories/reference/linux-study-clean/drivers/crypto/starfive/jh7110-aes.c

File Facts

System
Linux kernel
Corpus path
drivers/crypto/starfive/jh7110-aes.c
Extension
.c
Size
31329 bytes
Lines
1156
Domain
Driver Families
Bucket
drivers/crypto
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (sg_dma_len(stsg) - len) {
				stsg = scatterwalk_ffwd(_src, stsg, len);
				dtsg = sg_next(dtsg);
			} else if (sg_dma_len(dtsg) - len) {
				dtsg = scatterwalk_ffwd(_dst, dtsg, len);
				stsg = sg_next(stsg);
			} else {
				stsg = sg_next(stsg);
				dtsg = sg_next(dtsg);
			}
		}
	}

	return 0;
}

static int starfive_aes_do_one_req(struct crypto_engine *engine, void *areq)
{
	struct skcipher_request *req =
		container_of(areq, struct skcipher_request, base);
	struct starfive_cryp_ctx *ctx =
		crypto_skcipher_ctx(crypto_skcipher_reqtfm(req));
	struct starfive_cryp_request_ctx *rctx = skcipher_request_ctx(req);
	struct starfive_cryp_dev *cryp = ctx->cryp;
	int ret;

	cryp->req.sreq = req;
	cryp->total_in = req->cryptlen;
	cryp->total_out = req->cryptlen;
	cryp->assoclen = 0;
	cryp->authsize = 0;

	rctx->in_sg = req->src;
	rctx->out_sg = req->dst;

	ctx->rctx = rctx;

	ret = starfive_aes_hw_init(ctx);
	if (ret)
		return ret;

	if (!cryp->total_in)
		goto finish_req;

	starfive_aes_dma_init(cryp);

	ret = starfive_aes_map_sg(cryp, rctx->in_sg, rctx->out_sg);
	if (ret)
		return ret;

finish_req:
	starfive_aes_finish_req(ctx);

	return 0;
}

static int starfive_aes_init_tfm(struct crypto_skcipher *tfm,
				 const char *alg_name)
{
	struct starfive_cryp_ctx *ctx = crypto_skcipher_ctx(tfm);

	ctx->cryp = starfive_cryp_find_dev(ctx);
	if (!ctx->cryp)
		return -ENODEV;

	ctx->skcipher_fbk = crypto_alloc_skcipher(alg_name, 0,
						  CRYPTO_ALG_NEED_FALLBACK);
	if (IS_ERR(ctx->skcipher_fbk))
		return dev_err_probe(ctx->cryp->dev, PTR_ERR(ctx->skcipher_fbk),
				     "%s() failed to allocate fallback for %s\n",
				     __func__, alg_name);

	crypto_skcipher_set_reqsize(tfm, sizeof(struct starfive_cryp_request_ctx) +
				    crypto_skcipher_reqsize(ctx->skcipher_fbk));

	return 0;
}

static void starfive_aes_exit_tfm(struct crypto_skcipher *tfm)
{
	struct starfive_cryp_ctx *ctx = crypto_skcipher_ctx(tfm);

	crypto_free_skcipher(ctx->skcipher_fbk);
}

static int starfive_aes_aead_do_one_req(struct crypto_engine *engine, void *areq)
{
	struct aead_request *req =
		container_of(areq, struct aead_request, base);
	struct starfive_cryp_ctx *ctx =

Annotation

Implementation Notes