27559c987d478e56d59912ba8e08ea62b39d3fc8
[deliverable/linux.git] / drivers / net / virtio_net.c
1 /* A simple 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.
9 *
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.
14 *
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
18 */
19 //#define DEBUG
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
28 static int napi_weight = 128;
29 module_param(napi_weight, int, 0444);
30
31 static int csum = 1, gso = 1;
32 module_param(csum, bool, 0444);
33 module_param(gso, bool, 0444);
34
35 /* FIXME: MTU in config. */
36 #define MAX_PACKET_LEN (ETH_HLEN+ETH_DATA_LEN)
37
38 struct virtnet_info
39 {
40 struct virtio_device *vdev;
41 struct virtqueue *rvq, *svq;
42 struct net_device *dev;
43 struct napi_struct napi;
44
45 /* The skb we couldn't send because buffers were full. */
46 struct sk_buff *last_xmit_skb;
47
48 /* If we need to free in a timer, this is it. */
49 struct timer_list xmit_free_timer;
50
51 /* Number of input buffers, and max we've ever had. */
52 unsigned int num, max;
53
54 /* For cleaning up after transmission. */
55 struct tasklet_struct tasklet;
56 bool free_in_tasklet;
57
58 /* I like... big packets and I cannot lie! */
59 bool big_packets;
60
61 /* Receive & send queues. */
62 struct sk_buff_head recv;
63 struct sk_buff_head send;
64
65 /* Chain pages by the private ptr. */
66 struct page *pages;
67 };
68
69 static inline struct virtio_net_hdr *skb_vnet_hdr(struct sk_buff *skb)
70 {
71 return (struct virtio_net_hdr *)skb->cb;
72 }
73
74 static inline void vnet_hdr_to_sg(struct scatterlist *sg, struct sk_buff *skb)
75 {
76 sg_init_one(sg, skb_vnet_hdr(skb), sizeof(struct virtio_net_hdr));
77 }
78
79 static void give_a_page(struct virtnet_info *vi, struct page *page)
80 {
81 page->private = (unsigned long)vi->pages;
82 vi->pages = page;
83 }
84
85 static void trim_pages(struct virtnet_info *vi, struct sk_buff *skb)
86 {
87 unsigned int i;
88
89 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++)
90 give_a_page(vi, skb_shinfo(skb)->frags[i].page);
91 skb_shinfo(skb)->nr_frags = 0;
92 skb->data_len = 0;
93 }
94
95 static struct page *get_a_page(struct virtnet_info *vi, gfp_t gfp_mask)
96 {
97 struct page *p = vi->pages;
98
99 if (p)
100 vi->pages = (struct page *)p->private;
101 else
102 p = alloc_page(gfp_mask);
103 return p;
104 }
105
106 static void skb_xmit_done(struct virtqueue *svq)
107 {
108 struct virtnet_info *vi = svq->vdev->priv;
109
110 /* Suppress further interrupts. */
111 svq->vq_ops->disable_cb(svq);
112
113 /* We were probably waiting for more output buffers. */
114 netif_wake_queue(vi->dev);
115
116 /* Make sure we re-xmit last_xmit_skb: if there are no more packets
117 * queued, start_xmit won't be called. */
118 tasklet_schedule(&vi->tasklet);
119 }
120
121 static void receive_skb(struct net_device *dev, struct sk_buff *skb,
122 unsigned len)
123 {
124 struct virtio_net_hdr *hdr = skb_vnet_hdr(skb);
125 int err;
126
127 if (unlikely(len < sizeof(struct virtio_net_hdr) + ETH_HLEN)) {
128 pr_debug("%s: short packet %i\n", dev->name, len);
129 dev->stats.rx_length_errors++;
130 goto drop;
131 }
132 len -= sizeof(struct virtio_net_hdr);
133
134 if (len <= MAX_PACKET_LEN)
135 trim_pages(netdev_priv(dev), skb);
136
137 err = pskb_trim(skb, len);
138 if (err) {
139 pr_debug("%s: pskb_trim failed %i %d\n", dev->name, len, err);
140 dev->stats.rx_dropped++;
141 goto drop;
142 }
143 skb->truesize += skb->data_len;
144 dev->stats.rx_bytes += skb->len;
145 dev->stats.rx_packets++;
146
147 if (hdr->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) {
148 pr_debug("Needs csum!\n");
149 if (!skb_partial_csum_set(skb,hdr->csum_start,hdr->csum_offset))
150 goto frame_err;
151 }
152
153 skb->protocol = eth_type_trans(skb, dev);
154 pr_debug("Receiving skb proto 0x%04x len %i type %i\n",
155 ntohs(skb->protocol), skb->len, skb->pkt_type);
156
157 if (hdr->gso_type != VIRTIO_NET_HDR_GSO_NONE) {
158 pr_debug("GSO!\n");
159 switch (hdr->gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
160 case VIRTIO_NET_HDR_GSO_TCPV4:
161 skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4;
162 break;
163 case VIRTIO_NET_HDR_GSO_UDP:
164 skb_shinfo(skb)->gso_type = SKB_GSO_UDP;
165 break;
166 case VIRTIO_NET_HDR_GSO_TCPV6:
167 skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6;
168 break;
169 default:
170 if (net_ratelimit())
171 printk(KERN_WARNING "%s: bad gso type %u.\n",
172 dev->name, hdr->gso_type);
173 goto frame_err;
174 }
175
176 if (hdr->gso_type & VIRTIO_NET_HDR_GSO_ECN)
177 skb_shinfo(skb)->gso_type |= SKB_GSO_TCP_ECN;
178
179 skb_shinfo(skb)->gso_size = hdr->gso_size;
180 if (skb_shinfo(skb)->gso_size == 0) {
181 if (net_ratelimit())
182 printk(KERN_WARNING "%s: zero gso size.\n",
183 dev->name);
184 goto frame_err;
185 }
186
187 /* Header must be checked, and gso_segs computed. */
188 skb_shinfo(skb)->gso_type |= SKB_GSO_DODGY;
189 skb_shinfo(skb)->gso_segs = 0;
190 }
191
192 netif_receive_skb(skb);
193 return;
194
195 frame_err:
196 dev->stats.rx_frame_errors++;
197 drop:
198 dev_kfree_skb(skb);
199 }
200
201 static void try_fill_recv(struct virtnet_info *vi)
202 {
203 struct sk_buff *skb;
204 struct scatterlist sg[2+MAX_SKB_FRAGS];
205 int num, err, i;
206
207 sg_init_table(sg, 2+MAX_SKB_FRAGS);
208 for (;;) {
209 skb = netdev_alloc_skb(vi->dev, MAX_PACKET_LEN);
210 if (unlikely(!skb))
211 break;
212
213 skb_put(skb, MAX_PACKET_LEN);
214 vnet_hdr_to_sg(sg, skb);
215
216 if (vi->big_packets) {
217 for (i = 0; i < MAX_SKB_FRAGS; i++) {
218 skb_frag_t *f = &skb_shinfo(skb)->frags[i];
219 f->page = get_a_page(vi, GFP_ATOMIC);
220 if (!f->page)
221 break;
222
223 f->page_offset = 0;
224 f->size = PAGE_SIZE;
225
226 skb->data_len += PAGE_SIZE;
227 skb->len += PAGE_SIZE;
228
229 skb_shinfo(skb)->nr_frags++;
230 }
231 }
232
233 num = skb_to_sgvec(skb, sg+1, 0, skb->len) + 1;
234 skb_queue_head(&vi->recv, skb);
235
236 err = vi->rvq->vq_ops->add_buf(vi->rvq, sg, 0, num, skb);
237 if (err) {
238 skb_unlink(skb, &vi->recv);
239 trim_pages(vi, skb);
240 kfree_skb(skb);
241 break;
242 }
243 vi->num++;
244 }
245 if (unlikely(vi->num > vi->max))
246 vi->max = vi->num;
247 vi->rvq->vq_ops->kick(vi->rvq);
248 }
249
250 static void skb_recv_done(struct virtqueue *rvq)
251 {
252 struct virtnet_info *vi = rvq->vdev->priv;
253 /* Schedule NAPI, Suppress further interrupts if successful. */
254 if (netif_rx_schedule_prep(vi->dev, &vi->napi)) {
255 rvq->vq_ops->disable_cb(rvq);
256 __netif_rx_schedule(vi->dev, &vi->napi);
257 }
258 }
259
260 static int virtnet_poll(struct napi_struct *napi, int budget)
261 {
262 struct virtnet_info *vi = container_of(napi, struct virtnet_info, napi);
263 struct sk_buff *skb = NULL;
264 unsigned int len, received = 0;
265
266 again:
267 while (received < budget &&
268 (skb = vi->rvq->vq_ops->get_buf(vi->rvq, &len)) != NULL) {
269 __skb_unlink(skb, &vi->recv);
270 receive_skb(vi->dev, skb, len);
271 vi->num--;
272 received++;
273 }
274
275 /* FIXME: If we oom and completely run out of inbufs, we need
276 * to start a timer trying to fill more. */
277 if (vi->num < vi->max / 2)
278 try_fill_recv(vi);
279
280 /* Out of packets? */
281 if (received < budget) {
282 netif_rx_complete(vi->dev, napi);
283 if (unlikely(!vi->rvq->vq_ops->enable_cb(vi->rvq))
284 && napi_schedule_prep(napi)) {
285 vi->rvq->vq_ops->disable_cb(vi->rvq);
286 __netif_rx_schedule(vi->dev, napi);
287 goto again;
288 }
289 }
290
291 return received;
292 }
293
294 static void free_old_xmit_skbs(struct virtnet_info *vi)
295 {
296 struct sk_buff *skb;
297 unsigned int len;
298
299 while ((skb = vi->svq->vq_ops->get_buf(vi->svq, &len)) != NULL) {
300 pr_debug("Sent skb %p\n", skb);
301 __skb_unlink(skb, &vi->send);
302 vi->dev->stats.tx_bytes += skb->len;
303 vi->dev->stats.tx_packets++;
304 kfree_skb(skb);
305 }
306 }
307
308 /* If the virtio transport doesn't always notify us when all in-flight packets
309 * are consumed, we fall back to using this function on a timer to free them. */
310 static void xmit_free(unsigned long data)
311 {
312 struct virtnet_info *vi = (void *)data;
313
314 netif_tx_lock(vi->dev);
315
316 free_old_xmit_skbs(vi);
317
318 if (!skb_queue_empty(&vi->send))
319 mod_timer(&vi->xmit_free_timer, jiffies + (HZ/10));
320
321 netif_tx_unlock(vi->dev);
322 }
323
324 static int xmit_skb(struct virtnet_info *vi, struct sk_buff *skb)
325 {
326 int num, err;
327 struct scatterlist sg[2+MAX_SKB_FRAGS];
328 struct virtio_net_hdr *hdr;
329 const unsigned char *dest = ((struct ethhdr *)skb->data)->h_dest;
330
331 sg_init_table(sg, 2+MAX_SKB_FRAGS);
332
333 pr_debug("%s: xmit %p %pM\n", vi->dev->name, skb, dest);
334
335 /* Encode metadata header at front. */
336 hdr = skb_vnet_hdr(skb);
337 if (skb->ip_summed == CHECKSUM_PARTIAL) {
338 hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
339 hdr->csum_start = skb->csum_start - skb_headroom(skb);
340 hdr->csum_offset = skb->csum_offset;
341 } else {
342 hdr->flags = 0;
343 hdr->csum_offset = hdr->csum_start = 0;
344 }
345
346 if (skb_is_gso(skb)) {
347 hdr->hdr_len = skb_transport_header(skb) - skb->data;
348 hdr->gso_size = skb_shinfo(skb)->gso_size;
349 if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV4)
350 hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
351 else if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6)
352 hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
353 else if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP)
354 hdr->gso_type = VIRTIO_NET_HDR_GSO_UDP;
355 else
356 BUG();
357 if (skb_shinfo(skb)->gso_type & SKB_GSO_TCP_ECN)
358 hdr->gso_type |= VIRTIO_NET_HDR_GSO_ECN;
359 } else {
360 hdr->gso_type = VIRTIO_NET_HDR_GSO_NONE;
361 hdr->gso_size = hdr->hdr_len = 0;
362 }
363
364 vnet_hdr_to_sg(sg, skb);
365 num = skb_to_sgvec(skb, sg+1, 0, skb->len) + 1;
366
367 err = vi->svq->vq_ops->add_buf(vi->svq, sg, num, 0, skb);
368 if (!err && !vi->free_in_tasklet)
369 mod_timer(&vi->xmit_free_timer, jiffies + (HZ/10));
370
371 return err;
372 }
373
374 static void xmit_tasklet(unsigned long data)
375 {
376 struct virtnet_info *vi = (void *)data;
377
378 netif_tx_lock_bh(vi->dev);
379 if (vi->last_xmit_skb && xmit_skb(vi, vi->last_xmit_skb) == 0) {
380 vi->svq->vq_ops->kick(vi->svq);
381 vi->last_xmit_skb = NULL;
382 }
383 if (vi->free_in_tasklet)
384 free_old_xmit_skbs(vi);
385 netif_tx_unlock_bh(vi->dev);
386 }
387
388 static int start_xmit(struct sk_buff *skb, struct net_device *dev)
389 {
390 struct virtnet_info *vi = netdev_priv(dev);
391
392 again:
393 /* Free up any pending old buffers before queueing new ones. */
394 free_old_xmit_skbs(vi);
395
396 /* If we has a buffer left over from last time, send it now. */
397 if (unlikely(vi->last_xmit_skb) &&
398 xmit_skb(vi, vi->last_xmit_skb) != 0)
399 goto stop_queue;
400
401 vi->last_xmit_skb = NULL;
402
403 /* Put new one in send queue and do transmit */
404 if (likely(skb)) {
405 __skb_queue_head(&vi->send, skb);
406 if (xmit_skb(vi, skb) != 0) {
407 vi->last_xmit_skb = skb;
408 skb = NULL;
409 goto stop_queue;
410 }
411 }
412 done:
413 vi->svq->vq_ops->kick(vi->svq);
414 return NETDEV_TX_OK;
415
416 stop_queue:
417 pr_debug("%s: virtio not prepared to send\n", dev->name);
418 netif_stop_queue(dev);
419
420 /* Activate callback for using skbs: if this returns false it
421 * means some were used in the meantime. */
422 if (unlikely(!vi->svq->vq_ops->enable_cb(vi->svq))) {
423 vi->svq->vq_ops->disable_cb(vi->svq);
424 netif_start_queue(dev);
425 goto again;
426 }
427 if (skb) {
428 /* Drop this skb: we only queue one. */
429 vi->dev->stats.tx_dropped++;
430 kfree_skb(skb);
431 }
432 goto done;
433 }
434
435 #ifdef CONFIG_NET_POLL_CONTROLLER
436 static void virtnet_netpoll(struct net_device *dev)
437 {
438 struct virtnet_info *vi = netdev_priv(dev);
439
440 napi_schedule(&vi->napi);
441 }
442 #endif
443
444 static int virtnet_open(struct net_device *dev)
445 {
446 struct virtnet_info *vi = netdev_priv(dev);
447
448 napi_enable(&vi->napi);
449
450 /* If all buffers were filled by other side before we napi_enabled, we
451 * won't get another interrupt, so process any outstanding packets
452 * now. virtnet_poll wants re-enable the queue, so we disable here.
453 * We synchronize against interrupts via NAPI_STATE_SCHED */
454 if (netif_rx_schedule_prep(dev, &vi->napi)) {
455 vi->rvq->vq_ops->disable_cb(vi->rvq);
456 __netif_rx_schedule(dev, &vi->napi);
457 }
458 return 0;
459 }
460
461 static int virtnet_close(struct net_device *dev)
462 {
463 struct virtnet_info *vi = netdev_priv(dev);
464
465 napi_disable(&vi->napi);
466
467 return 0;
468 }
469
470 static int virtnet_set_tx_csum(struct net_device *dev, u32 data)
471 {
472 struct virtnet_info *vi = netdev_priv(dev);
473 struct virtio_device *vdev = vi->vdev;
474
475 if (data && !virtio_has_feature(vdev, VIRTIO_NET_F_CSUM))
476 return -ENOSYS;
477
478 return ethtool_op_set_tx_hw_csum(dev, data);
479 }
480
481 static struct ethtool_ops virtnet_ethtool_ops = {
482 .set_tx_csum = virtnet_set_tx_csum,
483 .set_sg = ethtool_op_set_sg,
484 .set_tso = ethtool_op_set_tso,
485 };
486
487 static int virtnet_probe(struct virtio_device *vdev)
488 {
489 int err;
490 struct net_device *dev;
491 struct virtnet_info *vi;
492
493 /* Allocate ourselves a network device with room for our info */
494 dev = alloc_etherdev(sizeof(struct virtnet_info));
495 if (!dev)
496 return -ENOMEM;
497
498 /* Set up network device as normal. */
499 dev->open = virtnet_open;
500 dev->stop = virtnet_close;
501 dev->hard_start_xmit = start_xmit;
502 dev->features = NETIF_F_HIGHDMA;
503 #ifdef CONFIG_NET_POLL_CONTROLLER
504 dev->poll_controller = virtnet_netpoll;
505 #endif
506 SET_ETHTOOL_OPS(dev, &virtnet_ethtool_ops);
507 SET_NETDEV_DEV(dev, &vdev->dev);
508
509 /* Do we support "hardware" checksums? */
510 if (csum && virtio_has_feature(vdev, VIRTIO_NET_F_CSUM)) {
511 /* This opens up the world of extra features. */
512 dev->features |= NETIF_F_HW_CSUM|NETIF_F_SG|NETIF_F_FRAGLIST;
513 if (gso && virtio_has_feature(vdev, VIRTIO_NET_F_GSO)) {
514 dev->features |= NETIF_F_TSO | NETIF_F_UFO
515 | NETIF_F_TSO_ECN | NETIF_F_TSO6;
516 }
517 /* Individual feature bits: what can host handle? */
518 if (gso && virtio_has_feature(vdev, VIRTIO_NET_F_HOST_TSO4))
519 dev->features |= NETIF_F_TSO;
520 if (gso && virtio_has_feature(vdev, VIRTIO_NET_F_HOST_TSO6))
521 dev->features |= NETIF_F_TSO6;
522 if (gso && virtio_has_feature(vdev, VIRTIO_NET_F_HOST_ECN))
523 dev->features |= NETIF_F_TSO_ECN;
524 if (gso && virtio_has_feature(vdev, VIRTIO_NET_F_HOST_UFO))
525 dev->features |= NETIF_F_UFO;
526 }
527
528 /* Configuration may specify what MAC to use. Otherwise random. */
529 if (virtio_has_feature(vdev, VIRTIO_NET_F_MAC)) {
530 vdev->config->get(vdev,
531 offsetof(struct virtio_net_config, mac),
532 dev->dev_addr, dev->addr_len);
533 } else
534 random_ether_addr(dev->dev_addr);
535
536 /* Set up our device-specific information */
537 vi = netdev_priv(dev);
538 netif_napi_add(dev, &vi->napi, virtnet_poll, napi_weight);
539 vi->dev = dev;
540 vi->vdev = vdev;
541 vdev->priv = vi;
542 vi->pages = NULL;
543
544 /* If they give us a callback when all buffers are done, we don't need
545 * the timer. */
546 vi->free_in_tasklet = virtio_has_feature(vdev,VIRTIO_F_NOTIFY_ON_EMPTY);
547
548 /* If we can receive ANY GSO packets, we must allocate large ones. */
549 if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4)
550 || virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6)
551 || virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_ECN))
552 vi->big_packets = true;
553
554 /* We expect two virtqueues, receive then send. */
555 vi->rvq = vdev->config->find_vq(vdev, 0, skb_recv_done);
556 if (IS_ERR(vi->rvq)) {
557 err = PTR_ERR(vi->rvq);
558 goto free;
559 }
560
561 vi->svq = vdev->config->find_vq(vdev, 1, skb_xmit_done);
562 if (IS_ERR(vi->svq)) {
563 err = PTR_ERR(vi->svq);
564 goto free_recv;
565 }
566
567 /* Initialize our empty receive and send queues. */
568 skb_queue_head_init(&vi->recv);
569 skb_queue_head_init(&vi->send);
570
571 tasklet_init(&vi->tasklet, xmit_tasklet, (unsigned long)vi);
572
573 if (!vi->free_in_tasklet)
574 setup_timer(&vi->xmit_free_timer, xmit_free, (unsigned long)vi);
575
576 err = register_netdev(dev);
577 if (err) {
578 pr_debug("virtio_net: registering device failed\n");
579 goto free_send;
580 }
581
582 /* Last of all, set up some receive buffers. */
583 try_fill_recv(vi);
584
585 /* If we didn't even get one input buffer, we're useless. */
586 if (vi->num == 0) {
587 err = -ENOMEM;
588 goto unregister;
589 }
590
591 pr_debug("virtnet: registered device %s\n", dev->name);
592 return 0;
593
594 unregister:
595 unregister_netdev(dev);
596 free_send:
597 vdev->config->del_vq(vi->svq);
598 free_recv:
599 vdev->config->del_vq(vi->rvq);
600 free:
601 free_netdev(dev);
602 return err;
603 }
604
605 static void virtnet_remove(struct virtio_device *vdev)
606 {
607 struct virtnet_info *vi = vdev->priv;
608 struct sk_buff *skb;
609
610 /* Stop all the virtqueues. */
611 vdev->config->reset(vdev);
612
613 if (!vi->free_in_tasklet)
614 del_timer_sync(&vi->xmit_free_timer);
615
616 /* Free our skbs in send and recv queues, if any. */
617 while ((skb = __skb_dequeue(&vi->recv)) != NULL) {
618 kfree_skb(skb);
619 vi->num--;
620 }
621 __skb_queue_purge(&vi->send);
622
623 BUG_ON(vi->num != 0);
624
625 vdev->config->del_vq(vi->svq);
626 vdev->config->del_vq(vi->rvq);
627 unregister_netdev(vi->dev);
628
629 while (vi->pages)
630 __free_pages(get_a_page(vi, GFP_KERNEL), 0);
631
632 free_netdev(vi->dev);
633 }
634
635 static struct virtio_device_id id_table[] = {
636 { VIRTIO_ID_NET, VIRTIO_DEV_ANY_ID },
637 { 0 },
638 };
639
640 static unsigned int features[] = {
641 VIRTIO_NET_F_CSUM, VIRTIO_NET_F_GUEST_CSUM,
642 VIRTIO_NET_F_GSO, VIRTIO_NET_F_MAC,
643 VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_UFO, VIRTIO_NET_F_HOST_TSO6,
644 VIRTIO_NET_F_HOST_ECN, VIRTIO_NET_F_GUEST_TSO4, VIRTIO_NET_F_GUEST_TSO6,
645 VIRTIO_NET_F_GUEST_ECN, /* We don't yet handle UFO input. */
646 VIRTIO_F_NOTIFY_ON_EMPTY,
647 };
648
649 static struct virtio_driver virtio_net = {
650 .feature_table = features,
651 .feature_table_size = ARRAY_SIZE(features),
652 .driver.name = KBUILD_MODNAME,
653 .driver.owner = THIS_MODULE,
654 .id_table = id_table,
655 .probe = virtnet_probe,
656 .remove = __devexit_p(virtnet_remove),
657 };
658
659 static int __init init(void)
660 {
661 return register_virtio_driver(&virtio_net);
662 }
663
664 static void __exit fini(void)
665 {
666 unregister_virtio_driver(&virtio_net);
667 }
668 module_init(init);
669 module_exit(fini);
670
671 MODULE_DEVICE_TABLE(virtio, id_table);
672 MODULE_DESCRIPTION("Virtio network driver");
673 MODULE_LICENSE("GPL");
This page took 0.043569 seconds and 4 git commands to generate.