Skip to content

Commit a7f46ba

Browse files
elic307imstsirkin
authored andcommitted
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: Si-Wei Liu <[email protected]> Acked-by: Jason Wang <[email protected]> Signed-off-by: Eli Cohen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent a64917b commit a7f46ba

File tree

1 file changed

+7
-23
lines changed

1 file changed

+7
-23
lines changed

drivers/vdpa/mlx5/net/mlx5_vnet.c

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,17 +1259,10 @@ static int create_rqt(struct mlx5_vdpa_net *ndev)
12591259
MLX5_SET(rqtc, rqtc, list_q_type, MLX5_RQTC_LIST_Q_TYPE_VIRTIO_NET_Q);
12601260
MLX5_SET(rqtc, rqtc, rqt_max_size, max_rqt);
12611261
list = MLX5_ADDR_OF(rqtc, rqtc, rq_num[0]);
1262-
for (i = 0, j = 0; j < max_rqt; j++) {
1263-
if (!ndev->vqs[j].initialized)
1264-
continue;
1265-
1266-
if (!vq_is_tx(ndev->vqs[j].index)) {
1267-
list[i] = cpu_to_be32(ndev->vqs[j].virtq_id);
1268-
i++;
1269-
}
1270-
}
1271-
MLX5_SET(rqtc, rqtc, rqt_actual_size, i);
1262+
for (i = 0, j = 0; i < max_rqt; i++, j += 2)
1263+
list[i] = cpu_to_be32(ndev->vqs[j % ndev->mvdev.max_vqs].virtq_id);
12721264

1265+
MLX5_SET(rqtc, rqtc, rqt_actual_size, max_rqt);
12731266
err = mlx5_vdpa_create_rqt(&ndev->mvdev, in, inlen, &ndev->res.rqtn);
12741267
kfree(in);
12751268
if (err)
@@ -1290,7 +1283,7 @@ static int modify_rqt(struct mlx5_vdpa_net *ndev, int num)
12901283
int i, j;
12911284
int err;
12921285

1293-
max_rqt = min_t(int, ndev->cur_num_vqs / 2,
1286+
max_rqt = min_t(int, roundup_pow_of_two(ndev->cur_num_vqs / 2),
12941287
1 << MLX5_CAP_GEN(ndev->mvdev.mdev, log_max_rqt_size));
12951288
if (max_rqt < 1)
12961289
return -EOPNOTSUPP;
@@ -1306,16 +1299,10 @@ static int modify_rqt(struct mlx5_vdpa_net *ndev, int num)
13061299
MLX5_SET(rqtc, rqtc, list_q_type, MLX5_RQTC_LIST_Q_TYPE_VIRTIO_NET_Q);
13071300

13081301
list = MLX5_ADDR_OF(rqtc, rqtc, rq_num[0]);
1309-
for (i = 0, j = 0; j < num; j++) {
1310-
if (!ndev->vqs[j].initialized)
1311-
continue;
1302+
for (i = 0, j = 0; i < max_rqt; i++, j += 2)
1303+
list[i] = cpu_to_be32(ndev->vqs[j % num].virtq_id);
13121304

1313-
if (!vq_is_tx(ndev->vqs[j].index)) {
1314-
list[i] = cpu_to_be32(ndev->vqs[j].virtq_id);
1315-
i++;
1316-
}
1317-
}
1318-
MLX5_SET(rqtc, rqtc, rqt_actual_size, i);
1305+
MLX5_SET(rqtc, rqtc, rqt_actual_size, max_rqt);
13191306
err = mlx5_vdpa_modify_rqt(&ndev->mvdev, in, inlen, ndev->res.rqtn);
13201307
kfree(in);
13211308
if (err)
@@ -1579,9 +1566,6 @@ static virtio_net_ctrl_ack handle_ctrl_mq(struct mlx5_vdpa_dev *mvdev, u8 cmd)
15791566
break;
15801567
}
15811568

1582-
if (newqps & (newqps - 1))
1583-
break;
1584-
15851569
if (!change_num_qps(mvdev, newqps))
15861570
status = VIRTIO_NET_OK;
15871571

0 commit comments

Comments
 (0)