drivers/crypto/ccp/ccp-dev-v5.c
Source file repositories/reference/linux-study-clean/drivers/crypto/ccp/ccp-dev-v5.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/ccp/ccp-dev-v5.c- Extension
.c- Size
- 30654 bytes
- Lines
- 1129
- 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
linux/kernel.hlinux/kthread.hlinux/dma-mapping.hlinux/interrupt.hlinux/compiler.hlinux/ccp.hccp-dev.h
Detected Declarations
function ccp_lsb_allocfunction ccp_lsb_freefunction low_addressfunction high_addressfunction ccp5_get_free_slotsfunction ccp5_do_cmdfunction ccp5_perform_aesfunction ccp5_perform_xts_aesfunction ccp5_perform_shafunction ccp5_perform_des3function ccp5_perform_rsafunction ccp5_perform_passthrufunction ccp5_perform_eccfunction ccp_find_lsb_regionsfunction ccp_find_and_assign_lsb_to_qfunction ccp_assign_lsbsfunction ccp5_disable_queue_interruptsfunction ccp5_enable_queue_interruptsfunction ccp5_irq_bhfunction ccp5_irq_handlerfunction ccp5_initfunction initializationfunction ccp5_destroyfunction ccp5_configfunction ccp5other_config
Annotated Snippet
if (start < LSB_SIZE) {
bitmap_set(cmd_q->lsbmap, start, count);
return start + cmd_q->lsb * LSB_SIZE;
}
}
/* No joy; try to get an entry from the shared blocks */
ccp = cmd_q->ccp;
for (;;) {
mutex_lock(&ccp->sb_mutex);
start = (u32)bitmap_find_next_zero_area(ccp->lsbmap,
MAX_LSB_CNT * LSB_SIZE,
0,
count, 0);
if (start <= MAX_LSB_CNT * LSB_SIZE) {
bitmap_set(ccp->lsbmap, start, count);
mutex_unlock(&ccp->sb_mutex);
return start;
}
ccp->sb_avail = 0;
mutex_unlock(&ccp->sb_mutex);
/* Wait for KSB entries to become available */
if (wait_event_interruptible(ccp->sb_queue, ccp->sb_avail))
return 0;
}
}
/* Free a number of LSB slots from the bitmap, starting at
* the indicated starting slot number.
*/
static void ccp_lsb_free(struct ccp_cmd_queue *cmd_q, unsigned int start,
unsigned int count)
{
if (!start)
return;
if (cmd_q->lsb == start) {
/* An entry from the private LSB */
bitmap_clear(cmd_q->lsbmap, start, count);
} else {
/* From the shared LSBs */
struct ccp_device *ccp = cmd_q->ccp;
mutex_lock(&ccp->sb_mutex);
bitmap_clear(ccp->lsbmap, start, count);
ccp->sb_avail = 1;
mutex_unlock(&ccp->sb_mutex);
wake_up_interruptible_all(&ccp->sb_queue);
}
}
/* CCP version 5: Union to define the function field (cmd_reg1/dword0) */
union ccp_function {
struct {
u16 size:7;
u16 encrypt:1;
u16 mode:5;
u16 type:2;
} aes;
struct {
u16 size:7;
u16 encrypt:1;
u16 rsvd:5;
u16 type:2;
} aes_xts;
struct {
u16 size:7;
u16 encrypt:1;
u16 mode:5;
u16 type:2;
} des3;
struct {
u16 rsvd1:10;
u16 type:4;
u16 rsvd2:1;
} sha;
struct {
u16 mode:3;
u16 size:12;
} rsa;
struct {
u16 byteswap:2;
u16 bitwise:3;
u16 reflect:2;
u16 rsvd:8;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/kthread.h`, `linux/dma-mapping.h`, `linux/interrupt.h`, `linux/compiler.h`, `linux/ccp.h`, `ccp-dev.h`.
- Detected declarations: `function ccp_lsb_alloc`, `function ccp_lsb_free`, `function low_address`, `function high_address`, `function ccp5_get_free_slots`, `function ccp5_do_cmd`, `function ccp5_perform_aes`, `function ccp5_perform_xts_aes`, `function ccp5_perform_sha`, `function ccp5_perform_des3`.
- 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.