drivers/crypto/sahara.c
Source file repositories/reference/linux-study-clean/drivers/crypto/sahara.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/sahara.c- Extension
.c- Size
- 38149 bytes
- Lines
- 1437
- 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/aes.hcrypto/internal/hash.hcrypto/internal/skcipher.hcrypto/scatterwalk.hcrypto/engine.hcrypto/sha1.hcrypto/sha2.hlinux/clk.hlinux/dma-mapping.hlinux/interrupt.hlinux/io.hlinux/irq.hlinux/kernel.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/spinlock.h
Detected Declarations
struct sahara_hw_descstruct sahara_hw_linkstruct sahara_ctxstruct sahara_aes_reqctxstruct sahara_sha_reqctxstruct sahara_devfunction sahara_writefunction sahara_readfunction sahara_aes_key_hdrfunction sahara_aes_data_link_hdrfunction sahara_decode_errorfunction sahara_decode_statusfunction sahara_dump_descriptorsfunction sahara_dump_linksfunction sahara_hw_descriptor_createfunction sahara_aes_cbc_update_ivfunction sahara_aes_processfunction sahara_aes_setkeyfunction sahara_aes_fallbackfunction sahara_aes_cryptfunction sahara_aes_ecb_encryptfunction sahara_aes_ecb_decryptfunction sahara_aes_cbc_encryptfunction sahara_aes_cbc_decryptfunction sahara_aes_init_tfmfunction sahara_aes_exit_tfmfunction sahara_sha_init_hdrfunction sahara_sha_hw_links_createfunction sahara_sha_hw_data_descriptor_createfunction sahara_sha_hw_context_descriptor_createfunction sahara_sha_prepare_requestfunction sahara_sha_processfunction sahara_do_one_requestfunction sahara_sha_enqueuefunction sahara_sha_initfunction sahara_sha_updatefunction sahara_sha_finalfunction sahara_sha_finupfunction sahara_sha_digestfunction sahara_sha_exportfunction sahara_sha_importfunction sahara_sha_cra_initfunction sahara_irq_handlerfunction sahara_register_algsfunction sahara_unregister_algsfunction sahara_probefunction sahara_remove
Annotated Snippet
struct sahara_hw_desc {
u32 hdr;
u32 len1;
u32 p1;
u32 len2;
u32 p2;
u32 next;
};
struct sahara_hw_link {
u32 len;
u32 p;
u32 next;
};
struct sahara_ctx {
/* AES-specific context */
int keylen;
u8 key[AES_KEYSIZE_128];
struct crypto_skcipher *fallback;
};
struct sahara_aes_reqctx {
unsigned long mode;
u8 iv_out[AES_BLOCK_SIZE];
struct skcipher_request fallback_req; // keep at the end
};
/*
* struct sahara_sha_reqctx - private data per request
* @buf: holds data for requests smaller than block_size
* @rembuf: used to prepare one block_size-aligned request
* @context: hw-specific context for request. Digest is extracted from this
* @mode: specifies what type of hw-descriptor needs to be built
* @digest_size: length of digest for this request
* @context_size: length of hw-context for this request.
* Always digest_size + 4
* @buf_cnt: number of bytes saved in buf
* @sg_in_idx: number of hw links
* @in_sg: scatterlist for input data
* @in_sg_chain: scatterlists for chained input data
* @total: total number of bytes for transfer
* @last: is this the last block
* @first: is this the first block
*/
struct sahara_sha_reqctx {
u8 buf[SAHARA_MAX_SHA_BLOCK_SIZE];
u8 rembuf[SAHARA_MAX_SHA_BLOCK_SIZE];
u8 context[SHA256_DIGEST_SIZE + 4];
unsigned int mode;
unsigned int digest_size;
unsigned int context_size;
unsigned int buf_cnt;
unsigned int sg_in_idx;
struct scatterlist *in_sg;
struct scatterlist in_sg_chain[2];
size_t total;
unsigned int last;
unsigned int first;
};
struct sahara_dev {
struct device *device;
unsigned int version;
void __iomem *regs_base;
struct clk *clk_ipg;
struct clk *clk_ahb;
struct completion dma_completion;
struct sahara_ctx *ctx;
unsigned long flags;
struct sahara_hw_desc *hw_desc[SAHARA_MAX_HW_DESC];
dma_addr_t hw_phys_desc[SAHARA_MAX_HW_DESC];
u8 *key_base;
dma_addr_t key_phys_base;
u8 *iv_base;
dma_addr_t iv_phys_base;
u8 *context_base;
dma_addr_t context_phys_base;
struct sahara_hw_link *hw_link[SAHARA_MAX_HW_LINK];
dma_addr_t hw_phys_link[SAHARA_MAX_HW_LINK];
size_t total;
struct scatterlist *in_sg;
int nb_in_sg;
Annotation
- Immediate include surface: `crypto/aes.h`, `crypto/internal/hash.h`, `crypto/internal/skcipher.h`, `crypto/scatterwalk.h`, `crypto/engine.h`, `crypto/sha1.h`, `crypto/sha2.h`, `linux/clk.h`.
- Detected declarations: `struct sahara_hw_desc`, `struct sahara_hw_link`, `struct sahara_ctx`, `struct sahara_aes_reqctx`, `struct sahara_sha_reqctx`, `struct sahara_dev`, `function sahara_write`, `function sahara_read`, `function sahara_aes_key_hdr`, `function sahara_aes_data_link_hdr`.
- 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.