linux/drivers/vdpa/vdpa.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * vDPA bus.
 *
 * Copyright (c) 2020, Red Hat. All rights reserved.
 *     Author: Jason Wang <[email protected]>
 *
 */

#include <linux/module.h>
#include <linux/idr.h>
#include <linux/slab.h>
#include <linux/vdpa.h>
#include <uapi/linux/vdpa.h>
#include <net/genetlink.h>
#include <linux/mod_devicetable.h>
#include <linux/virtio_ids.h>

static LIST_HEAD(mdev_head);
/* A global mutex that protects vdpa management device and device level operations. */
static DECLARE_RWSEM(vdpa_dev_lock);
static DEFINE_IDA(vdpa_index_ida);

void vdpa_set_status(struct vdpa_device *vdev, u8 status)
{}
EXPORT_SYMBOL();

static struct genl_family vdpa_nl_family;

static int vdpa_dev_probe(struct device *d)
{}

static void vdpa_dev_remove(struct device *d)
{}

static int vdpa_dev_match(struct device *dev, const struct device_driver *drv)
{}

static ssize_t driver_override_store(struct device *dev,
				     struct device_attribute *attr,
				     const char *buf, size_t count)
{}

static ssize_t driver_override_show(struct device *dev,
				    struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RW(driver_override);

static struct attribute *vdpa_dev_attrs[] =;

static const struct attribute_group vdpa_dev_group =;
__ATTRIBUTE_GROUPS();

static const struct bus_type vdpa_bus =;

static void vdpa_release_dev(struct device *d)
{}

/**
 * __vdpa_alloc_device - allocate and initilaize a vDPA device
 * This allows driver to some prepartion after device is
 * initialized but before registered.
 * @parent: the parent device
 * @config: the bus operations that is supported by this device
 * @ngroups: number of groups supported by this device
 * @nas: number of address spaces supported by this device
 * @size: size of the parent structure that contains private data
 * @name: name of the vdpa device; optional.
 * @use_va: indicate whether virtual address must be used by this device
 *
 * Driver should use vdpa_alloc_device() wrapper macro instead of
 * using this directly.
 *
 * Return: Returns an error when parent/config/dma_dev is not set or fail to get
 *	   ida.
 */
struct vdpa_device *__vdpa_alloc_device(struct device *parent,
					const struct vdpa_config_ops *config,
					unsigned int ngroups, unsigned int nas,
					size_t size, const char *name,
					bool use_va)
{}
EXPORT_SYMBOL_GPL();

static int vdpa_name_match(struct device *dev, const void *data)
{}

static int __vdpa_register_device(struct vdpa_device *vdev, u32 nvqs)
{}

/**
 * _vdpa_register_device - register a vDPA device with vdpa lock held
 * Caller must have a succeed call of vdpa_alloc_device() before.
 * Caller must invoke this routine in the management device dev_add()
 * callback after setting up valid mgmtdev for this vdpa device.
 * @vdev: the vdpa device to be registered to vDPA bus
 * @nvqs: number of virtqueues supported by this device
 *
 * Return: Returns an error when fail to add device to vDPA bus
 */
int _vdpa_register_device(struct vdpa_device *vdev, u32 nvqs)
{}
EXPORT_SYMBOL_GPL();

/**
 * vdpa_register_device - register a vDPA device
 * Callers must have a succeed call of vdpa_alloc_device() before.
 * @vdev: the vdpa device to be registered to vDPA bus
 * @nvqs: number of virtqueues supported by this device
 *
 * Return: Returns an error when fail to add to vDPA bus
 */
int vdpa_register_device(struct vdpa_device *vdev, u32 nvqs)
{}
EXPORT_SYMBOL_GPL();

/**
 * _vdpa_unregister_device - unregister a vDPA device
 * Caller must invoke this routine as part of management device dev_del()
 * callback.
 * @vdev: the vdpa device to be unregisted from vDPA bus
 */
void _vdpa_unregister_device(struct vdpa_device *vdev)
{}
EXPORT_SYMBOL_GPL();

/**
 * vdpa_unregister_device - unregister a vDPA device
 * @vdev: the vdpa device to be unregisted from vDPA bus
 */
void vdpa_unregister_device(struct vdpa_device *vdev)
{}
EXPORT_SYMBOL_GPL();

/**
 * __vdpa_register_driver - register a vDPA device driver
 * @drv: the vdpa device driver to be registered
 * @owner: module owner of the driver
 *
 * Return: Returns an err when fail to do the registration
 */
int __vdpa_register_driver(struct vdpa_driver *drv, struct module *owner)
{}
EXPORT_SYMBOL_GPL();

/**
 * vdpa_unregister_driver - unregister a vDPA device driver
 * @drv: the vdpa device driver to be unregistered
 */
void vdpa_unregister_driver(struct vdpa_driver *drv)
{}
EXPORT_SYMBOL_GPL();

/**
 * vdpa_mgmtdev_register - register a vdpa management device
 *
 * @mdev: Pointer to vdpa management device
 * vdpa_mgmtdev_register() register a vdpa management device which supports
 * vdpa device management.
 * Return: Returns 0 on success or failure when required callback ops are not
 *         initialized.
 */
int vdpa_mgmtdev_register(struct vdpa_mgmt_dev *mdev)
{}
EXPORT_SYMBOL_GPL();

static int vdpa_match_remove(struct device *dev, void *data)
{}

void vdpa_mgmtdev_unregister(struct vdpa_mgmt_dev *mdev)
{}
EXPORT_SYMBOL_GPL();

static void vdpa_get_config_unlocked(struct vdpa_device *vdev,
				     unsigned int offset,
				     void *buf, unsigned int len)
{}

/**
 * vdpa_get_config - Get one or more device configuration fields.
 * @vdev: vdpa device to operate on
 * @offset: starting byte offset of the field
 * @buf: buffer pointer to read to
 * @len: length of the configuration fields in bytes
 */
void vdpa_get_config(struct vdpa_device *vdev, unsigned int offset,
		     void *buf, unsigned int len)
{}
EXPORT_SYMBOL_GPL();

/**
 * vdpa_set_config - Set one or more device configuration fields.
 * @vdev: vdpa device to operate on
 * @offset: starting byte offset of the field
 * @buf: buffer pointer to read from
 * @length: length of the configuration fields in bytes
 */
void vdpa_set_config(struct vdpa_device *vdev, unsigned int offset,
		     const void *buf, unsigned int length)
{}
EXPORT_SYMBOL_GPL();

static bool mgmtdev_handle_match(const struct vdpa_mgmt_dev *mdev,
				 const char *busname, const char *devname)
{}

static struct vdpa_mgmt_dev *vdpa_mgmtdev_get_from_attr(struct nlattr **attrs)
{}

static int vdpa_nl_mgmtdev_handle_fill(struct sk_buff *msg, const struct vdpa_mgmt_dev *mdev)
{}

static u64 vdpa_mgmtdev_get_classes(const struct vdpa_mgmt_dev *mdev,
				    unsigned int *nclasses)
{}

static int vdpa_mgmtdev_fill(const struct vdpa_mgmt_dev *mdev, struct sk_buff *msg,
			     u32 portid, u32 seq, int flags)
{}

static int vdpa_nl_cmd_mgmtdev_get_doit(struct sk_buff *skb, struct genl_info *info)
{}

static int
vdpa_nl_cmd_mgmtdev_get_dumpit(struct sk_buff *msg, struct netlink_callback *cb)
{}

#define VDPA_DEV_NET_ATTRS_MASK

/*
 * Bitmask for all per-device features: feature bits VIRTIO_TRANSPORT_F_START
 * through VIRTIO_TRANSPORT_F_END are unset, i.e. 0xfffffc000fffffff for
 * all 64bit features. If the features are extended beyond 64 bits, or new
 * "holes" are reserved for other type of features than per-device, this
 * macro would have to be updated.
 */
#define VIRTIO_DEVICE_F_MASK

static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *info)
{}

static int vdpa_nl_cmd_dev_del_set_doit(struct sk_buff *skb, struct genl_info *info)
{}

static int
vdpa_dev_fill(struct vdpa_device *vdev, struct sk_buff *msg, u32 portid, u32 seq,
	      int flags, struct netlink_ext_ack *extack)
{}

static int vdpa_nl_cmd_dev_get_doit(struct sk_buff *skb, struct genl_info *info)
{}

struct vdpa_dev_dump_info {};

static int vdpa_dev_dump(struct device *dev, void *data)
{}

static int vdpa_nl_cmd_dev_get_dumpit(struct sk_buff *msg, struct netlink_callback *cb)
{}

static int vdpa_dev_net_mq_config_fill(struct sk_buff *msg, u64 features,
				       const struct virtio_net_config *config)
{}

static int vdpa_dev_net_mtu_config_fill(struct sk_buff *msg, u64 features,
					const struct virtio_net_config *config)
{}

static int vdpa_dev_net_mac_config_fill(struct sk_buff *msg, u64 features,
					const struct virtio_net_config *config)
{}

static int vdpa_dev_net_status_config_fill(struct sk_buff *msg, u64 features,
					   const struct virtio_net_config *config)
{}

static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *msg)
{}

static int
vdpa_dev_blk_capacity_config_fill(struct sk_buff *msg,
				  const struct virtio_blk_config *config)
{}

static int
vdpa_dev_blk_seg_size_config_fill(struct sk_buff *msg, u64 features,
				  const struct virtio_blk_config *config)
{}

/* fill the block size*/
static int
vdpa_dev_blk_block_size_config_fill(struct sk_buff *msg, u64 features,
				    const struct virtio_blk_config *config)
{}

static int
vdpa_dev_blk_seg_max_config_fill(struct sk_buff *msg, u64 features,
				 const struct virtio_blk_config *config)
{}

static int vdpa_dev_blk_mq_config_fill(struct sk_buff *msg, u64 features,
				       const struct virtio_blk_config *config)
{}

static int vdpa_dev_blk_topology_config_fill(struct sk_buff *msg, u64 features,
				       const struct virtio_blk_config *config)
{}

static int vdpa_dev_blk_discard_config_fill(struct sk_buff *msg, u64 features,
				       const struct virtio_blk_config *config)
{}

static int
vdpa_dev_blk_write_zeroes_config_fill(struct sk_buff *msg, u64 features,
				     const struct virtio_blk_config *config)
{}

static int vdpa_dev_blk_ro_config_fill(struct sk_buff *msg, u64 features)
{}

static int vdpa_dev_blk_flush_config_fill(struct sk_buff *msg, u64 features)
{}

static int vdpa_dev_blk_config_fill(struct vdpa_device *vdev,
				    struct sk_buff *msg)
{}

static int
vdpa_dev_config_fill(struct vdpa_device *vdev, struct sk_buff *msg, u32 portid, u32 seq,
		     int flags, struct netlink_ext_ack *extack)
{}

static int vdpa_fill_stats_rec(struct vdpa_device *vdev, struct sk_buff *msg,
			       struct genl_info *info, u32 index)
{}

static int vendor_stats_fill(struct vdpa_device *vdev, struct sk_buff *msg,
			     struct genl_info *info, u32 index)
{}

static int vdpa_dev_vendor_stats_fill(struct vdpa_device *vdev,
				      struct sk_buff *msg,
				      struct genl_info *info, u32 index)
{}

static int vdpa_nl_cmd_dev_config_get_doit(struct sk_buff *skb, struct genl_info *info)
{}

static int vdpa_dev_config_dump(struct device *dev, void *data)
{}

static int
vdpa_nl_cmd_dev_config_get_dumpit(struct sk_buff *msg, struct netlink_callback *cb)
{}

static int vdpa_nl_cmd_dev_stats_get_doit(struct sk_buff *skb,
					  struct genl_info *info)
{}

static const struct nla_policy vdpa_nl_policy[VDPA_ATTR_MAX + 1] =;

static const struct genl_ops vdpa_nl_ops[] =;

static struct genl_family vdpa_nl_family __ro_after_init =;

static int vdpa_init(void)
{}

static void __exit vdpa_exit(void)
{}
core_initcall(vdpa_init);
module_exit(vdpa_exit);

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();