Commit a7f46ba4 authored by Eli Cohen's avatar Eli Cohen Committed by Michael S. Tsirkin

vdpa/mlx5: Distribute RX virtqueues in RQT object

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.
Reviewed-by: default avatarSi-Wei Liu <si-wei.liu@oracle.com>
Acked-by: default avatarJason Wang <jasowang@redhat.com>
Signed-off-by: default avatarEli Cohen <elic@nvidia.com>
Link: https://lore.kernel.org/r/20220105114646.577224-3-elic@nvidia.comSigned-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent a64917bc
...@@ -1259,17 +1259,10 @@ static int create_rqt(struct mlx5_vdpa_net *ndev) ...@@ -1259,17 +1259,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, list_q_type, MLX5_RQTC_LIST_Q_TYPE_VIRTIO_NET_Q);
MLX5_SET(rqtc, rqtc, rqt_max_size, max_rqt); MLX5_SET(rqtc, rqtc, rqt_max_size, max_rqt);
list = MLX5_ADDR_OF(rqtc, rqtc, rq_num[0]); list = MLX5_ADDR_OF(rqtc, rqtc, rq_num[0]);
for (i = 0, j = 0; j < max_rqt; j++) { for (i = 0, j = 0; i < max_rqt; i++, j += 2)
if (!ndev->vqs[j].initialized) list[i] = cpu_to_be32(ndev->vqs[j % ndev->mvdev.max_vqs].virtq_id);
continue;
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_create_rqt(&ndev->mvdev, in, inlen, &ndev->res.rqtn); err = mlx5_vdpa_create_rqt(&ndev->mvdev, in, inlen, &ndev->res.rqtn);
kfree(in); kfree(in);
if (err) if (err)
...@@ -1290,7 +1283,7 @@ static int modify_rqt(struct mlx5_vdpa_net *ndev, int num) ...@@ -1290,7 +1283,7 @@ static int modify_rqt(struct mlx5_vdpa_net *ndev, int num)
int i, j; int i, j;
int err; 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)); 1 << MLX5_CAP_GEN(ndev->mvdev.mdev, log_max_rqt_size));
if (max_rqt < 1) if (max_rqt < 1)
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -1306,16 +1299,10 @@ static int modify_rqt(struct mlx5_vdpa_net *ndev, int num) ...@@ -1306,16 +1299,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); MLX5_SET(rqtc, rqtc, list_q_type, MLX5_RQTC_LIST_Q_TYPE_VIRTIO_NET_Q);
list = MLX5_ADDR_OF(rqtc, rqtc, rq_num[0]); list = MLX5_ADDR_OF(rqtc, rqtc, rq_num[0]);
for (i = 0, j = 0; j < num; j++) { for (i = 0, j = 0; i < max_rqt; i++, j += 2)
if (!ndev->vqs[j].initialized) list[i] = cpu_to_be32(ndev->vqs[j % num].virtq_id);
continue;
if (!vq_is_tx(ndev->vqs[j].index)) { MLX5_SET(rqtc, rqtc, rqt_actual_size, max_rqt);
list[i] = cpu_to_be32(ndev->vqs[j].virtq_id);
i++;
}
}
MLX5_SET(rqtc, rqtc, rqt_actual_size, i);
err = mlx5_vdpa_modify_rqt(&ndev->mvdev, in, inlen, ndev->res.rqtn); err = mlx5_vdpa_modify_rqt(&ndev->mvdev, in, inlen, ndev->res.rqtn);
kfree(in); kfree(in);
if (err) if (err)
...@@ -1579,9 +1566,6 @@ static virtio_net_ctrl_ack handle_ctrl_mq(struct mlx5_vdpa_dev *mvdev, u8 cmd) ...@@ -1579,9 +1566,6 @@ static virtio_net_ctrl_ack handle_ctrl_mq(struct mlx5_vdpa_dev *mvdev, u8 cmd)
break; break;
} }
if (newqps & (newqps - 1))
break;
if (!change_num_qps(mvdev, newqps)) if (!change_num_qps(mvdev, newqps))
status = VIRTIO_NET_OK; status = VIRTIO_NET_OK;
......
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