hv_netvsc: Sync offloading features to VF NIC
authorHaiyang Zhang <haiyangz@microsoft.com>
Thu, 5 Sep 2019 23:23:12 +0000 (23:23 +0000)
committerDavid S. Miller <davem@davemloft.net>
Sat, 7 Sep 2019 15:42:52 +0000 (17:42 +0200)
VF NIC may go down then come up during host servicing events. This
causes the VF NIC offloading feature settings to roll back to the
defaults. This patch can synchronize features from synthetic NIC to
the VF NIC during ndo_set_features (ethtool -K),
and netvsc_register_vf when VF comes back after host events.

Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Cc: Mark Bloch <markb@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/hyperv/netvsc_drv.c

index 1f1192ebcbbd13ee0bcf4a718499a9708184250c..39dddcd8b3cb0129d25c98400cca6692fa8b790c 100644 (file)
@@ -1785,13 +1785,15 @@ static int netvsc_set_features(struct net_device *ndev,
        netdev_features_t change = features ^ ndev->features;
        struct net_device_context *ndevctx = netdev_priv(ndev);
        struct netvsc_device *nvdev = rtnl_dereference(ndevctx->nvdev);
+       struct net_device *vf_netdev = rtnl_dereference(ndevctx->vf_netdev);
        struct ndis_offload_params offloads;
+       int ret = 0;
 
        if (!nvdev || nvdev->destroy)
                return -ENODEV;
 
        if (!(change & NETIF_F_LRO))
-               return 0;
+               goto syncvf;
 
        memset(&offloads, 0, sizeof(struct ndis_offload_params));
 
@@ -1803,7 +1805,19 @@ static int netvsc_set_features(struct net_device *ndev,
                offloads.rsc_ip_v6 = NDIS_OFFLOAD_PARAMETERS_RSC_DISABLED;
        }
 
-       return rndis_filter_set_offload_params(ndev, nvdev, &offloads);
+       ret = rndis_filter_set_offload_params(ndev, nvdev, &offloads);
+
+       if (ret)
+               features ^= NETIF_F_LRO;
+
+syncvf:
+       if (!vf_netdev)
+               return ret;
+
+       vf_netdev->wanted_features = features;
+       netdev_update_features(vf_netdev);
+
+       return ret;
 }
 
 static u32 netvsc_get_msglevel(struct net_device *ndev)
@@ -2181,6 +2195,10 @@ static int netvsc_register_vf(struct net_device *vf_netdev)
 
        dev_hold(vf_netdev);
        rcu_assign_pointer(net_device_ctx->vf_netdev, vf_netdev);
+
+       vf_netdev->wanted_features = ndev->features;
+       netdev_update_features(vf_netdev);
+
        return NOTIFY_OK;
 }