drivers/crypto/intel/qat/qat_common/qat_crypto.c
Source file repositories/reference/linux-study-clean/drivers/crypto/intel/qat/qat_common/qat_crypto.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/intel/qat/qat_common/qat_crypto.c- Extension
.c- Size
- 6894 bytes
- Lines
- 288
- 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.
- 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/module.hlinux/slab.hadf_accel_devices.hadf_common_drv.hadf_transport.hadf_cfg.hadf_cfg_strings.hadf_gen2_hw_data.hqat_crypto.hicp_qat_fw.h
Detected Declarations
function qat_crypto_put_instancefunction qat_crypto_free_instancesfunction list_for_each_entry_safefunction list_for_each_entryfunction list_for_each_entryfunction qat_crypto_vf_dev_configfunction qat_crypto_create_instancesfunction qat_crypto_initfunction qat_crypto_shutdownfunction qat_crypto_event_handlerfunction qat_crypto_registerfunction qat_crypto_unregister
Annotated Snippet
if (best > ctr) {
accel_dev = tmp_dev;
best = ctr;
}
}
}
if (!accel_dev) {
pr_debug_ratelimited("QAT: Could not find a device on node %d\n", node);
/* Get any started device */
list_for_each_entry(tmp_dev, adf_devmgr_get_head(), list) {
if (adf_dev_started(tmp_dev) &&
!list_empty(&tmp_dev->crypto_list)) {
accel_dev = tmp_dev;
break;
}
}
}
if (!accel_dev)
return NULL;
best = ~0;
list_for_each_entry(tmp_inst, &accel_dev->crypto_list, list) {
unsigned long ctr;
ctr = atomic_read(&tmp_inst->refctr);
if (best > ctr) {
inst = tmp_inst;
best = ctr;
}
}
if (inst) {
if (adf_dev_get(accel_dev)) {
dev_err(&GET_DEV(accel_dev), "Could not increment dev refctr\n");
return NULL;
}
atomic_inc(&inst->refctr);
}
return inst;
}
/**
* qat_crypto_vf_dev_config() - create dev config required to create
* crypto inst.
*
* @accel_dev: Pointer to acceleration device.
*
* Function creates device configuration required to create
* asym, sym or, crypto instances
*
* Return: 0 on success, error code otherwise.
*/
int qat_crypto_vf_dev_config(struct adf_accel_dev *accel_dev)
{
u16 ring_to_svc_map = GET_HW_DATA(accel_dev)->ring_to_svc_map;
if (ring_to_svc_map != ADF_GEN2_DEFAULT_RING_TO_SRV_MAP) {
dev_err(&GET_DEV(accel_dev),
"Unsupported ring/service mapping present on PF");
return -EFAULT;
}
return GET_HW_DATA(accel_dev)->dev_config(accel_dev);
}
static int qat_crypto_create_instances(struct adf_accel_dev *accel_dev)
{
unsigned long num_inst, num_msg_sym, num_msg_asym;
char key[ADF_CFG_MAX_KEY_LEN_IN_BYTES];
char val[ADF_CFG_MAX_VAL_LEN_IN_BYTES];
unsigned long sym_bank, asym_bank;
struct qat_crypto_instance *inst;
int msg_size;
int ret;
int i;
INIT_LIST_HEAD(&accel_dev->crypto_list);
ret = adf_cfg_get_param_value(accel_dev, SEC, ADF_NUM_CY, val);
if (ret)
return ret;
ret = kstrtoul(val, 0, &num_inst);
if (ret)
return ret;
for (i = 0; i < num_inst; i++) {
inst = kzalloc_node(sizeof(*inst), GFP_KERNEL,
dev_to_node(&GET_DEV(accel_dev)));
if (!inst) {
Annotation
- Immediate include surface: `linux/module.h`, `linux/slab.h`, `adf_accel_devices.h`, `adf_common_drv.h`, `adf_transport.h`, `adf_cfg.h`, `adf_cfg_strings.h`, `adf_gen2_hw_data.h`.
- Detected declarations: `function qat_crypto_put_instance`, `function qat_crypto_free_instances`, `function list_for_each_entry_safe`, `function list_for_each_entry`, `function list_for_each_entry`, `function qat_crypto_vf_dev_config`, `function qat_crypto_create_instances`, `function qat_crypto_init`, `function qat_crypto_shutdown`, `function qat_crypto_event_handler`.
- 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.
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.