Skip to content

Commit 03dd63c

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 <[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]> Reviewed-by: Si-Wei Liu <[email protected]> Tested-by: Si-Wei Liu <[email protected]> Tested-by: Lei Yang <[email protected]>
1 parent 55229ea commit 03dd63c

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
@@ -863,6 +863,7 @@ static int create_virtqueue(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtque
863863
u32 out[MLX5_ST_SZ_DW(create_virtio_net_q_out)] = {};
864864
struct mlx5_vdpa_dev *mvdev = &ndev->mvdev;
865865
struct mlx5_vdpa_mr *vq_mr;
866+
struct mlx5_vdpa_mr *vq_desc_mr;
866867
void *obj_context;
867868
u16 mlx_features;
868869
void *cmd_hdr;
@@ -918,6 +919,11 @@ static int create_virtqueue(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtque
918919
vq_mr = mvdev->mr[mvdev->group2asid[MLX5_VDPA_DATAVQ_GROUP]];
919920
if (vq_mr)
920921
MLX5_SET(virtio_q, vq_ctx, virtio_q_mkey, vq_mr->mkey);
922+
923+
vq_desc_mr = mvdev->mr[mvdev->group2asid[MLX5_VDPA_DATAVQ_DESC_GROUP]];
924+
if (vq_desc_mr && MLX5_CAP_DEV_VDPA_EMULATION(mvdev->mdev, desc_group_mkey_supported))
925+
MLX5_SET(virtio_q, vq_ctx, desc_group_mkey, vq_desc_mr->mkey);
926+
921927
MLX5_SET(virtio_q, vq_ctx, umem_1_id, mvq->umem1.id);
922928
MLX5_SET(virtio_q, vq_ctx, umem_1_size, mvq->umem1.size);
923929
MLX5_SET(virtio_q, vq_ctx, umem_2_id, mvq->umem2.id);
@@ -2305,6 +2311,16 @@ static u32 mlx5_vdpa_get_vq_group(struct vdpa_device *vdev, u16 idx)
23052311
return MLX5_VDPA_DATAVQ_GROUP;
23062312
}
23072313

2314+
static u32 mlx5_vdpa_get_vq_desc_group(struct vdpa_device *vdev, u16 idx)
2315+
{
2316+
struct mlx5_vdpa_dev *mvdev = to_mvdev(vdev);
2317+
2318+
if (is_ctrl_vq_idx(mvdev, idx))
2319+
return MLX5_VDPA_CVQ_GROUP;
2320+
2321+
return MLX5_VDPA_DATAVQ_DESC_GROUP;
2322+
}
2323+
23082324
static u64 mlx_to_vritio_features(u16 dev_features)
23092325
{
23102326
u64 result = 0;
@@ -3209,6 +3225,7 @@ static const struct vdpa_config_ops mlx5_vdpa_ops = {
32093225
.get_vq_irq = mlx5_get_vq_irq,
32103226
.get_vq_align = mlx5_vdpa_get_vq_align,
32113227
.get_vq_group = mlx5_vdpa_get_vq_group,
3228+
.get_vq_desc_group = mlx5_vdpa_get_vq_desc_group, /* Op disabled if not supported. */
32123229
.get_device_features = mlx5_vdpa_get_device_features,
32133230
.set_driver_features = mlx5_vdpa_set_driver_features,
32143231
.get_driver_features = mlx5_vdpa_get_driver_features,
@@ -3307,6 +3324,7 @@ struct mlx5_vdpa_mgmtdev {
33073324
struct vdpa_mgmt_dev mgtdev;
33083325
struct mlx5_adev *madev;
33093326
struct mlx5_vdpa_net *ndev;
3327+
struct vdpa_config_ops vdpa_ops;
33103328
};
33113329

33123330
static int config_func_mtu(struct mlx5_core_dev *mdev, u16 mtu)
@@ -3420,7 +3438,7 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name,
34203438
max_vqs = 2;
34213439
}
34223440

3423-
ndev = vdpa_alloc_device(struct mlx5_vdpa_net, mvdev.vdev, mdev->device, &mlx5_vdpa_ops,
3441+
ndev = vdpa_alloc_device(struct mlx5_vdpa_net, mvdev.vdev, mdev->device, &mgtdev->vdpa_ops,
34243442
MLX5_VDPA_NUMVQ_GROUPS, MLX5_VDPA_NUM_AS, name, false);
34253443
if (IS_ERR(ndev))
34263444
return PTR_ERR(ndev);
@@ -3593,6 +3611,10 @@ static int mlx5v_probe(struct auxiliary_device *adev,
35933611
MLX5_CAP_DEV_VDPA_EMULATION(mdev, max_num_virtio_queues) + 1;
35943612
mgtdev->mgtdev.supported_features = get_supported_features(mdev);
35953613
mgtdev->madev = madev;
3614+
mgtdev->vdpa_ops = mlx5_vdpa_ops;
3615+
3616+
if (!MLX5_CAP_DEV_VDPA_EMULATION(mdev, desc_group_mkey_supported))
3617+
mgtdev->vdpa_ops.get_vq_desc_group = NULL;
35963618

35973619
err = vdpa_mgmtdev_register(&mgtdev->mgtdev);
35983620
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)