Subject: LANCE driver reorganization
To: None <tech-kern@NetBSD.ORG>
From: Matthias Drochner <drochner@zelux6.zel.kfa-juelich.de>
List: tech-kern
Date: 07/21/1998 00:20:51
I'd like to make the LANCE driver aware of the
32-bit addressing modes which are implemented
in the 79c9xx chips.
This would not only allow me to drop my private
driver for the 79c900 "ILACC" (which doesn't
have the compatibility mode, so it _must_ be controlled
by a 32-bit aware driver). It would also fix some
slight brokeness in the PCNET/PCI driver (it doesn't
catch the case where the DMA buffer crosses a 16M
boundary).

It's of course desirable to share as much code as possible
between the 24-bit and the 32-bit drivers. Otoh, the
le driver is widely used, so there is some chance to
break thinks...

Here is my roadmap:

1. Split am7990.c into a bitness dependant and an independant
  part; lets call the independant part "lance" for now. (It's
  not too exact - it should include "ilacc" and "pcnet" -
  better ideas are welcome. Put the 32bit part into a new file
  "am79900".

2. Invent 2 new "config" attributes and use them to select
  source files for 32bit / 24bit / common parts:
[in sys/conf/files]
# LANCE and PCnet Ethernet controllers
device	le: arp, ether, ifnet
define le24
define le32
file	dev/ic/am7990.c		le24
file	dev/ic/am79900.c		le32
file	dev/ic/lance.c			le24 | le32

  Add them to the attachments as appropriate:
[dev/pci/files.pci]
# AMD am7990 (LANCE) -based Ethernet controllers
# device declaration in sys/conf/files
attach	le at pci with le_pci: le32
file	dev/pci/if_le_pci.c		le_pci

3. Put all the common software state into a "struct lance_softc".
  The "am7990_softc" would then look like:
struct am7990_softc {
	struct lance_softc lsc;
	/* specific parts */
};
  The frontents would then include "am7990_softc" as before
  as first member into their "softc" structures.
  Changes to pointer types would be necessary where
  shared code is referred to, and the new common headers
  would have to be included.


So what do you think about it?

best regards
Matthias