diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/net/wan/lmc/lmc_proto.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'drivers/net/wan/lmc/lmc_proto.c')
-rw-r--r-- | drivers/net/wan/lmc/lmc_proto.c | 249 |
1 files changed, 249 insertions, 0 deletions
diff --git a/drivers/net/wan/lmc/lmc_proto.c b/drivers/net/wan/lmc/lmc_proto.c new file mode 100644 index 000000000000..74876c0073e8 --- /dev/null +++ b/drivers/net/wan/lmc/lmc_proto.c | |||
@@ -0,0 +1,249 @@ | |||
1 | /* | ||
2 | * Copyright (c) 1997-2000 LAN Media Corporation (LMC) | ||
3 | * All rights reserved. www.lanmedia.com | ||
4 | * | ||
5 | * This code is written by: | ||
6 | * Andrew Stanley-Jones (asj@cban.com) | ||
7 | * Rob Braun (bbraun@vix.com), | ||
8 | * Michael Graff (explorer@vix.com) and | ||
9 | * Matt Thomas (matt@3am-software.com). | ||
10 | * | ||
11 | * With Help By: | ||
12 | * David Boggs | ||
13 | * Ron Crane | ||
14 | * Allan Cox | ||
15 | * | ||
16 | * This software may be used and distributed according to the terms | ||
17 | * of the GNU General Public License version 2, incorporated herein by reference. | ||
18 | * | ||
19 | * Driver for the LanMedia LMC5200, LMC5245, LMC1000, LMC1200 cards. | ||
20 | */ | ||
21 | |||
22 | #include <linux/kernel.h> | ||
23 | #include <linux/string.h> | ||
24 | #include <linux/timer.h> | ||
25 | #include <linux/ptrace.h> | ||
26 | #include <linux/errno.h> | ||
27 | #include <linux/ioport.h> | ||
28 | #include <linux/slab.h> | ||
29 | #include <linux/interrupt.h> | ||
30 | #include <linux/pci.h> | ||
31 | #include <linux/in.h> | ||
32 | #include <linux/if_arp.h> | ||
33 | #include <linux/netdevice.h> | ||
34 | #include <linux/etherdevice.h> | ||
35 | #include <linux/skbuff.h> | ||
36 | #include <linux/inet.h> | ||
37 | #include <linux/workqueue.h> | ||
38 | #include <linux/proc_fs.h> | ||
39 | #include <linux/bitops.h> | ||
40 | |||
41 | #include <net/syncppp.h> | ||
42 | |||
43 | #include <asm/processor.h> /* Processor type for cache alignment. */ | ||
44 | #include <asm/io.h> | ||
45 | #include <asm/dma.h> | ||
46 | #include <linux/smp.h> | ||
47 | |||
48 | #include "lmc.h" | ||
49 | #include "lmc_var.h" | ||
50 | #include "lmc_debug.h" | ||
51 | #include "lmc_ioctl.h" | ||
52 | #include "lmc_proto.h" | ||
53 | |||
54 | /* | ||
55 | * The compile-time variable SPPPSTUP causes the module to be | ||
56 | * compiled without referencing any of the sync ppp routines. | ||
57 | */ | ||
58 | #ifdef SPPPSTUB | ||
59 | #define SPPP_detach(d) (void)0 | ||
60 | #define SPPP_open(d) 0 | ||
61 | #define SPPP_reopen(d) (void)0 | ||
62 | #define SPPP_close(d) (void)0 | ||
63 | #define SPPP_attach(d) (void)0 | ||
64 | #define SPPP_do_ioctl(d,i,c) -EOPNOTSUPP | ||
65 | #else | ||
66 | #define SPPP_attach(x) sppp_attach((x)->pd) | ||
67 | #define SPPP_detach(x) sppp_detach((x)->pd->dev) | ||
68 | #define SPPP_open(x) sppp_open((x)->pd->dev) | ||
69 | #define SPPP_reopen(x) sppp_reopen((x)->pd->dev) | ||
70 | #define SPPP_close(x) sppp_close((x)->pd->dev) | ||
71 | #define SPPP_do_ioctl(x, y, z) sppp_do_ioctl((x)->pd->dev, (y), (z)) | ||
72 | #endif | ||
73 | |||
74 | // init | ||
75 | void lmc_proto_init(lmc_softc_t *sc) /*FOLD00*/ | ||
76 | { | ||
77 | lmc_trace(sc->lmc_device, "lmc_proto_init in"); | ||
78 | switch(sc->if_type){ | ||
79 | case LMC_PPP: | ||
80 | sc->pd = kmalloc(sizeof(struct ppp_device), GFP_KERNEL); | ||
81 | if (!sc->pd) { | ||
82 | printk("lmc_proto_init(): kmalloc failure!\n"); | ||
83 | return; | ||
84 | } | ||
85 | sc->pd->dev = sc->lmc_device; | ||
86 | sc->if_ptr = sc->pd; | ||
87 | break; | ||
88 | case LMC_RAW: | ||
89 | break; | ||
90 | default: | ||
91 | break; | ||
92 | } | ||
93 | lmc_trace(sc->lmc_device, "lmc_proto_init out"); | ||
94 | } | ||
95 | |||
96 | // attach | ||
97 | void lmc_proto_attach(lmc_softc_t *sc) /*FOLD00*/ | ||
98 | { | ||
99 | lmc_trace(sc->lmc_device, "lmc_proto_attach in"); | ||
100 | switch(sc->if_type){ | ||
101 | case LMC_PPP: | ||
102 | { | ||
103 | struct net_device *dev = sc->lmc_device; | ||
104 | SPPP_attach(sc); | ||
105 | dev->do_ioctl = lmc_ioctl; | ||
106 | } | ||
107 | break; | ||
108 | case LMC_NET: | ||
109 | { | ||
110 | struct net_device *dev = sc->lmc_device; | ||
111 | /* | ||
112 | * They set a few basics because they don't use sync_ppp | ||
113 | */ | ||
114 | dev->flags |= IFF_POINTOPOINT; | ||
115 | dev->hard_header = NULL; | ||
116 | dev->hard_header_len = 0; | ||
117 | dev->addr_len = 0; | ||
118 | } | ||
119 | case LMC_RAW: /* Setup the task queue, maybe we should notify someone? */ | ||
120 | { | ||
121 | } | ||
122 | default: | ||
123 | break; | ||
124 | } | ||
125 | lmc_trace(sc->lmc_device, "lmc_proto_attach out"); | ||
126 | } | ||
127 | |||
128 | // detach | ||
129 | void lmc_proto_detach(lmc_softc_t *sc) /*FOLD00*/ | ||
130 | { | ||
131 | switch(sc->if_type){ | ||
132 | case LMC_PPP: | ||
133 | SPPP_detach(sc); | ||
134 | break; | ||
135 | case LMC_RAW: /* Tell someone we're detaching? */ | ||
136 | break; | ||
137 | default: | ||
138 | break; | ||
139 | } | ||
140 | |||
141 | } | ||
142 | |||
143 | // reopen | ||
144 | void lmc_proto_reopen(lmc_softc_t *sc) /*FOLD00*/ | ||
145 | { | ||
146 | lmc_trace(sc->lmc_device, "lmc_proto_reopen in"); | ||
147 | switch(sc->if_type){ | ||
148 | case LMC_PPP: | ||
149 | SPPP_reopen(sc); | ||
150 | break; | ||
151 | case LMC_RAW: /* Reset the interface after being down, prerape to receive packets again */ | ||
152 | break; | ||
153 | default: | ||
154 | break; | ||
155 | } | ||
156 | lmc_trace(sc->lmc_device, "lmc_proto_reopen out"); | ||
157 | } | ||
158 | |||
159 | |||
160 | // ioctl | ||
161 | int lmc_proto_ioctl(lmc_softc_t *sc, struct ifreq *ifr, int cmd) /*FOLD00*/ | ||
162 | { | ||
163 | lmc_trace(sc->lmc_device, "lmc_proto_ioctl out"); | ||
164 | switch(sc->if_type){ | ||
165 | case LMC_PPP: | ||
166 | return SPPP_do_ioctl (sc, ifr, cmd); | ||
167 | break; | ||
168 | default: | ||
169 | return -EOPNOTSUPP; | ||
170 | break; | ||
171 | } | ||
172 | lmc_trace(sc->lmc_device, "lmc_proto_ioctl out"); | ||
173 | } | ||
174 | |||
175 | // open | ||
176 | void lmc_proto_open(lmc_softc_t *sc) /*FOLD00*/ | ||
177 | { | ||
178 | int ret; | ||
179 | |||
180 | lmc_trace(sc->lmc_device, "lmc_proto_open in"); | ||
181 | switch(sc->if_type){ | ||
182 | case LMC_PPP: | ||
183 | ret = SPPP_open(sc); | ||
184 | if(ret < 0) | ||
185 | printk("%s: syncPPP open failed: %d\n", sc->name, ret); | ||
186 | break; | ||
187 | case LMC_RAW: /* We're about to start getting packets! */ | ||
188 | break; | ||
189 | default: | ||
190 | break; | ||
191 | } | ||
192 | lmc_trace(sc->lmc_device, "lmc_proto_open out"); | ||
193 | } | ||
194 | |||
195 | // close | ||
196 | |||
197 | void lmc_proto_close(lmc_softc_t *sc) /*FOLD00*/ | ||
198 | { | ||
199 | lmc_trace(sc->lmc_device, "lmc_proto_close in"); | ||
200 | switch(sc->if_type){ | ||
201 | case LMC_PPP: | ||
202 | SPPP_close(sc); | ||
203 | break; | ||
204 | case LMC_RAW: /* Interface going down */ | ||
205 | break; | ||
206 | default: | ||
207 | break; | ||
208 | } | ||
209 | lmc_trace(sc->lmc_device, "lmc_proto_close out"); | ||
210 | } | ||
211 | |||
212 | unsigned short lmc_proto_type(lmc_softc_t *sc, struct sk_buff *skb) /*FOLD00*/ | ||
213 | { | ||
214 | lmc_trace(sc->lmc_device, "lmc_proto_type in"); | ||
215 | switch(sc->if_type){ | ||
216 | case LMC_PPP: | ||
217 | return htons(ETH_P_WAN_PPP); | ||
218 | break; | ||
219 | case LMC_NET: | ||
220 | return htons(ETH_P_802_2); | ||
221 | break; | ||
222 | case LMC_RAW: /* Packet type for skbuff kind of useless */ | ||
223 | return htons(ETH_P_802_2); | ||
224 | break; | ||
225 | default: | ||
226 | printk(KERN_WARNING "%s: No protocol set for this interface, assuming 802.2 (which is wrong!!)\n", sc->name); | ||
227 | return htons(ETH_P_802_2); | ||
228 | break; | ||
229 | } | ||
230 | lmc_trace(sc->lmc_device, "lmc_proto_tye out"); | ||
231 | |||
232 | } | ||
233 | |||
234 | void lmc_proto_netif(lmc_softc_t *sc, struct sk_buff *skb) /*FOLD00*/ | ||
235 | { | ||
236 | lmc_trace(sc->lmc_device, "lmc_proto_netif in"); | ||
237 | switch(sc->if_type){ | ||
238 | case LMC_PPP: | ||
239 | case LMC_NET: | ||
240 | default: | ||
241 | skb->dev->last_rx = jiffies; | ||
242 | netif_rx(skb); | ||
243 | break; | ||
244 | case LMC_RAW: | ||
245 | break; | ||
246 | } | ||
247 | lmc_trace(sc->lmc_device, "lmc_proto_netif out"); | ||
248 | } | ||
249 | |||