Skip to content

Commit 033779a

Browse files
siwliu-kernelmstsirkin
authored andcommitted
vdpa/mlx5: make MTU/STATUS presence conditional on feature bits
The spec says: mtu only exists if VIRTIO_NET_F_MTU is set status only exists if VIRTIO_NET_F_STATUS is set We should only present MTU and STATUS conditionally depending on the feature bits. Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com> Reviewed-by: Eli Cohen <elic@nvidia.com> Message-Id: <1675725124-7375-6-git-send-email-si-wei.liu@oracle.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
1 parent dbb6f1c commit 033779a

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

drivers/vdpa/mlx5/net/mlx5_vnet.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3046,6 +3046,8 @@ static int event_handler(struct notifier_block *nb, unsigned long event, void *p
30463046
struct mlx5_vdpa_wq_ent *wqent;
30473047

30483048
if (event == MLX5_EVENT_TYPE_PORT_CHANGE) {
3049+
if (!(ndev->mvdev.actual_features & BIT_ULL(VIRTIO_NET_F_STATUS)))
3050+
return NOTIFY_DONE;
30493051
switch (eqe->sub_type) {
30503052
case MLX5_PORT_CHANGE_SUBTYPE_DOWN:
30513053
case MLX5_PORT_CHANGE_SUBTYPE_ACTIVE:
@@ -3155,16 +3157,20 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name,
31553157
goto err_alloc;
31563158
}
31573159

3158-
err = query_mtu(mdev, &mtu);
3159-
if (err)
3160-
goto err_alloc;
3160+
if (ndev->mvdev.mlx_features & BIT_ULL(VIRTIO_NET_F_MTU)) {
3161+
err = query_mtu(mdev, &mtu);
3162+
if (err)
3163+
goto err_alloc;
31613164

3162-
ndev->config.mtu = cpu_to_mlx5vdpa16(mvdev, mtu);
3165+
ndev->config.mtu = cpu_to_mlx5vdpa16(mvdev, mtu);
3166+
}
31633167

3164-
if (get_link_state(mvdev))
3165-
ndev->config.status |= cpu_to_mlx5vdpa16(mvdev, VIRTIO_NET_S_LINK_UP);
3166-
else
3167-
ndev->config.status &= cpu_to_mlx5vdpa16(mvdev, ~VIRTIO_NET_S_LINK_UP);
3168+
if (ndev->mvdev.mlx_features & BIT_ULL(VIRTIO_NET_F_STATUS)) {
3169+
if (get_link_state(mvdev))
3170+
ndev->config.status |= cpu_to_mlx5vdpa16(mvdev, VIRTIO_NET_S_LINK_UP);
3171+
else
3172+
ndev->config.status &= cpu_to_mlx5vdpa16(mvdev, ~VIRTIO_NET_S_LINK_UP);
3173+
}
31683174

31693175
if (add_config->mask & (1 << VDPA_ATTR_DEV_NET_CFG_MACADDR)) {
31703176
memcpy(ndev->config.mac, add_config->net.mac, ETH_ALEN);

0 commit comments

Comments
 (0)