Re: [PATCH v1 2/7] vdpa/mlx5: Distribute RX virtqueues in RQT object

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

 





On 12/8/2021 10:55 PM, Eli Cohen wrote:
On Wed, Dec 08, 2021 at 04:12:33PM -0800, Si-Wei Liu wrote:

On 12/8/2021 12:14 PM, Eli Cohen wrote:
Distribute the available rx virtqueues amongst the available RQT
entries.

RQTs require to have a power of two entries. When creating or modifying
the RQT, use the lowest number of power of two entries that is not less
than the number of rx virtqueues. Distribute them in the available
entries such that some virtqueus may be referenced twice.

This allows to configure any number of virtqueue pairs when multiqueue
is used.

Signed-off-by: Eli Cohen <elic@xxxxxxxxxx>
---
   drivers/vdpa/mlx5/net/mlx5_vnet.c | 30 +++++++-----------------------
   1 file changed, 7 insertions(+), 23 deletions(-)

diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c
index ce2e13135dd8..e1a8a790f213 100644
--- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
+++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
@@ -1261,17 +1261,10 @@ static int create_rqt(struct mlx5_vdpa_net *ndev)
   	MLX5_SET(rqtc, rqtc, list_q_type, MLX5_RQTC_LIST_Q_TYPE_VIRTIO_NET_Q);
   	MLX5_SET(rqtc, rqtc, rqt_max_size, max_rqt);
   	list = MLX5_ADDR_OF(rqtc, rqtc, rq_num[0]);
-	for (i = 0, j = 0; j < max_rqt; j++) {
-		if (!ndev->vqs[j].initialized)
-			continue;
Why the !initialized check is dropped from the new code?
We now access the vqs array with j % ndev->mvdev.max_vqs and that keeps
us in the range of valid indices.
OK. I thought the previous check was more for defensive coding and it doesn't bother if keeping it. Anyway,

Reviewed-by: Si-Wei Liu <si-wei.liu@xxxxxxxxxx>


-
-		if (!vq_is_tx(ndev->vqs[j].index)) {
-			list[i] = cpu_to_be32(ndev->vqs[j].virtq_id);
-			i++;
-		}
-	}
-	MLX5_SET(rqtc, rqtc, rqt_actual_size, i);
+	for (i = 0, j = 0; i < max_rqt; i++, j += 2)
+		list[i] = cpu_to_be32(ndev->vqs[j % ndev->mvdev.max_vqs].virtq_id);
+	MLX5_SET(rqtc, rqtc, rqt_actual_size, max_rqt);
   	err = mlx5_vdpa_create_rqt(&ndev->mvdev, in, inlen, &ndev->res.rqtn);
   	kfree(in);
   	if (err)
@@ -1292,7 +1285,7 @@ static int modify_rqt(struct mlx5_vdpa_net *ndev, int num)
   	int i, j;
   	int err;
-	max_rqt = min_t(int, ndev->cur_num_vqs / 2,
+	max_rqt = min_t(int, roundup_pow_of_two(ndev->cur_num_vqs / 2),
   			1 << MLX5_CAP_GEN(ndev->mvdev.mdev, log_max_rqt_size));
   	if (max_rqt < 1)
   		return -EOPNOTSUPP;
@@ -1308,16 +1301,10 @@ static int modify_rqt(struct mlx5_vdpa_net *ndev, int num)
   	MLX5_SET(rqtc, rqtc, list_q_type, MLX5_RQTC_LIST_Q_TYPE_VIRTIO_NET_Q);
   	list = MLX5_ADDR_OF(rqtc, rqtc, rq_num[0]);
-	for (i = 0, j = 0; j < num; j++) {
-		if (!ndev->vqs[j].initialized)
-			continue;
Ditto.
Same as above.

-Siwei

+	for (i = 0, j = 0; i < max_rqt; i++, j += 2)
+		list[i] = cpu_to_be32(ndev->vqs[j % num].virtq_id);
-		if (!vq_is_tx(ndev->vqs[j].index)) {
-			list[i] = cpu_to_be32(ndev->vqs[j].virtq_id);
-			i++;
-		}
-	}
-	MLX5_SET(rqtc, rqtc, rqt_actual_size, i);
+	MLX5_SET(rqtc, rqtc, rqt_actual_size, max_rqt);
   	err = mlx5_vdpa_modify_rqt(&ndev->mvdev, in, inlen, ndev->res.rqtn);
   	kfree(in);
   	if (err)
@@ -1581,9 +1568,6 @@ static virtio_net_ctrl_ack handle_ctrl_mq(struct mlx5_vdpa_dev *mvdev, u8 cmd)
   			break;
   		}
-		if (newqps & (newqps - 1))
-			break;
-
   		if (!change_num_qps(mvdev, newqps))
   			status = VIRTIO_NET_OK;

_______________________________________________
Virtualization mailing list
Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linuxfoundation.org/mailman/listinfo/virtualization



[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