drivers/crypto/caam/caamalg.c
Source file repositories/reference/linux-study-clean/drivers/crypto/caam/caamalg.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/caam/caamalg.c- Extension
.c- Size
- 106789 bytes
- Lines
- 3989
- 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
compat.hregs.hintern.hdesc_constr.hjr.herror.hsg_sw_sec4.hkey_gen.hcaamalg_desc.hlinux/unaligned.hcrypto/internal/aead.hcrypto/internal/engine.hcrypto/internal/skcipher.hcrypto/xts.hkeys/trusted-type.hlinux/dma-mapping.hlinux/device.hlinux/err.hlinux/module.hlinux/kernel.hlinux/key-type.hlinux/slab.hlinux/string.hsoc/fsl/caam-blob.h
Detected Declarations
struct caam_alg_entrystruct caam_aead_algstruct caam_skcipher_algstruct caam_ctxstruct caam_skcipher_req_ctxstruct caam_aead_req_ctxstruct aead_edescstruct skcipher_edescfunction aead_null_set_sh_descfunction aead_set_sh_descfunction aead_setauthsizefunction gcm_set_sh_descfunction gcm_setauthsizefunction rfc4106_set_sh_descfunction rfc4106_setauthsizefunction rfc4543_set_sh_descfunction rfc4543_setauthsizefunction chachapoly_set_sh_descfunction chachapoly_setauthsizefunction chachapoly_setkeyfunction aead_setkeyfunction des3_aead_setkeyfunction gcm_setkeyfunction rfc4106_setkeyfunction rfc4543_setkeyfunction skcipher_setkeyfunction paes_skcipher_setkeyfunction aes_skcipher_setkeyfunction rfc3686_skcipher_setkeyfunction ctr_skcipher_setkeyfunction des_skcipher_setkeyfunction des3_skcipher_setkeyfunction xts_skcipher_setkeyfunction caam_unmapfunction aead_unmapfunction skcipher_unmapfunction aead_crypt_donefunction skcipher_crypt_donefunction IVfunction init_aead_jobfunction init_gcm_jobfunction init_chachapoly_jobfunction init_authenc_jobfunction init_skcipher_jobfunction aead_enqueue_reqfunction chachapoly_cryptfunction chachapoly_encryptfunction chachapoly_decrypt
Annotated Snippet
struct caam_alg_entry {
int class1_alg_type;
int class2_alg_type;
bool rfc3686;
bool geniv;
bool nodkp;
};
struct caam_aead_alg {
struct aead_engine_alg aead;
struct caam_alg_entry caam;
bool registered;
};
struct caam_skcipher_alg {
struct skcipher_engine_alg skcipher;
struct caam_alg_entry caam;
bool registered;
};
/*
* per-session context
*/
struct caam_ctx {
u32 sh_desc_enc[DESC_MAX_USED_LEN];
u32 sh_desc_dec[DESC_MAX_USED_LEN];
u8 key[CAAM_MAX_KEY_SIZE];
dma_addr_t sh_desc_enc_dma;
dma_addr_t sh_desc_dec_dma;
dma_addr_t key_dma;
u8 protected_key[CAAM_MAX_KEY_SIZE];
dma_addr_t protected_key_dma;
enum dma_data_direction dir;
struct device *jrdev;
struct alginfo adata;
struct alginfo cdata;
unsigned int authsize;
bool xts_key_fallback;
bool is_blob;
struct crypto_skcipher *fallback;
};
struct caam_skcipher_req_ctx {
struct skcipher_edesc *edesc;
struct skcipher_request fallback_req;
};
struct caam_aead_req_ctx {
struct aead_edesc *edesc;
};
static int aead_null_set_sh_desc(struct crypto_aead *aead)
{
struct caam_ctx *ctx = crypto_aead_ctx_dma(aead);
struct device *jrdev = ctx->jrdev;
struct caam_drv_private *ctrlpriv = dev_get_drvdata(jrdev->parent);
u32 *desc;
int rem_bytes = CAAM_DESC_BYTES_MAX - AEAD_DESC_JOB_IO_LEN -
ctx->adata.keylen_pad;
/*
* Job Descriptor and Shared Descriptors
* must all fit into the 64-word Descriptor h/w Buffer
*/
if (rem_bytes >= DESC_AEAD_NULL_ENC_LEN) {
ctx->adata.key_inline = true;
ctx->adata.key_virt = ctx->key;
} else {
ctx->adata.key_inline = false;
ctx->adata.key_dma = ctx->key_dma;
}
/* aead_encrypt shared descriptor */
desc = ctx->sh_desc_enc;
cnstr_shdsc_aead_null_encap(desc, &ctx->adata, ctx->authsize,
ctrlpriv->era);
dma_sync_single_for_device(jrdev, ctx->sh_desc_enc_dma,
desc_bytes(desc), ctx->dir);
/*
* Job Descriptor and Shared Descriptors
* must all fit into the 64-word Descriptor h/w Buffer
*/
if (rem_bytes >= DESC_AEAD_NULL_DEC_LEN) {
ctx->adata.key_inline = true;
ctx->adata.key_virt = ctx->key;
} else {
ctx->adata.key_inline = false;
ctx->adata.key_dma = ctx->key_dma;
}
Annotation
- Immediate include surface: `compat.h`, `regs.h`, `intern.h`, `desc_constr.h`, `jr.h`, `error.h`, `sg_sw_sec4.h`, `key_gen.h`.
- Detected declarations: `struct caam_alg_entry`, `struct caam_aead_alg`, `struct caam_skcipher_alg`, `struct caam_ctx`, `struct caam_skcipher_req_ctx`, `struct caam_aead_req_ctx`, `struct aead_edesc`, `struct skcipher_edesc`, `function aead_null_set_sh_desc`, `function aead_set_sh_desc`.
- 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.