drivers/crypto/intel/iaa/iaa_crypto_main.c
Source file repositories/reference/linux-study-clean/drivers/crypto/intel/iaa/iaa_crypto_main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/intel/iaa/iaa_crypto_main.c- Extension
.c- Size
- 48132 bytes
- Lines
- 1940
- Domain
- Driver Families
- Bucket
- drivers/crypto
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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 an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/init.hlinux/kernel.hlinux/module.hlinux/pci.hlinux/sysfs.hlinux/device.hlinux/iommu.huapi/linux/idxd.hlinux/highmem.hlinux/sched/smt.hcrypto/internal/acompress.hidxd.hiaa_crypto.hiaa_crypto_stats.h
Detected Declarations
function wq_table_addfunction wq_table_free_entryfunction wq_table_clear_entryfunction verify_compress_showfunction verify_compress_storefunction set_iaa_sync_modefunction sync_mode_showfunction sync_mode_storefunction find_empty_iaa_compression_modefunction free_iaa_compression_modefunction remove_iaa_compression_modefunction add_iaa_compression_modefunction get_iaa_device_compression_modefunction free_device_compression_modefunction init_device_compression_modefunction init_device_compression_modesfunction remove_device_compression_modesfunction iaa_has_wqfunction list_for_each_entryfunction init_iaa_devicefunction del_iaa_devicefunction add_iaa_wqfunction del_iaa_wqfunction list_for_each_entryfunction clear_wq_tablefunction free_iaa_devicefunction __free_iaa_wqfunction free_iaa_wqfunction iaa_wq_getfunction iaa_wq_putfunction free_wq_tablefunction alloc_wq_tablefunction save_iaa_wqfunction list_for_each_entryfunction remove_iaa_wqfunction list_for_each_entryfunction wq_table_add_wqsfunction list_for_each_entryfunction list_for_each_entryfunction rebalance_wq_tablefunction for_each_cpufunction check_completionfunction deflate_generic_decompressfunction iaa_desc_completefunction iaa_compressfunction iaa_remap_for_verifyfunction iaa_compress_verifyfunction iaa_decompress
Annotated Snippet
static ssize_t verify_compress_show(struct device_driver *driver, char *buf)
{
return sysfs_emit(buf, "%d\n", iaa_verify_compress);
}
static ssize_t verify_compress_store(struct device_driver *driver,
const char *buf, size_t count)
{
int ret = -EBUSY;
mutex_lock(&iaa_devices_lock);
if (iaa_crypto_enabled)
goto out;
ret = kstrtobool(buf, &iaa_verify_compress);
if (ret)
goto out;
ret = count;
out:
mutex_unlock(&iaa_devices_lock);
return ret;
}
static DRIVER_ATTR_RW(verify_compress);
/*
* The iaa crypto driver supports three 'sync' methods determining how
* compressions and decompressions are performed:
*
* - sync: the compression or decompression completes before
* returning. This is the mode used by the async crypto
* interface when the sync mode is set to 'sync' and by
* the sync crypto interface regardless of setting.
*
* - async: the compression or decompression is submitted and returns
* immediately. Completion interrupts are not used so
* the caller is responsible for polling the descriptor
* for completion. This mode is applicable to only the
* async crypto interface and is ignored for anything
* else.
*
* - async_irq: the compression or decompression is submitted and
* returns immediately. Completion interrupts are
* enabled so the caller can wait for the completion and
* yield to other threads. When the compression or
* decompression completes, the completion is signaled
* and the caller awakened. This mode is applicable to
* only the async crypto interface and is ignored for
* anything else.
*
* These modes can be set using the iaa_crypto sync_mode driver
* attribute.
*/
/* Use async mode */
static bool async_mode;
/* Use interrupts */
static bool use_irq;
/**
* set_iaa_sync_mode - Set IAA sync mode
* @name: The name of the sync mode
*
* Make the IAA sync mode named @name the current sync mode used by
* compression/decompression.
*/
static int set_iaa_sync_mode(const char *name)
{
int ret = 0;
if (sysfs_streq(name, "sync")) {
async_mode = false;
use_irq = false;
} else if (sysfs_streq(name, "async")) {
async_mode = false;
use_irq = false;
} else if (sysfs_streq(name, "async_irq")) {
async_mode = true;
use_irq = true;
} else {
ret = -EINVAL;
}
return ret;
}
static ssize_t sync_mode_show(struct device_driver *driver, char *buf)
Annotation
- Immediate include surface: `linux/init.h`, `linux/kernel.h`, `linux/module.h`, `linux/pci.h`, `linux/sysfs.h`, `linux/device.h`, `linux/iommu.h`, `uapi/linux/idxd.h`.
- Detected declarations: `function wq_table_add`, `function wq_table_free_entry`, `function wq_table_clear_entry`, `function verify_compress_show`, `function verify_compress_store`, `function set_iaa_sync_mode`, `function sync_mode_show`, `function sync_mode_store`, `function find_empty_iaa_compression_mode`, `function free_iaa_compression_mode`.
- Atlas domain: Driver Families / drivers/crypto.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.