drivers/net/ethernet/mellanox/mlx5/core/lib/hv_vhca.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/lib/hv_vhca.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/lib/hv_vhca.c- Extension
.c- Size
- 8534 bytes
- Lines
- 372
- Domain
- Driver Families
- Bucket
- drivers/net
- 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.
- 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/hyperv.hmlx5_core.hlib/hv.hlib/hv_vhca.h
Detected Declarations
struct mlx5_hv_vhcastruct mlx5_hv_vhca_workstruct mlx5_hv_vhca_data_blockstruct mlx5_hv_vhca_agentfunction mlx5_hv_vhca_destroyfunction mlx5_hv_vhca_invalidate_workfunction mlx5_hv_vhca_invalidatefunction mlx5_hv_vhca_agents_controlfunction mlx5_hv_vhca_capabilitiesfunction mlx5_hv_vhca_control_agent_invalidatefunction mlx5_hv_vhca_control_agent_createfunction mlx5_hv_vhca_control_agent_destroyfunction mlx5_hv_vhca_initfunction mlx5_hv_vhca_cleanupfunction mlx5_hv_vhca_agents_updatefunction mlx5_hv_vhca_agent_createfunction mlx5_hv_vhca_agent_destroyfunction mlx5_hv_vhca_data_block_preparefunction mlx5_hv_vhca_agent_seq_updatefunction mlx5_hv_vhca_agent_write
Annotated Snippet
struct mlx5_hv_vhca {
struct mlx5_core_dev *dev;
struct workqueue_struct *work_queue;
struct mlx5_hv_vhca_agent *agents[MLX5_HV_VHCA_AGENT_MAX];
struct mutex agents_lock; /* Protect agents array */
};
struct mlx5_hv_vhca_work {
struct work_struct invalidate_work;
struct mlx5_hv_vhca *hv_vhca;
u64 block_mask;
};
struct mlx5_hv_vhca_data_block {
u16 sequence;
u16 offset;
u8 reserved[4];
u64 data[15];
};
struct mlx5_hv_vhca_agent {
enum mlx5_hv_vhca_agent_type type;
struct mlx5_hv_vhca *hv_vhca;
void *priv;
u16 seq;
void (*control)(struct mlx5_hv_vhca_agent *agent,
struct mlx5_hv_vhca_control_block *block);
void (*invalidate)(struct mlx5_hv_vhca_agent *agent,
u64 block_mask);
void (*cleanup)(struct mlx5_hv_vhca_agent *agent);
};
struct mlx5_hv_vhca *mlx5_hv_vhca_create(struct mlx5_core_dev *dev)
{
struct mlx5_hv_vhca *hv_vhca;
hv_vhca = kzalloc_obj(*hv_vhca);
if (!hv_vhca)
return ERR_PTR(-ENOMEM);
hv_vhca->work_queue = create_singlethread_workqueue("mlx5_hv_vhca");
if (!hv_vhca->work_queue) {
kfree(hv_vhca);
return ERR_PTR(-ENOMEM);
}
hv_vhca->dev = dev;
mutex_init(&hv_vhca->agents_lock);
return hv_vhca;
}
void mlx5_hv_vhca_destroy(struct mlx5_hv_vhca *hv_vhca)
{
if (IS_ERR_OR_NULL(hv_vhca))
return;
destroy_workqueue(hv_vhca->work_queue);
kfree(hv_vhca);
}
static void mlx5_hv_vhca_invalidate_work(struct work_struct *work)
{
struct mlx5_hv_vhca_work *hwork;
struct mlx5_hv_vhca *hv_vhca;
int i;
hwork = container_of(work, struct mlx5_hv_vhca_work, invalidate_work);
hv_vhca = hwork->hv_vhca;
mutex_lock(&hv_vhca->agents_lock);
for (i = 0; i < MLX5_HV_VHCA_AGENT_MAX; i++) {
struct mlx5_hv_vhca_agent *agent = hv_vhca->agents[i];
if (!agent || !agent->invalidate)
continue;
if (!(BIT(agent->type) & hwork->block_mask))
continue;
agent->invalidate(agent, hwork->block_mask);
}
mutex_unlock(&hv_vhca->agents_lock);
kfree(hwork);
}
void mlx5_hv_vhca_invalidate(void *context, u64 block_mask)
{
struct mlx5_hv_vhca *hv_vhca = (struct mlx5_hv_vhca *)context;
Annotation
- Immediate include surface: `linux/hyperv.h`, `mlx5_core.h`, `lib/hv.h`, `lib/hv_vhca.h`.
- Detected declarations: `struct mlx5_hv_vhca`, `struct mlx5_hv_vhca_work`, `struct mlx5_hv_vhca_data_block`, `struct mlx5_hv_vhca_agent`, `function mlx5_hv_vhca_destroy`, `function mlx5_hv_vhca_invalidate_work`, `function mlx5_hv_vhca_invalidate`, `function mlx5_hv_vhca_agents_control`, `function mlx5_hv_vhca_capabilities`, `function mlx5_hv_vhca_control_agent_invalidate`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source 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.