Commit 442706f9 authored by Stefano Garzarella's avatar Stefano Garzarella Committed by Michael S. Tsirkin

vdpa: add get_config_size callback in vdpa_config_ops

This new callback is used to get the size of the configuration space
of vDPA devices.
Signed-off-by: default avatarStefano Garzarella <sgarzare@redhat.com>
Link: https://lore.kernel.org/r/20210315163450.254396-9-sgarzare@redhat.comSigned-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Acked-by: default avatarJason Wang <jasowang@redhat.com>
parent bc433e5e
...@@ -351,6 +351,11 @@ static u32 ifcvf_vdpa_get_vq_align(struct vdpa_device *vdpa_dev) ...@@ -351,6 +351,11 @@ static u32 ifcvf_vdpa_get_vq_align(struct vdpa_device *vdpa_dev)
return IFCVF_QUEUE_ALIGNMENT; return IFCVF_QUEUE_ALIGNMENT;
} }
static size_t ifcvf_vdpa_get_config_size(struct vdpa_device *vdpa_dev)
{
return sizeof(struct virtio_net_config);
}
static void ifcvf_vdpa_get_config(struct vdpa_device *vdpa_dev, static void ifcvf_vdpa_get_config(struct vdpa_device *vdpa_dev,
unsigned int offset, unsigned int offset,
void *buf, unsigned int len) void *buf, unsigned int len)
...@@ -411,6 +416,7 @@ static const struct vdpa_config_ops ifc_vdpa_ops = { ...@@ -411,6 +416,7 @@ static const struct vdpa_config_ops ifc_vdpa_ops = {
.get_device_id = ifcvf_vdpa_get_device_id, .get_device_id = ifcvf_vdpa_get_device_id,
.get_vendor_id = ifcvf_vdpa_get_vendor_id, .get_vendor_id = ifcvf_vdpa_get_vendor_id,
.get_vq_align = ifcvf_vdpa_get_vq_align, .get_vq_align = ifcvf_vdpa_get_vq_align,
.get_config_size = ifcvf_vdpa_get_config_size,
.get_config = ifcvf_vdpa_get_config, .get_config = ifcvf_vdpa_get_config,
.set_config = ifcvf_vdpa_set_config, .set_config = ifcvf_vdpa_set_config,
.set_config_cb = ifcvf_vdpa_set_config_cb, .set_config_cb = ifcvf_vdpa_set_config_cb,
......
...@@ -1809,6 +1809,11 @@ static void mlx5_vdpa_set_status(struct vdpa_device *vdev, u8 status) ...@@ -1809,6 +1809,11 @@ static void mlx5_vdpa_set_status(struct vdpa_device *vdev, u8 status)
ndev->mvdev.status |= VIRTIO_CONFIG_S_FAILED; ndev->mvdev.status |= VIRTIO_CONFIG_S_FAILED;
} }
static size_t mlx5_vdpa_get_config_size(struct vdpa_device *vdev)
{
return sizeof(struct virtio_net_config);
}
static void mlx5_vdpa_get_config(struct vdpa_device *vdev, unsigned int offset, void *buf, static void mlx5_vdpa_get_config(struct vdpa_device *vdev, unsigned int offset, void *buf,
unsigned int len) unsigned int len)
{ {
...@@ -1895,6 +1900,7 @@ static const struct vdpa_config_ops mlx5_vdpa_ops = { ...@@ -1895,6 +1900,7 @@ static const struct vdpa_config_ops mlx5_vdpa_ops = {
.get_vendor_id = mlx5_vdpa_get_vendor_id, .get_vendor_id = mlx5_vdpa_get_vendor_id,
.get_status = mlx5_vdpa_get_status, .get_status = mlx5_vdpa_get_status,
.set_status = mlx5_vdpa_set_status, .set_status = mlx5_vdpa_set_status,
.get_config_size = mlx5_vdpa_get_config_size,
.get_config = mlx5_vdpa_get_config, .get_config = mlx5_vdpa_get_config,
.set_config = mlx5_vdpa_set_config, .set_config = mlx5_vdpa_set_config,
.get_generation = mlx5_vdpa_get_generation, .get_generation = mlx5_vdpa_get_generation,
......
...@@ -462,6 +462,13 @@ static void vdpasim_set_status(struct vdpa_device *vdpa, u8 status) ...@@ -462,6 +462,13 @@ static void vdpasim_set_status(struct vdpa_device *vdpa, u8 status)
spin_unlock(&vdpasim->lock); spin_unlock(&vdpasim->lock);
} }
static size_t vdpasim_get_config_size(struct vdpa_device *vdpa)
{
struct vdpasim *vdpasim = vdpa_to_sim(vdpa);
return vdpasim->dev_attr.config_size;
}
static void vdpasim_get_config(struct vdpa_device *vdpa, unsigned int offset, static void vdpasim_get_config(struct vdpa_device *vdpa, unsigned int offset,
void *buf, unsigned int len) void *buf, unsigned int len)
{ {
...@@ -598,6 +605,7 @@ static const struct vdpa_config_ops vdpasim_config_ops = { ...@@ -598,6 +605,7 @@ static const struct vdpa_config_ops vdpasim_config_ops = {
.get_vendor_id = vdpasim_get_vendor_id, .get_vendor_id = vdpasim_get_vendor_id,
.get_status = vdpasim_get_status, .get_status = vdpasim_get_status,
.set_status = vdpasim_set_status, .set_status = vdpasim_set_status,
.get_config_size = vdpasim_get_config_size,
.get_config = vdpasim_get_config, .get_config = vdpasim_get_config,
.set_config = vdpasim_set_config, .set_config = vdpasim_set_config,
.get_generation = vdpasim_get_generation, .get_generation = vdpasim_get_generation,
...@@ -625,6 +633,7 @@ static const struct vdpa_config_ops vdpasim_batch_config_ops = { ...@@ -625,6 +633,7 @@ static const struct vdpa_config_ops vdpasim_batch_config_ops = {
.get_vendor_id = vdpasim_get_vendor_id, .get_vendor_id = vdpasim_get_vendor_id,
.get_status = vdpasim_get_status, .get_status = vdpasim_get_status,
.set_status = vdpasim_set_status, .set_status = vdpasim_set_status,
.get_config_size = vdpasim_get_config_size,
.get_config = vdpasim_get_config, .get_config = vdpasim_get_config,
.set_config = vdpasim_set_config, .set_config = vdpasim_set_config,
.get_generation = vdpasim_get_generation, .get_generation = vdpasim_get_generation,
......
...@@ -296,6 +296,13 @@ static u32 vp_vdpa_get_vq_align(struct vdpa_device *vdpa) ...@@ -296,6 +296,13 @@ static u32 vp_vdpa_get_vq_align(struct vdpa_device *vdpa)
return PAGE_SIZE; return PAGE_SIZE;
} }
static size_t vp_vdpa_get_config_size(struct vdpa_device *vdpa)
{
struct virtio_pci_modern_device *mdev = vdpa_to_mdev(vdpa);
return mdev->device_len;
}
static void vp_vdpa_get_config(struct vdpa_device *vdpa, static void vp_vdpa_get_config(struct vdpa_device *vdpa,
unsigned int offset, unsigned int offset,
void *buf, unsigned int len) void *buf, unsigned int len)
...@@ -369,6 +376,7 @@ static const struct vdpa_config_ops vp_vdpa_ops = { ...@@ -369,6 +376,7 @@ static const struct vdpa_config_ops vp_vdpa_ops = {
.get_device_id = vp_vdpa_get_device_id, .get_device_id = vp_vdpa_get_device_id,
.get_vendor_id = vp_vdpa_get_vendor_id, .get_vendor_id = vp_vdpa_get_vendor_id,
.get_vq_align = vp_vdpa_get_vq_align, .get_vq_align = vp_vdpa_get_vq_align,
.get_config_size = vp_vdpa_get_config_size,
.get_config = vp_vdpa_get_config, .get_config = vp_vdpa_get_config,
.set_config = vp_vdpa_set_config, .set_config = vp_vdpa_set_config,
.set_config_cb = vp_vdpa_set_config_cb, .set_config_cb = vp_vdpa_set_config_cb,
......
...@@ -150,6 +150,9 @@ struct vdpa_iova_range { ...@@ -150,6 +150,9 @@ struct vdpa_iova_range {
* @set_status: Set the device status * @set_status: Set the device status
* @vdev: vdpa device * @vdev: vdpa device
* @status: virtio device status * @status: virtio device status
* @get_config_size: Get the size of the configuration space
* @vdev: vdpa device
* Returns size_t: configuration size
* @get_config: Read from device specific configuration space * @get_config: Read from device specific configuration space
* @vdev: vdpa device * @vdev: vdpa device
* @offset: offset from the beginning of * @offset: offset from the beginning of
...@@ -231,6 +234,7 @@ struct vdpa_config_ops { ...@@ -231,6 +234,7 @@ struct vdpa_config_ops {
u32 (*get_vendor_id)(struct vdpa_device *vdev); u32 (*get_vendor_id)(struct vdpa_device *vdev);
u8 (*get_status)(struct vdpa_device *vdev); u8 (*get_status)(struct vdpa_device *vdev);
void (*set_status)(struct vdpa_device *vdev, u8 status); void (*set_status)(struct vdpa_device *vdev, u8 status);
size_t (*get_config_size)(struct vdpa_device *vdev);
void (*get_config)(struct vdpa_device *vdev, unsigned int offset, void (*get_config)(struct vdpa_device *vdev, unsigned int offset,
void *buf, unsigned int len); void *buf, unsigned int len);
void (*set_config)(struct vdpa_device *vdev, unsigned int offset, void (*set_config)(struct vdpa_device *vdev, unsigned int offset,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment