Skip to content

Commit f70080c

Browse files
dtatuleamstsirkin
authored andcommitted
vdpa/mlx5: Add support for modifying the virtio_version VQ field
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]>
1 parent 4a19f29 commit f70080c

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

drivers/vdpa/mlx5/net/mlx5_vnet.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,6 +1283,10 @@ static int modify_virtqueue(struct mlx5_vdpa_net *ndev,
12831283
if (mvq->modified_fields & MLX5_VIRTQ_MODIFY_MASK_VIRTIO_Q_USED_IDX)
12841284
MLX5_SET(virtio_net_q_object, obj_context, hw_used_index, mvq->used_idx);
12851285

1286+
if (mvq->modified_fields & MLX5_VIRTQ_MODIFY_MASK_QUEUE_VIRTIO_VERSION)
1287+
MLX5_SET(virtio_q, vq_ctx, virtio_version_1_0,
1288+
!!(ndev->mvdev.actual_features & BIT_ULL(VIRTIO_F_VERSION_1)));
1289+
12861290
if (mvq->modified_fields & MLX5_VIRTQ_MODIFY_MASK_VIRTIO_Q_MKEY) {
12871291
vq_mr = mvdev->mr[mvdev->group2asid[MLX5_VDPA_DATAVQ_GROUP]];
12881292

@@ -2709,6 +2713,7 @@ static int mlx5_vdpa_set_driver_features(struct vdpa_device *vdev, u64 features)
27092713
{
27102714
struct mlx5_vdpa_dev *mvdev = to_mvdev(vdev);
27112715
struct mlx5_vdpa_net *ndev = to_mlx5_vdpa_ndev(mvdev);
2716+
u64 old_features = mvdev->actual_features;
27122717
int err;
27132718

27142719
print_features(mvdev, features, true);
@@ -2723,6 +2728,17 @@ static int mlx5_vdpa_set_driver_features(struct vdpa_device *vdev, u64 features)
27232728
else
27242729
ndev->rqt_size = 1;
27252730

2731+
/* Interested in changes of vq features only. */
2732+
if (get_features(old_features) != get_features(mvdev->actual_features)) {
2733+
for (int i = 0; i < mvdev->max_vqs; ++i) {
2734+
struct mlx5_vdpa_virtqueue *mvq = &ndev->vqs[i];
2735+
2736+
mvq->modified_fields |= (
2737+
MLX5_VIRTQ_MODIFY_MASK_QUEUE_VIRTIO_VERSION
2738+
);
2739+
}
2740+
}
2741+
27262742
update_cvq_info(mvdev);
27272743
return err;
27282744
}

include/linux/mlx5/mlx5_ifc_vdpa.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ enum {
148148
MLX5_VIRTQ_MODIFY_MASK_VIRTIO_Q_ADDRS = (u64)1 << 6,
149149
MLX5_VIRTQ_MODIFY_MASK_VIRTIO_Q_AVAIL_IDX = (u64)1 << 7,
150150
MLX5_VIRTQ_MODIFY_MASK_VIRTIO_Q_USED_IDX = (u64)1 << 8,
151+
MLX5_VIRTQ_MODIFY_MASK_QUEUE_VIRTIO_VERSION = (u64)1 << 10,
151152
MLX5_VIRTQ_MODIFY_MASK_VIRTIO_Q_MKEY = (u64)1 << 11,
152153
MLX5_VIRTQ_MODIFY_MASK_DESC_GROUP_MKEY = (u64)1 << 14,
153154
};

0 commit comments

Comments
 (0)