hv_netvsc: move start_remove flag to net_device_context
authorVitaly Kuznetsov <vkuznets@redhat.com>
Fri, 13 May 2016 11:55:20 +0000 (13:55 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 16 May 2016 17:26:00 +0000 (13:26 -0400)
struct netvsc_device is destroyed on mtu change so keeping the
protection flag there is not a good idea. Move it to struct
net_device_context which is preserved.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/hyperv/hyperv_net.h
drivers/net/hyperv/netvsc.c
drivers/net/hyperv/netvsc_drv.c

index 6700a4dca7c82c55340b645a94e1a86d6590d41e..18e9cc8ea47b7f168313b205520b1565884dea83 100644 (file)
@@ -672,6 +672,9 @@ struct net_device_context {
        /* Ethtool settings */
        u8 duplex;
        u32 speed;
+
+       /* the device is going away */
+       bool start_remove;
 };
 
 /* Per netvsc device */
@@ -682,7 +685,6 @@ struct netvsc_device {
 
        atomic_t num_outstanding_sends;
        wait_queue_head_t wait_drain;
-       bool start_remove;
        bool destroy;
 
        /* Receive buffer allocated by us but manages by NetVSP */
index eddce3cdafa8b5cdc7f0421cad77b55dec762068..5e2017bb93f1fde6cee86614da3b57789e76ad8b 100644 (file)
@@ -74,7 +74,6 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device)
        }
 
        init_waitqueue_head(&net_device->wait_drain);
-       net_device->start_remove = false;
        net_device->destroy = false;
        atomic_set(&net_device->open_cnt, 0);
        atomic_set(&net_device->vf_use_cnt, 0);
@@ -691,7 +690,7 @@ static void netvsc_send_completion(struct netvsc_device *net_device,
                        wake_up(&net_device->wait_drain);
 
                if (netif_tx_queue_stopped(netdev_get_tx_queue(ndev, q_idx)) &&
-                   !net_device->start_remove &&
+                   !net_device->nd_ctx->start_remove &&
                    (hv_ringbuf_avail_percent(&channel->outbound) >
                     RING_AVAIL_PERCENT_HIWATER || queue_sends < 1))
                                netif_tx_wake_queue(netdev_get_tx_queue(
index ba3f3f3d48efcb27b34b1aa6be1786d6839751c3..b3fa2cdcb3f6cd9f6bc3709afba9554b5bc52f6e 100644 (file)
@@ -793,7 +793,7 @@ static int netvsc_set_channels(struct net_device *net,
                goto out;
 
  do_set:
-       nvdev->start_remove = true;
+       net_device_ctx->start_remove = true;
        rndis_filter_device_remove(dev);
 
        nvdev->num_chn = channels->combined_count;
@@ -837,6 +837,7 @@ static int netvsc_set_channels(struct net_device *net,
 
  out:
        netvsc_open(net);
+       net_device_ctx->start_remove = false;
 
        return ret;
 
@@ -927,7 +928,7 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu)
 
        num_chn = nvdev->num_chn;
 
-       nvdev->start_remove = true;
+       ndevctx->start_remove = true;
        rndis_filter_device_remove(hdev);
 
        ndev->mtu = mtu;
@@ -943,6 +944,7 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu)
 
 out:
        netvsc_open(ndev);
+       ndevctx->start_remove = false;
 
        return ret;
 }
@@ -1358,6 +1360,9 @@ static int netvsc_probe(struct hv_device *dev,
        }
 
        hv_set_drvdata(dev, net);
+
+       net_device_ctx->start_remove = false;
+
        INIT_DELAYED_WORK(&net_device_ctx->dwork, netvsc_link_change);
        INIT_WORK(&net_device_ctx->work, do_set_multicast);
        INIT_WORK(&net_device_ctx->gwrk.dwrk, netvsc_notify_peers);
@@ -1419,9 +1424,10 @@ static int netvsc_remove(struct hv_device *dev)
                return 0;
        }
 
-       net_device->start_remove = true;
 
        ndev_ctx = netdev_priv(net);
+       ndev_ctx->start_remove = true;
+
        cancel_delayed_work_sync(&ndev_ctx->dwork);
        cancel_work_sync(&ndev_ctx->work);