direct-io.hg

view linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c @ 7561:e212c0b60fbe

Move misplaced netif_free declaration.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@leeni.uk.xensource.com
date Sun Oct 30 17:17:21 2005 +0100 (2005-10-30)
parents b50eb7619dd4
children 43676a509982
line source
1 /******************************************************************************
2 * Virtual network driver for conversing with remote driver backends.
3 *
4 * Copyright (c) 2002-2005, K A Fraser
5 *
6 * This file may be distributed separately from the Linux kernel, or
7 * incorporated into other software packages, subject to the following license:
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a copy
10 * of this source file (the "Software"), to deal in the Software without
11 * restriction, including without limitation the rights to use, copy, modify,
12 * merge, publish, distribute, sublicense, and/or sell copies of the Software,
13 * and to permit persons to whom the Software is furnished to do so, subject to
14 * the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25 * IN THE SOFTWARE.
26 */
28 #include <linux/config.h>
29 #include <linux/module.h>
30 #include <linux/version.h>
31 #include <linux/kernel.h>
32 #include <linux/sched.h>
33 #include <linux/slab.h>
34 #include <linux/string.h>
35 #include <linux/errno.h>
36 #include <linux/netdevice.h>
37 #include <linux/inetdevice.h>
38 #include <linux/etherdevice.h>
39 #include <linux/skbuff.h>
40 #include <linux/init.h>
41 #include <linux/bitops.h>
42 #include <linux/proc_fs.h>
43 #include <linux/ethtool.h>
44 #include <net/sock.h>
45 #include <net/pkt_sched.h>
46 #include <net/arp.h>
47 #include <net/route.h>
48 #include <asm/io.h>
49 #include <asm/uaccess.h>
50 #include <asm-xen/evtchn.h>
51 #include <asm-xen/xenbus.h>
52 #include <asm-xen/xen-public/io/netif.h>
53 #include <asm-xen/xen-public/memory.h>
54 #include <asm-xen/balloon.h>
55 #include <asm/page.h>
56 #include <asm/uaccess.h>
57 #include <asm-xen/xen-public/grant_table.h>
58 #include <asm-xen/gnttab.h>
60 #define GRANT_INVALID_REF 0
62 #ifndef __GFP_NOWARN
63 #define __GFP_NOWARN 0
64 #endif
65 #define alloc_xen_skb(_l) __dev_alloc_skb((_l), GFP_ATOMIC|__GFP_NOWARN)
67 #define init_skb_shinfo(_skb) \
68 do { \
69 atomic_set(&(skb_shinfo(_skb)->dataref), 1); \
70 skb_shinfo(_skb)->nr_frags = 0; \
71 skb_shinfo(_skb)->frag_list = NULL; \
72 } while (0)
74 /* Allow headroom on each rx pkt for Ethernet header, alignment padding, ... */
75 #define RX_HEADROOM 200
77 /*
78 * If the backend driver is pipelining transmit requests then we can be very
79 * aggressive in avoiding new-packet notifications -- only need to send a
80 * notification if there are no outstanding unreceived responses.
81 * If the backend may be buffering our transmit buffers for any reason then we
82 * are rather more conservative.
83 */
84 #ifdef CONFIG_XEN_NETDEV_FRONTEND_PIPELINED_TRANSMITTER
85 #define TX_TEST_IDX resp_prod /* aggressive: any outstanding responses? */
86 #else
87 #define TX_TEST_IDX req_cons /* conservative: not seen all our requests? */
88 #endif
91 static void network_tx_buf_gc(struct net_device *dev);
92 static void network_alloc_rx_buffers(struct net_device *dev);
94 static unsigned long rx_pfn_array[NETIF_RX_RING_SIZE];
95 static multicall_entry_t rx_mcl[NETIF_RX_RING_SIZE+1];
96 static mmu_update_t rx_mmu[NETIF_RX_RING_SIZE];
98 #ifdef CONFIG_PROC_FS
99 static int xennet_proc_init(void);
100 static int xennet_proc_addif(struct net_device *dev);
101 static void xennet_proc_delif(struct net_device *dev);
102 #else
103 #define xennet_proc_init() (0)
104 #define xennet_proc_addif(d) (0)
105 #define xennet_proc_delif(d) ((void)0)
106 #endif
108 #define netfront_info net_private
109 struct net_private
110 {
111 struct list_head list;
112 struct net_device *netdev;
114 struct net_device_stats stats;
115 NETIF_RING_IDX rx_resp_cons, tx_resp_cons;
116 unsigned int tx_full;
118 netif_tx_interface_t *tx;
119 netif_rx_interface_t *rx;
121 spinlock_t tx_lock;
122 spinlock_t rx_lock;
124 unsigned int handle;
125 unsigned int evtchn, irq;
127 /* What is the status of our connection to the remote backend? */
128 #define BEST_CLOSED 0
129 #define BEST_DISCONNECTED 1
130 #define BEST_CONNECTED 2
131 unsigned int backend_state;
133 /* Is this interface open or closed (down or up)? */
134 #define UST_CLOSED 0
135 #define UST_OPEN 1
136 unsigned int user_state;
138 /* Receive-ring batched refills. */
139 #define RX_MIN_TARGET 8
140 #define RX_MAX_TARGET NETIF_RX_RING_SIZE
141 int rx_min_target, rx_max_target, rx_target;
142 struct sk_buff_head rx_batch;
144 /*
145 * {tx,rx}_skbs store outstanding skbuffs. The first entry in each
146 * array is an index into a chain of free entries.
147 */
148 struct sk_buff *tx_skbs[NETIF_TX_RING_SIZE+1];
149 struct sk_buff *rx_skbs[NETIF_RX_RING_SIZE+1];
151 grant_ref_t gref_tx_head;
152 grant_ref_t grant_tx_ref[NETIF_TX_RING_SIZE + 1];
153 grant_ref_t gref_rx_head;
154 grant_ref_t grant_rx_ref[NETIF_TX_RING_SIZE + 1];
156 struct xenbus_device *xbdev;
157 char *backend;
158 int backend_id;
159 struct xenbus_watch watch;
160 int tx_ring_ref;
161 int rx_ring_ref;
162 u8 mac[ETH_ALEN];
163 };
165 /* Access macros for acquiring freeing slots in {tx,rx}_skbs[]. */
166 #define ADD_ID_TO_FREELIST(_list, _id) \
167 (_list)[(_id)] = (_list)[0]; \
168 (_list)[0] = (void *)(unsigned long)(_id);
169 #define GET_ID_FROM_FREELIST(_list) \
170 ({ unsigned long _id = (unsigned long)(_list)[0]; \
171 (_list)[0] = (_list)[_id]; \
172 (unsigned short)_id; })
174 #ifdef DEBUG
175 static char *be_state_name[] = {
176 [BEST_CLOSED] = "closed",
177 [BEST_DISCONNECTED] = "disconnected",
178 [BEST_CONNECTED] = "connected",
179 };
180 #endif
182 #ifdef DEBUG
183 #define DPRINTK(fmt, args...) \
184 printk(KERN_ALERT "xen_net (%s:%d) " fmt, __FUNCTION__, __LINE__, ##args)
185 #else
186 #define DPRINTK(fmt, args...) ((void)0)
187 #endif
188 #define IPRINTK(fmt, args...) \
189 printk(KERN_INFO "xen_net: " fmt, ##args)
190 #define WPRINTK(fmt, args...) \
191 printk(KERN_WARNING "xen_net: " fmt, ##args)
193 static void netif_free(struct netfront_info *info);
195 /** Send a packet on a net device to encourage switches to learn the
196 * MAC. We send a fake ARP request.
197 *
198 * @param dev device
199 * @return 0 on success, error code otherwise
200 */
201 static int send_fake_arp(struct net_device *dev)
202 {
203 struct sk_buff *skb;
204 u32 src_ip, dst_ip;
206 dst_ip = INADDR_BROADCAST;
207 src_ip = inet_select_addr(dev, dst_ip, RT_SCOPE_LINK);
209 /* No IP? Then nothing to do. */
210 if (src_ip == 0)
211 return 0;
213 skb = arp_create(ARPOP_REPLY, ETH_P_ARP,
214 dst_ip, dev, src_ip,
215 /*dst_hw*/ NULL, /*src_hw*/ NULL,
216 /*target_hw*/ dev->dev_addr);
217 if (skb == NULL)
218 return -ENOMEM;
220 return dev_queue_xmit(skb);
221 }
223 static int network_open(struct net_device *dev)
224 {
225 struct net_private *np = netdev_priv(dev);
227 memset(&np->stats, 0, sizeof(np->stats));
229 np->user_state = UST_OPEN;
231 network_alloc_rx_buffers(dev);
232 np->rx->event = np->rx_resp_cons + 1;
234 netif_start_queue(dev);
236 return 0;
237 }
239 static void network_tx_buf_gc(struct net_device *dev)
240 {
241 NETIF_RING_IDX i, prod;
242 unsigned short id;
243 struct net_private *np = netdev_priv(dev);
244 struct sk_buff *skb;
246 if (np->backend_state != BEST_CONNECTED)
247 return;
249 do {
250 prod = np->tx->resp_prod;
251 rmb(); /* Ensure we see responses up to 'rp'. */
253 for (i = np->tx_resp_cons; i != prod; i++) {
254 id = np->tx->ring[MASK_NETIF_TX_IDX(i)].resp.id;
255 skb = np->tx_skbs[id];
256 if (unlikely(gnttab_query_foreign_access(
257 np->grant_tx_ref[id]) != 0)) {
258 printk(KERN_ALERT "network_tx_buf_gc: warning "
259 "-- grant still in use by backend "
260 "domain.\n");
261 goto out;
262 }
263 gnttab_end_foreign_access_ref(
264 np->grant_tx_ref[id], GNTMAP_readonly);
265 gnttab_release_grant_reference(
266 &np->gref_tx_head, np->grant_tx_ref[id]);
267 np->grant_tx_ref[id] = GRANT_INVALID_REF;
268 ADD_ID_TO_FREELIST(np->tx_skbs, id);
269 dev_kfree_skb_irq(skb);
270 }
272 np->tx_resp_cons = prod;
274 /*
275 * Set a new event, then check for race with update of tx_cons.
276 * Note that it is essential to schedule a callback, no matter
277 * how few buffers are pending. Even if there is space in the
278 * transmit ring, higher layers may be blocked because too much
279 * data is outstanding: in such cases notification from Xen is
280 * likely to be the only kick that we'll get.
281 */
282 np->tx->event = prod + ((np->tx->req_prod - prod) >> 1) + 1;
283 mb();
284 } while (prod != np->tx->resp_prod);
286 out:
287 if (np->tx_full && ((np->tx->req_prod - prod) < NETIF_TX_RING_SIZE)) {
288 np->tx_full = 0;
289 if (np->user_state == UST_OPEN)
290 netif_wake_queue(dev);
291 }
292 }
295 static void network_alloc_rx_buffers(struct net_device *dev)
296 {
297 unsigned short id;
298 struct net_private *np = netdev_priv(dev);
299 struct sk_buff *skb;
300 int i, batch_target;
301 NETIF_RING_IDX req_prod = np->rx->req_prod;
302 struct xen_memory_reservation reservation;
303 grant_ref_t ref;
305 if (unlikely(np->backend_state != BEST_CONNECTED))
306 return;
308 /*
309 * Allocate skbuffs greedily, even though we batch updates to the
310 * receive ring. This creates a less bursty demand on the memory
311 * allocator, so should reduce the chance of failed allocation requests
312 * both for ourself and for other kernel subsystems.
313 */
314 batch_target = np->rx_target - (req_prod - np->rx_resp_cons);
315 for (i = skb_queue_len(&np->rx_batch); i < batch_target; i++) {
316 skb = alloc_xen_skb(dev->mtu + RX_HEADROOM);
317 if (skb == NULL)
318 break;
319 __skb_queue_tail(&np->rx_batch, skb);
320 }
322 /* Is the batch large enough to be worthwhile? */
323 if (i < (np->rx_target/2))
324 return;
326 for (i = 0; ; i++) {
327 if ((skb = __skb_dequeue(&np->rx_batch)) == NULL)
328 break;
330 skb->dev = dev;
332 id = GET_ID_FROM_FREELIST(np->rx_skbs);
334 np->rx_skbs[id] = skb;
336 np->rx->ring[MASK_NETIF_RX_IDX(req_prod + i)].req.id = id;
337 ref = gnttab_claim_grant_reference(&np->gref_rx_head);
338 BUG_ON((signed short)ref < 0);
339 np->grant_rx_ref[id] = ref;
340 gnttab_grant_foreign_transfer_ref(ref, np->backend_id);
341 np->rx->ring[MASK_NETIF_RX_IDX(req_prod + i)].req.gref = ref;
342 rx_pfn_array[i] = virt_to_mfn(skb->head);
344 /* Remove this page from map before passing back to Xen. */
345 phys_to_machine_mapping[__pa(skb->head) >> PAGE_SHIFT]
346 = INVALID_P2M_ENTRY;
348 MULTI_update_va_mapping(rx_mcl+i, (unsigned long)skb->head,
349 __pte(0), 0);
350 }
352 /* After all PTEs have been zapped we blow away stale TLB entries. */
353 rx_mcl[i-1].args[MULTI_UVMFLAGS_INDEX] = UVMF_TLB_FLUSH|UVMF_ALL;
355 /* Give away a batch of pages. */
356 rx_mcl[i].op = __HYPERVISOR_memory_op;
357 rx_mcl[i].args[0] = XENMEM_decrease_reservation;
358 rx_mcl[i].args[1] = (unsigned long)&reservation;
360 reservation.extent_start = rx_pfn_array;
361 reservation.nr_extents = i;
362 reservation.extent_order = 0;
363 reservation.address_bits = 0;
364 reservation.domid = DOMID_SELF;
366 /* Tell the ballon driver what is going on. */
367 balloon_update_driver_allowance(i);
369 /* Zap PTEs and give away pages in one big multicall. */
370 (void)HYPERVISOR_multicall(rx_mcl, i+1);
372 /* Check return status of HYPERVISOR_memory_op(). */
373 if (unlikely(rx_mcl[i].result != i))
374 panic("Unable to reduce memory reservation\n");
376 /* Above is a suitable barrier to ensure backend will see requests. */
377 np->rx->req_prod = req_prod + i;
379 /* Adjust our fill target if we risked running out of buffers. */
380 if (((req_prod - np->rx->resp_prod) < (np->rx_target / 4)) &&
381 ((np->rx_target *= 2) > np->rx_max_target))
382 np->rx_target = np->rx_max_target;
383 }
386 static int network_start_xmit(struct sk_buff *skb, struct net_device *dev)
387 {
388 unsigned short id;
389 struct net_private *np = netdev_priv(dev);
390 netif_tx_request_t *tx;
391 NETIF_RING_IDX i;
392 grant_ref_t ref;
393 unsigned long mfn;
395 if (unlikely(np->tx_full)) {
396 printk(KERN_ALERT "%s: full queue wasn't stopped!\n",
397 dev->name);
398 netif_stop_queue(dev);
399 goto drop;
400 }
402 if (unlikely((((unsigned long)skb->data & ~PAGE_MASK) + skb->len) >=
403 PAGE_SIZE)) {
404 struct sk_buff *nskb;
405 if (unlikely((nskb = alloc_xen_skb(skb->len)) == NULL))
406 goto drop;
407 skb_put(nskb, skb->len);
408 memcpy(nskb->data, skb->data, skb->len);
409 nskb->dev = skb->dev;
410 dev_kfree_skb(skb);
411 skb = nskb;
412 }
414 spin_lock_irq(&np->tx_lock);
416 if (np->backend_state != BEST_CONNECTED) {
417 spin_unlock_irq(&np->tx_lock);
418 goto drop;
419 }
421 i = np->tx->req_prod;
423 id = GET_ID_FROM_FREELIST(np->tx_skbs);
424 np->tx_skbs[id] = skb;
426 tx = &np->tx->ring[MASK_NETIF_TX_IDX(i)].req;
428 tx->id = id;
429 ref = gnttab_claim_grant_reference(&np->gref_tx_head);
430 BUG_ON((signed short)ref < 0);
431 mfn = virt_to_mfn(skb->data);
432 gnttab_grant_foreign_access_ref(
433 ref, np->backend_id, mfn, GNTMAP_readonly);
434 tx->gref = np->grant_tx_ref[id] = ref;
435 tx->offset = (unsigned long)skb->data & ~PAGE_MASK;
436 tx->size = skb->len;
437 tx->csum_blank = (skb->ip_summed == CHECKSUM_HW);
439 wmb(); /* Ensure that backend will see the request. */
440 np->tx->req_prod = i + 1;
442 network_tx_buf_gc(dev);
444 if ((i - np->tx_resp_cons) == (NETIF_TX_RING_SIZE - 1)) {
445 np->tx_full = 1;
446 netif_stop_queue(dev);
447 }
449 spin_unlock_irq(&np->tx_lock);
451 np->stats.tx_bytes += skb->len;
452 np->stats.tx_packets++;
454 /* Only notify Xen if we really have to. */
455 mb();
456 if (np->tx->TX_TEST_IDX == i)
457 notify_remote_via_irq(np->irq);
459 return 0;
461 drop:
462 np->stats.tx_dropped++;
463 dev_kfree_skb(skb);
464 return 0;
465 }
467 static irqreturn_t netif_int(int irq, void *dev_id, struct pt_regs *ptregs)
468 {
469 struct net_device *dev = dev_id;
470 struct net_private *np = netdev_priv(dev);
471 unsigned long flags;
473 spin_lock_irqsave(&np->tx_lock, flags);
474 network_tx_buf_gc(dev);
475 spin_unlock_irqrestore(&np->tx_lock, flags);
477 if ((np->rx_resp_cons != np->rx->resp_prod) &&
478 (np->user_state == UST_OPEN))
479 netif_rx_schedule(dev);
481 return IRQ_HANDLED;
482 }
485 static int netif_poll(struct net_device *dev, int *pbudget)
486 {
487 struct net_private *np = netdev_priv(dev);
488 struct sk_buff *skb, *nskb;
489 netif_rx_response_t *rx;
490 NETIF_RING_IDX i, rp;
491 mmu_update_t *mmu = rx_mmu;
492 multicall_entry_t *mcl = rx_mcl;
493 int work_done, budget, more_to_do = 1;
494 struct sk_buff_head rxq;
495 unsigned long flags;
496 unsigned long mfn;
497 grant_ref_t ref;
499 spin_lock(&np->rx_lock);
501 if (np->backend_state != BEST_CONNECTED) {
502 spin_unlock(&np->rx_lock);
503 return 0;
504 }
506 skb_queue_head_init(&rxq);
508 if ((budget = *pbudget) > dev->quota)
509 budget = dev->quota;
510 rp = np->rx->resp_prod;
511 rmb(); /* Ensure we see queued responses up to 'rp'. */
513 for (i = np->rx_resp_cons, work_done = 0;
514 (i != rp) && (work_done < budget);
515 i++, work_done++) {
516 rx = &np->rx->ring[MASK_NETIF_RX_IDX(i)].resp;
517 /*
518 * An error here is very odd. Usually indicates a backend bug,
519 * low-mem condition, or we didn't have reservation headroom.
520 */
521 if (unlikely(rx->status <= 0)) {
522 if (net_ratelimit())
523 printk(KERN_WARNING "Bad rx buffer "
524 "(memory squeeze?).\n");
525 np->rx->ring[MASK_NETIF_RX_IDX(np->rx->req_prod)].
526 req.id = rx->id;
527 wmb();
528 np->rx->req_prod++;
529 work_done--;
530 continue;
531 }
533 ref = np->grant_rx_ref[rx->id];
535 if(ref == GRANT_INVALID_REF) {
536 printk(KERN_WARNING "Bad rx grant reference %d "
537 "from dom %d.\n",
538 ref, np->backend_id);
539 np->rx->ring[MASK_NETIF_RX_IDX(np->rx->req_prod)].
540 req.id = rx->id;
541 wmb();
542 np->rx->req_prod++;
543 work_done--;
544 continue;
545 }
547 np->grant_rx_ref[rx->id] = GRANT_INVALID_REF;
548 mfn = gnttab_end_foreign_transfer_ref(ref);
549 gnttab_release_grant_reference(&np->gref_rx_head, ref);
551 skb = np->rx_skbs[rx->id];
552 ADD_ID_TO_FREELIST(np->rx_skbs, rx->id);
554 /* NB. We handle skb overflow later. */
555 skb->data = skb->head + rx->offset;
556 skb->len = rx->status;
557 skb->tail = skb->data + skb->len;
559 if ( rx->csum_valid )
560 skb->ip_summed = CHECKSUM_UNNECESSARY;
562 np->stats.rx_packets++;
563 np->stats.rx_bytes += rx->status;
565 /* Remap the page. */
566 mmu->ptr = ((maddr_t)mfn << PAGE_SHIFT) | MMU_MACHPHYS_UPDATE;
567 mmu->val = __pa(skb->head) >> PAGE_SHIFT;
568 mmu++;
569 MULTI_update_va_mapping(mcl, (unsigned long)skb->head,
570 pfn_pte_ma(mfn, PAGE_KERNEL), 0);
571 mcl++;
573 phys_to_machine_mapping[__pa(skb->head) >> PAGE_SHIFT] = mfn;
575 __skb_queue_tail(&rxq, skb);
576 }
578 /* Some pages are no longer absent... */
579 balloon_update_driver_allowance(-work_done);
581 /* Do all the remapping work, and M2P updates, in one big hypercall. */
582 if (likely((mcl - rx_mcl) != 0)) {
583 mcl->op = __HYPERVISOR_mmu_update;
584 mcl->args[0] = (unsigned long)rx_mmu;
585 mcl->args[1] = mmu - rx_mmu;
586 mcl->args[2] = 0;
587 mcl->args[3] = DOMID_SELF;
588 mcl++;
589 (void)HYPERVISOR_multicall(rx_mcl, mcl - rx_mcl);
590 }
592 while ((skb = __skb_dequeue(&rxq)) != NULL) {
593 /*
594 * Enough room in skbuff for the data we were passed? Also,
595 * Linux expects at least 16 bytes headroom in each rx buffer.
596 */
597 if (unlikely(skb->tail > skb->end) ||
598 unlikely((skb->data - skb->head) < 16)) {
599 nskb = NULL;
601 /* Only copy the packet if it fits in the MTU. */
602 if (skb->len <= (dev->mtu + ETH_HLEN)) {
603 if ((skb->tail > skb->end) && net_ratelimit())
604 printk(KERN_INFO "Received packet "
605 "needs %zd bytes more "
606 "headroom.\n",
607 skb->tail - skb->end);
609 nskb = alloc_xen_skb(skb->len + 2);
610 if (nskb != NULL) {
611 skb_reserve(nskb, 2);
612 skb_put(nskb, skb->len);
613 memcpy(nskb->data,
614 skb->data,
615 skb->len);
616 nskb->dev = skb->dev;
617 }
618 }
619 else if (net_ratelimit())
620 printk(KERN_INFO "Received packet too big for "
621 "MTU (%d > %d)\n",
622 skb->len - ETH_HLEN, dev->mtu);
624 /* Reinitialise and then destroy the old skbuff. */
625 skb->len = 0;
626 skb->tail = skb->data;
627 init_skb_shinfo(skb);
628 dev_kfree_skb(skb);
630 /* Switch old for new, if we copied the buffer. */
631 if ((skb = nskb) == NULL)
632 continue;
633 }
635 /* Set the shinfo area, which is hidden behind the data. */
636 init_skb_shinfo(skb);
637 /* Ethernet work: Delayed to here as it peeks the header. */
638 skb->protocol = eth_type_trans(skb, dev);
640 /* Pass it up. */
641 netif_receive_skb(skb);
642 dev->last_rx = jiffies;
643 }
645 np->rx_resp_cons = i;
647 /* If we get a callback with very few responses, reduce fill target. */
648 /* NB. Note exponential increase, linear decrease. */
649 if (((np->rx->req_prod - np->rx->resp_prod) >
650 ((3*np->rx_target) / 4)) &&
651 (--np->rx_target < np->rx_min_target))
652 np->rx_target = np->rx_min_target;
654 network_alloc_rx_buffers(dev);
656 *pbudget -= work_done;
657 dev->quota -= work_done;
659 if (work_done < budget) {
660 local_irq_save(flags);
662 np->rx->event = i + 1;
664 /* Deal with hypervisor racing our resetting of rx_event. */
665 mb();
666 if (np->rx->resp_prod == i) {
667 __netif_rx_complete(dev);
668 more_to_do = 0;
669 }
671 local_irq_restore(flags);
672 }
674 spin_unlock(&np->rx_lock);
676 return more_to_do;
677 }
680 static int network_close(struct net_device *dev)
681 {
682 struct net_private *np = netdev_priv(dev);
683 np->user_state = UST_CLOSED;
684 netif_stop_queue(np->netdev);
685 return 0;
686 }
689 static struct net_device_stats *network_get_stats(struct net_device *dev)
690 {
691 struct net_private *np = netdev_priv(dev);
692 return &np->stats;
693 }
695 static void network_connect(struct net_device *dev)
696 {
697 struct net_private *np;
698 int i, requeue_idx;
699 netif_tx_request_t *tx;
700 struct sk_buff *skb;
702 np = netdev_priv(dev);
703 spin_lock_irq(&np->tx_lock);
704 spin_lock(&np->rx_lock);
706 /* Recovery procedure: */
708 /* Step 1: Reinitialise variables. */
709 np->rx_resp_cons = np->tx_resp_cons = np->tx_full = 0;
710 np->rx->event = np->tx->event = 1;
712 /*
713 * Step 2: Rebuild the RX and TX ring contents.
714 * NB. We could just free the queued TX packets now but we hope
715 * that sending them out might do some good. We have to rebuild
716 * the RX ring because some of our pages are currently flipped out
717 * so we can't just free the RX skbs.
718 * NB2. Freelist index entries are always going to be less than
719 * __PAGE_OFFSET, whereas pointers to skbs will always be equal or
720 * greater than __PAGE_OFFSET: we use this property to distinguish
721 * them.
722 */
724 /*
725 * Rebuild the TX buffer freelist and the TX ring itself.
726 * NB. This reorders packets. We could keep more private state
727 * to avoid this but maybe it doesn't matter so much given the
728 * interface has been down.
729 */
730 for (requeue_idx = 0, i = 1; i <= NETIF_TX_RING_SIZE; i++) {
731 if ((unsigned long)np->tx_skbs[i] < __PAGE_OFFSET)
732 continue;
734 skb = np->tx_skbs[i];
736 tx = &np->tx->ring[requeue_idx++].req;
738 tx->id = i;
739 gnttab_grant_foreign_access_ref(
740 np->grant_tx_ref[i], np->backend_id,
741 virt_to_mfn(np->tx_skbs[i]->data),
742 GNTMAP_readonly);
743 tx->gref = np->grant_tx_ref[i];
744 tx->offset = (unsigned long)skb->data & ~PAGE_MASK;
745 tx->size = skb->len;
746 tx->csum_blank = (skb->ip_summed == CHECKSUM_HW);
748 np->stats.tx_bytes += skb->len;
749 np->stats.tx_packets++;
750 }
751 wmb();
752 np->tx->req_prod = requeue_idx;
754 /* Rebuild the RX buffer freelist and the RX ring itself. */
755 for (requeue_idx = 0, i = 1; i <= NETIF_RX_RING_SIZE; i++) {
756 if ((unsigned long)np->rx_skbs[i] < __PAGE_OFFSET)
757 continue;
758 gnttab_grant_foreign_transfer_ref(
759 np->grant_rx_ref[i], np->backend_id);
760 np->rx->ring[requeue_idx].req.gref =
761 np->grant_rx_ref[i];
762 np->rx->ring[requeue_idx].req.id = i;
763 requeue_idx++;
764 }
765 wmb();
766 np->rx->req_prod = requeue_idx;
768 /*
769 * Step 3: All public and private state should now be sane. Get
770 * ready to start sending and receiving packets and give the driver
771 * domain a kick because we've probably just requeued some
772 * packets.
773 */
774 np->backend_state = BEST_CONNECTED;
775 wmb();
776 notify_remote_via_irq(np->irq);
777 network_tx_buf_gc(dev);
779 if (np->user_state == UST_OPEN)
780 netif_start_queue(dev);
782 spin_unlock(&np->rx_lock);
783 spin_unlock_irq(&np->tx_lock);
784 }
786 static void show_device(struct net_private *np)
787 {
788 #ifdef DEBUG
789 if (np) {
790 IPRINTK("<vif handle=%u %s(%s) evtchn=%u tx=%p rx=%p>\n",
791 np->handle,
792 be_state_name[np->backend_state],
793 np->user_state ? "open" : "closed",
794 np->evtchn,
795 np->tx,
796 np->rx);
797 } else {
798 IPRINTK("<vif NULL>\n");
799 }
800 #endif
801 }
803 /*
804 * Move the vif into connected state.
805 * Sets the mac and event channel from the message.
806 * Binds the irq to the event channel.
807 */
808 static void
809 connect_device(struct net_private *np, unsigned int evtchn)
810 {
811 struct net_device *dev = np->netdev;
812 memcpy(dev->dev_addr, np->mac, ETH_ALEN);
813 np->evtchn = evtchn;
814 network_connect(dev);
815 np->irq = bind_evtchn_to_irqhandler(
816 np->evtchn, netif_int, SA_SAMPLE_RANDOM, dev->name, dev);
817 (void)send_fake_arp(dev);
818 show_device(np);
819 }
821 static void netif_uninit(struct net_device *dev)
822 {
823 struct net_private *np = netdev_priv(dev);
824 gnttab_free_grant_references(np->gref_tx_head);
825 gnttab_free_grant_references(np->gref_rx_head);
826 }
828 static struct ethtool_ops network_ethtool_ops =
829 {
830 .get_tx_csum = ethtool_op_get_tx_csum,
831 .set_tx_csum = ethtool_op_set_tx_csum,
832 };
834 /** Create a network device.
835 * @param handle device handle
836 * @param val return parameter for created device
837 * @return 0 on success, error code otherwise
838 */
839 static int create_netdev(int handle, struct xenbus_device *dev,
840 struct net_device **val)
841 {
842 int i, err = 0;
843 struct net_device *netdev = NULL;
844 struct net_private *np = NULL;
846 if ((netdev = alloc_etherdev(sizeof(struct net_private))) == NULL) {
847 printk(KERN_WARNING "%s> alloc_etherdev failed.\n",
848 __FUNCTION__);
849 err = -ENOMEM;
850 goto exit;
851 }
853 np = netdev_priv(netdev);
854 np->backend_state = BEST_CLOSED;
855 np->user_state = UST_CLOSED;
856 np->handle = handle;
857 np->xbdev = dev;
859 spin_lock_init(&np->tx_lock);
860 spin_lock_init(&np->rx_lock);
862 skb_queue_head_init(&np->rx_batch);
863 np->rx_target = RX_MIN_TARGET;
864 np->rx_min_target = RX_MIN_TARGET;
865 np->rx_max_target = RX_MAX_TARGET;
867 /* Initialise {tx,rx}_skbs as a free chain containing every entry. */
868 for (i = 0; i <= NETIF_TX_RING_SIZE; i++) {
869 np->tx_skbs[i] = (void *)((unsigned long) i+1);
870 np->grant_tx_ref[i] = GRANT_INVALID_REF;
871 }
873 for (i = 0; i <= NETIF_RX_RING_SIZE; i++) {
874 np->rx_skbs[i] = (void *)((unsigned long) i+1);
875 np->grant_rx_ref[i] = GRANT_INVALID_REF;
876 }
878 /* A grant for every tx ring slot */
879 if (gnttab_alloc_grant_references(NETIF_TX_RING_SIZE,
880 &np->gref_tx_head) < 0) {
881 printk(KERN_ALERT "#### netfront can't alloc tx grant refs\n");
882 goto exit;
883 }
884 /* A grant for every rx ring slot */
885 if (gnttab_alloc_grant_references(NETIF_RX_RING_SIZE,
886 &np->gref_rx_head) < 0) {
887 printk(KERN_ALERT "#### netfront can't alloc rx grant refs\n");
888 gnttab_free_grant_references(np->gref_tx_head);
889 goto exit;
890 }
892 netdev->open = network_open;
893 netdev->hard_start_xmit = network_start_xmit;
894 netdev->stop = network_close;
895 netdev->get_stats = network_get_stats;
896 netdev->poll = netif_poll;
897 netdev->uninit = netif_uninit;
898 netdev->weight = 64;
899 netdev->features = NETIF_F_IP_CSUM;
901 SET_ETHTOOL_OPS(netdev, &network_ethtool_ops);
902 SET_MODULE_OWNER(netdev);
903 SET_NETDEV_DEV(netdev, &dev->dev);
905 if ((err = register_netdev(netdev)) != 0) {
906 printk(KERN_WARNING "%s> register_netdev err=%d\n",
907 __FUNCTION__, err);
908 goto exit_free_grefs;
909 }
911 if ((err = xennet_proc_addif(netdev)) != 0) {
912 unregister_netdev(netdev);
913 goto exit_free_grefs;
914 }
916 np->netdev = netdev;
918 exit:
919 if ((err != 0) && (netdev != NULL))
920 kfree(netdev);
921 else if (val != NULL)
922 *val = netdev;
923 return err;
925 exit_free_grefs:
926 gnttab_free_grant_references(np->gref_tx_head);
927 gnttab_free_grant_references(np->gref_rx_head);
928 goto exit;
929 }
931 static int destroy_netdev(struct net_device *netdev)
932 {
933 #ifdef CONFIG_PROC_FS
934 xennet_proc_delif(netdev);
935 #endif
936 unregister_netdev(netdev);
937 return 0;
938 }
940 /*
941 * We use this notifier to send out a fake ARP reply to reset switches and
942 * router ARP caches when an IP interface is brought up on a VIF.
943 */
944 static int
945 inetdev_notify(struct notifier_block *this, unsigned long event, void *ptr)
946 {
947 struct in_ifaddr *ifa = (struct in_ifaddr *)ptr;
948 struct net_device *dev = ifa->ifa_dev->dev;
950 /* UP event and is it one of our devices? */
951 if (event == NETDEV_UP && dev->open == network_open)
952 (void)send_fake_arp(dev);
954 return NOTIFY_DONE;
955 }
957 static struct notifier_block notifier_inetdev = {
958 .notifier_call = inetdev_notify,
959 .next = NULL,
960 .priority = 0
961 };
963 static struct xenbus_device_id netfront_ids[] = {
964 { "vif" },
965 { "" }
966 };
968 static void watch_for_status(struct xenbus_watch *watch,
969 const char **vec, unsigned int len)
970 {
971 }
973 static int setup_device(struct xenbus_device *dev, struct netfront_info *info)
974 {
975 int err;
976 evtchn_op_t op = {
977 .cmd = EVTCHNOP_alloc_unbound,
978 .u.alloc_unbound.dom = DOMID_SELF,
979 .u.alloc_unbound.remote_dom = info->backend_id };
981 info->tx_ring_ref = GRANT_INVALID_REF;
982 info->rx_ring_ref = GRANT_INVALID_REF;
983 info->rx = NULL;
984 info->tx = NULL;
985 info->irq = 0;
987 info->tx = (netif_tx_interface_t *)__get_free_page(GFP_KERNEL);
988 if (info->tx == 0) {
989 err = -ENOMEM;
990 xenbus_dev_error(dev, err, "allocating tx ring page");
991 goto out;
992 }
993 info->rx = (netif_rx_interface_t *)__get_free_page(GFP_KERNEL);
994 if (info->rx == 0) {
995 err = -ENOMEM;
996 xenbus_dev_error(dev, err, "allocating rx ring page");
997 goto out;
998 }
999 memset(info->tx, 0, PAGE_SIZE);
1000 memset(info->rx, 0, PAGE_SIZE);
1001 info->backend_state = BEST_DISCONNECTED;
1003 err = gnttab_grant_foreign_access(info->backend_id,
1004 virt_to_mfn(info->tx), 0);
1005 if (err < 0) {
1006 xenbus_dev_error(dev, err, "granting access to tx ring page");
1007 goto out;
1009 info->tx_ring_ref = err;
1011 err = gnttab_grant_foreign_access(info->backend_id,
1012 virt_to_mfn(info->rx), 0);
1013 if (err < 0) {
1014 xenbus_dev_error(dev, err, "granting access to rx ring page");
1015 goto out;
1017 info->rx_ring_ref = err;
1019 err = HYPERVISOR_event_channel_op(&op);
1020 if (err) {
1021 xenbus_dev_error(dev, err, "allocating event channel");
1022 goto out;
1025 connect_device(info, op.u.alloc_unbound.port);
1027 return 0;
1029 out:
1030 netif_free(info);
1031 return err;
1034 static void end_access(int ref, void *page)
1036 if (ref != GRANT_INVALID_REF)
1037 gnttab_end_foreign_access(ref, 0, (unsigned long)page);
1040 static void netif_free(struct netfront_info *info)
1042 end_access(info->tx_ring_ref, info->tx);
1043 end_access(info->rx_ring_ref, info->rx);
1044 info->tx_ring_ref = GRANT_INVALID_REF;
1045 info->rx_ring_ref = GRANT_INVALID_REF;
1046 info->tx = NULL;
1047 info->rx = NULL;
1049 if (info->irq)
1050 unbind_evtchn_from_irqhandler(info->irq, info->netdev);
1051 info->evtchn = info->irq = 0;
1054 /* Stop network device and free tx/rx queues and irq. */
1055 static void shutdown_device(struct net_private *np)
1057 /* Stop old i/f to prevent errors whilst we rebuild the state. */
1058 spin_lock_irq(&np->tx_lock);
1059 spin_lock(&np->rx_lock);
1060 netif_stop_queue(np->netdev);
1061 /* np->backend_state = BEST_DISCONNECTED; */
1062 spin_unlock(&np->rx_lock);
1063 spin_unlock_irq(&np->tx_lock);
1065 /* Free resources. */
1066 netif_free(np);
1069 /* Common code used when first setting up, and when resuming. */
1070 static int talk_to_backend(struct xenbus_device *dev,
1071 struct netfront_info *info)
1073 char *backend, *mac, *e, *s;
1074 const char *message;
1075 struct xenbus_transaction *xbt;
1076 int err, i;
1078 backend = NULL;
1079 err = xenbus_gather(NULL, dev->nodename,
1080 "backend-id", "%i", &info->backend_id,
1081 "backend", NULL, &backend,
1082 NULL);
1083 if (XENBUS_EXIST_ERR(err))
1084 goto out;
1085 if (backend && strlen(backend) == 0) {
1086 err = -ENOENT;
1087 goto out;
1089 if (err < 0) {
1090 xenbus_dev_error(dev, err, "reading %s/backend or backend-id",
1091 dev->nodename);
1092 goto out;
1095 mac = xenbus_read(NULL, dev->nodename, "mac", NULL);
1096 if (IS_ERR(mac)) {
1097 err = PTR_ERR(mac);
1098 xenbus_dev_error(dev, err, "reading %s/mac",
1099 dev->nodename);
1100 goto out;
1102 s = mac;
1103 for (i = 0; i < ETH_ALEN; i++) {
1104 info->mac[i] = simple_strtoul(s, &e, 16);
1105 if (s == e || (e[0] != ':' && e[0] != 0)) {
1106 kfree(mac);
1107 err = -ENOENT;
1108 xenbus_dev_error(dev, err, "parsing %s/mac",
1109 dev->nodename);
1110 goto out;
1112 s = &e[1];
1114 kfree(mac);
1116 /* Create shared ring, alloc event channel. */
1117 err = setup_device(dev, info);
1118 if (err) {
1119 xenbus_dev_error(dev, err, "setting up ring");
1120 goto out;
1123 again:
1124 xbt = xenbus_transaction_start();
1125 if (IS_ERR(xbt)) {
1126 xenbus_dev_error(dev, err, "starting transaction");
1127 goto destroy_ring;
1130 err = xenbus_printf(xbt, dev->nodename, "tx-ring-ref","%u",
1131 info->tx_ring_ref);
1132 if (err) {
1133 message = "writing tx ring-ref";
1134 goto abort_transaction;
1136 err = xenbus_printf(xbt, dev->nodename, "rx-ring-ref","%u",
1137 info->rx_ring_ref);
1138 if (err) {
1139 message = "writing rx ring-ref";
1140 goto abort_transaction;
1142 err = xenbus_printf(xbt, dev->nodename,
1143 "event-channel", "%u", info->evtchn);
1144 if (err) {
1145 message = "writing event-channel";
1146 goto abort_transaction;
1149 err = xenbus_transaction_end(xbt, 0);
1150 if (err) {
1151 if (err == -EAGAIN)
1152 goto again;
1153 xenbus_dev_error(dev, err, "completing transaction");
1154 goto destroy_ring;
1157 info->watch.node = backend;
1158 info->watch.callback = watch_for_status;
1159 err = register_xenbus_watch(&info->watch);
1160 if (err) {
1161 message = "registering watch on backend";
1162 goto destroy_ring;
1165 info->backend = backend;
1167 return 0;
1169 abort_transaction:
1170 xenbus_transaction_end(xbt, 1);
1171 xenbus_dev_error(dev, err, "%s", message);
1172 destroy_ring:
1173 shutdown_device(info);
1174 out:
1175 if (backend)
1176 kfree(backend);
1177 return err;
1180 /*
1181 * Setup supplies the backend dir, virtual device.
1182 * We place an event channel and shared frame entries.
1183 * We watch backend to wait if it's ok.
1184 */
1185 static int netfront_probe(struct xenbus_device *dev,
1186 const struct xenbus_device_id *id)
1188 int err;
1189 struct net_device *netdev;
1190 struct netfront_info *info;
1191 unsigned int handle;
1193 err = xenbus_scanf(NULL, dev->nodename, "handle", "%u", &handle);
1194 if (XENBUS_EXIST_ERR(err))
1195 return err;
1196 if (err < 0) {
1197 xenbus_dev_error(dev, err, "reading handle");
1198 return err;
1201 err = create_netdev(handle, dev, &netdev);
1202 if (err) {
1203 xenbus_dev_error(dev, err, "creating netdev");
1204 return err;
1207 info = netdev_priv(netdev);
1208 dev->data = info;
1210 err = talk_to_backend(dev, info);
1211 if (err) {
1212 destroy_netdev(netdev);
1213 kfree(netdev);
1214 dev->data = NULL;
1215 return err;
1218 return 0;
1221 static int netfront_remove(struct xenbus_device *dev)
1223 struct netfront_info *info = dev->data;
1225 if (info->backend)
1226 unregister_xenbus_watch(&info->watch);
1228 netif_free(info);
1230 kfree(info->backend);
1231 kfree(info);
1233 return 0;
1236 static int netfront_suspend(struct xenbus_device *dev)
1238 struct netfront_info *info = dev->data;
1239 unregister_xenbus_watch(&info->watch);
1240 kfree(info->backend);
1241 info->backend = NULL;
1242 return 0;
1245 static int netfront_resume(struct xenbus_device *dev)
1247 struct netfront_info *info = dev->data;
1248 netif_free(info);
1249 return talk_to_backend(dev, info);
1252 static struct xenbus_driver netfront = {
1253 .name = "vif",
1254 .owner = THIS_MODULE,
1255 .ids = netfront_ids,
1256 .probe = netfront_probe,
1257 .remove = netfront_remove,
1258 .resume = netfront_resume,
1259 .suspend = netfront_suspend,
1260 };
1262 static void __init init_net_xenbus(void)
1264 xenbus_register_driver(&netfront);
1267 static int __init netif_init(void)
1269 int err = 0;
1271 if (xen_start_info->flags & SIF_INITDOMAIN)
1272 return 0;
1274 if ((err = xennet_proc_init()) != 0)
1275 return err;
1277 IPRINTK("Initialising virtual ethernet driver.\n");
1279 (void)register_inetaddr_notifier(&notifier_inetdev);
1281 init_net_xenbus();
1283 return err;
1286 static void netif_exit(void)
1290 #ifdef CONFIG_PROC_FS
1292 #define TARGET_MIN 0UL
1293 #define TARGET_MAX 1UL
1294 #define TARGET_CUR 2UL
1296 static int xennet_proc_read(
1297 char *page, char **start, off_t off, int count, int *eof, void *data)
1299 struct net_device *dev =
1300 (struct net_device *)((unsigned long)data & ~3UL);
1301 struct net_private *np = netdev_priv(dev);
1302 int len = 0, which_target = (long)data & 3;
1304 switch (which_target)
1306 case TARGET_MIN:
1307 len = sprintf(page, "%d\n", np->rx_min_target);
1308 break;
1309 case TARGET_MAX:
1310 len = sprintf(page, "%d\n", np->rx_max_target);
1311 break;
1312 case TARGET_CUR:
1313 len = sprintf(page, "%d\n", np->rx_target);
1314 break;
1317 *eof = 1;
1318 return len;
1321 static int xennet_proc_write(
1322 struct file *file, const char __user *buffer,
1323 unsigned long count, void *data)
1325 struct net_device *dev =
1326 (struct net_device *)((unsigned long)data & ~3UL);
1327 struct net_private *np = netdev_priv(dev);
1328 int which_target = (long)data & 3;
1329 char string[64];
1330 long target;
1332 if (!capable(CAP_SYS_ADMIN))
1333 return -EPERM;
1335 if (count <= 1)
1336 return -EBADMSG; /* runt */
1337 if (count > sizeof(string))
1338 return -EFBIG; /* too long */
1340 if (copy_from_user(string, buffer, count))
1341 return -EFAULT;
1342 string[sizeof(string)-1] = '\0';
1344 target = simple_strtol(string, NULL, 10);
1345 if (target < RX_MIN_TARGET)
1346 target = RX_MIN_TARGET;
1347 if (target > RX_MAX_TARGET)
1348 target = RX_MAX_TARGET;
1350 spin_lock(&np->rx_lock);
1352 switch (which_target)
1354 case TARGET_MIN:
1355 if (target > np->rx_max_target)
1356 np->rx_max_target = target;
1357 np->rx_min_target = target;
1358 if (target > np->rx_target)
1359 np->rx_target = target;
1360 break;
1361 case TARGET_MAX:
1362 if (target < np->rx_min_target)
1363 np->rx_min_target = target;
1364 np->rx_max_target = target;
1365 if (target < np->rx_target)
1366 np->rx_target = target;
1367 break;
1368 case TARGET_CUR:
1369 break;
1372 network_alloc_rx_buffers(dev);
1374 spin_unlock(&np->rx_lock);
1376 return count;
1379 static int xennet_proc_init(void)
1381 if (proc_mkdir("xen/net", NULL) == NULL)
1382 return -ENOMEM;
1383 return 0;
1386 static int xennet_proc_addif(struct net_device *dev)
1388 struct proc_dir_entry *dir, *min, *max, *cur;
1389 char name[30];
1391 sprintf(name, "xen/net/%s", dev->name);
1393 dir = proc_mkdir(name, NULL);
1394 if (!dir)
1395 goto nomem;
1397 min = create_proc_entry("rxbuf_min", 0644, dir);
1398 max = create_proc_entry("rxbuf_max", 0644, dir);
1399 cur = create_proc_entry("rxbuf_cur", 0444, dir);
1400 if (!min || !max || !cur)
1401 goto nomem;
1403 min->read_proc = xennet_proc_read;
1404 min->write_proc = xennet_proc_write;
1405 min->data = (void *)((unsigned long)dev | TARGET_MIN);
1407 max->read_proc = xennet_proc_read;
1408 max->write_proc = xennet_proc_write;
1409 max->data = (void *)((unsigned long)dev | TARGET_MAX);
1411 cur->read_proc = xennet_proc_read;
1412 cur->write_proc = xennet_proc_write;
1413 cur->data = (void *)((unsigned long)dev | TARGET_CUR);
1415 return 0;
1417 nomem:
1418 xennet_proc_delif(dev);
1419 return -ENOMEM;
1422 static void xennet_proc_delif(struct net_device *dev)
1424 char name[30];
1426 sprintf(name, "xen/net/%s/rxbuf_min", dev->name);
1427 remove_proc_entry(name, NULL);
1429 sprintf(name, "xen/net/%s/rxbuf_max", dev->name);
1430 remove_proc_entry(name, NULL);
1432 sprintf(name, "xen/net/%s/rxbuf_cur", dev->name);
1433 remove_proc_entry(name, NULL);
1435 sprintf(name, "xen/net/%s", dev->name);
1436 remove_proc_entry(name, NULL);
1439 #endif
1441 module_init(netif_init);
1442 module_exit(netif_exit);
1444 /*
1445 * Local variables:
1446 * c-file-style: "linux"
1447 * indent-tabs-mode: t
1448 * c-indent-level: 8
1449 * c-basic-offset: 8
1450 * tab-width: 8
1451 * End:
1452 */