aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/virtio_net.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index d50f4fe352b..5450eac9e26 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -47,6 +47,9 @@ struct virtnet_info
47 /* Number of input buffers, and max we've ever had. */ 47 /* Number of input buffers, and max we've ever had. */
48 unsigned int num, max; 48 unsigned int num, max;
49 49
50 /* For cleaning up after transmission. */
51 struct tasklet_struct tasklet;
52
50 /* Receive & send queues. */ 53 /* Receive & send queues. */
51 struct sk_buff_head recv; 54 struct sk_buff_head recv;
52 struct sk_buff_head send; 55 struct sk_buff_head send;
@@ -68,8 +71,13 @@ static void skb_xmit_done(struct virtqueue *svq)
68 71
69 /* Suppress further interrupts. */ 72 /* Suppress further interrupts. */
70 svq->vq_ops->disable_cb(svq); 73 svq->vq_ops->disable_cb(svq);
74
71 /* We were waiting for more output buffers. */ 75 /* We were waiting for more output buffers. */
72 netif_wake_queue(vi->dev); 76 netif_wake_queue(vi->dev);
77
78 /* Make sure we re-xmit last_xmit_skb: if there are no more packets
79 * queued, start_xmit won't be called. */
80 tasklet_schedule(&vi->tasklet);
73} 81}
74 82
75static void receive_skb(struct net_device *dev, struct sk_buff *skb, 83static void receive_skb(struct net_device *dev, struct sk_buff *skb,
@@ -278,6 +286,18 @@ static int xmit_skb(struct virtnet_info *vi, struct sk_buff *skb)
278 return vi->svq->vq_ops->add_buf(vi->svq, sg, num, 0, skb); 286 return vi->svq->vq_ops->add_buf(vi->svq, sg, num, 0, skb);
279} 287}
280 288
289static void xmit_tasklet(unsigned long data)
290{
291 struct virtnet_info *vi = (void *)data;
292
293 netif_tx_lock_bh(vi->dev);
294 if (vi->last_xmit_skb && xmit_skb(vi, vi->last_xmit_skb) == 0) {
295 vi->svq->vq_ops->kick(vi->svq);
296 vi->last_xmit_skb = NULL;
297 }
298 netif_tx_unlock_bh(vi->dev);
299}
300
281static int start_xmit(struct sk_buff *skb, struct net_device *dev) 301static int start_xmit(struct sk_buff *skb, struct net_device *dev)
282{ 302{
283 struct virtnet_info *vi = netdev_priv(dev); 303 struct virtnet_info *vi = netdev_priv(dev);
@@ -432,6 +452,8 @@ static int virtnet_probe(struct virtio_device *vdev)
432 skb_queue_head_init(&vi->recv); 452 skb_queue_head_init(&vi->recv);
433 skb_queue_head_init(&vi->send); 453 skb_queue_head_init(&vi->send);
434 454
455 tasklet_init(&vi->tasklet, xmit_tasklet, (unsigned long)vi);
456
435 err = register_netdev(dev); 457 err = register_netdev(dev);
436 if (err) { 458 if (err) {
437 pr_debug("virtio_net: registering device failed\n"); 459 pr_debug("virtio_net: registering device failed\n");