aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/xen-netback/interface.c
diff options
context:
space:
mode:
authorZoltan Kiss <zoltan.kiss@citrix.com>2014-08-04 11:20:57 -0400
committerDavid S. Miller <davem@davemloft.net>2014-08-05 19:04:46 -0400
commit3d1af1df9762e56e563e8fd088a1b4ce2bcfaf8b (patch)
tree958644b13f317f33877a704060e3dc03d1eac118 /drivers/net/xen-netback/interface.c
parentaef4f5b6db654e512ebcccab2a6e50424c05d2f9 (diff)
xen-netback: Using a new state bit instead of carrier
This patch introduces a new state bit VIF_STATUS_CONNECTED to track whether the vif is in a connected state. Using carrier will not work with the next patch in this series, which aims to turn the carrier temporarily off if the guest doesn't seem to be able to receive packets. Signed-off-by: Zoltan Kiss <zoltan.kiss@citrix.com> Signed-off-by: David Vrabel <david.vrabel@citrix.com> Cc: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: xen-devel@lists.xenproject.org v2: - rename the bitshift type to "enum state_bit_shift" here, not in the next patch Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/xen-netback/interface.c')
-rw-r--r--drivers/net/xen-netback/interface.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c
index bd59d9dbf27b..fbdadb3d8220 100644
--- a/drivers/net/xen-netback/interface.c
+++ b/drivers/net/xen-netback/interface.c
@@ -55,7 +55,8 @@ static inline void xenvif_stop_queue(struct xenvif_queue *queue)
55 55
56int xenvif_schedulable(struct xenvif *vif) 56int xenvif_schedulable(struct xenvif *vif)
57{ 57{
58 return netif_running(vif->dev) && netif_carrier_ok(vif->dev); 58 return netif_running(vif->dev) &&
59 test_bit(VIF_STATUS_CONNECTED, &vif->status);
59} 60}
60 61
61static irqreturn_t xenvif_tx_interrupt(int irq, void *dev_id) 62static irqreturn_t xenvif_tx_interrupt(int irq, void *dev_id)
@@ -267,7 +268,7 @@ static void xenvif_down(struct xenvif *vif)
267static int xenvif_open(struct net_device *dev) 268static int xenvif_open(struct net_device *dev)
268{ 269{
269 struct xenvif *vif = netdev_priv(dev); 270 struct xenvif *vif = netdev_priv(dev);
270 if (netif_carrier_ok(dev)) 271 if (test_bit(VIF_STATUS_CONNECTED, &vif->status))
271 xenvif_up(vif); 272 xenvif_up(vif);
272 netif_tx_start_all_queues(dev); 273 netif_tx_start_all_queues(dev);
273 return 0; 274 return 0;
@@ -276,7 +277,7 @@ static int xenvif_open(struct net_device *dev)
276static int xenvif_close(struct net_device *dev) 277static int xenvif_close(struct net_device *dev)
277{ 278{
278 struct xenvif *vif = netdev_priv(dev); 279 struct xenvif *vif = netdev_priv(dev);
279 if (netif_carrier_ok(dev)) 280 if (test_bit(VIF_STATUS_CONNECTED, &vif->status))
280 xenvif_down(vif); 281 xenvif_down(vif);
281 netif_tx_stop_all_queues(dev); 282 netif_tx_stop_all_queues(dev);
282 return 0; 283 return 0;
@@ -528,6 +529,7 @@ void xenvif_carrier_on(struct xenvif *vif)
528 if (!vif->can_sg && vif->dev->mtu > ETH_DATA_LEN) 529 if (!vif->can_sg && vif->dev->mtu > ETH_DATA_LEN)
529 dev_set_mtu(vif->dev, ETH_DATA_LEN); 530 dev_set_mtu(vif->dev, ETH_DATA_LEN);
530 netdev_update_features(vif->dev); 531 netdev_update_features(vif->dev);
532 set_bit(VIF_STATUS_CONNECTED, &vif->status);
531 netif_carrier_on(vif->dev); 533 netif_carrier_on(vif->dev);
532 if (netif_running(vif->dev)) 534 if (netif_running(vif->dev))
533 xenvif_up(vif); 535 xenvif_up(vif);
@@ -625,9 +627,11 @@ void xenvif_carrier_off(struct xenvif *vif)
625 struct net_device *dev = vif->dev; 627 struct net_device *dev = vif->dev;
626 628
627 rtnl_lock(); 629 rtnl_lock();
628 netif_carrier_off(dev); /* discard queued packets */ 630 if (test_and_clear_bit(VIF_STATUS_CONNECTED, &vif->status)) {
629 if (netif_running(dev)) 631 netif_carrier_off(dev); /* discard queued packets */
630 xenvif_down(vif); 632 if (netif_running(dev))
633 xenvif_down(vif);
634 }
631 rtnl_unlock(); 635 rtnl_unlock();
632} 636}
633 637
@@ -656,8 +660,7 @@ void xenvif_disconnect(struct xenvif *vif)
656 unsigned int num_queues = vif->num_queues; 660 unsigned int num_queues = vif->num_queues;
657 unsigned int queue_index; 661 unsigned int queue_index;
658 662
659 if (netif_carrier_ok(vif->dev)) 663 xenvif_carrier_off(vif);
660 xenvif_carrier_off(vif);
661 664
662 for (queue_index = 0; queue_index < num_queues; ++queue_index) { 665 for (queue_index = 0; queue_index < num_queues; ++queue_index) {
663 queue = &vif->queues[queue_index]; 666 queue = &vif->queues[queue_index];