1 /* A simple network driver using virtio.
3 * Copyright 2007 Rusty Russell <rusty@rustcorp.com.au> IBM Corporation
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.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include <linux/netdevice.h>
21 #include <linux/etherdevice.h>
22 #include <linux/ethtool.h>
23 #include <linux/module.h>
24 #include <linux/virtio.h>
25 #include <linux/virtio_net.h>
26 #include <linux/scatterlist.h>
27 #include <linux/if_vlan.h>
29 static int napi_weight = 128;
30 module_param(napi_weight, int, 0444);
32 static int csum = 1, gso = 1;
33 module_param(csum, bool, 0444);
34 module_param(gso, bool, 0444);
36 /* FIXME: MTU in config. */
37 #define MAX_PACKET_LEN (ETH_HLEN + VLAN_HLEN + ETH_DATA_LEN)
38 #define GOOD_COPY_LEN 128
42 struct virtio_device *vdev;
43 struct virtqueue *rvq, *svq;
44 struct net_device *dev;
45 struct napi_struct napi;
48 /* The skb we couldn't send because buffers were full. */
49 struct sk_buff *last_xmit_skb;
51 /* If we need to free in a timer, this is it. */
52 struct timer_list xmit_free_timer;
54 /* Number of input buffers, and max we've ever had. */
55 unsigned int num, max;
57 /* For cleaning up after transmission. */
58 struct tasklet_struct tasklet;
61 /* I like... big packets and I cannot lie! */
64 /* Host will merge rx buffers for big packets (shake it! shake it!) */
65 bool mergeable_rx_bufs;
67 /* Receive & send queues. */
68 struct sk_buff_head recv;
69 struct sk_buff_head send;
71 /* Chain pages by the private ptr. */
75 static inline void *skb_vnet_hdr(struct sk_buff *skb)
77 return (struct virtio_net_hdr *)skb->cb;
80 static void give_a_page(struct virtnet_info *vi, struct page *page)
82 page->private = (unsigned long)vi->pages;
86 static void trim_pages(struct virtnet_info *vi, struct sk_buff *skb)
90 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++)
91 give_a_page(vi, skb_shinfo(skb)->frags[i].page);
92 skb_shinfo(skb)->nr_frags = 0;
96 static struct page *get_a_page(struct virtnet_info *vi, gfp_t gfp_mask)
98 struct page *p = vi->pages;
101 vi->pages = (struct page *)p->private;
103 p = alloc_page(gfp_mask);
107 static void skb_xmit_done(struct virtqueue *svq)
109 struct virtnet_info *vi = svq->vdev->priv;
111 /* Suppress further interrupts. */
112 svq->vq_ops->disable_cb(svq);
114 /* We were probably waiting for more output buffers. */
115 netif_wake_queue(vi->dev);
117 /* Make sure we re-xmit last_xmit_skb: if there are no more packets
118 * queued, start_xmit won't be called. */
119 tasklet_schedule(&vi->tasklet);
122 static void receive_skb(struct net_device *dev, struct sk_buff *skb,
125 struct virtnet_info *vi = netdev_priv(dev);
126 struct virtio_net_hdr *hdr = skb_vnet_hdr(skb);
130 if (unlikely(len < sizeof(struct virtio_net_hdr) + ETH_HLEN)) {
131 pr_debug("%s: short packet %i\n", dev->name, len);
132 dev->stats.rx_length_errors++;
136 if (vi->mergeable_rx_bufs) {
137 struct virtio_net_hdr_mrg_rxbuf *mhdr = skb_vnet_hdr(skb);
139 char *p = page_address(skb_shinfo(skb)->frags[0].page);
143 len -= sizeof(struct virtio_net_hdr_mrg_rxbuf);
145 memcpy(hdr, p, sizeof(*mhdr));
149 if (copy > skb_tailroom(skb))
150 copy = skb_tailroom(skb);
152 memcpy(skb_put(skb, copy), p, copy);
157 give_a_page(vi, skb_shinfo(skb)->frags[0].page);
158 skb_shinfo(skb)->nr_frags--;
160 skb_shinfo(skb)->frags[0].page_offset +=
161 sizeof(*mhdr) + copy;
162 skb_shinfo(skb)->frags[0].size = len;
163 skb->data_len += len;
167 while (--mhdr->num_buffers) {
168 struct sk_buff *nskb;
170 i = skb_shinfo(skb)->nr_frags;
171 if (i >= MAX_SKB_FRAGS) {
172 pr_debug("%s: packet too long %d\n", dev->name,
174 dev->stats.rx_length_errors++;
178 nskb = vi->rvq->vq_ops->get_buf(vi->rvq, &len);
180 pr_debug("%s: rx error: %d buffers missing\n",
181 dev->name, mhdr->num_buffers);
182 dev->stats.rx_length_errors++;
186 __skb_unlink(nskb, &vi->recv);
189 skb_shinfo(skb)->frags[i] = skb_shinfo(nskb)->frags[0];
190 skb_shinfo(nskb)->nr_frags = 0;
196 skb_shinfo(skb)->frags[i].size = len;
197 skb_shinfo(skb)->nr_frags++;
198 skb->data_len += len;
202 len -= sizeof(struct virtio_net_hdr);
204 if (len <= MAX_PACKET_LEN)
207 err = pskb_trim(skb, len);
209 pr_debug("%s: pskb_trim failed %i %d\n", dev->name,
211 dev->stats.rx_dropped++;
216 skb->truesize += skb->data_len;
217 dev->stats.rx_bytes += skb->len;
218 dev->stats.rx_packets++;
220 if (hdr->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) {
221 pr_debug("Needs csum!\n");
222 if (!skb_partial_csum_set(skb,hdr->csum_start,hdr->csum_offset))
226 skb->protocol = eth_type_trans(skb, dev);
227 pr_debug("Receiving skb proto 0x%04x len %i type %i\n",
228 ntohs(skb->protocol), skb->len, skb->pkt_type);
230 if (hdr->gso_type != VIRTIO_NET_HDR_GSO_NONE) {
232 switch (hdr->gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
233 case VIRTIO_NET_HDR_GSO_TCPV4:
234 skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4;
236 case VIRTIO_NET_HDR_GSO_UDP:
237 skb_shinfo(skb)->gso_type = SKB_GSO_UDP;
239 case VIRTIO_NET_HDR_GSO_TCPV6:
240 skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6;
244 printk(KERN_WARNING "%s: bad gso type %u.\n",
245 dev->name, hdr->gso_type);
249 if (hdr->gso_type & VIRTIO_NET_HDR_GSO_ECN)
250 skb_shinfo(skb)->gso_type |= SKB_GSO_TCP_ECN;
252 skb_shinfo(skb)->gso_size = hdr->gso_size;
253 if (skb_shinfo(skb)->gso_size == 0) {
255 printk(KERN_WARNING "%s: zero gso size.\n",
260 /* Header must be checked, and gso_segs computed. */
261 skb_shinfo(skb)->gso_type |= SKB_GSO_DODGY;
262 skb_shinfo(skb)->gso_segs = 0;
265 netif_receive_skb(skb);
269 dev->stats.rx_frame_errors++;
274 static void try_fill_recv_maxbufs(struct virtnet_info *vi)
277 struct scatterlist sg[2+MAX_SKB_FRAGS];
280 sg_init_table(sg, 2+MAX_SKB_FRAGS);
282 struct virtio_net_hdr *hdr;
284 skb = netdev_alloc_skb(vi->dev, MAX_PACKET_LEN);
288 skb_put(skb, MAX_PACKET_LEN);
290 hdr = skb_vnet_hdr(skb);
291 sg_init_one(sg, hdr, sizeof(*hdr));
293 if (vi->big_packets) {
294 for (i = 0; i < MAX_SKB_FRAGS; i++) {
295 skb_frag_t *f = &skb_shinfo(skb)->frags[i];
296 f->page = get_a_page(vi, GFP_ATOMIC);
303 skb->data_len += PAGE_SIZE;
304 skb->len += PAGE_SIZE;
306 skb_shinfo(skb)->nr_frags++;
310 num = skb_to_sgvec(skb, sg+1, 0, skb->len) + 1;
311 skb_queue_head(&vi->recv, skb);
313 err = vi->rvq->vq_ops->add_buf(vi->rvq, sg, 0, num, skb);
315 skb_unlink(skb, &vi->recv);
322 if (unlikely(vi->num > vi->max))
324 vi->rvq->vq_ops->kick(vi->rvq);
327 static void try_fill_recv(struct virtnet_info *vi)
330 struct scatterlist sg[1];
333 if (!vi->mergeable_rx_bufs) {
334 try_fill_recv_maxbufs(vi);
341 skb = netdev_alloc_skb(vi->dev, GOOD_COPY_LEN + NET_IP_ALIGN);
345 skb_reserve(skb, NET_IP_ALIGN);
347 f = &skb_shinfo(skb)->frags[0];
348 f->page = get_a_page(vi, GFP_ATOMIC);
357 skb_shinfo(skb)->nr_frags++;
359 sg_init_one(sg, page_address(f->page), PAGE_SIZE);
360 skb_queue_head(&vi->recv, skb);
362 err = vi->rvq->vq_ops->add_buf(vi->rvq, sg, 0, 1, skb);
364 skb_unlink(skb, &vi->recv);
370 if (unlikely(vi->num > vi->max))
372 vi->rvq->vq_ops->kick(vi->rvq);
375 static void skb_recv_done(struct virtqueue *rvq)
377 struct virtnet_info *vi = rvq->vdev->priv;
378 /* Schedule NAPI, Suppress further interrupts if successful. */
379 if (napi_schedule_prep(&vi->napi)) {
380 rvq->vq_ops->disable_cb(rvq);
381 __napi_schedule(&vi->napi);
385 static int virtnet_poll(struct napi_struct *napi, int budget)
387 struct virtnet_info *vi = container_of(napi, struct virtnet_info, napi);
388 struct sk_buff *skb = NULL;
389 unsigned int len, received = 0;
392 while (received < budget &&
393 (skb = vi->rvq->vq_ops->get_buf(vi->rvq, &len)) != NULL) {
394 __skb_unlink(skb, &vi->recv);
395 receive_skb(vi->dev, skb, len);
400 /* FIXME: If we oom and completely run out of inbufs, we need
401 * to start a timer trying to fill more. */
402 if (vi->num < vi->max / 2)
405 /* Out of packets? */
406 if (received < budget) {
408 if (unlikely(!vi->rvq->vq_ops->enable_cb(vi->rvq))
409 && napi_schedule_prep(napi)) {
410 vi->rvq->vq_ops->disable_cb(vi->rvq);
411 __napi_schedule(napi);
419 static void free_old_xmit_skbs(struct virtnet_info *vi)
424 while ((skb = vi->svq->vq_ops->get_buf(vi->svq, &len)) != NULL) {
425 pr_debug("Sent skb %p\n", skb);
426 __skb_unlink(skb, &vi->send);
427 vi->dev->stats.tx_bytes += skb->len;
428 vi->dev->stats.tx_packets++;
433 /* If the virtio transport doesn't always notify us when all in-flight packets
434 * are consumed, we fall back to using this function on a timer to free them. */
435 static void xmit_free(unsigned long data)
437 struct virtnet_info *vi = (void *)data;
439 netif_tx_lock(vi->dev);
441 free_old_xmit_skbs(vi);
443 if (!skb_queue_empty(&vi->send))
444 mod_timer(&vi->xmit_free_timer, jiffies + (HZ/10));
446 netif_tx_unlock(vi->dev);
449 static int xmit_skb(struct virtnet_info *vi, struct sk_buff *skb)
452 struct scatterlist sg[2+MAX_SKB_FRAGS];
453 struct virtio_net_hdr_mrg_rxbuf *mhdr = skb_vnet_hdr(skb);
454 struct virtio_net_hdr *hdr = skb_vnet_hdr(skb);
455 const unsigned char *dest = ((struct ethhdr *)skb->data)->h_dest;
457 sg_init_table(sg, 2+MAX_SKB_FRAGS);
459 pr_debug("%s: xmit %p %pM\n", vi->dev->name, skb, dest);
461 if (skb->ip_summed == CHECKSUM_PARTIAL) {
462 hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
463 hdr->csum_start = skb->csum_start - skb_headroom(skb);
464 hdr->csum_offset = skb->csum_offset;
467 hdr->csum_offset = hdr->csum_start = 0;
470 if (skb_is_gso(skb)) {
471 hdr->hdr_len = skb_transport_header(skb) - skb->data;
472 hdr->gso_size = skb_shinfo(skb)->gso_size;
473 if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV4)
474 hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
475 else if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6)
476 hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
477 else if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP)
478 hdr->gso_type = VIRTIO_NET_HDR_GSO_UDP;
481 if (skb_shinfo(skb)->gso_type & SKB_GSO_TCP_ECN)
482 hdr->gso_type |= VIRTIO_NET_HDR_GSO_ECN;
484 hdr->gso_type = VIRTIO_NET_HDR_GSO_NONE;
485 hdr->gso_size = hdr->hdr_len = 0;
488 mhdr->num_buffers = 0;
490 /* Encode metadata header at front. */
491 if (vi->mergeable_rx_bufs)
492 sg_init_one(sg, mhdr, sizeof(*mhdr));
494 sg_init_one(sg, hdr, sizeof(*hdr));
496 num = skb_to_sgvec(skb, sg+1, 0, skb->len) + 1;
498 err = vi->svq->vq_ops->add_buf(vi->svq, sg, num, 0, skb);
499 if (!err && !vi->free_in_tasklet)
500 mod_timer(&vi->xmit_free_timer, jiffies + (HZ/10));
505 static void xmit_tasklet(unsigned long data)
507 struct virtnet_info *vi = (void *)data;
509 netif_tx_lock_bh(vi->dev);
510 if (vi->last_xmit_skb && xmit_skb(vi, vi->last_xmit_skb) == 0) {
511 vi->svq->vq_ops->kick(vi->svq);
512 vi->last_xmit_skb = NULL;
514 if (vi->free_in_tasklet)
515 free_old_xmit_skbs(vi);
516 netif_tx_unlock_bh(vi->dev);
519 static int start_xmit(struct sk_buff *skb, struct net_device *dev)
521 struct virtnet_info *vi = netdev_priv(dev);
524 /* Free up any pending old buffers before queueing new ones. */
525 free_old_xmit_skbs(vi);
527 /* If we has a buffer left over from last time, send it now. */
528 if (unlikely(vi->last_xmit_skb) &&
529 xmit_skb(vi, vi->last_xmit_skb) != 0)
532 vi->last_xmit_skb = NULL;
534 /* Put new one in send queue and do transmit */
536 __skb_queue_head(&vi->send, skb);
537 if (xmit_skb(vi, skb) != 0) {
538 vi->last_xmit_skb = skb;
544 vi->svq->vq_ops->kick(vi->svq);
548 pr_debug("%s: virtio not prepared to send\n", dev->name);
549 netif_stop_queue(dev);
551 /* Activate callback for using skbs: if this returns false it
552 * means some were used in the meantime. */
553 if (unlikely(!vi->svq->vq_ops->enable_cb(vi->svq))) {
554 vi->svq->vq_ops->disable_cb(vi->svq);
555 netif_start_queue(dev);
559 /* Drop this skb: we only queue one. */
560 vi->dev->stats.tx_dropped++;
566 #ifdef CONFIG_NET_POLL_CONTROLLER
567 static void virtnet_netpoll(struct net_device *dev)
569 struct virtnet_info *vi = netdev_priv(dev);
571 napi_schedule(&vi->napi);
575 static int virtnet_open(struct net_device *dev)
577 struct virtnet_info *vi = netdev_priv(dev);
579 napi_enable(&vi->napi);
581 /* If all buffers were filled by other side before we napi_enabled, we
582 * won't get another interrupt, so process any outstanding packets
583 * now. virtnet_poll wants re-enable the queue, so we disable here.
584 * We synchronize against interrupts via NAPI_STATE_SCHED */
585 if (napi_schedule_prep(&vi->napi)) {
586 vi->rvq->vq_ops->disable_cb(vi->rvq);
587 __napi_schedule(&vi->napi);
592 static int virtnet_close(struct net_device *dev)
594 struct virtnet_info *vi = netdev_priv(dev);
596 napi_disable(&vi->napi);
601 static int virtnet_set_tx_csum(struct net_device *dev, u32 data)
603 struct virtnet_info *vi = netdev_priv(dev);
604 struct virtio_device *vdev = vi->vdev;
606 if (data && !virtio_has_feature(vdev, VIRTIO_NET_F_CSUM))
609 return ethtool_op_set_tx_hw_csum(dev, data);
612 static struct ethtool_ops virtnet_ethtool_ops = {
613 .set_tx_csum = virtnet_set_tx_csum,
614 .set_sg = ethtool_op_set_sg,
615 .set_tso = ethtool_op_set_tso,
616 .get_link = ethtool_op_get_link,
620 #define MAX_MTU 65535
622 static int virtnet_change_mtu(struct net_device *dev, int new_mtu)
624 if (new_mtu < MIN_MTU || new_mtu > MAX_MTU)
630 static const struct net_device_ops virtnet_netdev = {
631 .ndo_open = virtnet_open,
632 .ndo_stop = virtnet_close,
633 .ndo_start_xmit = start_xmit,
634 .ndo_validate_addr = eth_validate_addr,
635 .ndo_set_mac_address = eth_mac_addr,
636 .ndo_change_mtu = virtnet_change_mtu,
637 #ifdef CONFIG_NET_POLL_CONTROLLER
638 .ndo_poll_controller = virtnet_netpoll,
642 static void virtnet_update_status(struct virtnet_info *vi)
646 if (!virtio_has_feature(vi->vdev, VIRTIO_NET_F_STATUS))
649 vi->vdev->config->get(vi->vdev,
650 offsetof(struct virtio_net_config, status),
653 /* Ignore unknown (future) status bits */
654 v &= VIRTIO_NET_S_LINK_UP;
661 if (vi->status & VIRTIO_NET_S_LINK_UP) {
662 netif_carrier_on(vi->dev);
663 netif_wake_queue(vi->dev);
665 netif_carrier_off(vi->dev);
666 netif_stop_queue(vi->dev);
670 static void virtnet_config_changed(struct virtio_device *vdev)
672 struct virtnet_info *vi = vdev->priv;
674 virtnet_update_status(vi);
677 static int virtnet_probe(struct virtio_device *vdev)
680 struct net_device *dev;
681 struct virtnet_info *vi;
683 /* Allocate ourselves a network device with room for our info */
684 dev = alloc_etherdev(sizeof(struct virtnet_info));
688 /* Set up network device as normal. */
689 dev->netdev_ops = &virtnet_netdev;
690 dev->features = NETIF_F_HIGHDMA;
691 SET_ETHTOOL_OPS(dev, &virtnet_ethtool_ops);
692 SET_NETDEV_DEV(dev, &vdev->dev);
694 /* Do we support "hardware" checksums? */
695 if (csum && virtio_has_feature(vdev, VIRTIO_NET_F_CSUM)) {
696 /* This opens up the world of extra features. */
697 dev->features |= NETIF_F_HW_CSUM|NETIF_F_SG|NETIF_F_FRAGLIST;
698 if (gso && virtio_has_feature(vdev, VIRTIO_NET_F_GSO)) {
699 dev->features |= NETIF_F_TSO | NETIF_F_UFO
700 | NETIF_F_TSO_ECN | NETIF_F_TSO6;
702 /* Individual feature bits: what can host handle? */
703 if (gso && virtio_has_feature(vdev, VIRTIO_NET_F_HOST_TSO4))
704 dev->features |= NETIF_F_TSO;
705 if (gso && virtio_has_feature(vdev, VIRTIO_NET_F_HOST_TSO6))
706 dev->features |= NETIF_F_TSO6;
707 if (gso && virtio_has_feature(vdev, VIRTIO_NET_F_HOST_ECN))
708 dev->features |= NETIF_F_TSO_ECN;
709 if (gso && virtio_has_feature(vdev, VIRTIO_NET_F_HOST_UFO))
710 dev->features |= NETIF_F_UFO;
713 /* Configuration may specify what MAC to use. Otherwise random. */
714 if (virtio_has_feature(vdev, VIRTIO_NET_F_MAC)) {
715 vdev->config->get(vdev,
716 offsetof(struct virtio_net_config, mac),
717 dev->dev_addr, dev->addr_len);
719 random_ether_addr(dev->dev_addr);
721 /* Set up our device-specific information */
722 vi = netdev_priv(dev);
723 netif_napi_add(dev, &vi->napi, virtnet_poll, napi_weight);
729 /* If they give us a callback when all buffers are done, we don't need
731 vi->free_in_tasklet = virtio_has_feature(vdev,VIRTIO_F_NOTIFY_ON_EMPTY);
733 /* If we can receive ANY GSO packets, we must allocate large ones. */
734 if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4)
735 || virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6)
736 || virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_ECN))
737 vi->big_packets = true;
739 if (virtio_has_feature(vdev, VIRTIO_NET_F_MRG_RXBUF))
740 vi->mergeable_rx_bufs = true;
742 /* We expect two virtqueues, receive then send. */
743 vi->rvq = vdev->config->find_vq(vdev, 0, skb_recv_done);
744 if (IS_ERR(vi->rvq)) {
745 err = PTR_ERR(vi->rvq);
749 vi->svq = vdev->config->find_vq(vdev, 1, skb_xmit_done);
750 if (IS_ERR(vi->svq)) {
751 err = PTR_ERR(vi->svq);
755 /* Initialize our empty receive and send queues. */
756 skb_queue_head_init(&vi->recv);
757 skb_queue_head_init(&vi->send);
759 tasklet_init(&vi->tasklet, xmit_tasklet, (unsigned long)vi);
761 if (!vi->free_in_tasklet)
762 setup_timer(&vi->xmit_free_timer, xmit_free, (unsigned long)vi);
764 err = register_netdev(dev);
766 pr_debug("virtio_net: registering device failed\n");
770 /* Last of all, set up some receive buffers. */
773 /* If we didn't even get one input buffer, we're useless. */
779 vi->status = VIRTIO_NET_S_LINK_UP;
780 virtnet_update_status(vi);
782 pr_debug("virtnet: registered device %s\n", dev->name);
786 unregister_netdev(dev);
788 vdev->config->del_vq(vi->svq);
790 vdev->config->del_vq(vi->rvq);
796 static void virtnet_remove(struct virtio_device *vdev)
798 struct virtnet_info *vi = vdev->priv;
801 /* Stop all the virtqueues. */
802 vdev->config->reset(vdev);
804 if (!vi->free_in_tasklet)
805 del_timer_sync(&vi->xmit_free_timer);
807 /* Free our skbs in send and recv queues, if any. */
808 while ((skb = __skb_dequeue(&vi->recv)) != NULL) {
812 __skb_queue_purge(&vi->send);
814 BUG_ON(vi->num != 0);
816 vdev->config->del_vq(vi->svq);
817 vdev->config->del_vq(vi->rvq);
818 unregister_netdev(vi->dev);
821 __free_pages(get_a_page(vi, GFP_KERNEL), 0);
823 free_netdev(vi->dev);
826 static struct virtio_device_id id_table[] = {
827 { VIRTIO_ID_NET, VIRTIO_DEV_ANY_ID },
831 static unsigned int features[] = {
832 VIRTIO_NET_F_CSUM, VIRTIO_NET_F_GUEST_CSUM,
833 VIRTIO_NET_F_GSO, VIRTIO_NET_F_MAC,
834 VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_UFO, VIRTIO_NET_F_HOST_TSO6,
835 VIRTIO_NET_F_HOST_ECN, VIRTIO_NET_F_GUEST_TSO4, VIRTIO_NET_F_GUEST_TSO6,
836 VIRTIO_NET_F_GUEST_ECN, /* We don't yet handle UFO input. */
837 VIRTIO_NET_F_MRG_RXBUF, VIRTIO_NET_F_STATUS,
838 VIRTIO_F_NOTIFY_ON_EMPTY,
841 static struct virtio_driver virtio_net = {
842 .feature_table = features,
843 .feature_table_size = ARRAY_SIZE(features),
844 .driver.name = KBUILD_MODNAME,
845 .driver.owner = THIS_MODULE,
846 .id_table = id_table,
847 .probe = virtnet_probe,
848 .remove = __devexit_p(virtnet_remove),
849 .config_changed = virtnet_config_changed,
852 static int __init init(void)
854 return register_virtio_driver(&virtio_net);
857 static void __exit fini(void)
859 unregister_virtio_driver(&virtio_net);
864 MODULE_DEVICE_TABLE(virtio, id_table);
865 MODULE_DESCRIPTION("Virtio network driver");
866 MODULE_LICENSE("GPL");