drivers/crypto/intel/qat/qat_common/adf_mstate_mgr.c
Source file repositories/reference/linux-study-clean/drivers/crypto/intel/qat/qat_common/adf_mstate_mgr.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/intel/qat/qat_common/adf_mstate_mgr.c- Extension
.c- Size
- 7907 bytes
- Lines
- 319
- 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.
- 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/slab.hlinux/types.hadf_mstate_mgr.h
Detected Declarations
struct adf_mstate_sect_hfunction adf_mstate_state_sizefunction adf_mstate_avail_roomfunction adf_mstate_mgr_initfunction adf_mstate_mgr_destroyfunction adf_mstate_mgr_init_from_parentfunction adf_mstate_mgr_init_from_psectfunction adf_mstate_preamble_initfunction adf_mstate_preamble_def_checkerfunction adf_mstate_preamble_updatefunction adf_mstate_dump_sectfunction __adf_mstate_sect_updatefunction adf_mstate_sect_updatefunction adf_mstate_sect_validatefunction adf_mstate_state_size_from_remotefunction adf_mstate_mgr_init_from_remote
Annotated Snippet
struct adf_mstate_sect_h {
u8 id[ADF_MSTATE_ID_LEN];
u32 size;
u32 sub_sects;
u8 state[];
};
u32 adf_mstate_state_size(struct adf_mstate_mgr *mgr)
{
return mgr->state - mgr->buf;
}
static inline u32 adf_mstate_avail_room(struct adf_mstate_mgr *mgr)
{
return mgr->buf + mgr->size - mgr->state;
}
void adf_mstate_mgr_init(struct adf_mstate_mgr *mgr, u8 *buf, u32 size)
{
mgr->buf = buf;
mgr->state = buf;
mgr->size = size;
mgr->n_sects = 0;
};
struct adf_mstate_mgr *adf_mstate_mgr_new(u8 *buf, u32 size)
{
struct adf_mstate_mgr *mgr;
mgr = kzalloc_obj(*mgr);
if (!mgr)
return NULL;
adf_mstate_mgr_init(mgr, buf, size);
return mgr;
}
void adf_mstate_mgr_destroy(struct adf_mstate_mgr *mgr)
{
kfree(mgr);
}
void adf_mstate_mgr_init_from_parent(struct adf_mstate_mgr *mgr,
struct adf_mstate_mgr *p_mgr)
{
adf_mstate_mgr_init(mgr, p_mgr->state,
p_mgr->size - adf_mstate_state_size(p_mgr));
}
void adf_mstate_mgr_init_from_psect(struct adf_mstate_mgr *mgr,
struct adf_mstate_sect_h *p_sect)
{
adf_mstate_mgr_init(mgr, p_sect->state, p_sect->size);
mgr->n_sects = p_sect->sub_sects;
}
static void adf_mstate_preamble_init(struct adf_mstate_preh *preamble)
{
preamble->magic = ADF_MSTATE_MAGIC;
preamble->version = ADF_MSTATE_VERSION;
preamble->preh_len = sizeof(*preamble);
preamble->size = 0;
preamble->n_sects = 0;
}
/* default preambles checker */
static int adf_mstate_preamble_def_checker(struct adf_mstate_preh *preamble,
void *opaque)
{
struct adf_mstate_mgr *mgr = opaque;
if (preamble->magic != ADF_MSTATE_MAGIC ||
preamble->version > ADF_MSTATE_VERSION ||
preamble->preh_len > mgr->size) {
pr_debug("QAT: LM - Invalid state (magic=%#x, version=%#x, hlen=%u), state_size=%u\n",
preamble->magic, preamble->version, preamble->preh_len,
mgr->size);
return -EINVAL;
}
return 0;
}
struct adf_mstate_preh *adf_mstate_preamble_add(struct adf_mstate_mgr *mgr)
{
struct adf_mstate_preh *pre = (struct adf_mstate_preh *)mgr->buf;
if (adf_mstate_avail_room(mgr) < sizeof(*pre)) {
pr_err("QAT: LM - Not enough space for preamble\n");
Annotation
- Immediate include surface: `linux/slab.h`, `linux/types.h`, `adf_mstate_mgr.h`.
- Detected declarations: `struct adf_mstate_sect_h`, `function adf_mstate_state_size`, `function adf_mstate_avail_room`, `function adf_mstate_mgr_init`, `function adf_mstate_mgr_destroy`, `function adf_mstate_mgr_init_from_parent`, `function adf_mstate_mgr_init_from_psect`, `function adf_mstate_preamble_init`, `function adf_mstate_preamble_def_checker`, `function adf_mstate_preamble_update`.
- Atlas domain: Driver Families / drivers/crypto.
- Implementation status: source implementation candidate.
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.