Revert "Fix very high interrupt rate for IRQ8 (rtc) unless pnpacpi=off"
[pv_ops_mirror.git] / arch / um / drivers / slirp_kern.c
blobd987af277db9d8f1cc943aa72ab46201e57cbb58
1 /*
2 * Copyright (C) 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3 * Licensed under the GPL.
4 */
6 #include <linux/if_arp.h>
7 #include "linux/init.h"
8 #include <linux/netdevice.h>
9 #include <linux/string.h>
10 #include "net_kern.h"
11 #include "net_user.h"
12 #include "slirp.h"
14 struct slirp_init {
15 struct arg_list_dummy_wrapper argw; /* XXX should be simpler... */
18 void slirp_init(struct net_device *dev, void *data)
20 struct uml_net_private *private;
21 struct slirp_data *spri;
22 struct slirp_init *init = data;
23 int i;
25 private = dev->priv;
26 spri = (struct slirp_data *) private->user;
28 spri->argw = init->argw;
29 spri->pid = -1;
30 spri->slave = -1;
31 spri->dev = dev;
33 slip_proto_init(&spri->slip);
35 dev->init = NULL;
36 dev->hard_header_len = 0;
37 dev->header_ops = NULL;
38 dev->addr_len = 0;
39 dev->type = ARPHRD_SLIP;
40 dev->tx_queue_len = 256;
41 dev->flags = IFF_NOARP;
42 printk("SLIRP backend - command line:");
43 for (i = 0; spri->argw.argv[i] != NULL; i++)
44 printk(" '%s'",spri->argw.argv[i]);
45 printk("\n");
48 static unsigned short slirp_protocol(struct sk_buff *skbuff)
50 return htons(ETH_P_IP);
53 static int slirp_read(int fd, struct sk_buff *skb, struct uml_net_private *lp)
55 return slirp_user_read(fd, skb_mac_header(skb), skb->dev->mtu,
56 (struct slirp_data *) &lp->user);
59 static int slirp_write(int fd, struct sk_buff *skb, struct uml_net_private *lp)
61 return slirp_user_write(fd, skb->data, skb->len,
62 (struct slirp_data *) &lp->user);
65 const struct net_kern_info slirp_kern_info = {
66 .init = slirp_init,
67 .protocol = slirp_protocol,
68 .read = slirp_read,
69 .write = slirp_write,
72 static int slirp_setup(char *str, char **mac_out, void *data)
74 struct slirp_init *init = data;
75 int i=0;
77 *init = ((struct slirp_init) { .argw = { { "slirp", NULL } } });
79 str = split_if_spec(str, mac_out, NULL);
81 if (str == NULL) /* no command line given after MAC addr */
82 return 1;
84 do {
85 if (i >= SLIRP_MAX_ARGS - 1) {
86 printk(KERN_WARNING "slirp_setup: truncating slirp "
87 "arguments\n");
88 break;
90 init->argw.argv[i++] = str;
91 while(*str && *str!=',') {
92 if (*str == '_')
93 *str=' ';
94 str++;
96 if (*str != ',')
97 break;
98 *str++ = '\0';
99 } while (1);
101 init->argw.argv[i] = NULL;
102 return 1;
105 static struct transport slirp_transport = {
106 .list = LIST_HEAD_INIT(slirp_transport.list),
107 .name = "slirp",
108 .setup = slirp_setup,
109 .user = &slirp_user_info,
110 .kern = &slirp_kern_info,
111 .private_size = sizeof(struct slirp_data),
112 .setup_size = sizeof(struct slirp_init),
115 static int register_slirp(void)
117 register_transport(&slirp_transport);
118 return 0;
121 late_initcall(register_slirp);