[TG3]: Add tagged status support.
[linux-2.6/verdex.git] / drivers / net / wan / lmc / lmc_proto.c
blob74876c0073e8c8a5ad1a97c47b1518db8d81ba0e
1 /*
2 * Copyright (c) 1997-2000 LAN Media Corporation (LMC)
3 * All rights reserved. www.lanmedia.com
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).
11 * With Help By:
12 * David Boggs
13 * Ron Crane
14 * Allan Cox
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.
19 * Driver for the LanMedia LMC5200, LMC5245, LMC1000, LMC1200 cards.
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>
41 #include <net/syncppp.h>
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>
48 #include "lmc.h"
49 #include "lmc_var.h"
50 #include "lmc_debug.h"
51 #include "lmc_ioctl.h"
52 #include "lmc_proto.h"
55 * The compile-time variable SPPPSTUP causes the module to be
56 * compiled without referencing any of the sync ppp routines.
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
74 // init
75 void lmc_proto_init(lmc_softc_t *sc) /*FOLD00*/
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;
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;
93 lmc_trace(sc->lmc_device, "lmc_proto_init out");
96 // attach
97 void lmc_proto_attach(lmc_softc_t *sc) /*FOLD00*/
99 lmc_trace(sc->lmc_device, "lmc_proto_attach in");
100 switch(sc->if_type){
101 case LMC_PPP:
103 struct net_device *dev = sc->lmc_device;
104 SPPP_attach(sc);
105 dev->do_ioctl = lmc_ioctl;
107 break;
108 case LMC_NET:
110 struct net_device *dev = sc->lmc_device;
112 * They set a few basics because they don't use sync_ppp
114 dev->flags |= IFF_POINTOPOINT;
115 dev->hard_header = NULL;
116 dev->hard_header_len = 0;
117 dev->addr_len = 0;
119 case LMC_RAW: /* Setup the task queue, maybe we should notify someone? */
122 default:
123 break;
125 lmc_trace(sc->lmc_device, "lmc_proto_attach out");
128 // detach
129 void lmc_proto_detach(lmc_softc_t *sc) /*FOLD00*/
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;
143 // reopen
144 void lmc_proto_reopen(lmc_softc_t *sc) /*FOLD00*/
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;
156 lmc_trace(sc->lmc_device, "lmc_proto_reopen out");
160 // ioctl
161 int lmc_proto_ioctl(lmc_softc_t *sc, struct ifreq *ifr, int cmd) /*FOLD00*/
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;
172 lmc_trace(sc->lmc_device, "lmc_proto_ioctl out");
175 // open
176 void lmc_proto_open(lmc_softc_t *sc) /*FOLD00*/
178 int ret;
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;
192 lmc_trace(sc->lmc_device, "lmc_proto_open out");
195 // close
197 void lmc_proto_close(lmc_softc_t *sc) /*FOLD00*/
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;
209 lmc_trace(sc->lmc_device, "lmc_proto_close out");
212 unsigned short lmc_proto_type(lmc_softc_t *sc, struct sk_buff *skb) /*FOLD00*/
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;
230 lmc_trace(sc->lmc_device, "lmc_proto_tye out");
234 void lmc_proto_netif(lmc_softc_t *sc, struct sk_buff *skb) /*FOLD00*/
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;
247 lmc_trace(sc->lmc_device, "lmc_proto_netif out");