drivers/crypto/intel/qat/qat_common/qat_comp_algs.c
Source file repositories/reference/linux-study-clean/drivers/crypto/intel/qat/qat_common/qat_comp_algs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/intel/qat/qat_common/qat_comp_algs.c- Extension
.c- Size
- 19317 bytes
- Lines
- 760
- 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/crypto.hcrypto/acompress.hcrypto/internal/acompress.hcrypto/scatterwalk.hlinux/dma-mapping.hlinux/workqueue.hlinux/zstd.hadf_accel_devices.hadf_common_drv.hadf_dc.hqat_bl.hqat_comp_req.hqat_compression.hqat_algs_send.hqat_comp_zstd_utils.h
Detected Declarations
struct qat_zstd_scratchstruct qat_compression_reqstruct qat_callback_paramsstruct qat_compression_ctxstruct qat_compression_reqenum directionfunction qat_zstd_free_scratchfunction qat_alg_send_dc_messagefunction qat_comp_generic_callbackfunction qat_comp_alg_callbackfunction qat_comp_alg_init_tfmfunction qat_comp_alg_deflate_init_tfmfunction qat_comp_alg_exit_tfmfunction qat_comp_alg_compress_decompressfunction qat_comp_alg_compressfunction qat_comp_alg_decompressfunction qat_comp_alg_zstd_decompressfunction qat_comp_lz4s_zstd_callbackfunction qat_comp_alg_lz4s_zstd_init_tfmfunction qat_comp_alg_zstd_init_tfmfunction qat_comp_alg_zstd_exit_tfmfunction qat_comp_alg_lz4s_zstd_compressfunction qat_comp_alg_sw_decompressfunction qat_comp_algs_register_deflatefunction qat_comp_algs_unregister_deflatefunction qat_comp_algs_register_lz4sfunction qat_comp_algs_unregister_lz4sfunction qat_comp_algs_register_zstdfunction qat_comp_algs_unregister_zstdfunction qat_comp_algs_registerfunction qat_comp_algs_unregister
Annotated Snippet
struct qat_zstd_scratch {
size_t cctx_buffer_size;
void *lz4s;
void *literals;
void *out_seqs;
void *workspace;
ZSTD_CCtx *ctx;
};
static void *qat_zstd_alloc_scratch(void)
{
struct qat_zstd_scratch *scratch;
ZSTD_parameters params;
size_t cctx_size;
ZSTD_CCtx *ctx;
size_t zret;
int ret;
ret = -ENOMEM;
scratch = kzalloc_obj(*scratch);
if (!scratch)
return ERR_PTR(ret);
scratch->lz4s = kvmalloc(QAT_ZSTD_SCRATCH_SIZE, GFP_KERNEL);
if (!scratch->lz4s)
goto error;
scratch->literals = kvmalloc(QAT_ZSTD_SCRATCH_SIZE, GFP_KERNEL);
if (!scratch->literals)
goto error;
scratch->out_seqs = kvcalloc(QAT_MAX_SEQUENCES, sizeof(ZSTD_Sequence),
GFP_KERNEL);
if (!scratch->out_seqs)
goto error;
params = zstd_get_params(zstd_max_clevel(), QAT_ZSTD_SCRATCH_SIZE);
cctx_size = zstd_cctx_workspace_bound(¶ms.cParams);
scratch->workspace = kvmalloc(cctx_size, GFP_KERNEL | __GFP_ZERO);
if (!scratch->workspace)
goto error;
ret = -EINVAL;
ctx = zstd_init_cctx(scratch->workspace, cctx_size);
if (!ctx)
goto error;
scratch->ctx = ctx;
scratch->cctx_buffer_size = cctx_size;
zret = zstd_cctx_set_param(ctx, ZSTD_c_blockDelimiters, ZSTD_sf_explicitBlockDelimiters);
if (zstd_is_error(zret))
goto error;
return scratch;
error:
kvfree(scratch->lz4s);
kvfree(scratch->literals);
kvfree(scratch->out_seqs);
kvfree(scratch->workspace);
kfree(scratch);
return ERR_PTR(ret);
}
static void qat_zstd_free_scratch(void *ctx)
{
struct qat_zstd_scratch *scratch = ctx;
if (!scratch)
return;
kvfree(scratch->lz4s);
kvfree(scratch->literals);
kvfree(scratch->out_seqs);
kvfree(scratch->workspace);
kfree(scratch);
}
static struct crypto_acomp_streams qat_zstd_streams = {
.alloc_ctx = qat_zstd_alloc_scratch,
.free_ctx = qat_zstd_free_scratch,
};
enum direction {
DECOMPRESSION = 0,
COMPRESSION = 1,
};
Annotation
- Immediate include surface: `linux/crypto.h`, `crypto/acompress.h`, `crypto/internal/acompress.h`, `crypto/scatterwalk.h`, `linux/dma-mapping.h`, `linux/workqueue.h`, `linux/zstd.h`, `adf_accel_devices.h`.
- Detected declarations: `struct qat_zstd_scratch`, `struct qat_compression_req`, `struct qat_callback_params`, `struct qat_compression_ctx`, `struct qat_compression_req`, `enum direction`, `function qat_zstd_free_scratch`, `function qat_alg_send_dc_message`, `function qat_comp_generic_callback`, `function qat_comp_alg_callback`.
- 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.