drivers/crypto/caam/blob_gen.c
Source file repositories/reference/linux-study-clean/drivers/crypto/caam/blob_gen.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/caam/blob_gen.c- Extension
.c- Size
- 6880 bytes
- Lines
- 247
- Domain
- Driver Families
- Bucket
- drivers/crypto
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/bitfield.hlinux/device.hkeys/trusted-type.hsoc/fsl/caam-blob.hcompat.hdesc_constr.hdesc.herror.hintern.hjr.hregs.h
Detected Declarations
struct caam_blob_privstruct caam_blob_job_resultfunction caam_blob_job_donefunction check_caam_statefunction caam_process_blobfunction caam_blob_gen_exitexport caam_process_blobexport caam_blob_gen_initexport caam_blob_gen_exit
Annotated Snippet
struct caam_blob_priv {
struct device jrdev;
};
struct caam_blob_job_result {
int err;
struct completion completion;
};
static void caam_blob_job_done(struct device *dev, u32 *desc, u32 err, void *context)
{
struct caam_blob_job_result *res = context;
int ecode = 0;
dev_dbg(dev, "%s %d: err 0x%x\n", __func__, __LINE__, err);
if (err)
ecode = caam_jr_strstatus(dev, err);
res->err = ecode;
/*
* Upon completion, desc points to a buffer containing a CAAM job
* descriptor which encapsulates data into an externally-storable
* blob.
*/
complete(&res->completion);
}
static u32 check_caam_state(struct device *jrdev)
{
const struct caam_drv_private *ctrlpriv;
ctrlpriv = dev_get_drvdata(jrdev->parent);
return FIELD_GET(CSTA_MOO, rd_reg32(&ctrlpriv->jr[0]->perfmon.status));
}
int caam_process_blob(struct caam_blob_priv *priv,
struct caam_blob_info *info, bool encap)
{
struct caam_blob_job_result testres;
struct device *jrdev = &priv->jrdev;
dma_addr_t dma_in, dma_out;
int op = OP_PCLID_BLOB;
int hwbk_caam_ovhd = 0;
size_t output_len;
u32 *desc;
u32 moo;
int ret;
int len;
if (info->key_mod_len > CAAM_BLOB_KEYMOD_LENGTH)
return -EINVAL;
if (encap) {
op |= OP_TYPE_ENCAP_PROTOCOL;
output_len = info->input_len + CAAM_BLOB_OVERHEAD;
} else {
op |= OP_TYPE_DECAP_PROTOCOL;
output_len = info->input_len - CAAM_BLOB_OVERHEAD;
info->output_len = output_len;
}
if (encap && info->pkey_info.is_pkey) {
op |= OP_PCL_BLOB_BLACK;
if (info->pkey_info.key_enc_algo == CAAM_ENC_ALGO_CCM) {
op |= OP_PCL_BLOB_EKT;
hwbk_caam_ovhd = CAAM_CCM_OVERHEAD;
}
if ((info->input_len + hwbk_caam_ovhd) > MAX_KEY_SIZE)
return -EINVAL;
len = info->input_len + hwbk_caam_ovhd;
} else {
len = info->input_len;
}
desc = kzalloc(CAAM_BLOB_DESC_BYTES_MAX, GFP_KERNEL);
if (!desc)
return -ENOMEM;
dma_in = dma_map_single(jrdev, info->input, len,
encap ? DMA_BIDIRECTIONAL : DMA_TO_DEVICE);
if (dma_mapping_error(jrdev, dma_in)) {
dev_err(jrdev, "unable to map input DMA buffer\n");
ret = -ENOMEM;
goto out_free;
}
dma_out = dma_map_single(jrdev, info->output, output_len,
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/device.h`, `keys/trusted-type.h`, `soc/fsl/caam-blob.h`, `compat.h`, `desc_constr.h`, `desc.h`, `error.h`.
- Detected declarations: `struct caam_blob_priv`, `struct caam_blob_job_result`, `function caam_blob_job_done`, `function check_caam_state`, `function caam_process_blob`, `function caam_blob_gen_exit`, `export caam_process_blob`, `export caam_blob_gen_init`, `export caam_blob_gen_exit`.
- Atlas domain: Driver Families / drivers/crypto.
- Implementation status: integration 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.