drivers/crypto/ccree/cc_buffer_mgr.c
Source file repositories/reference/linux-study-clean/drivers/crypto/ccree/cc_buffer_mgr.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/ccree/cc_buffer_mgr.c- Extension
.c- Size
- 42506 bytes
- Lines
- 1398
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
crypto/internal/aead.hcrypto/authenc.hcrypto/scatterwalk.hlinux/dmapool.hlinux/dma-mapping.hcc_buffer_mgr.hcc_lli_defs.hcc_cipher.hcc_hash.hcc_aead.h
Detected Declarations
struct buffer_arrayfunction cc_copy_macfunction cc_get_sgl_nentsfunction cc_copy_sg_portionfunction cc_render_buff_to_mllifunction cc_render_sg_to_mllifunction cc_generate_mllifunction cc_add_sg_entryfunction cc_map_sgfunction cc_set_aead_conf_buffunction cc_set_hash_buffunction cc_unmap_cipher_requestfunction cc_map_cipher_requestfunction cc_unmap_aead_requestfunction cc_is_icv_fragfunction cc_aead_chain_ivfunction cc_aead_chain_assocfunction cc_prepare_aead_data_dllifunction cc_prepare_aead_data_mllifunction cc_aead_chain_datafunction cc_update_aead_mlli_nentsfunction cc_map_aead_requestfunction cc_map_hash_request_finalfunction cc_map_hash_request_updatefunction cc_unmap_hash_requestfunction cc_buffer_mgr_initfunction cc_buffer_mgr_fini
Annotated Snippet
struct buffer_array {
unsigned int num_of_buffers;
union buffer_array_entry entry[MAX_NUM_OF_BUFFERS_IN_MLLI];
unsigned int offset[MAX_NUM_OF_BUFFERS_IN_MLLI];
int nents[MAX_NUM_OF_BUFFERS_IN_MLLI];
int total_data_len[MAX_NUM_OF_BUFFERS_IN_MLLI];
bool is_last[MAX_NUM_OF_BUFFERS_IN_MLLI];
u32 *mlli_nents[MAX_NUM_OF_BUFFERS_IN_MLLI];
};
static inline char *cc_dma_buf_type(enum cc_req_dma_buf_type type)
{
switch (type) {
case CC_DMA_BUF_NULL:
return "BUF_NULL";
case CC_DMA_BUF_DLLI:
return "BUF_DLLI";
case CC_DMA_BUF_MLLI:
return "BUF_MLLI";
default:
return "BUF_INVALID";
}
}
/**
* cc_copy_mac() - Copy MAC to temporary location
*
* @dev: device object
* @req: aead request object
* @dir: [IN] copy from/to sgl
*/
static void cc_copy_mac(struct device *dev, struct aead_request *req,
enum cc_sg_cpy_direct dir)
{
struct aead_req_ctx *areq_ctx = aead_request_ctx_dma(req);
u32 skip = req->assoclen + req->cryptlen;
cc_copy_sg_portion(dev, areq_ctx->backup_mac, req->src,
(skip - areq_ctx->req_authsize), skip, dir);
}
/**
* cc_get_sgl_nents() - Get scatterlist number of entries.
*
* @dev: Device object
* @sg_list: SG list
* @nbytes: [IN] Total SGL data bytes.
* @lbytes: [OUT] Returns the amount of bytes at the last entry
*
* Return:
* Number of entries in the scatterlist
*/
static unsigned int cc_get_sgl_nents(struct device *dev,
struct scatterlist *sg_list,
unsigned int nbytes, u32 *lbytes)
{
unsigned int nents = 0;
*lbytes = 0;
while (nbytes && sg_list) {
nents++;
/* get the number of bytes in the last entry */
*lbytes = nbytes;
nbytes -= (sg_list->length > nbytes) ?
nbytes : sg_list->length;
sg_list = sg_next(sg_list);
}
dev_dbg(dev, "nents %d last bytes %d\n", nents, *lbytes);
return nents;
}
/**
* cc_copy_sg_portion() - Copy scatter list data,
* from to_skip to end, to dest and vice versa
*
* @dev: Device object
* @dest: Buffer to copy to/from
* @sg: SG list
* @to_skip: Number of bytes to skip before copying
* @end: Offset of last byte to copy
* @direct: Transfer direction (true == from SG list to buffer, false == from
* buffer to SG list)
*/
void cc_copy_sg_portion(struct device *dev, u8 *dest, struct scatterlist *sg,
u32 to_skip, u32 end, enum cc_sg_cpy_direct direct)
{
u32 nents;
Annotation
- Immediate include surface: `crypto/internal/aead.h`, `crypto/authenc.h`, `crypto/scatterwalk.h`, `linux/dmapool.h`, `linux/dma-mapping.h`, `cc_buffer_mgr.h`, `cc_lli_defs.h`, `cc_cipher.h`.
- Detected declarations: `struct buffer_array`, `function cc_copy_mac`, `function cc_get_sgl_nents`, `function cc_copy_sg_portion`, `function cc_render_buff_to_mlli`, `function cc_render_sg_to_mlli`, `function cc_generate_mlli`, `function cc_add_sg_entry`, `function cc_map_sg`, `function cc_set_aead_conf_buf`.
- 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.