#include <linux/init.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/kernel.h>
#include <linux/kthread.h>
#include <linux/slab.h>
#include <linux/dma-map-ops.h>
#include <linux/vringh.h>
#include <linux/vdpa.h>
#include <linux/vhost_iotlb.h>
#include <uapi/linux/vdpa.h>
#include <uapi/linux/vhost_types.h>
#include "vdpa_sim.h"
#define DRV_VERSION …
#define DRV_AUTHOR …
#define DRV_DESC …
#define DRV_LICENSE …
static int batch_mapping = …;
module_param(batch_mapping, int, 0444);
MODULE_PARM_DESC(…) …;
static int max_iotlb_entries = …;
module_param(max_iotlb_entries, int, 0444);
MODULE_PARM_DESC(…) …;
static bool use_va = …;
module_param(use_va, bool, 0444);
MODULE_PARM_DESC(…) …;
#define VDPASIM_QUEUE_ALIGN …
#define VDPASIM_QUEUE_MAX …
#define VDPASIM_VENDOR_ID …
struct vdpasim_mm_work { … };
static void vdpasim_mm_work_fn(struct kthread_work *work)
{ … }
static void vdpasim_worker_change_mm_sync(struct vdpasim *vdpasim,
struct vdpasim_mm_work *mm_work)
{ … }
static struct vdpasim *vdpa_to_sim(struct vdpa_device *vdpa)
{ … }
static void vdpasim_vq_notify(struct vringh *vring)
{ … }
static void vdpasim_queue_ready(struct vdpasim *vdpasim, unsigned int idx)
{ … }
static void vdpasim_vq_reset(struct vdpasim *vdpasim,
struct vdpasim_virtqueue *vq)
{ … }
static void vdpasim_do_reset(struct vdpasim *vdpasim, u32 flags)
{ … }
static const struct vdpa_config_ops vdpasim_config_ops;
static const struct vdpa_config_ops vdpasim_batch_config_ops;
static void vdpasim_work_fn(struct kthread_work *work)
{ … }
struct vdpasim *vdpasim_create(struct vdpasim_dev_attr *dev_attr,
const struct vdpa_dev_set_config *config)
{ … }
EXPORT_SYMBOL_GPL(…);
void vdpasim_schedule_work(struct vdpasim *vdpasim)
{ … }
EXPORT_SYMBOL_GPL(…);
static int vdpasim_set_vq_address(struct vdpa_device *vdpa, u16 idx,
u64 desc_area, u64 driver_area,
u64 device_area)
{ … }
static void vdpasim_set_vq_num(struct vdpa_device *vdpa, u16 idx, u32 num)
{ … }
static u16 vdpasim_get_vq_size(struct vdpa_device *vdpa, u16 idx)
{ … }
static void vdpasim_kick_vq(struct vdpa_device *vdpa, u16 idx)
{ … }
static void vdpasim_set_vq_cb(struct vdpa_device *vdpa, u16 idx,
struct vdpa_callback *cb)
{ … }
static void vdpasim_set_vq_ready(struct vdpa_device *vdpa, u16 idx, bool ready)
{ … }
static bool vdpasim_get_vq_ready(struct vdpa_device *vdpa, u16 idx)
{ … }
static int vdpasim_set_vq_state(struct vdpa_device *vdpa, u16 idx,
const struct vdpa_vq_state *state)
{ … }
static int vdpasim_get_vq_state(struct vdpa_device *vdpa, u16 idx,
struct vdpa_vq_state *state)
{ … }
static int vdpasim_get_vq_stats(struct vdpa_device *vdpa, u16 idx,
struct sk_buff *msg,
struct netlink_ext_ack *extack)
{ … }
static u32 vdpasim_get_vq_align(struct vdpa_device *vdpa)
{ … }
static u32 vdpasim_get_vq_group(struct vdpa_device *vdpa, u16 idx)
{ … }
static u64 vdpasim_get_device_features(struct vdpa_device *vdpa)
{ … }
static u64 vdpasim_get_backend_features(const struct vdpa_device *vdpa)
{ … }
static int vdpasim_set_driver_features(struct vdpa_device *vdpa, u64 features)
{ … }
static u64 vdpasim_get_driver_features(struct vdpa_device *vdpa)
{ … }
static void vdpasim_set_config_cb(struct vdpa_device *vdpa,
struct vdpa_callback *cb)
{ … }
static u16 vdpasim_get_vq_num_max(struct vdpa_device *vdpa)
{ … }
static u32 vdpasim_get_device_id(struct vdpa_device *vdpa)
{ … }
static u32 vdpasim_get_vendor_id(struct vdpa_device *vdpa)
{ … }
static u8 vdpasim_get_status(struct vdpa_device *vdpa)
{ … }
static void vdpasim_set_status(struct vdpa_device *vdpa, u8 status)
{ … }
static int vdpasim_compat_reset(struct vdpa_device *vdpa, u32 flags)
{ … }
static int vdpasim_reset(struct vdpa_device *vdpa)
{ … }
static int vdpasim_suspend(struct vdpa_device *vdpa)
{ … }
static int vdpasim_resume(struct vdpa_device *vdpa)
{ … }
static size_t vdpasim_get_config_size(struct vdpa_device *vdpa)
{ … }
static void vdpasim_get_config(struct vdpa_device *vdpa, unsigned int offset,
void *buf, unsigned int len)
{ … }
static void vdpasim_set_config(struct vdpa_device *vdpa, unsigned int offset,
const void *buf, unsigned int len)
{ … }
static u32 vdpasim_get_generation(struct vdpa_device *vdpa)
{ … }
static struct vdpa_iova_range vdpasim_get_iova_range(struct vdpa_device *vdpa)
{ … }
static int vdpasim_set_group_asid(struct vdpa_device *vdpa, unsigned int group,
unsigned int asid)
{ … }
static int vdpasim_set_map(struct vdpa_device *vdpa, unsigned int asid,
struct vhost_iotlb *iotlb)
{ … }
static int vdpasim_reset_map(struct vdpa_device *vdpa, unsigned int asid)
{ … }
static int vdpasim_bind_mm(struct vdpa_device *vdpa, struct mm_struct *mm)
{ … }
static void vdpasim_unbind_mm(struct vdpa_device *vdpa)
{ … }
static int vdpasim_dma_map(struct vdpa_device *vdpa, unsigned int asid,
u64 iova, u64 size,
u64 pa, u32 perm, void *opaque)
{ … }
static int vdpasim_dma_unmap(struct vdpa_device *vdpa, unsigned int asid,
u64 iova, u64 size)
{ … }
static void vdpasim_free(struct vdpa_device *vdpa)
{ … }
static const struct vdpa_config_ops vdpasim_config_ops = …;
static const struct vdpa_config_ops vdpasim_batch_config_ops = …;
MODULE_VERSION(…);
MODULE_LICENSE(…);
MODULE_AUTHOR(…);
MODULE_DESCRIPTION(…);