drivers/crypto/intel/keembay/keembay-ocs-aes-core.c
Source file repositories/reference/linux-study-clean/drivers/crypto/intel/keembay/keembay-ocs-aes-core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/intel/keembay/keembay-ocs-aes-core.c- Extension
.c- Size
- 48187 bytes
- Lines
- 1690
- 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.
- 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/aes.hcrypto/engine.hcrypto/gcm.hcrypto/internal/aead.hcrypto/internal/skcipher.hcrypto/scatterwalk.hlinux/clk.hlinux/completion.hlinux/dma-mapping.hlinux/err.hlinux/interrupt.hlinux/io.hlinux/kernel.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/string.hocs-aes.h
Detected Declarations
struct ocs_aes_tctxstruct ocs_aes_rctxstruct ocs_aes_drvfunction check_keyfunction save_keyfunction kmb_ocs_sk_set_keyfunction kmb_ocs_aead_set_keyfunction sg_swap_blocksfunction ocs_aes_init_rctxfunction kmb_ocs_sk_validate_inputfunction encryptfunction cleanup_ocs_dma_linked_listfunction kmb_ocs_sk_dma_cleanupfunction kmb_ocs_sk_prepare_inplacefunction kmb_ocs_sk_prepare_notinplacefunction kmb_ocs_sk_runfunction kmb_ocs_aead_validate_inputfunction encryptfunction kmb_ocs_aead_dma_cleanupfunction kmb_ocs_aead_dma_preparefunction kmb_ocs_aead_runfunction kmb_ocs_aes_sk_do_one_requestfunction kmb_ocs_aes_aead_do_one_requestfunction kmb_ocs_aes_set_keyfunction kmb_ocs_aes_aead_set_keyfunction kmb_ocs_aes_ecb_encryptfunction kmb_ocs_aes_ecb_decryptfunction kmb_ocs_aes_cbc_encryptfunction kmb_ocs_aes_cbc_decryptfunction kmb_ocs_aes_ctr_encryptfunction kmb_ocs_aes_ctr_decryptfunction kmb_ocs_aes_cts_encryptfunction kmb_ocs_aes_cts_decryptfunction kmb_ocs_aes_gcm_encryptfunction kmb_ocs_aes_gcm_decryptfunction kmb_ocs_aes_ccm_encryptfunction kmb_ocs_aes_ccm_decryptfunction kmb_ocs_sm4_set_keyfunction kmb_ocs_sm4_aead_set_keyfunction kmb_ocs_sm4_ecb_encryptfunction kmb_ocs_sm4_ecb_decryptfunction kmb_ocs_sm4_cbc_encryptfunction kmb_ocs_sm4_cbc_decryptfunction kmb_ocs_sm4_ctr_encryptfunction kmb_ocs_sm4_ctr_decryptfunction kmb_ocs_sm4_cts_encryptfunction kmb_ocs_sm4_cts_decryptfunction kmb_ocs_sm4_gcm_encrypt
Annotated Snippet
struct ocs_aes_tctx {
struct ocs_aes_dev *aes_dev;
u8 key[OCS_AES_KEYSIZE_256];
unsigned int key_len;
enum ocs_cipher cipher;
union {
struct crypto_sync_skcipher *sk;
struct crypto_aead *aead;
} sw_cipher;
bool use_fallback;
};
/**
* struct ocs_aes_rctx - OCS AES Request context.
* @instruction: Instruction to be executed (encrypt / decrypt).
* @mode: Mode to use (ECB, CBC, CTR, CCm, GCM, CTS)
* @src_nents: Number of source SG entries.
* @dst_nents: Number of destination SG entries.
* @src_dma_count: The number of DMA-mapped entries of the source SG.
* @dst_dma_count: The number of DMA-mapped entries of the destination SG.
* @in_place: Whether or not this is an in place request, i.e.,
* src_sg == dst_sg.
* @src_dll: OCS DMA linked list for input data.
* @dst_dll: OCS DMA linked list for output data.
* @last_ct_blk: Buffer to hold last cipher text block (only used in CBC
* mode).
* @cts_swap: Whether or not CTS swap must be performed.
* @aad_src_dll: OCS DMA linked list for input AAD data.
* @aad_dst_dll: OCS DMA linked list for output AAD data.
* @in_tag: Buffer to hold input encrypted tag (only used for
* CCM/GCM decrypt).
* @out_tag: Buffer to hold output encrypted / decrypted tag (only
* used for GCM encrypt / decrypt).
*/
struct ocs_aes_rctx {
/* Fields common across all modes. */
enum ocs_instruction instruction;
enum ocs_mode mode;
int src_nents;
int dst_nents;
int src_dma_count;
int dst_dma_count;
bool in_place;
struct ocs_dll_desc src_dll;
struct ocs_dll_desc dst_dll;
/* CBC specific */
u8 last_ct_blk[AES_BLOCK_SIZE];
/* CTS specific */
int cts_swap;
/* CCM/GCM specific */
struct ocs_dll_desc aad_src_dll;
struct ocs_dll_desc aad_dst_dll;
u8 in_tag[AES_BLOCK_SIZE];
/* GCM specific */
u8 out_tag[AES_BLOCK_SIZE];
};
/* Driver data. */
struct ocs_aes_drv {
struct list_head dev_list;
spinlock_t lock; /* Protects dev_list. */
};
static struct ocs_aes_drv ocs_aes = {
.dev_list = LIST_HEAD_INIT(ocs_aes.dev_list),
.lock = __SPIN_LOCK_UNLOCKED(ocs_aes.lock),
};
static struct ocs_aes_dev *kmb_ocs_aes_find_dev(struct ocs_aes_tctx *tctx)
{
struct ocs_aes_dev *aes_dev;
spin_lock(&ocs_aes.lock);
if (tctx->aes_dev) {
aes_dev = tctx->aes_dev;
goto exit;
}
/* Only a single OCS device available */
aes_dev = list_first_entry(&ocs_aes.dev_list, struct ocs_aes_dev, list);
tctx->aes_dev = aes_dev;
exit:
spin_unlock(&ocs_aes.lock);
Annotation
- Immediate include surface: `crypto/aes.h`, `crypto/engine.h`, `crypto/gcm.h`, `crypto/internal/aead.h`, `crypto/internal/skcipher.h`, `crypto/scatterwalk.h`, `linux/clk.h`, `linux/completion.h`.
- Detected declarations: `struct ocs_aes_tctx`, `struct ocs_aes_rctx`, `struct ocs_aes_drv`, `function check_key`, `function save_key`, `function kmb_ocs_sk_set_key`, `function kmb_ocs_aead_set_key`, `function sg_swap_blocks`, `function ocs_aes_init_rctx`, `function kmb_ocs_sk_validate_input`.
- 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.