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>
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>
40 #include <net/syncppp.h>
42 #include <asm/processor.h> /* Processor type for cache alignment. */
45 #include <linux/smp.h>
49 #include "lmc_debug.h"
50 #include "lmc_ioctl.h"
51 #include "lmc_proto.h"
54 * The compile-time variable SPPPSTUP causes the module to be
55 * compiled without referencing any of the sync ppp routines.
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
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))
74 void lmc_proto_init(lmc_softc_t
*sc
) /*FOLD00*/
76 lmc_trace(sc
->lmc_device
, "lmc_proto_init in");
79 sc
->pd
= kmalloc(sizeof(struct ppp_device
), GFP_KERNEL
);
81 printk("lmc_proto_init(): kmalloc failure!\n");
84 sc
->pd
->dev
= sc
->lmc_device
;
92 lmc_trace(sc
->lmc_device
, "lmc_proto_init out");
96 void lmc_proto_attach(lmc_softc_t
*sc
) /*FOLD00*/
98 lmc_trace(sc
->lmc_device
, "lmc_proto_attach in");
102 struct net_device
*dev
= sc
->lmc_device
;
104 dev
->do_ioctl
= lmc_ioctl
;
109 struct net_device
*dev
= sc
->lmc_device
;
111 * They set a few basics because they don't use sync_ppp
113 dev
->flags
|= IFF_POINTOPOINT
;
115 dev
->hard_header_len
= 0;
118 case LMC_RAW
: /* Setup the task queue, maybe we should notify someone? */
124 lmc_trace(sc
->lmc_device
, "lmc_proto_attach out");
128 void lmc_proto_detach(lmc_softc_t
*sc
) /*FOLD00*/
134 case LMC_RAW
: /* Tell someone we're detaching? */
143 void lmc_proto_reopen(lmc_softc_t
*sc
) /*FOLD00*/
145 lmc_trace(sc
->lmc_device
, "lmc_proto_reopen in");
150 case LMC_RAW
: /* Reset the interface after being down, prerape to receive packets again */
155 lmc_trace(sc
->lmc_device
, "lmc_proto_reopen out");
160 int lmc_proto_ioctl(lmc_softc_t
*sc
, struct ifreq
*ifr
, int cmd
) /*FOLD00*/
162 lmc_trace(sc
->lmc_device
, "lmc_proto_ioctl out");
165 return SPPP_do_ioctl (sc
, ifr
, cmd
);
171 lmc_trace(sc
->lmc_device
, "lmc_proto_ioctl out");
175 void lmc_proto_open(lmc_softc_t
*sc
) /*FOLD00*/
179 lmc_trace(sc
->lmc_device
, "lmc_proto_open in");
184 printk("%s: syncPPP open failed: %d\n", sc
->name
, ret
);
186 case LMC_RAW
: /* We're about to start getting packets! */
191 lmc_trace(sc
->lmc_device
, "lmc_proto_open out");
196 void lmc_proto_close(lmc_softc_t
*sc
) /*FOLD00*/
198 lmc_trace(sc
->lmc_device
, "lmc_proto_close in");
203 case LMC_RAW
: /* Interface going down */
208 lmc_trace(sc
->lmc_device
, "lmc_proto_close out");
211 __be16
lmc_proto_type(lmc_softc_t
*sc
, struct sk_buff
*skb
) /*FOLD00*/
213 lmc_trace(sc
->lmc_device
, "lmc_proto_type in");
216 return htons(ETH_P_WAN_PPP
);
219 return htons(ETH_P_802_2
);
221 case LMC_RAW
: /* Packet type for skbuff kind of useless */
222 return htons(ETH_P_802_2
);
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
);
229 lmc_trace(sc
->lmc_device
, "lmc_proto_tye out");
233 void lmc_proto_netif(lmc_softc_t
*sc
, struct sk_buff
*skb
) /*FOLD00*/
235 lmc_trace(sc
->lmc_device
, "lmc_proto_netif in");
240 skb
->dev
->last_rx
= jiffies
;
246 lmc_trace(sc
->lmc_device
, "lmc_proto_netif out");