drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c
Source file repositories/reference/linux-study-clean/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c- Extension
.c- Size
- 14239 bytes
- Lines
- 513
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bottom_half.hlinux/crypto.hlinux/dma-mapping.hlinux/io.hlinux/pm_runtime.hcrypto/scatterwalk.hcrypto/internal/des.hcrypto/internal/skcipher.hsun8i-ce.h
Detected Declarations
function Copyrightfunction sun8i_ce_cipher_fallbackfunction sun8i_ce_cipher_preparefunction sun8i_ce_cipher_unpreparefunction sun8i_ce_cipher_do_onefunction sun8i_ce_skdecryptfunction sun8i_ce_skencryptfunction sun8i_ce_cipher_initfunction sun8i_ce_cipher_exitfunction sun8i_ce_aes_setkeyfunction sun8i_ce_des3_setkey
Annotated Snippet
sg_nents_for_len(areq->dst, areq->cryptlen) > MAX_SG) {
if (IS_ENABLED(CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG))
algt->stat_fb_maxsg++;
return true;
}
if (areq->cryptlen < crypto_skcipher_ivsize(tfm)) {
if (IS_ENABLED(CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG))
algt->stat_fb_leniv++;
return true;
}
if (areq->cryptlen == 0) {
if (IS_ENABLED(CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG))
algt->stat_fb_len0++;
return true;
}
if (areq->cryptlen % 16) {
if (IS_ENABLED(CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG))
algt->stat_fb_mod16++;
return true;
}
len = areq->cryptlen;
sg = areq->src;
while (sg) {
if (!IS_ALIGNED(sg->offset, sizeof(u32))) {
if (IS_ENABLED(CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG))
algt->stat_fb_srcali++;
return true;
}
todo = min(len, sg->length);
if (todo % 4) {
if (IS_ENABLED(CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG))
algt->stat_fb_srclen++;
return true;
}
len -= todo;
sg = sg_next(sg);
}
len = areq->cryptlen;
sg = areq->dst;
while (sg) {
if (!IS_ALIGNED(sg->offset, sizeof(u32))) {
if (IS_ENABLED(CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG))
algt->stat_fb_dstali++;
return true;
}
todo = min(len, sg->length);
if (todo % 4) {
if (IS_ENABLED(CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG))
algt->stat_fb_dstlen++;
return true;
}
len -= todo;
sg = sg_next(sg);
}
return false;
}
static int sun8i_ce_cipher_fallback(struct skcipher_request *areq)
{
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq);
struct sun8i_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm);
struct sun8i_cipher_req_ctx *rctx = skcipher_request_ctx(areq);
int err;
if (IS_ENABLED(CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG)) {
struct skcipher_alg *alg = crypto_skcipher_alg(tfm);
struct sun8i_ce_alg_template *algt;
algt = container_of(alg, struct sun8i_ce_alg_template,
alg.skcipher.base);
algt->stat_fb++;
}
skcipher_request_set_tfm(&rctx->fallback_req, op->fallback_tfm);
skcipher_request_set_callback(&rctx->fallback_req, areq->base.flags,
areq->base.complete, areq->base.data);
Annotation
- Immediate include surface: `linux/bottom_half.h`, `linux/crypto.h`, `linux/dma-mapping.h`, `linux/io.h`, `linux/pm_runtime.h`, `crypto/scatterwalk.h`, `crypto/internal/des.h`, `crypto/internal/skcipher.h`.
- Detected declarations: `function Copyright`, `function sun8i_ce_cipher_fallback`, `function sun8i_ce_cipher_prepare`, `function sun8i_ce_cipher_unprepare`, `function sun8i_ce_cipher_do_one`, `function sun8i_ce_skdecrypt`, `function sun8i_ce_skencrypt`, `function sun8i_ce_cipher_init`, `function sun8i_ce_cipher_exit`, `function sun8i_ce_aes_setkey`.
- 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.