[NET]: Move hardware header operations out of netdevice.
[deliverable/linux.git] / drivers / net / wan / lmc / lmc_proto.c
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/in.h>
31 #include <linux/if_arp.h>
32 #include <linux/netdevice.h>
33 #include <linux/etherdevice.h>
34 #include <linux/skbuff.h>
35 #include <linux/inet.h>
36 #include <linux/workqueue.h>
37 #include <linux/proc_fs.h>
38 #include <linux/bitops.h>
39
40 #include <net/syncppp.h>
41
42 #include <asm/processor.h> /* Processor type for cache alignment. */
43 #include <asm/io.h>
44 #include <asm/dma.h>
45 #include <linux/smp.h>
46
47 #include "lmc.h"
48 #include "lmc_var.h"
49 #include "lmc_debug.h"
50 #include "lmc_ioctl.h"
51 #include "lmc_proto.h"
52
53 /*
54 * The compile-time variable SPPPSTUP causes the module to be
55 * compiled without referencing any of the sync ppp routines.
56 */
57 #ifdef SPPPSTUB
58 #define SPPP_detach(d) (void)0
59 #define SPPP_open(d) 0
60 #define SPPP_reopen(d) (void)0
61 #define SPPP_close(d) (void)0
62 #define SPPP_attach(d) (void)0
63 #define SPPP_do_ioctl(d,i,c) -EOPNOTSUPP
64 #else
65 #define SPPP_attach(x) sppp_attach((x)->pd)
66 #define SPPP_detach(x) sppp_detach((x)->pd->dev)
67 #define SPPP_open(x) sppp_open((x)->pd->dev)
68 #define SPPP_reopen(x) sppp_reopen((x)->pd->dev)
69 #define SPPP_close(x) sppp_close((x)->pd->dev)
70 #define SPPP_do_ioctl(x, y, z) sppp_do_ioctl((x)->pd->dev, (y), (z))
71 #endif
72
73 // init
74 void lmc_proto_init(lmc_softc_t *sc) /*FOLD00*/
75 {
76 lmc_trace(sc->lmc_device, "lmc_proto_init in");
77 switch(sc->if_type){
78 case LMC_PPP:
79 sc->pd = kmalloc(sizeof(struct ppp_device), GFP_KERNEL);
80 if (!sc->pd) {
81 printk("lmc_proto_init(): kmalloc failure!\n");
82 return;
83 }
84 sc->pd->dev = sc->lmc_device;
85 sc->if_ptr = sc->pd;
86 break;
87 case LMC_RAW:
88 break;
89 default:
90 break;
91 }
92 lmc_trace(sc->lmc_device, "lmc_proto_init out");
93 }
94
95 // attach
96 void lmc_proto_attach(lmc_softc_t *sc) /*FOLD00*/
97 {
98 lmc_trace(sc->lmc_device, "lmc_proto_attach in");
99 switch(sc->if_type){
100 case LMC_PPP:
101 {
102 struct net_device *dev = sc->lmc_device;
103 SPPP_attach(sc);
104 dev->do_ioctl = lmc_ioctl;
105 }
106 break;
107 case LMC_NET:
108 {
109 struct net_device *dev = sc->lmc_device;
110 /*
111 * They set a few basics because they don't use sync_ppp
112 */
113 dev->flags |= IFF_POINTOPOINT;
114
115 dev->hard_header_len = 0;
116 dev->addr_len = 0;
117 }
118 case LMC_RAW: /* Setup the task queue, maybe we should notify someone? */
119 {
120 }
121 default:
122 break;
123 }
124 lmc_trace(sc->lmc_device, "lmc_proto_attach out");
125 }
126
127 // detach
128 void lmc_proto_detach(lmc_softc_t *sc) /*FOLD00*/
129 {
130 switch(sc->if_type){
131 case LMC_PPP:
132 SPPP_detach(sc);
133 break;
134 case LMC_RAW: /* Tell someone we're detaching? */
135 break;
136 default:
137 break;
138 }
139
140 }
141
142 // reopen
143 void lmc_proto_reopen(lmc_softc_t *sc) /*FOLD00*/
144 {
145 lmc_trace(sc->lmc_device, "lmc_proto_reopen in");
146 switch(sc->if_type){
147 case LMC_PPP:
148 SPPP_reopen(sc);
149 break;
150 case LMC_RAW: /* Reset the interface after being down, prerape to receive packets again */
151 break;
152 default:
153 break;
154 }
155 lmc_trace(sc->lmc_device, "lmc_proto_reopen out");
156 }
157
158
159 // ioctl
160 int lmc_proto_ioctl(lmc_softc_t *sc, struct ifreq *ifr, int cmd) /*FOLD00*/
161 {
162 lmc_trace(sc->lmc_device, "lmc_proto_ioctl out");
163 switch(sc->if_type){
164 case LMC_PPP:
165 return SPPP_do_ioctl (sc, ifr, cmd);
166 break;
167 default:
168 return -EOPNOTSUPP;
169 break;
170 }
171 lmc_trace(sc->lmc_device, "lmc_proto_ioctl out");
172 }
173
174 // open
175 void lmc_proto_open(lmc_softc_t *sc) /*FOLD00*/
176 {
177 int ret;
178
179 lmc_trace(sc->lmc_device, "lmc_proto_open in");
180 switch(sc->if_type){
181 case LMC_PPP:
182 ret = SPPP_open(sc);
183 if(ret < 0)
184 printk("%s: syncPPP open failed: %d\n", sc->name, ret);
185 break;
186 case LMC_RAW: /* We're about to start getting packets! */
187 break;
188 default:
189 break;
190 }
191 lmc_trace(sc->lmc_device, "lmc_proto_open out");
192 }
193
194 // close
195
196 void lmc_proto_close(lmc_softc_t *sc) /*FOLD00*/
197 {
198 lmc_trace(sc->lmc_device, "lmc_proto_close in");
199 switch(sc->if_type){
200 case LMC_PPP:
201 SPPP_close(sc);
202 break;
203 case LMC_RAW: /* Interface going down */
204 break;
205 default:
206 break;
207 }
208 lmc_trace(sc->lmc_device, "lmc_proto_close out");
209 }
210
211 unsigned short lmc_proto_type(lmc_softc_t *sc, struct sk_buff *skb) /*FOLD00*/
212 {
213 lmc_trace(sc->lmc_device, "lmc_proto_type in");
214 switch(sc->if_type){
215 case LMC_PPP:
216 return htons(ETH_P_WAN_PPP);
217 break;
218 case LMC_NET:
219 return htons(ETH_P_802_2);
220 break;
221 case LMC_RAW: /* Packet type for skbuff kind of useless */
222 return htons(ETH_P_802_2);
223 break;
224 default:
225 printk(KERN_WARNING "%s: No protocol set for this interface, assuming 802.2 (which is wrong!!)\n", sc->name);
226 return htons(ETH_P_802_2);
227 break;
228 }
229 lmc_trace(sc->lmc_device, "lmc_proto_tye out");
230
231 }
232
233 void lmc_proto_netif(lmc_softc_t *sc, struct sk_buff *skb) /*FOLD00*/
234 {
235 lmc_trace(sc->lmc_device, "lmc_proto_netif in");
236 switch(sc->if_type){
237 case LMC_PPP:
238 case LMC_NET:
239 default:
240 skb->dev->last_rx = jiffies;
241 netif_rx(skb);
242 break;
243 case LMC_RAW:
244 break;
245 }
246 lmc_trace(sc->lmc_device, "lmc_proto_netif out");
247 }
248
This page took 0.056635 seconds and 5 git commands to generate.