drivers/crypto/hisilicon/zip/zip_crypto.c
Source file repositories/reference/linux-study-clean/drivers/crypto/hisilicon/zip/zip_crypto.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/hisilicon/zip/zip_crypto.c- Extension
.c- Size
- 17848 bytes
- Lines
- 728
- 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
crypto/internal/acompress.hlinux/bitfield.hlinux/bitmap.hlinux/dma-mapping.hlinux/scatterlist.hzip.h
Detected Declarations
struct hisi_zip_reqstruct hisi_zip_req_qstruct hisi_zip_qp_ctxstruct hisi_zip_sqe_opsstruct hisi_zip_ctxenum hisi_zip_alg_typefunction sgl_sge_nr_setfunction hisi_zip_fallback_do_workfunction hisi_zip_remove_reqfunction hisi_zip_fill_addrfunction hisi_zip_fill_buf_sizefunction hisi_zip_fill_buf_typefunction hisi_zip_fill_req_typefunction hisi_zip_fill_win_sizefunction hisi_zip_fill_tagfunction hisi_zip_fill_sqe_typefunction hisi_zip_fill_sqefunction hisi_zip_do_workfunction hisi_zip_get_statusfunction hisi_zip_get_dstlenfunction hisi_zip_acomp_cbfunction hisi_zip_acompressfunction hisi_zip_adecompressfunction hisi_zip_decompressfunction hisi_zip_ctx_initfunction hisi_zip_ctx_exitfunction hisi_zip_create_req_qfunction hisi_zip_release_req_qfunction hisi_zip_create_sgl_poolfunction hisi_zip_release_sgl_poolfunction hisi_zip_set_acomp_cbfunction hisi_zip_acomp_initfunction hisi_zip_acomp_exitfunction hisi_zip_register_deflatefunction hisi_zip_unregister_deflatefunction hisi_zip_register_lz4function hisi_zip_unregister_lz4function hisi_zip_register_to_cryptofunction hisi_zip_unregister_from_crypto
Annotated Snippet
struct hisi_zip_req {
struct acomp_req *req;
struct hisi_acc_hw_sgl *hw_src;
struct hisi_acc_hw_sgl *hw_dst;
dma_addr_t dma_src;
dma_addr_t dma_dst;
struct hisi_zip_qp_ctx *qp_ctx;
u16 req_id;
};
struct hisi_zip_req_q {
struct hisi_zip_req *q;
unsigned long *req_bitmap;
spinlock_t req_lock;
u16 size;
};
struct hisi_zip_qp_ctx {
struct hisi_qp *qp;
struct hisi_zip_req_q req_q;
struct hisi_acc_sgl_pool *sgl_pool;
struct hisi_zip *zip_dev;
struct hisi_zip_ctx *ctx;
u8 req_type;
};
struct hisi_zip_sqe_ops {
u8 sqe_type;
void (*fill_addr)(struct hisi_zip_sqe *sqe, struct hisi_zip_req *req);
void (*fill_buf_size)(struct hisi_zip_sqe *sqe, struct hisi_zip_req *req);
void (*fill_buf_type)(struct hisi_zip_sqe *sqe, u8 buf_type);
void (*fill_req_type)(struct hisi_zip_sqe *sqe, u8 req_type);
void (*fill_win_size)(struct hisi_zip_sqe *sqe, u8 win_size);
void (*fill_tag)(struct hisi_zip_sqe *sqe, struct hisi_zip_req *req);
void (*fill_sqe_type)(struct hisi_zip_sqe *sqe, u8 sqe_type);
u32 (*get_status)(struct hisi_zip_sqe *sqe);
u32 (*get_dstlen)(struct hisi_zip_sqe *sqe);
};
struct hisi_zip_ctx {
struct hisi_zip_qp_ctx qp_ctx[HZIP_CTX_Q_NUM];
const struct hisi_zip_sqe_ops *ops;
bool fallback;
};
static int sgl_sge_nr_set(const char *val, const struct kernel_param *kp)
{
int ret;
u16 n;
if (!val)
return -EINVAL;
ret = kstrtou16(val, 10, &n);
if (ret || n == 0 || n > HISI_ACC_SGL_SGE_NR_MAX)
return -EINVAL;
return param_set_ushort(val, kp);
}
static const struct kernel_param_ops sgl_sge_nr_ops = {
.set = sgl_sge_nr_set,
.get = param_get_ushort,
};
static u16 sgl_sge_nr = HZIP_SGL_SGE_NR;
module_param_cb(sgl_sge_nr, &sgl_sge_nr_ops, &sgl_sge_nr, 0444);
MODULE_PARM_DESC(sgl_sge_nr, "Number of sge in sgl(1-255)");
static int hisi_zip_fallback_do_work(struct acomp_req *acomp_req, bool is_decompress)
{
ACOMP_FBREQ_ON_STACK(fbreq, acomp_req);
int ret;
if (!is_decompress)
ret = crypto_acomp_compress(fbreq);
else
ret = crypto_acomp_decompress(fbreq);
if (ret) {
pr_err("failed to do fallback work, ret=%d\n", ret);
return ret;
}
acomp_req->dlen = fbreq->dlen;
return ret;
}
static struct hisi_zip_req *hisi_zip_create_req(struct hisi_zip_qp_ctx *qp_ctx,
struct acomp_req *req)
{
Annotation
- Immediate include surface: `crypto/internal/acompress.h`, `linux/bitfield.h`, `linux/bitmap.h`, `linux/dma-mapping.h`, `linux/scatterlist.h`, `zip.h`.
- Detected declarations: `struct hisi_zip_req`, `struct hisi_zip_req_q`, `struct hisi_zip_qp_ctx`, `struct hisi_zip_sqe_ops`, `struct hisi_zip_ctx`, `enum hisi_zip_alg_type`, `function sgl_sge_nr_set`, `function hisi_zip_fallback_do_work`, `function hisi_zip_remove_req`, `function hisi_zip_fill_addr`.
- 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.