Skip to content

Commit 27e74c6

Browse files
dtatuleamstsirkin
authored andcommitted
vdpa/mlx5: Enable hw support for vq descriptor mapping
Vq descriptor mappings are supported in hardware by filling in an additional mkey which contains the descriptor mappings to the hw vq. A previous patch in this series added support for hw mkey (mr) creation for ASID 1. This patch fills in both the vq data and vq descriptor mkeys based on group ASID mapping. The feature is signaled to the vdpa core through the presence of the .get_vq_desc_group op. Acked-by: Jason Wang <jasowang@redhat.com> Acked-by: Eugenio Pérez <eperezma@redhat.com> Signed-off-by: Dragos Tatulea <dtatulea@nvidia.com> Message-Id: <20231018171456.1624030-16-dtatulea@nvidia.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
1 parent c5c0b1c commit 27e74c6

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

drivers/vdpa/mlx5/net/mlx5_vnet.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,7 @@ static int create_virtqueue(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtque
864864
u32 out[MLX5_ST_SZ_DW(create_virtio_net_q_out)] = {};
865865
struct mlx5_vdpa_dev *mvdev = &ndev->mvdev;
866866
struct mlx5_vdpa_mr *vq_mr;
867+
struct mlx5_vdpa_mr *vq_desc_mr;
867868
void *obj_context;
868869
u16 mlx_features;
869870
void *cmd_hdr;
@@ -919,6 +920,11 @@ static int create_virtqueue(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtque
919920
vq_mr = mvdev->mr[mvdev->group2asid[MLX5_VDPA_DATAVQ_GROUP]];
920921
if (vq_mr)
921922
MLX5_SET(virtio_q, vq_ctx, virtio_q_mkey, vq_mr->mkey);
923+
924+
vq_desc_mr = mvdev->mr[mvdev->group2asid[MLX5_VDPA_DATAVQ_DESC_GROUP]];
925+
if (vq_desc_mr && MLX5_CAP_DEV_VDPA_EMULATION(mvdev->mdev, desc_group_mkey_supported))
926+
MLX5_SET(virtio_q, vq_ctx, desc_group_mkey, vq_desc_mr->mkey);
927+
922928
MLX5_SET(virtio_q, vq_ctx, umem_1_id, mvq->umem1.id);
923929
MLX5_SET(virtio_q, vq_ctx, umem_1_size, mvq->umem1.size);
924930
MLX5_SET(virtio_q, vq_ctx, umem_2_id, mvq->umem2.id);
@@ -2306,6 +2312,16 @@ static u32 mlx5_vdpa_get_vq_group(struct vdpa_device *vdev, u16 idx)
23062312
return MLX5_VDPA_DATAVQ_GROUP;
23072313
}
23082314

2315+
static u32 mlx5_vdpa_get_vq_desc_group(struct vdpa_device *vdev, u16 idx)
2316+
{
2317+
struct mlx5_vdpa_dev *mvdev = to_mvdev(vdev);
2318+
2319+
if (is_ctrl_vq_idx(mvdev, idx))
2320+
return MLX5_VDPA_CVQ_GROUP;
2321+
2322+
return MLX5_VDPA_DATAVQ_DESC_GROUP;
2323+
}
2324+
23092325
static u64 mlx_to_vritio_features(u16 dev_features)
23102326
{
23112327
u64 result = 0;
@@ -3215,6 +3231,7 @@ static const struct vdpa_config_ops mlx5_vdpa_ops = {
32153231
.get_vq_irq = mlx5_get_vq_irq,
32163232
.get_vq_align = mlx5_vdpa_get_vq_align,
32173233
.get_vq_group = mlx5_vdpa_get_vq_group,
3234+
.get_vq_desc_group = mlx5_vdpa_get_vq_desc_group, /* Op disabled if not supported. */
32183235
.get_device_features = mlx5_vdpa_get_device_features,
32193236
.get_backend_features = mlx5_vdpa_get_backend_features,
32203237
.set_driver_features = mlx5_vdpa_set_driver_features,
@@ -3314,6 +3331,7 @@ struct mlx5_vdpa_mgmtdev {
33143331
struct vdpa_mgmt_dev mgtdev;
33153332
struct mlx5_adev *madev;
33163333
struct mlx5_vdpa_net *ndev;
3334+
struct vdpa_config_ops vdpa_ops;
33173335
};
33183336

33193337
static int config_func_mtu(struct mlx5_core_dev *mdev, u16 mtu)
@@ -3427,7 +3445,7 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name,
34273445
max_vqs = 2;
34283446
}
34293447

3430-
ndev = vdpa_alloc_device(struct mlx5_vdpa_net, mvdev.vdev, mdev->device, &mlx5_vdpa_ops,
3448+
ndev = vdpa_alloc_device(struct mlx5_vdpa_net, mvdev.vdev, mdev->device, &mgtdev->vdpa_ops,
34313449
MLX5_VDPA_NUMVQ_GROUPS, MLX5_VDPA_NUM_AS, name, false);
34323450
if (IS_ERR(ndev))
34333451
return PTR_ERR(ndev);
@@ -3600,6 +3618,10 @@ static int mlx5v_probe(struct auxiliary_device *adev,
36003618
MLX5_CAP_DEV_VDPA_EMULATION(mdev, max_num_virtio_queues) + 1;
36013619
mgtdev->mgtdev.supported_features = get_supported_features(mdev);
36023620
mgtdev->madev = madev;
3621+
mgtdev->vdpa_ops = mlx5_vdpa_ops;
3622+
3623+
if (!MLX5_CAP_DEV_VDPA_EMULATION(mdev, desc_group_mkey_supported))
3624+
mgtdev->vdpa_ops.get_vq_desc_group = NULL;
36033625

36043626
err = vdpa_mgmtdev_register(&mgtdev->mgtdev);
36053627
if (err)

include/linux/mlx5/mlx5_ifc_vdpa.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ struct mlx5_ifc_virtio_q_bits {
7474
u8 reserved_at_320[0x8];
7575
u8 pd[0x18];
7676

77-
u8 reserved_at_340[0xc0];
77+
u8 reserved_at_340[0x20];
78+
79+
u8 desc_group_mkey[0x20];
80+
81+
u8 reserved_at_380[0x80];
7882
};
7983

8084
struct mlx5_ifc_virtio_net_q_object_bits {
@@ -141,6 +145,7 @@ enum {
141145
MLX5_VIRTQ_MODIFY_MASK_STATE = (u64)1 << 0,
142146
MLX5_VIRTQ_MODIFY_MASK_DIRTY_BITMAP_PARAMS = (u64)1 << 3,
143147
MLX5_VIRTQ_MODIFY_MASK_DIRTY_BITMAP_DUMP_ENABLE = (u64)1 << 4,
148+
MLX5_VIRTQ_MODIFY_MASK_DESC_GROUP_MKEY = (u64)1 << 14,
144149
};
145150

146151
enum {

0 commit comments

Comments
 (0)