Skip to content

Commit 1835ed4

Browse files
dtatuleamstsirkin
authored andcommitted
vdpa/mlx5: Initialize and reset device with one queue pair
The virtio spec says that a vdpa device should start off with one queue pair. The driver is already compliant. This patch moves the initialization to device add and reset times. This is done in preparation for the pre-creation of hardware virtqueues at device add time. Signed-off-by: Dragos Tatulea <[email protected]> Reviewed-by: Cosmin Ratiu <[email protected]> Message-Id: <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]> Acked-by: Eugenio Pérez <[email protected]>
1 parent a366465 commit 1835ed4

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

drivers/vdpa/mlx5/net/mlx5_vnet.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ MODULE_LICENSE("Dual BSD/GPL");
4848

4949
#define MLX5V_UNTAGGED 0x1000
5050

51+
/* Device must start with 1 queue pair, as per VIRTIO v1.2 spec, section
52+
* 5.1.6.5.5 "Device operation in multiqueue mode":
53+
*
54+
* Multiqueue is disabled by default.
55+
* The driver enables multiqueue by sending a command using class
56+
* VIRTIO_NET_CTRL_MQ. The command selects the mode of multiqueue
57+
* operation, as follows: ...
58+
*/
59+
#define MLX5V_DEFAULT_VQ_COUNT 2
60+
5161
struct mlx5_vdpa_cq_buf {
5262
struct mlx5_frag_buf_ctrl fbc;
5363
struct mlx5_frag_buf frag_buf;
@@ -2713,16 +2723,6 @@ static int mlx5_vdpa_set_driver_features(struct vdpa_device *vdev, u64 features)
27132723
else
27142724
ndev->rqt_size = 1;
27152725

2716-
/* Device must start with 1 queue pair, as per VIRTIO v1.2 spec, section
2717-
* 5.1.6.5.5 "Device operation in multiqueue mode":
2718-
*
2719-
* Multiqueue is disabled by default.
2720-
* The driver enables multiqueue by sending a command using class
2721-
* VIRTIO_NET_CTRL_MQ. The command selects the mode of multiqueue
2722-
* operation, as follows: ...
2723-
*/
2724-
ndev->cur_num_vqs = 2;
2725-
27262726
update_cvq_info(mvdev);
27272727
return err;
27282728
}
@@ -3040,7 +3040,7 @@ static int mlx5_vdpa_compat_reset(struct vdpa_device *vdev, u32 flags)
30403040
mlx5_vdpa_destroy_mr_resources(&ndev->mvdev);
30413041
ndev->mvdev.status = 0;
30423042
ndev->mvdev.suspended = false;
3043-
ndev->cur_num_vqs = 0;
3043+
ndev->cur_num_vqs = MLX5V_DEFAULT_VQ_COUNT;
30443044
ndev->mvdev.cvq.received_desc = 0;
30453045
ndev->mvdev.cvq.completed_desc = 0;
30463046
memset(ndev->event_cbs, 0, sizeof(*ndev->event_cbs) * (mvdev->max_vqs + 1));
@@ -3643,6 +3643,7 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name,
36433643
err = -ENOMEM;
36443644
goto err_alloc;
36453645
}
3646+
ndev->cur_num_vqs = MLX5V_DEFAULT_VQ_COUNT;
36463647

36473648
init_mvqs(ndev);
36483649
allocate_irqs(ndev);

0 commit comments

Comments
 (0)