Re: vdpa/mlx5: Allow CVQ size changes

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


On 2/15/24 2:02 PM, Eugenio Perez Martin wrote:
On Thu, Feb 15, 2024 at 7:55 PM Eugenio Perez Martin
<eperezma@xxxxxxxxxx> wrote:

On Thu, Feb 15, 2024 at 6:05 PM Jonah Palmer <jonah.palmer@xxxxxxxxxx> wrote:

The MLX driver was not updating its control virtqueue size at set_vq_num
and instead always initialized to MLX5_CVQ_MAX_ENT (16) at

Qemu would try to set the size to 64 by default, however, because the
CVQ size always was initialized to 16, an error would be thrown when
sending >16 control messages (as used-ring entry 17 is initialized to 0).
For example, starting a guest with x-svq=on and then executing the
following command would produce the error below:

  # for i in {1..20}; do ifconfig eth0 hw ether XX:xx:XX:xx:XX:XX; done

  qemu-system-x86_64: Insufficient written data (0)
  [  435.331223] virtio_net virtio0: Failed to set mac address by vq command.
  SIOCSIFHWADDR: Invalid argument

Signed-off-by: Jonah Palmer <jonah.palmer@xxxxxxxxxx>

Acked-by: Eugenio Pérez <eperezma@xxxxxxxxxx>


  drivers/vdpa/mlx5/net/mlx5_vnet.c | 10 ++++++++--
  1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c
index 778821bab7d9..c74de1fe6a94 100644
--- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
+++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
@@ -2276,9 +2276,15 @@ static void mlx5_vdpa_set_vq_num(struct vdpa_device *vdev, u16 idx, u32 num)
         struct mlx5_vdpa_net *ndev = to_mlx5_vdpa_ndev(mvdev);
         struct mlx5_vdpa_virtqueue *mvq;

-       if (!is_index_valid(mvdev, idx) || is_ctrl_vq_idx(mvdev, idx))
+       if (!is_index_valid(mvdev, idx))

+        if (is_ctrl_vq_idx(mvdev, idx)) {
+                struct mlx5_control_vq *cvq = &mvdev->cvq;
+                cvq->vring.vring.num = num;
+                return;
+        }
         mvq = &ndev->vqs[idx];
         mvq->num_ent = num;
@@ -2963,7 +2969,7 @@ static int setup_cvq_vring(struct mlx5_vdpa_dev *mvdev)
                 u16 idx = cvq->vring.last_avail_idx;

                 err = vringh_init_iotlb(&cvq->vring, mvdev->actual_features,
-                                       MLX5_CVQ_MAX_ENT, false,

Actually there is one nitpick: MLX5_CVQ_MAX_ENT macro should be
deleted as there are no more usages :). With that change and Dragos'
request you can post a V2 with my Acked-by included.


Will do, thank you!


+                                       cvq->vring.vring.num, false,
                                         (struct vring_desc *)(uintptr_t)cvq->desc_addr,
                                         (struct vring_avail *)(uintptr_t)cvq->driver_addr,
                                         (struct vring_used *)(uintptr_t)cvq->device_addr);

[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux