diff options
Diffstat (limited to 'drivers/net/xen-netback/interface.c')
-rw-r--r-- | drivers/net/xen-netback/interface.c | 59 |
1 files changed, 11 insertions, 48 deletions
diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c index c6759b1ec18d..a134d52f55b4 100644 --- a/drivers/net/xen-netback/interface.c +++ b/drivers/net/xen-netback/interface.c | |||
@@ -43,6 +43,9 @@ | |||
43 | #define XENVIF_QUEUE_LENGTH 32 | 43 | #define XENVIF_QUEUE_LENGTH 32 |
44 | #define XENVIF_NAPI_WEIGHT 64 | 44 | #define XENVIF_NAPI_WEIGHT 64 |
45 | 45 | ||
46 | /* Number of bytes allowed on the internal guest Rx queue. */ | ||
47 | #define XENVIF_RX_QUEUE_BYTES (XEN_NETIF_RX_RING_SIZE/2 * PAGE_SIZE) | ||
48 | |||
46 | /* This function is used to set SKBTX_DEV_ZEROCOPY as well as | 49 | /* This function is used to set SKBTX_DEV_ZEROCOPY as well as |
47 | * increasing the inflight counter. We need to increase the inflight | 50 | * increasing the inflight counter. We need to increase the inflight |
48 | * counter because core driver calls into xenvif_zerocopy_callback | 51 | * counter because core driver calls into xenvif_zerocopy_callback |
@@ -63,7 +66,8 @@ void xenvif_skb_zerocopy_complete(struct xenvif_queue *queue) | |||
63 | int xenvif_schedulable(struct xenvif *vif) | 66 | int xenvif_schedulable(struct xenvif *vif) |
64 | { | 67 | { |
65 | return netif_running(vif->dev) && | 68 | return netif_running(vif->dev) && |
66 | test_bit(VIF_STATUS_CONNECTED, &vif->status); | 69 | test_bit(VIF_STATUS_CONNECTED, &vif->status) && |
70 | !vif->disabled; | ||
67 | } | 71 | } |
68 | 72 | ||
69 | static irqreturn_t xenvif_tx_interrupt(int irq, void *dev_id) | 73 | static irqreturn_t xenvif_tx_interrupt(int irq, void *dev_id) |
@@ -104,16 +108,7 @@ int xenvif_poll(struct napi_struct *napi, int budget) | |||
104 | static irqreturn_t xenvif_rx_interrupt(int irq, void *dev_id) | 108 | static irqreturn_t xenvif_rx_interrupt(int irq, void *dev_id) |
105 | { | 109 | { |
106 | struct xenvif_queue *queue = dev_id; | 110 | struct xenvif_queue *queue = dev_id; |
107 | struct netdev_queue *net_queue = | ||
108 | netdev_get_tx_queue(queue->vif->dev, queue->id); | ||
109 | 111 | ||
110 | /* QUEUE_STATUS_RX_PURGE_EVENT is only set if either QDisc was off OR | ||
111 | * the carrier went down and this queue was previously blocked | ||
112 | */ | ||
113 | if (unlikely(netif_tx_queue_stopped(net_queue) || | ||
114 | (!netif_carrier_ok(queue->vif->dev) && | ||
115 | test_bit(QUEUE_STATUS_RX_STALLED, &queue->status)))) | ||
116 | set_bit(QUEUE_STATUS_RX_PURGE_EVENT, &queue->status); | ||
117 | xenvif_kick_thread(queue); | 112 | xenvif_kick_thread(queue); |
118 | 113 | ||
119 | return IRQ_HANDLED; | 114 | return IRQ_HANDLED; |
@@ -141,24 +136,13 @@ void xenvif_wake_queue(struct xenvif_queue *queue) | |||
141 | netif_tx_wake_queue(netdev_get_tx_queue(dev, id)); | 136 | netif_tx_wake_queue(netdev_get_tx_queue(dev, id)); |
142 | } | 137 | } |
143 | 138 | ||
144 | /* Callback to wake the queue's thread and turn the carrier off on timeout */ | ||
145 | static void xenvif_rx_stalled(unsigned long data) | ||
146 | { | ||
147 | struct xenvif_queue *queue = (struct xenvif_queue *)data; | ||
148 | |||
149 | if (xenvif_queue_stopped(queue)) { | ||
150 | set_bit(QUEUE_STATUS_RX_PURGE_EVENT, &queue->status); | ||
151 | xenvif_kick_thread(queue); | ||
152 | } | ||
153 | } | ||
154 | |||
155 | static int xenvif_start_xmit(struct sk_buff *skb, struct net_device *dev) | 139 | static int xenvif_start_xmit(struct sk_buff *skb, struct net_device *dev) |
156 | { | 140 | { |
157 | struct xenvif *vif = netdev_priv(dev); | 141 | struct xenvif *vif = netdev_priv(dev); |
158 | struct xenvif_queue *queue = NULL; | 142 | struct xenvif_queue *queue = NULL; |
159 | unsigned int num_queues = vif->num_queues; | 143 | unsigned int num_queues = vif->num_queues; |
160 | u16 index; | 144 | u16 index; |
161 | int min_slots_needed; | 145 | struct xenvif_rx_cb *cb; |
162 | 146 | ||
163 | BUG_ON(skb->dev != dev); | 147 | BUG_ON(skb->dev != dev); |
164 | 148 | ||
@@ -181,30 +165,10 @@ static int xenvif_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
181 | !xenvif_schedulable(vif)) | 165 | !xenvif_schedulable(vif)) |
182 | goto drop; | 166 | goto drop; |
183 | 167 | ||
184 | /* At best we'll need one slot for the header and one for each | 168 | cb = XENVIF_RX_CB(skb); |
185 | * frag. | 169 | cb->expires = jiffies + rx_drain_timeout_jiffies; |
186 | */ | ||
187 | min_slots_needed = 1 + skb_shinfo(skb)->nr_frags; | ||
188 | 170 | ||
189 | /* If the skb is GSO then we'll also need an extra slot for the | 171 | xenvif_rx_queue_tail(queue, skb); |
190 | * metadata. | ||
191 | */ | ||
192 | if (skb_is_gso(skb)) | ||
193 | min_slots_needed++; | ||
194 | |||
195 | /* If the skb can't possibly fit in the remaining slots | ||
196 | * then turn off the queue to give the ring a chance to | ||
197 | * drain. | ||
198 | */ | ||
199 | if (!xenvif_rx_ring_slots_available(queue, min_slots_needed)) { | ||
200 | queue->rx_stalled.function = xenvif_rx_stalled; | ||
201 | queue->rx_stalled.data = (unsigned long)queue; | ||
202 | netif_tx_stop_queue(netdev_get_tx_queue(dev, queue->id)); | ||
203 | mod_timer(&queue->rx_stalled, | ||
204 | jiffies + rx_drain_timeout_jiffies); | ||
205 | } | ||
206 | |||
207 | skb_queue_tail(&queue->rx_queue, skb); | ||
208 | xenvif_kick_thread(queue); | 172 | xenvif_kick_thread(queue); |
209 | 173 | ||
210 | return NETDEV_TX_OK; | 174 | return NETDEV_TX_OK; |
@@ -498,6 +462,8 @@ int xenvif_init_queue(struct xenvif_queue *queue) | |||
498 | init_timer(&queue->credit_timeout); | 462 | init_timer(&queue->credit_timeout); |
499 | queue->credit_window_start = get_jiffies_64(); | 463 | queue->credit_window_start = get_jiffies_64(); |
500 | 464 | ||
465 | queue->rx_queue_max = XENVIF_RX_QUEUE_BYTES; | ||
466 | |||
501 | skb_queue_head_init(&queue->rx_queue); | 467 | skb_queue_head_init(&queue->rx_queue); |
502 | skb_queue_head_init(&queue->tx_queue); | 468 | skb_queue_head_init(&queue->tx_queue); |
503 | 469 | ||
@@ -529,8 +495,6 @@ int xenvif_init_queue(struct xenvif_queue *queue) | |||
529 | queue->grant_tx_handle[i] = NETBACK_INVALID_HANDLE; | 495 | queue->grant_tx_handle[i] = NETBACK_INVALID_HANDLE; |
530 | } | 496 | } |
531 | 497 | ||
532 | init_timer(&queue->rx_stalled); | ||
533 | |||
534 | return 0; | 498 | return 0; |
535 | } | 499 | } |
536 | 500 | ||
@@ -664,7 +628,6 @@ void xenvif_disconnect(struct xenvif *vif) | |||
664 | netif_napi_del(&queue->napi); | 628 | netif_napi_del(&queue->napi); |
665 | 629 | ||
666 | if (queue->task) { | 630 | if (queue->task) { |
667 | del_timer_sync(&queue->rx_stalled); | ||
668 | kthread_stop(queue->task); | 631 | kthread_stop(queue->task); |
669 | queue->task = NULL; | 632 | queue->task = NULL; |
670 | } | 633 | } |