drivers/vfio/pci/mlx5/cmd.c
Source file repositories/reference/linux-study-clean/drivers/vfio/pci/mlx5/cmd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/vfio/pci/mlx5/cmd.c- Extension
.c- Size
- 50108 bytes
- Lines
- 1810
- Domain
- Driver Families
- Bucket
- drivers/vfio
- 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.
- 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
cmd.h
Detected Declarations
function mlx5vf_is_migratablefunction mlx5vf_cmd_suspend_vhcafunction mlx5vf_cmd_resume_vhcafunction mlx5vf_cmd_query_vhca_migration_statefunction set_tracker_change_eventfunction set_tracker_errorfunction mlx5fv_vf_eventfunction mlx5vf_cmd_close_migratablefunction mlx5vf_cmd_remove_migratablefunction mlx5vf_cmd_set_migratablefunction mlx5vf_cmd_get_vhca_idfunction create_mkeyfunction unregister_dma_pagesfunction register_dma_pagesfunction mlx5vf_dma_data_bufferfunction free_page_listfunction mlx5vf_free_data_bufferfunction mlx5vf_add_pagesfunction mlx5vf_alloc_data_bufferfunction mlx5vf_put_data_bufferfunction mlx5vf_get_data_bufferfunction mlx5vf_save_callback_completefunction mlx5vf_mig_file_cleanup_cbfunction add_buf_headerfunction mlx5vf_save_callbackfunction mlx5vf_cmd_save_vhca_statefunction mlx5vf_cmd_load_vhca_statefunction mlx5vf_cmd_alloc_pdfunction mlx5vf_cmd_dealloc_pdfunction mlx5fv_cmd_clean_migf_resourcesfunction mlx5vf_create_trackerfunction mlx5vf_cmd_destroy_trackerfunction mlx5vf_cmd_modify_trackerfunction mlx5vf_cmd_query_trackerfunction alloc_cq_frag_buffunction init_cq_frag_buffunction mlx5vf_destroy_cqfunction mlx5vf_cq_eventfunction mlx5vf_event_notifierfunction mlx5vf_cq_completefunction mlx5vf_create_cqfunction mlx5vf_create_rc_qpfunction mlx5vf_post_recvfunction mlx5vf_activate_qpfunction mlx5vf_destroy_qpfunction mlx5vf_free_qp_recv_resourcesfunction mlx5vf_alloc_qp_recv_resourcesfunction _mlx5vf_free_page_tracker_resources
Annotated Snippet
if (!(query_flags & MLX5VF_QUERY_FINAL)) {
*state_size = 0;
complete(&mvdev->saving_migf->save_comp);
return 0;
}
query_flags &= ~MLX5VF_QUERY_INC;
}
/* Block incremental query which is state-dependent */
if (mvdev->saving_migf->state == MLX5_MIGF_STATE_ERROR) {
complete(&mvdev->saving_migf->save_comp);
return -ENODEV;
}
}
MLX5_SET(query_vhca_migration_state_in, in, opcode,
MLX5_CMD_OP_QUERY_VHCA_MIGRATION_STATE);
MLX5_SET(query_vhca_migration_state_in, in, vhca_id, mvdev->vhca_id);
MLX5_SET(query_vhca_migration_state_in, in, op_mod, 0);
MLX5_SET(query_vhca_migration_state_in, in, incremental,
query_flags & MLX5VF_QUERY_INC);
MLX5_SET(query_vhca_migration_state_in, in, chunk, mvdev->chunk_mode);
ret = mlx5_cmd_exec_inout(mvdev->mdev, query_vhca_migration_state, in,
out);
if (inc)
complete(&mvdev->saving_migf->save_comp);
if (ret)
return ret;
*state_size = MLX5_GET(query_vhca_migration_state_out, out,
required_umem_size);
if (total_size)
*total_size = mvdev->chunk_mode ?
MLX5_GET64(query_vhca_migration_state_out, out,
remaining_total_size) : *state_size;
if (mig_state && mvdev->mig_state_cap)
*mig_state = MLX5_GET(query_vhca_migration_state_out, out,
migration_state);
return 0;
}
static void set_tracker_change_event(struct mlx5vf_pci_core_device *mvdev)
{
mvdev->tracker.object_changed = true;
complete(&mvdev->tracker_comp);
}
static void set_tracker_error(struct mlx5vf_pci_core_device *mvdev)
{
/* Mark the tracker under an error and wake it up if it's running */
mvdev->tracker.is_err = true;
complete(&mvdev->tracker_comp);
}
static int mlx5fv_vf_event(struct notifier_block *nb,
unsigned long event, void *data)
{
struct mlx5vf_pci_core_device *mvdev =
container_of(nb, struct mlx5vf_pci_core_device, nb);
switch (event) {
case MLX5_PF_NOTIFY_ENABLE_VF:
mutex_lock(&mvdev->state_mutex);
mvdev->mdev_detach = false;
mlx5vf_state_mutex_unlock(mvdev);
break;
case MLX5_PF_NOTIFY_DISABLE_VF:
mlx5vf_cmd_close_migratable(mvdev);
mutex_lock(&mvdev->state_mutex);
mvdev->mdev_detach = true;
mlx5vf_state_mutex_unlock(mvdev);
break;
default:
break;
}
return 0;
}
void mlx5vf_cmd_close_migratable(struct mlx5vf_pci_core_device *mvdev)
{
if (!mvdev->migrate_cap)
return;
/* Must be done outside the lock to let it progress */
set_tracker_error(mvdev);
mutex_lock(&mvdev->state_mutex);
Annotation
- Immediate include surface: `cmd.h`.
- Detected declarations: `function mlx5vf_is_migratable`, `function mlx5vf_cmd_suspend_vhca`, `function mlx5vf_cmd_resume_vhca`, `function mlx5vf_cmd_query_vhca_migration_state`, `function set_tracker_change_event`, `function set_tracker_error`, `function mlx5fv_vf_event`, `function mlx5vf_cmd_close_migratable`, `function mlx5vf_cmd_remove_migratable`, `function mlx5vf_cmd_set_migratable`.
- Atlas domain: Driver Families / drivers/vfio.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.