drivers/crypto/intel/keembay/keembay-ocs-hcu-core.c
Source file repositories/reference/linux-study-clean/drivers/crypto/intel/keembay/keembay-ocs-hcu-core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/intel/keembay/keembay-ocs-hcu-core.c- Extension
.c- Size
- 34178 bytes
- Lines
- 1265
- 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/engine.hcrypto/hmac.hcrypto/internal/hash.hcrypto/scatterwalk.hcrypto/sha2.hcrypto/sm3.hlinux/completion.hlinux/dma-mapping.hlinux/err.hlinux/interrupt.hlinux/kernel.hlinux/mod_devicetable.hlinux/module.hlinux/platform_device.hlinux/string.hocs-hcu.h
Detected Declarations
struct ocs_hcu_ctxstruct ocs_hcu_rctxstruct ocs_hcu_drvfunction kmb_get_total_datafunction flush_sg_to_ocs_bufferfunction kmb_ocs_hcu_dma_cleanupfunction kmb_ocs_dma_preparefunction remainderfunction kmb_ocs_hcu_secure_cleanupfunction kmb_ocs_hcu_handle_queuefunction prepare_ipadfunction zerofunction kmb_ocs_hcu_do_one_requestfunction kmb_ocs_hcu_initfunction kmb_ocs_hcu_updatefunction switchingfunction kmb_ocs_hcu_fin_commonfunction kmb_ocs_hcu_finalfunction kmb_ocs_hcu_finupfunction kmb_ocs_hcu_digestfunction kmb_ocs_hcu_exportfunction kmb_ocs_hcu_importfunction kmb_ocs_hcu_setkeyfunction __cra_initfunction kmb_ocs_hcu_sha_cra_initfunction kmb_ocs_hcu_sm3_cra_initfunction kmb_ocs_hcu_hmac_sm3_cra_initfunction kmb_ocs_hcu_hmac_cra_initfunction kmb_ocs_hcu_hmac_cra_exitfunction kmb_ocs_hcu_removefunction kmb_ocs_hcu_probe
Annotated Snippet
struct ocs_hcu_ctx {
struct ocs_hcu_dev *hcu_dev;
u8 key[SHA512_BLOCK_SIZE];
size_t key_len;
bool is_sm3_tfm;
bool is_hmac_tfm;
};
/**
* struct ocs_hcu_rctx - Context for the request.
* @hcu_dev: OCS HCU device to be used to service the request.
* @flags: Flags tracking request status.
* @algo: Algorithm to use for the request.
* @blk_sz: Block size of the transformation / request.
* @dig_sz: Digest size of the transformation / request.
* @dma_list: OCS DMA linked list.
* @hash_ctx: OCS HCU hashing context.
* @buffer: Buffer to store: partial block of data and SW HMAC
* artifacts (ipad, opad, etc.).
* @buf_cnt: Number of bytes currently stored in the buffer.
* @buf_dma_addr: The DMA address of @buffer (when mapped).
* @buf_dma_count: The number of bytes in @buffer currently DMA-mapped.
* @sg: Head of the scatterlist entries containing data.
* @sg_data_total: Total data in the SG list at any time.
* @sg_data_offset: Offset into the data of the current individual SG node.
* @sg_dma_nents: Number of sg entries mapped in dma_list.
* @nents: Number of entries in the scatterlist.
*/
struct ocs_hcu_rctx {
struct ocs_hcu_dev *hcu_dev;
u32 flags;
enum ocs_hcu_algo algo;
size_t blk_sz;
size_t dig_sz;
struct ocs_hcu_dma_list *dma_list;
struct ocs_hcu_hash_ctx hash_ctx;
/*
* Buffer is double the block size because we need space for SW HMAC
* artifacts, i.e:
* - ipad (1 block) + a possible partial block of data.
* - opad (1 block) + digest of H(k ^ ipad || m)
*/
u8 buffer[2 * SHA512_BLOCK_SIZE];
size_t buf_cnt;
dma_addr_t buf_dma_addr;
size_t buf_dma_count;
struct scatterlist *sg;
unsigned int sg_data_total;
unsigned int sg_data_offset;
unsigned int sg_dma_nents;
unsigned int nents;
};
/**
* struct ocs_hcu_drv - Driver data
* @dev_list: The list of HCU devices.
* @lock: The lock protecting dev_list.
*/
struct ocs_hcu_drv {
struct list_head dev_list;
spinlock_t lock; /* Protects dev_list. */
};
static struct ocs_hcu_drv ocs_hcu = {
.dev_list = LIST_HEAD_INIT(ocs_hcu.dev_list),
.lock = __SPIN_LOCK_UNLOCKED(ocs_hcu.lock),
};
/*
* Return the total amount of data in the request; that is: the data in the
* request buffer + the data in the sg list.
*/
static inline unsigned int kmb_get_total_data(struct ocs_hcu_rctx *rctx)
{
return rctx->sg_data_total + rctx->buf_cnt;
}
/* Move remaining content of scatter-gather list to context buffer. */
static int flush_sg_to_ocs_buffer(struct ocs_hcu_rctx *rctx)
{
size_t count;
if (rctx->sg_data_total > (sizeof(rctx->buffer) - rctx->buf_cnt)) {
WARN(1, "%s: sg data does not fit in buffer\n", __func__);
return -EINVAL;
}
while (rctx->sg_data_total) {
if (!rctx->sg) {
WARN(1, "%s: unexpected NULL sg\n", __func__);
Annotation
- Immediate include surface: `crypto/engine.h`, `crypto/hmac.h`, `crypto/internal/hash.h`, `crypto/scatterwalk.h`, `crypto/sha2.h`, `crypto/sm3.h`, `linux/completion.h`, `linux/dma-mapping.h`.
- Detected declarations: `struct ocs_hcu_ctx`, `struct ocs_hcu_rctx`, `struct ocs_hcu_drv`, `function kmb_get_total_data`, `function flush_sg_to_ocs_buffer`, `function kmb_ocs_hcu_dma_cleanup`, `function kmb_ocs_dma_prepare`, `function remainder`, `function kmb_ocs_hcu_secure_cleanup`, `function kmb_ocs_hcu_handle_queue`.
- 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.