Skip to content

Commit 0fe963d

Browse files
dtatuleamstsirkin
authored andcommitted
vdpa/mlx5: Re-create HW VQs under certain conditions
There are a few conditions under which the hardware VQs need a full teardown and setup: - VQ size changed to something else than default value. Hardware VQ size modification is not supported. - User turns off certain device features: mergeable buffers, checksum virtio 1.0 compliance. In these cases, the TIR and RQT need to be re-created. Add a needs_teardown configuration variable and set it when detecting the above scenarios. On next DRIVER_OK, the resources will be torn down first. Reviewed-by: Cosmin Ratiu <[email protected]> Acked-by: Eugenio Pérez <[email protected]> Signed-off-by: Dragos Tatulea <[email protected]> Message-Id: <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent ffb1aae commit 0fe963d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

drivers/vdpa/mlx5/net/mlx5_vnet.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2390,6 +2390,7 @@ static void mlx5_vdpa_set_vq_num(struct vdpa_device *vdev, u16 idx, u32 num)
23902390
}
23912391

23922392
mvq = &ndev->vqs[idx];
2393+
ndev->needs_teardown = num != mvq->num_ent;
23932394
mvq->num_ent = num;
23942395
}
23952396

@@ -2800,6 +2801,7 @@ static int mlx5_vdpa_set_driver_features(struct vdpa_device *vdev, u64 features)
28002801
struct mlx5_vdpa_dev *mvdev = to_mvdev(vdev);
28012802
struct mlx5_vdpa_net *ndev = to_mlx5_vdpa_ndev(mvdev);
28022803
u64 old_features = mvdev->actual_features;
2804+
u64 diff_features;
28032805
int err;
28042806

28052807
print_features(mvdev, features, true);
@@ -2822,6 +2824,14 @@ static int mlx5_vdpa_set_driver_features(struct vdpa_device *vdev, u64 features)
28222824
}
28232825
}
28242826

2827+
/* When below features diverge from initial device features, VQs need a full teardown. */
2828+
#define NEEDS_TEARDOWN_MASK (BIT_ULL(VIRTIO_NET_F_MRG_RXBUF) | \
2829+
BIT_ULL(VIRTIO_NET_F_CSUM) | \
2830+
BIT_ULL(VIRTIO_F_VERSION_1))
2831+
2832+
diff_features = mvdev->mlx_features ^ mvdev->actual_features;
2833+
ndev->needs_teardown = !!(diff_features & NEEDS_TEARDOWN_MASK);
2834+
28252835
update_cvq_info(mvdev);
28262836
return err;
28272837
}
@@ -3038,6 +3048,7 @@ static void teardown_vq_resources(struct mlx5_vdpa_net *ndev)
30383048
destroy_rqt(ndev);
30393049
teardown_virtqueues(ndev);
30403050
ndev->setup = false;
3051+
ndev->needs_teardown = false;
30413052
}
30423053

30433054
static int setup_cvq_vring(struct mlx5_vdpa_dev *mvdev)
@@ -3078,6 +3089,10 @@ static void mlx5_vdpa_set_status(struct vdpa_device *vdev, u8 status)
30783089
goto err_setup;
30793090
}
30803091
register_link_notifier(ndev);
3092+
3093+
if (ndev->needs_teardown)
3094+
teardown_vq_resources(ndev);
3095+
30813096
if (ndev->setup) {
30823097
err = resume_vqs(ndev);
30833098
if (err) {

drivers/vdpa/mlx5/net/mlx5_vnet.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ struct mlx5_vdpa_net {
5656
struct dentry *rx_dent;
5757
struct dentry *rx_table_dent;
5858
bool setup;
59+
bool needs_teardown;
5960
u32 cur_num_vqs;
6061
u32 rqt_size;
6162
bool nb_registered;

0 commit comments

Comments
 (0)