drivers/virtio/virtio_vdpa.c
Source file repositories/reference/linux-study-clean/drivers/virtio/virtio_vdpa.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/virtio/virtio_vdpa.c- Extension
.c- Size
- 12508 bytes
- Lines
- 519
- Domain
- Driver Families
- Bucket
- drivers/virtio
- 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.
- 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/init.hlinux/module.hlinux/device.hlinux/kernel.hlinux/slab.hlinux/uuid.hlinux/group_cpus.hlinux/virtio.hlinux/vdpa.hlinux/virtio_config.hlinux/virtio_ring.h
Detected Declarations
struct virtio_vdpa_devicefunction to_virtio_vdpa_devicefunction virtio_vdpa_getfunction virtio_vdpa_setfunction virtio_vdpa_generationfunction virtio_vdpa_get_statusfunction virtio_vdpa_set_statusfunction virtio_vdpa_resetfunction virtio_vdpa_notifyfunction virtio_vdpa_notify_with_datafunction virtio_vdpa_config_cbfunction virtio_vdpa_virtqueue_cbfunction virtio_vdpa_setup_vqfunction virtio_vdpa_del_vqfunction virtio_vdpa_del_vqsfunction default_calc_setsfunction create_affinity_masksfunction virtio_vdpa_find_vqsfunction virtio_vdpa_get_featuresfunction virtio_vdpa_finalize_featuresfunction virtio_vdpa_set_vq_affinityfunction virtio_vdpa_get_vq_affinityfunction virtio_vdpa_release_devfunction virtio_vdpa_probefunction virtio_vdpa_remove
Annotated Snippet
struct virtio_vdpa_device {
struct virtio_device vdev;
struct vdpa_device *vdpa;
u64 features;
};
static inline struct virtio_vdpa_device *
to_virtio_vdpa_device(struct virtio_device *dev)
{
return container_of(dev, struct virtio_vdpa_device, vdev);
}
static struct vdpa_device *vd_get_vdpa(struct virtio_device *vdev)
{
return to_virtio_vdpa_device(vdev)->vdpa;
}
static void virtio_vdpa_get(struct virtio_device *vdev, unsigned int offset,
void *buf, unsigned int len)
{
struct vdpa_device *vdpa = vd_get_vdpa(vdev);
vdpa_get_config(vdpa, offset, buf, len);
}
static void virtio_vdpa_set(struct virtio_device *vdev, unsigned int offset,
const void *buf, unsigned int len)
{
struct vdpa_device *vdpa = vd_get_vdpa(vdev);
vdpa_set_config(vdpa, offset, buf, len);
}
static u32 virtio_vdpa_generation(struct virtio_device *vdev)
{
struct vdpa_device *vdpa = vd_get_vdpa(vdev);
const struct vdpa_config_ops *ops = vdpa->config;
if (ops->get_generation)
return ops->get_generation(vdpa);
return 0;
}
static u8 virtio_vdpa_get_status(struct virtio_device *vdev)
{
struct vdpa_device *vdpa = vd_get_vdpa(vdev);
const struct vdpa_config_ops *ops = vdpa->config;
return ops->get_status(vdpa);
}
static void virtio_vdpa_set_status(struct virtio_device *vdev, u8 status)
{
struct vdpa_device *vdpa = vd_get_vdpa(vdev);
vdpa_set_status(vdpa, status);
}
static void virtio_vdpa_reset(struct virtio_device *vdev)
{
struct vdpa_device *vdpa = vd_get_vdpa(vdev);
vdpa_reset(vdpa, 0);
}
static bool virtio_vdpa_notify(struct virtqueue *vq)
{
struct vdpa_device *vdpa = vd_get_vdpa(vq->vdev);
const struct vdpa_config_ops *ops = vdpa->config;
ops->kick_vq(vdpa, vq->index);
return true;
}
static bool virtio_vdpa_notify_with_data(struct virtqueue *vq)
{
struct vdpa_device *vdpa = vd_get_vdpa(vq->vdev);
const struct vdpa_config_ops *ops = vdpa->config;
u32 data = vring_notification_data(vq);
ops->kick_vq_with_data(vdpa, data);
return true;
}
static irqreturn_t virtio_vdpa_config_cb(void *private)
{
struct virtio_vdpa_device *vd_dev = private;
Annotation
- Immediate include surface: `linux/init.h`, `linux/module.h`, `linux/device.h`, `linux/kernel.h`, `linux/slab.h`, `linux/uuid.h`, `linux/group_cpus.h`, `linux/virtio.h`.
- Detected declarations: `struct virtio_vdpa_device`, `function to_virtio_vdpa_device`, `function virtio_vdpa_get`, `function virtio_vdpa_set`, `function virtio_vdpa_generation`, `function virtio_vdpa_get_status`, `function virtio_vdpa_set_status`, `function virtio_vdpa_reset`, `function virtio_vdpa_notify`, `function virtio_vdpa_notify_with_data`.
- Atlas domain: Driver Families / drivers/virtio.
- Implementation status: source implementation candidate.
- 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.