Home | History | Annotate | Download | only in ic
History log of /src/sys/dev/ic/ne2000.c
RevisionDateAuthorComments
 1.79  21-May-2024  andvar nix extra whitespace.
 1.78  21-May-2024  andvar s/amout/amount/ in comments.
 1.77  20-Aug-2021  andvar fix various typos in comments and log messages.
 1.76  27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.75  15-Jul-2018  maxv Retire ipkdb entirely. The option was removed from the config files
yesterday.

ok kamil christos
 1.74  11-Aug-2013  rkujawa branches: 1.74.28; 1.74.30;
Add support for AX88796(B) variant.
 1.73  27-Oct-2012  chs branches: 1.73.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.72  29-Mar-2010  tsutsui branches: 1.72.8; 1.72.18;
Don't warn about DMA timeout during probe.
 1.71  19-Mar-2010  tsutsui No need to override mem_ring value in ne2000_ipkdb_attach()
since a wrong calculation in dp8390_ipkdb_attach() was fixed.
 1.70  13-Mar-2010  tsutsui branches: 1.70.2;
- make local functions static
- const'ify
 1.69  13-Mar-2010  tsutsui Misc KNF.
 1.68  03-Mar-2010  tsutsui Put several fixes to ne(4) driver for better 8 bit mode support,
especially on RTL8019AS which is also used for non-ISA local bus of
embedded controllers and some m68k machines like atari and x68k.

* move RTL8019 probe and attach code from each bus attachment
to MI ne2000_detect() and ne2000_attach()
* change a method for backend and attachment to specify 8 bit mode
to use a new sc->sc_quirk member, instead of sc->sc_dmawidth
* handle more NE2000 8 bit mode specific settings, including
bus_space(9) access width and available size of buffer memory
* add a function to detect NE2000 8 bit mode
(disabled by default, but enalbed by options NE2000_DETECT_8BIT
to avoid possible regression on various ISA clones)
* fix ipkdb attachment accordingly (untested)

Tested on two NE2000 ISA variants (RTL8019AS and another clone named UL0001)
in both 8 bit and 16 bit mode on i386. "Looks good" from nonaka@.

See my post on tech-kern for details:
http://mail-index.NetBSD.org/tech-kern/2010/02/26/msg007423.html
 1.67  24-Feb-2010  dyoung A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.66  24-Feb-2010  tsutsui Use roundup2() in <sys/param.h> rather than a conditional.
 1.65  24-Feb-2010  tsutsui Now dp8390_config() calculates mem_ring correctly so
no longer need to override it in ne2000_attach().
 1.64  08-Jan-2010  dyoung branches: 1.64.2;
Expand PMF_FN_* macros.
 1.63  02-Jan-2010  christos nothing uses ne2000_power anymore.
 1.62  05-May-2009  nonaka Added NE2000 with 8bit bus width support.
reviewd by tsutsui@ at tech-kern ML.
 1.61  05-Apr-2009  uwe Provide pmf(9) hooks that do what dopowerhooks(9) hook does.

XXX: Do NOT call pmf_class_network_register() yet, b/c db8320.c
doesn't provide if_stop method!
 1.60  14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.59  28-Apr-2008  martin branches: 1.59.8; 1.59.10; 1.59.14;
Remove clause 3 and 4 from TNF licenses
 1.58  08-Apr-2008  cegger branches: 1.58.2; 1.58.4;
use aprint_*_dev and device_xname
 1.57  12-Mar-2008  cube Split device_t and softc for the NE2000 Ethernet chip and all its variants
and attachments. Use device_t accessors, correct types, and ANSIfy when
appropriate.
 1.56  09-Mar-2008  dholland Use NE2000_TYPE_UNKNOWN instead of just 0 in a couple places.
 1.55  19-Oct-2007  ad branches: 1.55.12; 1.55.16;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.54  04-Mar-2007  christos branches: 1.54.2; 1.54.14; 1.54.16; 1.54.20;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.53  13-Jan-2007  cube branches: 1.53.2;
Make the IPKDB code compile.
 1.52  16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.51  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.50  11-Jul-2006  peter branches: 1.50.4; 1.50.6;
Add power hooks for "ne* at pcmcia?".

ok christos@
 1.49  21-May-2006  christos branches: 1.49.2;
void casts to functions whose return values are ignored.
 1.48  29-Jan-2006  dsl branches: 1.48.2; 1.48.4; 1.48.6; 1.48.10; 1.48.12;
Make almost everything #include <sys/bswap.h> instead of <machine/bswap.h>
The bswap.h and endian.h files are all rather incestuous, but I want to
get the constant folding stuff into one place - sys/bswap.h
 1.47  11-Dec-2005  christos branches: 1.47.2;
merge ktrace-lwp.
 1.46  26-Feb-2005  bsh branches: 1.46.4;
ASIX AX88796 is an NE2000 compatible ethernet chip, but doesn't seem to
have "remote DMA complete bit" is ISR. So, don't wait for ISR.RDC bit
after writing a packet.
 1.45  04-Feb-2005  perry de-__P
 1.44  09-Aug-2004  mycroft branches: 1.44.4; 1.44.6;
Do barriers on the ASIC space without touching the NIC space.
 1.43  04-Jul-2004  mycroft Fix a bug in the packet "padding" code. If we're padding a packet with an odd
size, we were writing out too much data, possibly causing the chip to lock up.
 1.42  17-Mar-2004  mycroft branches: 1.42.2;
A random patch that's been in my source tree...
Figure out whether the shared memory region is word-accessible in the same
place we figure out its size, and store this in the softc, rather than using a
series of comparisons later.
 1.41  02-Nov-2003  wiz Fix some typos. From Tom Cosgrove via jmc@openbsd.
 1.40  25-Oct-2003  christos Fix uninitialized variable warnings
 1.39  22-Oct-2003  christos support for NE2000_TYPE_AX88790 from
Yong-Jhen Hong yongjhen at alqualonde dot org
 1.38  15-Jan-2003  bouyer branches: 1.38.2;
Zero out the NIC memory when padding packet to ETHER_MIN_LEN-ETHER_CRC_LEN
sc->write_mbuf now return len of buffer, including padding.
Tested with a PCI ne2000.
 1.37  13-Nov-2001  lukem branches: 1.37.10;
add/cleanup RCSID
 1.36  04-Aug-2001  enami MII access routines for ASIX AX88190.
 1.35  07-Jul-2001  thorpej branches: 1.35.2;
bcopy -> memcpy
 1.34  07-Jul-2001  thorpej bcmp -> memcmp
 1.33  05-Jun-2001  thorpej Handle the DL10022 case.
 1.32  12-Feb-2001  thorpej branches: 1.32.2;
Adjust the way that media is initialized on DP8390-compatible
chips. The dp8390_softc now has media_init and media_fini
function pointers that do the work.
 1.31  11-Dec-2000  ws Fix the previous differently:
The intent was to protect the full range of ports on the board by the
barriers. But the start address was wrong. Fix it.

While here, change two other barriers to also protect the full range
(not only the nic ports), and add yet another similar barrier.
 1.30  03-Dec-2000  jlam Set range of memory protected by read/write bus space barriers to the
correct size, instead of extending past the mapped region.
 1.29  22-Mar-2000  ws Make IPKDB working again.
Add support for i386 debugging and pci-based ne2000 boards.
 1.28  22-Mar-2000  ws Add bus_space_barrier.
Add DELAY in some busy loops to allow the dma engine to actually do something
(neccessary on fast processors).
 1.27  09-Feb-2000  enami ASIX AX88190 support (Planex FNW-3700-T and Melco LPC3-TX) from FreeBSD/PAO3.
 1.26  09-Feb-2000  enami - Since all resources are mandatory, no need to manage individually.
- KNF some code.
- Factor out some code into function.
- Disestablish an interrupt handler when failed to enable card power.
 1.25  02-Feb-2000  itojun use a bit more standard (sys/device.h) prototype for {dp8390,ne2000}_detach().
 1.24  02-Feb-2000  itojun implement if_detach code for ne/pcmcia.
XXX still incomplete, ne_pcmcia_detach() commented out for safery - please test
 1.23  27-Sep-1999  enami branches: 1.23.2;
Support Planex Communications Inc, FNW-3600-T.
 1.22  27-Sep-1999  enami Change NE2000_USE_WORD to take pointer to softc rather than type.
 1.21  27-Sep-1999  enami Minor cleanup; use the cached result instead of evaluating the
macro NE2000_USE_WORD twice.
 1.20  27-Sep-1999  enami Define new macro NE2000_USE_WORD() and use it where appropriate.
 1.19  27-Sep-1999  enami Allow caller to specify the type of NE2000.
 1.18  23-Mar-1999  drochner Use BUS_SPACE_ALIGNED_POINTER() instead of ALIGNED_POINTER() where the pointer
in not just used to access memory but is bassed to bus_space_xxx_n()
methods. For debugging purposes, bus_space can have additional constraints
which will be properly met by BUS_SPACE_ALIGNED_POINTER().
 1.17  18-Jan-1999  mjacob If you're BIG_ENDIAN and use bswapXX, pull in the header file that prototypes
these functions.
 1.16  18-Jan-1999  pk Need <machine/bswap.h>
 1.15  18-Dec-1998  thorpej Quiet some diagnostic messages when we might expect them to happen.
PR #6460, Rafal Boni.
 1.14  28-Oct-1998  thorpej branches: 1.14.4;
Add media list, media list count, and default media arguments to
ne2000_attach().
 1.13  13-Oct-1998  msaitoh make it compile with GWETHER again.
 1.12  10-Jun-1998  thorpej Do the unaligned buffer fixup without copying data, more-or-less lifted
from the Shark CS8900 driver.
 1.11  04-Feb-1998  sakamoto Change "__BUS_SPACE_NEED_STREAM_METHODS" to "__BUS_SPACE_HAS_STREAM_METHODS".
 1.10  03-Feb-1998  sakamoto Change the data access busification functions to
the "stream" busification functions.
In the architecture as the BeBox(CPU is big endian, have ISA bus),
These methods would be used where "raw" data needs to {read,write,set}
unchanged.

Add #ifndef __BUS_SPACE_NEED_STREAM_METHODS (define that on NetBSD/bebox),
if not define __BUS_SPACE_NEED_STREAM_METHODS,
define "stream" busification functions to normal busification functions.
 1.9  29-Jan-1998  thorpej In the NE2000 case, if we encounter an unaligned mbuf, copy it to an
aligned buffer so that we can do 16-bit PIO to the device without causing
an unaligned access fault.
 1.8  26-Jan-1998  thorpej Update copyright.
 1.7  26-Jan-1998  thorpej If we're using these devices on a big-endian CPU, byte swap the "count"
field in the dp8390's packet header (because the dp8390 runs in little-endian
mode in these cases). Inspired by an e-mail from Kazuki Sakamoto.
 1.6  12-Jan-1998  thorpej Adjust for config changes.
 1.5  02-Nov-1997  thorpej Adjust for ifmedia-related changes to dp8390 driver.
 1.4  29-Oct-1997  thorpej When probing for a dp8390 in ne2000_detect(), check for RST being set
in the ISR (from the ISA "ed" driver's generic 8390 probe routine).
Also, add a big comment describing exactly what we're checking when
probing for the dp8390 (also lifted from the ISA "ed" driver).

The RST check should help weed-out non-matches before they get to the
fairly invasive memory check.
 1.3  15-Oct-1997  enami branches: 1.3.2;
Pull following change from marc-pcmcia branch:

> revision 1.1.2.4
> date: 1997/10/15 01:01:57; author: enami; state: Exp; lines: +10 -8
> Use bus_space_write_1() directly instead of NIC_PUT(), since
> - same io port is accessed by bus_space_read_1() in the same function, and
> - can bypass sc_reg_map[].
 1.2  14-Oct-1997  thorpej Pull down from marc-pcmcia branch: Common code used by NE2000 and compatible
ethernet cards.
 1.1  14-Oct-1997  thorpej branches: 1.1.2;
file ne2000.c was initially added on branch marc-pcmcia.
 1.1.2.4  15-Oct-1997  enami Use bus_space_write_1() directly instead of NIC_PUT(), since
- same io port is accessed by bus_space_read_1() in the same function, and
- can bypass sc_reg_map[].
 1.1.2.3  14-Oct-1997  enami Delete unnecessary indentation.
 1.1.2.2  14-Oct-1997  thorpej Garbage-collect some debugging code that I forgot to remove.
 1.1.2.1  14-Oct-1997  thorpej Split off NE2000 support from the ISA "ed" driver, and create a new "ne"
driver that deals with NE2000s and compatibles on ISA, PCI, and PCMCIA
busses.

This driver uses the generic DP8390 core chipset back-end.
 1.3.2.3  29-Jan-1998  mellon Pull up 1.7-1.9 (thorpej)
 1.3.2.2  05-Nov-1997  thorpej Pullup from trunk: update for dp8390 ifmedia changes.
 1.3.2.1  29-Oct-1997  thorpej Pull up from trunk: make the check for a dp8390 in ne2000_detect()
slightly more robust, and comment it.
 1.14.4.1  11-Dec-1998  kenh The beginnings of interface detach support. Still some bugs, but mostly
works for me.

This work was originally by Bill Studenmund, and cleaned up by me.
 1.23.2.4  12-Mar-2001  bouyer Sync with HEAD.
 1.23.2.3  13-Dec-2000  bouyer Sync with HEAD (for UBC fixes).
 1.23.2.2  08-Dec-2000  bouyer Sync with HEAD.
 1.23.2.1  20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.32.2.4  17-Jan-2003  thorpej Sync with HEAD.
 1.32.2.3  14-Nov-2001  nathanw Catch up to -current.
 1.32.2.2  24-Aug-2001  nathanw Catch up with -current.
 1.32.2.1  21-Jun-2001  nathanw Catch up to -current.
 1.35.2.2  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.35.2.1  25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.37.10.1  27-Jan-2003  jmc Pullup revisions 1.37-1.38 (requested by bouyer in ticket #1096)
Zero out the NIC memory when padding packet to
ETHER_MIN_LEN-ETHER_CRC_LEN sc->write_mbuf now return len of
buffer, including padding.
 1.38.2.6  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.38.2.5  04-Feb-2005  skrll Sync with HEAD.
 1.38.2.4  21-Sep-2004  skrll Fix the sync with head I botched.
 1.38.2.3  18-Sep-2004  skrll Sync with HEAD.
 1.38.2.2  12-Aug-2004  skrll Sync with HEAD.
 1.38.2.1  03-Aug-2004  skrll Sync with HEAD
 1.42.2.1  05-Jul-2004  he Pull up revision 1.43 (requested by mycroft in ticket #602):
Fix a bug in the packet ``padding'' code. If we are padding
a packet with an odd length, we are writing out too much
data, possibly causing the chip to lock up.
 1.44.6.2  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.44.6.1  12-Feb-2005  yamt sync with head.
 1.44.4.1  29-Apr-2005  kent sync with -current
 1.46.4.6  17-Mar-2008  yamt sync with head.
 1.46.4.5  27-Oct-2007  yamt sync with head.
 1.46.4.4  03-Sep-2007  yamt sync with head.
 1.46.4.3  26-Feb-2007  yamt sync with head.
 1.46.4.2  30-Dec-2006  yamt sync with head.
 1.46.4.1  21-Jun-2006  yamt sync with head.
 1.47.2.1  01-Feb-2006  yamt sync with head.
 1.48.12.1  19-Jun-2006  chap Sync with head.
 1.48.10.1  24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.48.6.2  11-Aug-2006  yamt sync with head
 1.48.6.1  24-May-2006  yamt sync with head.
 1.48.4.1  01-Jun-2006  kardel Sync with head.
 1.48.2.1  09-Sep-2006  rpaulo sync with head
 1.49.2.1  13-Jul-2006  gdamore Merge from HEAD.
 1.50.6.2  10-Dec-2006  yamt sync with head.
 1.50.6.1  22-Oct-2006  yamt sync with head
 1.50.4.2  01-Feb-2007  ad Sync with head.
 1.50.4.1  18-Nov-2006  ad Sync with head.
 1.53.2.1  12-Mar-2007  rmind Sync with HEAD.
 1.54.20.1  25-Oct-2007  bouyer Sync with HEAD.
 1.54.16.2  23-Mar-2008  matt sync with HEAD
 1.54.16.1  06-Nov-2007  matt sync with HEAD
 1.54.14.1  26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.54.2.1  23-Oct-2007  ad Sync with head.
 1.55.16.2  02-Jun-2008  mjf Sync with HEAD.
 1.55.16.1  03-Apr-2008  mjf Sync with HEAD.
 1.55.12.1  24-Mar-2008  keiichi sync with head.
 1.58.4.5  11-Aug-2010  yamt sync with head.
 1.58.4.4  11-Mar-2010  yamt sync with head
 1.58.4.3  16-May-2009  yamt sync with head
 1.58.4.2  04-May-2009  yamt sync with head.
 1.58.4.1  16-May-2008  yamt sync with head.
 1.58.2.1  18-May-2008  yamt sync with head.
 1.59.14.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.59.10.1  20-Nov-2010  riz Pull up following revision(s) (requested by tsutsui in ticket #1367):
sys/dev/ic/ne2000var.h: revision 1.25
sys/arch/atari/conf/MILAN.in: revision 1.24
sys/arch/atari/conf/MILAN.in: revision 1.25
sys/dev/ic/ne2000.c: revision 1.71
sys/dev/ic/ne2000.c: revision 1.72
sys/arch/atari/dev/if_ne_mb.c: revision 1.1
sys/arch/atari/dev/if_ne_mb.c: revision 1.2
sys/arch/atari/conf/MILAN-PCIIDE: revision 1.69
sys/arch/atari/conf/HADES.in: revision 1.10
sys/arch/atari/conf/HADES.in: revision 1.11
sys/arch/x68k/dev/if_ne_neptune.c: revision 1.20
sys/dev/isa/if_ne_isa.c: revision 1.27
sys/arch/atari/atari/autoconf.c: revision 1.57
sys/dev/ic/ne2000.c: revision 1.62
sys/dev/isapnp/if_ne_isapnp.c: revision 1.27
sys/arch/atari/conf/files.atari: revision 1.117
sys/arch/atari/conf/HADES: revision 1.88
sys/arch/atari/conf/GENERIC.in: revision 1.85
sys/dev/ic/ne2000.c: revision 1.65
sys/dev/ic/ne2000.c: revision 1.66
sys/dev/ic/ne2000.c: revision 1.68
sys/arch/atari/conf/MILAN-ISAIDE: revision 1.65
distrib/notes/atari/hardware: revision 1.24
sys/conf/files: revision 1.980
sys/dev/ic/ne2000var.h: revision 1.21
sys/arch/x68k/dev/if_ne_intio.c: revision 1.16
sys/dev/ic/dp8390.c: revision 1.74
sys/dev/ic/dp8390.c: revision 1.75
Added NE2000 with 8bit bus width support.
reviewd by tsutsui@ at tech-kern ML.
Fix a wrong calculation bug around RX ring buffer memory address
slipped in about sixteen years ago. Fortunately, it had been working
for ages because some devices used address zero and other devices
ignored wrong higher bits.
Tested on we(4) (SMC Elite Ultra) and ne(4) (NE2000 compatible
named UL0001) on ISA.
Note FreeBSD also uses the same correct value in their ed(4) driver.
Now dp8390_config() calculates mem_ring correctly so
no longer need to override it in ne2000_attach().
Use roundup2() in <sys/param.h> rather than a conditional.
Also fix a wrong mem_ring calculation in dp8390_ipkdb_attach().
Put several fixes to ne(4) driver for better 8 bit mode support,
especially on RTL8019AS which is also used for non-ISA local bus of
embedded controllers and some m68k machines like atari and x68k.
* move RTL8019 probe and attach code from each bus attachment
to MI ne2000_detect() and ne2000_attach()
* change a method for backend and attachment to specify 8 bit mode
to use a new sc->sc_quirk member, instead of sc->sc_dmawidth
* handle more NE2000 8 bit mode specific settings, including
bus_space(9) access width and available size of buffer memory
* add a function to detect NE2000 8 bit mode
(disabled by default, but enalbed by options NE2000_DETECT_8BIT
to avoid possible regression on various ISA clones)
* fix ipkdb attachment accordingly (untested)
Tested on two NE2000 ISA variants (RTL8019AS and another clone named UL0001)
in both 8 bit and 16 bit mode on i386. "Looks good" from nonaka@.
See my post on tech-kern for details:
http://mail-index.NetBSD.org/tech-kern/2010/02/26/msg007423.html
No need to override mem_ring value in ne2000_ipkdb_attach()
since a wrong calculation in dp8390_ipkdb_attach() was fixed.
Don't warn about DMA timeout during probe.
Add support for the EtherNEC.
The EtherNEC is yet another user designed device for Atari machines,
an NE2000 based ISA board connected to Atari's ROM cartridge slot with
simple but ingenious interface and cartridge port adapter, and
it's the most available network solution for the old Atari machines.
See following pages for more details about EtherNEC:
http://hardware.atari.org/ether/
http://home.arcor.de/thomas.redelberger/prj/atari/etherne/
http://www.freemint.org/ethernec/ethernec.html
Also note EtherNEC.
Use callout_schedule(9) rather than callout_reset(9) on polling
as callout(9) man says.
Remove EtherNEC from HADES and MILAN.
They have ISA so no one will bother to connect ISA NE2000 via EtherNEC.
Regen from HADES.in rev 1.11 and MILAN.in rev 1.25:
Remove EtherNEC from HADES and MILAN.
They have ISA so no one will bother to connect ISA NE2000 via EtherNEC.
 1.59.8.1  28-Apr-2009  skrll Sync with HEAD.
 1.64.2.1  30-Apr-2010  uebayasi Sync with HEAD.
 1.70.2.1  30-May-2010  rmind sync with head
 1.72.18.2  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.72.18.1  20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.72.8.2  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.72.8.1  30-Oct-2012  yamt sync with head
 1.73.2.1  28-Aug-2013  rmind sync with head
 1.74.30.1  10-Jun-2019  christos Sync with HEAD
 1.74.28.1  28-Jul-2018  pgoyette Sync with HEAD

RSS XML Feed