drivers/crypto/intel/qat/qat_common/qat_bl.c
Source file repositories/reference/linux-study-clean/drivers/crypto/intel/qat/qat_common/qat_bl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/intel/qat/qat_common/qat_bl.c- Extension
.c- Size
- 6329 bytes
- Lines
- 254
- 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.
- 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/device.hlinux/dma-mapping.hlinux/pci.hlinux/scatterlist.hlinux/slab.hlinux/types.hadf_accel_devices.hqat_bl.hqat_crypto.h
Detected Declarations
function qat_bl_free_buflfunction __qat_bl_sgl_to_buflfunction for_each_sgfunction for_each_sgfunction qat_bl_sgl_to_bufl
Annotated Snippet
if (left >= sg->length) {
left -= sg->length;
continue;
}
bufl->buffers[y].addr = dma_map_single(dev, sg_virt(sg) + left,
sg->length - left,
bufl_dma_dir);
bufl->buffers[y].len = sg->length;
if (unlikely(dma_mapping_error(dev, bufl->buffers[y].addr)))
goto err_in;
sg_nctr++;
if (left) {
bufl->buffers[y].len -= left;
left = 0;
}
}
bufl->num_bufs = sg_nctr;
blp = dma_map_single(dev, bufl, sz, DMA_TO_DEVICE);
if (unlikely(dma_mapping_error(dev, blp)))
goto err_in;
buf->bl = bufl;
buf->blp = blp;
buf->sz = sz;
/* Handle out of place operation */
if (sgl != sglout) {
struct qat_alg_buf *buffers;
int extra_buff = extra_dst_buff ? 1 : 0;
int n_sglout = sg_nents(sglout);
n = n_sglout + extra_buff;
sz_out = struct_size(buflout, buffers, n);
left = dskip;
sg_nctr = 0;
if (n > QAT_MAX_BUFF_DESC) {
buflout = kzalloc_node(sz_out, flags, node);
if (unlikely(!buflout))
goto err_in;
} else {
buflout = container_of(&buf->sgl_dst.sgl_hdr,
struct qat_alg_buf_list, hdr);
memset(buflout, 0, sizeof(struct qat_alg_buf_list));
buf->sgl_dst_valid = true;
}
buffers = buflout->buffers;
for (i = 0; i < n; i++)
buffers[i].addr = DMA_MAPPING_ERROR;
for_each_sg(sglout, sg, n_sglout, i) {
int y = sg_nctr;
if (!sg->length)
continue;
if (left >= sg->length) {
left -= sg->length;
continue;
}
buffers[y].addr = dma_map_single(dev, sg_virt(sg) + left,
sg->length - left,
DMA_BIDIRECTIONAL);
if (unlikely(dma_mapping_error(dev, buffers[y].addr)))
goto err_out;
buffers[y].len = sg->length;
sg_nctr++;
if (left) {
buffers[y].len -= left;
left = 0;
}
}
if (extra_buff) {
buffers[sg_nctr].addr = extra_dst_buff;
buffers[sg_nctr].len = sz_extra_dst_buff;
}
buflout->num_bufs = sg_nctr;
buflout->num_bufs += extra_buff;
buflout->num_mapped_bufs = sg_nctr;
bloutp = dma_map_single(dev, buflout, sz_out, DMA_TO_DEVICE);
if (unlikely(dma_mapping_error(dev, bloutp)))
goto err_out;
buf->blout = buflout;
buf->bloutp = bloutp;
buf->sz_out = sz_out;
} else {
/* Otherwise set the src and dst to the same address */
buf->bloutp = buf->blp;
buf->sz_out = 0;
Annotation
- Immediate include surface: `linux/device.h`, `linux/dma-mapping.h`, `linux/pci.h`, `linux/scatterlist.h`, `linux/slab.h`, `linux/types.h`, `adf_accel_devices.h`, `qat_bl.h`.
- Detected declarations: `function qat_bl_free_bufl`, `function __qat_bl_sgl_to_bufl`, `function for_each_sg`, `function for_each_sg`, `function qat_bl_sgl_to_bufl`.
- Atlas domain: Driver Families / drivers/crypto.
- Implementation status: source 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.