Subject: Re: VS3100 memory quirk
To: David Brownlee <abs@anim.dreamworks.com>
From: Bertram Barth <bertram@ifib.uni-karlsruhe.de>
List: port-vax
Date: 01/14/1998 11:13:24
> > > 	The network controller on the VS3100 can only access 16MB of
> > > 	memory (the first 16MB in the machine). I believe NetBSD maps the
> > > 	buffers for the card at the top of memory, which obviously causes
> > > 	problems for machines with more than 16MB. 
> > 
> > Argh. This would seem a bit more tricky to deal with.  (I need to remember
> > to grep the archives prior to opening my keyboard).  Is it that the kernel
> > by design locates buffers in high memory, or does one have flexibility in
> > where you locate them?  I guess my question is, does NetBSD have the
> > facilities to allocate buffers in physical memory where you please?  If
> > not, how do you get around this problem? 
> > 
> 	The kernel could allocate the buffers anywhere it chooses... :)
> 	It may have been cleaner or easier to allocate the buffers at the
> 	top of memory.

There are two things to mention; first there's quite a difference between
the kernel-drivers and the standalone-drivers. The netboot-problems are
caused by the standalone-driver which tries to access the lance's address-
space via physical memory. Since the driver itself has no clue about the
amount of physically avalable memory it just tries to setup the lance 
for using lower 16MB of memory. It seems that there are some problems
in that which causes machines with more the 16MB to fail. I could never
check this by myself since mine has exactly 16MB. Second is that quite
a bunch of problems arises from using virtual memory for talking with
the lance, since the different models need to behave different when 
talking to the lance.

> 	Hmm.. from a quick browse of /sys/arch/vax/ka43.c
> 	ka43_steal_pages() steals 64k from the top of available memory for
> 	the LANCE's (VS3100 ethernet chip) buffers. It has a note that if
> 	the address is over 16MB to set the 'LANCE DMA' bit which is used
> 	as an extra address bit, which _should_ mean it would work with up
> 	to 32MB, but still fail with more....

Once again, I couldn't check this; but I think there's quite a good
chance the kernel-driver works with more than 16MB once the kernel has 
been loaded. But here again the standalone-driver used for net-boot 
currently prevents checking this on machines with more than 16MB.
[Or is there anybody out there who has more than 16MB in an 3100/76
and doesn't netboot for getting the OS running?]

> 	I would be inclined to try modifying to code to steal the pages
> 	from avail_start rather than avail_end (there _has_ to be a reason
> 	why its not just that easy :), but I'm still not able to get my
> 	VS3100 running - I now have a serial cable from Brian (Thanks
> 	Brian!), but I've found out my genuine VT240 is a genuine non
> 	working VT240.. grr.. I'm sure I have a breakout cable for the
> 	serial port on my IPX, so I'm not beaten yet :)

For similiar reasons I once tried to use avail_start instead of avail_end,
but for unclear reasons the driver failed and I just went back to the
working solution. I've some assumptions but I really don't know:
- IIRC some page on top of physical memory are used by console-ROM and
  other "built-in" things, thus they shouldn't be used by the OS and
  are thus reserved by making them invisible.
- the RAM area used to communicate with the LANCE needs proper alignment
  at it's physical location, and by decreasing avail_end the kernel just
  doesn't know about the existence of this area which is OK.
- and BTW all model-specific init-routines reserve some space at top
  of physical memory where at least I don't know how much is neccessary
  and what it's needed for. Thus reserving 8K for whatever and another
  8K for the lance seems to be a save bet which shouldn't break anything.

One last remark on different lance communication for different models:
All I have and thus could check on is VS2000 and VS3100/76 and these
two behave different. On the KA410 the communication with lance via 
physical/virtual addresses works as one would expect, while on KA43
the shared area needs to be accessed via "diagnostic memory" addresses
which are just another address-range for the same physical address.
For all other models I don't have a clue if they behave more like
the KA410 or more like the KA43 or completely different. Thus people
with access to other models need to check how to access this area
and IMHO this is the single critical point which prevents lance from
working on the not-yet-supported 3100's...

Ciao,
	bertram

PS: AFAIK 3100/76 can't have more than 32MB.