drivers/crypto/marvell/cesa/cipher.c
Source file repositories/reference/linux-study-clean/drivers/crypto/marvell/cesa/cipher.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/marvell/cesa/cipher.c- Extension
.c- Size
- 21869 bytes
- Lines
- 823
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
crypto/aes.hcrypto/internal/des.hlinux/device.hlinux/dma-mapping.hcesa.h
Detected Declarations
struct mv_cesa_des_ctxstruct mv_cesa_des3_ctxstruct mv_cesa_aes_ctxstruct mv_cesa_skcipher_dma_iterfunction mv_cesa_skcipher_req_iter_initfunction mv_cesa_skcipher_req_iter_next_opfunction mv_cesa_skcipher_dma_cleanupfunction mv_cesa_skcipher_cleanupfunction mv_cesa_skcipher_std_stepfunction mv_cesa_skcipher_std_processfunction mv_cesa_skcipher_processfunction mv_cesa_skcipher_stepfunction mv_cesa_skcipher_dma_preparefunction mv_cesa_skcipher_std_preparefunction mv_cesa_skcipher_preparefunction mv_cesa_skcipher_req_cleanupfunction mv_cesa_skcipher_completefunction mv_cesa_skcipher_cra_exitfunction mv_cesa_skcipher_cra_initfunction mv_cesa_aes_setkeyfunction mv_cesa_des_setkeyfunction mv_cesa_des3_ede_setkeyfunction mv_cesa_skcipher_dma_req_initfunction mv_cesa_skcipher_std_req_initfunction mv_cesa_skcipher_req_initfunction mv_cesa_skcipher_queue_reqfunction mv_cesa_des_opfunction mv_cesa_ecb_des_encryptfunction mv_cesa_ecb_des_decryptfunction mv_cesa_cbc_des_opfunction mv_cesa_cbc_des_encryptfunction mv_cesa_cbc_des_decryptfunction mv_cesa_des3_opfunction mv_cesa_ecb_des3_ede_encryptfunction mv_cesa_ecb_des3_ede_decryptfunction mv_cesa_cbc_des3_opfunction mv_cesa_cbc_des3_ede_encryptfunction mv_cesa_cbc_des3_ede_decryptfunction mv_cesa_aes_opfunction mv_cesa_ecb_aes_encryptfunction mv_cesa_ecb_aes_decryptfunction mv_cesa_cbc_aes_opfunction mv_cesa_cbc_aes_encryptfunction mv_cesa_cbc_aes_decrypt
Annotated Snippet
struct mv_cesa_des_ctx {
struct mv_cesa_ctx base;
u8 key[DES_KEY_SIZE];
};
struct mv_cesa_des3_ctx {
struct mv_cesa_ctx base;
u8 key[DES3_EDE_KEY_SIZE];
};
struct mv_cesa_aes_ctx {
struct mv_cesa_ctx base;
struct crypto_aes_ctx aes;
};
struct mv_cesa_skcipher_dma_iter {
struct mv_cesa_dma_iter base;
struct mv_cesa_sg_dma_iter src;
struct mv_cesa_sg_dma_iter dst;
};
static inline void
mv_cesa_skcipher_req_iter_init(struct mv_cesa_skcipher_dma_iter *iter,
struct skcipher_request *req)
{
mv_cesa_req_dma_iter_init(&iter->base, req->cryptlen);
mv_cesa_sg_dma_iter_init(&iter->src, req->src, DMA_TO_DEVICE);
mv_cesa_sg_dma_iter_init(&iter->dst, req->dst, DMA_FROM_DEVICE);
}
static inline bool
mv_cesa_skcipher_req_iter_next_op(struct mv_cesa_skcipher_dma_iter *iter)
{
iter->src.op_offset = 0;
iter->dst.op_offset = 0;
return mv_cesa_req_dma_iter_next_op(&iter->base);
}
static inline void
mv_cesa_skcipher_dma_cleanup(struct skcipher_request *req)
{
struct mv_cesa_skcipher_req *creq = skcipher_request_ctx(req);
if (req->dst != req->src) {
dma_unmap_sg(cesa_dev->dev, req->dst, creq->dst_nents,
DMA_FROM_DEVICE);
dma_unmap_sg(cesa_dev->dev, req->src, creq->src_nents,
DMA_TO_DEVICE);
} else {
dma_unmap_sg(cesa_dev->dev, req->src, creq->src_nents,
DMA_BIDIRECTIONAL);
}
mv_cesa_dma_cleanup(&creq->base);
}
static inline void mv_cesa_skcipher_cleanup(struct skcipher_request *req)
{
struct mv_cesa_skcipher_req *creq = skcipher_request_ctx(req);
struct mv_cesa_engine *engine = creq->base.engine;
if (mv_cesa_req_get_type(&creq->base) == CESA_DMA_REQ)
mv_cesa_skcipher_dma_cleanup(req);
atomic_sub(req->cryptlen, &engine->load);
}
static void mv_cesa_skcipher_std_step(struct skcipher_request *req)
{
struct mv_cesa_skcipher_req *creq = skcipher_request_ctx(req);
struct mv_cesa_skcipher_std_req *sreq = &creq->std;
struct mv_cesa_engine *engine = creq->base.engine;
size_t len = min_t(size_t, req->cryptlen - sreq->offset,
CESA_SA_SRAM_PAYLOAD_SIZE);
mv_cesa_adjust_op(engine, &sreq->op);
if (engine->pool)
memcpy(engine->sram_pool, &sreq->op, sizeof(sreq->op));
else
memcpy_toio(engine->sram, &sreq->op, sizeof(sreq->op));
len = mv_cesa_sg_copy_to_sram(engine, req->src, creq->src_nents,
CESA_SA_DATA_SRAM_OFFSET, len,
sreq->offset);
sreq->size = len;
mv_cesa_set_crypt_op_len(&sreq->op, len);
/* FIXME: only update enc_len field */
if (!sreq->skip_ctx) {
Annotation
- Immediate include surface: `crypto/aes.h`, `crypto/internal/des.h`, `linux/device.h`, `linux/dma-mapping.h`, `cesa.h`.
- Detected declarations: `struct mv_cesa_des_ctx`, `struct mv_cesa_des3_ctx`, `struct mv_cesa_aes_ctx`, `struct mv_cesa_skcipher_dma_iter`, `function mv_cesa_skcipher_req_iter_init`, `function mv_cesa_skcipher_req_iter_next_op`, `function mv_cesa_skcipher_dma_cleanup`, `function mv_cesa_skcipher_cleanup`, `function mv_cesa_skcipher_std_step`, `function mv_cesa_skcipher_std_process`.
- 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.