drivers/crypto/ti/dthev2-aes.c
Source file repositories/reference/linux-study-clean/drivers/crypto/ti/dthev2-aes.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/ti/dthev2-aes.c- Extension
.c- Size
- 40349 bytes
- Lines
- 1376
- 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/aead.hcrypto/aes.hcrypto/algapi.hcrypto/engine.hcrypto/gcm.hcrypto/internal/aead.hcrypto/internal/skcipher.hdthev2-common.hlinux/bitfield.hlinux/delay.hlinux/dmaengine.hlinux/dma-mapping.hlinux/io.hlinux/iopoll.hlinux/scatterlist.h
Detected Declarations
enum aes_ctrl_mode_masksfunction dthe_cipher_init_tfmfunction dthe_cipher_init_tfm_fallbackfunction dthe_cipher_exit_tfmfunction dthe_aes_setkeyfunction dthe_aes_ecb_setkeyfunction dthe_aes_cbc_setkeyfunction dthe_aes_ctr_setkeyfunction dthe_aes_xts_setkeyfunction dthe_aes_set_ctrl_keyfunction dthe_aes_do_fallbackfunction dthe_aes_dma_in_callbackfunction dthe_aes_runfunction dthe_aes_cryptfunction dthe_aes_encryptfunction dthe_aes_decryptfunction dthe_aead_init_tfmfunction dthe_aead_exit_tfmfunction dthe_aead_read_tagfunction dthe_aead_enc_get_tagfunction dthe_aead_dec_verify_tagfunction dthe_aead_setkeyfunction dthe_gcm_aes_setkeyfunction dthe_ccm_aes_setkeyfunction dthe_aead_setauthsizefunction dthe_aead_do_fallbackfunction dthe_aead_dma_in_callbackfunction dthe_aead_runfunction dthe_aead_cryptfunction dthe_aead_encryptfunction dthe_aead_decryptfunction dthe_register_aes_algsfunction dthe_unregister_aes_algs
Annotated Snippet
if (ctx->keylen > AES_KEYSIZE_128) {
writel_relaxed(ctx->key[key2_offset + 4], aes_base_reg + DTHE_P_AES_KEY2_4);
writel_relaxed(ctx->key[key2_offset + 5], aes_base_reg + DTHE_P_AES_KEY2_5);
}
if (ctx->keylen == AES_KEYSIZE_256) {
writel_relaxed(ctx->key[key2_offset + 6], aes_base_reg + DTHE_P_AES_KEY2_6);
writel_relaxed(ctx->key[key2_offset + 7], aes_base_reg + DTHE_P_AES_KEY2_7);
}
}
if (rctx->enc)
ctrl_val |= DTHE_AES_CTRL_DIR_ENC;
if (ctx->keylen == AES_KEYSIZE_128)
ctrl_val |= DTHE_AES_CTRL_KEYSIZE_16B;
else if (ctx->keylen == AES_KEYSIZE_192)
ctrl_val |= DTHE_AES_CTRL_KEYSIZE_24B;
else
ctrl_val |= DTHE_AES_CTRL_KEYSIZE_32B;
// Write AES mode
ctrl_val &= DTHE_AES_CTRL_MODE_CLEAR_MASK;
switch (ctx->aes_mode) {
case DTHE_AES_ECB:
ctrl_val |= AES_CTRL_ECB_MASK;
break;
case DTHE_AES_CBC:
ctrl_val |= AES_CTRL_CBC_MASK;
break;
case DTHE_AES_CTR:
ctrl_val |= AES_CTRL_CTR_MASK;
ctrl_val |= DTHE_AES_CTRL_CTR_WIDTH_128B;
break;
case DTHE_AES_XTS:
ctrl_val |= AES_CTRL_XTS_MASK;
break;
case DTHE_AES_GCM:
ctrl_val |= AES_CTRL_GCM_MASK;
break;
case DTHE_AES_CCM:
ctrl_val |= AES_CTRL_CCM_MASK;
ctrl_val |= FIELD_PREP(DTHE_AES_CTRL_CCM_L_FIELD_MASK,
(iv_in[0] & DTHE_AES_CCM_L_FROM_IV_MASK));
ctrl_val |= FIELD_PREP(DTHE_AES_CTRL_CCM_M_FIELD_MASK,
((ctx->authsize - 2) >> 1) & DTHE_AES_CCM_M_BITS);
break;
}
if (iv_in) {
ctrl_val |= DTHE_AES_CTRL_SAVE_CTX_SET;
for (int i = 0; i < AES_IV_WORDS; ++i)
writel_relaxed(iv_in[i],
aes_base_reg + DTHE_P_AES_IV_IN_0 + (DTHE_REG_SIZE * i));
}
writel_relaxed(ctrl_val, aes_base_reg + DTHE_P_AES_CTRL);
}
static int dthe_aes_do_fallback(struct skcipher_request *req)
{
struct dthe_tfm_ctx *ctx = crypto_skcipher_ctx(crypto_skcipher_reqtfm(req));
struct dthe_aes_req_ctx *rctx = skcipher_request_ctx(req);
SYNC_SKCIPHER_REQUEST_ON_STACK(subreq, ctx->skcipher_fb);
skcipher_request_set_callback(subreq, skcipher_request_flags(req),
req->base.complete, req->base.data);
skcipher_request_set_crypt(subreq, req->src, req->dst,
req->cryptlen, req->iv);
return rctx->enc ? crypto_skcipher_encrypt(subreq) :
crypto_skcipher_decrypt(subreq);
}
static void dthe_aes_dma_in_callback(void *data)
{
struct skcipher_request *req = (struct skcipher_request *)data;
struct dthe_aes_req_ctx *rctx = skcipher_request_ctx(req);
complete(&rctx->aes_compl);
}
static int dthe_aes_run(struct crypto_engine *engine, void *areq)
{
struct skcipher_request *req = container_of(areq, struct skcipher_request, base);
struct dthe_tfm_ctx *ctx = crypto_skcipher_ctx(crypto_skcipher_reqtfm(req));
struct dthe_data *dev_data = dthe_get_dev(ctx);
struct dthe_aes_req_ctx *rctx = skcipher_request_ctx(req);
unsigned int len = req->cryptlen;
Annotation
- Immediate include surface: `crypto/aead.h`, `crypto/aes.h`, `crypto/algapi.h`, `crypto/engine.h`, `crypto/gcm.h`, `crypto/internal/aead.h`, `crypto/internal/skcipher.h`, `dthev2-common.h`.
- Detected declarations: `enum aes_ctrl_mode_masks`, `function dthe_cipher_init_tfm`, `function dthe_cipher_init_tfm_fallback`, `function dthe_cipher_exit_tfm`, `function dthe_aes_setkey`, `function dthe_aes_ecb_setkey`, `function dthe_aes_cbc_setkey`, `function dthe_aes_ctr_setkey`, `function dthe_aes_xts_setkey`, `function dthe_aes_set_ctrl_key`.
- 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.