/*** ltpc.c -- a driver for the LocalTalk PC card.
*
* Copyright (c) 1995,1996 Bradford W. Johnson <johns393@maroon.tc.umn.edu>
*
* This software may be used and distributed according to the terms
* of the GNU General Public License, incorporated herein by reference.
*
* This is ALPHA code at best. It may not work for you. It may
* damage your equipment. It may damage your relations with other
* users of your network. Use it at your own risk!
*
* Based in part on:
* skeleton.c by Donald Becker
* dummy.c by Nick Holloway and Alan Cox
* loopback.c by Ross Biro, Fred van Kampen, Donald Becker
* the netatalk source code (UMICH)
* lots of work on the card...
*
* I do not have access to the (proprietary) SDK that goes with the card.
* If you do, I don't want to know about it, and you can probably write
* a better driver yourself anyway. This does mean that the pieces that
* talk to the card are guesswork on my part, so use at your own risk!
*
* This is my first try at writing Linux networking code, and is also
* guesswork. Again, use at your own risk! (Although on this part, I'd
* welcome suggestions)
*
* This is a loadable kernel module which seems to work at my site
* consisting of a 1.2.13 linux box running netatalk 1.3.3, and with
* the kernel support from 1.3.3b2 including patches routing.patch
* and ddp.disappears.from.chooser. In order to run it, you will need
* to patch ddp.c and aarp.c in the kernel, but only a little...
*
* I'm fairly confident that while this is arguably badly written, the
* problems that people experience will be "higher level", that is, with
* complications in the netatalk code. The driver itself doesn't do
* anything terribly complicated -- it pretends to be an ether device
* as far as netatalk is concerned, strips the DDP data out of the ether
* frame and builds a LLAP packet to send out the card. In the other
* direction, it receives LLAP frames from the card and builds a fake
* ether packet that it then tosses up to the networking code. You can
* argue (correctly) that this is an ugly way to do things, but it
* requires a minimal amount of fooling with the code in ddp.c and aarp.c.
*
* The card will do a lot more than is used here -- I *think* it has the
* layers up through ATP. Even if you knew how that part works (which I
* don't) it would be a big job to carve up the kernel ddp code to insert
* things at a higher level, and probably a bad idea...
*
* There are a number of other cards that do LocalTalk on the PC. If
* nobody finds any insurmountable (at the netatalk level) problems
* here, this driver should encourage people to put some work into the
* other cards (some of which I gather are still commercially available)
* and also to put hooks for LocalTalk into the official ddp code.
*
* I welcome comments and suggestions. This is my first try at Linux
* networking stuff, and there are probably lots of things that I did
* suboptimally.
*
***/
/***
*
* $Log: ltpc.c,v $
* Revision 1.1.2.1 2000/03/01 05:35:07 jgarzik
* at and tr cleanup
*
* Revision 1.8 1997/01/28 05:44:54 bradford
* Clean up for non-module a little.
* Hacked about a bit to clean things up - Alan Cox
* Probably broken it from the origina 1.8
*
* 1998/11/09: David Huggins-Daines <dhd@debian.org>
* Cleaned up the initialization code to use the standard autoirq methods,
and to probe for things in the standard order of i/o, irq, dma. This
removes the "reset the reset" hack, because I couldn't figure out an
easy way to get the card to trigger an interrupt after it.
* Added support for passing configuration parameters on the kernel command
line and through insmod
* Changed the device name from "ltalk0" to "lt0", both to conform with the
other localtalk driver, and to clear up the inconsistency between the
module and the non-module versions of the driver :-)
* Added a bunch of comments (I was going to make some enums for the state
codes and the register offsets, but I'm still not sure exactly what their
semantics are)
* Don't poll anymore in interrupt-driven mode
* It seems to work as a module now (as of 2.1.127), but I don't think
I'm responsible for that...
*
* Revision 1.7 1996/12/12 03:42:33 bradford
* DMA alloc cribbed from 3c505.c.
*
* Revision 1.6 1996/12/12 03:18:58 bradford
* Added virt_to_bus; works in 2.1.13.
*
* Revision 1.5 1996/12/12 03:13:22 root
* xmitQel initialization -- think through better though.
*
* Revision 1.4 1996/06/18 14:55:55 root
* Change names to ltpc. Tabs. Took a shot at dma alloc,
* although more needs to be done eventually.
*
* Revision 1.3 1996/05/22 14:59:39 root
* Change dev->open, dev->close to track dummy.c in 1.99.(around 7)
*
* Revision 1.2 1996/05/22 14:58:24 root
* Change tabs mostly.
*
* Revision 1.1 1996/04/23 04:45:09 root
* Initial revision
*
* Revision 0.16 1996/03/05 15:59:56 root
* Change ARPHRD_LOCALTLK definition to the "real" one.
*
* Revision 0.15 1996/03/05 06:28:30 root
* Changes for kernel 1.3.70. Still need a few patches to kernel, but
* it's getting closer.
*
* Revision 0.14 1996/02/25 17:38:32 root
* More cleanups. Removed query to card on get_stats.
*
* Revision 0.13 1996/02/21 16:27:40 root
* Refix debug_print_skb. Fix mac.raw gotcha that appeared in 1.3.65.
* Clean up receive code a little.
*
* Revision 0.12 1996/02/19 16:34:53 root
* Fix debug_print_skb. Kludge outgoing snet to 0 when using startup
* range. Change debug to mask: 1 for verbose, 2 for higher level stuff
* including packet printing, 4 for lower level (card i/o) stuff.
*
* Revision 0.11 1996/02/12 15:53:38 root
* Added router sends (requires new aarp.c patch)
*
* Revision 0.10 1996/02/11 00:19:35 root
* Change source LTALK_LOGGING debug switch to insmod ... debug=2.
*
* Revision 0.9 1996/02/10 23:59:35 root
* Fixed those fixes for 1.2 -- DANGER! The at.h that comes with netatalk
* has a *different* definition of struct sockaddr_at than the Linux kernel
* does. This is an "insidious and invidious" bug...
* (Actually the preceding comment is false -- it's the atalk.h in the
* ancient atalk-0.06 that's the problem)
*
* Revision 0.8 1996/02/10 19:09:00 root
* Merge 1.3 changes. Tested OK under 1.3.60.
*
* Revision 0.7 1996/02/10 17:56:56 root
* Added debug=1 parameter on insmod for debugging prints. Tried
* to fix timer unload on rmmod, but I don't think that's the problem.
*
* Revision 0.6 1995/12/31 19:01:09 root
* Clean up rmmod, irq comments per feedback from Corin Anderson (Thanks Corey!)
* Clean up initial probing -- sometimes the card wakes up latched in reset.
*
* Revision 0.5 1995/12/22 06:03:44 root
* Added comments in front and cleaned up a bit.
* This version sent out to people.
*
* Revision 0.4 1995/12/18 03:46:44 root
* Return shortDDP to longDDP fake to 0/0. Added command structs.
*
***/
/* ltpc jumpers are:
*
* Interrupts -- set at most one. If none are set, the driver uses
* polled mode. Because the card was developed in the XT era, the
* origina