drivers/crypto/ccree/cc_hash.c
Source file repositories/reference/linux-study-clean/drivers/crypto/ccree/cc_hash.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/ccree/cc_hash.c- Extension
.c- Size
- 68195 bytes
- Lines
- 2314
- 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
linux/kernel.hlinux/module.hlinux/string.hcrypto/algapi.hcrypto/hash.hcrypto/md5.hcrypto/sm3.hcrypto/internal/hash.hcc_driver.hcc_request_mgr.hcc_buffer_mgr.hcc_hash.hcc_sram_mgr.h
Detected Declarations
struct cc_hash_handlestruct cc_hash_algstruct hash_key_req_ctxstruct cc_hash_ctxstruct cc_hash_templatefunction cc_set_endianityfunction cc_map_resultfunction cc_init_reqfunction cc_map_reqfunction cc_unmap_reqfunction cc_unmap_resultfunction cc_update_completefunction cc_digest_completefunction cc_hash_completefunction cc_fin_resultfunction cc_fin_hmacfunction cc_hash_digestfunction cc_restore_hashfunction cc_hash_updatefunction cc_do_finupfunction cc_hash_finupfunction cc_hash_finalfunction cc_hash_initfunction cc_hash_setkeyfunction cc_xcbc_setkeyfunction cc_cmac_setkeyfunction cc_free_ctxfunction cc_alloc_ctxfunction cc_get_hash_lenfunction cc_cra_initfunction cc_cra_exitfunction cc_mac_updatefunction cc_mac_finalfunction cc_mac_finupfunction cc_mac_digestfunction cc_hash_exportfunction cc_hash_importfunction cc_init_copy_sramfunction cc_init_hash_sramfunction cc_hash_allocfunction cc_hash_freefunction list_for_each_entry_safefunction cc_setup_xcbcfunction cc_setup_cmacfunction cc_set_descfunction cc_larval_digest_addrfunction cc_digest_len_addr
Annotated Snippet
struct cc_hash_handle {
u32 digest_len_sram_addr; /* const value in SRAM*/
u32 larval_digest_sram_addr; /* const value in SRAM */
struct list_head hash_list;
};
static const u32 cc_digest_len_init[] = {
0x00000040, 0x00000000, 0x00000000, 0x00000000 };
static const u32 cc_md5_init[] = {
SHA1_H3, SHA1_H2, SHA1_H1, SHA1_H0 };
static const u32 cc_sha1_init[] = {
SHA1_H4, SHA1_H3, SHA1_H2, SHA1_H1, SHA1_H0 };
static const u32 cc_sha224_init[] = {
SHA224_H7, SHA224_H6, SHA224_H5, SHA224_H4,
SHA224_H3, SHA224_H2, SHA224_H1, SHA224_H0 };
static const u32 cc_sha256_init[] = {
SHA256_H7, SHA256_H6, SHA256_H5, SHA256_H4,
SHA256_H3, SHA256_H2, SHA256_H1, SHA256_H0 };
static const u32 cc_digest_len_sha512_init[] = {
0x00000080, 0x00000000, 0x00000000, 0x00000000 };
/*
* Due to the way the HW works, every double word in the SHA384 and SHA512
* larval hashes must be stored in hi/lo order
*/
#define hilo(x) upper_32_bits(x), lower_32_bits(x)
static const u32 cc_sha384_init[] = {
hilo(SHA384_H7), hilo(SHA384_H6), hilo(SHA384_H5), hilo(SHA384_H4),
hilo(SHA384_H3), hilo(SHA384_H2), hilo(SHA384_H1), hilo(SHA384_H0) };
static const u32 cc_sha512_init[] = {
hilo(SHA512_H7), hilo(SHA512_H6), hilo(SHA512_H5), hilo(SHA512_H4),
hilo(SHA512_H3), hilo(SHA512_H2), hilo(SHA512_H1), hilo(SHA512_H0) };
static const u32 cc_sm3_init[] = {
SM3_IVH, SM3_IVG, SM3_IVF, SM3_IVE,
SM3_IVD, SM3_IVC, SM3_IVB, SM3_IVA };
static void cc_setup_xcbc(struct ahash_request *areq, struct cc_hw_desc desc[],
unsigned int *seq_size);
static void cc_setup_cmac(struct ahash_request *areq, struct cc_hw_desc desc[],
unsigned int *seq_size);
static const void *cc_larval_digest(struct device *dev, u32 mode);
struct cc_hash_alg {
struct list_head entry;
int hash_mode;
int hw_mode;
int inter_digestsize;
struct cc_drvdata *drvdata;
struct ahash_alg ahash_alg;
};
struct hash_key_req_ctx {
u32 keylen;
dma_addr_t key_dma_addr;
u8 *key;
};
/* hash per-session context */
struct cc_hash_ctx {
struct cc_drvdata *drvdata;
/* holds the origin digest; the digest after "setkey" if HMAC,*
* the initial digest if HASH.
*/
u8 digest_buff[CC_MAX_HASH_DIGEST_SIZE] ____cacheline_aligned;
u8 opad_tmp_keys_buff[CC_MAX_OPAD_KEYS_SIZE] ____cacheline_aligned;
dma_addr_t opad_tmp_keys_dma_addr ____cacheline_aligned;
dma_addr_t digest_buff_dma_addr;
/* use for hmac with key large then mode block size */
struct hash_key_req_ctx key_params;
int hash_mode;
int hw_mode;
int inter_digestsize;
unsigned int hash_len;
struct completion setkey_comp;
bool is_hmac;
};
static void cc_set_desc(struct ahash_req_ctx *areq_ctx, struct cc_hash_ctx *ctx,
unsigned int flow_mode, struct cc_hw_desc desc[],
bool is_not_last_data, unsigned int *seq_size);
static void cc_set_endianity(u32 mode, struct cc_hw_desc *desc)
{
if (mode == DRV_HASH_MD5 || mode == DRV_HASH_SHA384 ||
mode == DRV_HASH_SHA512) {
set_bytes_swap(desc, 1);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/string.h`, `crypto/algapi.h`, `crypto/hash.h`, `crypto/md5.h`, `crypto/sm3.h`, `crypto/internal/hash.h`.
- Detected declarations: `struct cc_hash_handle`, `struct cc_hash_alg`, `struct hash_key_req_ctx`, `struct cc_hash_ctx`, `struct cc_hash_template`, `function cc_set_endianity`, `function cc_map_result`, `function cc_init_req`, `function cc_map_req`, `function cc_unmap_req`.
- 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.