Skip to content

Commit 79de65e

Browse files
elic307imstsirkin
authored andcommitted
vdpa/mlx5: Report max device capabilities
Configure max supported virtqueues and features on the management device. This info can be retrieved using: $ vdpa mgmtdev show auxiliary/mlx5_core.sf.1: supported_classes net max_supported_vqs 257 dev_features CSUM GUEST_CSUM MTU HOST_TSO4 HOST_TSO6 STATUS CTRL_VQ MQ \ CTRL_MAC_ADDR VERSION_1 ACCESS_PLATFORM Signed-off-by: Eli Cohen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]> Reviewed-by: Si-Wei Liu<[email protected]>
1 parent cd2629f commit 79de65e

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

drivers/vdpa/mlx5/net/mlx5_vnet.c

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1866,22 +1866,29 @@ static u64 mlx_to_vritio_features(u16 dev_features)
18661866
return result;
18671867
}
18681868

1869+
static u64 get_supported_features(struct mlx5_core_dev *mdev)
1870+
{
1871+
u64 mlx_vdpa_features = 0;
1872+
u16 dev_features;
1873+
1874+
dev_features = MLX5_CAP_DEV_VDPA_EMULATION(mdev, device_features_bits_mask);
1875+
mlx_vdpa_features |= mlx_to_vritio_features(dev_features);
1876+
if (MLX5_CAP_DEV_VDPA_EMULATION(mdev, virtio_version_1_0))
1877+
mlx_vdpa_features |= BIT_ULL(VIRTIO_F_VERSION_1);
1878+
mlx_vdpa_features |= BIT_ULL(VIRTIO_F_ACCESS_PLATFORM);
1879+
mlx_vdpa_features |= BIT_ULL(VIRTIO_NET_F_CTRL_VQ);
1880+
mlx_vdpa_features |= BIT_ULL(VIRTIO_NET_F_CTRL_MAC_ADDR);
1881+
mlx_vdpa_features |= BIT_ULL(VIRTIO_NET_F_MQ);
1882+
mlx_vdpa_features |= BIT_ULL(VIRTIO_NET_F_STATUS);
1883+
mlx_vdpa_features |= BIT_ULL(VIRTIO_NET_F_MTU);
1884+
1885+
return mlx_vdpa_features;
1886+
}
1887+
18691888
static u64 mlx5_vdpa_get_device_features(struct vdpa_device *vdev)
18701889
{
18711890
struct mlx5_vdpa_dev *mvdev = to_mvdev(vdev);
18721891
struct mlx5_vdpa_net *ndev = to_mlx5_vdpa_ndev(mvdev);
1873-
u16 dev_features;
1874-
1875-
dev_features = MLX5_CAP_DEV_VDPA_EMULATION(mvdev->mdev, device_features_bits_mask);
1876-
ndev->mvdev.mlx_features |= mlx_to_vritio_features(dev_features);
1877-
if (MLX5_CAP_DEV_VDPA_EMULATION(mvdev->mdev, virtio_version_1_0))
1878-
ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_F_VERSION_1);
1879-
ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_F_ACCESS_PLATFORM);
1880-
ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_NET_F_CTRL_VQ);
1881-
ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_NET_F_CTRL_MAC_ADDR);
1882-
ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_NET_F_MQ);
1883-
ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_NET_F_STATUS);
1884-
ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_NET_F_MTU);
18851892

18861893
print_features(mvdev, ndev->mvdev.mlx_features, false);
18871894
return ndev->mvdev.mlx_features;
@@ -2563,6 +2570,7 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name,
25632570
if (IS_ERR(ndev))
25642571
return PTR_ERR(ndev);
25652572

2573+
ndev->mvdev.mlx_features = mgtdev->mgtdev.supported_features;
25662574
ndev->mvdev.max_vqs = max_vqs;
25672575
mvdev = &ndev->mvdev;
25682576
mvdev->mdev = mdev;
@@ -2696,6 +2704,9 @@ static int mlx5v_probe(struct auxiliary_device *adev,
26962704
mgtdev->mgtdev.id_table = id_table;
26972705
mgtdev->mgtdev.config_attr_mask = BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MACADDR) |
26982706
BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MAX_VQP);
2707+
mgtdev->mgtdev.max_supported_vqs =
2708+
MLX5_CAP_DEV_VDPA_EMULATION(mdev, max_num_virtio_queues) + 1;
2709+
mgtdev->mgtdev.supported_features = get_supported_features(mdev);
26992710
mgtdev->madev = madev;
27002711

27012712
err = vdpa_mgmtdev_register(&mgtdev->mgtdev);

0 commit comments

Comments
 (0)