drivers/crypto/intel/qat/qat_common/adf_gen4_vf_mig.c
Source file repositories/reference/linux-study-clean/drivers/crypto/intel/qat/qat_common/adf_gen4_vf_mig.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/intel/qat/qat_common/adf_gen4_vf_mig.c- Extension
.c- Size
- 28596 bytes
- Lines
- 1012
- Domain
- Driver Families
- Bucket
- drivers/crypto
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/delay.hlinux/dev_printk.hlinux/kernel.hlinux/slab.hlinux/string.hlinux/types.hasm/errno.hadf_accel_devices.hadf_bank_state.hadf_common_drv.hadf_gen4_hw_data.hadf_gen4_pfvf.hadf_pfvf_utils.hadf_mstate_mgr.hadf_gen4_vf_mig.h
Detected Declarations
struct adf_vf_bank_infostruct mig_user_slafunction adf_gen4_vfmig_init_devicefunction adf_gen4_vfmig_cleanup_devicefunction adf_gen4_vfmig_reset_devicefunction adf_gen4_vfmig_open_devicefunction adf_gen4_vfmig_close_devicefunction adf_gen4_vfmig_suspend_devicefunction adf_gen4_vfmig_resume_devicefunction adf_mstate_sla_checkfunction adf_mstate_check_cap_sizefunction adf_mstate_compatver_checkfunction adf_mstate_capmask_comparefunction adf_mstate_capmask_supersetfunction adf_mstate_capmask_equalfunction adf_mstate_set_vregfunction adf_gen4_vfmig_get_slasfunction adf_gen4_vfmig_load_etr_regsfunction adf_gen4_vfmig_load_etr_bankfunction adf_gen4_vfmig_load_etrfunction adf_gen4_vfmig_load_miscfunction adf_gen4_vfmig_load_genericfunction adf_gen4_vfmig_load_configfunction adf_gen4_vfmig_save_etr_regsfunction adf_gen4_vfmig_save_etr_bankfunction adf_gen4_vfmig_save_etrfunction adf_gen4_vfmig_save_miscfunction adf_gen4_vfmig_save_genericfunction adf_gen4_vfmig_save_configfunction adf_gen4_vfmig_save_statefunction adf_gen4_vfmig_load_statefunction adf_gen4_vfmig_save_setupfunction adf_gen4_vfmig_load_setupfunction adf_gen4_init_vf_mig_opsexport adf_gen4_init_vf_mig_ops
Annotated Snippet
struct adf_vf_bank_info {
struct adf_accel_dev *accel_dev;
u32 vf_nr;
u32 bank_nr;
};
struct mig_user_sla {
enum adf_base_services srv;
u64 rp_mask;
u32 cir;
u32 pir;
};
static int adf_mstate_sla_check(struct adf_mstate_mgr *sub_mgr, u8 *src_buf,
u32 src_size, void *opaque)
{
struct adf_mstate_vreginfo _sinfo = { src_buf, src_size };
struct adf_mstate_vreginfo *sinfo = &_sinfo, *dinfo = opaque;
u32 src_sla_cnt = sinfo->size / sizeof(struct mig_user_sla);
u32 dst_sla_cnt = dinfo->size / sizeof(struct mig_user_sla);
struct mig_user_sla *src_slas = sinfo->addr;
struct mig_user_sla *dst_slas = dinfo->addr;
int i, j;
for (i = 0; i < src_sla_cnt; i++) {
for (j = 0; j < dst_sla_cnt; j++) {
if (src_slas[i].srv != dst_slas[j].srv ||
src_slas[i].rp_mask != dst_slas[j].rp_mask)
continue;
if (src_slas[i].cir > dst_slas[j].cir ||
src_slas[i].pir > dst_slas[j].pir) {
pr_err("QAT: DST VF rate limiting mismatch.\n");
return -EINVAL;
}
break;
}
if (j == dst_sla_cnt) {
pr_err("QAT: SRC VF rate limiting mismatch - SRC srv %d and rp_mask 0x%llx.\n",
src_slas[i].srv, src_slas[i].rp_mask);
return -EINVAL;
}
}
return 0;
}
static inline int adf_mstate_check_cap_size(u32 src_sz, u32 dst_sz, u32 max_sz)
{
if (src_sz > max_sz || dst_sz > max_sz)
return -EINVAL;
else
return 0;
}
static int adf_mstate_compatver_check(struct adf_mstate_mgr *sub_mgr,
u8 *src_buf, u32 src_sz, void *opaque)
{
struct adf_mstate_vreginfo *info = opaque;
u8 compat = 0;
u8 *pcompat;
if (src_sz != info->size) {
pr_debug("QAT: State mismatch (compat version size), current %u, expected %u\n",
src_sz, info->size);
return -EINVAL;
}
memcpy(info->addr, src_buf, info->size);
pcompat = info->addr;
if (*pcompat == 0) {
pr_warn("QAT: Unable to determine the version of VF\n");
return 0;
}
compat = adf_vf_compat_checker(*pcompat);
if (compat == ADF_PF2VF_VF_INCOMPATIBLE) {
pr_debug("QAT: SRC VF driver (ver=%u) is incompatible with DST PF driver (ver=%u)\n",
*pcompat, ADF_PFVF_COMPAT_THIS_VERSION);
return -EINVAL;
}
if (compat == ADF_PF2VF_VF_COMPAT_UNKNOWN)
pr_debug("QAT: SRC VF driver (ver=%u) is newer than DST PF driver (ver=%u)\n",
*pcompat, ADF_PFVF_COMPAT_THIS_VERSION);
return 0;
}
Annotation
- Immediate include surface: `linux/delay.h`, `linux/dev_printk.h`, `linux/kernel.h`, `linux/slab.h`, `linux/string.h`, `linux/types.h`, `asm/errno.h`, `adf_accel_devices.h`.
- Detected declarations: `struct adf_vf_bank_info`, `struct mig_user_sla`, `function adf_gen4_vfmig_init_device`, `function adf_gen4_vfmig_cleanup_device`, `function adf_gen4_vfmig_reset_device`, `function adf_gen4_vfmig_open_device`, `function adf_gen4_vfmig_close_device`, `function adf_gen4_vfmig_suspend_device`, `function adf_gen4_vfmig_resume_device`, `function adf_mstate_sla_check`.
- Atlas domain: Driver Families / drivers/crypto.
- Implementation status: integration 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.