From: Stefano Garzarella <sgarz...@redhat.com>

commit 442706f9f94d28fe3c9f188ae4ebbd6b40addffe from
https://github.com/altera-opensource/linux-socfpga.git

This new callback is used to get the size of the configuration space
of vDPA devices.

Signed-off-by: Stefano Garzarella <sgarz...@redhat.com>
Link: https://lore.kernel.org/r/20210315163450.254396-9-sgarz...@redhat.com
Signed-off-by: Michael S. Tsirkin <m...@redhat.com>
Acked-by: Jason Wang <jasow...@redhat.com>
Signed-off-by: Wenlin Kang <wenlin.k...@windriver.com>
---
 drivers/vdpa/ifcvf/ifcvf_main.c   | 6 ++++++
 drivers/vdpa/mlx5/net/mlx5_vnet.c | 6 ++++++
 drivers/vdpa/vdpa_sim/vdpa_sim.c  | 9 +++++++++
 drivers/vdpa/virtio_pci/vp_vdpa.c | 8 ++++++++
 include/linux/vdpa.h              | 4 ++++
 5 files changed, 33 insertions(+)

diff --git a/drivers/vdpa/ifcvf/ifcvf_main.c b/drivers/vdpa/ifcvf/ifcvf_main.c
index 8b4028556cb6..a4e4bf1213e7 100644
--- a/drivers/vdpa/ifcvf/ifcvf_main.c
+++ b/drivers/vdpa/ifcvf/ifcvf_main.c
@@ -332,6 +332,11 @@ static u32 ifcvf_vdpa_get_vq_align(struct vdpa_device 
*vdpa_dev)
        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,
                                  unsigned int offset,
                                  void *buf, unsigned int len)
@@ -392,6 +397,7 @@ static const struct vdpa_config_ops ifc_vdpa_ops = {
        .get_device_id  = ifcvf_vdpa_get_device_id,
        .get_vendor_id  = ifcvf_vdpa_get_vendor_id,
        .get_vq_align   = ifcvf_vdpa_get_vq_align,
+       .get_config_size        = ifcvf_vdpa_get_config_size,
        .get_config     = ifcvf_vdpa_get_config,
        .set_config     = ifcvf_vdpa_set_config,
        .set_config_cb  = ifcvf_vdpa_set_config_cb,
diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c 
b/drivers/vdpa/mlx5/net/mlx5_vnet.c
index 577ff786f11b..53584a43e311 100644
--- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
+++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
@@ -1810,6 +1810,11 @@ static void mlx5_vdpa_set_status(struct vdpa_device 
*vdev, u8 status)
        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,
                                 unsigned int len)
 {
@@ -1901,6 +1906,7 @@ static const struct vdpa_config_ops mlx5_vdpa_ops = {
        .get_vendor_id = mlx5_vdpa_get_vendor_id,
        .get_status = mlx5_vdpa_get_status,
        .set_status = mlx5_vdpa_set_status,
+       .get_config_size = mlx5_vdpa_get_config_size,
        .get_config = mlx5_vdpa_get_config,
        .set_config = mlx5_vdpa_set_config,
        .get_generation = mlx5_vdpa_get_generation,
diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c
index c95e1d4efe2b..9bdc3f4e254f 100644
--- a/drivers/vdpa/vdpa_sim/vdpa_sim.c
+++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c
@@ -584,6 +584,13 @@ static void vdpasim_set_status(struct vdpa_device *vdpa, 
u8 status)
        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,
                             void *buf, unsigned int len)
 {
@@ -703,6 +710,7 @@ static const struct vdpa_config_ops vdpasim_config_ops = {
        .get_vendor_id          = vdpasim_get_vendor_id,
        .get_status             = vdpasim_get_status,
        .set_status             = vdpasim_set_status,
+       .get_config_size        = vdpasim_get_config_size,
        .get_config             = vdpasim_get_config,
        .set_config             = vdpasim_set_config,
        .get_generation         = vdpasim_get_generation,
@@ -730,6 +738,7 @@ static const struct vdpa_config_ops 
vdpasim_batch_config_ops = {
        .get_vendor_id          = vdpasim_get_vendor_id,
        .get_status             = vdpasim_get_status,
        .set_status             = vdpasim_set_status,
+       .get_config_size        = vdpasim_get_config_size,
        .get_config             = vdpasim_get_config,
        .set_config             = vdpasim_set_config,
        .get_generation         = vdpasim_get_generation,
diff --git a/drivers/vdpa/virtio_pci/vp_vdpa.c 
b/drivers/vdpa/virtio_pci/vp_vdpa.c
index 1321a2fcd088..dc27ec970884 100644
--- a/drivers/vdpa/virtio_pci/vp_vdpa.c
+++ b/drivers/vdpa/virtio_pci/vp_vdpa.c
@@ -295,6 +295,13 @@ static u32 vp_vdpa_get_vq_align(struct vdpa_device *vdpa)
        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,
                               unsigned int offset,
                               void *buf, unsigned int len)
@@ -354,6 +361,7 @@ static const struct vdpa_config_ops vp_vdpa_ops = {
        .get_device_id  = vp_vdpa_get_device_id,
        .get_vendor_id  = vp_vdpa_get_vendor_id,
        .get_vq_align   = vp_vdpa_get_vq_align,
+       .get_config_size = vp_vdpa_get_config_size,
        .get_config     = vp_vdpa_get_config,
        .set_config     = vp_vdpa_set_config,
        .set_config_cb  = vp_vdpa_set_config_cb,
diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h
index 30bc7a7223bb..43824efa13fd 100644
--- a/include/linux/vdpa.h
+++ b/include/linux/vdpa.h
@@ -144,6 +144,9 @@ struct vdpa_iova_range {
  * @set_status:                        Set the device status
  *                             @vdev: vdpa device
  *                             @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
  *                             @vdev: vdpa device
  *                             @offset: offset from the beginning of
@@ -225,6 +228,7 @@ struct vdpa_config_ops {
        u32 (*get_vendor_id)(struct vdpa_device *vdev);
        u8 (*get_status)(struct vdpa_device *vdev);
        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 *buf, unsigned int len);
        void (*set_config)(struct vdpa_device *vdev, unsigned int offset,
-- 
2.25.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#12579): 
https://lists.yoctoproject.org/g/linux-yocto/message/12579
Mute This Topic: https://lists.yoctoproject.org/mt/98921500/21656
Group Owner: linux-yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to