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).
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>
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. */
46 #include <linux/smp.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.
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
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))
75 void lmc_proto_init(lmc_softc_t *sc) /*FOLD00*/
77 lmc_trace(sc->lmc_device, "lmc_proto_init in");
80 sc->pd = kmalloc(sizeof(struct ppp_device), GFP_KERNEL);
82 printk("lmc_proto_init(): kmalloc failure!\n");
85 sc->pd->dev = sc->lmc_device;
93 lmc_trace(sc->lmc_device, "lmc_proto_init out");
97 void lmc_proto_attach(lmc_softc_t *sc) /*FOLD00*/
99 lmc_trace(sc->lmc_device, "lmc_proto_attach in");
103 struct net_device *dev = sc->lmc_device;
105 dev->do_ioctl = lmc_ioctl;
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;
119 case LMC_RAW: /* Setup the task queue, maybe we should notify someone? */
125 lmc_trace(sc->lmc_device, "lmc_proto_attach out");
129 void lmc_proto_detach(lmc_softc_t *sc) /*FOLD00*/
135 case LMC_RAW: /* Tell someone we're detaching? */
144 void lmc_proto_reopen(lmc_softc_t *sc) /*FOLD00*/
146 lmc_trace(sc->lmc_device, "lmc_proto_reopen in");
151 case LMC_RAW: /* Reset the interface after being down, prerape to receive packets again */
156 lmc_trace(sc->lmc_device, "lmc_proto_reopen out");
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");
166 return SPPP_do_ioctl (sc, ifr, cmd);
172 lmc_trace(sc->lmc_device, "lmc_proto_ioctl out");
176 void lmc_proto_open(lmc_softc_t *sc) /*FOLD00*/
180 lmc_trace(sc->lmc_device, "lmc_proto_open in");
185 printk("%s: syncPPP open failed: %d\n", sc->name, ret);
187 case LMC_RAW: /* We're about to start getting packets! */
192 lmc_trace(sc->lmc_device, "lmc_proto_open out");
197 void lmc_proto_close(lmc_softc_t *sc) /*FOLD00*/
199 lmc_trace(sc->lmc_device, "lmc_proto_close in");
204 case LMC_RAW: /* Interface going down */
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");
217 return htons(ETH_P_WAN_PPP);
220 return htons(ETH_P_802_2);
222 case LMC_RAW: /* Packet type for skbuff kind of useless */
223 return htons(ETH_P_802_2);
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);
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");
241 skb->dev->last_rx = jiffies;
247 lmc_trace(sc->lmc_device, "lmc_proto_netif out");