include/linux/vdpa.h

Source file repositories/reference/linux-study-clean/include/linux/vdpa.h

File Facts

System
Linux kernel
Corpus path
include/linux/vdpa.h
Extension
.h
Size
22720 bytes
Lines
629
Domain
Core OS
Bucket
Core Kernel Interface
Inferred role
Core OS: operation-table or driver-model contract
Status
pattern implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

struct device_driver driver;
	int (*probe)(struct vdpa_device *vdev);
	void (*remove)(struct vdpa_device *vdev);
};

#define vdpa_register_driver(drv) \
	__vdpa_register_driver(drv, THIS_MODULE)
int __vdpa_register_driver(struct vdpa_driver *drv, struct module *owner);
void vdpa_unregister_driver(struct vdpa_driver *drv);

#define module_vdpa_driver(__vdpa_driver) \
	module_driver(__vdpa_driver, vdpa_register_driver,	\
		      vdpa_unregister_driver)

static inline struct vdpa_driver *drv_to_vdpa(struct device_driver *driver)
{
	return container_of(driver, struct vdpa_driver, driver);
}

static inline struct vdpa_device *dev_to_vdpa(struct device *_dev)
{
	return container_of(_dev, struct vdpa_device, dev);
}

static inline void *vdpa_get_drvdata(const struct vdpa_device *vdev)
{
	return dev_get_drvdata(&vdev->dev);
}

static inline void vdpa_set_drvdata(struct vdpa_device *vdev, void *data)
{
	dev_set_drvdata(&vdev->dev, data);
}

static inline union virtio_map vdpa_get_map(struct vdpa_device *vdev)
{
	return vdev->vmap;
}

static inline int vdpa_reset(struct vdpa_device *vdev, u32 flags)
{
	const struct vdpa_config_ops *ops = vdev->config;
	int ret;

	down_write(&vdev->cf_lock);
	vdev->features_valid = false;
	if (ops->compat_reset && flags)
		ret = ops->compat_reset(vdev, flags);
	else
		ret = ops->reset(vdev);
	up_write(&vdev->cf_lock);
	return ret;
}

static inline int vdpa_set_features_unlocked(struct vdpa_device *vdev, u64 features)
{
	const struct vdpa_config_ops *ops = vdev->config;
	int ret;

	vdev->features_valid = true;
	ret = ops->set_driver_features(vdev, features);

	return ret;
}

static inline int vdpa_set_features(struct vdpa_device *vdev, u64 features)
{
	int ret;

	down_write(&vdev->cf_lock);
	ret = vdpa_set_features_unlocked(vdev, features);
	up_write(&vdev->cf_lock);

	return ret;
}

void vdpa_get_config(struct vdpa_device *vdev, unsigned int offset,
		     void *buf, unsigned int len);
void vdpa_set_config(struct vdpa_device *dev, unsigned int offset,
		     const void *buf, unsigned int length);
void vdpa_set_status(struct vdpa_device *vdev, u8 status);

/**
 * struct vdpa_mgmtdev_ops - vdpa device ops
 * @dev_add: Add a vdpa device using alloc and register
 *	     @mdev: parent device to use for device addition
 *	     @name: name of the new vdpa device
 *	     @config: config attributes to apply to the device under creation
 *	     Driver need to add a new device using _vdpa_register_device()
 *	     after fully initializing the vdpa device. Driver must return 0

Annotation

Implementation Notes