virtio_net.c (7a53c7f56bbfc9b0ef892e68f5cfae3d902544d1) | virtio_net.c (22402529df88ec39a59b08a46bced73dd5722b64) |
---|---|
1/* A network driver using virtio. 2 * 3 * Copyright 2007 Rusty Russell <rusty@rustcorp.com.au> IBM Corporation 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. --- 440 unchanged lines hidden (view full) --- 449 unsigned int len, tot_sgs = 0; 450 451 while ((skb = vi->svq->vq_ops->get_buf(vi->svq, &len)) != NULL) { 452 pr_debug("Sent skb %p\n", skb); 453 __skb_unlink(skb, &vi->send); 454 vi->dev->stats.tx_bytes += skb->len; 455 vi->dev->stats.tx_packets++; 456 tot_sgs += skb_vnet_hdr(skb)->num_sg; | 1/* A network driver using virtio. 2 * 3 * Copyright 2007 Rusty Russell <rusty@rustcorp.com.au> IBM Corporation 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. --- 440 unchanged lines hidden (view full) --- 449 unsigned int len, tot_sgs = 0; 450 451 while ((skb = vi->svq->vq_ops->get_buf(vi->svq, &len)) != NULL) { 452 pr_debug("Sent skb %p\n", skb); 453 __skb_unlink(skb, &vi->send); 454 vi->dev->stats.tx_bytes += skb->len; 455 vi->dev->stats.tx_packets++; 456 tot_sgs += skb_vnet_hdr(skb)->num_sg; |
457 kfree_skb(skb); | 457 dev_kfree_skb_any(skb); |
458 } 459 return tot_sgs; 460} 461 462static int xmit_skb(struct virtnet_info *vi, struct sk_buff *skb) 463{ 464 struct scatterlist sg[2+MAX_SKB_FRAGS]; 465 struct skb_vnet_hdr *hdr = skb_vnet_hdr(skb); --- 46 unchanged lines hidden (view full) --- 512{ 513 struct virtnet_info *vi = netdev_priv(dev); 514 int capacity; 515 516again: 517 /* Free up any pending old buffers before queueing new ones. */ 518 free_old_xmit_skbs(vi); 519 | 458 } 459 return tot_sgs; 460} 461 462static int xmit_skb(struct virtnet_info *vi, struct sk_buff *skb) 463{ 464 struct scatterlist sg[2+MAX_SKB_FRAGS]; 465 struct skb_vnet_hdr *hdr = skb_vnet_hdr(skb); --- 46 unchanged lines hidden (view full) --- 512{ 513 struct virtnet_info *vi = netdev_priv(dev); 514 int capacity; 515 516again: 517 /* Free up any pending old buffers before queueing new ones. */ 518 free_old_xmit_skbs(vi); 519 |
520 /* Put new one in send queue and do transmit */ 521 __skb_queue_head(&vi->send, skb); | 520 /* Try to transmit */ |
522 capacity = xmit_skb(vi, skb); 523 524 /* This can happen with OOM and indirect buffers. */ 525 if (unlikely(capacity < 0)) { 526 netif_stop_queue(dev); 527 dev_warn(&dev->dev, "Unexpected full queue\n"); 528 if (unlikely(!vi->svq->vq_ops->enable_cb(vi->svq))) { 529 vi->svq->vq_ops->disable_cb(vi->svq); 530 netif_start_queue(dev); 531 goto again; 532 } 533 return NETDEV_TX_BUSY; 534 } | 521 capacity = xmit_skb(vi, skb); 522 523 /* This can happen with OOM and indirect buffers. */ 524 if (unlikely(capacity < 0)) { 525 netif_stop_queue(dev); 526 dev_warn(&dev->dev, "Unexpected full queue\n"); 527 if (unlikely(!vi->svq->vq_ops->enable_cb(vi->svq))) { 528 vi->svq->vq_ops->disable_cb(vi->svq); 529 netif_start_queue(dev); 530 goto again; 531 } 532 return NETDEV_TX_BUSY; 533 } |
535 | |
536 vi->svq->vq_ops->kick(vi->svq); | 534 vi->svq->vq_ops->kick(vi->svq); |
535 536 /* 537 * Put new one in send queue. You'd expect we'd need this before 538 * xmit_skb calls add_buf(), since the callback can be triggered 539 * immediately after that. But since the callback just triggers 540 * another call back here, normal network xmit locking prevents the 541 * race. 542 */ 543 __skb_queue_head(&vi->send, skb); 544 |
|
537 /* Don't wait up for transmitted skbs to be freed. */ 538 skb_orphan(skb); 539 nf_reset(skb); 540 541 /* Apparently nice girls don't return TX_BUSY; stop the queue 542 * before it gets out of hand. Naturally, this wastes entries. */ 543 if (capacity < 2+MAX_SKB_FRAGS) { 544 netif_stop_queue(dev); --- 441 unchanged lines hidden (view full) --- 986 VIRTIO_NET_F_GSO, VIRTIO_NET_F_MAC, 987 VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_UFO, VIRTIO_NET_F_HOST_TSO6, 988 VIRTIO_NET_F_HOST_ECN, VIRTIO_NET_F_GUEST_TSO4, VIRTIO_NET_F_GUEST_TSO6, 989 VIRTIO_NET_F_GUEST_ECN, VIRTIO_NET_F_GUEST_UFO, 990 VIRTIO_NET_F_MRG_RXBUF, VIRTIO_NET_F_STATUS, VIRTIO_NET_F_CTRL_VQ, 991 VIRTIO_NET_F_CTRL_RX, VIRTIO_NET_F_CTRL_VLAN, 992}; 993 | 545 /* Don't wait up for transmitted skbs to be freed. */ 546 skb_orphan(skb); 547 nf_reset(skb); 548 549 /* Apparently nice girls don't return TX_BUSY; stop the queue 550 * before it gets out of hand. Naturally, this wastes entries. */ 551 if (capacity < 2+MAX_SKB_FRAGS) { 552 netif_stop_queue(dev); --- 441 unchanged lines hidden (view full) --- 994 VIRTIO_NET_F_GSO, VIRTIO_NET_F_MAC, 995 VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_UFO, VIRTIO_NET_F_HOST_TSO6, 996 VIRTIO_NET_F_HOST_ECN, VIRTIO_NET_F_GUEST_TSO4, VIRTIO_NET_F_GUEST_TSO6, 997 VIRTIO_NET_F_GUEST_ECN, VIRTIO_NET_F_GUEST_UFO, 998 VIRTIO_NET_F_MRG_RXBUF, VIRTIO_NET_F_STATUS, VIRTIO_NET_F_CTRL_VQ, 999 VIRTIO_NET_F_CTRL_RX, VIRTIO_NET_F_CTRL_VLAN, 1000}; 1001 |
994static struct virtio_driver virtio_net = { | 1002static struct virtio_driver virtio_net_driver = { |
995 .feature_table = features, 996 .feature_table_size = ARRAY_SIZE(features), 997 .driver.name = KBUILD_MODNAME, 998 .driver.owner = THIS_MODULE, 999 .id_table = id_table, 1000 .probe = virtnet_probe, 1001 .remove = __devexit_p(virtnet_remove), 1002 .config_changed = virtnet_config_changed, 1003}; 1004 1005static int __init init(void) 1006{ | 1003 .feature_table = features, 1004 .feature_table_size = ARRAY_SIZE(features), 1005 .driver.name = KBUILD_MODNAME, 1006 .driver.owner = THIS_MODULE, 1007 .id_table = id_table, 1008 .probe = virtnet_probe, 1009 .remove = __devexit_p(virtnet_remove), 1010 .config_changed = virtnet_config_changed, 1011}; 1012 1013static int __init init(void) 1014{ |
1007 return register_virtio_driver(&virtio_net); | 1015 return register_virtio_driver(&virtio_net_driver); |
1008} 1009 1010static void __exit fini(void) 1011{ | 1016} 1017 1018static void __exit fini(void) 1019{ |
1012 unregister_virtio_driver(&virtio_net); | 1020 unregister_virtio_driver(&virtio_net_driver); |
1013} 1014module_init(init); 1015module_exit(fini); 1016 1017MODULE_DEVICE_TABLE(virtio, id_table); 1018MODULE_DESCRIPTION("Virtio network driver"); 1019MODULE_LICENSE("GPL"); | 1021} 1022module_init(init); 1023module_exit(fini); 1024 1025MODULE_DEVICE_TABLE(virtio, id_table); 1026MODULE_DESCRIPTION("Virtio network driver"); 1027MODULE_LICENSE("GPL"); |