drivers/crypto/bcm/spu2.c
Source file repositories/reference/linux-study-clean/drivers/crypto/bcm/spu2.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/bcm/spu2.c- Extension
.c- Size
- 39945 bytes
- Lines
- 1386
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/string.hlinux/string_choices.hutil.hspu.hspu2.h
Detected Declarations
enum spu2_proto_selfunction spu2_cipher_mode_xlatefunction spu2_cipher_xlatefunction spu2_hash_mode_xlatefunction spu2_hash_xlatefunction spu2_dump_fmd_ctrl0function spu2_dump_fmd_ctrl1function spu2_dump_fmd_ctrl2function spu2_dump_fmd_ctrl3function spu2_dump_fmdfunction spu2_dump_omdfunction spu2_dump_msg_hdrfunction spu2_fmd_initfunction spu2_fmd_ctrl0_writefunction spu2_fmd_ctrl1_writefunction spu2_fmd_ctrl2_writefunction spu2_fmd_ctrl3_writefunction spu2_ctx_max_payloadfunction spu2_payload_lengthfunction spu2_response_hdr_lenfunction spu2_hash_pad_lenfunction spu2_gcm_ccm_pad_lenfunction spu2_assoc_resp_lenfunction spu2_aead_ivlenfunction spu2_hash_typefunction spu2_digest_sizefunction spu2_create_requestfunction spu2_cipher_req_initfunction spu2_cipher_req_finishfunction spu2_request_padfunction spu2_xts_tweak_in_payloadfunction spu2_tx_status_lenfunction spu2_rx_status_lenfunction spu2_status_processfunction spu2_ccm_update_ivfunction spu2_wordalign_padlen
Annotated Snippet
switch (cipher_type) {
case CIPHER_TYPE_AES128:
*spu2_type = SPU2_CIPHER_TYPE_AES128;
break;
case CIPHER_TYPE_AES192:
*spu2_type = SPU2_CIPHER_TYPE_AES192;
break;
case CIPHER_TYPE_AES256:
*spu2_type = SPU2_CIPHER_TYPE_AES256;
break;
default:
err = -EINVAL;
}
break;
case CIPHER_ALG_LAST:
default:
err = -EINVAL;
break;
}
if (err)
flow_log("Invalid cipher alg %d or type %d\n",
cipher_alg, cipher_type);
return err;
}
/*
* Convert from a software hash mode value to the corresponding value
* for SPU2. Note that HASH_MODE_NONE and HASH_MODE_XCBC have the same value.
*/
static int spu2_hash_mode_xlate(enum hash_mode hash_mode,
enum spu2_hash_mode *spu2_mode)
{
switch (hash_mode) {
case HASH_MODE_XCBC:
*spu2_mode = SPU2_HASH_MODE_XCBC_MAC;
break;
case HASH_MODE_CMAC:
*spu2_mode = SPU2_HASH_MODE_CMAC;
break;
case HASH_MODE_HMAC:
*spu2_mode = SPU2_HASH_MODE_HMAC;
break;
case HASH_MODE_CCM:
*spu2_mode = SPU2_HASH_MODE_CCM;
break;
case HASH_MODE_GCM:
*spu2_mode = SPU2_HASH_MODE_GCM;
break;
default:
return -EINVAL;
}
return 0;
}
/**
* spu2_hash_xlate() - Convert a hash {alg/mode/type} triple to a SPU2 hash type
* and mode.
* @hash_alg: [in] hash algorithm value from software enumeration
* @hash_mode: [in] hash mode value from software enumeration
* @hash_type: [in] hash type value from software enumeration
* @ciph_type: [in] cipher type value from software enumeration
* @spu2_type: [out] hash type value used by SPU2 hardware
* @spu2_mode: [out] hash mode value used by SPU2 hardware
*
* Return: 0 if successful
*/
static int
spu2_hash_xlate(enum hash_alg hash_alg, enum hash_mode hash_mode,
enum hash_type hash_type, enum spu_cipher_type ciph_type,
enum spu2_hash_type *spu2_type, enum spu2_hash_mode *spu2_mode)
{
int err;
err = spu2_hash_mode_xlate(hash_mode, spu2_mode);
if (err) {
flow_log("Invalid hash mode %d\n", hash_mode);
return err;
}
switch (hash_alg) {
case HASH_ALG_NONE:
*spu2_type = SPU2_HASH_TYPE_NONE;
break;
case HASH_ALG_MD5:
*spu2_type = SPU2_HASH_TYPE_MD5;
break;
case HASH_ALG_SHA1:
*spu2_type = SPU2_HASH_TYPE_SHA1;
break;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/string.h`, `linux/string_choices.h`, `util.h`, `spu.h`, `spu2.h`.
- Detected declarations: `enum spu2_proto_sel`, `function spu2_cipher_mode_xlate`, `function spu2_cipher_xlate`, `function spu2_hash_mode_xlate`, `function spu2_hash_xlate`, `function spu2_dump_fmd_ctrl0`, `function spu2_dump_fmd_ctrl1`, `function spu2_dump_fmd_ctrl2`, `function spu2_dump_fmd_ctrl3`, `function spu2_dump_fmd`.
- Atlas domain: Driver Families / drivers/crypto.
- Implementation status: source implementation candidate.
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.