drivers/crypto/caam/caamalg_desc.c
Source file repositories/reference/linux-study-clean/drivers/crypto/caam/caamalg_desc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/caam/caamalg_desc.c- Extension
.c- Size
- 58815 bytes
- Lines
- 1726
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
compat.hdesc_constr.hcaamalg_desc.hsoc/fsl/caam-blob.h
Detected Declarations
function aead_append_src_dstfunction append_dec_op1function cnstr_shdsc_aead_null_encapfunction cnstr_shdsc_aead_null_decapfunction init_sh_desc_key_aeadfunction cnstr_shdsc_aead_encapfunction cnstr_shdsc_aead_decapfunction cnstr_shdsc_aead_givencapfunction cnstr_shdsc_gcm_encapfunction cnstr_shdsc_gcm_decapfunction lengthfunction cnstr_shdsc_rfc4106_decapfunction cnstr_shdsc_rfc4543_encapfunction cnstr_shdsc_rfc4543_decapfunction ESPfunction skcipher_append_src_dstfunction cnstr_desc_skcipher_enc_decfunction cnstr_desc_protected_blob_decapfunction cnstr_shdsc_skcipher_encapfunction cnstr_shdsc_skcipher_decapfunction cnstr_shdsc_xts_skcipher_encapfunction cnstr_shdsc_xts_skcipher_decapexport cnstr_shdsc_aead_null_encapexport cnstr_shdsc_aead_null_decapexport cnstr_shdsc_aead_encapexport cnstr_shdsc_aead_decapexport cnstr_shdsc_aead_givencapexport cnstr_shdsc_gcm_encapexport cnstr_shdsc_gcm_decapexport cnstr_shdsc_rfc4106_encapexport cnstr_shdsc_rfc4106_decapexport cnstr_shdsc_rfc4543_encapexport cnstr_shdsc_rfc4543_decapexport cnstr_shdsc_chachapolyexport cnstr_desc_skcipher_enc_decexport cnstr_desc_protected_blob_decapexport cnstr_shdsc_skcipher_encapexport cnstr_shdsc_skcipher_decapexport cnstr_shdsc_xts_skcipher_encapexport cnstr_shdsc_xts_skcipher_decap
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
/*
* Shared descriptors for aead, skcipher algorithms
*
* Copyright 2016-2019, 2025 NXP
*/
#include "compat.h"
#include "desc_constr.h"
#include "caamalg_desc.h"
#include <soc/fsl/caam-blob.h>
/*
* For aead functions, read payload and write payload,
* both of which are specified in req->src and req->dst
*/
static inline void aead_append_src_dst(u32 *desc, u32 msg_type)
{
append_seq_fifo_store(desc, 0, FIFOST_TYPE_MESSAGE_DATA | KEY_VLF);
append_seq_fifo_load(desc, 0, FIFOLD_CLASS_BOTH |
KEY_VLF | msg_type | FIFOLD_TYPE_LASTBOTH);
}
/* Set DK bit in class 1 operation if shared */
static inline void append_dec_op1(u32 *desc, u32 type)
{
u32 *jump_cmd, *uncond_jump_cmd;
/* DK bit is valid only for AES */
if ((type & OP_ALG_ALGSEL_MASK) != OP_ALG_ALGSEL_AES) {
append_operation(desc, type | OP_ALG_AS_INITFINAL |
OP_ALG_DECRYPT);
return;
}
jump_cmd = append_jump(desc, JUMP_TEST_ALL | JUMP_COND_SHRD);
append_operation(desc, type | OP_ALG_AS_INIT | OP_ALG_DECRYPT);
uncond_jump_cmd = append_jump(desc, JUMP_TEST_ALL);
set_jump_tgt_here(desc, jump_cmd);
append_operation(desc, type | OP_ALG_AS_INIT | OP_ALG_DECRYPT |
OP_ALG_AAI_DK);
set_jump_tgt_here(desc, uncond_jump_cmd);
}
/**
* cnstr_shdsc_aead_null_encap - IPSec ESP encapsulation shared descriptor
* (non-protocol) with no (null) encryption.
* @desc: pointer to buffer used for descriptor construction
* @adata: pointer to authentication transform definitions.
* A split key is required for SEC Era < 6; the size of the split key
* is specified in this case. Valid algorithm values - one of
* OP_ALG_ALGSEL_{MD5, SHA1, SHA224, SHA256, SHA384, SHA512} ANDed
* with OP_ALG_AAI_HMAC_PRECOMP.
* @icvsize: integrity check value (ICV) size (truncated or full)
* @era: SEC Era
*/
void cnstr_shdsc_aead_null_encap(u32 * const desc, struct alginfo *adata,
unsigned int icvsize, int era)
{
u32 *key_jump_cmd, *read_move_cmd, *write_move_cmd;
init_sh_desc(desc, HDR_SHARE_SERIAL);
/* Skip if already shared */
key_jump_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL |
JUMP_COND_SHRD);
if (era < 6) {
if (adata->key_inline)
append_key_as_imm(desc, adata->key_virt,
adata->keylen_pad, adata->keylen,
CLASS_2 | KEY_DEST_MDHA_SPLIT |
KEY_ENC);
else
append_key(desc, adata->key_dma, adata->keylen,
CLASS_2 | KEY_DEST_MDHA_SPLIT | KEY_ENC);
} else {
append_proto_dkp(desc, adata);
}
set_jump_tgt_here(desc, key_jump_cmd);
/* assoclen + cryptlen = seqinlen */
append_math_sub(desc, REG3, SEQINLEN, REG0, CAAM_CMD_SZ);
/* Prepare to read and write cryptlen + assoclen bytes */
append_math_add(desc, VARSEQINLEN, ZERO, REG3, CAAM_CMD_SZ);
append_math_add(desc, VARSEQOUTLEN, ZERO, REG3, CAAM_CMD_SZ);
/*
* MOVE_LEN opcode is not available in all SEC HW revisions,
* thus need to do some magic, i.e. self-patch the descriptor
Annotation
- Immediate include surface: `compat.h`, `desc_constr.h`, `caamalg_desc.h`, `soc/fsl/caam-blob.h`.
- Detected declarations: `function aead_append_src_dst`, `function append_dec_op1`, `function cnstr_shdsc_aead_null_encap`, `function cnstr_shdsc_aead_null_decap`, `function init_sh_desc_key_aead`, `function cnstr_shdsc_aead_encap`, `function cnstr_shdsc_aead_decap`, `function cnstr_shdsc_aead_givencap`, `function cnstr_shdsc_gcm_encap`, `function cnstr_shdsc_gcm_decap`.
- Atlas domain: Driver Families / drivers/crypto.
- Implementation status: integration implementation candidate.
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.