drivers/crypto/nx/nx-aes-ccm.c
Source file repositories/reference/linux-study-clean/drivers/crypto/nx/nx-aes-ccm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/nx/nx-aes-ccm.c- Extension
.c- Size
- 14346 bytes
- Lines
- 560
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
crypto/internal/aead.hcrypto/aes.hcrypto/algapi.hcrypto/scatterwalk.hlinux/module.hlinux/types.hlinux/crypto.hasm/vio.hnx_csbcpb.hnx.h
Detected Declarations
function Copyrightfunction ccm4309_aes_nx_set_keyfunction ccm_aes_nx_setauthsizefunction ccm4309_aes_nx_setauthsizefunction set_msg_lenfunction crypto_ccm_check_ivfunction generate_b0function generate_patfunction ccm_nx_decryptfunction ccm_nx_encryptfunction ccm4309_aes_nx_encryptfunction ccm_aes_nx_encryptfunction ccm4309_aes_nx_decryptfunction ccm_aes_nx_decrypt
Annotated Snippet
if (assoclen <= 65280) {
*(u16 *)b1 = assoclen;
memcpy_from_sglist(b1 + 2, req->src, 0, iauth_len);
} else {
*(u16 *)b1 = (u16)(0xfffe);
*(u32 *)&b1[2] = assoclen;
memcpy_from_sglist(b1 + 6, req->src, 0, iauth_len);
}
}
/* now copy any remaining AAD to scatterlist and call nx... */
if (!assoclen) {
return rc;
} else if (assoclen <= 14) {
unsigned int len = 16;
nx_insg = nx_build_sg_list(nx_insg, b1, &len, nx_ctx->ap->sglen);
if (len != 16)
return -EINVAL;
nx_outsg = nx_build_sg_list(nx_outsg, tmp, &len,
nx_ctx->ap->sglen);
if (len != 16)
return -EINVAL;
/* inlen should be negative, indicating to phyp that its a
* pointer to an sg list */
nx_ctx->op.inlen = (nx_ctx->in_sg - nx_insg) *
sizeof(struct nx_sg);
nx_ctx->op.outlen = (nx_ctx->out_sg - nx_outsg) *
sizeof(struct nx_sg);
NX_CPB_FDM(nx_ctx->csbcpb) |= NX_FDM_ENDE_ENCRYPT;
NX_CPB_FDM(nx_ctx->csbcpb) |= NX_FDM_INTERMEDIATE;
result = nx_ctx->csbcpb->cpb.aes_ccm.out_pat_or_mac;
rc = nx_hcall_sync(nx_ctx, &nx_ctx->op,
req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP);
if (rc)
return rc;
atomic_inc(&(nx_ctx->stats->aes_ops));
atomic64_add(assoclen, &nx_ctx->stats->aes_bytes);
} else {
unsigned int processed = 0, to_process;
processed += iauth_len;
/* page_limit: number of sg entries that fit on one page */
max_sg_len = min_t(u64, nx_ctx->ap->sglen,
nx_driver.of.max_sg_len/sizeof(struct nx_sg));
max_sg_len = min_t(u64, max_sg_len,
nx_ctx->ap->databytelen/NX_PAGE_SIZE);
do {
to_process = min_t(u32, assoclen - processed,
nx_ctx->ap->databytelen);
nx_insg = nx_walk_and_build(nx_ctx->in_sg,
nx_ctx->ap->sglen,
req->src, processed,
&to_process);
if ((to_process + processed) < assoclen) {
NX_CPB_FDM(nx_ctx->csbcpb_aead) |=
NX_FDM_INTERMEDIATE;
} else {
NX_CPB_FDM(nx_ctx->csbcpb_aead) &=
~NX_FDM_INTERMEDIATE;
}
nx_ctx->op_aead.inlen = (nx_ctx->in_sg - nx_insg) *
sizeof(struct nx_sg);
result = nx_ctx->csbcpb_aead->cpb.aes_cca.out_pat_or_b0;
rc = nx_hcall_sync(nx_ctx, &nx_ctx->op_aead,
req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP);
if (rc)
return rc;
memcpy(nx_ctx->csbcpb_aead->cpb.aes_cca.b0,
nx_ctx->csbcpb_aead->cpb.aes_cca.out_pat_or_b0,
AES_BLOCK_SIZE);
Annotation
- Immediate include surface: `crypto/internal/aead.h`, `crypto/aes.h`, `crypto/algapi.h`, `crypto/scatterwalk.h`, `linux/module.h`, `linux/types.h`, `linux/crypto.h`, `asm/vio.h`.
- Detected declarations: `function Copyright`, `function ccm4309_aes_nx_set_key`, `function ccm_aes_nx_setauthsize`, `function ccm4309_aes_nx_setauthsize`, `function set_msg_len`, `function crypto_ccm_check_iv`, `function generate_b0`, `function generate_pat`, `function ccm_nx_decrypt`, `function ccm_nx_encrypt`.
- 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.
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.