[PATCH] mlx5: Add support to update the vDPA configuration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is needed for VHOST_VDPA_SET_CONFIG.

Signed-off-by: Carlos Bilbao <cbilbao@xxxxxxxxxxxxxxxx>
---
 drivers/vdpa/mlx5/net/mlx5_vnet.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c
index b56aae3f7be3..da31c743b2b9 100644
--- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
+++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
@@ -2909,14 +2909,32 @@ static void mlx5_vdpa_get_config(struct vdpa_device *vdev, unsigned int offset,
     struct mlx5_vdpa_dev *mvdev = to_mvdev(vdev);
     struct mlx5_vdpa_net *ndev = to_mlx5_vdpa_ndev(mvdev);

-    if (offset + len <= sizeof(struct virtio_net_config))
+    if (offset + len <= sizeof(struct virtio_net_config)) {
         memcpy(buf, (u8 *)&ndev->config + offset, len);
+        }
+        else
+        {
+            printk(KERN_ERR "%s: Offset and length out of bounds\n",
+            __func__);
+        }
+
 }

 static void mlx5_vdpa_set_config(struct vdpa_device *vdev, unsigned int offset, const void *buf,
                  unsigned int len)
 {
-    /* not supported */
+    struct mlx5_vdpa_dev *mvdev = to_mvdev(vdev);
+    struct mlx5_vdpa_net *ndev = to_mlx5_vdpa_ndev(mvdev);
+
+    if (offset + len <= sizeof(struct virtio_net_config))
+    {
+        memcpy((u8 *)&ndev->config + offset, buf, len);
+    }
+    else
+    {
+        printk(KERN_ERR "%s: Offset and length out of bounds\n",
+        __func__);
+    }
 }

 static u32 mlx5_vdpa_get_generation(struct vdpa_device *vdev)
--
2.34.1






[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux