Usenet comp.os.linux.announce (1993-2013)
 help / color / mirror / Atom feed
* Linux Ethernet HOWTO (Part 2/2)
@ 1993-11-17  4:22 Paul Gortmaker
  0 siblings, 0 replies; 6+ messages in thread
From: Paul Gortmaker @ 1993-11-17  4:22 UTC (permalink / raw)


Archive-Name: linux/howto/ethernet/part2
Last-Modified: November 16, 1993

This is part 2/2 of the Linux Ethernet HOWTO. It is archived on 
sunsite.unc.edu in pub/Linux/docs/HOWTO.

[Begin part 2/2]

5 Technical information.

	For those who want to play with the present drivers, or try to make
	up their own driver for a card that is presently unsupported, this
	information should be useful. If you do not fall into this category,
	then perhaps you will want to skip this section.

5.01 Probed addresses

	While trying to determine what ethernet card is there, the following
	addresses are autoprobed, assuming the type and specs of the card
	have not been set in the kernel. In /usr/src/linux/net/inet/CONFIG,
	one can set the cards that are compiled in to the kernel. As of
	0.99pl12, doing a "make config" will ask what cards are to be
	supported. The file names below are in /usr/src/linux/net/inet/
	----------------------------------------------------------------
	wd.c:		0x300, 0x280, 0x380, 0x240
	3c503.c:	0x300, 0x310, 0x330, 0x350, 0x250, 0x280, 0x2a0, 0x2e0
	ne.c:		0x300, 0x280, 0x320, 0x340, 0x360
	hp.c:		0x300, 0x320, 0x340, 0x280, 0x2C0, 0x200, 0x240
	lance.c:	0x300, 0x320, 0x340, 0x360
	smc-ultra.c:	0x300, 0x280
	3c509.c:	<Special "ID Port" probe>
	----------------------------------------------------------------
	There are some NE2000 clone ethercards out there that are waiting black
	holes for autoprobe drivers.  While many NE2000 clones are
	safe until they are enabled, some can't be reset to a safe mode.
	These dangerous ethercards will hang any I/O access to their
	"dataports".  The typical dangerous locations are:

	Ethercard jumpered base     Dangerous locations (base + 0x10 - 0x1f)
		0x300 *				0x310-0x317
		0x320				0x330-0x337
		0x340				0x350-0x357
		0x360				0x370-0x377

	* The 0x300 location is the traditional place to put an ethercard, but
	it's also a popular place to put other devices (often SCSI
	controllers).  The 0x320 location is often the next one chosen, but
	that's bad for for the AHA1542 driver probe.  The 0x360 location is
	bad, because it conflicts with the parallel port at 0x378.

	To avoid these lurking ethercard, here are the things you can do:

        o Probe for the device's BIOS in memory space.  This is easy
	  and always safe, but it only works for cards that always have
	  BIOSes, like primary SCSI controllers.

	o Avoid probing any of the above locations until you think
	  you've located your device.  The NE2000 clones have a reset range
	  from <base>+0x18 to <base>+0x1f that will read as 0xff, so probe
	  there first if possible.  It's also safe to probe in the 8390
	  space at <base>+0x00 - <base>+0x0f, but that area will return
	  quasi-random values

	o If you must probe in the dangerous range, for instance if your
	  target device has only a few port locations, first check that
	  there isn't an NE2000 there. You can see how to do this by
	  looking at the probe code in /usr/src/linux/net/inet/ne.c

	In other news, I've written the code for the I/O port registrar.
	Peter MacDonald and I have been intensely discussing this, and I think
	our current scheme has the necessary functionality with minimal kernel
	size impact.  (The implementation involved rewriting the bitmap ops in
	kernel/ioport.c:ioperm() so that most code could be shared.)

	Here is the current "blurb".  As usual comments are welcome. Please
	keep them substantial and constructive (we've already talked about
	changing the name from "reserve=" to "noprobe=").

	==================

	Boot-Time Parameters: "reserve="
	
	In some machines it may be necessary to prevent device drivers from
	checking for devices (auto-probing) in a specific region.  This may be
	because of poorly designed hardware that causes the boot to "freeze"
	(such as some ethercards), hardware that is mistakenly identified,
	hardware whose state is changed by an earlier probe, or merely
	hardware you don't want the kernel to initialize.

	The "reserve" boot-time argument addresses this problem by specifying
	an I/O port region that shouldn't be probed.  That region is reserved
	in the kernel's port registration table as if a device has already
	been found in that region.  Note that this mechanism shouldn't be
	necessary on most machine, only when there is a problem or special
	case.

	The boot-line syntax is

	  lilo-prompt: linux-image reserve=[<port>,<size>,<port>,<size>...]

	As usual with boot-time specifiers there is an 11 parameter limit, thus
	you can only specify 5 reserved regions per "reserve" keyword.
	Multiple "reserve" specifiers will work if you have an usually
	complicated request.

	If you specify a "reserve" region to protect a specific device, you
	must generally specify an explicit probe for that device.  Most
	drivers ignore the port registration table if they are given an
	explicit address.

5.02 Skeleton / prototype driver

	OK. So you have decided that you want to write a driver for the
	Foobar Ethernet card, as you have the programming information,
	and it hasn't been done yet. (...these are the two main require-
	ments ;-) You can use the skeleton network driver that is provided
	with the Linux kernel source tree. It can be found in the file
	/usr/src/linux/net/inet/README.DRIVERS as of 0.99pl12, and later.

	It's also very useful to look at the Crynwr (nee Clarkson) driver
	for your target ethercard, if it's available.  Russ Nelson
	<nelson@crynwr.com> has been actively updating and writing these,
	and he has been very helpful with his code reviews of the current 
	Linux drivers.

5.03 Driver interface to the kernel

	Here are some notes that may help when trying to figure out what
	the code in the driver segments is doing, or perhaps what it is
	supposed to be doing.

	=====================================================

	int ethif_init(struct device *dev)
	{
	    ...
		dev->send_packet = &ei_send_packet;
		dev->open = &ei_open;
		dev->stop = &ei_close;
		dev->hard_start_xmit = &ei_start_xmit;
		...
	}

	int ethif_init(struct device *dev)

	This function is put into the device structure in Space.c.  It is
	called only at boot time, and returns '0' iff the ethercard 'dev'
	exists.

	=====================================================

	static int ei_open(struct device *dev)
	static int ei_close(struct device *dev)

	This routine opens and initializes the board in response to an
	socket ioctl() usually called by 'config' or 'ifconfig'.  It is
	commonly stuffed into the 'struct device' by ethif_init().

	The inverse routine is ei_close(), which should shut down the
	ethercard, free the IRQs and DMA channels if the hardware permits,
	and turn off anything that will save power (like the transceiver).

	(Note: As of NET-2, the relevant program is '/etc/ifconfig' - and
	the device *can* be turned off or on via passing 'up' or 'down'
	to 'ifconfig' from the command line with the device name.)

	=====================================================

	static int ei_start_xmit(struct sk_buff *skb, struct device *dev)
		dev->hard_start_xmit = &ei_start_xmit;

	This routine puts packets to be transmitted into the hardware.  It
	is usually stuffed into the 'struct device' by ethif_init().

	When the hardware can't accept additional packets it should set
	the dev->tbusy flag.  When additional room is available, usually
	during a transmit-complete interrupt, dev->tbusy should be cleared
	and the higher levels informed with mark_bh(INET_BH).
	[[Note: pre0.99.4 kernels didn't use this interface for all packets.]]
	
	=====================================================

	...
	    if (dev_rint(buffer, length, is_skb ? IN_SKBUFF : 0, dev))
		   stats->rx_dropped++;
	...
	A received packet is passed to the higher levels using dev_rint().
	If the unadorned packet data in a memory buffer, dev_rint will copy
	it into a 'skbuff' for you.  Otherwise a new skbuff should be
	kmalloc()ed, filled, and passed to dev_rint() with the IN_SKBUFF flag.

	=====================================================

5.04 Interrupts and Linux

	There are two kinds of interrupt handlers in Linux:
	fast ones and slow ones. You decide what kind you are installing by
	the flags you pass to irqaction().  The fast ones, such as the serial
	interrupt handler, run with _all_ interrupts disabled.  The normal
	interrupt handlers, such as the one for ethercard drivers, runs with
	other interrupts enabled.

	There is a two-level interrupt structure.  The "fast" part handles the
	device register, removes the packets, and perhaps sets a flag.   After
	it is done, and interrupts are re-enabled, the slow part is run if the
	flag is set.

	The flag between the two parts is set by:
		mark_bh(INET_BH);

	Usually this flag is set within dev_rint() during a received-packet
	interrupt, and set directly by the device driver during a
	transmit-complete interrupt.

	You might wonder why all interrupt handlers cannot run in
	"normal mode" with other interrupts enabled.  Ross Biro uses this
	scenario to illustrate the problem:
		o You get a serial interrupt, and start processing it.
	          The serial interrupt is now masked.
		o You get a network interrupt, and you start transferring
	          a maximum-sized 1500 byte packet from the card.
		o Another character comes in, but this time the interrupts
		  are masked!

	The "fast" interrupt structure solves this problem by allowing
	bounded-time interrupt handlers to run without the risk of leaving
	their interrupt lines masked by another interrupt request.

	There is an additional distinction between fast and slow interrupt
	handlers -- the arguments passed to the handler.  A "slow" handler is
	defined as

		static void
		handle_interrupt(int reg_ptr)
		{
		    int irq = -(((struct pt_regs *)reg_ptr)->orig_eax+2);
		    struct device *dev = irq2dev_map[irq];
		...

	While a fast handler gets the interrupt number directly

		static void
		handle_fast_interrupt(int irq)
		{
		...

	A final aspect of network performance is latency.  The only board
	that really addresses this is the 3c509, which allows a predictive
	interrupt to be posted.  It provides an interrupt response timer so
	that the driver can fine-tune how early an interrupt is generated.

	Alan Cox has some advice for anyone wanting to write drivers
	that are to be used with pl14 kernels and newer. He says:

	"Any driver intended for pl14 should use the new alloc_skb() and 
	kfree_skbmem() functions rather than using kmalloc() to obtain an
	sk_buff. The new pl14 skeleton does this correctly. For drivers 
	wishing to remain compatible with both sets the define 
	'HAVE_ALLOC_SKB' indicates these functions must be used.

	In essence replace

		skb=(struct sk_buff *)kmalloc(size)
	with

		skb=alloc_skb(size)

	and

		kfree_s(skb,size)

	with

		kfree_skbmem(skb,size)	/* Only sk_buff memory though */

	Any questions should I guess be directed to me since I made the change.
	This is a change to allow tracking of sk_buff's and sanity checks on 
	buffers and stack behaviour. If a driver produces the message 
	'File: ??? Line: ??? passed a non skb!' then it is probable the 
	driver is not using the new sk_buff allocators."




5.05 Programmed I/O vs. shared mem. vs. slave/master DMA

	Ethernet is 10Mbs.  (Don't be pedantic, 3Mbs and 100Mbs don't count.)
	If you can already send and receive back-to-back packets, you just
	can't put more bits over the wire.  Every modern ethercard can receive
	back-to-back packets.  The Linux DP8390 drivers come pretty close to
	sending back-to-back packets (depending on the current interrupt
	latency) and the 3c509 and AT1500 hardware has no problem at all
	automatically sending back-to-back packets.

	The ISA bus can do 5.3MB/sec (42Mb/sec), which sounds like more than
	enough.  You can use that bandwidth in several ways:

	Programmed I/O
	==============
	  Pro: Doesn't use any constrained system resources,
	       just a few I/O registers, and has no 16M limit.
	  Con: Usually the slowest transfer rate, the CPU is waiting
	       the whole time, and interleaved packet access is usually
	       difficult to impossible.

	Shared memory
	=============
	  Pro: Simple, faster than programmed I/O, and allows random
	       access to packets.
	  Con: Uses up memory space (a big one for DOS users, only a minor
	       issue under Linux), and it still ties up the CPU.

	Slave (normal) DMA
	==================
	  Pro: Frees up the CPU during the actual data transfer.
	  Con: Checking boundary conditions, allocating contiguous buffers,
	       and programming the DMA registers makes it the slowest
	       of all techniques.  It also uses up a scarce DMA
	       channel, and requires aligned low memory buffers.

	Master (bus-master) DMA
	=======================
	  Pro: Frees up the CPU during the data transfer, can string together
	       buffers, can require little or no CPU time lost on the
	       ISA bus.
	  Con: Requires low-memory buffers and a DMA channel. Any
	       bus-master will have problems with other bus-masters that 
	       are bus-hogs, such as some primitive SCSI adaptors. A few
	       badly-designed motherboard chipsets have problems with
	       bus-masters. And a reason for not using *any* type of 
	       DMA device is using a Cyrix 486 processor designed for
	       plug-in replacement of a 386: these processors must
	       flush their cache with each DMA cycle.

5.06 Programming the Intel chips (i82586 and i82593)

	These chips are used on a number of cards, namely the 3c507 ('86),
	the Intel EtherExpress 16 ('86), Microdyne's exos205t ('86),
	the Z-Note ('93), and the Racal-Interlan ni5210 ('86).

	Russ Nelson writes:
	"Most boards based on the 82586 can reuse quite a bit of their code.
	More, in fact, than the 8390-based adapters.  There are only three
	differences between them:

	  o The code to get the Ethernet address,
	  o The code to trigger CA on the 82586, and
	  o The code to reset the 82586.

	The Intel EtherExpress 16 is an exception, as it I/O maps the 82586.
	Yes, I/O maps it.  Fairly clunky, but it works.

	Garrett Wollman did an AT&T driver for BSD that uses the BSD
	copyright.  The latest version I have (Sep '92) only uses a single
	transmit buffer.  You can and should do better than this if you've
	got the memory.  The AT&T and 3c507 adapters do; the ni5210 doesn't.

	The people at Intel gave me a very big clue on how you queue up
	multiple transmit packets.  You set up a list of
	NOP->XMIT->NOP->XMIT->NOP->XMIT->(beginning) blocks, then you set the
	"next" pointer of all the NOP blocks to themselves.  Now you start
	the command unit on this chain.  It continually processes the first
	NOP block.  To transmit a packet, you stuff it into the next transmit
	block, then point the NOP to it.  To transmit the next packet, you
	stuff the next transmit block and point the previous NOP to *it*.  In
	this way, you don't have to wait for the previous transmit to finish,
	you can queue up multiple packets without any ambiguity as to whether
	it got accepted, and you can avoid the command unit start-up delay."

5.07	Technical information from 3Com

	From: Cameron Spitzer 764-6339 <camerons@nad.3com.com>
	Subject: getting 3Com Adapter manuals
	Date: Mon, 27 Sep 1993 21:17:07 +0200
	
	Since this is becoming a FAQ, I'm going to tread the thin
	ice of No Commercial Use and answer it here.

	3Com's Ethernet Adapters are documented for driver writers
	in our "Technical References" (TRs).  These manuals describe
	the programmer interfaces to the boards but they don't talk
	about the diagnostics, installation programs, etc that end
	users can see.
	
	The Network Adapter Division marketing department has the
	TRs to give away.  To keep this program efficient, we
	centralized it in a thing called "CardFacts."  CardFacts is
	an automated phone system.  You call it with a touch-tone
	phone and it faxes you stuff.  To get a TR, call CardFacts
	at 408-727-7021.  Ask it for Developer's Order Form,
	document number 9070.  Have your fax number ready when you
	call.  Fill out the order form and fax it to 408-764-5004.
	Manuals are shipped by Federal Express 2nd Day Service.
	
	If you don't have a fax and nobody you know has a fax,
	really and truly, *then* send mail to
	Terry_Murphy@3Mail.3Com.com and tell her about your problem.
	PLEASE use the fax thing if you possibly can.
	
	After you get a manual, if you still can't figure out how to
	program the board, try our "CardBoard" BBS at
	1-800-876-3266, and if you can't do that, write
	Andy_Chan@3Mail.3com.com and ask him for alternatives.  If
	you have a real stumper that nobody has figured out yet, the
	fellow who needs to know about it is
	Steve_Lebus@3Mail.3com.com.
	
	There are people here who think we are too free with the
	manuals, and they are looking for evidence that the system
	is too expensive, or takes too much time and effort.  That's
	why it's important to try to use CardFacts *before* you
	start calling and mailing the people I named here.
	
	There are even people who think we should be like Diamond
	and Xircom, requiring tight "partnership" with driver
	writers to prevent poorly performing drivers from getting
	written.  So far, 3Com customers have been really good about
	this, and there's no problem with the level of requests
	we've been getting.  We need your continued cooperation and
	restraint to keep it that way.
	
	Cameron Spitzer,  408-764-6339
	3Com NAD
	Santa Clara
	work: camerons@nad.3com.com
	home: cls@truffula.sj.ca.us

5.08 Notes on AMD PCnet-ISA / LANCE Based cards (79C960)

	The AMD LANCE (Local Area Network Controller for Ethernet)
	was the original offering, and has since been replaced by
	the "PCnet-ISA" chip, otherwise known as the 79C960.
	A relatively new chip from AMD, the 79C960, is the heart of many
	new cards being released at present. Note that the name "LANCE"
	has stuck, and some people will refer to the new chip by the old
	name. Dave Roberts of the Network Products Division of AMD was kind
	enough to contribute the following information regarding this chip:

	"As for the architecture itself, AMD developed it originally
	and reduced it to a single chip -- the PCnet(tm)-ISA -- over a year
	ago.  It's been selling like hotcakes ever since.

	Functionally, it is equivalent to a NE1500.  The register set
	is identical to the old LANCE with the 1500/2100 architecture
	additions.  Older 1500/2100 drivers will work on the PCnet-ISA.
	The NE1500 and NE2100 architecture is basically the same.
	Initially Novell called it the 2100, but then tried to distinguish
	between coax and 10BASE-T cards.  Anything that was 10BASE-T only was
	to be numbered in the 1500 range.  That's the only difference.

	Many companies offer PCnet-ISA based products, including HP,
	Racal-Datacom, Allied Telesis, Boca Research, Kingston Technology, etc.
	The cards are basically the same except that some manufacturers
	have added "jumperless" features that allow the card to
	be configured in software.  Most have not.  AMD offers a standard
	design package for a card that uses the PCnet-ISA and many
	manufacturers use our design without change.
	What this means is that anybody who wants to write drivers for
	most PCnet-ISA based cards can just get the data-sheet from AMD.  Call
	our literature distribution center at (800)222-9323 and ask for the
	Am79C960, PCnet-ISA data sheet.  It's free.

	A quick way to understand whether the card is a "stock" card
	is to just look at it.  If it's stock, it should just have one large
	chip on it, a crystal, a small IEEE address PROM, possibly a socket
	for a boot ROM, and a connector (1, 2, or 3, depending on the media
	options offered).  Note that if it's a coax card, it will have some
	transceiver stuff built onto it as well, but that should be near the
	connector and away from the PCnet-ISA.

	The PCnet-ISA is faster than the original LANCE design and
	makes better use of the available bus bandwidth.  Additionally, some
	LANCE bugs were corrected and many enhancements were made."

5.09 Multicast and Promiscuous mode

	One of the things I've been working on recently is the
	major remaining item on the ethercard feature list:
	implementing multicast and promiscuous mode hooks.
	
	At first I was planning to do it while implementing either
	the /dev/* or DDI interface, but that's not really the
	correct way to do it.  We should only enable multicast or
	promiscuous modes when something wants to look at the
	packets, and shut it down when that application is
	finished, neither of which is strongly related to when the
	hardware is opened or released.
	
	I'll start by discussing promiscuous mode, which is
	conceptually easy to implement.  For most hardware you
	only have to set a register bit, and from then on you get
	every packet on the wire.  Well, it's almost that easy;
	for some hardware you have to shut the board (potentially
	dropping a few packet), reconfigure it, and then re-enable
	the ethercard.  This is grungy and risky, but the
	alternative seems to be to have every application register
	before you open the ethercard at boot-time.
	
	OK, so that's easy, so I'll move on something that's not
	quite so obvious: Multicast.  It can be done two ways:
	
	1) Use promiscuous mode, and a packet filter like the
	   Berkeley packet filter (BPF).  The BPF is a pattern matching
	   stack language, where you write a program that picks out the
	   addresses you are interested in.  Its advantage is that it's
	   very general and programmable.  Its disadvantage is that there
	   is no general way for the kernel to avoid turning on promiscuous
	   mode and running every packet on the wire through every registered
	   packet filter. See the next section for more information on BPF.
	
	2) Using the built-in multicast filter that most etherchips have.
	
	I guess I should list what a few ethercards/chips provide:
	
	Chip/card  Promiscuous	Multicast filter
	========================================
	Seeq8001/3c501	Yes	Binary filter (1)
	3Com/3c509	Yes	Binary filter (1)
	8390		Yes	Autodin II six bit hash (2) (3)
	LANCE		Yes	Autodin II six bit hash (2) (3)
	i82586		Yes	Hidden Autodin II six bit hash (2) (4)
	
	
	(1) These cards claim to have a filter, but it's a simple
	yes/no 'accept all multicast packets', or 'accept no
	multicast packets'.
	
	(2) AUTODIN II is the standard ethernet CRC (checksum)
	polynomial.  In this scheme multicast addresses are hashed
	and looked up in a hash table.  If the cooresponding bit
	is enabled, this packet is accepted.  Ethernet packets are
	laid out so that the hardware to do this is trivial -- you
	just latch six (usually) bits from the CRC circuit (needed
	anyway for error checking) after the first six octets (the
	destination address), and use them as an index into the
	hash table (six bits == a 64-bit table).
	
	(3) These chips use the six bit hash, and must have the
	table computed and loaded by the host.  This means the
	kernel must include the CRC code.
	
	(4) The 82586 uses the six bit hash internally, but it
	computes the hash table itself from a list of multicast
	addresses to accept.

	Note that none of these chips do perfect filtering, and we
	still need a middle-level module to do the final
	filtering.  Also note that in every case we must keep a
	complete list of accepted multicast addresses to recompute
	the hash table when it changes.
	
	My first pass at device-level support is detailed in the
	new outline driver:
	ftp.super.org:/pub/linux/pl14/skeleton.c
	
	Also in that directory you'll find all of my drivers
	updated to use the proposed promiscuous/multicast mode
	hook.
	
	#ifdef HAVE_MULTICAST
	static void set_multicast_list(struct device *dev, int num_addrs,
					 void *addrs);
	#endif
	.
	.
	
	ethercard_open() {
	...
	#ifdef HAVE_MULTICAST
		dev->set_multicast_list = &set_multicast_list;
	#endif
	...
	
	#ifdef HAVE_MULTICAST
	/* Set or clear the multicast filter for this adaptor.
	   num_addrs == -1	Promiscuous mode, receive all packets
	   num_addrs == 0	Normal mode, clear multicast list
	   num_addrs > 0	Multicast mode, receive normal and
				MC packets, and do best-effort filtering.
	 */
	static void
	set_multicast_list(struct device *dev, int num_addrs, void *addrs)
	{
	...

	Any comments, criticism, etc. are welcome.

	Alan Cox adds that "...in pl14, user programs can access promiscuous 
	mode but not multicast mode, even though the drivers support both. 
	The ifconfig program allows you to mark an interface 'promisc'."
	
5.10 The Berkely Packet Filter (BPF)

	I'm not bitterly opposed to it, but I'm coming to the
	conclusion that the 'bpf' functionality should not be provided
	by the kernel, but should be in a (hopefully little-used)
	compatibility library.
	
	For those not in the know: 'bpf' (the Berkeley Packet Filter)
	is an mechanism for specifying to the kernel networking layers
	what packets you are interested in.  It's implemented as a
	specialized stack language interpreter built into a low level
	of the networking code.  An application passes a program
	written in this language to the kernel, and the kernel runs the
	program on each incoming packet.  If the kernel has multiple
	'bpf' applications, each program is run on each packet.
	
	The problem is that it's difficult to deduce what kind of
	packets the application is really interested in from the packet
	filter program, so the general solution is to always run the
	filter.  Imagine a program that registers a 'bpf' program to
	pick up a low data-rate stream sent to a multicast address.
	Most ethernet cards have a hardware multicast address filter
	implemented as a 64 entry hash table that ignores most unwanted
	multicast packets, so the capability exists to make this a very
	inexpensive operation.  But with the BFP the kernel must switch
	the interface to promiscuous mode, receive _all_ packets, and
	run them through this filter.  This is work, BTW, that's very
	difficult to account back to the process requesting the packets.

5.11 Unresolved questions / concerns

	There may be some benefit from processing packet data as it is
	transferred to and from the ethercard, especially with very fast
	processors transferring data to a slow ethercard.  As I see it this
	question has multiple parts:
		1) Is there any useful processing power available, perhaps
		   during the ISA bus recovery period, or while the 8390
		   remote DMA is preparing for another transfer??
		2) Is there any useful but simple work that can be done
		   between/during each word of the copy, such as calculating
		   a CRC, or discarding obviously unwanted packets??
		3) would the complexity of an interface to do this make future
		   ethercard drivers impossible??

	There should be a better structure than Space.c  Drivers should be
	able to autoprobe for all installed ethercards rather than just
	quitting after finding the first.  I've written code to do this,
	but the constant promise (threat?) of DDI has prevented me from
	making it standard.

	A related topic is the problem of driver probes corrupting
	unrelated hardware. Even worse is a probe into a dataport that
	isn't set up to transfer data, which will freeze the machine.  The
	common suggestion is a boot-time device registry that records
	already-used I/O ports and shared memory. This has been implemented
	as of pl13, see section 5.01.

6 Possible problems, and troubleshooting.

	This section tries to answer any unresolved questions, and not so
	common solutions to common problems. They are sorted on a "per
	manufacturer basis". You should have also read the relevant info.
	from section 1 about your specific card. Section 8 contains more
	general FAQ's.

6.01 Problems with NE2000 (and clones)

	"DMA address mismatch"
	======================

	Is the chip a real NatSemi 8390? (DP8390, DP83901, DP83902 or DP83905)?
	If not, some clone chips don't correctly implement the transfer
	verification register.  MS-DOS drivers never do error checking,
	so it doesn't matter to them.

	Are most of the messages off by a factor of 2?
	If so:	Are you using the NE2000 in a 16 bit slot?
		Is it jumpered to use only 8 bit transfers?

	The Linux driver expects a NE2000 to be a 16 bit slot.  A NE1000 can
	be in either size slot.  This problem can also occur with some clones,
	notably D-Link 16 bit cards, that don't have the correct ID bytes
	in the station address PROM. [[ This should be fixed in pl12.]]

	Are you running the bus faster than 8Mhz?
	If you can change the speed (faster or slower), see if that
	makes a difference.  Most NE2000 clones will run at 16Mhz, but
	some may not.  Changing speed can also mask a noisy bus.

	What other devices are on the bus?
	If moving the devices around changes the reliability, then you
	have a bus noise problem -- just what that error message was
	designed to detect.  Congratulations, you've probably found the
	source of other problems as well.

	Machine Hangs during Boot.
	==========================

	Problem:  The machine hangs during boot right after the "8390..."  or
		  "WD...." message.  Removing the NE2000 fixes the problem.

	Solution: Change your NE2000 base address to 0x360 (or 0x340 for
		  pl12 or later kernels.) Alternatively, you can use the new
		  device registrar implemented in pl13 (see section 5.1)

	Reason:   Your NE2000 clone isn't a good enough clone.  An active
		  NE2000 is a bottomless pit that will trap any driver
		  autoprobing in its space.  The other ethercard drivers take
		  great pain to reset the NE2000 so that it's safe, but some
		  clones cannot be reset.  Clone chips to watch out for:
		  Winbond 83C901.  Changing the NE2000 to a less-popular
		  address will move it out of the way of other autoprobes,
		  allowing your machine to boot.

	Problem:  The machine hangs during the SCSI probe at boot.

	Solution: It's the same problem as above, change the
		  ethercard's address, or use the device registrar.

	Problem:  The machine hangs during the soundcard probe at boot.

	Solution: No, that's really during the silent SCSI probe, and it's
		  the same problem as above.

	"eth0: DMAing conflict in ne_block_input"
	=========================================

	This bug came from timer-based packet retransmissions.  If you got a
	timer tick _during_ a ethercard RX interrupt, and timer tick tried to
	retransmit a timed-out packet, you could get a conflict.  Because of
	the design of the NE2000 you would have the machine hang (exactly the
	same the NE2000-clone boot hangs).

	Early versions of the driver disabled interrupts for a long time,
	and didn't have this problem.  Later versions are fixed. (ie. kernels
	after 0.99p9 should be OK.)

	NE2000 not detected at boot.
	============================

	A few people have reported a problem with detecting the Accton NE2000.
	This problem occurs only at boot-time, and the card is later detected
	at run-time by the identical code my (alpha-test) ne2k diagnostic
	program. Accton has been very responsive, but I still haven't tracked
	down what is going on.  I've been unable to reproduce this problem
	with the Accton cards we purchased.  If you are having this problem,
	please send me an immediate bug report.  For that matter, if you have
	an Accton card send me a success report, including the type of the
	motherboard.  I'm especially interested in finding out if this problem
	moves with the particular ethercard, or stays with the motherboard.

6.02 Problems with WD80*3 cards

	Detected Non-existent Ethercard
	===============================

	Problem:  A WD80*3 is falsely detected.  Removing the sound or
		  MIDI card eliminates the "detected" message.

	Solution: Update your ethercard driver: new versions include an
		  additional sanity check.

	Reason:   Some MIDI ports happen to produce the same checksum as a
		  WD ethercard.

	Error messages from the 80*3
	============================

	Problem:  You get messages such as the following with your 80*3:
			eth0: bogus packet size, status = ........
			kmalloc called with impossibly large argument (65400)
			eth0: Couldn't allocate sk_buff of size 65400
			eth0: receiver overrun

	Reason:   There is a shared memory problem.

	Solution: If the problem is sparodic, you have hardware problems.
		  Typical problems that are easy to fix are board conflicts,
		  having cache or "shadow ROM" enabled for that region, or
		  running your bus faster than 8Mhz.  There are also a
		  surprising number of memory failures on ethernet cards,
		  so run a diagnostic program if you have one for your
		  ethercard.

		  If the problem is continual, and you have have to reboot
		  to fix the problem, record the boot-time probe message
		  and mail it to becker@super.org  Take particular note of
		  the shared memory location.

6.03 Problems with 3Com cards

	Choosing the Interrupt of the 3c503
	===================================

	Problem:  The 3c503 picks IRQ n at boot, but this is needed for some
		  other device which needs IRQ n. (eg. CD ROM driver, etc.)
		  Can this be fixed without compiling this into the kernel?

	Solution: The 3c503 driver probes for a free IRQ line in the order
		  {5, 9/2, 3, 4}, and it should pick a line which isn't being
		  used.  The pre-pl12 (SLS 1.02) driver picked the IRQ line
		  at boot-time, and the current driver (pl12) chooses when
		  the card is open()/'ifconfig'ed. Note the "bug" noted in
		  the 3c503 section in 1.01

		  Alternately, you can fix the IRQ at boot by passing
		  parameters via LILO.  The following selects IRQ9, base
		  location 0x300, <ignored value>, and if_port #1 (the
		  external transceiver).
			lilo: linux ether=9,0x300,0,1,eth0

		  The following selects IRQ3, probes for the base location,
		  <ignored value>, and the default if_port #0 (the internal
		  transceiver)
			lilo: linux ether=3,0,0,0,eth0

	"3c503: Configured interrupt number XX is out of range."
	========================================================

	Problem:  Whoever built your kernel fixed the ethercard IRQ at XX.

	Reason:   The above is truly evil, and worse than that, it is
		  not necessary. The 3c503 will autoIRQ when it gets
		  "ifconfig"ed, and pick one of IRQ{5, 2/9, 3, 4}.

	Solution: Use lilo to set the IRQ, or rebuild the kernel, enabling
		  autoIRQ by not specifying the IRQ line.

	Choosing the output of the 3c503
	================================

	Problem:  The supplied 3c503 drivers don't use the AUI (thicknet) port.
		  How does one choose it over the default thinnet port?

	Solution: The 3c503 AUI port can be selected at boot-time with 0.99pl12
		  and later.  The selection is overloaded onto the low bit of
		  the currently-unused dev->rmem_start variable, so a boot-time
		  parameter of:
			lilo: linux ether=0,0,0,1,eth0
		  should work.  A boot line to force IRQ 5, port base 0x300,
		  and use an external transceiver is:
			lilo: linux ether=5,0x300,0,1,eth0

7 Networking with a laptop computer

	There are currently only a few ways to put your laptop on a network.
	You can use the NET-2 SLIP code (and run at serial line speeds);
	you can buy one of the few laptops that come with a NE2000-compatible
	ethercard or PCMCIA slot built-in; you can get a laptop with a
	docking station and plug in an ISA ethercard; or you can use a
	parallel port Ethernet adapter such as the D-Link DE-600.

7.01 Option 1 -- using SLIP

	This is the cheapest solution, but by far the most difficult. Also,
	you will not get very high transmission rates. Since SLIP is not
	really related to ethernet cards, it will not be discussed further
	here. See the NET-2 HOWTO.

7.02 Option 2 -- Built in NE2000 compatible or PCMCIA Ethercard.

	The second solution severely limits your laptop choices and is fairly
	expensive.  Be sure to read the specifications carefully, you may find
	that you will have to buy an additional non-standard transceiver to
	actually put the machine on a network. Anyone who has used a PCMCIA
	Ethernet card is requested to contact us so that we can add it to
	this document. Barry Jaspan <bjaspan@security.ov.com> has started
	some work on controlling the PCMCIA slot.

7.03 Option 3 -- ISA Ethercard in the Docking Station.

	I recommend the third solution.  Docking stations for laptops typically
	cost about $250 and provide two full-size ISA slots, two serial and one
	parallel port.  Most (all?) docking stations are powered off of the
	laptop's batteries, and a few allow adding extra batteries in the
	docking station if you use short ISA cards.  You can add an inexpensive
	ethercard and enjoy full-speed ethernet performance.

7.04 Option 4 -- Pocket / parallel port adaptors.

	The "pocket" ethernet adaptors may also fit your need.
	Until recently they actually costed more than a docking station and
	cheap ethercard, and most tie you down with a wall-brick power supply.
	The only pocket adaptor driver right now is for the D-Link.
	I'm also working on a driver for the AT-LAN-TEC/RealTek pocket adaptor.
	Most other companies, especially Xircom, treat the programming
	information as a trade secret, so support will likely be slow in
	coming.

	You can sometimes avoid the wall-brick with the adaptors by buying
	or making a cable that draws power from the laptop's keyboard
	port.

8 Frequently asked questions

	Here are some of the more frequently asked questions about using
	Linux with an Ethernet connection. Some of the more specific
	questions are sorted on a "per manufacturer basis" and are listed
	in the "Troubleshooting" section. (section 6). However, since this
	document is basically "old" by the time you get it, any "new" problems
	will not appear here instantly. For these, I suggest that you make
	efficient use of your newsreader. For example, nn users would type
		nn -xX -s'3c'
	to get all the news articles in your subscribed list that have
	"3c" in the subject. (ie. 3com, 3c509, 3c503, etc.)
	The moral: Read the man page for your newsreader.
	
8.01 Just the FAQ's ma'am -- just the FAQ's.

	Q: I heard that there is an alpha driver available for my card.
	   Where can I get it?

	A: Assuming that it is a djb driver, it will be on ftp.super.org
	   in the /pub/linux/ area. Things change here quite frequently,
	   so just look around for it. There is usually only about 3
	   subdirs, so you should be able to find it. Now, if it really
	   is an alpha, or pre-alpha driver, then please treat it as
	   such. In other words, don't complain because you can't figure
	   out what to do with it. If you can't figure out how to install
	   it, then you probably shouldn't be testing it. Also, if it brings
	   your machine down, don't complain. Instead, send us a well
	   documented bug report, or even better, a patch!

	Q: Is there token ring support for Linux?

	A: No, there is no token ring support in Linux. To support token ring
	   requires more than only a writing a device driver, it also requires
	   writing the source routing routines for token ring.  Given that
	   token ring is expensive, not fast, and will probably be swept away
	   by 100baseVG in a few months, it doesn't seem worth it to write
	   a driver. In case anyone wants to, I looked at writing a token ring
	   device driver, and concluded that the hardware interface
	   wasn't too difficult to do, but writing the support for source
	   routing would take significantly longer than I was willing to spend
	   on an expensive and dying technology.

	   Alan Cox adds: "It will require [...] changes to the bottom socket
	   layer to support 802.2 and 802.2 based TCP/IP. Don't expect
	   anything soon."

	Q: Is there IPX or Novell support available for Linux?

	A: Alan Cox writes: "The novell protocols are available from novell
	   for various amounts. IPX is freely documented. SPX is about $1000
	   but I'm told Xerox SPP is identical. _PLEASE_ has anyone got any
	   freely distributable Xerox SPP code/documentation?  The novell
	   server spec costs you $15000 + royalties providing you only
	   want to write a client, or $30000 + royalties otherwise. Needless
	   to say the final output has to be binary only and subject to a
	   novell license. Reading their license rules by my interpretation
	   its also impossible for us to do because you would seem to have
	   to bar disassembly of your final result, which is not allowed
	   in the EEC.

	   Bits of NCP are known, and I hope eventually enough will be known
	   to write limited NCP support into Linux, for the moment I'm poking
	   around at IPX, tho this will have to wait until the new network
	   code is finished.

	   An Alpha test IPX protocol layer is available from me (Alan)
	   for pl14 or higher. People are also exploring the issue of NCP and 
	   the new Dr Dobbs journal article on the innards of netware has 
	   provided a core of good information."

	   As an alternative, Miquel van Smoorenburg suggests the following:
	   "It _is_ possible to set up a dedicated PC running both novell and
	   the PD SOSS server and let it gateway from NFS to novell. This way
	   it is possible to mount the Novell drives on the Unix client.

	   SOSS is a PD (perhaps with some restrictions, but freely available)
	   NFS server for DOS. It includes the PC/IP TCP/IP implementation
	   and runs on a packet driver. I have run both a Novell client
	   (with PDIPX, a Packet Driver IPX) and this SOSS server together
	   successfully."

	Q: What needs to be done so that Linux can run two ethernet cards?

	A: The easiest solution is to get 0.99pl13, which already includes
	   the changes described below.  You can enable additional ethercards
	   with LILO parameters such as
		lilo: linux ether=5,0x300,0,1,eth0 ether=15,0x280,eth1

	   For pre-pl13 you can enable additional ethercards by
	   adding another entry to Space.c, naming it "eth1" instead
	   of "eth0".  If you want routing to work well you should
	   use a recent kernel, say 0.99pl11 or later.  You may also
	   want to verify that your driver writer kept all of the
	   per-card variables in 'dev->priv'.  Most do, but the pl12
	   AT1500/LANCE driver has a single static low-memory buffer.

	Q: I have /dev/eth0 as a link to /dev/xxx. Is this right?

	A: Contrary to the Net-2 HowTo, the files in /dev/* are not used.
	   I originally thought that they might be an OK idea. I've since 
	   concluded that they won't work, at least in the documented form.

9 Miscellaneous.

	Any other associated stuff that didn't fit in anywhere else gets
	dumped here. It may not be relevant, and it may not be of general
	interest but it is here anyway.

9.01 The Cabletron story. (...as related by Donald J. Becker)

		I contacted Cabletron in early December 1992 for
	programming information (I had called and sent several
	earlier messages).  I was referred through several
	different people, and each one took several days to
	respond before they forwarded me to the next.  Eventually
	I was told I should deal with their (outside?) developer
	Mr. Dev.Null.  I persisted, and around March it seemed
	that I had finally succeed: Cabletron offered to send me
	an evaluation board (unrequested) and everything I needed
	to use it (what I wanted).  The hardware showed up right
	away, and I waited, expecting the the programming
	information information as well.  About a month later I
	contacted them, and they told me that "all I needed to use
	it" was the standard MS-DOS NDIS drivers, a binary on
	standard driver disk.  The disk envelope was covered in
	legalese, including no-disassembly, no-reverse-engineering
	clauses.  It was May (and a few email exchanges later)
	before I figured out that I had been "slow rolled", and
	had wasted about 20 hours on this particular windmill.

	The story isn't over yet.  People have written to me say
	they have vetoed several medium-sized purchases from
	Cabletron based on the lack of Linux drivers.  Cabletron
	must have noticed this because yesterday I got a call
	_from_ Cabletron (the first!) stating that they will be
	independently writing a Linux driver.  Of course, their
	lawyers probably haven't read the GPL yet...
	
9.02 The Xircom story. (...as related by Russ Nelson)

	From: "Russell Nelson" <nelson@crynwr.com>
	Subject:   Xircom support (horses mouth)
	Date: Mon, 30 Aug 1993 17:01:04 +0300

	Okay, here's the word on Xircom support.  I spoke to Dirk
	Gates, President of Xircom, about the packet driver
	situation.  Yes, the packet driver uses the Crynwr packet
	driver skeleton, and yes, it's in violation of the GPL.
	However, it was not Xircom's intention to violate the GPL.
	They paid Persoft to write a proprietary driver for them,
	and Persoft used the Clarkson skeleton, alleging that the
	code was in the public domain.  Xircom is unsuable because
	they were an innocent infringer.  I will shortly be sending
	them a demand letter.  If they continue to distribute the
	driver after they get the letter, they will be in
	infringement and I can *then* sue them.  Xircom has
	basically the same philosophy as Diamond.  The actual
	hardware interface is reverse-engineerable in the space of a
	day or so.  However, Xircom prefers to write all their own
	drivers, because badly-written drivers reflect badly on
	their product.  They also perceive a monetary interest in
	keeping their product proprietary.  Xircom would *probably*
	release the specs at this point if they were approached by
	an ad-hoc consortium of potential purchasers who required
	the specs as a condition of purchase.  However, I don't
	think this is the right thing to do.  At this point they
	have already gotten all the proprietary advantage they are
	going to.  Purchasing their product now will only reward
	their "bad attitude" toward open systems.  Much better to
	purchase from a vendor who appreciates and encourages open
	systems, such as D-Link.

9.03	Closing

	If you have found any glaring typos, or outdated info in this
	document, please let one of us know.

	Paul Gortmaker		<gpg109@rsphysse.anu.edu.au>
	Donald J. Becker	<becker@super.org>

		=========== end of Ethernet HOWTO ============




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Linux Ethernet HOWTO (Part 2/2)
@ 1993-12-15 22:08 Paul Gortmaker
  0 siblings, 0 replies; 6+ messages in thread
From: Paul Gortmaker @ 1993-12-15 22:08 UTC (permalink / raw)


Archive-Name: linux/howto/ethernet/part2
Last-Modified: November 16, 1993

This is part 2/2 of the Linux Ethernet HOWTO. It is archived on 
sunsite.unc.edu in pub/Linux/docs/HOWTO.

[Begin part 2/2]

5 Technical information.

	For those who want to play with the present drivers, or try to make
	up their own driver for a card that is presently unsupported, this
	information should be useful. If you do not fall into this category,
	then perhaps you will want to skip this section.

5.01 Probed addresses

	While trying to determine what ethernet card is there, the following
	addresses are autoprobed, assuming the type and specs of the card
	have not been set in the kernel. In /usr/src/linux/net/inet/CONFIG,
	one can set the cards that are compiled in to the kernel. As of
	0.99pl12, doing a "make config" will ask what cards are to be
	supported. The file names below are in /usr/src/linux/net/inet/
	----------------------------------------------------------------
	wd.c:		0x300, 0x280, 0x380, 0x240
	3c503.c:	0x300, 0x310, 0x330, 0x350, 0x250, 0x280, 0x2a0, 0x2e0
	ne.c:		0x300, 0x280, 0x320, 0x340, 0x360
	hp.c:		0x300, 0x320, 0x340, 0x280, 0x2C0, 0x200, 0x240
	lance.c:	0x300, 0x320, 0x340, 0x360
	smc-ultra.c:	0x300, 0x280
	3c509.c:	<Special "ID Port" probe>
	----------------------------------------------------------------
	There are some NE2000 clone ethercards out there that are waiting black
	holes for autoprobe drivers.  While many NE2000 clones are
	safe until they are enabled, some can't be reset to a safe mode.
	These dangerous ethercards will hang any I/O access to their
	"dataports".  The typical dangerous locations are:

	Ethercard jumpered base     Dangerous locations (base + 0x10 - 0x1f)
		0x300 *				0x310-0x317
		0x320				0x330-0x337
		0x340				0x350-0x357
		0x360				0x370-0x377

	* The 0x300 location is the traditional place to put an ethercard, but
	it's also a popular place to put other devices (often SCSI
	controllers).  The 0x320 location is often the next one chosen, but
	that's bad for for the AHA1542 driver probe.  The 0x360 location is
	bad, because it conflicts with the parallel port at 0x378.

	To avoid these lurking ethercard, here are the things you can do:

        o Probe for the device's BIOS in memory space.  This is easy
	  and always safe, but it only works for cards that always have
	  BIOSes, like primary SCSI controllers.

	o Avoid probing any of the above locations until you think
	  you've located your device.  The NE2000 clones have a reset range
	  from <base>+0x18 to <base>+0x1f that will read as 0xff, so probe
	  there first if possible.  It's also safe to probe in the 8390
	  space at <base>+0x00 - <base>+0x0f, but that area will return
	  quasi-random values

	o If you must probe in the dangerous range, for instance if your
	  target device has only a few port locations, first check that
	  there isn't an NE2000 there. You can see how to do this by
	  looking at the probe code in /usr/src/linux/net/inet/ne.c

	In other news, I've written the code for the I/O port registrar.
	Peter MacDonald and I have been intensely discussing this, and I think
	our current scheme has the necessary functionality with minimal kernel
	size impact.  (The implementation involved rewriting the bitmap ops in
	kernel/ioport.c:ioperm() so that most code could be shared.)

	Here is the current "blurb".  As usual comments are welcome. Please
	keep them substantial and constructive (we've already talked about
	changing the name from "reserve=" to "noprobe=").

	==================

	Boot-Time Parameters: "reserve="
	
	In some machines it may be necessary to prevent device drivers from
	checking for devices (auto-probing) in a specific region.  This may be
	because of poorly designed hardware that causes the boot to "freeze"
	(such as some ethercards), hardware that is mistakenly identified,
	hardware whose state is changed by an earlier probe, or merely
	hardware you don't want the kernel to initialize.

	The "reserve" boot-time argument addresses this problem by specifying
	an I/O port region that shouldn't be probed.  That region is reserved
	in the kernel's port registration table as if a device has already
	been found in that region.  Note that this mechanism shouldn't be
	necessary on most machine, only when there is a problem or special
	case.

	The boot-line syntax is

	  lilo-prompt: linux-image reserve=[<port>,<size>,<port>,<size>...]

	As usual with boot-time specifiers there is an 11 parameter limit, thus
	you can only specify 5 reserved regions per "reserve" keyword.
	Multiple "reserve" specifiers will work if you have an usually
	complicated request.

	If you specify a "reserve" region to protect a specific device, you
	must generally specify an explicit probe for that device.  Most
	drivers ignore the port registration table if they are given an
	explicit address.

5.02 Skeleton / prototype driver

	OK. So you have decided that you want to write a driver for the
	Foobar Ethernet card, as you have the programming information,
	and it hasn't been done yet. (...these are the two main require-
	ments ;-) You can use the skeleton network driver that is provided
	with the Linux kernel source tree. It can be found in the file
	/usr/src/linux/net/inet/README.DRIVERS as of 0.99pl12, and later.

	It's also very useful to look at the Crynwr (nee Clarkson) driver
	for your target ethercard, if it's available.  Russ Nelson
	<nelson@crynwr.com> has been actively updating and writing these,
	and he has been very helpful with his code reviews of the current 
	Linux drivers.

5.03 Driver interface to the kernel

	Here are some notes that may help when trying to figure out what
	the code in the driver segments is doing, or perhaps what it is
	supposed to be doing.

	=====================================================

	int ethif_init(struct device *dev)
	{
	    ...
		dev->send_packet = &ei_send_packet;
		dev->open = &ei_open;
		dev->stop = &ei_close;
		dev->hard_start_xmit = &ei_start_xmit;
		...
	}

	int ethif_init(struct device *dev)

	This function is put into the device structure in Space.c.  It is
	called only at boot time, and returns '0' iff the ethercard 'dev'
	exists.

	=====================================================

	static int ei_open(struct device *dev)
	static int ei_close(struct device *dev)

	This routine opens and initializes the board in response to an
	socket ioctl() usually called by 'config' or 'ifconfig'.  It is
	commonly stuffed into the 'struct device' by ethif_init().

	The inverse routine is ei_close(), which should shut down the
	ethercard, free the IRQs and DMA channels if the hardware permits,
	and turn off anything that will save power (like the transceiver).

	(Note: As of NET-2, the relevant program is '/etc/ifconfig' - and
	the device *can* be turned off or on via passing 'up' or 'down'
	to 'ifconfig' from the command line with the device name.)

	=====================================================

	static int ei_start_xmit(struct sk_buff *skb, struct device *dev)
		dev->hard_start_xmit = &ei_start_xmit;

	This routine puts packets to be transmitted into the hardware.  It
	is usually stuffed into the 'struct device' by ethif_init().

	When the hardware can't accept additional packets it should set
	the dev->tbusy flag.  When additional room is available, usually
	during a transmit-complete interrupt, dev->tbusy should be cleared
	and the higher levels informed with mark_bh(INET_BH).
	[[Note: pre0.99.4 kernels didn't use this interface for all packets.]]
	
	=====================================================

	...
	    if (dev_rint(buffer, length, is_skb ? IN_SKBUFF : 0, dev))
		   stats->rx_dropped++;
	...
	A received packet is passed to the higher levels using dev_rint().
	If the unadorned packet data in a memory buffer, dev_rint will copy
	it into a 'skbuff' for you.  Otherwise a new skbuff should be
	kmalloc()ed, filled, and passed to dev_rint() with the IN_SKBUFF flag.

	=====================================================

5.04 Interrupts and Linux

	There are two kinds of interrupt handlers in Linux:
	fast ones and slow ones. You decide what kind you are installing by
	the flags you pass to irqaction().  The fast ones, such as the serial
	interrupt handler, run with _all_ interrupts disabled.  The normal
	interrupt handlers, such as the one for ethercard drivers, runs with
	other interrupts enabled.

	There is a two-level interrupt structure.  The "fast" part handles the
	device register, removes the packets, and perhaps sets a flag.   After
	it is done, and interrupts are re-enabled, the slow part is run if the
	flag is set.

	The flag between the two parts is set by:
		mark_bh(INET_BH);

	Usually this flag is set within dev_rint() during a received-packet
	interrupt, and set directly by the device driver during a
	transmit-complete interrupt.

	You might wonder why all interrupt handlers cannot run in
	"normal mode" with other interrupts enabled.  Ross Biro uses this
	scenario to illustrate the problem:
		o You get a serial interrupt, and start processing it.
	          The serial interrupt is now masked.
		o You get a network interrupt, and you start transferring
	          a maximum-sized 1500 byte packet from the card.
		o Another character comes in, but this time the interrupts
		  are masked!

	The "fast" interrupt structure solves this problem by allowing
	bounded-time interrupt handlers to run without the risk of leaving
	their interrupt lines masked by another interrupt request.

	There is an additional distinction between fast and slow interrupt
	handlers -- the arguments passed to the handler.  A "slow" handler is
	defined as

		static void
		handle_interrupt(int reg_ptr)
		{
		    int irq = -(((struct pt_regs *)reg_ptr)->orig_eax+2);
		    struct device *dev = irq2dev_map[irq];
		...

	While a fast handler gets the interrupt number directly

		static void
		handle_fast_interrupt(int irq)
		{
		...

	A final aspect of network performance is latency.  The only board
	that really addresses this is the 3c509, which allows a predictive
	interrupt to be posted.  It provides an interrupt response timer so
	that the driver can fine-tune how early an interrupt is generated.

	Alan Cox has some advice for anyone wanting to write drivers
	that are to be used with pl14 kernels and newer. He says:

	"Any driver intended for pl14 should use the new alloc_skb() and 
	kfree_skbmem() functions rather than using kmalloc() to obtain an
	sk_buff. The new pl14 skeleton does this correctly. For drivers 
	wishing to remain compatible with both sets the define 
	'HAVE_ALLOC_SKB' indicates these functions must be used.

	In essence replace

		skb=(struct sk_buff *)kmalloc(size)
	with

		skb=alloc_skb(size)

	and

		kfree_s(skb,size)

	with

		kfree_skbmem(skb,size)	/* Only sk_buff memory though */

	Any questions should I guess be directed to me since I made the change.
	This is a change to allow tracking of sk_buff's and sanity checks on 
	buffers and stack behaviour. If a driver produces the message 
	'File: ??? Line: ??? passed a non skb!' then it is probable the 
	driver is not using the new sk_buff allocators."




5.05 Programmed I/O vs. shared mem. vs. slave/master DMA

	Ethernet is 10Mbs.  (Don't be pedantic, 3Mbs and 100Mbs don't count.)
	If you can already send and receive back-to-back packets, you just
	can't put more bits over the wire.  Every modern ethercard can receive
	back-to-back packets.  The Linux DP8390 drivers come pretty close to
	sending back-to-back packets (depending on the current interrupt
	latency) and the 3c509 and AT1500 hardware has no problem at all
	automatically sending back-to-back packets.

	The ISA bus can do 5.3MB/sec (42Mb/sec), which sounds like more than
	enough.  You can use that bandwidth in several ways:

	Programmed I/O
	==============
	  Pro: Doesn't use any constrained system resources,
	       just a few I/O registers, and has no 16M limit.
	  Con: Usually the slowest transfer rate, the CPU is waiting
	       the whole time, and interleaved packet access is usually
	       difficult to impossible.

	Shared memory
	=============
	  Pro: Simple, faster than programmed I/O, and allows random
	       access to packets.
	  Con: Uses up memory space (a big one for DOS users, only a minor
	       issue under Linux), and it still ties up the CPU.

	Slave (normal) DMA
	==================
	  Pro: Frees up the CPU during the actual data transfer.
	  Con: Checking boundary conditions, allocating contiguous buffers,
	       and programming the DMA registers makes it the slowest
	       of all techniques.  It also uses up a scarce DMA
	       channel, and requires aligned low memory buffers.

	Master (bus-master) DMA
	=======================
	  Pro: Frees up the CPU during the data transfer, can string together
	       buffers, can require little or no CPU time lost on the
	       ISA bus.
	  Con: Requires low-memory buffers and a DMA channel. Any
	       bus-master will have problems with other bus-masters that 
	       are bus-hogs, such as some primitive SCSI adaptors. A few
	       badly-designed motherboard chipsets have problems with
	       bus-masters. And a reason for not using *any* type of 
	       DMA device is using a Cyrix 486 processor designed for
	       plug-in replacement of a 386: these processors must
	       flush their cache with each DMA cycle.

5.06 Programming the Intel chips (i82586 and i82593)

	These chips are used on a number of cards, namely the 3c507 ('86),
	the Intel EtherExpress 16 ('86), Microdyne's exos205t ('86),
	the Z-Note ('93), and the Racal-Interlan ni5210 ('86).

	Russ Nelson writes:
	"Most boards based on the 82586 can reuse quite a bit of their code.
	More, in fact, than the 8390-based adapters.  There are only three
	differences between them:

	  o The code to get the Ethernet address,
	  o The code to trigger CA on the 82586, and
	  o The code to reset the 82586.

	The Intel EtherExpress 16 is an exception, as it I/O maps the 82586.
	Yes, I/O maps it.  Fairly clunky, but it works.

	Garrett Wollman did an AT&T driver for BSD that uses the BSD
	copyright.  The latest version I have (Sep '92) only uses a single
	transmit buffer.  You can and should do better than this if you've
	got the memory.  The AT&T and 3c507 adapters do; the ni5210 doesn't.

	The people at Intel gave me a very big clue on how you queue up
	multiple transmit packets.  You set up a list of
	NOP->XMIT->NOP->XMIT->NOP->XMIT->(beginning) blocks, then you set the
	"next" pointer of all the NOP blocks to themselves.  Now you start
	the command unit on this chain.  It continually processes the first
	NOP block.  To transmit a packet, you stuff it into the next transmit
	block, then point the NOP to it.  To transmit the next packet, you
	stuff the next transmit block and point the previous NOP to *it*.  In
	this way, you don't have to wait for the previous transmit to finish,
	you can queue up multiple packets without any ambiguity as to whether
	it got accepted, and you can avoid the command unit start-up delay."

5.07	Technical information from 3Com

	From: Cameron Spitzer 764-6339 <camerons@nad.3com.com>
	Subject: getting 3Com Adapter manuals
	Date: Mon, 27 Sep 1993 21:17:07 +0200
	
	Since this is becoming a FAQ, I'm going to tread the thin
	ice of No Commercial Use and answer it here.

	3Com's Ethernet Adapters are documented for driver writers
	in our "Technical References" (TRs).  These manuals describe
	the programmer interfaces to the boards but they don't talk
	about the diagnostics, installation programs, etc that end
	users can see.
	
	The Network Adapter Division marketing department has the
	TRs to give away.  To keep this program efficient, we
	centralized it in a thing called "CardFacts."  CardFacts is
	an automated phone system.  You call it with a touch-tone
	phone and it faxes you stuff.  To get a TR, call CardFacts
	at 408-727-7021.  Ask it for Developer's Order Form,
	document number 9070.  Have your fax number ready when you
	call.  Fill out the order form and fax it to 408-764-5004.
	Manuals are shipped by Federal Express 2nd Day Service.
	
	If you don't have a fax and nobody you know has a fax,
	really and truly, *then* send mail to
	Terry_Murphy@3Mail.3Com.com and tell her about your problem.
	PLEASE use the fax thing if you possibly can.
	
	After you get a manual, if you still can't figure out how to
	program the board, try our "CardBoard" BBS at
	1-800-876-3266, and if you can't do that, write
	Andy_Chan@3Mail.3com.com and ask him for alternatives.  If
	you have a real stumper that nobody has figured out yet, the
	fellow who needs to know about it is
	Steve_Lebus@3Mail.3com.com.
	
	There are people here who think we are too free with the
	manuals, and they are looking for evidence that the system
	is too expensive, or takes too much time and effort.  That's
	why it's important to try to use CardFacts *before* you
	start calling and mailing the people I named here.
	
	There are even people who think we should be like Diamond
	and Xircom, requiring tight "partnership" with driver
	writers to prevent poorly performing drivers from getting
	written.  So far, 3Com customers have been really good about
	this, and there's no problem with the level of requests
	we've been getting.  We need your continued cooperation and
	restraint to keep it that way.
	
	Cameron Spitzer,  408-764-6339
	3Com NAD
	Santa Clara
	work: camerons@nad.3com.com
	home: cls@truffula.sj.ca.us

5.08 Notes on AMD PCnet-ISA / LANCE Based cards (79C960)

	The AMD LANCE (Local Area Network Controller for Ethernet)
	was the original offering, and has since been replaced by
	the "PCnet-ISA" chip, otherwise known as the 79C960.
	A relatively new chip from AMD, the 79C960, is the heart of many
	new cards being released at present. Note that the name "LANCE"
	has stuck, and some people will refer to the new chip by the old
	name. Dave Roberts of the Network Products Division of AMD was kind
	enough to contribute the following information regarding this chip:

	"As for the architecture itself, AMD developed it originally
	and reduced it to a single chip -- the PCnet(tm)-ISA -- over a year
	ago.  It's been selling like hotcakes ever since.

	Functionally, it is equivalent to a NE1500.  The register set
	is identical to the old LANCE with the 1500/2100 architecture
	additions.  Older 1500/2100 drivers will work on the PCnet-ISA.
	The NE1500 and NE2100 architecture is basically the same.
	Initially Novell called it the 2100, but then tried to distinguish
	between coax and 10BASE-T cards.  Anything that was 10BASE-T only was
	to be numbered in the 1500 range.  That's the only difference.

	Many companies offer PCnet-ISA based products, including HP,
	Racal-Datacom, Allied Telesis, Boca Research, Kingston Technology, etc.
	The cards are basically the same except that some manufacturers
	have added "jumperless" features that allow the card to
	be configured in software.  Most have not.  AMD offers a standard
	design package for a card that uses the PCnet-ISA and many
	manufacturers use our design without change.
	What this means is that anybody who wants to write drivers for
	most PCnet-ISA based cards can just get the data-sheet from AMD.  Call
	our literature distribution center at (800)222-9323 and ask for the
	Am79C960, PCnet-ISA data sheet.  It's free.

	A quick way to understand whether the card is a "stock" card
	is to just look at it.  If it's stock, it should just have one large
	chip on it, a crystal, a small IEEE address PROM, possibly a socket
	for a boot ROM, and a connector (1, 2, or 3, depending on the media
	options offered).  Note that if it's a coax card, it will have some
	transceiver stuff built onto it as well, but that should be near the
	connector and away from the PCnet-ISA.

	The PCnet-ISA is faster than the original LANCE design and
	makes better use of the available bus bandwidth.  Additionally, some
	LANCE bugs were corrected and many enhancements were made."

5.09 Multicast and Promiscuous mode

	One of the things I've been working on recently is the
	major remaining item on the ethercard feature list:
	implementing multicast and promiscuous mode hooks.
	
	At first I was planning to do it while implementing either
	the /dev/* or DDI interface, but that's not really the
	correct way to do it.  We should only enable multicast or
	promiscuous modes when something wants to look at the
	packets, and shut it down when that application is
	finished, neither of which is strongly related to when the
	hardware is opened or released.
	
	I'll start by discussing promiscuous mode, which is
	conceptually easy to implement.  For most hardware you
	only have to set a register bit, and from then on you get
	every packet on the wire.  Well, it's almost that easy;
	for some hardware you have to shut the board (potentially
	dropping a few packet), reconfigure it, and then re-enable
	the ethercard.  This is grungy and risky, but the
	alternative seems to be to have every application register
	before you open the ethercard at boot-time.
	
	OK, so that's easy, so I'll move on something that's not
	quite so obvious: Multicast.  It can be done two ways:
	
	1) Use promiscuous mode, and a packet filter like the
	   Berkeley packet filter (BPF).  The BPF is a pattern matching
	   stack language, where you write a program that picks out the
	   addresses you are interested in.  Its advantage is that it's
	   very general and programmable.  Its disadvantage is that there
	   is no general way for the kernel to avoid turning on promiscuous
	   mode and running every packet on the wire through every registered
	   packet filter. See the next section for more information on BPF.
	
	2) Using the built-in multicast filter that most etherchips have.
	
	I guess I should list what a few ethercards/chips provide:
	
	Chip/card  Promiscuous	Multicast filter
	========================================
	Seeq8001/3c501	Yes	Binary filter (1)
	3Com/3c509	Yes	Binary filter (1)
	8390		Yes	Autodin II six bit hash (2) (3)
	LANCE		Yes	Autodin II six bit hash (2) (3)
	i82586		Yes	Hidden Autodin II six bit hash (2) (4)
	
	
	(1) These cards claim to have a filter, but it's a simple
	yes/no 'accept all multicast packets', or 'accept no
	multicast packets'.
	
	(2) AUTODIN II is the standard ethernet CRC (checksum)
	polynomial.  In this scheme multicast addresses are hashed
	and looked up in a hash table.  If the cooresponding bit
	is enabled, this packet is accepted.  Ethernet packets are
	laid out so that the hardware to do this is trivial -- you
	just latch six (usually) bits from the CRC circuit (needed
	anyway for error checking) after the first six octets (the
	destination address), and use them as an index into the
	hash table (six bits == a 64-bit table).
	
	(3) These chips use the six bit hash, and must have the
	table computed and loaded by the host.  This means the
	kernel must include the CRC code.
	
	(4) The 82586 uses the six bit hash internally, but it
	computes the hash table itself from a list of multicast
	addresses to accept.

	Note that none of these chips do perfect filtering, and we
	still need a middle-level module to do the final
	filtering.  Also note that in every case we must keep a
	complete list of accepted multicast addresses to recompute
	the hash table when it changes.
	
	My first pass at device-level support is detailed in the
	new outline driver:
	ftp.super.org:/pub/linux/pl14/skeleton.c
	
	Also in that directory you'll find all of my drivers
	updated to use the proposed promiscuous/multicast mode
	hook.
	
	#ifdef HAVE_MULTICAST
	static void set_multicast_list(struct device *dev, int num_addrs,
					 void *addrs);
	#endif
	.
	.
	
	ethercard_open() {
	...
	#ifdef HAVE_MULTICAST
		dev->set_multicast_list = &set_multicast_list;
	#endif
	...
	
	#ifdef HAVE_MULTICAST
	/* Set or clear the multicast filter for this adaptor.
	   num_addrs == -1	Promiscuous mode, receive all packets
	   num_addrs == 0	Normal mode, clear multicast list
	   num_addrs > 0	Multicast mode, receive normal and
				MC packets, and do best-effort filtering.
	 */
	static void
	set_multicast_list(struct device *dev, int num_addrs, void *addrs)
	{
	...

	Any comments, criticism, etc. are welcome.

	Alan Cox adds that "...in pl14, user programs can access promiscuous 
	mode but not multicast mode, even though the drivers support both. 
	The ifconfig program allows you to mark an interface 'promisc'."
	
5.10 The Berkely Packet Filter (BPF)

	I'm not bitterly opposed to it, but I'm coming to the
	conclusion that the 'bpf' functionality should not be provided
	by the kernel, but should be in a (hopefully little-used)
	compatibility library.
	
	For those not in the know: 'bpf' (the Berkeley Packet Filter)
	is an mechanism for specifying to the kernel networking layers
	what packets you are interested in.  It's implemented as a
	specialized stack language interpreter built into a low level
	of the networking code.  An application passes a program
	written in this language to the kernel, and the kernel runs the
	program on each incoming packet.  If the kernel has multiple
	'bpf' applications, each program is run on each packet.
	
	The problem is that it's difficult to deduce what kind of
	packets the application is really interested in from the packet
	filter program, so the general solution is to always run the
	filter.  Imagine a program that registers a 'bpf' program to
	pick up a low data-rate stream sent to a multicast address.
	Most ethernet cards have a hardware multicast address filter
	implemented as a 64 entry hash table that ignores most unwanted
	multicast packets, so the capability exists to make this a very
	inexpensive operation.  But with the BFP the kernel must switch
	the interface to promiscuous mode, receive _all_ packets, and
	run them through this filter.  This is work, BTW, that's very
	difficult to account back to the process requesting the packets.

5.11 Unresolved questions / concerns

	There may be some benefit from processing packet data as it is
	transferred to and from the ethercard, especially with very fast
	processors transferring data to a slow ethercard.  As I see it this
	question has multiple parts:
		1) Is there any useful processing power available, perhaps
		   during the ISA bus recovery period, or while the 8390
		   remote DMA is preparing for another transfer??
		2) Is there any useful but simple work that can be done
		   between/during each word of the copy, such as calculating
		   a CRC, or discarding obviously unwanted packets??
		3) would the complexity of an interface to do this make future
		   ethercard drivers impossible??

	There should be a better structure than Space.c  Drivers should be
	able to autoprobe for all installed ethercards rather than just
	quitting after finding the first.  I've written code to do this,
	but the constant promise (threat?) of DDI has prevented me from
	making it standard.

	A related topic is the problem of driver probes corrupting
	unrelated hardware. Even worse is a probe into a dataport that
	isn't set up to transfer data, which will freeze the machine.  The
	common suggestion is a boot-time device registry that records
	already-used I/O ports and shared memory. This has been implemented
	as of pl13, see section 5.01.

6 Possible problems, and troubleshooting.

	This section tries to answer any unresolved questions, and not so
	common solutions to common problems. They are sorted on a "per
	manufacturer basis". You should have also read the relevant info.
	from section 1 about your specific card. Section 8 contains more
	general FAQ's.

6.01 Problems with NE2000 (and clones)

	"DMA address mismatch"
	======================

	Is the chip a real NatSemi 8390? (DP8390, DP83901, DP83902 or DP83905)?
	If not, some clone chips don't correctly implement the transfer
	verification register.  MS-DOS drivers never do error checking,
	so it doesn't matter to them.

	Are most of the messages off by a factor of 2?
	If so:	Are you using the NE2000 in a 16 bit slot?
		Is it jumpered to use only 8 bit transfers?

	The Linux driver expects a NE2000 to be a 16 bit slot.  A NE1000 can
	be in either size slot.  This problem can also occur with some clones,
	notably D-Link 16 bit cards, that don't have the correct ID bytes
	in the station address PROM. [[ This should be fixed in pl12.]]

	Are you running the bus faster than 8Mhz?
	If you can change the speed (faster or slower), see if that
	makes a difference.  Most NE2000 clones will run at 16Mhz, but
	some may not.  Changing speed can also mask a noisy bus.

	What other devices are on the bus?
	If moving the devices around changes the reliability, then you
	have a bus noise problem -- just what that error message was
	designed to detect.  Congratulations, you've probably found the
	source of other problems as well.

	Machine Hangs during Boot.
	==========================

	Problem:  The machine hangs during boot right after the "8390..."  or
		  "WD...." message.  Removing the NE2000 fixes the problem.

	Solution: Change your NE2000 base address to 0x360 (or 0x340 for
		  pl12 or later kernels.) Alternatively, you can use the new
		  device registrar implemented in pl13 (see section 5.1)

	Reason:   Your NE2000 clone isn't a good enough clone.  An active
		  NE2000 is a bottomless pit that will trap any driver
		  autoprobing in its space.  The other ethercard drivers take
		  great pain to reset the NE2000 so that it's safe, but some
		  clones cannot be reset.  Clone chips to watch out for:
		  Winbond 83C901.  Changing the NE2000 to a less-popular
		  address will move it out of the way of other autoprobes,
		  allowing your machine to boot.

	Problem:  The machine hangs during the SCSI probe at boot.

	Solution: It's the same problem as above, change the
		  ethercard's address, or use the device registrar.

	Problem:  The machine hangs during the soundcard probe at boot.

	Solution: No, that's really during the silent SCSI probe, and it's
		  the same problem as above.

	"eth0: DMAing conflict in ne_block_input"
	=========================================

	This bug came from timer-based packet retransmissions.  If you got a
	timer tick _during_ a ethercard RX interrupt, and timer tick tried to
	retransmit a timed-out packet, you could get a conflict.  Because of
	the design of the NE2000 you would have the machine hang (exactly the
	same the NE2000-clone boot hangs).

	Early versions of the driver disabled interrupts for a long time,
	and didn't have this problem.  Later versions are fixed. (ie. kernels
	after 0.99p9 should be OK.)

	NE2000 not detected at boot.
	============================

	A few people have reported a problem with detecting the Accton NE2000.
	This problem occurs only at boot-time, and the card is later detected
	at run-time by the identical code my (alpha-test) ne2k diagnostic
	program. Accton has been very responsive, but I still haven't tracked
	down what is going on.  I've been unable to reproduce this problem
	with the Accton cards we purchased.  If you are having this problem,
	please send me an immediate bug report.  For that matter, if you have
	an Accton card send me a success report, including the type of the
	motherboard.  I'm especially interested in finding out if this problem
	moves with the particular ethercard, or stays with the motherboard.

6.02 Problems with WD80*3 cards

	Detected Non-existent Ethercard
	===============================

	Problem:  A WD80*3 is falsely detected.  Removing the sound or
		  MIDI card eliminates the "detected" message.

	Solution: Update your ethercard driver: new versions include an
		  additional sanity check.

	Reason:   Some MIDI ports happen to produce the same checksum as a
		  WD ethercard.

	Error messages from the 80*3
	============================

	Problem:  You get messages such as the following with your 80*3:
			eth0: bogus packet size, status = ........
			kmalloc called with impossibly large argument (65400)
			eth0: Couldn't allocate sk_buff of size 65400
			eth0: receiver overrun

	Reason:   There is a shared memory problem.

	Solution: If the problem is sparodic, you have hardware problems.
		  Typical problems that are easy to fix are board conflicts,
		  having cache or "shadow ROM" enabled for that region, or
		  running your bus faster than 8Mhz.  There are also a
		  surprising number of memory failures on ethernet cards,
		  so run a diagnostic program if you have one for your
		  ethercard.

		  If the problem is continual, and you have have to reboot
		  to fix the problem, record the boot-time probe message
		  and mail it to becker@super.org  Take particular note of
		  the shared memory location.

6.03 Problems with 3Com cards

	Choosing the Interrupt of the 3c503
	===================================

	Problem:  The 3c503 picks IRQ n at boot, but this is needed for some
		  other device which needs IRQ n. (eg. CD ROM driver, etc.)
		  Can this be fixed without compiling this into the kernel?

	Solution: The 3c503 driver probes for a free IRQ line in the order
		  {5, 9/2, 3, 4}, and it should pick a line which isn't being
		  used.  The pre-pl12 (SLS 1.02) driver picked the IRQ line
		  at boot-time, and the current driver (pl12) chooses when
		  the card is open()/'ifconfig'ed. Note the "bug" noted in
		  the 3c503 section in 1.01

		  Alternately, you can fix the IRQ at boot by passing
		  parameters via LILO.  The following selects IRQ9, base
		  location 0x300, <ignored value>, and if_port #1 (the
		  external transceiver).
			lilo: linux ether=9,0x300,0,1,eth0

		  The following selects IRQ3, probes for the base location,
		  <ignored value>, and the default if_port #0 (the internal
		  transceiver)
			lilo: linux ether=3,0,0,0,eth0

	"3c503: Configured interrupt number XX is out of range."
	========================================================

	Problem:  Whoever built your kernel fixed the ethercard IRQ at XX.

	Reason:   The above is truly evil, and worse than that, it is
		  not necessary. The 3c503 will autoIRQ when it gets
		  "ifconfig"ed, and pick one of IRQ{5, 2/9, 3, 4}.

	Solution: Use lilo to set the IRQ, or rebuild the kernel, enabling
		  autoIRQ by not specifying the IRQ line.

	Choosing the output of the 3c503
	================================

	Problem:  The supplied 3c503 drivers don't use the AUI (thicknet) port.
		  How does one choose it over the default thinnet port?

	Solution: The 3c503 AUI port can be selected at boot-time with 0.99pl12
		  and later.  The selection is overloaded onto the low bit of
		  the currently-unused dev->rmem_start variable, so a boot-time
		  parameter of:
			lilo: linux ether=0,0,0,1,eth0
		  should work.  A boot line to force IRQ 5, port base 0x300,
		  and use an external transceiver is:
			lilo: linux ether=5,0x300,0,1,eth0

7 Networking with a laptop computer

	There are currently only a few ways to put your laptop on a network.
	You can use the NET-2 SLIP code (and run at serial line speeds);
	you can buy one of the few laptops that come with a NE2000-compatible
	ethercard or PCMCIA slot built-in; you can get a laptop with a
	docking station and plug in an ISA ethercard; or you can use a
	parallel port Ethernet adapter such as the D-Link DE-600.

7.01 Option 1 -- using SLIP

	This is the cheapest solution, but by far the most difficult. Also,
	you will not get very high transmission rates. Since SLIP is not
	really related to ethernet cards, it will not be discussed further
	here. See the NET-2 HOWTO.

7.02 Option 2 -- Built in NE2000 compatible or PCMCIA Ethercard.

	The second solution severely limits your laptop choices and is fairly
	expensive.  Be sure to read the specifications carefully, you may find
	that you will have to buy an additional non-standard transceiver to
	actually put the machine on a network. Anyone who has used a PCMCIA
	Ethernet card is requested to contact us so that we can add it to
	this document. Barry Jaspan <bjaspan@security.ov.com> has started
	some work on controlling the PCMCIA slot.

7.03 Option 3 -- ISA Ethercard in the Docking Station.

	I recommend the third solution.  Docking stations for laptops typically
	cost about $250 and provide two full-size ISA slots, two serial and one
	parallel port.  Most (all?) docking stations are powered off of the
	laptop's batteries, and a few allow adding extra batteries in the
	docking station if you use short ISA cards.  You can add an inexpensive
	ethercard and enjoy full-speed ethernet performance.

7.04 Option 4 -- Pocket / parallel port adaptors.

	The "pocket" ethernet adaptors may also fit your need.
	Until recently they actually costed more than a docking station and
	cheap ethercard, and most tie you down with a wall-brick power supply.
	The only pocket adaptor driver right now is for the D-Link.
	I'm also working on a driver for the AT-LAN-TEC/RealTek pocket adaptor.
	Most other companies, especially Xircom, treat the programming
	information as a trade secret, so support will likely be slow in
	coming.

	You can sometimes avoid the wall-brick with the adaptors by buying
	or making a cable that draws power from the laptop's keyboard
	port.

8 Frequently asked questions

	Here are some of the more frequently asked questions about using
	Linux with an Ethernet connection. Some of the more specific
	questions are sorted on a "per manufacturer basis" and are listed
	in the "Troubleshooting" section. (section 6). However, since this
	document is basically "old" by the time you get it, any "new" problems
	will not appear here instantly. For these, I suggest that you make
	efficient use of your newsreader. For example, nn users would type
		nn -xX -s'3c'
	to get all the news articles in your subscribed list that have
	"3c" in the subject. (ie. 3com, 3c509, 3c503, etc.)
	The moral: Read the man page for your newsreader.
	
8.01 Just the FAQ's ma'am -- just the FAQ's.

	Q: I heard that there is an alpha driver available for my card.
	   Where can I get it?

	A: Assuming that it is a djb driver, it will be on ftp.super.org
	   in the /pub/linux/ area. Things change here quite frequently,
	   so just look around for it. There is usually only about 3
	   subdirs, so you should be able to find it. Now, if it really
	   is an alpha, or pre-alpha driver, then please treat it as
	   such. In other words, don't complain because you can't figure
	   out what to do with it. If you can't figure out how to install
	   it, then you probably shouldn't be testing it. Also, if it brings
	   your machine down, don't complain. Instead, send us a well
	   documented bug report, or even better, a patch!

	Q: Is there token ring support for Linux?

	A: No, there is no token ring support in Linux. To support token ring
	   requires more than only a writing a device driver, it also requires
	   writing the source routing routines for token ring.  Given that
	   token ring is expensive, not fast, and will probably be swept away
	   by 100baseVG in a few months, it doesn't seem worth it to write
	   a driver. In case anyone wants to, I looked at writing a token ring
	   device driver, and concluded that the hardware interface
	   wasn't too difficult to do, but writing the support for source
	   routing would take significantly longer than I was willing to spend
	   on an expensive and dying technology.

	   Alan Cox adds: "It will require [...] changes to the bottom socket
	   layer to support 802.2 and 802.2 based TCP/IP. Don't expect
	   anything soon."

	Q: Is there IPX or Novell support available for Linux?

	A: Alan Cox writes: "The novell protocols are available from novell
	   for various amounts. IPX is freely documented. SPX is about $1000
	   but I'm told Xerox SPP is identical. _PLEASE_ has anyone got any
	   freely distributable Xerox SPP code/documentation?  The novell
	   server spec costs you $15000 + royalties providing you only
	   want to write a client, or $30000 + royalties otherwise. Needless
	   to say the final output has to be binary only and subject to a
	   novell license. Reading their license rules by my interpretation
	   its also impossible for us to do because you would seem to have
	   to bar disassembly of your final result, which is not allowed
	   in the EEC.

	   Bits of NCP are known, and I hope eventually enough will be known
	   to write limited NCP support into Linux, for the moment I'm poking
	   around at IPX, tho this will have to wait until the new network
	   code is finished.

	   An Alpha test IPX protocol layer is available from me (Alan)
	   for pl14 or higher. People are also exploring the issue of NCP and 
	   the new Dr Dobbs journal article on the innards of netware has 
	   provided a core of good information."

	   As an alternative, Miquel van Smoorenburg suggests the following:
	   "It _is_ possible to set up a dedicated PC running both novell and
	   the PD SOSS server and let it gateway from NFS to novell. This way
	   it is possible to mount the Novell drives on the Unix client.

	   SOSS is a PD (perhaps with some restrictions, but freely available)
	   NFS server for DOS. It includes the PC/IP TCP/IP implementation
	   and runs on a packet driver. I have run both a Novell client
	   (with PDIPX, a Packet Driver IPX) and this SOSS server together
	   successfully."

	Q: What needs to be done so that Linux can run two ethernet cards?

	A: The easiest solution is to get 0.99pl13, which already includes
	   the changes described below.  You can enable additional ethercards
	   with LILO parameters such as
		lilo: linux ether=5,0x300,0,1,eth0 ether=15,0x280,eth1

	   For pre-pl13 you can enable additional ethercards by
	   adding another entry to Space.c, naming it "eth1" instead
	   of "eth0".  If you want routing to work well you should
	   use a recent kernel, say 0.99pl11 or later.  You may also
	   want to verify that your driver writer kept all of the
	   per-card variables in 'dev->priv'.  Most do, but the pl12
	   AT1500/LANCE driver has a single static low-memory buffer.

	Q: I have /dev/eth0 as a link to /dev/xxx. Is this right?

	A: Contrary to the Net-2 HowTo, the files in /dev/* are not used.
	   I originally thought that they might be an OK idea. I've since 
	   concluded that they won't work, at least in the documented form.

9 Miscellaneous.

	Any other associated stuff that didn't fit in anywhere else gets
	dumped here. It may not be relevant, and it may not be of general
	interest but it is here anyway.

9.01 The Cabletron story. (...as related by Donald J. Becker)

		I contacted Cabletron in early December 1992 for
	programming information (I had called and sent several
	earlier messages).  I was referred through several
	different people, and each one took several days to
	respond before they forwarded me to the next.  Eventually
	I was told I should deal with their (outside?) developer
	Mr. Dev.Null.  I persisted, and around March it seemed
	that I had finally succeed: Cabletron offered to send me
	an evaluation board (unrequested) and everything I needed
	to use it (what I wanted).  The hardware showed up right
	away, and I waited, expecting the the programming
	information information as well.  About a month later I
	contacted them, and they told me that "all I needed to use
	it" was the standard MS-DOS NDIS drivers, a binary on
	standard driver disk.  The disk envelope was covered in
	legalese, including no-disassembly, no-reverse-engineering
	clauses.  It was May (and a few email exchanges later)
	before I figured out that I had been "slow rolled", and
	had wasted about 20 hours on this particular windmill.

	The story isn't over yet.  People have written to me say
	they have vetoed several medium-sized purchases from
	Cabletron based on the lack of Linux drivers.  Cabletron
	must have noticed this because yesterday I got a call
	_from_ Cabletron (the first!) stating that they will be
	independently writing a Linux driver.  Of course, their
	lawyers probably haven't read the GPL yet...
	
9.02 The Xircom story. (...as related by Russ Nelson)

	From: "Russell Nelson" <nelson@crynwr.com>
	Subject:   Xircom support (horses mouth)
	Date: Mon, 30 Aug 1993 17:01:04 +0300

	Okay, here's the word on Xircom support.  I spoke to Dirk
	Gates, President of Xircom, about the packet driver
	situation.  Yes, the packet driver uses the Crynwr packet
	driver skeleton, and yes, it's in violation of the GPL.
	However, it was not Xircom's intention to violate the GPL.
	They paid Persoft to write a proprietary driver for them,
	and Persoft used the Clarkson skeleton, alleging that the
	code was in the public domain.  Xircom is unsuable because
	they were an innocent infringer.  I will shortly be sending
	them a demand letter.  If they continue to distribute the
	driver after they get the letter, they will be in
	infringement and I can *then* sue them.  Xircom has
	basically the same philosophy as Diamond.  The actual
	hardware interface is reverse-engineerable in the space of a
	day or so.  However, Xircom prefers to write all their own
	drivers, because badly-written drivers reflect badly on
	their product.  They also perceive a monetary interest in
	keeping their product proprietary.  Xircom would *probably*
	release the specs at this point if they were approached by
	an ad-hoc consortium of potential purchasers who required
	the specs as a condition of purchase.  However, I don't
	think this is the right thing to do.  At this point they
	have already gotten all the proprietary advantage they are
	going to.  Purchasing their product now will only reward
	their "bad attitude" toward open systems.  Much better to
	purchase from a vendor who appreciates and encourages open
	systems, such as D-Link.

9.03	Closing

	If you have found any glaring typos, or outdated info in this
	document, please let one of us know.

	Paul Gortmaker		<gpg109@rsphysse.anu.edu.au>
	Donald J. Becker	<becker@super.org>

		=========== end of Ethernet HOWTO ============




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Linux Ethernet HOWTO (Part 2/2)
@ 1994-01-25  4:24 Paul Gortmaker
  0 siblings, 0 replies; 6+ messages in thread
From: Paul Gortmaker @ 1994-01-25  4:24 UTC (permalink / raw)


Archive-Name: linux/howto/ethernet/part2
Last-Modified: November 16, 1993

This is part 2/2 of the Linux Ethernet HOWTO. It is archived on 
sunsite.unc.edu in pub/Linux/docs/HOWTO.

[Begin part 2/2]

5 Technical information.

	For those who want to play with the present drivers, or try to make
	up their own driver for a card that is presently unsupported, this
	information should be useful. If you do not fall into this category,
	then perhaps you will want to skip this section.

5.01 Probed addresses

	While trying to determine what ethernet card is there, the following
	addresses are autoprobed, assuming the type and specs of the card
	have not been set in the kernel. In /usr/src/linux/net/inet/CONFIG,
	one can set the cards that are compiled in to the kernel. As of
	0.99pl12, doing a "make config" will ask what cards are to be
	supported. The file names below are in /usr/src/linux/net/inet/
	----------------------------------------------------------------
	wd.c:		0x300, 0x280, 0x380, 0x240
	3c503.c:	0x300, 0x310, 0x330, 0x350, 0x250, 0x280, 0x2a0, 0x2e0
	ne.c:		0x300, 0x280, 0x320, 0x340, 0x360
	hp.c:		0x300, 0x320, 0x340, 0x280, 0x2C0, 0x200, 0x240
	lance.c:	0x300, 0x320, 0x340, 0x360
	smc-ultra.c:	0x300, 0x280
	3c509.c:	<Special "ID Port" probe>
	----------------------------------------------------------------
	There are some NE2000 clone ethercards out there that are waiting black
	holes for autoprobe drivers.  While many NE2000 clones are
	safe until they are enabled, some can't be reset to a safe mode.
	These dangerous ethercards will hang any I/O access to their
	"dataports".  The typical dangerous locations are:

	Ethercard jumpered base     Dangerous locations (base + 0x10 - 0x1f)
		0x300 *				0x310-0x317
		0x320				0x330-0x337
		0x340				0x350-0x357
		0x360				0x370-0x377

	* The 0x300 location is the traditional place to put an ethercard, but
	it's also a popular place to put other devices (often SCSI
	controllers).  The 0x320 location is often the next one chosen, but
	that's bad for for the AHA1542 driver probe.  The 0x360 location is
	bad, because it conflicts with the parallel port at 0x378.

	To avoid these lurking ethercard, here are the things you can do:

        o Probe for the device's BIOS in memory space.  This is easy
	  and always safe, but it only works for cards that always have
	  BIOSes, like primary SCSI controllers.

	o Avoid probing any of the above locations until you think
	  you've located your device.  The NE2000 clones have a reset range
	  from <base>+0x18 to <base>+0x1f that will read as 0xff, so probe
	  there first if possible.  It's also safe to probe in the 8390
	  space at <base>+0x00 - <base>+0x0f, but that area will return
	  quasi-random values

	o If you must probe in the dangerous range, for instance if your
	  target device has only a few port locations, first check that
	  there isn't an NE2000 there. You can see how to do this by
	  looking at the probe code in /usr/src/linux/net/inet/ne.c

	In other news, I've written the code for the I/O port registrar.
	Peter MacDonald and I have been intensely discussing this, and I think
	our current scheme has the necessary functionality with minimal kernel
	size impact.  (The implementation involved rewriting the bitmap ops in
	kernel/ioport.c:ioperm() so that most code could be shared.)

	Here is the current "blurb".  As usual comments are welcome. Please
	keep them substantial and constructive (we've already talked about
	changing the name from "reserve=" to "noprobe=").

	==================

	Boot-Time Parameters: "reserve="
	
	In some machines it may be necessary to prevent device drivers from
	checking for devices (auto-probing) in a specific region.  This may be
	because of poorly designed hardware that causes the boot to "freeze"
	(such as some ethercards), hardware that is mistakenly identified,
	hardware whose state is changed by an earlier probe, or merely
	hardware you don't want the kernel to initialize.

	The "reserve" boot-time argument addresses this problem by specifying
	an I/O port region that shouldn't be probed.  That region is reserved
	in the kernel's port registration table as if a device has already
	been found in that region.  Note that this mechanism shouldn't be
	necessary on most machine, only when there is a problem or special
	case.

	The boot-line syntax is

	  lilo-prompt: linux-image reserve=[<port>,<size>,<port>,<size>...]

	As usual with boot-time specifiers there is an 11 parameter limit, thus
	you can only specify 5 reserved regions per "reserve" keyword.
	Multiple "reserve" specifiers will work if you have an usually
	complicated request.

	If you specify a "reserve" region to protect a specific device, you
	must generally specify an explicit probe for that device.  Most
	drivers ignore the port registration table if they are given an
	explicit address.

5.02 Skeleton / prototype driver

	OK. So you have decided that you want to write a driver for the
	Foobar Ethernet card, as you have the programming information,
	and it hasn't been done yet. (...these are the two main require-
	ments ;-) You can use the skeleton network driver that is provided
	with the Linux kernel source tree. It can be found in the file
	/usr/src/linux/net/inet/README.DRIVERS as of 0.99pl12, and later.

	It's also very useful to look at the Crynwr (nee Clarkson) driver
	for your target ethercard, if it's available.  Russ Nelson
	<nelson@crynwr.com> has been actively updating and writing these,
	and he has been very helpful with his code reviews of the current 
	Linux drivers.

5.03 Driver interface to the kernel

	Here are some notes that may help when trying to figure out what
	the code in the driver segments is doing, or perhaps what it is
	supposed to be doing.

	=====================================================

	int ethif_init(struct device *dev)
	{
	    ...
		dev->send_packet = &ei_send_packet;
		dev->open = &ei_open;
		dev->stop = &ei_close;
		dev->hard_start_xmit = &ei_start_xmit;
		...
	}

	int ethif_init(struct device *dev)

	This function is put into the device structure in Space.c.  It is
	called only at boot time, and returns '0' iff the ethercard 'dev'
	exists.

	=====================================================

	static int ei_open(struct device *dev)
	static int ei_close(struct device *dev)

	This routine opens and initializes the board in response to an
	socket ioctl() usually called by 'config' or 'ifconfig'.  It is
	commonly stuffed into the 'struct device' by ethif_init().

	The inverse routine is ei_close(), which should shut down the
	ethercard, free the IRQs and DMA channels if the hardware permits,
	and turn off anything that will save power (like the transceiver).

	(Note: As of NET-2, the relevant program is '/etc/ifconfig' - and
	the device *can* be turned off or on via passing 'up' or 'down'
	to 'ifconfig' from the command line with the device name.)

	=====================================================

	static int ei_start_xmit(struct sk_buff *skb, struct device *dev)
		dev->hard_start_xmit = &ei_start_xmit;

	This routine puts packets to be transmitted into the hardware.  It
	is usually stuffed into the 'struct device' by ethif_init().

	When the hardware can't accept additional packets it should set
	the dev->tbusy flag.  When additional room is available, usually
	during a transmit-complete interrupt, dev->tbusy should be cleared
	and the higher levels informed with mark_bh(INET_BH).
	[[Note: pre0.99.4 kernels didn't use this interface for all packets.]]
	
	=====================================================

	...
	    if (dev_rint(buffer, length, is_skb ? IN_SKBUFF : 0, dev))
		   stats->rx_dropped++;
	...
	A received packet is passed to the higher levels using dev_rint().
	If the unadorned packet data in a memory buffer, dev_rint will copy
	it into a 'skbuff' for you.  Otherwise a new skbuff should be
	kmalloc()ed, filled, and passed to dev_rint() with the IN_SKBUFF flag.

	=====================================================

5.04 Interrupts and Linux

	There are two kinds of interrupt handlers in Linux:
	fast ones and slow ones. You decide what kind you are installing by
	the flags you pass to irqaction().  The fast ones, such as the serial
	interrupt handler, run with _all_ interrupts disabled.  The normal
	interrupt handlers, such as the one for ethercard drivers, runs with
	other interrupts enabled.

	There is a two-level interrupt structure.  The "fast" part handles the
	device register, removes the packets, and perhaps sets a flag.   After
	it is done, and interrupts are re-enabled, the slow part is run if the
	flag is set.

	The flag between the two parts is set by:
		mark_bh(INET_BH);

	Usually this flag is set within dev_rint() during a received-packet
	interrupt, and set directly by the device driver during a
	transmit-complete interrupt.

	You might wonder why all interrupt handlers cannot run in
	"normal mode" with other interrupts enabled.  Ross Biro uses this
	scenario to illustrate the problem:
		o You get a serial interrupt, and start processing it.
	          The serial interrupt is now masked.
		o You get a network interrupt, and you start transferring
	          a maximum-sized 1500 byte packet from the card.
		o Another character comes in, but this time the interrupts
		  are masked!

	The "fast" interrupt structure solves this problem by allowing
	bounded-time interrupt handlers to run without the risk of leaving
	their interrupt lines masked by another interrupt request.

	There is an additional distinction between fast and slow interrupt
	handlers -- the arguments passed to the handler.  A "slow" handler is
	defined as

		static void
		handle_interrupt(int reg_ptr)
		{
		    int irq = -(((struct pt_regs *)reg_ptr)->orig_eax+2);
		    struct device *dev = irq2dev_map[irq];
		...

	While a fast handler gets the interrupt number directly

		static void
		handle_fast_interrupt(int irq)
		{
		...

	A final aspect of network performance is latency.  The only board
	that really addresses this is the 3c509, which allows a predictive
	interrupt to be posted.  It provides an interrupt response timer so
	that the driver can fine-tune how early an interrupt is generated.

	Alan Cox has some advice for anyone wanting to write drivers
	that are to be used with pl14 kernels and newer. He says:

	"Any driver intended for pl14 should use the new alloc_skb() and 
	kfree_skbmem() functions rather than using kmalloc() to obtain an
	sk_buff. The new pl14 skeleton does this correctly. For drivers 
	wishing to remain compatible with both sets the define 
	'HAVE_ALLOC_SKB' indicates these functions must be used.

	In essence replace

		skb=(struct sk_buff *)kmalloc(size)
	with

		skb=alloc_skb(size)

	and

		kfree_s(skb,size)

	with

		kfree_skbmem(skb,size)	/* Only sk_buff memory though */

	Any questions should I guess be directed to me since I made the change.
	This is a change to allow tracking of sk_buff's and sanity checks on 
	buffers and stack behaviour. If a driver produces the message 
	'File: ??? Line: ??? passed a non skb!' then it is probable the 
	driver is not using the new sk_buff allocators."




5.05 Programmed I/O vs. shared mem. vs. slave/master DMA

	Ethernet is 10Mbs.  (Don't be pedantic, 3Mbs and 100Mbs don't count.)
	If you can already send and receive back-to-back packets, you just
	can't put more bits over the wire.  Every modern ethercard can receive
	back-to-back packets.  The Linux DP8390 drivers come pretty close to
	sending back-to-back packets (depending on the current interrupt
	latency) and the 3c509 and AT1500 hardware has no problem at all
	automatically sending back-to-back packets.

	The ISA bus can do 5.3MB/sec (42Mb/sec), which sounds like more than
	enough.  You can use that bandwidth in several ways:

	Programmed I/O
	==============
	  Pro: Doesn't use any constrained system resources,
	       just a few I/O registers, and has no 16M limit.
	  Con: Usually the slowest transfer rate, the CPU is waiting
	       the whole time, and interleaved packet access is usually
	       difficult to impossible.

	Shared memory
	=============
	  Pro: Simple, faster than programmed I/O, and allows random
	       access to packets.
	  Con: Uses up memory space (a big one for DOS users, only a minor
	       issue under Linux), and it still ties up the CPU.

	Slave (normal) DMA
	==================
	  Pro: Frees up the CPU during the actual data transfer.
	  Con: Checking boundary conditions, allocating contiguous buffers,
	       and programming the DMA registers makes it the slowest
	       of all techniques.  It also uses up a scarce DMA
	       channel, and requires aligned low memory buffers.

	Master (bus-master) DMA
	=======================
	  Pro: Frees up the CPU during the data transfer, can string together
	       buffers, can require little or no CPU time lost on the
	       ISA bus.
	  Con: Requires low-memory buffers and a DMA channel. Any
	       bus-master will have problems with other bus-masters that 
	       are bus-hogs, such as some primitive SCSI adaptors. A few
	       badly-designed motherboard chipsets have problems with
	       bus-masters. And a reason for not using *any* type of 
	       DMA device is using a Cyrix 486 processor designed for
	       plug-in replacement of a 386: these processors must
	       flush their cache with each DMA cycle.

5.06 Programming the Intel chips (i82586 and i82593)

	These chips are used on a number of cards, namely the 3c507 ('86),
	the Intel EtherExpress 16 ('86), Microdyne's exos205t ('86),
	the Z-Note ('93), and the Racal-Interlan ni5210 ('86).

	Russ Nelson writes:
	"Most boards based on the 82586 can reuse quite a bit of their code.
	More, in fact, than the 8390-based adapters.  There are only three
	differences between them:

	  o The code to get the Ethernet address,
	  o The code to trigger CA on the 82586, and
	  o The code to reset the 82586.

	The Intel EtherExpress 16 is an exception, as it I/O maps the 82586.
	Yes, I/O maps it.  Fairly clunky, but it works.

	Garrett Wollman did an AT&T driver for BSD that uses the BSD
	copyright.  The latest version I have (Sep '92) only uses a single
	transmit buffer.  You can and should do better than this if you've
	got the memory.  The AT&T and 3c507 adapters do; the ni5210 doesn't.

	The people at Intel gave me a very big clue on how you queue up
	multiple transmit packets.  You set up a list of
	NOP->XMIT->NOP->XMIT->NOP->XMIT->(beginning) blocks, then you set the
	"next" pointer of all the NOP blocks to themselves.  Now you start
	the command unit on this chain.  It continually processes the first
	NOP block.  To transmit a packet, you stuff it into the next transmit
	block, then point the NOP to it.  To transmit the next packet, you
	stuff the next transmit block and point the previous NOP to *it*.  In
	this way, you don't have to wait for the previous transmit to finish,
	you can queue up multiple packets without any ambiguity as to whether
	it got accepted, and you can avoid the command unit start-up delay."

5.07	Technical information from 3Com

	From: Cameron Spitzer 764-6339 <camerons@nad.3com.com>
	Subject: getting 3Com Adapter manuals
	Date: Mon, 27 Sep 1993 21:17:07 +0200
	
	Since this is becoming a FAQ, I'm going to tread the thin
	ice of No Commercial Use and answer it here.

	3Com's Ethernet Adapters are documented for driver writers
	in our "Technical References" (TRs).  These manuals describe
	the programmer interfaces to the boards but they don't talk
	about the diagnostics, installation programs, etc that end
	users can see.
	
	The Network Adapter Division marketing department has the
	TRs to give away.  To keep this program efficient, we
	centralized it in a thing called "CardFacts."  CardFacts is
	an automated phone system.  You call it with a touch-tone
	phone and it faxes you stuff.  To get a TR, call CardFacts
	at 408-727-7021.  Ask it for Developer's Order Form,
	document number 9070.  Have your fax number ready when you
	call.  Fill out the order form and fax it to 408-764-5004.
	Manuals are shipped by Federal Express 2nd Day Service.
	
	If you don't have a fax and nobody you know has a fax,
	really and truly, *then* send mail to
	Terry_Murphy@3Mail.3Com.com and tell her about your problem.
	PLEASE use the fax thing if you possibly can.
	
	After you get a manual, if you still can't figure out how to
	program the board, try our "CardBoard" BBS at
	1-800-876-3266, and if you can't do that, write
	Andy_Chan@3Mail.3com.com and ask him for alternatives.  If
	you have a real stumper that nobody has figured out yet, the
	fellow who needs to know about it is
	Steve_Lebus@3Mail.3com.com.
	
	There are people here who think we are too free with the
	manuals, and they are looking for evidence that the system
	is too expensive, or takes too much time and effort.  That's
	why it's important to try to use CardFacts *before* you
	start calling and mailing the people I named here.
	
	There are even people who think we should be like Diamond
	and Xircom, requiring tight "partnership" with driver
	writers to prevent poorly performing drivers from getting
	written.  So far, 3Com customers have been really good about
	this, and there's no problem with the level of requests
	we've been getting.  We need your continued cooperation and
	restraint to keep it that way.
	
	Cameron Spitzer,  408-764-6339
	3Com NAD
	Santa Clara
	work: camerons@nad.3com.com
	home: cls@truffula.sj.ca.us

5.08 Notes on AMD PCnet-ISA / LANCE Based cards (79C960)

	The AMD LANCE (Local Area Network Controller for Ethernet)
	was the original offering, and has since been replaced by
	the "PCnet-ISA" chip, otherwise known as the 79C960.
	A relatively new chip from AMD, the 79C960, is the heart of many
	new cards being released at present. Note that the name "LANCE"
	has stuck, and some people will refer to the new chip by the old
	name. Dave Roberts of the Network Products Division of AMD was kind
	enough to contribute the following information regarding this chip:

	"As for the architecture itself, AMD developed it originally
	and reduced it to a single chip -- the PCnet(tm)-ISA -- over a year
	ago.  It's been selling like hotcakes ever since.

	Functionally, it is equivalent to a NE1500.  The register set
	is identical to the old LANCE with the 1500/2100 architecture
	additions.  Older 1500/2100 drivers will work on the PCnet-ISA.
	The NE1500 and NE2100 architecture is basically the same.
	Initially Novell called it the 2100, but then tried to distinguish
	between coax and 10BASE-T cards.  Anything that was 10BASE-T only was
	to be numbered in the 1500 range.  That's the only difference.

	Many companies offer PCnet-ISA based products, including HP,
	Racal-Datacom, Allied Telesis, Boca Research, Kingston Technology, etc.
	The cards are basically the same except that some manufacturers
	have added "jumperless" features that allow the card to
	be configured in software.  Most have not.  AMD offers a standard
	design package for a card that uses the PCnet-ISA and many
	manufacturers use our design without change.
	What this means is that anybody who wants to write drivers for
	most PCnet-ISA based cards can just get the data-sheet from AMD.  Call
	our literature distribution center at (800)222-9323 and ask for the
	Am79C960, PCnet-ISA data sheet.  It's free.

	A quick way to understand whether the card is a "stock" card
	is to just look at it.  If it's stock, it should just have one large
	chip on it, a crystal, a small IEEE address PROM, possibly a socket
	for a boot ROM, and a connector (1, 2, or 3, depending on the media
	options offered).  Note that if it's a coax card, it will have some
	transceiver stuff built onto it as well, but that should be near the
	connector and away from the PCnet-ISA.

	The PCnet-ISA is faster than the original LANCE design and
	makes better use of the available bus bandwidth.  Additionally, some
	LANCE bugs were corrected and many enhancements were made."

5.09 Multicast and Promiscuous mode

	One of the things I've been working on recently is the
	major remaining item on the ethercard feature list:
	implementing multicast and promiscuous mode hooks.
	
	At first I was planning to do it while implementing either
	the /dev/* or DDI interface, but that's not really the
	correct way to do it.  We should only enable multicast or
	promiscuous modes when something wants to look at the
	packets, and shut it down when that application is
	finished, neither of which is strongly related to when the
	hardware is opened or released.
	
	I'll start by discussing promiscuous mode, which is
	conceptually easy to implement.  For most hardware you
	only have to set a register bit, and from then on you get
	every packet on the wire.  Well, it's almost that easy;
	for some hardware you have to shut the board (potentially
	dropping a few packet), reconfigure it, and then re-enable
	the ethercard.  This is grungy and risky, but the
	alternative seems to be to have every application register
	before you open the ethercard at boot-time.
	
	OK, so that's easy, so I'll move on something that's not
	quite so obvious: Multicast.  It can be done two ways:
	
	1) Use promiscuous mode, and a packet filter like the
	   Berkeley packet filter (BPF).  The BPF is a pattern matching
	   stack language, where you write a program that picks out the
	   addresses you are interested in.  Its advantage is that it's
	   very general and programmable.  Its disadvantage is that there
	   is no general way for the kernel to avoid turning on promiscuous
	   mode and running every packet on the wire through every registered
	   packet filter. See the next section for more information on BPF.
	
	2) Using the built-in multicast filter that most etherchips have.
	
	I guess I should list what a few ethercards/chips provide:
	
	Chip/card  Promiscuous	Multicast filter
	========================================
	Seeq8001/3c501	Yes	Binary filter (1)
	3Com/3c509	Yes	Binary filter (1)
	8390		Yes	Autodin II six bit hash (2) (3)
	LANCE		Yes	Autodin II six bit hash (2) (3)
	i82586		Yes	Hidden Autodin II six bit hash (2) (4)
	
	
	(1) These cards claim to have a filter, but it's a simple
	yes/no 'accept all multicast packets', or 'accept no
	multicast packets'.
	
	(2) AUTODIN II is the standard ethernet CRC (checksum)
	polynomial.  In this scheme multicast addresses are hashed
	and looked up in a hash table.  If the cooresponding bit
	is enabled, this packet is accepted.  Ethernet packets are
	laid out so that the hardware to do this is trivial -- you
	just latch six (usually) bits from the CRC circuit (needed
	anyway for error checking) after the first six octets (the
	destination address), and use them as an index into the
	hash table (six bits == a 64-bit table).
	
	(3) These chips use the six bit hash, and must have the
	table computed and loaded by the host.  This means the
	kernel must include the CRC code.
	
	(4) The 82586 uses the six bit hash internally, but it
	computes the hash table itself from a list of multicast
	addresses to accept.

	Note that none of these chips do perfect filtering, and we
	still need a middle-level module to do the final
	filtering.  Also note that in every case we must keep a
	complete list of accepted multicast addresses to recompute
	the hash table when it changes.
	
	My first pass at device-level support is detailed in the
	new outline driver:
	ftp.super.org:/pub/linux/pl14/skeleton.c
	
	Also in that directory you'll find all of my drivers
	updated to use the proposed promiscuous/multicast mode
	hook.
	
	#ifdef HAVE_MULTICAST
	static void set_multicast_list(struct device *dev, int num_addrs,
					 void *addrs);
	#endif
	.
	.
	
	ethercard_open() {
	...
	#ifdef HAVE_MULTICAST
		dev->set_multicast_list = &set_multicast_list;
	#endif
	...
	
	#ifdef HAVE_MULTICAST
	/* Set or clear the multicast filter for this adaptor.
	   num_addrs == -1	Promiscuous mode, receive all packets
	   num_addrs == 0	Normal mode, clear multicast list
	   num_addrs > 0	Multicast mode, receive normal and
				MC packets, and do best-effort filtering.
	 */
	static void
	set_multicast_list(struct device *dev, int num_addrs, void *addrs)
	{
	...

	Any comments, criticism, etc. are welcome.

	Alan Cox adds that "...in pl14, user programs can access promiscuous 
	mode but not multicast mode, even though the drivers support both. 
	The ifconfig program allows you to mark an interface 'promisc'."
	
5.10 The Berkely Packet Filter (BPF)

	I'm not bitterly opposed to it, but I'm coming to the
	conclusion that the 'bpf' functionality should not be provided
	by the kernel, but should be in a (hopefully little-used)
	compatibility library.
	
	For those not in the know: 'bpf' (the Berkeley Packet Filter)
	is an mechanism for specifying to the kernel networking layers
	what packets you are interested in.  It's implemented as a
	specialized stack language interpreter built into a low level
	of the networking code.  An application passes a program
	written in this language to the kernel, and the kernel runs the
	program on each incoming packet.  If the kernel has multiple
	'bpf' applications, each program is run on each packet.
	
	The problem is that it's difficult to deduce what kind of
	packets the application is really interested in from the packet
	filter program, so the general solution is to always run the
	filter.  Imagine a program that registers a 'bpf' program to
	pick up a low data-rate stream sent to a multicast address.
	Most ethernet cards have a hardware multicast address filter
	implemented as a 64 entry hash table that ignores most unwanted
	multicast packets, so the capability exists to make this a very
	inexpensive operation.  But with the BFP the kernel must switch
	the interface to promiscuous mode, receive _all_ packets, and
	run them through this filter.  This is work, BTW, that's very
	difficult to account back to the process requesting the packets.

5.11 Unresolved questions / concerns

	There may be some benefit from processing packet data as it is
	transferred to and from the ethercard, especially with very fast
	processors transferring data to a slow ethercard.  As I see it this
	question has multiple parts:
		1) Is there any useful processing power available, perhaps
		   during the ISA bus recovery period, or while the 8390
		   remote DMA is preparing for another transfer??
		2) Is there any useful but simple work that can be done
		   between/during each word of the copy, such as calculating
		   a CRC, or discarding obviously unwanted packets??
		3) would the complexity of an interface to do this make future
		   ethercard drivers impossible??

	There should be a better structure than Space.c  Drivers should be
	able to autoprobe for all installed ethercards rather than just
	quitting after finding the first.  I've written code to do this,
	but the constant promise (threat?) of DDI has prevented me from
	making it standard.

	A related topic is the problem of driver probes corrupting
	unrelated hardware. Even worse is a probe into a dataport that
	isn't set up to transfer data, which will freeze the machine.  The
	common suggestion is a boot-time device registry that records
	already-used I/O ports and shared memory. This has been implemented
	as of pl13, see section 5.01.

6 Possible problems, and troubleshooting.

	This section tries to answer any unresolved questions, and not so
	common solutions to common problems. They are sorted on a "per
	manufacturer basis". You should have also read the relevant info.
	from section 1 about your specific card. Section 8 contains more
	general FAQ's.

6.01 Problems with NE2000 (and clones)

	"DMA address mismatch"
	======================

	Is the chip a real NatSemi 8390? (DP8390, DP83901, DP83902 or DP83905)?
	If not, some clone chips don't correctly implement the transfer
	verification register.  MS-DOS drivers never do error checking,
	so it doesn't matter to them.

	Are most of the messages off by a factor of 2?
	If so:	Are you using the NE2000 in a 16 bit slot?
		Is it jumpered to use only 8 bit transfers?

	The Linux driver expects a NE2000 to be a 16 bit slot.  A NE1000 can
	be in either size slot.  This problem can also occur with some clones,
	notably D-Link 16 bit cards, that don't have the correct ID bytes
	in the station address PROM. [[ This should be fixed in pl12.]]

	Are you running the bus faster than 8Mhz?
	If you can change the speed (faster or slower), see if that
	makes a difference.  Most NE2000 clones will run at 16Mhz, but
	some may not.  Changing speed can also mask a noisy bus.

	What other devices are on the bus?
	If moving the devices around changes the reliability, then you
	have a bus noise problem -- just what that error message was
	designed to detect.  Congratulations, you've probably found the
	source of other problems as well.

	Machine Hangs during Boot.
	==========================

	Problem:  The machine hangs during boot right after the "8390..."  or
		  "WD...." message.  Removing the NE2000 fixes the problem.

	Solution: Change your NE2000 base address to 0x360 (or 0x340 for
		  pl12 or later kernels.) Alternatively, you can use the new
		  device registrar implemented in pl13 (see section 5.1)

	Reason:   Your NE2000 clone isn't a good enough clone.  An active
		  NE2000 is a bottomless pit that will trap any driver
		  autoprobing in its space.  The other ethercard drivers take
		  great pain to reset the NE2000 so that it's safe, but some
		  clones cannot be reset.  Clone chips to watch out for:
		  Winbond 83C901.  Changing the NE2000 to a less-popular
		  address will move it out of the way of other autoprobes,
		  allowing your machine to boot.

	Problem:  The machine hangs during the SCSI probe at boot.

	Solution: It's the same problem as above, change the
		  ethercard's address, or use the device registrar.

	Problem:  The machine hangs during the soundcard probe at boot.

	Solution: No, that's really during the silent SCSI probe, and it's
		  the same problem as above.

	"eth0: DMAing conflict in ne_block_input"
	=========================================

	This bug came from timer-based packet retransmissions.  If you got a
	timer tick _during_ a ethercard RX interrupt, and timer tick tried to
	retransmit a timed-out packet, you could get a conflict.  Because of
	the design of the NE2000 you would have the machine hang (exactly the
	same the NE2000-clone boot hangs).

	Early versions of the driver disabled interrupts for a long time,
	and didn't have this problem.  Later versions are fixed. (ie. kernels
	after 0.99p9 should be OK.)

	NE2000 not detected at boot.
	============================

	A few people have reported a problem with detecting the Accton NE2000.
	This problem occurs only at boot-time, and the card is later detected
	at run-time by the identical code my (alpha-test) ne2k diagnostic
	program. Accton has been very responsive, but I still haven't tracked
	down what is going on.  I've been unable to reproduce this problem
	with the Accton cards we purchased.  If you are having this problem,
	please send me an immediate bug report.  For that matter, if you have
	an Accton card send me a success report, including the type of the
	motherboard.  I'm especially interested in finding out if this problem
	moves with the particular ethercard, or stays with the motherboard.

6.02 Problems with WD80*3 cards

	Detected Non-existent Ethercard
	===============================

	Problem:  A WD80*3 is falsely detected.  Removing the sound or
		  MIDI card eliminates the "detected" message.

	Solution: Update your ethercard driver: new versions include an
		  additional sanity check.

	Reason:   Some MIDI ports happen to produce the same checksum as a
		  WD ethercard.

	Error messages from the 80*3
	============================

	Problem:  You get messages such as the following with your 80*3:
			eth0: bogus packet size, status = ........
			kmalloc called with impossibly large argument (65400)
			eth0: Couldn't allocate sk_buff of size 65400
			eth0: receiver overrun

	Reason:   There is a shared memory problem.

	Solution: If the problem is sparodic, you have hardware problems.
		  Typical problems that are easy to fix are board conflicts,
		  having cache or "shadow ROM" enabled for that region, or
		  running your bus faster than 8Mhz.  There are also a
		  surprising number of memory failures on ethernet cards,
		  so run a diagnostic program if you have one for your
		  ethercard.

		  If the problem is continual, and you have have to reboot
		  to fix the problem, record the boot-time probe message
		  and mail it to becker@super.org  Take particular note of
		  the shared memory location.

6.03 Problems with 3Com cards

	Choosing the Interrupt of the 3c503
	===================================

	Problem:  The 3c503 picks IRQ n at boot, but this is needed for some
		  other device which needs IRQ n. (eg. CD ROM driver, etc.)
		  Can this be fixed without compiling this into the kernel?

	Solution: The 3c503 driver probes for a free IRQ line in the order
		  {5, 9/2, 3, 4}, and it should pick a line which isn't being
		  used.  The pre-pl12 (SLS 1.02) driver picked the IRQ line
		  at boot-time, and the current driver (pl12) chooses when
		  the card is open()/'ifconfig'ed. Note the "bug" noted in
		  the 3c503 section in 1.01

		  Alternately, you can fix the IRQ at boot by passing
		  parameters via LILO.  The following selects IRQ9, base
		  location 0x300, <ignored value>, and if_port #1 (the
		  external transceiver).
			lilo: linux ether=9,0x300,0,1,eth0

		  The following selects IRQ3, probes for the base location,
		  <ignored value>, and the default if_port #0 (the internal
		  transceiver)
			lilo: linux ether=3,0,0,0,eth0

	"3c503: Configured interrupt number XX is out of range."
	========================================================

	Problem:  Whoever built your kernel fixed the ethercard IRQ at XX.

	Reason:   The above is truly evil, and worse than that, it is
		  not necessary. The 3c503 will autoIRQ when it gets
		  "ifconfig"ed, and pick one of IRQ{5, 2/9, 3, 4}.

	Solution: Use lilo to set the IRQ, or rebuild the kernel, enabling
		  autoIRQ by not specifying the IRQ line.

	Choosing the output of the 3c503
	================================

	Problem:  The supplied 3c503 drivers don't use the AUI (thicknet) port.
		  How does one choose it over the default thinnet port?

	Solution: The 3c503 AUI port can be selected at boot-time with 0.99pl12
		  and later.  The selection is overloaded onto the low bit of
		  the currently-unused dev->rmem_start variable, so a boot-time
		  parameter of:
			lilo: linux ether=0,0,0,1,eth0
		  should work.  A boot line to force IRQ 5, port base 0x300,
		  and use an external transceiver is:
			lilo: linux ether=5,0x300,0,1,eth0

7 Networking with a laptop computer

	There are currently only a few ways to put your laptop on a network.
	You can use the NET-2 SLIP code (and run at serial line speeds);
	you can buy one of the few laptops that come with a NE2000-compatible
	ethercard or PCMCIA slot built-in; you can get a laptop with a
	docking station and plug in an ISA ethercard; or you can use a
	parallel port Ethernet adapter such as the D-Link DE-600.

7.01 Option 1 -- using SLIP

	This is the cheapest solution, but by far the most difficult. Also,
	you will not get very high transmission rates. Since SLIP is not
	really related to ethernet cards, it will not be discussed further
	here. See the NET-2 HOWTO.

7.02 Option 2 -- Built in NE2000 compatible or PCMCIA Ethercard.

	The second solution severely limits your laptop choices and is fairly
	expensive.  Be sure to read the specifications carefully, you may find
	that you will have to buy an additional non-standard transceiver to
	actually put the machine on a network. Anyone who has used a PCMCIA
	Ethernet card is requested to contact us so that we can add it to
	this document. Barry Jaspan <bjaspan@security.ov.com> has started
	some work on controlling the PCMCIA slot.

7.03 Option 3 -- ISA Ethercard in the Docking Station.

	I recommend the third solution.  Docking stations for laptops typically
	cost about $250 and provide two full-size ISA slots, two serial and one
	parallel port.  Most (all?) docking stations are powered off of the
	laptop's batteries, and a few allow adding extra batteries in the
	docking station if you use short ISA cards.  You can add an inexpensive
	ethercard and enjoy full-speed ethernet performance.

7.04 Option 4 -- Pocket / parallel port adaptors.

	The "pocket" ethernet adaptors may also fit your need.
	Until recently they actually costed more than a docking station and
	cheap ethercard, and most tie you down with a wall-brick power supply.
	The only pocket adaptor driver right now is for the D-Link.
	I'm also working on a driver for the AT-LAN-TEC/RealTek pocket adaptor.
	Most other companies, especially Xircom, treat the programming
	information as a trade secret, so support will likely be slow in
	coming.

	You can sometimes avoid the wall-brick with the adaptors by buying
	or making a cable that draws power from the laptop's keyboard
	port.

8 Frequently asked questions

	Here are some of the more frequently asked questions about using
	Linux with an Ethernet connection. Some of the more specific
	questions are sorted on a "per manufacturer basis" and are listed
	in the "Troubleshooting" section. (section 6). However, since this
	document is basically "old" by the time you get it, any "new" problems
	will not appear here instantly. For these, I suggest that you make
	efficient use of your newsreader. For example, nn users would type
		nn -xX -s'3c'
	to get all the news articles in your subscribed list that have
	"3c" in the subject. (ie. 3com, 3c509, 3c503, etc.)
	The moral: Read the man page for your newsreader.
	
8.01 Just the FAQ's ma'am -- just the FAQ's.

	Q: I heard that there is an alpha driver available for my card.
	   Where can I get it?

	A: Assuming that it is a djb driver, it will be on ftp.super.org
	   in the /pub/linux/ area. Things change here quite frequently,
	   so just look around for it. There is usually only about 3
	   subdirs, so you should be able to find it. Now, if it really
	   is an alpha, or pre-alpha driver, then please treat it as
	   such. In other words, don't complain because you can't figure
	   out what to do with it. If you can't figure out how to install
	   it, then you probably shouldn't be testing it. Also, if it brings
	   your machine down, don't complain. Instead, send us a well
	   documented bug report, or even better, a patch!

	Q: Is there token ring support for Linux?

	A: No, there is no token ring support in Linux. To support token ring
	   requires more than only a writing a device driver, it also requires
	   writing the source routing routines for token ring.  Given that
	   token ring is expensive, not fast, and will probably be swept away
	   by 100baseVG in a few months, it doesn't seem worth it to write
	   a driver. In case anyone wants to, I looked at writing a token ring
	   device driver, and concluded that the hardware interface
	   wasn't too difficult to do, but writing the support for source
	   routing would take significantly longer than I was willing to spend
	   on an expensive and dying technology.

	   Alan Cox adds: "It will require [...] changes to the bottom socket
	   layer to support 802.2 and 802.2 based TCP/IP. Don't expect
	   anything soon."

	Q: Is there IPX or Novell support available for Linux?

	A: Alan Cox writes: "The novell protocols are available from novell
	   for various amounts. IPX is freely documented. SPX is about $1000
	   but I'm told Xerox SPP is identical. _PLEASE_ has anyone got any
	   freely distributable Xerox SPP code/documentation?  The novell
	   server spec costs you $15000 + royalties providing you only
	   want to write a client, or $30000 + royalties otherwise. Needless
	   to say the final output has to be binary only and subject to a
	   novell license. Reading their license rules by my interpretation
	   its also impossible for us to do because you would seem to have
	   to bar disassembly of your final result, which is not allowed
	   in the EEC.

	   Bits of NCP are known, and I hope eventually enough will be known
	   to write limited NCP support into Linux, for the moment I'm poking
	   around at IPX, tho this will have to wait until the new network
	   code is finished.

	   An Alpha test IPX protocol layer is available from me (Alan)
	   for pl14 or higher. People are also exploring the issue of NCP and 
	   the new Dr Dobbs journal article on the innards of netware has 
	   provided a core of good information."

	   As an alternative, Miquel van Smoorenburg suggests the following:
	   "It _is_ possible to set up a dedicated PC running both novell and
	   the PD SOSS server and let it gateway from NFS to novell. This way
	   it is possible to mount the Novell drives on the Unix client.

	   SOSS is a PD (perhaps with some restrictions, but freely available)
	   NFS server for DOS. It includes the PC/IP TCP/IP implementation
	   and runs on a packet driver. I have run both a Novell client
	   (with PDIPX, a Packet Driver IPX) and this SOSS server together
	   successfully."

	Q: What needs to be done so that Linux can run two ethernet cards?

	A: The easiest solution is to get 0.99pl13, which already includes
	   the changes described below.  You can enable additional ethercards
	   with LILO parameters such as
		lilo: linux ether=5,0x300,0,1,eth0 ether=15,0x280,eth1

	   For pre-pl13 you can enable additional ethercards by
	   adding another entry to Space.c, naming it "eth1" instead
	   of "eth0".  If you want routing to work well you should
	   use a recent kernel, say 0.99pl11 or later.  You may also
	   want to verify that your driver writer kept all of the
	   per-card variables in 'dev->priv'.  Most do, but the pl12
	   AT1500/LANCE driver has a single static low-memory buffer.

	Q: I have /dev/eth0 as a link to /dev/xxx. Is this right?

	A: Contrary to the Net-2 HowTo, the files in /dev/* are not used.
	   I originally thought that they might be an OK idea. I've since 
	   concluded that they won't work, at least in the documented form.

9 Miscellaneous.

	Any other associated stuff that didn't fit in anywhere else gets
	dumped here. It may not be relevant, and it may not be of general
	interest but it is here anyway.

9.01 The Cabletron story. (...as related by Donald J. Becker)

		I contacted Cabletron in early December 1992 for
	programming information (I had called and sent several
	earlier messages).  I was referred through several
	different people, and each one took several days to
	respond before they forwarded me to the next.  Eventually
	I was told I should deal with their (outside?) developer
	Mr. Dev.Null.  I persisted, and around March it seemed
	that I had finally succeed: Cabletron offered to send me
	an evaluation board (unrequested) and everything I needed
	to use it (what I wanted).  The hardware showed up right
	away, and I waited, expecting the the programming
	information information as well.  About a month later I
	contacted them, and they told me that "all I needed to use
	it" was the standard MS-DOS NDIS drivers, a binary on
	standard driver disk.  The disk envelope was covered in
	legalese, including no-disassembly, no-reverse-engineering
	clauses.  It was May (and a few email exchanges later)
	before I figured out that I had been "slow rolled", and
	had wasted about 20 hours on this particular windmill.

	The story isn't over yet.  People have written to me say
	they have vetoed several medium-sized purchases from
	Cabletron based on the lack of Linux drivers.  Cabletron
	must have noticed this because yesterday I got a call
	_from_ Cabletron (the first!) stating that they will be
	independently writing a Linux driver.  Of course, their
	lawyers probably haven't read the GPL yet...
	
9.02 The Xircom story. (...as related by Russ Nelson)

	From: "Russell Nelson" <nelson@crynwr.com>
	Subject:   Xircom support (horses mouth)
	Date: Mon, 30 Aug 1993 17:01:04 +0300

	Okay, here's the word on Xircom support.  I spoke to Dirk
	Gates, President of Xircom, about the packet driver
	situation.  Yes, the packet driver uses the Crynwr packet
	driver skeleton, and yes, it's in violation of the GPL.
	However, it was not Xircom's intention to violate the GPL.
	They paid Persoft to write a proprietary driver for them,
	and Persoft used the Clarkson skeleton, alleging that the
	code was in the public domain.  Xircom is unsuable because
	they were an innocent infringer.  I will shortly be sending
	them a demand letter.  If they continue to distribute the
	driver after they get the letter, they will be in
	infringement and I can *then* sue them.  Xircom has
	basically the same philosophy as Diamond.  The actual
	hardware interface is reverse-engineerable in the space of a
	day or so.  However, Xircom prefers to write all their own
	drivers, because badly-written drivers reflect badly on
	their product.  They also perceive a monetary interest in
	keeping their product proprietary.  Xircom would *probably*
	release the specs at this point if they were approached by
	an ad-hoc consortium of potential purchasers who required
	the specs as a condition of purchase.  However, I don't
	think this is the right thing to do.  At this point they
	have already gotten all the proprietary advantage they are
	going to.  Purchasing their product now will only reward
	their "bad attitude" toward open systems.  Much better to
	purchase from a vendor who appreciates and encourages open
	systems, such as D-Link.

9.03	Closing

	If you have found any glaring typos, or outdated info in this
	document, please let one of us know.

	Paul Gortmaker		<gpg109@rsphysse.anu.edu.au>
	Donald J. Becker	<becker@super.org>

		=========== end of Ethernet HOWTO ============




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Linux Ethernet HOWTO (Part 2/2)
@ 1994-03-16  5:27 Paul Gortmaker
  0 siblings, 0 replies; 6+ messages in thread
From: Paul Gortmaker @ 1994-03-16  5:27 UTC (permalink / raw)


Archive-Name: linux/howto/ethernet/part2
Last-Modified: 16 Mar 1994

[This is part 2/2 of the Ethernet-HOWTO.]

5 Technical information.

	For those who want to play with the present drivers, or try to make
	up their own driver for a card that is presently unsupported, this
	information should be useful. If you do not fall into this category,
	then perhaps you will want to skip this section.

5.01 Probed addresses

	While trying to determine what ethernet card is there, the following
	addresses are autoprobed, assuming the type and specs of the card
	have not been set in the kernel. As of 0.99pl12, doing a "make config"
	will ask what cards are to be supported. The file names below are
	in /usr/src/linux/drivers/net/
	----------------------------------------------------------------
	wd.c:		0x300, 0x280, 0x380, 0x240
	3c501.c		0x280
	3c503.c:	0x300, 0x310, 0x330, 0x350, 0x250, 0x280, 0x2a0, 0x2e0
	3c507.c:	0x300, 0x320, 0x340, 0x280
	3c509.c:	<Special "ID Port" probe>
	at1700.c:	0x300, 0x280, 0x380, 0x320, 0x340, 0x260, 0x2a0, 0x240
	atp.c:		0x378, 0x278, 0x3bc
	depca.c		0x300, 0x200
	d_link.c:	0x378
	ne.c:		0x300, 0x280, 0x320, 0x340, 0x360
	hp.c:		0x300, 0x320, 0x340, 0x280, 0x2C0, 0x200, 0x240
	lance.c:	0x300, 0x320, 0x340, 0x360
	smc-ultra.c:	0x200, 0x220, 0x240, 0x280, 0x300, 0x340, 0x380
	eexpress.c:	0x300, 0x270, 0x320, 0x340
	3c509.c:	<Special "ID Port" probe>
	----------------------------------------------------------------
	There are some NE2000 clone ethercards out there that are waiting black
	holes for autoprobe drivers. While many NE2000 clones are
	safe until they are enabled, some can't be reset to a safe mode.
	These dangerous ethercards will hang any I/O access to their
	"dataports". The typical dangerous locations are:

	Ethercard jumpered base     Dangerous locations (base + 0x10 - 0x1f)
		0x300 *				0x310-0x317
		0x320				0x330-0x337
		0x340				0x350-0x357
		0x360				0x370-0x377

	* The 0x300 location is the traditional place to put an ethercard, but
	it's also a popular place to put other devices (often SCSI
	controllers). The 0x320 location is often the next one chosen, but
	that's bad for for the AHA1542 driver probe. The 0x360 location is
	bad, because it conflicts with the parallel port at 0x378.

	To avoid these lurking ethercard, here are the things you can do:

	o Probe for the device's BIOS in memory space. This is easy
	  and always safe, but it only works for cards that always have
	  BIOSes, like primary SCSI controllers.

	o Avoid probing any of the above locations until you think
	  you've located your device. The NE2000 clones have a reset range
	  from <base>+0x18 to <base>+0x1f that will read as 0xff, so probe
	  there first if possible. It's also safe to probe in the 8390
	  space at <base>+0x00 - <base>+0x0f, but that area will return
	  quasi-random values

	o If you must probe in the dangerous range, for instance if your
	  target device has only a few port locations, first check that
	  there isn't an NE2000 there. You can see how to do this by
	  looking at the probe code in /usr/src/linux/net/inet/ne.c

	In other news, I've written the code for the I/O port registrar.
	Peter MacDonald and I have been intensely discussing this, and I think
	our current scheme has the necessary functionality with minimal kernel
	size impact. (The implementation involved rewriting the bitmap ops in
	kernel/ioport.c:ioperm() so that most code could be shared.)

	Here is the current "blurb". As usual comments are welcome. Please
	keep them substantial and constructive (we've already talked about
	changing the name from "reserve=" to "noprobe=").

	==================

	Boot-Time Parameters: "reserve="
	
	In some machines it may be necessary to prevent device drivers from
	checking for devices (auto-probing) in a specific region. This may be
	because of poorly designed hardware that causes the boot to "freeze"
	(such as some ethercards), hardware that is mistakenly identified,
	hardware whose state is changed by an earlier probe, or merely
	hardware you don't want the kernel to initialize.

	The "reserve" boot-time argument addresses this problem by specifying
	an I/O port region that shouldn't be probed. That region is reserved
	in the kernel's port registration table as if a device has already
	been found in that region. Note that this mechanism shouldn't be
	necessary on most machine, only when there is a problem or special
	case.

	The boot-line syntax is

	  lilo-prompt: linux-image reserve=[<port>,<size>,<port>,<size>...]

	As usual with boot-time specifiers there is an 11 parameter limit, thus
	you can only specify 5 reserved regions per "reserve" keyword.
	Multiple "reserve" specifiers will work if you have an usually
	complicated request.

	If you specify a "reserve" region to protect a specific device, you
	must generally specify an explicit probe for that device. Most
	drivers ignore the port registration table if they are given an
	explicit address.

5.02 Skeleton / prototype driver

	OK. So you have decided that you want to write a driver for the
	Foobar Ethernet card, as you have the programming information,
	and it hasn't been done yet. (...these are the two main require-
	ments ;-) You can use the skeleton network driver that is provided
	with the Linux kernel source tree. It can be found in the file
	/usr/src/linux/drivers/net/skeleton.c as of 0.99pl15, and later.

	It's also very useful to look at the Crynwr (nee Clarkson) driver
	for your target ethercard, if it's available. Russ Nelson
	<nelson@crynwr.com> has been actively updating and writing these,
	and he has been very helpful with his code reviews of the current
	Linux drivers.

5.03 Driver interface to the kernel

	Here are some notes that may help when trying to figure out what
	the code in the driver segments is doing, or perhaps what it is
	supposed to be doing.

	=====================================================

	int ethif_init(struct device *dev)
	{
	    ...
		dev->send_packet = &ei_send_packet;
		dev->open = &ei_open;
		dev->stop = &ei_close;
		dev->hard_start_xmit = &ei_start_xmit;
		...
	}

	int ethif_init(struct device *dev)

	This function is put into the device structure in Space.c. It is
	called only at boot time, and returns '0' iff the ethercard 'dev'
	exists.

	=====================================================

	static int ei_open(struct device *dev)
	static int ei_close(struct device *dev)

	This routine opens and initializes the board in response to an
	socket ioctl() usually called by 'config' or 'ifconfig'. It is
	commonly stuffed into the 'struct device' by ethif_init().

	The inverse routine is ei_close(), which should shut down the
	ethercard, free the IRQs and DMA channels if the hardware permits,
	and turn off anything that will save power (like the transceiver).

	(Note: As of NET-2, the relevant program is '/etc/ifconfig' - and
	the device *can* be turned off or on via passing 'up' or 'down'
	to 'ifconfig' from the command line with the device name.)

	=====================================================

	static int ei_start_xmit(struct sk_buff *skb, struct device *dev)
		dev->hard_start_xmit = &ei_start_xmit;

	This routine puts packets to be transmitted into the hardware. It
	is usually stuffed into the 'struct device' by ethif_init().

	When the hardware can't accept additional packets it should set
	the dev->tbusy flag. When additional room is available, usually
	during a transmit-complete interrupt, dev->tbusy should be cleared
	and the higher levels informed with mark_bh(INET_BH).
	[[Note: pre0.99.4 kernels didn't use this interface for all packets.]]
	
	=====================================================

	...
	    if (dev_rint(buffer, length, is_skb ? IN_SKBUFF : 0, dev))
		   stats->rx_dropped++;
	...
	A received packet is passed to the higher levels using dev_rint().
	If the unadorned packet data in a memory buffer, dev_rint will copy
	it into a 'skbuff' for you. Otherwise a new skbuff should be
	kmalloc()ed, filled, and passed to dev_rint() with the IN_SKBUFF flag.

	=====================================================

5.04 Interrupts and Linux

	There are two kinds of interrupt handlers in Linux:
	fast ones and slow ones. You decide what kind you are installing by
	the flags you pass to irqaction(). The fast ones, such as the serial
	interrupt handler, run with _all_ interrupts disabled. The normal
	interrupt handlers, such as the one for ethercard drivers, runs with
	other interrupts enabled.

	There is a two-level interrupt structure. The "fast" part handles the
	device register, removes the packets, and perhaps sets a flag.  After
	it is done, and interrupts are re-enabled, the slow part is run if the
	flag is set.

	The flag between the two parts is set by:
		mark_bh(INET_BH);

	Usually this flag is set within dev_rint() during a received-packet
	interrupt, and set directly by the device driver during a
	transmit-complete interrupt.

	You might wonder why all interrupt handlers cannot run in
	"normal mode" with other interrupts enabled. Ross Biro uses this
	scenario to illustrate the problem:
		o You get a serial interrupt, and start processing it.
		  The serial interrupt is now masked.
		o You get a network interrupt, and you start transferring
		  a maximum-sized 1500 byte packet from the card.
		o Another character comes in, but this time the interrupts
		  are masked!

	The "fast" interrupt structure solves this problem by allowing
	bounded-time interrupt handlers to run without the risk of leaving
	their interrupt lines masked by another interrupt request.

	There is an additional distinction between fast and slow interrupt
	handlers -- the arguments passed to the handler. A "slow" handler is
	defined as

		static void
		handle_interrupt(int reg_ptr)
		{
		    int irq = -(((struct pt_regs *)reg_ptr)->orig_eax+2);
		    struct device *dev = irq2dev_map[irq];
		...

	While a fast handler gets the interrupt number directly

		static void
		handle_fast_interrupt(int irq)
		{
		...

	A final aspect of network performance is latency. The only board
	that really addresses this is the 3c509, which allows a predictive
	interrupt to be posted. It provides an interrupt response timer so
	that the driver can fine-tune how early an interrupt is generated.

	Alan Cox has some advice for anyone wanting to write drivers
	that are to be used with pl14 kernels and newer. He says:

	"Any driver intended for pl14 should use the new alloc_skb() and
	kfree_skbmem() functions rather than using kmalloc() to obtain an
	sk_buff. The new pl14 skeleton does this correctly. For drivers
	wishing to remain compatible with both sets the define
	'HAVE_ALLOC_SKB' indicates these functions must be used.

	In essence replace

		skb=(struct sk_buff *)kmalloc(size)
	with

		skb=alloc_skb(size)

	and

		kfree_s(skb,size)

	with

		kfree_skbmem(skb,size)	/* Only sk_buff memory though */

	Any questions should I guess be directed to me since I made the change.
	This is a change to allow tracking of sk_buff's and sanity checks on
	buffers and stack behaviour. If a driver produces the message
	'File: ??? Line: ??? passed a non skb!' then it is probable the
	driver is not using the new sk_buff allocators."


5.05 Programmed I/O vs. shared mem. vs. slave/master DMA

	Ethernet is 10Mbs. (Don't be pedantic, 3Mbs and 100Mbs don't count.)
	If you can already send and receive back-to-back packets, you just
	can't put more bits over the wire. Every modern ethercard can receive
	back-to-back packets. The Linux DP8390 drivers come pretty close to
	sending back-to-back packets (depending on the current interrupt
	latency) and the 3c509 and AT1500 hardware has no problem at all
	automatically sending back-to-back packets.

	The ISA bus can do 5.3MB/sec (42Mb/sec), which sounds like more than
	enough. You can use that bandwidth in several ways:

	Programmed I/O
	==============
	  Pro: Doesn't use any constrained system resources,
	       just a few I/O registers, and has no 16M limit.
	  Con: Usually the slowest transfer rate, the CPU is waiting
	       the whole time, and interleaved packet access is usually
	       difficult to impossible.

	Shared memory
	=============
	  Pro: Simple, faster than programmed I/O, and allows random
	       access to packets.
	  Con: Uses up memory space (a big one for DOS users, only a minor
	       issue under Linux), and it still ties up the CPU.

	Slave (normal) DMA
	==================
	  Pro: Frees up the CPU during the actual data transfer.
	  Con: Checking boundary conditions, allocating contiguous buffers,
	       and programming the DMA registers makes it the slowest
	       of all techniques.  It also uses up a scarce DMA
	       channel, and requires aligned low memory buffers.

	Master (bus-master) DMA
	=======================
	  Pro: Frees up the CPU during the data transfer, can string together
	       buffers, can require little or no CPU time lost on the
	       ISA bus.
	  Con: Requires low-memory buffers and a DMA channel. Any
	       bus-master will have problems with other bus-masters that
	       are bus-hogs, such as some primitive SCSI adaptors. A few
	       badly-designed motherboard chipsets have problems with
	       bus-masters. And a reason for not using *any* type of
	       DMA device is using a Cyrix 486 processor designed for
	       plug-in replacement of a 386: these processors must
	       flush their cache with each DMA cycle.

5.06 Programming the Intel chips (i82586 and i82593)

	These chips are used on a number of cards, namely the 3c507 ('86),
	the Intel EtherExpress 16 ('86), Microdyne's exos205t ('86),
	the Z-Note ('93), and the Racal-Interlan ni5210 ('86).

	Russ Nelson writes:
	"Most boards based on the 82586 can reuse quite a bit of their code.
	More, in fact, than the 8390-based adapters. There are only three
	differences between them:

	  o The code to get the Ethernet address,
	  o The code to trigger CA on the 82586, and
	  o The code to reset the 82586.

	The Intel EtherExpress 16 is an exception, as it I/O maps the 82586.
	Yes, I/O maps it. Fairly clunky, but it works.

	Garrett Wollman did an AT&T driver for BSD that uses the BSD
	copyright. The latest version I have (Sep '92) only uses a single
	transmit buffer. You can and should do better than this if you've
	got the memory. The AT&T and 3c507 adapters do; the ni5210 doesn't.

	The people at Intel gave me a very big clue on how you queue up
	multiple transmit packets. You set up a list of
	NOP->XMIT->NOP->XMIT->NOP->XMIT->(beginning) blocks, then you set the
	"next" pointer of all the NOP blocks to themselves. Now you start
	the command unit on this chain. It continually processes the first
	NOP block. To transmit a packet, you stuff it into the next transmit
	block, then point the NOP to it. To transmit the next packet, you
	stuff the next transmit block and point the previous NOP to *it*. In
	this way, you don't have to wait for the previous transmit to finish,
	you can queue up multiple packets without any ambiguity as to whether
	it got accepted, and you can avoid the command unit start-up delay."

5.07	Technical information from 3Com

	From: Cameron Spitzer 764-6339 <camerons@nad.3com.com>
	Subject: getting 3Com Adapter manuals
	Date: Mon, 27 Sep 1993 21:17:07 +0200
	
	Since this is becoming a FAQ, I'm going to tread the thin
	ice of No Commercial Use and answer it here.

	3Com's Ethernet Adapters are documented for driver writers
	in our "Technical References" (TRs). These manuals describe
	the programmer interfaces to the boards but they don't talk
	about the diagnostics, installation programs, etc that end
	users can see.
	
	The Network Adapter Division marketing department has the
	TRs to give away. To keep this program efficient, we
	centralized it in a thing called "CardFacts." CardFacts is
	an automated phone system. You call it with a touch-tone
	phone and it faxes you stuff. To get a TR, call CardFacts
	at 408-727-7021. Ask it for Developer's Order Form,
	document number 9070. Have your fax number ready when you
	call. Fill out the order form and fax it to 408-764-5004.
	Manuals are shipped by Federal Express 2nd Day Service.
	
	If you don't have a fax and nobody you know has a fax,
	really and truly, *then* send mail to
	Terry_Murphy@3Mail.3Com.com and tell her about your problem.
	PLEASE use the fax thing if you possibly can.
	
	After you get a manual, if you still can't figure out how to
	program the board, try our "CardBoard" BBS at
	1-800-876-3266, and if you can't do that, write
	Andy_Chan@3Mail.3com.com and ask him for alternatives. If
	you have a real stumper that nobody has figured out yet, the
	fellow who needs to know about it is
	Steve_Lebus@3Mail.3com.com.
	
	There are people here who think we are too free with the
	manuals, and they are looking for evidence that the system
	is too expensive, or takes too much time and effort. That's
	why it's important to try to use CardFacts *before* you
	start calling and mailing the people I named here.
	
	There are even people who think we should be like Diamond
	and Xircom, requiring tight "partnership" with driver
	writers to prevent poorly performing drivers from getting
	written. So far, 3Com customers have been really good about
	this, and there's no problem with the level of requests
	we've been getting. We need your continued cooperation and
	restraint to keep it that way.
	
	Cameron Spitzer, 408-764-6339
	3Com NAD
	Santa Clara
	work: camerons@nad.3com.com
	home: cls@truffula.sj.ca.us

5.08 Notes on AMD PCnet-ISA / LANCE Based cards (79C960)

	The AMD LANCE (Local Area Network Controller for Ethernet)
	was the original offering, and has since been replaced by
	the "PCnet-ISA" chip, otherwise known as the 79C960.
	A relatively new chip from AMD, the 79C960, is the heart of many
	new cards being released at present. Note that the name "LANCE"
	has stuck, and some people will refer to the new chip by the old
	name. Dave Roberts of the Network Products Division of AMD was kind
	enough to contribute the following information regarding this chip:

	"As for the architecture itself, AMD developed it originally
	and reduced it to a single chip -- the PCnet(tm)-ISA -- over a year
	ago. It's been selling like hotcakes ever since.

	Functionally, it is equivalent to a NE1500. The register set
	is identical to the old LANCE with the 1500/2100 architecture
	additions. Older 1500/2100 drivers will work on the PCnet-ISA.
	The NE1500 and NE2100 architecture is basically the same.
	Initially Novell called it the 2100, but then tried to distinguish
	between coax and 10BASE-T cards. Anything that was 10BASE-T only was
	to be numbered in the 1500 range. That's the only difference.

	Many companies offer PCnet-ISA based products, including HP,
	Racal-Datacom, Allied Telesis, Boca Research, Kingston Technology, etc.
	The cards are basically the same except that some manufacturers
	have added "jumperless" features that allow the card to
	be configured in software. Most have not. AMD offers a standard
	design package for a card that uses the PCnet-ISA and many
	manufacturers use our design without change.
	What this means is that anybody who wants to write drivers for
	most PCnet-ISA based cards can just get the data-sheet from AMD. Call
	our literature distribution center at (800)222-9323 and ask for the
	Am79C960, PCnet-ISA data sheet. It's free.

	A quick way to understand whether the card is a "stock" card
	is to just look at it. If it's stock, it should just have one large
	chip on it, a crystal, a small IEEE address PROM, possibly a socket
	for a boot ROM, and a connector (1, 2, or 3, depending on the media
	options offered). Note that if it's a coax card, it will have some
	transceiver stuff built onto it as well, but that should be near the
	connector and away from the PCnet-ISA.

	The PCnet-ISA is faster than the original LANCE design and
	makes better use of the available bus bandwidth. Additionally, some
	LANCE bugs were corrected and many enhancements were made."

	There is also some info regarding the LANCE chip in the file
	lance.c which is included in the standard kernel.

5.09 Multicast and Promiscuous mode

	One of the things I've been working on recently is the
	major remaining item on the ethercard feature list:
	implementing multicast and promiscuous mode hooks.
	
	At first I was planning to do it while implementing either
	the /dev/* or DDI interface, but that's not really the
	correct way to do it. We should only enable multicast or
	promiscuous modes when something wants to look at the
	packets, and shut it down when that application is
	finished, neither of which is strongly related to when the
	hardware is opened or released.
	
	I'll start by discussing promiscuous mode, which is
	conceptually easy to implement. For most hardware you
	only have to set a register bit, and from then on you get
	every packet on the wire. Well, it's almost that easy;
	for some hardware you have to shut the board (potentially
	dropping a few packet), reconfigure it, and then re-enable
	the ethercard. This is grungy and risky, but the
	alternative seems to be to have every application register
	before you open the ethercard at boot-time.
	
	OK, so that's easy, so I'll move on something that's not
	quite so obvious: Multicast. It can be done two ways:
	
	1) Use promiscuous mode, and a packet filter like the
	   Berkeley packet filter (BPF). The BPF is a pattern matching
	   stack language, where you write a program that picks out the
	   addresses you are interested in. Its advantage is that it's
	   very general and programmable. Its disadvantage is that there
	   is no general way for the kernel to avoid turning on promiscuous
	   mode and running every packet on the wire through every registered
	   packet filter. See the next section for more information on BPF.
	
	2) Using the built-in multicast filter that most etherchips have.
	
	I guess I should list what a few ethercards/chips provide:
	
	Chip/card  Promiscuous	Multicast filter
	========================================
	Seeq8001/3c501	Yes	Binary filter (1)
	3Com/3c509	Yes	Binary filter (1)
	8390		Yes	Autodin II six bit hash (2) (3)
	LANCE		Yes	Autodin II six bit hash (2) (3)
	i82586		Yes	Hidden Autodin II six bit hash (2) (4)
	
	
	(1) These cards claim to have a filter, but it's a simple
	yes/no 'accept all multicast packets', or 'accept no
	multicast packets'.
	
	(2) AUTODIN II is the standard ethernet CRC (checksum)
	polynomial. In this scheme multicast addresses are hashed
	and looked up in a hash table. If the corresponding bit
	is enabled, this packet is accepted. Ethernet packets are
	laid out so that the hardware to do this is trivial -- you
	just latch six (usually) bits from the CRC circuit (needed
	anyway for error checking) after the first six octets (the
	destination address), and use them as an index into the
	hash table (six bits == a 64-bit table).
	
	(3) These chips use the six bit hash, and must have the
	table computed and loaded by the host. This means the
	kernel must include the CRC code.
	
	(4) The 82586 uses the six bit hash internally, but it
	computes the hash table itself from a list of multicast
	addresses to accept.

	Note that none of these chips do perfect filtering, and we
	still need a middle-level module to do the final
	filtering. Also note that in every case we must keep a
	complete list of accepted multicast addresses to recompute
	the hash table when it changes.
	
	My first pass at device-level support is detailed in the
	new outline driver skeleton.c (pl14 and up.)

	It looks like the following:
	
	#ifdef HAVE_MULTICAST
	static void set_multicast_list(struct device *dev, int num_addrs,
					 void *addrs);
	#endif
	.
	.
	
	ethercard_open() {
	...
#ifdef HAVE_MULTICAST
		dev->set_multicast_list = &set_multicast_list;
	#endif
	...
	
	#ifdef HAVE_MULTICAST
	/* Set or clear the multicast filter for this adaptor.
	   num_addrs == -1	Promiscuous mode, receive all packets
	   num_addrs == 0	Normal mode, clear multicast list
	   num_addrs > 0	Multicast mode, receive normal and
				MC packets, and do best-effort filtering.
	 */
	static void
	set_multicast_list(struct device *dev, int num_addrs, void *addrs)
	{
	...

	Any comments, criticism, etc. are welcome.

	Alan Cox adds that "...in pl14, user programs can access promiscuous
	mode but not multicast mode, even though the drivers support both.
	The ifconfig program allows you to mark an interface 'promisc'."
	
5.10 The Berkeley Packet Filter (BPF)

	I'm not bitterly opposed to it, but I'm coming to the
	conclusion that the 'bpf' functionality should not be provided
	by the kernel, but should be in a (hopefully little-used)
	compatibility library.
	
	For those not in the know: 'bpf' (the Berkeley Packet Filter)
	is an mechanism for specifying to the kernel networking layers
	what packets you are interested in. It's implemented as a
	specialized stack language interpreter built into a low level
	of the networking code. An application passes a program
	written in this language to the kernel, and the kernel runs the
	program on each incoming packet. If the kernel has multiple
	'bpf' applications, each program is run on each packet.
	
	The problem is that it's difficult to deduce what kind of
	packets the application is really interested in from the packet
	filter program, so the general solution is to always run the
	filter. Imagine a program that registers a 'bpf' program to
	pick up a low data-rate stream sent to a multicast address.
	Most ethernet cards have a hardware multicast address filter
	implemented as a 64 entry hash table that ignores most unwanted
	multicast packets, so the capability exists to make this a very
	inexpensive operation. But with the BFP the kernel must switch
	the interface to promiscuous mode, receive _all_ packets, and
	run them through this filter. This is work, BTW, that's very
	difficult to account back to the process requesting the packets.

5.11 Unresolved questions / concerns

	There may be some benefit from processing packet data as it is
	transferred to and from the ethercard, especially with very fast
	processors transferring data to a slow ethercard. As I see it this
	question has multiple parts:
		1) Is there any useful processing power available, perhaps
		   during the ISA bus recovery period, or while the 8390
		   remote DMA is preparing for another transfer??
		2) Is there any useful but simple work that can be done
		   between/during each word of the copy, such as calculating
		   a CRC, or discarding obviously unwanted packets??
		3) would the complexity of an interface to do this make future
		   ethercard drivers impossible??

	There should be a better structure than Space.c - Drivers should be
	able to autoprobe for all installed ethercards rather than just
	quitting after finding the first.  I've written code to do this,
	but the constant promise (threat?) of DDI has prevented me from
	making it standard.

	A related topic is the problem of driver probes corrupting
	unrelated hardware. Even worse is a probe into a dataport that
	isn't set up to transfer data, which will freeze the machine. The
	common suggestion is a boot-time device registry that records
	already-used I/O ports and shared memory. This has been implemented
	as of pl13, see section 5.01.

6 Possible problems, and troubleshooting.

	This section tries to answer any unresolved questions, and not so
	common solutions to common problems. They are sorted on a "per
	manufacturer basis". You should have also read the relevant info.
	from section 1 about your specific card. Section 8 contains more
	general FAQ's.

6.01 Problems with NE2000 (and clones)

	"DMA address mismatch"
	======================

	Is the chip a real NatSemi 8390? (DP8390, DP83901, DP83902 or DP83905)?
	If not, some clone chips don't correctly implement the transfer
	verification register. MS-DOS drivers never do error checking,
	so it doesn't matter to them.

	Are most of the messages off by a factor of 2?
	If so:	Are you using the NE2000 in a 16 bit slot?
		Is it jumpered to use only 8 bit transfers?

	The Linux driver expects a NE2000 to be a 16 bit slot. A NE1000 can
	be in either size slot. This problem can also occur with some clones,
	notably D-Link 16 bit cards, that don't have the correct ID bytes
	in the station address PROM. [[ This should be fixed in pl12.]]

	Are you running the bus faster than 8Mhz?
	If you can change the speed (faster or slower), see if that
	makes a difference. Most NE2000 clones will run at 16Mhz, but
	some may not. Changing speed can also mask a noisy bus.

	What other devices are on the bus?
	If moving the devices around changes the reliability, then you
	have a bus noise problem -- just what that error message was
	designed to detect. Congratulations, you've probably found the
	source of other problems as well.

	Machine Hangs during Boot.
	==========================

	Problem:  The machine hangs during boot right after the "8390..."  or
		  "WD...." message. Removing the NE2000 fixes the problem.

	Solution: Change your NE2000 base address to 0x360 (or 0x340 for
		  pl12 or later kernels.) Alternatively, you can use the new
		  device registrar implemented in pl13 (see section 5.1)

	Reason:   Your NE2000 clone isn't a good enough clone. An active
		  NE2000 is a bottomless pit that will trap any driver
		  autoprobing in its space. The other ethercard drivers take
		  great pain to reset the NE2000 so that it's safe, but some
		  clones cannot be reset. Clone chips to watch out for:
		  Winbond 83C901. Changing the NE2000 to a less-popular
		  address will move it out of the way of other autoprobes,
		  allowing your machine to boot.

	Problem:  The machine hangs during the SCSI probe at boot.

	Solution: It's the same problem as above, change the
		  ethercard's address, or use the device registrar.

	Problem:  The machine hangs during the soundcard probe at boot.

	Solution: No, that's really during the silent SCSI probe, and it's
		  the same problem as above.

	"eth0: DMAing conflict in ne_block_input"
	=========================================

	This bug came from timer-based packet retransmissions. If you got a
	timer tick _during_ a ethercard RX interrupt, and timer tick tried to
	retransmit a timed-out packet, you could get a conflict. Because of
	the design of the NE2000 you would have the machine hang (exactly the
	same the NE2000-clone boot hangs).

	Early versions of the driver disabled interrupts for a long time,
	and didn't have this problem. Later versions are fixed. (ie. kernels
	after 0.99p9 should be OK.)

	NE2000 not detected at boot.
	============================

	A few people have reported a problem with detecting the Accton NE2000.
	This problem occurs only at boot-time, and the card is later detected
	at run-time by the identical code my (alpha-test) ne2k diagnostic
	program. Accton has been very responsive, but I still haven't tracked
	down what is going on. I've been unable to reproduce this problem
	with the Accton cards we purchased. If you are having this problem,
	please send me an immediate bug report. For that matter, if you have
	an Accton card send me a success report, including the type of the
	motherboard. I'm especially interested in finding out if this problem
	moves with the particular ethercard, or stays with the motherboard.
	
	Here are some things to try, as they have fixed it for some people:
	1) Change the bus speed, or just move the card to a different slot (!).
	2) Change the "I/O recovery time" parameter in the BIOS
	   chipset configuration.
	3) Make the following code change suggested by David Cutler,
	   <dave@dmitri.ucdavis.edu> to ne.c around line 150:

	    for(i = 0; i < 32 /*sizeof(SA_prom)*/; i+=2) {
	-        SA_prom[i] = inb_p(ioaddr + NE_DATAPORT);
	-        SA_prom[i+1] = inb_p(ioaddr + NE_DATAPORT);
	+        SA_prom[i] = inb(ioaddr + NE_DATAPORT);
	+        SA_prom[i+1] = inb(ioaddr + NE_DATAPORT);
	        if (SA_prom[i] != SA_prom[i+1])
	            wordlength = 1;
	    }

	Yes, this removes the delay between board accesses, something that
	would normally increase the likelihood of data corruption rather
	than decreasing it. Note that this change is already incorporated
	into pl15. If you have an older kernel, you may have to do it
	yourself.

6.02 Problems with WD80*3 cards

	Detected Non-existent Ethercard
	===============================

	Problem:  A WD80*3 is falsely detected. Removing the sound or
		  MIDI card eliminates the "detected" message.

	Solution: Update your ethercard driver: new versions include an
		  additional sanity check.

	Reason:   Some MIDI ports happen to produce the same checksum as a
		  WD ethercard.

	Error messages from the 80*3
	============================

	Problem:  You get messages such as the following with your 80*3:
			eth0: bogus packet size, status = ........
			kmalloc called with impossibly large argument (65400)
			eth0: Couldn't allocate sk_buff of size 65400
			eth0: receiver overrun

	Reason:   There is a shared memory problem.

	Solution: If the problem is sporadic, you have hardware problems.
		  Typical problems that are easy to fix are board conflicts,
		  having cache or "shadow ROM" enabled for that region, or
		  running your bus faster than 8Mhz. There are also a
		  surprising number of memory failures on ethernet cards,
		  so run a diagnostic program if you have one for your
		  ethercard.

		  If the problem is continual, and you have have to reboot
		  to fix the problem, record the boot-time probe message
		  and mail it to becker@super.org - Take particular note of
		  the shared memory location.

	Will not detect my 80x3
	=======================

	Reason:   The Mitsumi CD-ROM (mcd) driver probe at 0x300 will
		  succeed if just about *anything* is that I/O location.
		  This is bad news and needs to be a bit more robust. (pl15)
		  Once another driver registers that it "owns" an I/O
		  location, other drivers (incl. the wd80x3) are "locked
		  out" and can not probe that addr for a card.

	Solution: Recompile a new kernel without any excess drivers that
		  you aren't using, including the above mcd driver.
		  Or try moving your ethercard to a new I/O addr. Valid
		  I/O addr. for all the cards are listed in section 5.1
		  You can also point the mcd driver off in another direction
		  by a boot-time parameter (via LILO) such as:
			"mcd=0x200,12"

6.03 Problems with 3Com cards

	Choosing the Interrupt of the 3c503
	===================================

	Problem:  The 3c503 picks IRQ n at boot, but this is needed for some
		  other device which needs IRQ n. (eg. CD ROM driver, etc.)
		  Can this be fixed without compiling this into the kernel?

	Solution: The 3c503 driver probes for a free IRQ line in the order
		  {5, 9/2, 3, 4}, and it should pick a line which isn't being
		  used. The pre-pl12 (SLS 1.02) driver picked the IRQ line
		  at boot-time, and the current driver (pl12) chooses when
		  the card is open()/'ifconfig'ed. Note the "bug" noted in
		  the 3c503 section in 1.01

		  Alternately, you can fix the IRQ at boot by passing
		  parameters via LILO. The following selects IRQ9, base
		  location 0x300, <ignored value>, and if_port #1 (the
		  external transceiver).
			lilo: linux ether=9,0x300,0,1,eth0

		  The following selects IRQ3, probes for the base location,
		  <ignored value>, and the default if_port #0 (the internal
		  transceiver)
			lilo: linux ether=3,0,0,0,eth0

	"3c503: Configured interrupt number XX is out of range."
	========================================================

	Problem:  Whoever built your kernel fixed the ethercard IRQ at XX.

	Reason:   The above is truly evil, and worse than that, it is
		  not necessary. The 3c503 will autoIRQ when it gets
		  "ifconfig"ed, and pick one of IRQ{5, 2/9, 3, 4}.

	Solution: Use lilo to set the IRQ, or rebuild the kernel, enabling
		  autoIRQ by not specifying the IRQ line.

	Choosing the output of the 3c503
	================================

	Problem:  The supplied 3c503 drivers don't use the AUI (thicknet) port.
		  How does one choose it over the default thinnet port?

	Solution: The 3c503 AUI port can be selected at boot-time with 0.99pl12
		  and later. The selection is overloaded onto the low bit of
		  the currently-unused dev->rmem_start variable, so a boot-time
		  parameter of:
			lilo: linux ether=0,0,0,1,eth0
		  should work. A boot line to force IRQ 5, port base 0x300,
		  and use an external transceiver is:
			lilo: linux ether=5,0x300,0,1,eth0

7 Networking with a laptop computer

	There are currently only a few ways to put your laptop on a network.
	You can use the SLIP code (and run at serial line speeds);
	you can buy one of the few laptops that come with a NE2000-compatible
	ethercard or PCMCIA slot built-in; you can get a laptop with a
	docking station and plug in an ISA ethercard; or you can use a
	parallel port Ethernet adapter such as the D-Link DE-600.

7.01 Option 1 -- using SLIP

	This is the cheapest solution, but by far the most difficult. Also,
	you will not get very high transmission rates. Since SLIP is not
	really related to ethernet cards, it will not be discussed further
	here. See the NET-2 HOWTO.

7.02 Option 2 -- Built in NE2000 compatible or PCMCIA Ethercard.

	The second solution severely limits your laptop choices and is fairly
	expensive. Be sure to read the specifications carefully, you may find
	that you will have to buy an additional non-standard transceiver to
	actually put the machine on a network.

	As this area of Linux development is fairly young, I'd suggest
	that you join the LAPTOPS mailing channel. See section 0.02
	which describes how to join a mailing list channel. Try and
	determine exactly what hardware you have (ie. card manufacturer,
	PCMCIA chip controller manufacturer) and then ask on the LAPTOPS
	channel. Regardless, don't expect things to be all that simple.
	Expect to have to fiddle around a bit, and patch kernels, etc.
	Maybe someday you will be able to type "make config" 8-)

	There is a number of programs on tsx-11.mit.edu in
	/pub/linux/packages/laptops/ that you may find useful. These
	range from PCMCIA Ethercard drivers to programs that communicate
	with the PCMCIA controller chip. Note that these drivers are
	usually tied to a specific PCMCIA chip (ie. the intel 82365
	or the TCIC/2) On a brighter note, I know that people have used the
	Linksys/D-Link 650 PCMCIA Ethernet PC Card with both controller
	chipsets, so it *can* be done. I have also seen reports of
	people using the IBM Credit Card Adapter for Ethernet with the
	intel 82365 chip. This is all just from following the LAPTOPS
	channel.

	The 3c589 from 3Com is supposed to look a lot like a 3c509.

	Anyway, the PCMCIA driver problem isn't specific to the Linux world.
	It's been a real disaster in the MS-DOS world. In that world
	people expect the hardware to work if they just follow the manual.
	They might not expect it to interoperate with any other hardware
	or software, or operate optimally, but they do expect that the
	software shipped with the product will function. Many PCMCIA
	adaptors don't pass this test.

7.03 Option 3 -- ISA Ethercard in the Docking Station.

	I recommend the third solution. Docking stations for laptops typically
	cost about $250 and provide two full-size ISA slots, two serial and one
	parallel port. Most (all?) docking stations are powered off of the
	laptop's batteries, and a few allow adding extra batteries in the
	docking station if you use short ISA cards. You can add an inexpensive
	ethercard and enjoy full-speed ethernet performance.

7.04 Option 4 -- Pocket / parallel port adaptors.

	The "pocket" ethernet adaptors may also fit your need.
	Until recently they actually costed more than a docking station and
	cheap ethercard, and most tie you down with a wall-brick power supply.
	At present, you can choose from the D-Link, or the RealTek adaptor.
	Most other companies, especially Xircom, treat the programming
	information as a trade secret, so support will likely be slow in
	coming.

	You can sometimes avoid the wall-brick with the adaptors by buying
	or making a cable that draws power from the laptop's keyboard
	port. (This is mentioned in the info. for the AT-Lan-Tec unit.)

	The keyboard pinouts (5 pin DIN) are as follows:

		Signal/Function			Pin #
		---------------			-----
		KEYCLK (clock)			1
		KEYDAT (data)			2
		N/C				3
		Ground				4
		+5 V				5

	A quick check with a voltmeter will verify which pins are 4 and 5
	if you are not sure.
8 Frequently asked questions

	Here are some of the more frequently asked questions about using
	Linux with an Ethernet connection. Some of the more specific
	questions are sorted on a "per manufacturer basis" and are listed
	in the "Troubleshooting" section. (section 6). However, since this
	document is basically "old" by the time you get it, any "new" problems
	will not appear here instantly. For these, I suggest that you make
	efficient use of your newsreader. For example, nn users would type
		nn -xX -s'3c'
	to get all the news articles in your subscribed list that have
	"3c" in the subject. (ie. 3com, 3c509, 3c503, etc.)
	The moral: Read the man page for your newsreader.
	
8.01 Just the FAQ's ma'am -- just the FAQ's.

	Q: I heard that there is an alpha driver available for my card.
	   Where can I get it?

	A: Assuming that it is a djb driver, it will be on ftp.super.org
	   in the /pub/linux/ area. Things change here quite frequently,
	   so just look around for it. There is usually only about 3
	   subdirs, so you should be able to find it. Now, if it really
	   is an alpha, or pre-alpha driver, then please treat it as
	   such. In other words, don't complain because you can't figure
	   out what to do with it. If you can't figure out how to install
	   it, then you probably shouldn't be testing it. Also, if it brings
	   your machine down, don't complain. Instead, send us a well
	   documented bug report, or even better, a patch!

	Q: Is there token ring support for Linux?

	A: No, there is no token ring support in Linux. To support token ring
	   requires more than only a writing a device driver, it also requires
	   writing the source routing routines for token ring. Given that
	   token ring is expensive, not fast, and will probably be swept away
	   by 100baseVG in a few months, it doesn't seem worth it to write
	   a driver. In case anyone wants to, I looked at writing a token ring
	   device driver, and concluded that the hardware interface
	   wasn't too difficult to do, but writing the support for source
	   routing would take significantly longer than I was willing to spend
	   on an expensive and dying technology.

	   Alan Cox adds: "It will require [...] changes to the bottom socket
	   layer to support 802.2 and 802.2 based TCP/IP. Don't expect
	   anything soon."

	Q: Is there FDDI support for Linux?

	A: No, there is no Linux driver for any FDDI boards. I come from a
	   place with supercomputers, so an external observer might think
	   FDDI would be high on my list. But FDDI never delivered end-to-end
	   throughput that would justify its cost, and it seems to be a nearly
	   abandoned technology now that 100base{X,Anynet} seems imminent.
	   (And yes, I know you can now get FDDI boards for <$1K. That
	   seems to be a last-ditch effort to get some return on the
	   development investment. Where is the next generation of FDDI
	   going to come from?)

	Q: Can I link 10BaseT (RJ45) based systems together without a hub?

	A: You can link 2 machines easily, but no more than that, without
	   extra devices/gizmos. See section 4 on wiring -- it explains
	   how to do it. And no, you can't hack together a hub just by
	   crossing a few wires and stuff. It's pretty much impossible 
	   to do the collision signal right without duplicating a hub.

	Q: Is there IPX or Novell support available for Linux?

	A: Alan Cox writes: "The novell protocols are available from novell
	   for various amounts. IPX is freely documented. SPX is about $1000
	   but I'm told Xerox SPP is identical. _PLEASE_ has anyone got any
	   freely distributable Xerox SPP code/documentation? The novell
	   server spec costs you $15000 + royalties providing you only
	   want to write a client, or $30000 + royalties otherwise. Needless
	   to say the final output has to be binary only and subject to a
	   novell license. Reading their license rules by my interpretation
	   its also impossible for us to do because you would seem to have
	   to bar disassembly of your final result, which is not allowed
	   in the EEC.

	   Bits of NCP are known, and I hope eventually enough will be known
	   to write limited NCP support into Linux, for the moment I'm poking
	   around at IPX, tho this will have to wait until the new network
	   code is finished.

	   An Alpha test IPX protocol layer is available from me (Alan)
	   for pl14 or higher. People are also exploring the issue of NCP and
	   the new Dr Dobbs journal article on the innards of netware has
	   provided a core of good information."

	   As an alternative, Miquel van Smoorenburg suggests the following:
	   "It _is_ possible to set up a dedicated PC running both novell and
	   the PD SOSS server and let it gateway from NFS to novell. This way
	   it is possible to mount the Novell drives on the Unix client.

	   SOSS is a PD (perhaps with some restrictions, but freely available)
	   NFS server for DOS. It includes the PC/IP TCP/IP implementation
	   and runs on a packet driver. I have run both a Novell client
	   (with PDIPX, a Packet Driver IPX) and this SOSS server together
	   successfully."

	   You can get "Stan's Own Server System" from the following location:
		hilbert.wharton.upenn.edu:pub/tcpip/soss.zip
	   Note that this version has the IP bugs fixed and the subdirs
	   with extensions bug fixed. Some of the soss.zoo archives do
	   not contain these fixes.

	Q: What needs to be done so that Linux can run two ethernet cards?

	A: The easiest solution is to get 0.99pl13 or newer, as the hooks for
	   multiple ethercards are all there.
	   You can enable additional ethercards with LILO parameters such as:

		lilo: linux ether=5,0x300,0,1,eth0 ether=15,0x280,eth1

	   These boot time arguments can be made permanent so that you
	   don't have to re-enter them every time. See the LILO manual.

	Q: Okay, I can run 2 cards -- can I run Linux as a gateway 
	   between two networks?

	A: This is really a question for the NET-HOWTO, but it is 
	   answered here anyways: Charles Hedrick (aka Mr. Slip)
	   had this to say:

	   "Yes, however I'm a bit nervous about doing it. The problem isn't
	   functionality -- there's IP forwarding code, and as far as I know,
	   it works. Some people do use it. However routers need to be
	   particularly careful to avoid creating network problems such as
	   "meltdowns." The Linux IP layer doesn't have quite enough of these
	   protective features. It will only cause trouble if other hosts on
	   your network are misconfigured, and even then it probably won't
	   cause much trouble (assuming that only systems actually acting as
	   gateways are built with IP_FORWARD enabled). But I'd still rather
	   use a router that met all of the requirements of the host and
	   router requirements in the RFC's. (Note that not all other Unix
	   implementations do either. I'm concerned about things like not
	   sending ICMP responses to messages that arrive as media 
	   broadcasts. 386BSD looks OK, but older BSD-based implementations
	   often didn't do all of these checks.)

	   It depends a lot on what the network is like and how critical it is.
	   For a home setup with a couple of hosts, I see no problem at all.
	   But I would not consider using Linux as a router on a large
	   campus network at the moment. I still think that by release 1.0,
	   Linux will be a reasonably well-behaved host. But I think use
	   as a router in critical situations should wait until somebody
	   has checked the ip and icmp modules for compliance with RFC 1009
	   and a few other specs."

	Q: I have /dev/eth0 as a link to /dev/xxx. Is this right?

	A: Contrary to what you have heard, the files in /dev/* are not used.
	   I originally thought that they might be an OK idea. I've since
	   concluded that they won't work, at least in the documented form.

	Q: Should I disable trailers when I "ifconfig" my ethercard?

	A: You can't disable trailers, and you shouldn't want to.
	   'Trailers' are a hack to avoid data copying in the
	   networking layers. The idea was to use a trivial 
	   fixed-size header of size 'H', put the variable-size header 
	   info at the end of the packet, and allocate all packets
	   'H' bytes before the start of a page. While it was a good
	   idea, it turned out to not work well in practice.
	   If someone suggests the use of '-trailers', note that it
	   is the equivalent of sacrificial goats blood. It won't do
	   anything to solve the problem, but if problem fixes itself then
	   someone can claim deep magical knowledge.

9 Miscellaneous.

	Any other associated stuff that didn't fit in anywhere else gets
	dumped here. It may not be relevant, and it may not be of general
	interest but it is here anyway.

9.01 Bad Vendors

	#define SOAPBOX

	There used to be some horror stories here about dealings with
	Cabletron and Xircom. They were pretty ugly and gruesome.
	Basically these companies are the ethernet equivalent of
	what Diamond is to XFree86. They do not want to release
	vital information on low-level programming of their hardware.
	For something like Linux, where the source code for everything
	is out in the open, this makes their hardware difficult or
	impossible to use. However, like Diamond, when confronted
	with the fact that they are losing sales from Linux/BSD users,
	they basically shrug it off, saying that it is only a small
	percentage of the total sales. If you can afford the time,
	drop these vendors a note (via e-mail or snail-mail) and tell
	them politely that the fact that they don't support open
	software systems such as Linux has forced you to exclude them
	from the vendors that you are purchasing hardware from. It may
	not make any immediate difference, but it might make you feel
	better. Besides, a few seconds of your time is a cheap price
	to pay for *all* that free Linux software you are using. 8-)

	#undef SOAPBOX

9.02 Closing

	If you have found any glaring typos, or outdated info in this
	document, please let one of us know. It's getting big, and it
	is easy to overlook stuff.

	Paul Gortmaker		<gpg109@rsphy1.anu.edu.au>
	Donald J. Becker	<becker@super.org>

		=========== end of Ethernet HOWTO ============



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Linux Ethernet HOWTO (part 2/2)
  1994-04-25 19:39 Linux Ethernet HOWTO (part 1/2) Paul Gortmaker
@ 1994-04-25 19:40 ` Paul Gortmaker
  0 siblings, 0 replies; 6+ messages in thread
From: Paul Gortmaker @ 1994-04-25 19:40 UTC (permalink / raw)


Archive-Name: linux/howto/ethernet/part2
Last-modified: 15 Apr 94


---This is part 2/2---

5.06 Programming the Intel chips (i82586 and i82593)

	These chips are used on a number of cards, namely the 3c507 ('86),
	the Intel EtherExpress 16 ('86), Microdyne's exos205t ('86),
	the Z-Note ('93), and the Racal-Interlan ni5210 ('86).

	Russ Nelson writes:
	"Most boards based on the 82586 can reuse quite a bit of their code.
	More, in fact, than the 8390-based adapters. There are only three
	differences between them:

	  o The code to get the Ethernet address,
	  o The code to trigger CA on the 82586, and
	  o The code to reset the 82586.

	The Intel EtherExpress 16 is an exception, as it I/O maps the 82586.
	Yes, I/O maps it. Fairly clunky, but it works.

	Garrett Wollman did an AT&T driver for BSD that uses the BSD
	copyright. The latest version I have (Sep '92) only uses a single
	transmit buffer. You can and should do better than this if you've
	got the memory. The AT&T and 3c507 adapters do; the ni5210 doesn't.

	The people at Intel gave me a very big clue on how you queue up
	multiple transmit packets. You set up a list of
	NOP->XMIT->NOP->XMIT->NOP->XMIT->(beginning) blocks, then you set the
	"next" pointer of all the NOP blocks to themselves. Now you start
	the command unit on this chain. It continually processes the first
	NOP block. To transmit a packet, you stuff it into the next transmit
	block, then point the NOP to it. To transmit the next packet, you
	stuff the next transmit block and point the previous NOP to *it*. In
	this way, you don't have to wait for the previous transmit to finish,
	you can queue up multiple packets without any ambiguity as to whether
	it got accepted, and you can avoid the command unit start-up delay."

5.07	Technical information from 3Com

	From: Cameron Spitzer 764-6339 <camerons@nad.3com.com>
	Subject: getting 3Com Adapter manuals
	Date: Mon, 27 Sep 1993 21:17:07 +0200
	
	Since this is becoming a FAQ, I'm going to tread the thin
	ice of No Commercial Use and answer it here.

	3Com's Ethernet Adapters are documented for driver writers
	in our "Technical References" (TRs). These manuals describe
	the programmer interfaces to the boards but they don't talk
	about the diagnostics, installation programs, etc that end
	users can see.
	
	The Network Adapter Division marketing department has the
	TRs to give away. To keep this program efficient, we
	centralized it in a thing called "CardFacts." CardFacts is
	an automated phone system. You call it with a touch-tone
	phone and it faxes you stuff. To get a TR, call CardFacts
	at 408-727-7021. Ask it for Developer's Order Form,
	document number 9070. Have your fax number ready when you
	call. Fill out the order form and fax it to 408-764-5004.
	Manuals are shipped by Federal Express 2nd Day Service.
	
	If you don't have a fax and nobody you know has a fax,
	really and truly, *then* send mail to
	Terry_Murphy@3Mail.3Com.com and tell her about your problem.
	PLEASE use the fax thing if you possibly can.
	
	After you get a manual, if you still can't figure out how to
	program the board, try our "CardBoard" BBS at
	1-800-876-3266, and if you can't do that, write
	Andy_Chan@3Mail.3com.com and ask him for alternatives. If
	you have a real stumper that nobody has figured out yet, the
	fellow who needs to know about it is
	Steve_Lebus@3Mail.3com.com.
	
	There are people here who think we are too free with the
	manuals, and they are looking for evidence that the system
	is too expensive, or takes too much time and effort. That's
	why it's important to try to use CardFacts *before* you
	start calling and mailing the people I named here.
	
	There are even people who think we should be like Diamond
	and Xircom, requiring tight "partnership" with driver
	writers to prevent poorly performing drivers from getting
	written. So far, 3Com customers have been really good about
	this, and there's no problem with the level of requests
	we've been getting. We need your continued cooperation and
	restraint to keep it that way.
	
	Cameron Spitzer, 408-764-6339
	3Com NAD
	Santa Clara
	work: camerons@nad.3com.com
	home: cls@truffula.sj.ca.us

5.08 Notes on AMD PCnet-ISA / LANCE Based cards (79C960)

	The AMD LANCE (Local Area Network Controller for Ethernet)
	was the original offering, and has since been replaced by
	the "PCnet-ISA" chip, otherwise known as the 79C960.
	A relatively new chip from AMD, the 79C960, is the heart of many
	new cards being released at present. Note that the name "LANCE"
	has stuck, and some people will refer to the new chip by the old
	name. Dave Roberts of the Network Products Division of AMD was kind
	enough to contribute the following information regarding this chip:

	"As for the architecture itself, AMD developed it originally
	and reduced it to a single chip -- the PCnet(tm)-ISA -- over a year
	ago. It's been selling like hotcakes ever since.

	Functionally, it is equivalent to a NE1500. The register set
	is identical to the old LANCE with the 1500/2100 architecture
	additions. Older 1500/2100 drivers will work on the PCnet-ISA.
	The NE1500 and NE2100 architecture is basically the same.
	Initially Novell called it the 2100, but then tried to distinguish
	between coax and 10BASE-T cards. Anything that was 10BASE-T only was
	to be numbered in the 1500 range. That's the only difference.

	Many companies offer PCnet-ISA based products, including HP,
	Racal-Datacom, Allied Telesis, Boca Research, Kingston Technology, etc.
	The cards are basically the same except that some manufacturers
	have added "jumperless" features that allow the card to
	be configured in software. Most have not. AMD offers a standard
	design package for a card that uses the PCnet-ISA and many
	manufacturers use our design without change.
	What this means is that anybody who wants to write drivers for
	most PCnet-ISA based cards can just get the data-sheet from AMD. Call
	our literature distribution center at (800)222-9323 and ask for the
	Am79C960, PCnet-ISA data sheet. It's free.

	A quick way to understand whether the card is a "stock" card
	is to just look at it. If it's stock, it should just have one large
	chip on it, a crystal, a small IEEE address PROM, possibly a socket
	for a boot ROM, and a connector (1, 2, or 3, depending on the media
	options offered). Note that if it's a coax card, it will have some
	transceiver stuff built onto it as well, but that should be near the
	connector and away from the PCnet-ISA.

	The PCnet-ISA is faster than the original LANCE design and
	makes better use of the available bus bandwidth. Additionally, some
	LANCE bugs were corrected and many enhancements were made."

	There is also some info regarding the LANCE chip in the file
	lance.c which is included in the standard kernel.

5.09 Multicast and Promiscuous mode

	One of the things I've been working on recently is the
	major remaining item on the ethercard feature list:
	implementing multicast and promiscuous mode hooks.
	
	At first I was planning to do it while implementing either
	the /dev/* or DDI interface, but that's not really the
	correct way to do it. We should only enable multicast or
	promiscuous modes when something wants to look at the
	packets, and shut it down when that application is
	finished, neither of which is strongly related to when the
	hardware is opened or released.
	
	I'll start by discussing promiscuous mode, which is
	conceptually easy to implement. For most hardware you
	only have to set a register bit, and from then on you get
	every packet on the wire. Well, it's almost that easy;
	for some hardware you have to shut the board (potentially
	dropping a few packet), reconfigure it, and then re-enable
	the ethercard. This is grungy and risky, but the
	alternative seems to be to have every application register
	before you open the ethercard at boot-time.
	
	OK, so that's easy, so I'll move on something that's not
	quite so obvious: Multicast. It can be done two ways:
	
	1) Use promiscuous mode, and a packet filter like the
	   Berkeley packet filter (BPF). The BPF is a pattern matching
	   stack language, where you write a program that picks out the
	   addresses you are interested in. Its advantage is that it's
	   very general and programmable. Its disadvantage is that there
	   is no general way for the kernel to avoid turning on promiscuous
	   mode and running every packet on the wire through every registered
	   packet filter. See the next section for more information on BPF.
	
	2) Using the built-in multicast filter that most etherchips have.
	
	I guess I should list what a few ethercards/chips provide:
	
	Chip/card  Promiscuous	Multicast filter
	========================================
	Seeq8001/3c501	Yes	Binary filter (1)
	3Com/3c509	Yes	Binary filter (1)
	8390		Yes	Autodin II six bit hash (2) (3)
	LANCE		Yes	Autodin II six bit hash (2) (3)
	i82586		Yes	Hidden Autodin II six bit hash (2) (4)
	
	
	(1) These cards claim to have a filter, but it's a simple
	yes/no 'accept all multicast packets', or 'accept no
	multicast packets'.
	
	(2) AUTODIN II is the standard ethernet CRC (checksum)
	polynomial. In this scheme multicast addresses are hashed
	and looked up in a hash table. If the corresponding bit
	is enabled, this packet is accepted. Ethernet packets are
	laid out so that the hardware to do this is trivial -- you
	just latch six (usually) bits from the CRC circuit (needed
	anyway for error checking) after the first six octets (the
	destination address), and use them as an index into the
	hash table (six bits == a 64-bit table).
	
	(3) These chips use the six bit hash, and must have the
	table computed and loaded by the host. This means the
	kernel must include the CRC code.
	
	(4) The 82586 uses the six bit hash internally, but it
	computes the hash table itself from a list of multicast
	addresses to accept.

	Note that none of these chips do perfect filtering, and we
	still need a middle-level module to do the final
	filtering. Also note that in every case we must keep a
	complete list of accepted multicast addresses to recompute
	the hash table when it changes.
	
	My first pass at device-level support is detailed in the
	new outline driver skeleton.c (pl14 and up.)

	It looks like the following:
	
	#ifdef HAVE_MULTICAST
	static void set_multicast_list(struct device *dev, int num_addrs,
					 void *addrs);
	#endif
	.
	.
	
	ethercard_open() {
	...
#ifdef HAVE_MULTICAST
		dev->set_multicast_list = &set_multicast_list;
	#endif
	...
	
	#ifdef HAVE_MULTICAST
	/* Set or clear the multicast filter for this adaptor.
	   num_addrs == -1	Promiscuous mode, receive all packets
	   num_addrs == 0	Normal mode, clear multicast list
	   num_addrs > 0	Multicast mode, receive normal and
				MC packets, and do best-effort filtering.
	 */
	static void
	set_multicast_list(struct device *dev, int num_addrs, void *addrs)
	{
	...

	Any comments, criticism, etc. are welcome.

	Alan Cox adds that "...in pl14, user programs can access promiscuous
	mode but not multicast mode, even though the drivers support both.
	The ifconfig program allows you to mark an interface 'promisc'."
	
5.10 The Berkeley Packet Filter (BPF)

	I'm not bitterly opposed to it, but I'm coming to the
	conclusion that the 'bpf' functionality should not be provided
	by the kernel, but should be in a (hopefully little-used)
	compatibility library.
	
	For those not in the know: 'bpf' (the Berkeley Packet Filter)
	is an mechanism for specifying to the kernel networking layers
	what packets you are interested in. It's implemented as a
	specialized stack language interpreter built into a low level
	of the networking code. An application passes a program
	written in this language to the kernel, and the kernel runs the
	program on each incoming packet. If the kernel has multiple
	'bpf' applications, each program is run on each packet.
	
	The problem is that it's difficult to deduce what kind of
	packets the application is really interested in from the packet
	filter program, so the general solution is to always run the
	filter. Imagine a program that registers a 'bpf' program to
	pick up a low data-rate stream sent to a multicast address.
	Most ethernet cards have a hardware multicast address filter
	implemented as a 64 entry hash table that ignores most unwanted
	multicast packets, so the capability exists to make this a very
	inexpensive operation. But with the BFP the kernel must switch
	the interface to promiscuous mode, receive _all_ packets, and
	run them through this filter. This is work, BTW, that's very
	difficult to account back to the process requesting the packets.

5.11 Unresolved questions / concerns

	There may be some benefit from processing packet data as it is
	transferred to and from the ethercard, especially with very fast
	processors transferring data to a slow ethercard. As I see it this
	question has multiple parts:
		1) Is there any useful processing power available, perhaps
		   during the ISA bus recovery period, or while the 8390
		   remote DMA is preparing for another transfer??
		2) Is there any useful but simple work that can be done
		   between/during each word of the copy, such as calculating
		   a CRC, or discarding obviously unwanted packets??
		3) would the complexity of an interface to do this make future
		   ethercard drivers impossible??

	There should be a better structure than Space.c - Drivers should be
	able to autoprobe for all installed ethercards rather than just
	quitting after finding the first.  I've written code to do this,
	but the constant promise (threat?) of DDI has prevented me from
	making it standard.

	A related topic is the problem of driver probes corrupting
	unrelated hardware. Even worse is a probe into a dataport that
	isn't set up to transfer data, which will freeze the machine. The
	common suggestion is a boot-time device registry that records
	already-used I/O ports and shared memory. This has been implemented
	as of pl13, see section 5.01.

6 Possible problems, and troubleshooting.

	This section tries to answer any unresolved questions, and not so
	common solutions to common problems. They are sorted on a "per
	manufacturer basis". You should have also read the relevant info.
	from section 1 about your specific card. Section 8 contains more
	general FAQ's.

6.01 Problems with NE2000 (and clones)

	"DMA address mismatch"
	======================

	Is the chip a real NatSemi 8390? (DP8390, DP83901, DP83902 or DP83905)?
	If not, some clone chips don't correctly implement the transfer
	verification register. MS-DOS drivers never do error checking,
	so it doesn't matter to them.

	Are most of the messages off by a factor of 2?
	If so:	Are you using the NE2000 in a 16 bit slot?
		Is it jumpered to use only 8 bit transfers?

	The Linux driver expects a NE2000 to be a 16 bit slot. A NE1000 can
	be in either size slot. This problem can also occur with some clones,
	notably D-Link 16 bit cards, that don't have the correct ID bytes
	in the station address PROM. [[ This should be fixed in pl12.]]

	Are you running the bus faster than 8Mhz?
	If you can change the speed (faster or slower), see if that
	makes a difference. Most NE2000 clones will run at 16Mhz, but
	some may not. Changing speed can also mask a noisy bus.

	What other devices are on the bus?
	If moving the devices around changes the reliability, then you
	have a bus noise problem -- just what that error message was
	designed to detect. Congratulations, you've probably found the
	source of other problems as well.

	Machine Hangs during Boot.
	==========================

	Problem:  The machine hangs during boot right after the "8390..."  or
		  "WD...." message. Removing the NE2000 fixes the problem.

	Solution: Change your NE2000 base address to 0x360 (or 0x340 for
		  pl12 or later kernels.) Alternatively, you can use the new
		  device registrar implemented in pl13 (see section 5.1)

	Reason:   Your NE2000 clone isn't a good enough clone. An active
		  NE2000 is a bottomless pit that will trap any driver
		  autoprobing in its space. The other ethercard drivers take
		  great pain to reset the NE2000 so that it's safe, but some
		  clones cannot be reset. Clone chips to watch out for:
		  Winbond 83C901. Changing the NE2000 to a less-popular
		  address will move it out of the way of other autoprobes,
		  allowing your machine to boot.

	Problem:  The machine hangs during the SCSI probe at boot.

	Solution: It's the same problem as above, change the
		  ethercard's address, or use the device registrar.

	Problem:  The machine hangs during the soundcard probe at boot.

	Solution: No, that's really during the silent SCSI probe, and it's
		  the same problem as above.

	"eth0: DMAing conflict in ne_block_input"
	=========================================

	This bug came from timer-based packet retransmissions. If you got a
	timer tick _during_ a ethercard RX interrupt, and timer tick tried to
	retransmit a timed-out packet, you could get a conflict. Because of
	the design of the NE2000 you would have the machine hang (exactly the
	same the NE2000-clone boot hangs).

	Early versions of the driver disabled interrupts for a long time,
	and didn't have this problem. Later versions are fixed. (ie. kernels
	after 0.99p9 should be OK.)

	NE2000 not detected at boot.
	============================

	A few people have reported a problem with detecting the Accton NE2000.
	This problem occurs only at boot-time, and the card is later detected
	at run-time by the identical code my (alpha-test) ne2k diagnostic
	program. Accton has been very responsive, but I still haven't tracked
	down what is going on. I've been unable to reproduce this problem
	with the Accton cards we purchased. If you are having this problem,
	please send me an immediate bug report. For that matter, if you have
	an Accton card send me a success report, including the type of the
	motherboard. I'm especially interested in finding out if this problem
	moves with the particular ethercard, or stays with the motherboard.
	
	Here are some things to try, as they have fixed it for some people:
	1) Change the bus speed, or just move the card to a different slot (!).
	2) Change the "I/O recovery time" parameter in the BIOS
	   chipset configuration.
	3) Make the following code change suggested by David Cutler,
	   <dave@dmitri.ucdavis.edu> to ne.c around line 150:

	    for(i = 0; i < 32 /*sizeof(SA_prom)*/; i+=2) {
	-        SA_prom[i] = inb_p(ioaddr + NE_DATAPORT);
	-        SA_prom[i+1] = inb_p(ioaddr + NE_DATAPORT);
	+        SA_prom[i] = inb(ioaddr + NE_DATAPORT);
	+        SA_prom[i+1] = inb(ioaddr + NE_DATAPORT);
	        if (SA_prom[i] != SA_prom[i+1])
	            wordlength = 1;
	    }

	Yes, this removes the delay between board accesses, something that
	would normally increase the likelihood of data corruption rather
	than decreasing it. Note that this change is already incorporated
	into pl15. If you have an older kernel, you may have to do it
	yourself.

6.02 Problems with WD80*3 cards

	Detected Non-existent Ethercard
	===============================

	Problem:  A WD80*3 is falsely detected. Removing the sound or
		  MIDI card eliminates the "detected" message.

	Solution: Update your ethercard driver: new versions include an
		  additional sanity check.

	Reason:   Some MIDI ports happen to produce the same checksum as a
		  WD ethercard.

	Error messages from the 80*3
	============================

	Problem:  You get messages such as the following with your 80*3:
			eth0: bogus packet size, status = ........
			kmalloc called with impossibly large argument (65400)
			eth0: Couldn't allocate sk_buff of size 65400
			eth0: receiver overrun

	Reason:   There is a shared memory problem.

	Solution: If the problem is sporadic, you have hardware problems.
		  Typical problems that are easy to fix are board conflicts,
		  having cache or "shadow ROM" enabled for that region, or
		  running your bus faster than 8Mhz. There are also a
		  surprising number of memory failures on ethernet cards,
		  so run a diagnostic program if you have one for your
		  ethercard.

		  If the problem is continual, and you have have to reboot
		  to fix the problem, record the boot-time probe message
		  and mail it to becker@super.org - Take particular note of
		  the shared memory location.

	Will not detect my 80x3
	=======================

	Reason:   The Mitsumi CD-ROM (mcd) driver probe at 0x300 will
		  succeed if just about *anything* is that I/O location.
		  This is bad news and needs to be a bit more robust. (pl15)
		  Once another driver registers that it "owns" an I/O
		  location, other drivers (incl. the wd80x3) are "locked
		  out" and can not probe that addr for a card.

	Solution: Recompile a new kernel without any excess drivers that
		  you aren't using, including the above mcd driver.
		  Or try moving your ethercard to a new I/O addr. Valid
		  I/O addr. for all the cards are listed in section 5.1
		  You can also point the mcd driver off in another direction
		  by a boot-time parameter (via LILO) such as:
			"mcd=0x200,12"

6.03 Problems with 3Com cards

	Choosing the Interrupt of the 3c503
	===================================

	Problem:  The 3c503 picks IRQ n at boot, but this is needed for some
		  other device which needs IRQ n. (eg. CD ROM driver, etc.)
		  Can this be fixed without compiling this into the kernel?

	Solution: The 3c503 driver probes for a free IRQ line in the order
		  {5, 9/2, 3, 4}, and it should pick a line which isn't being
		  used. The pre-pl12 (SLS 1.02) driver picked the IRQ line
		  at boot-time, and the current driver (pl12) chooses when
		  the card is open()/'ifconfig'ed. Note the "bug" noted in
		  the 3c503 section in 1.01

		  Alternately, you can fix the IRQ at boot by passing
		  parameters via LILO. The following selects IRQ9, base
		  location 0x300, <ignored value>, and if_port #1 (the
		  external transceiver).
			lilo: linux ether=9,0x300,0,1,eth0

		  The following selects IRQ3, probes for the base location,
		  <ignored value>, and the default if_port #0 (the internal
		  transceiver)
			lilo: linux ether=3,0,0,0,eth0

	"3c503: Configured interrupt number XX is out of range."
	========================================================

	Problem:  Whoever built your kernel fixed the ethercard IRQ at XX.

	Reason:   The above is truly evil, and worse than that, it is
		  not necessary. The 3c503 will autoIRQ when it gets
		  "ifconfig"ed, and pick one of IRQ{5, 2/9, 3, 4}.

	Solution: Use lilo to set the IRQ, or rebuild the kernel, enabling
		  autoIRQ by not specifying the IRQ line.

	Choosing the output of the 3c503
	================================

	Problem:  The supplied 3c503 drivers don't use the AUI (thicknet) port.
		  How does one choose it over the default thinnet port?

	Solution: The 3c503 AUI port can be selected at boot-time with 0.99pl12
		  and later. The selection is overloaded onto the low bit of
		  the currently-unused dev->rmem_start variable, so a boot-time
		  parameter of:
			lilo: linux ether=0,0,0,1,eth0
		  should work. A boot line to force IRQ 5, port base 0x300,
		  and use an external transceiver is:
			lilo: linux ether=5,0x300,0,1,eth0

7 Networking with a laptop computer

	There are currently only a few ways to put your laptop on a network.
	You can use the SLIP code (and run at serial line speeds);
	you can buy one of the few laptops that come with a NE2000-compatible
	ethercard or PCMCIA slot built-in; you can get a laptop with a
	docking station and plug in an ISA ethercard; or you can use a
	parallel port Ethernet adapter such as the D-Link DE-600.

7.01 Option 1 -- using SLIP

	This is the cheapest solution, but by far the most difficult. Also,
	you will not get very high transmission rates. Since SLIP is not
	really related to ethernet cards, it will not be discussed further
	here. See the NET-2 HOWTO.

7.02 Option 2 -- Built in NE2000 compatible or PCMCIA Ethercard.

	The second solution severely limits your laptop choices and is fairly
	expensive. Be sure to read the specifications carefully, you may find
	that you will have to buy an additional non-standard transceiver to
	actually put the machine on a network.

	As this area of Linux development is fairly young, I'd suggest
	that you join the LAPTOPS mailing channel. See section 0.02
	which describes how to join a mailing list channel. Try and
	determine exactly what hardware you have (ie. card manufacturer,
	PCMCIA chip controller manufacturer) and then ask on the LAPTOPS
	channel. Regardless, don't expect things to be all that simple.
	Expect to have to fiddle around a bit, and patch kernels, etc.
	Maybe someday you will be able to type "make config" 8-)

	There is a number of programs on tsx-11.mit.edu in
	/pub/linux/packages/laptops/ that you may find useful. These
	range from PCMCIA Ethercard drivers to programs that communicate
	with the PCMCIA controller chip. Note that these drivers are
	usually tied to a specific PCMCIA chip (ie. the intel 82365
	or the TCIC/2) On a brighter note, I know that people have used the
	Linksys/D-Link 650 PCMCIA Ethernet PC Card with both controller
	chipsets, so it *can* be done. I have also seen reports of
	people using the IBM Credit Card Adapter for Ethernet with the
	intel 82365 chip. This is all just from following the LAPTOPS
	channel.

	The 3c589 from 3Com is supposed to look a lot like a 3c509.

	Anyway, the PCMCIA driver problem isn't specific to the Linux world.
	It's been a real disaster in the MS-DOS world. In that world
	people expect the hardware to work if they just follow the manual.
	They might not expect it to interoperate with any other hardware
	or software, or operate optimally, but they do expect that the
	software shipped with the product will function. Many PCMCIA
	adaptors don't pass this test.

7.03 Option 3 -- ISA Ethercard in the Docking Station.

	I recommend the third solution. Docking stations for laptops typically
	cost about $250 and provide two full-size ISA slots, two serial and one
	parallel port. Most (all?) docking stations are powered off of the
	laptop's batteries, and a few allow adding extra batteries in the
	docking station if you use short ISA cards. You can add an inexpensive
	ethercard and enjoy full-speed ethernet performance.

7.04 Option 4 -- Pocket / parallel port adaptors.

	The "pocket" ethernet adaptors may also fit your need.
	Until recently they actually costed more than a docking station and
	cheap ethercard, and most tie you down with a wall-brick power supply.
	At present, you can choose from the D-Link, or the RealTek adaptor.
	Most other companies, especially Xircom, treat the programming
	information as a trade secret, so support will likely be slow in
	coming.

	You can sometimes avoid the wall-brick with the adaptors by buying
	or making a cable that draws power from the laptop's keyboard
	port. (This is mentioned in the info. for the AT-Lan-Tec unit.)

	The keyboard pinouts (5 pin DIN) are as follows:

		Signal/Function			Pin #
		---------------			-----
		KEYCLK (clock)			1
		KEYDAT (data)			2
		N/C				3
		Ground				4
		+5 V				5

	A quick check with a voltmeter will verify which pins are 4 and 5
	if you are not sure.
8 Frequently asked questions

	Here are some of the more frequently asked questions about using
	Linux with an Ethernet connection. Some of the more specific
	questions are sorted on a "per manufacturer basis" and are listed
	in the "Troubleshooting" section. (section 6). However, since this
	document is basically "old" by the time you get it, any "new" problems
	will not appear here instantly. For these, I suggest that you make
	efficient use of your newsreader. For example, nn users would type
		nn -xX -s'3c'
	to get all the news articles in your subscribed list that have
	"3c" in the subject. (ie. 3com, 3c509, 3c503, etc.)
	The moral: Read the man page for your newsreader.
	
8.01 Just the FAQ's ma'am -- just the FAQ's.

	Q: I heard that there is an alpha driver available for my card.
	   Where can I get it?

	A: Assuming that it is a djb driver, it will be on ftp.super.org
	   in the /pub/linux/ area. Things change here quite frequently,
	   so just look around for it. There is usually only about 3
	   subdirs, so you should be able to find it. Now, if it really
	   is an alpha, or pre-alpha driver, then please treat it as
	   such. In other words, don't complain because you can't figure
	   out what to do with it. If you can't figure out how to install
	   it, then you probably shouldn't be testing it. Also, if it brings
	   your machine down, don't complain. Instead, send us a well
	   documented bug report, or even better, a patch!

	Q: Is there token ring support for Linux?

	A: No, there is no token ring support in Linux. To support token ring
	   requires more than only a writing a device driver, it also requires
	   writing the source routing routines for token ring. Given that
	   token ring is expensive, not fast, and will probably be swept away
	   by 100baseVG in a few months, it doesn't seem worth it to write
	   a driver. In case anyone wants to, I looked at writing a token ring
	   device driver, and concluded that the hardware interface
	   wasn't too difficult to do, but writing the support for source
	   routing would take significantly longer than I was willing to spend
	   on an expensive and dying technology.

	   Alan Cox adds: "It will require [...] changes to the bottom socket
	   layer to support 802.2 and 802.2 based TCP/IP. Don't expect
	   anything soon."

	Q: Is there FDDI support for Linux?

	A: No, there is no Linux driver for any FDDI boards. I come from a
	   place with supercomputers, so an external observer might think
	   FDDI would be high on my list. But FDDI never delivered end-to-end
	   throughput that would justify its cost, and it seems to be a nearly
	   abandoned technology now that 100base{X,Anynet} seems imminent.
	   (And yes, I know you can now get FDDI boards for <$1K. That
	   seems to be a last-ditch effort to get some return on the
	   development investment. Where is the next generation of FDDI
	   going to come from?)

	Q: Can I link 10BaseT (RJ45) based systems together without a hub?

	A: You can link 2 machines easily, but no more than that, without
	   extra devices/gizmos. See section 4 on wiring -- it explains
	   how to do it. And no, you can't hack together a hub just by
	   crossing a few wires and stuff. It's pretty much impossible 
	   to do the collision signal right without duplicating a hub.

	Q: Is there IPX or Novell support available for Linux?

	A: Alan Cox writes: "The novell protocols are available from novell
	   for various amounts. IPX is freely documented. SPX is about $1000
	   but I'm told Xerox SPP is identical. _PLEASE_ has anyone got any
	   freely distributable Xerox SPP code/documentation? The novell
	   server spec costs you $15000 + royalties providing you only
	   want to write a client, or $30000 + royalties otherwise. Needless
	   to say the final output has to be binary only and subject to a
	   novell license. Reading their license rules by my interpretation
	   its also impossible for us to do because you would seem to have
	   to bar disassembly of your final result, which is not allowed
	   in the EEC.

	   Bits of NCP are known, and I hope eventually enough will be known
	   to write limited NCP support into Linux, for the moment I'm poking
	   around at IPX, tho this will have to wait until the new network
	   code is finished.

	   An Alpha test IPX protocol layer is available from me (Alan)
	   for pl14 or higher. People are also exploring the issue of NCP and
	   the new Dr Dobbs journal article on the innards of netware has
	   provided a core of good information."

	   As an alternative, Miquel van Smoorenburg suggests the following:
	   "It _is_ possible to set up a dedicated PC running both novell and
	   the PD SOSS server and let it gateway from NFS to novell. This way
	   it is possible to mount the Novell drives on the Unix client.

	   SOSS is a PD (perhaps with some restrictions, but freely available)
	   NFS server for DOS. It includes the PC/IP TCP/IP implementation
	   and runs on a packet driver. I have run both a Novell client
	   (with PDIPX, a Packet Driver IPX) and this SOSS server together
	   successfully."

	   You can get "Stan's Own Server System" from the following location:
		hilbert.wharton.upenn.edu:pub/tcpip/soss.zip
	   Note that this version has the IP bugs fixed and the subdirs
	   with extensions bug fixed. Some of the soss.zoo archives do
	   not contain these fixes.

	Q: What needs to be done so that Linux can run two ethernet cards?

	A: The easiest solution is to get 0.99pl13 or newer, as the hooks for
	   multiple ethercards are all there.
	   You can enable additional ethercards with LILO parameters such as:

		lilo: linux ether=5,0x300,0,1,eth0 ether=15,0x280,eth1

	   These boot time arguments can be made permanent so that you
	   don't have to re-enter them every time. See the LILO manual.

	Q: Okay, I can run 2 cards -- can I run Linux as a gateway 
	   between two networks?

	A: This is really a question for the NET-HOWTO, but it is 
	   answered here anyways: Charles Hedrick (aka Mr. Slip)
	   had this to say:

	   "Yes, however I'm a bit nervous about doing it. The problem isn't
	   functionality -- there's IP forwarding code, and as far as I know,
	   it works. Some people do use it. However routers need to be
	   particularly careful to avoid creating network problems such as
	   "meltdowns." The Linux IP layer doesn't have quite enough of these
	   protective features. It will only cause trouble if other hosts on
	   your network are misconfigured, and even then it probably won't
	   cause much trouble (assuming that only systems actually acting as
	   gateways are built with IP_FORWARD enabled). But I'd still rather
	   use a router that met all of the requirements of the host and
	   router requirements in the RFC's. (Note that not all other Unix
	   implementations do either. I'm concerned about things like not
	   sending ICMP responses to messages that arrive as media 
	   broadcasts. 386BSD looks OK, but older BSD-based implementations
	   often didn't do all of these checks.)

	   It depends a lot on what the network is like and how critical it is.
	   For a home setup with a couple of hosts, I see no problem at all.
	   But I would not consider using Linux as a router on a large
	   campus network at the moment. I still think that by release 1.0,
	   Linux will be a reasonably well-behaved host. But I think use
	   as a router in critical situations should wait until somebody
	   has checked the ip and icmp modules for compliance with RFC 1009
	   and a few other specs."

	Q: I have /dev/eth0 as a link to /dev/xxx. Is this right?

	A: Contrary to what you have heard, the files in /dev/* are not used.
	   I originally thought that they might be an OK idea. I've since
	   concluded that they won't work, at least in the documented form.

	Q: Should I disable trailers when I "ifconfig" my ethercard?

	A: You can't disable trailers, and you shouldn't want to.
	   'Trailers' are a hack to avoid data copying in the
	   networking layers. The idea was to use a trivial 
	   fixed-size header of size 'H', put the variable-size header 
	   info at the end of the packet, and allocate all packets
	   'H' bytes before the start of a page. While it was a good
	   idea, it turned out to not work well in practice.
	   If someone suggests the use of '-trailers', note that it
	   is the equivalent of sacrificial goats blood. It won't do
	   anything to solve the problem, but if problem fixes itself then
	   someone can claim deep magical knowledge.

9 Miscellaneous.

	Any other associated stuff that didn't fit in anywhere else gets
	dumped here. It may not be relevant, and it may not be of general
	interest but it is here anyway.

9.01 Bad Vendors

	#define SOAPBOX

	There used to be some horror stories here about dealings with
	Cabletron and Xircom. They were pretty ugly and gruesome.
	Basically these companies are the ethernet equivalent of
	what Diamond is to XFree86. They do not want to release
	vital information on low-level programming of their hardware.
	For something like Linux, where the source code for everything
	is out in the open, this makes their hardware difficult or
	impossible to use. However, like Diamond, when confronted
	with the fact that they are losing sales from Linux/BSD users,
	they basically shrug it off, saying that it is only a small
	percentage of the total sales. If you can afford the time,
	drop these vendors a note (via e-mail or snail-mail) and tell
	them politely that the fact that they don't support open
	software systems such as Linux has forced you to exclude them
	from the vendors that you are purchasing hardware from. It may
	not make any immediate difference, but it might make you feel
	better. Besides, a few seconds of your time is a cheap price
	to pay for *all* that free Linux software you are using. 8-)

	#undef SOAPBOX

9.02 Closing

	If you have found any glaring typos, or outdated info in this
	document, please let one of us know. It's getting big, and it
	is easy to overlook stuff.

	Paul Gortmaker		<gpg109@rsphy1.anu.edu.au>
	Donald J. Becker	<becker@super.org>



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Linux Ethernet HOWTO (part 2/2)
  1994-11-18 17:03 Linux Ethernet HOWTO (part 1/2) Paul Gortmaker
@ 1994-11-18 17:05 ` Paul Gortmaker
  0 siblings, 0 replies; 6+ messages in thread
From: Paul Gortmaker @ 1994-11-18 17:05 UTC (permalink / raw)


Archive-Name: linux/howto/ethernet/part2
Last-modified: 20 Oct 94


---This is part 2/2---

  And if you just want to verify that this is the case, you can reach
  Xircom at 1-800-874-7875 or +1-818-878-7600.


  3.25.1.  PE1, PE2, PE3-10B*


  Status -- Not Supported

  Not to get your hopes up, but if you have one of these parallel port
  adaptors, you may be able to use it in the DOS emulator with the
  Xircom-supplied DOS drivers. You will have to allow DOSEMU access to
  your parallel port, and will probably have to play with SIG (DOSEMU's
  Silly Interrupt Generator). I have no idea if this will work, but if
  you have any success with it, let me know, and I will include it here.


  3.26.  Zenith



  3.26.1.  Z-Note


  Status -- Supported

  The built-in Z-Note network adaptor is based on the Intel i82593 using
  two DMA channels. There is an (alpha?) driver available in the present
  kernel version. As with all notebook and pocket adaptors, it is under
  the `Pocket and portable adaptors' section when running make config.
  See ``Programming the Intel chips'' for more technical information.
  Also note that the IBM ThinkPad 300 is compatible with the Z-Note.


  4.  Clones of popular Ethernet cards.


  Due to the popular design of some cards, different companies will make
  `clones' or replicas of the original card. However, one must be
  careful, as some of these clones are not 100 % compatible, and can be
  troublesome. Some common problems with `not-quite-clones' are noted in
  ``the FAQ section''.

  This section used to have a listing of a whole bunch of clones that
  were reported to work, but seeing as nearly all clones will work, it
  makes more sense to list the ones that don't work 100 % .


  4.1.  NE2000 Clones with Problems


  Here is a list of some of the NE-2000 clones that are known to have
  various problems. Most of them aren't fatal. In the case of the ones
  listed as `bad clones' -- this usually indicates that the cards don't
  have the two NE2000 identifier bytes. NEx000-clones have a Station
  Address PROM (SAPROM) in the packet buffer memory space.  NE2000
  clones have 0x57,0x57 in bytes 0x0e,0x0f of the SAPROM, while other
  supposed NE2000 clones must be detected by their SA prefix.

  Accton NE2000 -- might not get detected at boot, see ``ne2000
  problems''.

  Aritsoft LANtastic AE-2 -- OK, but has flawed error-reporting
  registers.

  AT-LAN-TEC NE2000 -- clone uses Winbond chip that traps SCSI drivers

  Cabletron E10**, E20**, E10**-x, E20**-x -- bad clones, but the driver
  checks for them. See ``E10**''.

  D-Link Ethernet II -- bad clones, but the driver checks for them. See
  ``DE-100 / DE-200''.

  DFI DFINET-300, DFINET-400 -- bad clones, but the driver checks for
  them. See ``DFI-300 / DFI-400''


  4.2.  WD8013 Clones with Problems


  I haven't heard of any bad clones of these cards, except for some
  chamelion-type cards that can be set to look like a ne2000 card or a
  wd8013 card. There is really no need to purchase one of these `double-
  identity' cards anyway.


  5.  Cables, Coax, Twisted Pair

  If you are starting a network from scratch, it's considerably less
  expensive to use thin ethernet, RG58 co-ax cable with BNC connectors,
  than old-fashioned thick ethernet, RG-5 cable with N connectors, or
  10baseT, twisted pair telco-style cables with RJ-45 eight wire `phone'
  connectors. See ``Type of cable...'' for an introductory look at
  cables.


  5.1.  Thin Ethernet (thinnet)


  Thin ethernet is the `ether of choice'. The cable is inexpensive. If
  you are making your own cables solid-core RG58A is $0.09/ft. and
  stranded RG58AU is $0.15/ft. Twist-on BNC connectors are < $2 ea., and
  other misc. pieces are similarly inexpensive. It is essential that you
  properly terminate each end of the cable with 50 ohm terminators, so
  budget $2 ea. for a pair. It's also vital that your cable have no
  `stubs' -- the `T' connectors must be attached directly to the
  ethercards. The only drawback is that if you have a big loop of
  machines connected together, and some bonehead breaks the loop by
  taking one cable off the side of his tee, the whole network goes down
  because it sees an infinite impedance (open circuit) instead of the
  required 50 ohm termination. Note that you can remove the tee piece
  from the card itself without killing the whole subnet, as long as you
  don't remove the cables from the tee itself. Of course this will
  disturb the machine that you pull the actual tee off of. 8-) And if
  you are doing a small network of two machines, you *still* need the
  tees and the 50 ohm terminators -- you *can't* just cable them
  together!


  5.2.  Twisted Pair


  Twisted pair networks require active hubs, which start around $200,
  and the raw cable cost can actually be higher than thinnet. They are
  usually sold using the claim that you can use your existing telephone
  wiring, but it's a rare installation where that turns out to be the
  case. The claim that you can upgrade to higher speeds is also suspect,
  as most proposed schemes use higher-grade (read $$) cable and more
  sophisticated termination ($$$) than you would likely install on
  speculation. New gizmos are floating around which allow you to daisy-
  chain machines together, and the like. For example, Falleron sells
  EtherWave adaptors and transceivers. This device allows multiple
  10baseT devices to be daisy-chained. They also sell a 3c509 clone that
  includes the EtherWave transceiver.  The drawback is that it's more
  expensive and less reliable than a cheap ($100-$150) mini-hub and
  another ethercard.  IMO, you should either go for the hub approach or
  switch over to 10base2 thinnet.

  On the other hand, hubs are rapidly dropping in price, all 100Mb/sec
  ethernet proposals use twisted pair, and most new business
  installations use twisted pair. (This is probably to avoid the problem
  with idiots messing with the BNC's as described above.)

  If you are only connecting two machines, it is possible to avoid using
  a hub, by swapping the Rx and Tx pairs (1-2 and 3-6).

  Also, Russ Nelson adds that `New installations should use Category 5
  wiring. Anything else is a waste of your installer's time, as 100Base-
  whatever is going to require Cat 5.'
  5.3.  Thick Ethernet

  Thick ethernet is mostly obsolete, and is usually used only to remain
  compatible with an existing implementation. You can stretch the rules
  and connect short spans of thick and thin ethernet together with a
  passive $3 N-to-BNC connector, and that's often the best solution to
  expanding an existing thicknet. A correct (but expensive) solution is
  to use a repeater in this case.

  6.  Technical Information


  For those who want to play with the present drivers, or try to make up
  their own driver for a card that is presently unsupported, this
  information should be useful. If you do not fall into this category,
  then perhaps you will want to skip this section.


  6.1.  Probed Addresses



  While trying to determine what ethernet card is there, the following
  addresses are autoprobed, assuming the type and specs of the card have
  not been set in the kernel. The file names below are in
  /usr/src/linux/drivers/net/


  ______________________________________________________________________
          3c501.c         0x280, 0x300
          3c503.c:        0x300, 0x310, 0x330, 0x350, 0x250, 0x280, 0x2a0, 0x2e0
          3c505.c:        0x300, 0x280, 0x310
          3c507.c:        0x300, 0x320, 0x340, 0x280
          3c509.c:        Special ID Port probe
          apricot.c       0x300
          at1700.c:       0x300, 0x280, 0x380, 0x320, 0x340, 0x260, 0x2a0, 0x240
          atp.c:          0x378, 0x278, 0x3bc
          depca.c         0x300, 0x200
          d_link.c:       0x378
          eexpress.c:     0x300, 0x270, 0x320, 0x340
          hp.c:           0x300, 0x320, 0x340, 0x280, 0x2C0, 0x200, 0x240
          hp-plus.c       0x200, 0x240, 0x280, 0x2C0, 0x300, 0x320, 0x340
          lance.c:        0x300, 0x320, 0x340, 0x360
          ne.c:           0x300, 0x280, 0x320, 0x340, 0x360
          ni52.c          0x300, 0x280, 0x360, 0x320, 0x340
          ni65.c          0x300, 0x320, 0x340, 0x360
          smc-ultra.c:    0x200, 0x220, 0x240, 0x280, 0x300, 0x340, 0x380
          wd.c:           0x300, 0x280, 0x380, 0x240
  ______________________________________________________________________



  There are some NE2000 clone ethercards out there that are waiting
  black holes for autoprobe drivers. While many NE2000 clones are safe
  until they are enabled, some can't be reset to a safe mode.  These
  dangerous ethercards will hang any I/O access to their `dataports'.
  The typical dangerous locations are:

  ______________________________________________________________________
          Ethercard jumpered base     Dangerous locations (base + 0x10 - 0x1f)
                  0x300 *                         0x310-0x317
                  0x320                           0x330-0x337
                  0x340                           0x350-0x357
                  0x360                           0x370-0x377
  ______________________________________________________________________

  * The 0x300 location is the traditional place to put an ethercard, but
  it's also a popular place to put other devices (often SCSI
  controllers). The 0x320 location is often the next one chosen, but
  that's bad for for the AHA1542 driver probe. The 0x360 location is
  bad, because it conflicts with the parallel port at 0x378.

  To avoid these lurking ethercards, here are the things you can do:


  o  Probe for the device's BIOS in memory space. This is easy and
     always safe, but it only works for cards that always have BIOSes,
     like primary SCSI controllers.

  o  Avoid probing any of the above locations until you think you've
     located your device. The NE2000 clones have a reset range from
     <base>+0x18 to <base>+0x1f that will read as 0xff, so probe there
     first if possible. It's also safe to probe in the 8390 space at
     <base>+0x00 - <base>+0x0f, but that area will return quasi-random
     values

  o  If you must probe in the dangerous range, for instance if your
     target device has only a few port locations, first check that there
     isn't an NE2000 there. You can see how to do this by looking at the
     probe code in /usr/src/linux/net/inet/ne.c

  o  Use the `reserve' boot time argument to protect volatile areas from
     being probed. See the information on using boot time arguments with
     LILO in ``The reserve command''


  6.2.  Skeleton / prototype driver



  OK. So you have decided that you want to write a driver for the Foobar
  Ethernet card, as you have the programming information, and it hasn't
  been done yet. (...these are the two main requirements ;-) You can use
  the skeleton network driver that is provided with the Linux kernel
  source tree. It can be found in the file
  /usr/src/linux/drivers/net/skeleton.c as of 0.99pl15, and later.

  It's also very useful to look at the Crynwr (nee Clarkson) driver for
  your target ethercard, if it's available. Russ Nelson
  nelson@crynwr.com has been actively updating and writing these, and he
  has been very helpful with his code reviews of the current Linux
  drivers.


  6.3.  Driver interface to the kernel


  Here are some notes that may help when trying to figure out what the
  code in the driver segments is doing, or perhaps what it is supposed
  to be doing.












  ______________________________________________________________________
          int ethif_init(struct device *dev)
          {
              ...
                  dev->send_packet = &ei_send_packet;
                  dev->open = &ei_open;
                  dev->stop = &ei_close;
                  dev->hard_start_xmit = &ei_start_xmit;
                  ...
          }

          int ethif_init(struct device *dev)
  ______________________________________________________________________



  This function is put into the device structure in Space.c. It is
  called only at boot time, and returns `0' iff the ethercard `dev'
  exists.


  ______________________________________________________________________
          static int ei_open(struct device *dev)
          static int ei_close(struct device *dev)
  ______________________________________________________________________



  This routine opens and initializes the board in response to an socket
  ioctl() usually called by `ifconfig'. It is commonly stuffed into the
  `struct device' by ethif_init().

  The inverse routine is ei_close(), which should shut down the
  ethercard, free the IRQs and DMA channels if the hardware permits, and
  turn off anything that will save power (like the transceiver).


  ______________________________________________________________________
          static int ei_start_xmit(struct sk_buff *skb, struct device *dev)
                  dev->hard_start_xmit = &ei_start_xmit;
  ______________________________________________________________________



  This routine puts packets to be transmitted into the hardware. It is
  usually stuffed into the `struct device' by ethif_init().

  When the hardware can't accept additional packets it should set the
  dev->tbusy flag. When additional room is available, usually during a
  transmit-complete interrupt, dev->tbusy should be cleared and the
  higher levels informed with mark_bh(INET_BH).


  ______________________________________________________________________
              if (dev_rint(buffer, length, is_skb ? IN_SKBUFF : 0, dev))
                     stats->rx_dropped++;
  ______________________________________________________________________



  A received packet is passed to the higher levels using dev_rint().  If
  the unadorned packet data in a memory buffer, dev_rint will copy it
  into a `skbuff' for you. Otherwise a new skbuff should be kmalloc()ed,
  filled, and passed to dev_rint() with the IN_SKBUFF flag.


  ______________________________________________________________________
          int s=socket(AF_INET,SOCK_PACKET,htons(ETH_P_ALL));
  ______________________________________________________________________



  Gives you a socket receving every protocol type. Do recvfrom() calls
  to it and it will fill the sockaddr with device type in sa_family and
  the device name in the sa_data array. I don't know who originally
  invented SOCK_PACKET for Linux (its been in for ages) but its superb
  stuff.  You can use it to send stuff raw too (both only as root).



  6.4.  Interrupts and Linux


  There are two kinds of interrupt handlers in Linux: fast ones and slow
  ones. You decide what kind you are installing by the flags you pass to
  irqaction(). The fast ones, such as the serial interrupt handler, run
  with _all_ interrupts disabled. The normal interrupt handlers, such as
  the one for ethercard drivers, runs with other interrupts enabled.

  There is a two-level interrupt structure. The `fast' part handles the
  device register, removes the packets, and perhaps sets a flag.  After
  it is done, and interrupts are re-enabled, the slow part is run if the
  flag is set.

  The flag between the two parts is set by:


       mark_bh(INET_BH);


  Usually this flag is set within dev_rint() during a received-packet
  interrupt, and set directly by the device driver during a transmit-
  complete interrupt.

  You might wonder why all interrupt handlers cannot run in `normal
  mode' with other interrupts enabled. Ross Biro uses this scenario to
  illustrate the problem:


  o  You get a serial interrupt, and start processing it.  The serial
     interrupt is now masked.

  o  You get a network interrupt, and you start transferring a maximum-
     sized 1500 byte packet from the card.

  o  Another character comes in, but this time the interrupts are
     masked!

  The `fast' interrupt structure solves this problem by allowing
  bounded-time interrupt handlers to run without the risk of leaving
  their interrupt lines masked by another interrupt request.

  There is an additional distinction between fast and slow interrupt
  handlers -- the arguments passed to the handler. A `slow' handler is
  defined as







  ______________________________________________________________________

                  static void
                  handle_interrupt(int reg_ptr)
                  {
                      int irq = -(((struct pt_regs *)reg_ptr)->orig_eax+2);
                      struct device *dev = irq2dev_map[irq];
                  ...
  ______________________________________________________________________



  While a fast handler gets the interrupt number directly


  ______________________________________________________________________

                  static void
                  handle_fast_interrupt(int irq)
                  {
                  ...
  ______________________________________________________________________



  A final aspect of network performance is latency. The only board that
  really addresses this is the 3c509, which allows a predictive
  interrupt to be posted. It provides an interrupt response timer so
  that the driver can fine-tune how early an interrupt is generated.

  Alan Cox has some advice for anyone wanting to write drivers that are
  to be used with pl14 kernels and newer. He says:

  `Any driver intended for pl14 should use the new alloc_skb() and
  kfree_skbmem() functions rather than using kmalloc() to obtain a
  sk_buff. The new pl14 skeleton does this correctly. For drivers
  wishing to remain compatible with both sets the define
  `HAVE_ALLOC_SKB' indicates these functions must be used.

  In essence replace


       skb=(struct sk_buff *)kmalloc(size)


  with


       skb=alloc_skb(size)


  and


       kfree_s(skb,size)


  with


       kfree_skbmem(skb,size)  /* Only sk_buff memory though */


  Any questions should I guess be directed to me (Alan Cox) since I made
  the change.  This is a change to allow tracking of sk_buff's and
  sanity checks on buffers and stack behaviour. If a driver produces the
  message'File: ??? Line: ??? passed a non skb!' then it is probable the
  driver is not using the new sk_buff allocators.'



  6.5.  Programmed I/O vs. Shared Memory vs. DMA


  Ethernet is 10Mbs. (Don't be pedantic, 3Mbs and 100Mbs don't count.)
  If you can already send and receive back-to-back packets, you just
  can't put more bits over the wire. Every modern ethercard can receive
  back-to-back packets. The Linux DP8390 drivers come pretty close to
  sending back-to-back packets (depending on the current interrupt
  latency) and the 3c509 and AT1500 hardware has no problem at all
  automatically sending back-to-back packets.

  The ISA bus can do 5.3MB/sec (42Mb/sec), which sounds like more than
  enough. You can use that bandwidth in several ways:


  6.5.1.  Programmed I/O


  Pro: Doesn't use any constrained system resources, just a few I/O
  registers, and has no 16M limit.

  Con: Usually the slowest transfer rate, the CPU is waiting the whole
  time, and interleaved packet access is usually difficult to
  impossible.


  6.5.2.  Shared memory


  Pro: Simple, faster than programmed I/O, and allows random access to
  packets.

  Con: Uses up memory space (a big one for DOS users, only a minor issue
  under Linux), and it still ties up the CPU.


  6.5.3.  Slave (normal) Direct Memory Access


  Pro: Frees up the CPU during the actual data transfer.

  Con: Checking boundary conditions, allocating contiguous buffers, and
  programming the DMA registers makes it the slowest of all techniques.
  It also uses up a scarce DMA channel, and requires aligned low memory
  buffers.


  6.5.4.  Master Direct Memory Access (bus-master)


  Pro: Frees up the CPU during the data transfer, can string together
  buffers, can require little or no CPU time lost on the ISA bus.

  Con: Requires low-memory buffers and a DMA channel. Any bus-master
  will have problems with other bus-masters that are bus-hogs, such as
  some primitive SCSI adaptors. A few badly-designed motherboard
  chipsets have problems with bus-masters. And a reason for not using
  any type of DMA device is using a Cyrix 486 processor designed for
  plug-in replacement of a 386: these processors must flush their cache
  with each DMA cycle. (This includes the Cx486DLC, Ti486DLC, Cx486SLC,
  Ti486SLC, etc.)
  6.6.  Programming the Intel chips (i82586 and i82593)


  These chips are used on a number of cards, namely the 3c507 ('86), the
  Intel EtherExpress 16 ('86), Microdyne's exos205t ('86), the Z-Note
  ('93), and the Racal-Interlan ni5210 ('86).

  Russ Nelson writes: `Most boards based on the 82586 can reuse quite a
  bit of their code.  More, in fact, than the 8390-based adapters. There
  are only three differences between them:


  o  The code to get the Ethernet address,

  o  The code to trigger CA on the 82586, and

  o  The code to reset the 82586.

  The Intel EtherExpress 16 is an exception, as it I/O maps the 82586.
  Yes, I/O maps it. Fairly clunky, but it works.

  Garrett Wollman did an AT&T driver for BSD that uses the BSD
  copyright. The latest version I have (Sep '92) only uses a single
  transmit buffer. You can and should do better than this if you've got
  the memory. The AT&T and 3c507 adapters do; the ni5210 doesn't.

  The people at Intel gave me a very big clue on how you queue up
  multiple transmit packets. You set up a list of NOP- > XMIT- > NOP- >
  XMIT- > NOP- > XMIT- > beginning) blocks, then you set the `next'
  pointer of all the NOP blocks to themselves. Now you start the command
  unit on this chain. It continually processes the first NOP block. To
  transmit a packet, you stuff it into the next transmit block, then
  point the NOP to it. To transmit the next packet, you stuff the next
  transmit block and point the previous NOP to *it*. In this way, you
  don't have to wait for the previous transmit to finish, you can queue
  up multiple packets without any ambiguity as to whether it got
  accepted, and you can avoid the command unit start-up delay.'


  6.7.  Technical information from 3Com


  From: Cameron Spitzer 764-6339 <camerons@nad.3com.com >Subject:
  getting 3Com Adapter manuals Date: Mon, 27 Sep 1993 21:17:07 +0200

  Since this is becoming a FAQ, I'm going to tread the thin ice of No
  Commercial Use and answer it here.

  3Com's Ethernet Adapters are documented for driver writers in our
  `Technical References' (TRs). These manuals describe the programmer
  interfaces to the boards but they don't talk about the diagnostics,
  installation programs, etc that end users can see.

  The Network Adapter Division marketing department has the TRs to give
  away. To keep this program efficient, we centralized it in a thing
  called `CardFacts.' CardFacts is an automated phone system. You call
  it with a touch-tone phone and it faxes you stuff. To get a TR, call
  CardFacts at 408-727-7021. Ask it for Developer's Order Form, document
  number 9070. Have your fax number ready when you call. Fill out the
  order form and fax it to 408-764-5004.  Manuals are shipped by Federal
  Express 2nd Day Service.

  If you don't have a fax and nobody you know has a fax, really and
  truly, *then* send mail to Terry_Murphy@3Mail.3Com.com and tell her
  about your problem.  PLEASE use the fax thing if you possibly can.

  After you get a manual, if you still can't figure out how to program
  the board, try our `CardBoard' BBS at 1-800-876-3266, and if you can't
  do that, write Andy_Chan@3Mail.3com.com and ask him for alternatives.
  If you have a real stumper that nobody has figured out yet, the fellow
  who needs to know about it is Steve_Lebus@3Mail.3com.com.

  There are people here who think we are too free with the manuals, and
  they are looking for evidence that the system is too expensive, or
  takes too much time and effort. That's why it's important to try to
  use CardFacts *before* you start calling and mailing the people I
  named here.

  There are even people who think we should be like Diamond and Xircom,
  requiring tight `partnership' with driver writers to prevent poorly
  performing drivers from getting written. So far, 3Com customers have
  been really good about this, and there's no problem with the level of
  requests we've been getting. We need your continued cooperation and
  restraint to keep it that way.

  Cameron Spitzer, 408-764-6339 3Com NAD Santa Clara work:
  camerons@nad.3com.com home: cls@truffula.sj.ca.us



  6.8.  Notes on AMD PCnet / LANCE Based cards


  The AMD LANCE (Local Area Network Controller for Ethernet) was the
  original offering, and has since been replaced by the `PCnet-ISA'
  chip, otherwise known as the 79C960.  A relatively new chip from AMD,
  the 79C960, is the heart of many new cards being released at present.
  Note that the name `LANCE' has stuck, and some people will refer to
  the new chip by the old name. Dave Roberts of the Network Products
  Division of AMD was kind enough to contribute the following
  information regarding this chip:

  `As for the architecture itself, AMD developed it originally and
  reduced it to a single chip -- the PCnet(tm)-ISA -- over a year ago.
  It's been selling like hotcakes ever since.

  Functionally, it is equivalent to a NE1500. The register set is
  identical to the old LANCE with the 1500/2100 architecture additions.
  Older 1500/2100 drivers will work on the PCnet-ISA.  The NE1500 and
  NE2100 architecture is basically the same.  Initially Novell called it
  the 2100, but then tried to distinguish between coax and 10BASE-T
  cards. Anything that was 10BASE-T only was to be numbered in the 1500
  range. That's the only difference.

  Many companies offer PCnet-ISA based products, including HP, Racal-
  Datacom, Allied Telesis, Boca Research, Kingston Technology, etc.  The
  cards are basically the same except that some manufacturers have added
  `jumperless' features that allow the card to be configured in
  software. Most have not. AMD offers a standard design package for a
  card that uses the PCnet-ISA and many manufacturers use our design
  without change.  What this means is that anybody who wants to write
  drivers for most PCnet-ISA based cards can just get the data-sheet
  from AMD. Call our literature distribution center at (800)222-9323 and
  ask for the Am79C960, PCnet-ISA data sheet. It's free.

  A quick way to understand whether the card is a `stock' card is to
  just look at it. If it's stock, it should just have one large chip on
  it, a crystal, a small IEEE address PROM, possibly a socket for a boot
  ROM, and a connector (1, 2, or 3, depending on the media options
  offered). Note that if it's a coax card, it will have some transceiver
  stuff built onto it as well, but that should be near the connector and
  away from the PCnet-ISA.'
  There is also some info regarding the LANCE chip in the file lance.c
  which is included in the standard kernel.


  6.9.  Multicast and Promiscuous Mode


  One of the things Donald has been working on recently is the major
  remaining item on the ethercard feature list: implementing multicast
  and promiscuous mode hooks.  All of the released (i.e. not ALPHA) ISA
  drivers now support promiscuous mode. There was a minor problem with
  8390 based cards with capturing multicast packets, in that the
  promiscuous mode setting in 8390.c around line 574 should be 0x18 and
  not 0x10. If you have an up to date kernel, this will already be
  fixed.

  Donald writes: `At first I was planning to do it while implementing
  either the /dev/* or DDI interface, but that's not really the correct
  way to do it. We should only enable multicast or promiscuous modes
  when something wants to look at the packets, and shut it down when
  that application is finished, neither of which is strongly related to
  when the hardware is opened or released.

  I'll start by discussing promiscuous mode, which is conceptually easy
  to implement. For most hardware you only have to set a register bit,
  and from then on you get every packet on the wire. Well, it's almost
  that easy; for some hardware you have to shut the board (potentially
  dropping a few packet), reconfigure it, and then re-enable the
  ethercard. This is grungy and risky, but the alternative seems to be
  to have every application register before you open the ethercard at
  boot-time.

  OK, so that's easy, so I'll move on something that's not quite so
  obvious: Multicast. It can be done two ways:


  1. Use promiscuous mode, and a packet filter like the Berkeley packet
     filter (BPF). The BPF is a pattern matching stack language, where
     you write a program that picks out the addresses you are interested
     in. Its advantage is that it's very general and programmable. Its
     disadvantage is that there is no general way for the kernel to
     avoid turning on promiscuous mode and running every packet on the
     wire through every registered packet filter. See ``The Berkeley
     Packet Filter'' for more info.


  2. Using the built-in multicast filter that most etherchips have.

  I guess I should list what a few ethercards/chips provide:



          Chip/card  Promiscuous  Multicast filter
          ----------------------------------------
          Seeq8001/3c501  Yes     Binary filter (1)
          3Com/3c509      Yes     Binary filter (1)
          8390            Yes     Autodin II six bit hash (2) (3)
          LANCE           Yes     Autodin II six bit hash (2) (3)
          i82586          Yes     Hidden Autodin II six bit hash (2) (4)





  1. These cards claim to have a filter, but it's a simple yes/no
     `accept all multicast packets', or `accept no multicast packets'.
  2. AUTODIN II is the standard ethernet CRC (checksum) polynomial. In
     this scheme multicast addresses are hashed and looked up in a hash
     table. If the corresponding bit is enabled, this packet is
     accepted. Ethernet packets are laid out so that the hardware to do
     this is trivial -- you just latch six (usually) bits from the CRC
     circuit (needed anyway for error checking) after the first six
     octets (the destination address), and use them as an index into the
     hash table (six bits -- a 64-bit table).


  3. These chips use the six bit hash, and must have the table computed
     and loaded by the host. This means the kernel must include the CRC
     code.


  4. The 82586 uses the six bit hash internally, but it computes the
     hash table itself from a list of multicast addresses to accept.

  Note that none of these chips do perfect filtering, and we still need
  a middle-level module to do the final filtering. Also note that in
  every case we must keep a complete list of accepted multicast
  addresses to recompute the hash table when it changes.

  My first pass at device-level support is detailed in the new outline
  driver skeleton.c

  It looks like the following:


  ______________________________________________________________________
          #ifdef HAVE_MULTICAST
          static void set_multicast_list(struct device *dev, int num_addrs,
                           void *addrs);
          #endif
          .
          .

          ethercard_open() {
          ...
          #ifdef HAVE_MULTICAST
                  dev->set_multicast_list = &set_multicast_list;
          #endif
          ...

          #ifdef HAVE_MULTICAST
          /* Set or clear the multicast filter for this adaptor.
             num_addrs -- -1      Promiscuous mode, receive all packets
             num_addrs -- 0       Normal mode, clear multicast list
             num_addrs > 0        Multicast mode, receive normal and
                  MC packets, and do best-effort filtering.
           */
          static void
          set_multicast_list(struct device *dev, int num_addrs, void *addrs)
          {
          ...
  ______________________________________________________________________



  Any comments, criticism, etc. are welcome.'


  6.10.  The Berkeley Packet Filter (BPF)



  I'm not bitterly opposed to it, but I'm coming to the conclusion that
  the BPF functionality should not be provided by the kernel, but should
  be in a (hopefully little-used) compatibility library.

  For those not in the know: BPF (the Berkeley Packet Filter) is an
  mechanism for specifying to the kernel networking layers what packets
  you are interested in. It's implemented as a specialized stack
  language interpreter built into a low level of the networking code. An
  application passes a program written in this language to the kernel,
  and the kernel runs the program on each incoming packet. If the kernel
  has multiple BPF applications, each program is run on each packet.

  The problem is that it's difficult to deduce what kind of packets the
  application is really interested in from the packet filter program, so
  the general solution is to always run the filter. Imagine a program
  that registers a BPF program to pick up a low data-rate stream sent to
  a multicast address.  Most ethernet cards have a hardware multicast
  address filter implemented as a 64 entry hash table that ignores most
  unwanted multicast packets, so the capability exists to make this a
  very inexpensive operation. But with the BFP the kernel must switch
  the interface to promiscuous mode, receive _all_ packets, and run them
  through this filter. This is work, BTW, that's very difficult to
  account back to the process requesting the packets.


  7.  Networking with a Laptop/Notebook Computer


  There are currently only a few ways to put your laptop on a network.
  You can use the SLIP code (and run at serial line speeds); you can buy
  one of the few laptops that come with a NE2000-compatible ethercard;
  you can get a notebook with a supported PCMCIA slot built-in; you can
  get a laptop with a docking station and plug in an ISA ethercard; or
  you can use a parallel port Ethernet adapter such as the D-Link
  DE-600.


  7.1.  Using SLIP


  This is the cheapest solution, but by far the most difficult. Also,
  you will not get very high transmission rates. Since SLIP is not
  really related to ethernet cards, it will not be discussed further
  here. See the NET-2 Howto.


  7.2.  Built in NE2000


  This solution severely limits your laptop choices and is fairly
  expensive. Be sure to read the specifications carefully, as you may
  find that you will have to buy an additional non-standard transceiver
  to actually put the machine on a network. A good idea might be to boot
  the notebook with a kernel that has ne2000 support, and make sure it
  gets detected and works before you lay down your cash.



  7.3.  PCMCIA Support


  As this area of Linux development is fairly young, I'd suggest that
  you join the LAPTOPS mailing channel. See ``Mailing lists...''  which
  describes how to join a mailing list channel.


  Try and determine exactly what hardware you have (ie. card
  manufacturer, PCMCIA chip controller manufacturer) and then ask on the
  LAPTOPS channel. Regardless, don't expect things to be all that
  simple.  Expect to have to fiddle around a bit, and patch kernels,
  etc.  Maybe someday you will be able to type `make config' 8-)

  At present, the two PCMCIA chipsets that are supported are the TCIC/2
  and the intel i82365.

  There is a number of programs on tsx-11.mit.edu in
  /pub/linux/packages/laptops/ that you may find useful. These range
  from PCMCIA Ethercard drivers to programs that communicate with the
  PCMCIA controller chip. Note that these drivers are usually tied to a
  specific PCMCIA chip (ie. the intel 82365 or the TCIC/2)

  For NE2000 compatible cards, some people have had success with just
  configuring the card under DOS, and then booting linux from the DOS
  command prompt via loadlin.

  For those that are net-surfing you can try:

  Don's PCMCIA Stuff (http://cesdis.gsfc.nasa.gov/linux/pcmcia.html)

  Anyway, the PCMCIA driver problem isn't specific to the Linux world.
  It's been a real disaster in the MS-DOS world. In that world people
  expect the hardware to work if they just follow the manual.  They
  might not expect it to interoperate with any other hardware or
  software, or operate optimally, but they do expect that the software
  shipped with the product will function. Many PCMCIA adaptors don't
  even pass this test.

  Things are looking up for Linux users that want PCMCIA support, as
  substantial progress is being made. Pioneering this effort is David
  Hinds.


  7.4.  ISA Ethercard in the Docking Station.


  Docking stations for laptops typically cost about $250 and provide two
  full-size ISA slots, two serial and one parallel port. Most docking
  stations are powered off of the laptop's batteries, and a few allow
  adding extra batteries in the docking station if you use short ISA
  cards. You can add an inexpensive ethercard and enjoy full-speed
  ethernet performance.


  7.5.  Pocket / parallel port adaptors.


  The `pocket' ethernet adaptors may also fit your need.  Until recently
  they actually costed more than a docking station and cheap ethercard,
  and most tie you down with a wall-brick power supply.  At present, you
  can choose from the D-Link, or the RealTek adaptor.  Most other
  companies, especially Xircom, (see ``Xircom'') treat the programming
  information as a trade secret, so support will likely be slow in
  coming. (if ever!)

  Note that the transfer speed will not be all that great (perhaps
  100kB/s tops?) due to the limitations of the parallel port interface.

  See ``DE-600 / DE-620'' and ``RealTek'' for supported pocket adaptors.

  You can sometimes avoid the wall-brick with the adaptors by buying or
  making a cable that draws power from the laptop's keyboard port. (See
  ``keyboard power'')
  8.  Frequently Asked Questions


  Here are some of the more frequently asked questions about using Linux
  with an Ethernet connection. Some of the more specific questions are
  sorted on a `per manufacturer basis'.  However, since this document is
  basically `old' by the time you get it, any `new' problems will not
  appear here instantly. For these, I suggest that you make efficient
  use of your newsreader. For example, nn users would type


       nn -xX -s'3c'


  to get all the news articles in your subscribed list that have `3c' in
  the subject. (ie. 3com, 3c509, 3c503, etc.)  The moral: Read the man
  page for your newsreader.


  8.1.  Alpha Drivers -- Getting and Using them


  I heard that there is an alpha driver available for my card.  Where
  can I get it?

  The newest of the `new' drivers can be found on Donald's new ftp site:
  cesdis.gsfc.nasa.gov in the /pub/linux/ area. Things change here quite
  frequently, so just look around for it.  There is still all the stuff
  on the old ftp site ftp.super.org in /pub/linux, but this is not being
  actively maintained, and hence will be of limited value to most
  people.

  As of recent v1.1 kernels, the `useable' alpha drivers have been
  included in the standard kernel source tree. When running make config
  you will be asked if you want to be offered ALPHA test drivers.

  Now, if it really is an alpha, or pre-alpha driver, then please treat
  it as such. In other words, don't complain because you can't figure
  out what to do with it. If you can't figure out how to install it,
  then you probably shouldn't be testing it.  Also, if it brings your
  machine down, don't complain. Instead, send us a well documented bug
  report, or even better, a patch!

  People reading this while net-surfing may want to check out:

  Don's Linux Home Page
  (http://cesdis.gsfc.nasa.gov/pub/linux/linux.html)

  for the latest dirt on what is new and upcoming.


  8.2.  Using More than one Ethernet Card per Machine


  What needs to be done so that Linux can run two ethernet cards?

  The hooks for multiple ethercards are all there.  You can enable
  additional ethercards with LILO parameters such as:


       LILO: linux ether=5,0x300,0,1,eth0 ether=15,0x280,eth1


  These boot time arguments can be made permanent so that you don't have
  to re-enter them every time. See the LILO manual, and ``Passing
  Ethernet Arguments...''  where there are tips on using LILO to pass
  boot-time ethernet card arguments.

  Also note that only *one* ethercard is auto-probed for, and the second
  *must* be specified as above.  This avoids a lot of possible boot time
  hangs caused by probing sensitive cards. Probing for the second card
  can be achieved by using something as simple as ether=0,0,eth1. In
  this case eth0 and eth1 will be assigned in the order that the cards
  are found at boot. With the previous example, the user has forced the
  card at 0x300 to be eth0 and the card at 0x280 to be eth1.

  Note that if you are intending to use Linux as a gateway between two
  networks, you will have to re-compile a kernel with IP forwarding
  enabled. Usually using an old AT/286 with something like the `kbridge'
  software is a better solution.

  If you are viewing this while net-surfing, you may wish to look at a
  mini-howto Donald has on his WWW site. Check out Multiple Ethercards
  (http://cesdis.gsfc.nasa.gov/linux/misc/multicard.html).


  8.3.  Problems with NE1000 / NE2000 cards (and clones)

  Problem: Errors like DMA address mismatch

  Is the chip a real NatSemi 8390? (DP8390, DP83901, DP83902 or
  DP83905)?  If not, some clone chips don't correctly implement the
  transfer verification register. MS-DOS drivers never do error
  checking, so it doesn't matter to them.

  Are most of the messages off by a factor of 2?  If so:  Are you using
  the NE2000 in a 16 bit slot?  Is it jumpered to use only 8 bit
  transfers?

  The Linux driver expects a NE2000 to be in a 16 bit slot. A NE1000 can
  be in either size slot. This problem can also occur with some clones,
  notably D-Link 16 bit cards, that don't have the correct ID bytes in
  the station address PROM. (This should be fixed in pl12.)

  Are you running the bus faster than 8Mhz?  If you can change the speed
  (faster or slower), see if that makes a difference. Most NE2000 clones
  will run at 16MHz, but some may not. Changing speed can also mask a
  noisy bus.

  What other devices are on the bus?  If moving the devices around
  changes the reliability, then you have a bus noise problem -- just
  what that error message was designed to detect. Congratulations,
  you've probably found the source of other problems as well.

  Problem: The machine hangs during boot right after the `8390...'  or
  `WD....' message. Removing the NE2000 fixes the problem.

  Solution: Change your NE2000 base address to 0x360 (or 0x340 for pl12
  or later kernels.) Alternatively, you can use the new device registrar
  implemented in pl13

  Reason: Your NE2000 clone isn't a good enough clone. An active NE2000
  is a bottomless pit that will trap any driver autoprobing in its
  space. The other ethercard drivers take great pain to reset the NE2000
  so that it's safe, but some clones cannot be reset. Clone chips to
  watch out for: Winbond 83C901. Changing the NE2000 to a less-popular
  address will move it out of the way of other autoprobes, allowing your
  machine to boot.


  Problem: The machine hangs during the SCSI probe at boot.

  Reason: It's the same problem as above, change the ethercard's
  address, or use the device registrar.

  Problem: The machine hangs during the soundcard probe at boot.

  Reason: No, that's really during the silent SCSI probe, and it's the
  same problem as above.

  Problem: Errors like eth0: DMAing conflict in ne_block_input

  This bug came from timer-based packet retransmissions. If you got a
  timer tick _during_ a ethercard RX interrupt, and timer tick tried to
  retransmit a timed-out packet, you could get a conflict. Because of
  the design of the NE2000 you would have the machine hang (exactly the
  same the NE2000-clone boot hangs).

  Early versions of the driver disabled interrupts for a long time, and
  didn't have this problem. Later versions are fixed. (ie. kernels after
  0.99p9 should be OK.)

  Problem: NE2000 not detected at boot.

  Donald writes: `A few people have reported a problem with detecting
  the Accton NE2000.  This problem occurs only at boot-time, and the
  card is later detected at run-time by the identical code my (alpha-
  test) ne2k diagnostic program. Accton has been very responsive, but I
  still haven't tracked down what is going on. I've been unable to
  reproduce this problem with the Accton cards we purchased. If you are
  having this problem, please send me an immediate bug report. For that
  matter, if you have an Accton card send me a success report, including
  the type of the motherboard. I'm especially interested in finding out
  if this problem moves with the particular ethercard, or stays with the
  motherboard.'

  Here are some things to try, as they have fixed it for some people:


  o  Change the bus speed, or just move the card to a different slot.

  o  Change the `I/O recovery time' parameter in the BIOS chipset
     configuration.

  Problem: Network `goes away' every time I print something (NE2000)

  Reason: You have your NE2000 living at 0x360, and a NE2000 is 0x20
  ports wide, putting it to 0x380. Your parallel port is at 0x378 and is
  stepping on the NE2000 cards I/O space.  Jumper it to 0x300 or 0x340
  or something like that.


  8.4.  Problems with WD80*3 cards


  Problem: A WD80*3 is falsely detected. Removing the sound or MIDI card
  eliminates the `detected' message.

  Reason: Some MIDI ports happen to produce the same checksum as a WD
  ethercard.

  Solution: Update your ethercard driver: new versions include an
  additional sanity check. If it is the midi chip at 0x388 that is
  getting detected as a WD living at 0x380, then you could also use:

          LILO: linux reserve=0x380,8


  Problem: You get messages such as the following with your 80*3:


       eth0: bogus packet size, status = ........  kmalloc called with impos-
       sibly large argument (65400) eth0: Couldn't allocate sk_buff of size
       65400 eth0: receiver overrun


  Reason: There is a shared memory problem.

  Solution: If the problem is sporadic, you have hardware problems.
  Typical problems that are easy to fix are board conflicts, having
  cache or `shadow ROM' enabled for that region, or running your bus
  faster than 8Mhz. There are also a surprising number of memory
  failures on ethernet cards, so run a diagnostic program if you have
  one for your ethercard.

  If the problem is continual, and you have have to reboot to fix the
  problem, record the boot-time probe message and mail it to
  becker@cesdis.gsfc.nasa.gov - Take particular note of the shared
  memory location.

  Problem: WD80*3 will not get detected at boot.

  Reason: The Mitsumi CD-ROM (mcd) driver probe at 0x300 will succeed if
  just about *anything* is that I/O location.  This is bad news and
  needs to be a bit more robust. (pl15) Once another driver registers
  that it `owns' an I/O location, other drivers (incl. the wd80x3) are
  `locked out' and can not probe that addr for a card.

  Solution: Recompile a new kernel without any excess drivers that you
  aren't using, including the above mcd driver.  Or try moving your
  ethercard to a new I/O addr. Valid I/O addr. for all the cards are
  listed in ``Probed Addresses'' You can also point the mcd driver off
  in another direction by a boot-time parameter (via LILO) such as:

       mcd=0x200,12



  8.5.  Problems with 3Com cards

  Problem: The 3c503 picks IRQ n at boot, but this is needed for some
  other device which needs IRQ n. (eg. CD ROM driver, etc.)  Can this be
  fixed without compiling this into the kernel?

  Solution: The 3c503 driver probes for a free IRQ line in the order {5,
  9/2, 3, 4}, and it should pick a line which isn't being used. The pre-
  pl12 (SLS 1.02) driver picked the IRQ line at boot-time, and the
  current driver (pl12) chooses when the card is open()/ifconfig'ed.

  Alternately, you can fix the IRQ at boot by passing parameters via
  LILO. The following selects IRQ9, base location 0x300, <ignored
  value>, and if_port #1 (the external transceiver).


       LILO: linux ether=9,0x300,0,1,eth0


  The following selects IRQ3, probes for the base location, <ignored
  value>, and the default if_port #0 (the internal transceiver)


       LILO: linux ether=3,0,0,0,eth0


  Problem: 3c503: Configured interrupt number XX is out of range.

  Reason: Whoever built your kernel fixed the ethercard IRQ at XX.  The
  above is truly evil, and worse than that, it is not necessary. The
  3c503 will autoIRQ when it gets ifconfig'ed, and pick one of IRQ{5,
  2/9, 3, 4}.

  Solution: Use LILO as described above, or rebuild the kernel, enabling
  autoIRQ by not specifying the IRQ line.

  Problem: The supplied 3c503 drivers don't use the AUI (thicknet) port.
  How does one choose it over the default thinnet port?

  Solution: The 3c503 AUI port can be selected at boot-time with
  0.99pl12 and later. The selection is overloaded onto the low bit of
  the currently-unused dev->rmem_start variable, so a boot-time
  parameter of:


       LILO: linux ether=0,0,0,1,eth0


  should work. A boot line to force IRQ 5, port base 0x300, and use an
  external transceiver is:


       LILO: linux ether=5,0x300,0,1,eth0


  Also note that kernel revisions 1.00 to 1.03 had an interesting
  `feature'. They would switch to the AUI port when the internal
  transciever failed. This is a problem, as it will *never* switch back
  if for example you momentarily disconnect the cable. Kernel versions
  1.04 and newer only switch if the very first Tx attempt fails.


  8.6.  Problems with Hewlett Packard Cards


  Problem: HP Vectra using built in AMD LANCE chip gets IRQ and DMA
  wrong.

  Solution: The HP Vectra uses a different implementation to the
  standard HP-J2405A. The `lance.c' driver used to always use the value
  in the setup register of an HP Lance implementation.  In the Vectra
  case it's reading an invalid 0xff value. Kernel versions newer than
  about 1.1.50 now handle the Vectra in an appropriate fashion.

  Problem: HP Card is not detected at boot, even though kernel was
  compiled with `HP PCLAN support'.

  Solution: You probably have a HP PCLAN+  -- note the `plus'. Support
  for the PCLAN+ was added to final versions of 1.1, but some of them
  didn't have the entry in `config.in'. If you have the file hp-plus.c
  in  /linux/drivers/net/ but no entry in config.in, then add the
  following line under the `HP PCLAN support' line:


          bool 'HP PCLAN Plus support' CONFIG_HPLAN_PLUS n



  Kernels up tp 1.1.54 are missing the line in `config.in' still.  Do a
  `make mrproper;make config;make dep;make zlilo' and you should be in
  business.

  8.7.  FAQs Not Specific to Any Card.




  8.7.1.  Token Ring

  Is there token ring support for Linux?

  To support token ring requires more than only a writing a device
  driver, it also requires writing the source routing routines for token
  ring. It is the source routing that would be the most time comsuming
  to write.

  Alan Cox adds: `It will require (...) changes to the bottom socket
  layer to support 802.2 and 802.2 based TCP/IP. Don't expect anything
  soon.'

  Peter De Schrijver has been spending some time on Token Ring lately,
  and has patches that are available for IBM ISA and MCA token ring
  cards. Don't expect miracles here, as he has just started on this as
  of 1.1.42. You can get the patch from:

  aix13ps2.cc.kuleuven.ac.be:/pub/Linux/TokenRing.patch-1.1.49.gz



  8.7.2.  32 Bit / VLB / PCI Ethernet Cards


  What is the selection for 32 bit ethernet cards?

  There aren't many 32 bit ethercard device drivers because there aren't
  that many 32 bit ethercards.

  There aren't many 32 bit ethercards out there because a 10Mbs network
  doesn't justify spending the 5x price increment for the 32 bit
  interface.  See ``Programmed I/O vs. ...'' as to why having an
  ethercard on an 8MHz ISA bus is really not a bottleneck.

  This might change now that AMD has introduced the 32 bit PCnet-VLB and
  PCnet-PCI chips.  The street price of the Boca PCnet-VLB board should
  be under $70 from a place like CMO (see Computer Shopper).  See ``Boca
  PCI/VLB'' for info on these cards.

  See ``AMD PCnet-32'' for info on the 32 bit versions of the LANCE /
  PCnet-ISA chip.

  In the future, the DEC 21040 PCI chip will probably be supported as
  well, but don't hold your breath.


  8.7.3.  FDDI

  Is there FDDI support for Linux?

  Donald writes: `No, there is no Linux driver for any FDDI boards.  I
  come from a place with supercomputers, so an external observer might
  think FDDI would be high on my list. But FDDI never delivered end-to-
  end throughput that would justify its cost, and it seems to be a
  nearly abandoned technology now that 100base{X,Anynet} seems imminent.
  (And yes, I know you can now get FDDI boards for <$1K. That seems to
  be a last-ditch effort to get some return on the development
  investment. Where is the next generation of FDDI going to come from?)'


  8.7.4.  Linking 10BaseT without a Hub


  Can I link 10BaseT (RJ45) based systems together without a hub?

  You can link 2 machines easily, but no more than that, without extra
  devices/gizmos. See ``Twisted Pair'' -- it explains how to do it. And
  no, you can't hack together a hub just by crossing a few wires and
  stuff. It's pretty much impossible to do the collision signal right
  without duplicating a hub.


  8.7.5.  SIOCSFFLAGS: Try again


  I get `SIOCSFFLAGS: Try again' when I run `ifconfig' -- Huh?

  Some other device has taken the IRQ that your ethercard is trying to
  use, and so the ethercard can't use the IRQ.  You don't necessairly
  need to reboot to resolve this, as some devices only grab the IRQs
  when they need them and then release them when they are done. Examples
  are some sound cards, serial ports, floppy disk driver, etc. You can
  type cat /proc/interrupts to see which interrupts are presently in
  use. Those marked with a `+' are ones that are not taken on a
  permanent basis. Most of the Linux ethercard drivers only grab the IRQ
  when they are opened for use via `ifconfig'. If you can get the other
  device to `let go' of the required IRQ line, then you should be able
  to `Try again' with ifconfig.


  8.7.6.  Link UNSPEC and HW-addr of 00-00-00-00-00-00


  When I run ifconfig with no arguments, it reports that LINK is UNSPEC
  (instead of 10Mbs Ethernet) and it also says that my hardware address
  is all zeros.

  This is because people are running a newer version of the `ifconfig'
  program than their kernel version. This new version of ifconfig is not
  able to report these properties when used in conjunction with an older
  kernel. You can either upgrade your kernel, `downgrade' ifconfig, or
  simply ignore it. The kernel knows your hardware address, so it really
  doesn't matter if ifconfig can't read it.


  8.7.7.  Huge Number of RX and TX Errors


  When I run ifconfig with no arguments, it reports that I have a huge
  error count in both rec'd and transmitted packets. It all seems to
  work ok -- What is wrong?

  Look again. It says RX packets big number PAUSE errors 0 PAUSE dropped
  0 PAUSE overrun 0.  And the same for the TX column.  Hence the big
  numbers you are seeing are the total number of packets that your
  machine has rec'd and transmitted.  If you still find it confusing,
  try typing cat /proc/net/dev instead.


  8.7.8.  Entries in /dev/ for Ethercards


  I have /dev/eth0 as a link to /dev/xxx. Is this right?

  Contrary to what you have heard, the files in /dev/* are not used.
  You can delete any /dev/wd0, /dev/ne0 and similar entries.
  8.7.9.  Linux and ``trailers''


  Should I disable trailers when I `ifconfig' my ethercard?

  You can't disable trailers, and you shouldn't want to. `Trailers' are
  a hack to avoid data copying in the networking layers. The idea was to
  use a trivial fixed-size header of size `H', put the variable-size
  header info at the end of the packet, and allocate all packets packets
  `H' bytes before the start of a page. While it was a good idea, it
  turned out to not work well in practice.  If someone suggests the use
  of `-trailers', note that it is the equivalent of sacrificial goats
  blood. It won't do anything to solve the problem, but if problem fixes
  itself then someone can claim deep magical knowledge.


  9.  Miscellaneous.


  Any other associated stuff that didn't fit in anywhere else gets
  dumped here. It may not be relevant, and it may not be of general
  interest but it is here anyway.


  9.1.  Passing Ethernet Arguments to the Kernel via LILO


  Here are two generic kernel commands that would be typed after the
  name of your configuration in your lilo.conf file (usually `linux')
  For exmaple, if the command was `blah' and it expected 3 arguments
  (say 123, 456, and 789) then you would use:

  LILO: linux blah=123,456,789


  9.1.1.  The ether command


  In its most generic form, it looks something like this:


       ether=IRQ,BASE_ADDR,PARAM_1,PARAM_2,NAME


  All arguments are optional.  The first non-numeric argument is taken
  as the NAME.

  IRQ: Obvious.  An IRQ value of `0' (usually the default) means to
  autoIRQ.  It's a historical accident that the IRQ setting is first
  rather than the base_addr -- this will be fixed whenever something
  else changes.

  BASE_ADDR: Also obvious.  A value of `0' (usually the default) means
  to probe a card-type-specific address list for an ethercard.

  PARAM_1: It was orginally used as an override value for the memory
  start for a shared-memory ethercard, like the WD80*3.  Some drivers
  use the low four bits of this value to set the debug message level.  0
  -- default, 1-7 -- level 1..7, (7 is maximum verbosity)  8 -- level 0
  (no messages).

  PARAM_2: The 3c503 driver uses this select between the internal and
  external transceivers.  0 -- default/internal, 1 -- AUI external.

  NAME: Selects the network device the values refer to.  The standard
  kernel uses the names `eth0', `eth1', `eth2' and `eth3' for bus-
  attached ethercards, and `atp0/dl0' for parallel port `pocket'
  ethernet adaptors.  The default setting is for a single ethercard to
  be probed for as `eth0'.  Multiple cards can only be enabled by
  explicitly setting up their base address using these LILO parameters.
  The 1.0 kernel has LANCE-based ethercards as a special case.  LILO
  arguments are ignored, and LANCE cards are always assigned `eth<n>'
  names starting at `eth0'.  Additional non-LANCE ethercards must be
  explicitly assigned to `eth<n+1>', and the usual `eth0' probe disabled
  with something like  `ether=0,-1,eth0'.  ( Yes, this is bug. )


  9.1.2.  The reserve command


  This next lilo command is used just like `ether=' above, ie. it is
  appended to the name of the boot select specified in lilo.conf


       reserve=IO-base,extent{,IO-base,extent...}


  In some machines it may be necessary to prevent device drivers from
  checking for devices (auto-probing) in a specific region. This may be
  because of poorly designed hardware that causes the boot to freeze
  (such as some ethercards), hardware that is mistakenly identified,
  hardware whose state is changed by an earlier probe, or merely
  hardware you don't want the kernel to initialize.

  The reserve boot-time argument addresses this problem by specifying an
  I/O port region that shouldn't be probed. That region is reserved in
  the kernel's port registration table as if a device has already been
  found in that region. Note that this mechanism shouldn't be necessary
  on most machine, only when there is a problem or special case.

  The I/O ports in the specified region are protected against device
  probes. This was put in to be used when some driver was hanging on
  e.g. a NE2000, or misidentifying some other device as its own.  A
  correct device driver shouldn't probe a reserved region, unless
  another boot argument explicitly specifies that it do so.  This
  implies that reserve will most often be used with some other boot
  argument. Hence if you specify a reserve region to protect a specific
  device, you must generally specify an explicit probe for that device.
  Most drivers ignore the port registration table if they are given an
  explicit address.

  For example, the boot line


       LILO: linux  reserve=0x300,32  ether=0,0x300,eth0


  keeps all device drivers except the ethercard drivers from probing
  0x300-0x31f.

  As usual with boot-time specifiers there is an 11 parameter limit,
  thus you can only specify 5 reserved regions per reserve keyword.
  Multiple reserve specifiers will work if you have an usually
  complicated request.


  9.2.  Contributors


  Other people who have contributed (directly or indirectly) to the
  Ethernet-Howto are, in alphabetical order:

          Peter Bauer             <pbauer@rnivh.rni.sub.org>
          Ross Biro               <bir7@leland.Stanford.EDU>
          Alan Cox                <iiitac@pyr.swan.ac.uk>
          David C. Davies         <davies@wanton.enet.dec.com>
          Bjorn Ekwall            <bj0rn@blox.se>
          David Hinds             <dhinds@allegro.stanford.edu>
          Michael Hipp            <mhipp@student.uni-tuebingen.de>
          Mike Jagdis             <jaggy@purplet.demon.co.uk>
          Duke Kamstra            <kamstra@ccmail.west.smc.com>
          Russell Nelson          <nelson@crynwr.com>
          Cameron Spitzer         <camerons@NAD.3Com.com>
          Dave Roberts            <david.roberts@amd.com>
          Glenn Talbott           <gt@hprnd.rose.hp.com>




  Many thanks to the above people, and all the other unmentioned testers
  out there.


  9.3.  Closing


  If you have found any glaring typos, or outdated info in this
  document, please let one of us know. It's getting big, and it is easy
  to overlook stuff.

  Thanks,

  Paul Gortmaker, Paul.Gortmaker@anu.edu.au

  Donald J. Becker, becker@cesdis.gsfc.nasa.gov


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1994-11-18 17:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1994-01-25  4:24 Linux Ethernet HOWTO (Part 2/2) Paul Gortmaker
  -- strict thread matches above, loose matches on Subject: below --
1994-11-18 17:03 Linux Ethernet HOWTO (part 1/2) Paul Gortmaker
1994-11-18 17:05 ` Linux Ethernet HOWTO (part 2/2) Paul Gortmaker
1994-04-25 19:39 Linux Ethernet HOWTO (part 1/2) Paul Gortmaker
1994-04-25 19:40 ` Linux Ethernet HOWTO (part 2/2) Paul Gortmaker
1994-03-16  5:27 Linux Ethernet HOWTO (Part 2/2) Paul Gortmaker
1993-12-15 22:08 Paul Gortmaker
1993-11-17  4:22 Paul Gortmaker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox