drivers/net/ethernet/mellanox/mlx5/core/sf/vhca_event.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/sf/vhca_event.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/sf/vhca_event.c- Extension
.c- Size
- 6833 bytes
- Lines
- 236
- 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.
- 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/mlx5/driver.hmlx5_ifc_vhca_event.hmlx5_core.hvhca_event.hecpf.hdiag/vhca_tracepoint.h
Detected Declarations
struct mlx5_vhca_event_workstruct mlx5_vhca_event_handlerstruct mlx5_vhca_eventsfunction mlx5_cmd_query_vhca_statefunction mlx5_cmd_modify_vhca_statefunction mlx5_modify_vhca_sw_idfunction mlx5_vhca_event_armfunction mlx5_vhca_event_notifyfunction mlx5_vhca_state_work_handlerfunction mlx5_vhca_events_work_enqueuefunction mlx5_vhca_state_change_notifierfunction mlx5_vhca_state_cap_handlefunction mlx5_vhca_state_notifier_initfunction mlx5_vhca_event_initfunction mlx5_vhca_event_work_queues_flushfunction mlx5_vhca_event_cleanupfunction mlx5_vhca_event_startfunction mlx5_vhca_event_stopfunction mlx5_vhca_event_notifier_registerfunction mlx5_vhca_event_notifier_unregister
Annotated Snippet
struct mlx5_vhca_event_work {
struct work_struct work;
struct mlx5_core_dev *dev;
struct mlx5_vhca_state_event event;
};
struct mlx5_vhca_event_handler {
struct workqueue_struct *wq;
};
struct mlx5_vhca_events {
struct mlx5_core_dev *dev;
struct mlx5_vhca_event_handler handler[MLX5_DEV_MAX_WQS];
};
int mlx5_cmd_query_vhca_state(struct mlx5_core_dev *dev, u16 function_id, u32 *out, u32 outlen)
{
u32 in[MLX5_ST_SZ_DW(query_vhca_state_in)] = {};
MLX5_SET(query_vhca_state_in, in, opcode, MLX5_CMD_OP_QUERY_VHCA_STATE);
MLX5_SET(query_vhca_state_in, in, function_id, function_id);
MLX5_SET(query_vhca_state_in, in, embedded_cpu_function, 0);
return mlx5_cmd_exec(dev, in, sizeof(in), out, outlen);
}
static int mlx5_cmd_modify_vhca_state(struct mlx5_core_dev *dev, u16 function_id,
u32 *in, u32 inlen)
{
u32 out[MLX5_ST_SZ_DW(modify_vhca_state_out)] = {};
MLX5_SET(modify_vhca_state_in, in, opcode, MLX5_CMD_OP_MODIFY_VHCA_STATE);
MLX5_SET(modify_vhca_state_in, in, function_id, function_id);
MLX5_SET(modify_vhca_state_in, in, embedded_cpu_function, 0);
return mlx5_cmd_exec(dev, in, inlen, out, sizeof(out));
}
int mlx5_modify_vhca_sw_id(struct mlx5_core_dev *dev, u16 function_id, u32 sw_fn_id)
{
u32 out[MLX5_ST_SZ_DW(modify_vhca_state_out)] = {};
u32 in[MLX5_ST_SZ_DW(modify_vhca_state_in)] = {};
MLX5_SET(modify_vhca_state_in, in, opcode, MLX5_CMD_OP_MODIFY_VHCA_STATE);
MLX5_SET(modify_vhca_state_in, in, function_id, function_id);
MLX5_SET(modify_vhca_state_in, in, embedded_cpu_function, 0);
MLX5_SET(modify_vhca_state_in, in, vhca_state_field_select.sw_function_id, 1);
MLX5_SET(modify_vhca_state_in, in, vhca_state_context.sw_function_id, sw_fn_id);
return mlx5_cmd_exec_inout(dev, modify_vhca_state, in, out);
}
int mlx5_vhca_event_arm(struct mlx5_core_dev *dev, u16 function_id)
{
u32 in[MLX5_ST_SZ_DW(modify_vhca_state_in)] = {};
MLX5_SET(modify_vhca_state_in, in, vhca_state_context.arm_change_event, 1);
MLX5_SET(modify_vhca_state_in, in, vhca_state_field_select.arm_change_event, 1);
return mlx5_cmd_modify_vhca_state(dev, function_id, in, sizeof(in));
}
static void
mlx5_vhca_event_notify(struct mlx5_core_dev *dev, struct mlx5_vhca_state_event *event)
{
u32 out[MLX5_ST_SZ_DW(query_vhca_state_out)] = {};
int err;
err = mlx5_cmd_query_vhca_state(dev, event->function_id, out, sizeof(out));
if (err)
return;
event->sw_function_id = MLX5_GET(query_vhca_state_out, out,
vhca_state_context.sw_function_id);
event->new_vhca_state = MLX5_GET(query_vhca_state_out, out,
vhca_state_context.vhca_state);
mlx5_vhca_event_arm(dev, event->function_id);
trace_mlx5_sf_vhca_event(dev, event);
blocking_notifier_call_chain(&dev->priv.vhca_state_n_head, 0, event);
}
static void mlx5_vhca_state_work_handler(struct work_struct *_work)
{
struct mlx5_vhca_event_work *work = container_of(_work, struct mlx5_vhca_event_work, work);
mlx5_vhca_event_notify(work->dev, &work->event);
kfree(work);
}
Annotation
- Immediate include surface: `linux/mlx5/driver.h`, `mlx5_ifc_vhca_event.h`, `mlx5_core.h`, `vhca_event.h`, `ecpf.h`, `diag/vhca_tracepoint.h`.
- Detected declarations: `struct mlx5_vhca_event_work`, `struct mlx5_vhca_event_handler`, `struct mlx5_vhca_events`, `function mlx5_cmd_query_vhca_state`, `function mlx5_cmd_modify_vhca_state`, `function mlx5_modify_vhca_sw_id`, `function mlx5_vhca_event_arm`, `function mlx5_vhca_event_notify`, `function mlx5_vhca_state_work_handler`, `function mlx5_vhca_events_work_enqueue`.
- Atlas domain: Driver Families / drivers/net.
- 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.