drivers/crypto/caam/caamalg_qi2.c
Source file repositories/reference/linux-study-clean/drivers/crypto/caam/caamalg_qi2.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/caam/caamalg_qi2.c- Extension
.c- Size
- 153561 bytes
- Lines
- 5566
- Domain
- Driver Families
- Bucket
- drivers/crypto
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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.hcaamalg_qi2.hdpseci_cmd.hdesc_constr.herror.hsg_sw_sec4.hsg_sw_qm2.hkey_gen.hcaamalg_desc.hcaamhash_desc.hdpseci-debugfs.hlinux/dma-mapping.hlinux/fsl/mc.hlinux/kernel.hlinux/string.hlinux/string_choices.hsoc/fsl/dpaa2-io.hsoc/fsl/dpaa2-fd.hcrypto/xts.hlinux/unaligned.h
Detected Declarations
struct caam_alg_entrystruct caam_aead_algstruct caam_skcipher_algstruct caam_ctxstruct caam_hash_ctxstruct caam_hash_statestruct caam_export_statestruct split_key_sh_resultstruct caam_hash_templatestruct caam_hash_algenum hash_optypefunction cachefunction kmem_cache_freefunction caam_unmapfunction aead_set_sh_descfunction aead_setauthsizefunction aead_setkeyfunction des3_aead_setkeyfunction chachapoly_set_sh_descfunction chachapoly_setauthsizefunction chachapoly_setkeyfunction gcm_set_sh_descfunction gcm_setauthsizefunction gcm_setkeyfunction rfc4106_set_sh_descfunction rfc4106_setauthsizefunction rfc4106_setkeyfunction rfc4543_set_sh_descfunction rfc4543_setauthsizefunction rfc4543_setkeyfunction skcipher_setkeyfunction aes_skcipher_setkeyfunction rfc3686_skcipher_setkeyfunction ctr_skcipher_setkeyfunction chacha20_skcipher_setkeyfunction des_skcipher_setkeyfunction des3_skcipher_setkeyfunction xts_skcipher_setkeyfunction aead_unmapfunction skcipher_unmapfunction aead_encrypt_donefunction aead_decrypt_donefunction aead_encryptfunction aead_decryptfunction ipsec_gcm_encryptfunction ipsec_gcm_decryptfunction skcipher_encrypt_donefunction skcipher_decrypt_done
Annotated Snippet
struct caam_alg_entry {
struct device *dev;
int class1_alg_type;
int class2_alg_type;
bool rfc3686;
bool geniv;
bool nodkp;
};
struct caam_aead_alg {
struct aead_alg aead;
struct caam_alg_entry caam;
bool registered;
};
struct caam_skcipher_alg {
struct skcipher_alg skcipher;
struct caam_alg_entry caam;
bool registered;
};
/**
* struct caam_ctx - per-session context
* @flc: Flow Contexts array
* @key: [authentication key], encryption key
* @flc_dma: I/O virtual addresses of the Flow Contexts
* @key_dma: I/O virtual address of the key
* @dir: DMA direction for mapping key and Flow Contexts
* @dev: dpseci device
* @adata: authentication algorithm details
* @cdata: encryption algorithm details
* @authsize: authentication tag (a.k.a. ICV / MAC) size
* @xts_key_fallback: true if fallback tfm needs to be used due
* to unsupported xts key lengths
* @fallback: xts fallback tfm
*/
struct caam_ctx {
struct caam_flc flc[NUM_OP];
u8 key[CAAM_MAX_KEY_SIZE];
dma_addr_t flc_dma[NUM_OP];
dma_addr_t key_dma;
enum dma_data_direction dir;
struct device *dev;
struct alginfo adata;
struct alginfo cdata;
unsigned int authsize;
bool xts_key_fallback;
struct crypto_skcipher *fallback;
};
static void *dpaa2_caam_iova_to_virt(struct dpaa2_caam_priv *priv,
dma_addr_t iova_addr)
{
phys_addr_t phys_addr;
phys_addr = priv->domain ? iommu_iova_to_phys(priv->domain, iova_addr) :
iova_addr;
return phys_to_virt(phys_addr);
}
/*
* qi_cache_zalloc - Allocate buffers from CAAM-QI cache
*
* Allocate data on the hotpath. Instead of using kzalloc, one can use the
* services of the CAAM QI memory cache (backed by kmem_cache). The buffers
* will have a size of CAAM_QI_MEMCACHE_SIZE, which should be sufficient for
* hosting 16 SG entries.
*
* @flags - flags that would be used for the equivalent kmalloc(..) call
*
* Returns a pointer to a retrieved buffer on success or NULL on failure.
*/
static inline void *qi_cache_zalloc(gfp_t flags)
{
return kmem_cache_zalloc(qi_cache, flags);
}
/*
* qi_cache_free - Frees buffers allocated from CAAM-QI cache
*
* @obj - buffer previously allocated by qi_cache_zalloc
*
* No checking is being done, the call is a passthrough call to
* kmem_cache_free(...)
*/
static inline void qi_cache_free(void *obj)
{
kmem_cache_free(qi_cache, obj);
}
Annotation
- Immediate include surface: `compat.h`, `regs.h`, `caamalg_qi2.h`, `dpseci_cmd.h`, `desc_constr.h`, `error.h`, `sg_sw_sec4.h`, `sg_sw_qm2.h`.
- Detected declarations: `struct caam_alg_entry`, `struct caam_aead_alg`, `struct caam_skcipher_alg`, `struct caam_ctx`, `struct caam_hash_ctx`, `struct caam_hash_state`, `struct caam_export_state`, `struct split_key_sh_result`, `struct caam_hash_template`, `struct caam_hash_alg`.
- Atlas domain: Driver Families / drivers/crypto.
- Implementation status: integration 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.