drivers/vdpa/mlx5/net/mlx5_vnet.c
Source file repositories/reference/linux-study-clean/drivers/vdpa/mlx5/net/mlx5_vnet.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/vdpa/mlx5/net/mlx5_vnet.c- Extension
.c- Size
- 113422 bytes
- Lines
- 4166
- Domain
- Driver Families
- Bucket
- drivers/vdpa
- 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
linux/module.hlinux/vdpa.hlinux/vringh.huapi/linux/virtio_net.huapi/linux/virtio_ids.huapi/linux/vdpa.huapi/linux/vhost_types.hlinux/virtio_config.hlinux/auxiliary_bus.hlinux/mlx5/cq.hlinux/mlx5/qp.hlinux/mlx5/device.hlinux/mlx5/driver.hlinux/mlx5/vport.hlinux/mlx5/fs.hlinux/mlx5/mlx5_ifc_vdpa.hlinux/mlx5/mpfs.hmlx5_vdpa.hmlx5_vnet.h
Detected Declarations
struct mlx5_vdpa_cq_bufstruct mlx5_vdpa_cqstruct mlx5_vdpa_umemstruct mlx5_vdpa_qpstruct mlx5_vq_restore_infostruct mlx5_vdpa_virtqueuestruct mlx5_virtq_attrstruct mlx5_virtqueue_query_memstruct mlx5_virtqueue_modify_memstruct mlx5_vdpa_mgmtdevfunction is_index_validfunction mlx5_vdpa_is_little_endianfunction mlx5vdpa16_to_cpufunction cpu_to_mlx5vdpa16function ctrl_vq_idxfunction is_ctrl_vq_idxfunction print_statusfunction print_featuresfunction create_tisfunction destroy_tisfunction cq_frag_buf_allocfunction umem_frag_buf_allocfunction cq_frag_buf_freefunction cq_frag_buf_initfunction rx_postfunction qp_preparefunction rq_buf_allocfunction rq_buf_freefunction qp_createfunction qp_destroyfunction mlx5_vdpa_poll_onefunction mlx5_vdpa_handle_completionsfunction mlx5_vdpa_cq_compfunction cq_createfunction cq_destroyfunction read_umem_paramsfunction set_umem_sizefunction umem_frag_buf_freefunction create_umemfunction umem_destroyfunction umems_createfunction umems_destroyfunction get_queue_typefunction vq_is_txfunction get_featuresfunction counters_supportedfunction msix_mode_supportedfunction create_virtqueue
Annotated Snippet
struct mlx5_vdpa_cq_buf {
struct mlx5_frag_buf_ctrl fbc;
struct mlx5_frag_buf frag_buf;
int cqe_size;
int nent;
};
struct mlx5_vdpa_cq {
struct mlx5_core_cq mcq;
struct mlx5_vdpa_cq_buf buf;
struct mlx5_db db;
int cqe;
};
struct mlx5_vdpa_umem {
struct mlx5_frag_buf_ctrl fbc;
struct mlx5_frag_buf frag_buf;
int size;
u32 id;
};
struct mlx5_vdpa_qp {
struct mlx5_core_qp mqp;
struct mlx5_frag_buf frag_buf;
struct mlx5_db db;
u16 head;
bool fw;
};
struct mlx5_vq_restore_info {
u32 num_ent;
u64 desc_addr;
u64 device_addr;
u64 driver_addr;
u16 avail_index;
u16 used_index;
struct msi_map map;
bool ready;
bool restore;
};
struct mlx5_vdpa_virtqueue {
bool ready;
u64 desc_addr;
u64 device_addr;
u64 driver_addr;
u32 num_ent;
/* Resources for implementing the notification channel from the device
* to the driver. fwqp is the firmware end of an RC connection; the
* other end is vqqp used by the driver. cq is where completions are
* reported.
*/
struct mlx5_vdpa_cq cq;
struct mlx5_vdpa_qp fwqp;
struct mlx5_vdpa_qp vqqp;
/* umem resources are required for the virtqueue operation. They're use
* is internal and they must be provided by the driver.
*/
struct mlx5_vdpa_umem umem1;
struct mlx5_vdpa_umem umem2;
struct mlx5_vdpa_umem umem3;
u32 counter_set_id;
bool initialized;
int index;
u32 virtq_id;
struct mlx5_vdpa_net *ndev;
u16 avail_idx;
u16 used_idx;
int fw_state;
u64 modified_fields;
struct mlx5_vdpa_mr *vq_mr;
struct mlx5_vdpa_mr *desc_mr;
struct msi_map map;
/* keep last in the struct */
struct mlx5_vq_restore_info ri;
};
static bool is_index_valid(struct mlx5_vdpa_dev *mvdev, u16 idx)
{
if (!(mvdev->actual_features & BIT_ULL(VIRTIO_NET_F_MQ))) {
if (!(mvdev->actual_features & BIT_ULL(VIRTIO_NET_F_CTRL_VQ)))
return idx < 2;
else
Annotation
- Immediate include surface: `linux/module.h`, `linux/vdpa.h`, `linux/vringh.h`, `uapi/linux/virtio_net.h`, `uapi/linux/virtio_ids.h`, `uapi/linux/vdpa.h`, `uapi/linux/vhost_types.h`, `linux/virtio_config.h`.
- Detected declarations: `struct mlx5_vdpa_cq_buf`, `struct mlx5_vdpa_cq`, `struct mlx5_vdpa_umem`, `struct mlx5_vdpa_qp`, `struct mlx5_vq_restore_info`, `struct mlx5_vdpa_virtqueue`, `struct mlx5_virtq_attr`, `struct mlx5_virtqueue_query_mem`, `struct mlx5_virtqueue_modify_mem`, `struct mlx5_vdpa_mgmtdev`.
- Atlas domain: Driver Families / drivers/vdpa.
- 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.