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.
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
crypto/engine.hcrypto/gcm.hcrypto/internal/aead.hcrypto/internal/skcipher.hcrypto/scatterwalk.hjh7110-cryp.hlinux/err.hlinux/iopoll.hlinux/kernel.hlinux/slab.hlinux/string.h
Detected Declarations
function Copyrightfunction starfive_aes_wait_keydonefunction starfive_aes_wait_gcmdonefunction is_gcmfunction is_encryptfunction starfive_aes_aead_hw_startfunction starfive_aes_set_alenfunction starfive_aes_set_mlenfunction starfive_aes_ccm_check_ivfunction starfive_aes_write_ivfunction starfive_aes_get_ivfunction starfive_aes_write_noncefunction starfive_aes_write_keyfunction starfive_aes_ccm_initfunction starfive_aes_hw_initfunction starfive_aes_read_authtagfunction starfive_aes_finish_reqfunction starfive_aes_gcm_write_adatafunction starfive_aes_ccm_write_adatafunction starfive_aes_dma_donefunction starfive_aes_dma_initfunction starfive_aes_dma_xferfunction starfive_aes_map_sgfunction starfive_aes_do_one_reqfunction starfive_aes_init_tfmfunction starfive_aes_exit_tfmfunction starfive_aes_aead_do_one_reqfunction starfive_aes_aead_init_tfmfunction starfive_aes_aead_exit_tfmfunction starfive_aes_check_unalignedfunction starfive_aes_do_fallbackfunction starfive_aes_cryptfunction starfive_aes_aead_do_fallbackfunction starfive_aes_aead_cryptfunction starfive_aes_setkeyfunction starfive_aes_aead_setkeyfunction starfive_aes_gcm_setauthsizefunction starfive_aes_ccm_setauthsizefunction starfive_aes_ecb_encryptfunction starfive_aes_ecb_decryptfunction starfive_aes_cbc_encryptfunction starfive_aes_cbc_decryptfunction starfive_aes_ctr_encryptfunction starfive_aes_ctr_decryptfunction starfive_aes_gcm_encryptfunction starfive_aes_gcm_decryptfunction starfive_aes_ccm_encryptfunction starfive_aes_ccm_decrypt
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
- Immediate include surface: `crypto/engine.h`, `crypto/gcm.h`, `crypto/internal/aead.h`, `crypto/internal/skcipher.h`, `crypto/scatterwalk.h`, `jh7110-cryp.h`, `linux/err.h`, `linux/iopoll.h`.
- Detected declarations: `function Copyright`, `function starfive_aes_wait_keydone`, `function starfive_aes_wait_gcmdone`, `function is_gcm`, `function is_encrypt`, `function starfive_aes_aead_hw_start`, `function starfive_aes_set_alen`, `function starfive_aes_set_mlen`, `function starfive_aes_ccm_check_iv`, `function starfive_aes_write_iv`.
- Atlas domain: Driver Families / drivers/crypto.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.