drivers/crypto/stm32/stm32-cryp.c
Source file repositories/reference/linux-study-clean/drivers/crypto/stm32/stm32-cryp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/stm32/stm32-cryp.c- Extension
.c- Size
- 69622 bytes
- Lines
- 2779
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/aes.hcrypto/engine.hcrypto/internal/aead.hcrypto/internal/des.hcrypto/internal/skcipher.hcrypto/scatterwalk.hlinux/bottom_half.hlinux/clk.hlinux/delay.hlinux/dma-mapping.hlinux/dmaengine.hlinux/err.hlinux/iopoll.hlinux/interrupt.hlinux/kernel.hlinux/module.hlinux/minmax.hlinux/of.hlinux/platform_device.hlinux/pm_runtime.hlinux/reset.hlinux/string.h
Detected Declarations
struct stm32_cryp_capsstruct stm32_cryp_ctxstruct stm32_cryp_reqctxstruct stm32_crypstruct stm32_cryp_listenum stm32_dma_modefunction is_aesfunction is_desfunction is_tdesfunction is_ecbfunction is_cbcfunction is_ctrfunction is_gcmfunction is_ccmfunction is_encryptfunction is_decryptfunction stm32_cryp_readfunction stm32_cryp_writefunction stm32_cryp_wait_busyfunction stm32_cryp_enablefunction stm32_cryp_wait_enablefunction stm32_cryp_wait_inputfunction stm32_cryp_wait_outputfunction stm32_cryp_key_read_enablefunction stm32_cryp_key_read_disablefunction stm32_cryp_hw_write_ivfunction stm32_cryp_get_ivfunction ux500_swap_bits_in_bytefunction ux500_swizzle_keyfunction stm32_cryp_hw_write_keyfunction stm32_cryp_get_hw_modefunction stm32_cryp_get_input_text_lenfunction stm32_cryp_gcm_initfunction stm32_crypt_gcmccm_end_headerfunction stm32_cryp_write_ccm_first_headerfunction stm32_cryp_ccm_initfunction stm32_cryp_hw_initfunction stm32_cryp_finish_reqfunction stm32_cryp_header_dma_callbackfunction stm32_cryp_dma_callbackfunction stm32_cryp_header_dma_startfunction stm32_cryp_dma_startfunction stm32_cryp_it_startfunction stm32_cryp_init_tfmfunction stm32_cryp_aes_aead_initfunction stm32_cryp_cryptfunction stm32_cryp_aead_cryptfunction stm32_cryp_setkey
Annotated Snippet
struct stm32_cryp_caps {
bool aeads_support;
bool linear_aes_key;
bool kp_mode;
bool iv_protection;
bool swap_final;
bool padding_wa;
u32 cr;
u32 sr;
u32 din;
u32 dout;
u32 dmacr;
u32 imsc;
u32 mis;
u32 k1l;
u32 k1r;
u32 k3r;
u32 iv0l;
u32 iv0r;
u32 iv1l;
u32 iv1r;
};
struct stm32_cryp_ctx {
struct stm32_cryp *cryp;
int keylen;
__be32 key[AES_KEYSIZE_256 / sizeof(u32)];
unsigned long flags;
};
struct stm32_cryp_reqctx {
unsigned long mode;
};
struct stm32_cryp {
struct list_head list;
struct device *dev;
void __iomem *regs;
phys_addr_t phys_base;
struct clk *clk;
unsigned long flags;
u32 irq_status;
const struct stm32_cryp_caps *caps;
struct stm32_cryp_ctx *ctx;
struct crypto_engine *engine;
struct skcipher_request *req;
struct aead_request *areq;
size_t authsize;
size_t hw_blocksize;
size_t payload_in;
size_t header_in;
size_t payload_out;
/* DMA process fields */
struct scatterlist *in_sg;
struct scatterlist *header_sg;
struct scatterlist *out_sg;
size_t in_sg_len;
size_t header_sg_len;
size_t out_sg_len;
struct completion dma_completion;
struct dma_chan *dma_lch_in;
struct dma_chan *dma_lch_out;
enum stm32_dma_mode dma_mode;
/* IT process fields */
struct scatter_walk in_walk;
struct scatter_walk out_walk;
__be32 last_ctr[4];
u32 gcm_ctr;
};
struct stm32_cryp_list {
struct list_head dev_list;
spinlock_t lock; /* protect dev_list */
};
static struct stm32_cryp_list cryp_list = {
.dev_list = LIST_HEAD_INIT(cryp_list.dev_list),
.lock = __SPIN_LOCK_UNLOCKED(cryp_list.lock),
};
static inline bool is_aes(struct stm32_cryp *cryp)
{
Annotation
- Immediate include surface: `crypto/aes.h`, `crypto/engine.h`, `crypto/internal/aead.h`, `crypto/internal/des.h`, `crypto/internal/skcipher.h`, `crypto/scatterwalk.h`, `linux/bottom_half.h`, `linux/clk.h`.
- Detected declarations: `struct stm32_cryp_caps`, `struct stm32_cryp_ctx`, `struct stm32_cryp_reqctx`, `struct stm32_cryp`, `struct stm32_cryp_list`, `enum stm32_dma_mode`, `function is_aes`, `function is_des`, `function is_tdes`, `function is_ecb`.
- Atlas domain: Driver Families / drivers/crypto.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.