drivers/crypto/intel/qat/qat_common/adf_sriov.c
Source file repositories/reference/linux-study-clean/drivers/crypto/intel/qat/qat_common/adf_sriov.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/intel/qat/qat_common/adf_sriov.c- Extension
.c- Size
- 8659 bytes
- Lines
- 340
- 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.
- 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/workqueue.hlinux/pci.hlinux/device.hadf_common_drv.hadf_cfg.hadf_pfvf_pf_msg.h
Detected Declarations
struct adf_pf2vf_respfunction adf_iov_send_respfunction adf_schedule_vf2pf_handlerfunction adf_flush_pf2vf_resp_wqfunction adf_enable_sriovfunction adf_add_sriov_configurationfunction adf_do_disable_sriovfunction adf_do_enable_sriovfunction adf_reenable_sriovfunction adf_disable_sriovfunction adf_sriov_configurefunction adf_init_pf_wqfunction adf_exit_pf_wqexport adf_disable_sriovexport adf_sriov_configure
Annotated Snippet
struct adf_pf2vf_resp {
struct work_struct pf2vf_resp_work;
struct adf_accel_vf_info *vf_info;
};
static void adf_iov_send_resp(struct work_struct *work)
{
struct adf_pf2vf_resp *pf2vf_resp =
container_of(work, struct adf_pf2vf_resp, pf2vf_resp_work);
struct adf_accel_vf_info *vf_info = pf2vf_resp->vf_info;
struct adf_accel_dev *accel_dev = vf_info->accel_dev;
u32 vf_nr = vf_info->vf_nr;
bool ret;
if (READ_ONCE(accel_dev->pf.vf2pf_disabled))
goto out;
mutex_lock(&vf_info->pfvf_mig_lock);
ret = adf_recv_and_handle_vf2pf_msg(accel_dev, vf_nr);
if (ret)
/* re-enable interrupt on PF from this VF */
adf_enable_vf2pf_interrupts(accel_dev, 1 << vf_nr);
mutex_unlock(&vf_info->pfvf_mig_lock);
out:
kfree(pf2vf_resp);
}
void adf_schedule_vf2pf_handler(struct adf_accel_vf_info *vf_info)
{
struct adf_accel_dev *accel_dev = vf_info->accel_dev;
struct adf_pf2vf_resp *pf2vf_resp;
if (READ_ONCE(accel_dev->pf.vf2pf_disabled))
return;
pf2vf_resp = kzalloc_obj(*pf2vf_resp, GFP_ATOMIC);
if (!pf2vf_resp)
return;
pf2vf_resp->vf_info = vf_info;
INIT_WORK(&pf2vf_resp->pf2vf_resp_work, adf_iov_send_resp);
queue_work(pf2vf_resp_wq, &pf2vf_resp->pf2vf_resp_work);
}
static void adf_flush_pf2vf_resp_wq(void)
{
if (pf2vf_resp_wq)
flush_workqueue(pf2vf_resp_wq);
}
static int adf_enable_sriov(struct adf_accel_dev *accel_dev)
{
struct pci_dev *pdev = accel_to_pci_dev(accel_dev);
int totalvfs = pci_sriov_get_totalvfs(pdev);
struct adf_hw_device_data *hw_data = accel_dev->hw_device;
struct adf_accel_vf_info *vf_info;
int i;
for (i = 0, vf_info = accel_dev->pf.vf_info; i < totalvfs;
i++, vf_info++) {
/* This ptr will be populated when VFs will be created */
vf_info->accel_dev = accel_dev;
vf_info->vf_nr = i;
mutex_init(&vf_info->pf2vf_lock);
mutex_init(&vf_info->pfvf_mig_lock);
ratelimit_state_init(&vf_info->vf2pf_ratelimit,
ADF_VF2PF_RATELIMIT_INTERVAL,
ADF_VF2PF_RATELIMIT_BURST);
}
/* Set Valid bits in AE Thread to PCIe Function Mapping */
if (hw_data->configure_iov_threads)
hw_data->configure_iov_threads(accel_dev, true);
/* Enable VF to PF interrupts for all VFs */
adf_enable_all_vf2pf_interrupts(accel_dev, totalvfs);
/* Do not enable SR-IOV if already enabled */
if (pci_num_vf(pdev))
return 0;
/*
* Due to the hardware design, when SR-IOV and the ring arbiter
* are enabled all the VFs supported in hardware must be enabled in
* order for all the hardware resources (i.e. bundles) to be usable.
* When SR-IOV is enabled, each of the VFs will own one bundle.
*/
return pci_enable_sriov(pdev, totalvfs);
Annotation
- Immediate include surface: `linux/workqueue.h`, `linux/pci.h`, `linux/device.h`, `adf_common_drv.h`, `adf_cfg.h`, `adf_pfvf_pf_msg.h`.
- Detected declarations: `struct adf_pf2vf_resp`, `function adf_iov_send_resp`, `function adf_schedule_vf2pf_handler`, `function adf_flush_pf2vf_resp_wq`, `function adf_enable_sriov`, `function adf_add_sriov_configuration`, `function adf_do_disable_sriov`, `function adf_do_enable_sriov`, `function adf_reenable_sriov`, `function adf_disable_sriov`.
- Atlas domain: Driver Families / drivers/crypto.
- Implementation status: integration 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.