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