vdpa/mlx5: Remove mtu field from vdpa net device
authorEli Cohen <elic@nvidia.com>
Thu, 9 Sep 2021 12:36:33 +0000 (15:36 +0300)
committerMichael S. Tsirkin <mst@redhat.com>
Mon, 1 Nov 2021 09:26:47 +0000 (05:26 -0400)
No need to save the mtu int the net device struct. We can save it in the
config struct which cannot be modified.

Moreover, move the initialization to. mlx5_vdpa_set_features() callback
is not the right place to put it.

Signed-off-by: Eli Cohen <elic@nvidia.com>
Link: https://lore.kernel.org/r/20210909123635.30884-2-elic@nvidia.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/vdpa/mlx5/net/mlx5_vnet.c

index bd56de7484dcb1d72d2b99cbeef7932adfb81888..570bd5a8e068c56b472f237a6b0d8bbb3137f07f 100644 (file)
@@ -159,7 +159,6 @@ struct mlx5_vdpa_net {
        struct mlx5_fc *rx_counter;
        struct mlx5_flow_handle *rx_rule;
        bool setup;
-       u16 mtu;
        u32 cur_num_vqs;
 };
 
@@ -1942,8 +1941,6 @@ static int mlx5_vdpa_set_features(struct vdpa_device *vdev, u64 features)
                return err;
 
        ndev->mvdev.actual_features = features & ndev->mvdev.mlx_features;
-       ndev->config.mtu = cpu_to_mlx5vdpa16(mvdev, ndev->mtu);
-       ndev->config.status |= cpu_to_mlx5vdpa16(mvdev, VIRTIO_NET_S_LINK_UP);
        update_cvq_info(mvdev);
        return err;
 }
@@ -2413,6 +2410,7 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name)
        struct mlx5_vdpa_net *ndev;
        struct mlx5_core_dev *mdev;
        u32 max_vqs;
+       u16 mtu;
        int err;
 
        if (mgtdev->ndev)
@@ -2440,10 +2438,13 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name)
        init_mvqs(ndev);
        mutex_init(&ndev->reslock);
        config = &ndev->config;
-       err = query_mtu(mdev, &ndev->mtu);
+       err = query_mtu(mdev, &mtu);
        if (err)
                goto err_mtu;
 
+       ndev->config.mtu = cpu_to_mlx5vdpa16(mvdev, mtu);
+       ndev->config.status |= cpu_to_mlx5vdpa16(mvdev, VIRTIO_NET_S_LINK_UP);
+
        err = mlx5_query_nic_vport_mac_address(mdev, 0, 0, config->mac);
        if (err)
                goto err_mtu;