Skip to content

Commit 719d959

Browse files
Cindy Lumstsirkin
authored andcommitted
vdpa/mlx5: update mlx_features with driver state check
Add logic in mlx5_vdpa_set_attr() to ensure the VIRTIO_NET_F_MAC feature bit is properly set only when the device is not yet in the DRIVER_OK (running) state. This makes the MAC address visible in the output of: vdpa dev config show -jp when the device is created without an initial MAC address. Signed-off-by: Cindy Lu <lulu@redhat.com> Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Message-Id: <20260126094848.9601-2-lulu@redhat.com>
1 parent 72ecf75 commit 719d959

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

drivers/vdpa/mlx5/net/mlx5_vnet.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4046,21 +4046,30 @@ static int mlx5_vdpa_set_attr(struct vdpa_mgmt_dev *v_mdev, struct vdpa_device *
40464046
struct mlx5_vdpa_dev *mvdev;
40474047
struct mlx5_vdpa_net *ndev;
40484048
struct mlx5_core_dev *mdev;
4049-
int err = -EOPNOTSUPP;
4049+
int err = 0;
40504050

40514051
mvdev = to_mvdev(dev);
40524052
ndev = to_mlx5_vdpa_ndev(mvdev);
40534053
mdev = mvdev->mdev;
40544054
config = &ndev->config;
40554055

40564056
down_write(&ndev->reslock);
4057-
if (add_config->mask & (1 << VDPA_ATTR_DEV_NET_CFG_MACADDR)) {
4057+
4058+
if (add_config->mask & BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MACADDR)) {
4059+
if (!(ndev->mvdev.status & VIRTIO_CONFIG_S_DRIVER_OK)) {
4060+
ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_NET_F_MAC);
4061+
} else {
4062+
mlx5_vdpa_warn(mvdev, "device running, skip updating MAC\n");
4063+
err = -EBUSY;
4064+
goto out;
4065+
}
40584066
pfmdev = pci_get_drvdata(pci_physfn(mdev->pdev));
40594067
err = mlx5_mpfs_add_mac(pfmdev, config->mac);
40604068
if (!err)
40614069
ether_addr_copy(config->mac, add_config->net.mac);
40624070
}
40634071

4072+
out:
40644073
up_write(&ndev->reslock);
40654074
return err;
40664075
}

0 commit comments

Comments
 (0)