History log of /freebsd-11-stable/sys/dev/rl/if_rl.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 331643 27-Mar-2018 dim

MFC r314568 (by emaste):

kern_sig.c: ANSIfy and remove archaic register keyword

Sponsored by: The FreeBSD Foundation

MFC r318389 (by emaste):

Remove register keyword from sys/ and ANSIfy prototypes

A long long time ago the register keyword told the compiler to store
the corresponding variable in a CPU register, but it is not relevant
for any compiler used in the FreeBSD world today.

ANSIfy related prototypes while here.

Reviewed by: cem, jhb
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D10193


# 302408 07-Jul-2016 gjb

Copy head@r302406 to stable/11 as part of the 11.0-RELEASE cycle.
Prune svn:mergeinfo from the new branch, as nothing has been merged
here.

Additional commits post-branch will follow.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


/freebsd-11-stable/MAINTAINERS
/freebsd-11-stable/cddl
/freebsd-11-stable/cddl/contrib/opensolaris
/freebsd-11-stable/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/print
/freebsd-11-stable/cddl/contrib/opensolaris/cmd/zfs
/freebsd-11-stable/cddl/contrib/opensolaris/lib/libzfs
/freebsd-11-stable/contrib/amd
/freebsd-11-stable/contrib/apr
/freebsd-11-stable/contrib/apr-util
/freebsd-11-stable/contrib/atf
/freebsd-11-stable/contrib/binutils
/freebsd-11-stable/contrib/bmake
/freebsd-11-stable/contrib/byacc
/freebsd-11-stable/contrib/bzip2
/freebsd-11-stable/contrib/com_err
/freebsd-11-stable/contrib/compiler-rt
/freebsd-11-stable/contrib/dialog
/freebsd-11-stable/contrib/dma
/freebsd-11-stable/contrib/dtc
/freebsd-11-stable/contrib/ee
/freebsd-11-stable/contrib/elftoolchain
/freebsd-11-stable/contrib/elftoolchain/ar
/freebsd-11-stable/contrib/elftoolchain/brandelf
/freebsd-11-stable/contrib/elftoolchain/elfdump
/freebsd-11-stable/contrib/expat
/freebsd-11-stable/contrib/file
/freebsd-11-stable/contrib/gcc
/freebsd-11-stable/contrib/gcclibs/libgomp
/freebsd-11-stable/contrib/gdb
/freebsd-11-stable/contrib/gdtoa
/freebsd-11-stable/contrib/groff
/freebsd-11-stable/contrib/ipfilter
/freebsd-11-stable/contrib/ldns
/freebsd-11-stable/contrib/ldns-host
/freebsd-11-stable/contrib/less
/freebsd-11-stable/contrib/libarchive
/freebsd-11-stable/contrib/libarchive/cpio
/freebsd-11-stable/contrib/libarchive/libarchive
/freebsd-11-stable/contrib/libarchive/libarchive_fe
/freebsd-11-stable/contrib/libarchive/tar
/freebsd-11-stable/contrib/libc++
/freebsd-11-stable/contrib/libc-vis
/freebsd-11-stable/contrib/libcxxrt
/freebsd-11-stable/contrib/libexecinfo
/freebsd-11-stable/contrib/libpcap
/freebsd-11-stable/contrib/libstdc++
/freebsd-11-stable/contrib/libucl
/freebsd-11-stable/contrib/libxo
/freebsd-11-stable/contrib/llvm
/freebsd-11-stable/contrib/llvm/projects/libunwind
/freebsd-11-stable/contrib/llvm/tools/clang
/freebsd-11-stable/contrib/llvm/tools/lldb
/freebsd-11-stable/contrib/llvm/tools/llvm-dwarfdump
/freebsd-11-stable/contrib/llvm/tools/llvm-lto
/freebsd-11-stable/contrib/mdocml
/freebsd-11-stable/contrib/mtree
/freebsd-11-stable/contrib/ncurses
/freebsd-11-stable/contrib/netcat
/freebsd-11-stable/contrib/ntp
/freebsd-11-stable/contrib/nvi
/freebsd-11-stable/contrib/one-true-awk
/freebsd-11-stable/contrib/openbsm
/freebsd-11-stable/contrib/openpam
/freebsd-11-stable/contrib/openresolv
/freebsd-11-stable/contrib/pf
/freebsd-11-stable/contrib/sendmail
/freebsd-11-stable/contrib/serf
/freebsd-11-stable/contrib/sqlite3
/freebsd-11-stable/contrib/subversion
/freebsd-11-stable/contrib/tcpdump
/freebsd-11-stable/contrib/tcsh
/freebsd-11-stable/contrib/tnftp
/freebsd-11-stable/contrib/top
/freebsd-11-stable/contrib/top/install-sh
/freebsd-11-stable/contrib/tzcode/stdtime
/freebsd-11-stable/contrib/tzcode/zic
/freebsd-11-stable/contrib/tzdata
/freebsd-11-stable/contrib/unbound
/freebsd-11-stable/contrib/vis
/freebsd-11-stable/contrib/wpa
/freebsd-11-stable/contrib/xz
/freebsd-11-stable/crypto/heimdal
/freebsd-11-stable/crypto/openssh
/freebsd-11-stable/crypto/openssl
/freebsd-11-stable/gnu/lib
/freebsd-11-stable/gnu/usr.bin/binutils
/freebsd-11-stable/gnu/usr.bin/cc/cc_tools
/freebsd-11-stable/gnu/usr.bin/gdb
/freebsd-11-stable/lib/libc/locale/ascii.c
/freebsd-11-stable/sys/cddl/contrib/opensolaris
/freebsd-11-stable/sys/contrib/dev/acpica
/freebsd-11-stable/sys/contrib/ipfilter
/freebsd-11-stable/sys/contrib/libfdt
/freebsd-11-stable/sys/contrib/octeon-sdk
/freebsd-11-stable/sys/contrib/x86emu
/freebsd-11-stable/sys/contrib/xz-embedded
/freebsd-11-stable/usr.sbin/bhyve/atkbdc.h
/freebsd-11-stable/usr.sbin/bhyve/bhyvegc.c
/freebsd-11-stable/usr.sbin/bhyve/bhyvegc.h
/freebsd-11-stable/usr.sbin/bhyve/console.c
/freebsd-11-stable/usr.sbin/bhyve/console.h
/freebsd-11-stable/usr.sbin/bhyve/pci_fbuf.c
/freebsd-11-stable/usr.sbin/bhyve/pci_xhci.c
/freebsd-11-stable/usr.sbin/bhyve/pci_xhci.h
/freebsd-11-stable/usr.sbin/bhyve/ps2kbd.c
/freebsd-11-stable/usr.sbin/bhyve/ps2kbd.h
/freebsd-11-stable/usr.sbin/bhyve/ps2mouse.c
/freebsd-11-stable/usr.sbin/bhyve/ps2mouse.h
/freebsd-11-stable/usr.sbin/bhyve/rfb.c
/freebsd-11-stable/usr.sbin/bhyve/rfb.h
/freebsd-11-stable/usr.sbin/bhyve/sockstream.c
/freebsd-11-stable/usr.sbin/bhyve/sockstream.h
/freebsd-11-stable/usr.sbin/bhyve/usb_emul.c
/freebsd-11-stable/usr.sbin/bhyve/usb_emul.h
/freebsd-11-stable/usr.sbin/bhyve/usb_mouse.c
/freebsd-11-stable/usr.sbin/bhyve/vga.c
/freebsd-11-stable/usr.sbin/bhyve/vga.h
# 298307 19-Apr-2016 pfg

sys/dev: use our nitems() macro when it is avaliable through param.h.

No functional change, only trivial cases are done in this sweep,
Drivers that can get further enhancements will be done independently.

Discussed in: freebsd-current


# 295738 18-Feb-2016 yongari

Fix a bug introduced in r295736
TX descriptor address should be updated for valid chain.

Pointed out by: jmallett


# 295736 17-Feb-2016 yongari

Remove duplicated check.

Found by: PVS-Studio


# 271865 19-Sep-2014 glebius

Mechanically convert to if_inc_counter().


# 271864 19-Sep-2014 glebius

Move rl(4) to dev/rl.


# 267363 11-Jun-2014 jhb

Fix various NIC drivers to properly cleanup static DMA resources.
In particular, don't check the value of the bus_dma map against NULL
to determine if either bus_dmamem_alloc() or bus_dmamap_load() succeeded.
Instead, assume that bus_dmamap_load() succeeeded (and thus that
bus_dmamap_unload() should be called) if the bus address for a resource
is non-zero, and assume that bus_dmamem_alloc() succeeded (and thus
that bus_dmamem_free() should be called) if the virtual address for a
resource is not NULL.

In many cases these bugs could result in leaks when a driver was detached.

Reviewed by: yongari
MFC after: 2 weeks


# 257176 26-Oct-2013 glebius

The r48589 promised to remove implicit inclusion of if_var.h soon. Prepare
to this event, adding if_var.h to files that do need it. Also, include
all includes that now are included due to implicit pollution via if_var.h

Sponsored by: Netflix
Sponsored by: Nginx, Inc.


# 245485 15-Jan-2013 yongari

Add D-Link DFE-520TX rev C1.

Tested by: Ruslan Makhmatkhanov < cvs-src <> yandex dot ru >
MFC After: 1 week


# 243882 05-Dec-2012 glebius

Mechanically substitute flags from historic mbuf allocator with
malloc(9) flags within sys.

Exceptions:

- sys/contrib not touched
- sys/mbuf.h edited manually


# 242625 05-Nov-2012 dim

Remove duplicate const specifiers in many drivers (I hope I got all of
them, please let me know if not). Most of these are of the form:

static const struct bzzt_type {
[...list of members...]
} const bzzt_devs[] = {
[...list of initializers...]
};

The second const is unnecessary, as arrays cannot be modified anyway,
and if the elements are const, the whole thing is const automatically
(e.g. it is placed in .rodata).

I have verified this does not change the binary output of a full kernel
build (except for build timestamps embedded in the object files).

Reviewed by: yongari, marius
MFC after: 1 week


# 232145 25-Feb-2012 yongari

Use correct Config registers for RTL8139 family. Unlike RTL8168 and
RTL810x family , RTL8139 has different register map for Config
registers.

While here, follow the lead of re(4) in WOL configuration.
- Disable WOL_UCAST and WOL_MCAST capabilities by default.
- Config5 register write does not need to unlock EEPROM access
on RTL8139 family but unlocking EEPROM access does not affect
its operation and make it consistent with re(4).

Reported by: Matt Renzelmann mjr <> cs dot wisc dot edu


# 227843 22-Nov-2011 marius

- There's no need to overwrite the default device method with the default
one. Interestingly, these are actually the default for quite some time
(bus_generic_driver_added(9) since r52045 and bus_generic_print_child(9)
since r52045) but even recently added device drivers do this unnecessarily.
Discussed with: jhb, marcel
- While at it, use DEVMETHOD_END.
Discussed with: jhb
- Also while at it, use __FBSDID.


# 226995 01-Nov-2011 marius

- Import the common MII bitbang'ing code from NetBSD and convert drivers to
take advantage of it instead of duplicating it. This reduces the size of
the i386 GENERIC kernel by about 4k. The only potential in-tree user left
unconverted is xe(4), which generally should be changed to use miibus(4)
instead of implementing PHY handling on its own, as otherwise it makes not
much sense to add a dependency on miibus(4)/mii_bitbang(4) to xe(4) just
for the MII bitbang'ing code. The common MII bitbang'ing code also is
useful in the embedded space for using GPIO pins to implement MII access.
- Based on lessons learnt with dc(4) (see r185750), add bus barriers to the
MII bitbang read and write functions of the other drivers converted in
order to ensure the intended ordering. Given that register access via an
index register as well as register bank/window switching is subject to the
same problem, also add bus barriers to the respective functions of smc(4),
tl(4) and xl(4).
- Sprinkle some const.

Thanks to the following testers:
Andrew Bliznak (nge(4)), nwhitehorn@ (bm(4)), yongari@ (sis(4) and ste(4))
Thanks to Hans-Joerg Sirtl for supplying hardware to test stge(4).

Reviewed by: yongari (subset of drivers)
Obtained from: NetBSD (partially)


# 226478 17-Oct-2011 yongari

Close a race where SIOCGIFMEDIA ioctl get inconsistent link status.
Because driver is accessing a common MII structure in
mii_pollstat(), updating user supplied structure should be done
before dropping a driver lock.

Reported by: Karim (fodillemlinkarimi <> gmail dot com)


# 219902 23-Mar-2011 jhb

Do a sweep of the tree replacing calls to pci_find_extcap() with calls to
pci_find_cap() instead.


# 213893 15-Oct-2010 marius

Convert the PHY drivers to honor the mii_flags passed down and convert
the NIC drivers as well as the PHY drivers to take advantage of the
mii_attach() introduced in r213878 to get rid of certain hacks. For
the most part these were:
- Artificially limiting miibus_{read,write}reg methods to certain PHY
addresses; we now let mii_attach() only probe the PHY at the desired
address(es) instead.
- PHY drivers setting MIIF_* flags based on the NIC driver they hang
off from, partly even based on grabbing and using the softc of the
parent; we now pass these flags down from the NIC to the PHY drivers
via mii_attach(). This got us rid of all such hacks except those of
brgphy() in combination with bce(4) and bge(4), which is way beyond
what can be expressed with simple flags.

While at it, I took the opportunity to change the NIC drivers to pass
up the error returned by mii_attach() (previously by mii_phy_probe())
and unify the error message used in this case where and as appropriate
as mii_attach() actually can fail for a number of reasons, not just
because of no PHY(s) being present at the expected address(es).

Reviewed by: jhb, yongari


# 213796 13-Oct-2010 yongari

Rewrite interrupt handler to give fairness for both RX and TX.
Previously rl(4) continuously checked whether there are RX events
or TX completions in forever loop. This caused TX starvation under
high RX load as well as consuming too much CPU cycles in the
interrupt handler. If interrupt was shared with other devices which
may be always true due to USB devices in these days, rl(4) also
tried to process the interrupt. This means polling(4) was the only
way to mitigate the these issues.

To address these issues, rl(4) now disables interrupts when it
knows the interrupt is ours and limit the number of iteration of
the loop to 16. The interrupt would be enabled again before exiting
interrupt handler if the driver is still running. Because RX buffer
is 64KB in size, the number of iterations in the loop has nothing
to do with number of RX packets being processed. This change
ensures sending TX frames under high RX load.

RX handler drops a driver lock to pass received frames to upper
stack such that there is a window that user can down the interface.
So rl(4) now checks whether driver is still running before serving
RX or TX completion in the loop.

While I'm here, exit interrupt handler when driver initialized
controller.

With this change, now rl(4) can send frames under high RX load even
though the TX performance is still not good(rl(4) controllers can't
queue more than 4 frames at a time so low TX performance was one of
design issue of rl(4) controllers). It's much better than previous
TX starvation and you should not notice RX performance drop with
this change. Controller still shows poor performance under high
network load but for many cases it's now usable without resorting
to polling(4).

MFC after: 2 weeks


# 213306 30-Sep-2010 yongari

Rename rl_setmulti() to rl_rxfilter() as rl_rxfilter() will handle
IFF_ALLMULTI/IFF_PROMISC as well as multicast filter configuration.
Rewrite RX filter logic to reduce number of register accesses and
make it handle promiscuous/allmulti toggling without controller
reinitialization.

Previously rl(4) counted on controller reinitialization to reprogram
promiscuous configuration but r211767 resulted in avoiding
controller reinitialization whenever promiscuous mode is toggled.
To address this, keep track of driver's view of interface state and
handle IFF_ALLMULTI/IFF_PROMISC changes without reinitializing
controller. This should fix a regression introduced in r211267.

While I'm here remove unnecessary variable reassignment in ioctl
handler.

PR: kern/151079
MFC after: 1 week


# 211767 24-Aug-2010 yongari

Remove unnecessary controller reinitialization.

PR: kern/87506


# 211648 22-Aug-2010 yongari

It seems some newer RTL8139 controllers provides only memory space
register mapping. I'm not sure whether it comes from the fact that
controllers live behind certain PCI brdge(PLX PCI 6152 33BC) and
the bridge has some issues in handling I/O space register mapping.
Unfortunately it's not possible to narrow down to an exact
controller that shows this issue because RealTek used the same PCI
device/revision id again. In theory, it's possible to check parent
PCI bridge device and change rl(4) to use memory space register
mapping if the parent PCI bridge is PLX PCI 6152. But I didn't try
to do that and we wouldn't get much benefit with added complexity.

Blindly switching to use memory space register mapping for rl(4)
may make most old controllers not to work. At least, I don't want
to take potential risk from such change. So use I/O space register
mapping by default but give users chance to override it via a
tunable. The tunable to use memory space register mapping would be
given by adding the following line to /boot/loader.conf file.

dev.rl.%d.prefer_iomap="0"

This change makes P811B quad-port work with this tunable.

Tested by: Nikola Kalpazanov ( n.kalpazanov <> gmail dot com )
MFC after: 1 week


# 210244 19-Jul-2010 yongari

Implement WOL. WOL is supported on RTL8139B or newer controllers.

PR: kern/148013


# 207554 03-May-2010 sobomax

Add new tunable 'net.link.ifqmaxlen' to set default send interface
queue length. The default value for this parameter is 50, which is
quite low for many of today's uses and the only way to modify this
parameter right now is to edit if_var.h file. Also add read-only
sysctl with the same name, so that it's possible to retrieve the
current value.

MFC after: 1 month


# 195049 26-Jun-2009 rwatson

Use if_maddr_rlock()/if_maddr_runlock() rather than IF_ADDR_LOCK()/
IF_ADDR_UNLOCK() across network device drivers when accessing the
per-interface multicast address list, if_multiaddrs. This will
allow us to change the locking strategy without affecting our driver
programming interface or binary interface.

For two wireless drivers, remove unnecessary locking, since they
don't actually access the multicast address list.

Approved by: re (kib)
MFC after: 6 weeks


# 193096 30-May-2009 attilio

When user_frac in the polling subsystem is low it is going to busy the
CPU for too long period than necessary. Additively, interfaces are kept
polled (in the tick) even if no more packets are available.
In order to avoid such situations a new generic mechanism can be
implemented in proactive way, keeping track of the time spent on any
packet and fragmenting the time for any tick, stopping the processing
as soon as possible.

In order to implement such mechanism, the polling handler needs to
change, returning the number of packets processed.
While the intended logic is not part of this patch, the polling KPI is
broken by this commit, adding an int return value and the new flag
IFCAP_POLLING_NOCOUNT (which will signal that the return value is
meaningless for the installed handler and checking should be skipped).

Bump __FreeBSD_version in order to signal such situation.

Reviewed by: emaste
Sponsored by: Sandvine Incorporated


# 188392 09-Feb-2009 fjoe

Destroy TX tag outside of loop scope.

Found with: Coverity Prevent(tm)
CID: 3886


# 186390 21-Dec-2008 yongari

Since we don't request reset for rlphy(4), the link state 'UP'
event from mii(4) may not be delivered if valid link was already
established. To address the issue, check current link state after
driving MII_TICK. This should fix a regression introduced in
r184245.

PR: kern/129647


# 186142 15-Dec-2008 wilko

By default assume a 8139 chip if the EEPROM contents prove inconclusive. The
same LOM hardware with goofed-up EEPROM programming also needed reading the
Ethernet address from the chips registers as the EEPROM did not have a
sensible address programmed.

Patch developed by: pyun@
Funky hardware on loan: www.id-it.nl

MFC after: 2 weeks


# 185575 03-Dec-2008 yongari

Update if_iqdrops instead of if_ierrors when m_devget(9) fails.


# 184559 02-Nov-2008 imp

Make RL_TWISTER_ENABLE a tunable/sysctl. Eliminate it as an option.
Fix module build.

Submitted by: Kostik Belousov


# 184524 01-Nov-2008 imp

Fix a few typos/spelling errors in my comments from the last commit,
plus a few others that had lingered in this driver...

Submitted by: "b." bf2006a att yahoo KIBO com


# 184515 31-Oct-2008 imp

Add RL_TWISTER_ENABLE option. This enables the magic bits to do long
cable tuning. This has helped in some installations for hardware
deployed by a former employer. Made optional because the lists aren't
full of complaints about these cards... even when they were wildly
popular.

Reviewed by: attilio@, jhb@, trhodes@ (all an older version of the patch)


# 184245 25-Oct-2008 yongari

Implement miibus_statchg handler. It detects whether rl(4)
established a valid link or not.
In rl_start_locked, don't try to send packets unless we have valid
link. While I'm here add a check that verifies whether driver can
accept Tx requests by inspecting IFF_DRV_OACTIVE/IFF_DRV_RUNNING
flag.


# 184243 25-Oct-2008 yongari

After sending stop command to MAC, give hardware chance to drain
active DMA operation.


# 184242 25-Oct-2008 yongari

Make rl_init_locked() call rl_reset. This will put hardware into
sane state after resume/watchdog timeouts.


# 184241 25-Oct-2008 yongari

Don't rearm watchdog timer in rl_txeof(). The watchdog timer was
already set in rl_start_locked(). Touching the watchdog timer in
other places will hide the root cause of watchdog timeouts.


# 184240 25-Oct-2008 yongari

Various bus_dma(9) fixes.
- The hardware does not support DAC so limit DMA address space to
4GB.
- Removed BUS_DMA_ALLOC_NOW flag.
- Created separated Tx buffer and Rx buffer DMA tags. Previously
it used to single DMA tag and it was not possible to specify
different DMA restrictions.
- Apply 4 bytes alignment limitation of Tx buffer.
- Apply 8 bytes alignment limitation of Rx buffer.
- Tx side bus_dmamap_load_mbuf_sg(9) support.
- Preallocate Tx DMA maps as creating DMA maps take very long time
on architectures that require real DMA maps.
- Adjust guard buffer size to 1522 + 8 as it should include VLAN
and additional reserved bytes in Rx buffer.
- Plug memory leak in device detach. Previously wrong buffer
address was used to free allocated memory.
- Added rl_list_rx_init() to clear Rx buffer and cleared the
buffer.
- Don't destroy DMA maps in rl_txeof() as the DMA map should be
reused. There is no reason to destroy/recreate the DMA maps in
this driver.
- Removed rl_dma_map_rxbuf()/rl_dma_map_txbuf() callbacks.
- The hardware does not support descriptor based DMA on Tx side
and the Tx buffer address should be aligned on 4 bytes boundary
as well as manual padding for short frames. Because of this
hardware limitation rl(4) always used to invoke m_defrag(9) to
get a 4 bytes aligned single buffer. However m_defrag(9) takes
a lot of CPU cycles on slow machines and not all packets need
the help of m_defrag(9). Armed with the information, don't
invoke m_defrag(9) if the following conditions are true.
1. Buffer is not fragmented.
2. Buffer is aligned on 4 bytes boundary.
3. Manual padding is not necessary.
4. Or padding is necessary but upper stack passed a writable
buffer and the space needed for padding is satisfied.
This change combined with preallocated DMA maps greatly
increased Tx performance of driver on sparc64.
- Moved bus_dmamap_sync(9) in rl_start_locked() to rl_encap() and
corrected memory synchronization operation specifier of
bus_dmamap_sync(9).
- Removed bus_dmamap_unload(9) in rl_stop(). There is no need to
reload/unload Rx buffer as rl(4) always have to copy from the
buffer. It just needs proper bus_dmamap_sync(9) calls before
copying the received frame.

With this change rl(4) should work on systems with more than 4GB
memory.

PR: kern/128143


# 179831 16-Jun-2008 remko

Add another 8139D variant.

PR: 124622
Submitted by: Evgeny Zhirnov <jirnov at gmail dot com>
Approved by: imp (mentor, implicit)
MFC after: 3 days


# 178054 09-Apr-2008 yongari

It seems that RealTek 8129/8139 chip reports invalid length of
received frame under certain conditions. wpaul said the length
0xfff0 is special meaning that indicates hardware is in the
process of copying a packet into host memory. But it seems
there are other cases that hardware is busy or stuck in bad
situation even if the received frame length is not 0xfff0.
To work-around this condition, add a check that verifys that
recevied frame length is in valid range. If received length is out
of range reinitialize hardware to recover from stuck condition.

Reported by: Mike Tancsa ( mike AT sentex DOT net )
Tested by: Mike Tancsa
Obtained from: OpenBSD
MFC after: 1 week


# 176757 03-Mar-2008 yongari

Don't map memory/IO resource in device probe and just use PCI
vendor/revision/sub device id of the hardware to probe it.
This is the same way as NetBSD does and it enhances readabilty
a lot.


# 173948 26-Nov-2007 remko

Add the FNW3603TX Planex NIC.

PR: 76081
Approved by: imp (mentor)
Submitted by: umi at pocke dot org
MFC After: 3 days


# 173839 22-Nov-2007 yongari

Fix function prototype for device_shutdown method.


# 171560 23-Jul-2007 yongari

Add MSI support.
Ever since switching to adaptive polling re(4) occasionally spews
watchdog timeouts on systems with MSI capability. This change is
minimal one for supporting MSI and re(4) also needs MSIX support
for RTL8111C in future. Because softc structure of re(4) is shared
with rl(4), rl(4) was touched to use the modified softc.

Reported by: cnst
Tested by: cnst
Approved by: re (kensmith)


# 166901 23-Feb-2007 piso

o break newbus api: add a new argument of type driver_filter_t to
bus_setup_intr()

o add an int return code to all fast handlers

o retire INTR_FAST/IH_FAST

For more info: http://docs.freebsd.org/cgi/getmsg.cgi?fetch=465712+0+current/freebsd-current

Reviewed by: many
Approved by: re@


# 166165 21-Jan-2007 marius

Change the remainder of the drivers for DMA'ing devices enabled in the
sparc64 GENERIC and the sound device drivers known working on sparc64
to use bus_get_dma_tag() to obtain the parent DMA tag so we can get rid
of the sparc64_root_dma_tag kludge eventually. Except for ath(4), sk(4),
stge(4) and ti(4) these changes are runtime tested (unless I booted up
the wrong kernels again...).


# 165314 18-Dec-2006 yongari

Forced commit to note reserved ID registers in rtl81x9 are
RL_IDR6/RL_IDR67 in previous commit.


# 165311 17-Dec-2006 yongari

Don't assume IF_LLADDR returns aligned memory address.
Because accessing ID registers in rtl81x9 needs 32bit register access
and RL_IDR4/RL_IDR5 registers are reservered registers bzero() is
needed before copying ethernet address.
This fixes unaligned memory accesses panic in sparc64.

PR: kern/106801
MFC after: 3 days


# 164811 01-Dec-2006 ru

if_watchdog -> rl_watchdog


# 162315 15-Sep-2006 glebius

Consistently use if_printf() only in interface methods: if_start,
if_ioctl, if_watchdog, etc, or in functions that are used by
these methods only. In all other cases use device_printf().

This also fixes several panics, when if_printf() is called before
softc->ifp was initialized.

Submitted by: Alex Lyashkov <umka sevcity.net>


# 155671 14-Feb-2006 glebius

Do not touch ifp->if_baudrate in miibus aware drivers.


# 152315 11-Nov-2005 ru

- Store pointer to the link-level address right in "struct ifnet"
rather than in ifindex_table[]; all (except one) accesses are
through ifp anyway. IF_LLADDR() works faster, and all (except
one) ifaddr_byindex() users were converted to use ifp->if_addr.

- Stop storing a (pointer to) Ethernet address in "struct arpcom",
and drop the IFP2ENADDR() macro; all users have been converted
to use IF_LLADDR() instead.


# 151545 22-Oct-2005 imp

Replace FreeBSD 3.x syntax (controller miibus0) with 4.x syntax
(device miibus) in time for 7.0 :-)


# 151297 13-Oct-2005 ru

In detach method, move if_free() after bus_teardown_intr().


# 150968 05-Oct-2005 glebius

- Don't pollute opt_global.h with DEVICE_POLLING and introduce
opt_device_polling.h
- Include opt_device_polling.h into appropriate files.
- Embrace with HAVE_KERNEL_OPTION_HEADERS the include in the files that
can be compiled as loadable modules.

Reviewed by: bde


# 150789 01-Oct-2005 glebius

Big polling(4) cleanup.

o Axe poll in trap.

o Axe IFF_POLLING flag from if_flags.

o Rework revision 1.21 (Giant removal), in such a way that
poll_mtx is not dropped during call to polling handler.
This fixes problem with idle polling.

o Make registration and deregistration from polling in a
functional way, insted of next tick/interrupt.

o Obsolete kern.polling.enable. Polling is turned on/off
with ifconfig.

Detailed kern_poll.c changes:
- Remove polling handler flags, introduced in 1.21. The are not
needed now.
- Forget and do not check if_flags, if_capenable and if_drv_flags.
- Call all registered polling handlers unconditionally.
- Do not drop poll_mtx, when entering polling handlers.
- In ether_poll() NET_LOCK_GIANT prior to locking poll_mtx.
- In netisr_poll() axe the block, where polling code asks drivers
to unregister.
- In netisr_poll() and ether_poll() do polling always, if any
handlers are present.
- In ether_poll_[de]register() remove a lot of error hiding code. Assert
that arguments are correct, instead.
- In ether_poll_[de]register() use standard return values in case of
error or success.
- Introduce poll_switch() that is a sysctl handler for kern.polling.enable.
poll_switch() goes through interface list and enabled/disables polling.
A message that kern.polling.enable is deprecated is printed.

Detailed driver changes:
- On attach driver announces IFCAP_POLLING in if_capabilities, but
not in if_capenable.
- On detach driver calls ether_poll_deregister() if polling is enabled.
- In polling handler driver obtains its lock and checks IFF_DRV_RUNNING
flag. If there is no, then unlocks and returns.
- In ioctl handler driver checks for IFCAP_POLLING flag requested to
be set or cleared. Driver first calls ether_poll_[de]register(), then
obtains driver lock and [dis/en]ables interrupts.
- In interrupt handler driver checks IFCAP_POLLING flag in if_capenable.
If present, then returns.This is important to protect from spurious
interrupts.

Reviewed by: ru, sam, jhb


# 150720 29-Sep-2005 jhb

- Use if_printf() and device_printf() in re(4) and remove rl_unit from
the softc.
- Use callout_init_mtx() and rather than timeout/untimeout in both rl(4)
and re(4).
- Fix locking for ifmedia by locking the driver in the ifmedia handlers
rather than in the miibus functions. (re(4) didn't lock the mii stuff
at all!)
- Fix some locking in re_ioctl().

Note: the two drivers share the same softc declared in if_rlreg.h, so they
had to be change simultaneously.

MFC after: 1 week
Tested by: several on rl(4), none on re(4)


# 150213 16-Sep-2005 ru

Fix "struct ifnet" leaks when attach() fails in the middle, e.g.
when mii_phy_probe() or bus_setup_intr() fails. For drivers that
call their detach() in this case, call if_free() there to cover
this case too.


# 150126 14-Sep-2005 ru

Fixed "Memory modified after free" panic in rl_detach() due
to rl_stop() accessing already freed "struct ifnet".

Fixed LOR between rl mutex and some ACPI mutex in rl_detach().


# 148887 09-Aug-2005 rwatson

Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and
IFF_DRV_RUNNING, as well as the move from ifnet.if_flags to
ifnet.if_drv_flags. Device drivers are now responsible for
synchronizing access to these flags, as they are in if_drv_flags. This
helps prevent races between the network stack and device driver in
maintaining the interface flags field.

Many __FreeBSD__ and __FreeBSD_version checks maintained and continued;
some less so.

Reviewed by: pjd, bz
MFC after: 7 days


# 148654 02-Aug-2005 rwatson

Modify device drivers supporting multicast addresses to lock if_addr_mtx
over iteration of their multicast address lists when synchronizing the
hardware address filter with the network stack-maintained list.

Problem reported by: Ed Maste (emaste at phaedrus dot sandvine dot ca>
MFC after: 1 week


# 147291 10-Jun-2005 brooks

Move if_alloc() up so it's before mii_phy_probe().


# 147256 10-Jun-2005 brooks

Stop embedding struct ifnet at the top of driver softcs. Instead the
struct ifnet or the layer 2 common structure it was embedded in have
been replaced with a struct ifnet pointer to be filled by a call to the
new function, if_alloc(). The layer 2 common structure is also allocated
via if_alloc() based on the interface type. It is hung off the new
struct ifnet member, if_l2com.

This change removes the size of these structures from the kernel ABI and
will allow us to better manage them as interfaces come and go.

Other changes of note:
- Struct arpcom is no longer referenced in normal interface code.
Instead the Ethernet address is accessed via the IFP2ENADDR() macro.
To enforce this ac_enaddr has been renamed to _ac_enaddr.
- The second argument to ether_ifattach is now always the mac address
from driver private storage rather than sometimes being ac_enaddr.

Reviewed by: sobomax, sam


# 146734 29-May-2005 nyan

Remove bus_{mem,p}io.h and related code for a micro-optimization on i386
and amd64. The optimization is a trivial on recent machines.

Reviewed by: -arch (imp, marcel, dfr)


# 142407 24-Feb-2005 imp

Fix style(9) issues with __P removal.

Noticed by: bde


# 142398 24-Feb-2005 imp

Return BUS_PROBE_DEFAULT instead of 0.


# 141676 10-Feb-2005 mlaier

Adjust TX threshold on every TX underrun. Some supported cards (8139-based)
can retransmit on TX underrun and set TOK in addition to TUND. Also add a
check to prevent overflow of the addressable threshold.

This fixes some reports of rl(4) slowness, believed to be related to ALTQ
before.

PR: kern/61448
Submitted by: Tim Draegen-Gilman <timNOeudaemonSPAMnet> (with changes)
MFC after: 1 week


# 139825 07-Jan-2005 imp

/* -> /*- for license, minor formatting changes


# 133403 09-Aug-2004 green

Fix rl(4)'s lock behavior upon deinitialization. I would get a panic
when kldunloading due to its private locking being acquired recursively.


# 131841 08-Jul-2004 bms

Further rl(4) locking improvements:
- Avoid unnecessary re-acquisition elsewhere by adding *_locked()
entry points as needed.
- Correct locking for the DEVICE_POLLING case.
- Hold the driver lock for the entire duration of interrupt servicing,
to avoid unneeded, expensive re-acquisition; use *_locked() entry
points as needed.

Reviewed by: -net (silence)


# 131606 05-Jul-2004 bms

Locking cleanup for rl(4).
- Eliminate the use of a recursive mutex.
- Mark the driver INTR_MPSAFE.

This work is incomplete and will be refined in a future commit.
- Most notably, _locked() variants of entry points need to be introduced.
- The mii upcall/downcall may still be racy.
- Add a stubbed-out guard against racing rl_detach() for the time being.

Tested on: UP, debug.mpsafenet && !debug.mpsafenet
Reviewed by: silence on -net


# 131605 05-Jul-2004 bms

style(9) and whitespace cleanup.
Use C99 types. Use ANSI function definitions. Sort prototypes.
Split long lines correctly. Punctuate/wordsmith comments.
Use device_printf()/if_printf() where possible.

Reviewed by: -net (silence)


# 131455 02-Jul-2004 mlaier

Bring in the first chunk of altq driver modifications. This covers the
following drivers: bfe(4), em(4), fxp(4), lnc(4), tun(4), de(4) rl(4),
sis(4) and xl(4)

More patches are pending on: http://peoples.freebsd.org/~mlaier/ Please take
a look and tell me if "your" driver is missing, so I can fix this.

Tested-by: many
No-objection: -current, -net


# 131253 28-Jun-2004 imp

Remove burn bridges code that saved/restored the pci config registers
that are now handled in the pci bus layer. They are no longer
necessary.


# 130270 09-Jun-2004 naddy

Replace handrolled CRC calculation with ether_crc32_[lb]e().


# 129878 30-May-2004 phk

Add missing <sys/module.h> includes


# 129672 24-May-2004 jhb

Wrap the code to save/restore PCI config registers on suspend/resume in
#ifndef BURN_BRIDGES.

Noticed by: phk


# 129633 23-May-2004 yar

A handler for ioctl(SIOCSIFCAP) should not alter a bit in
if_capenable unless the interface driver is actually able
to toggle the respective capability on and off.

Reviewed by: ru


# 128121 11-Apr-2004 ru

Implemented per-interface polling(4) control.


# 127783 02-Apr-2004 ru

Fixed a few bugs in the rl(4) driver:

Under polling(4), we counted non-existent output packets and wasted
CPU cycles, corrected. (PR kern/64975.)

The fix in revision 1.71 to correct resetting of the watchdog timer
was wrong.

In rl(4), the TX list does not have a gap between the consumer and
producer, so the "empty TX list" test was wrong, corrected.

Also, resetting the timer to five each time we know there is still
some TX work to do was a bad idea -- under polling(4), if the chip
goes out to lunch, this results in the watchdog routine to _never_
be called. Instead, let the timer downgrade to zero and fire the
watchdog, then reset it to five when it is zero AND there is some
TX work left. (Most other network drivers need this fix too.)

MFC after: 3 days


# 127135 17-Mar-2004 njl

Convert callers to the new bus_alloc_resource_any(9) API.

Submitted by: Mark Santcroos <marks@ripe.net>
Reviewed by: imp, dfr, bde


# 126966 14-Mar-2004 mdodd

Announce ethernet MAC addresss in ether_ifattach().


# 126847 11-Mar-2004 mux

Stop setting ifp->if_output to ether_output() since ether_ifattach()
does it for us already.


# 124816 21-Jan-2004 wpaul

Calculate the right register offset when clearing TX buffer pointer
registers in rl_stop().

PR: kern/60250


# 124076 02-Jan-2004 wpaul

Fix detection of RealTek 8129 PCI cards. Apparently, these cards
report a hardware rev of 0x00000000. Sadly, the 8169 gigE MAC
also reports 0x00000000, so testing against this for exclusion
results in both cards being skipped by rl_probe(). Make the 8169
test more specific by matching against both the hwrev and the PCI
ID for this chip.

PR: kern/60824


# 123740 23-Dec-2003 peter

Catch a few places where NULL (pointer) was used where 0 (integer) was
expected.


# 123289 08-Dec-2003 obrien

Don't use caddr_t in mchash(). Also use C99 spellings over BSD ones.

Requested by: bde,imp


# 123019 28-Nov-2003 imp

Sometimes cardbus attachments don't attach, so while we track down
this problem put these lines back in. While they should be
unnecessary, they appear to be sometimes necessary.

Reviewed in concept: dfr
Approved by: re (scottl@)


# 122689 14-Nov-2003 sam

Drop the driver lock around calls to if_input to avoid a LOR when
the packets are immediately returned for sending (e.g. when bridging
or packet forwarding). There are more efficient ways to do this
but for now use the least intrusive approach.

Reviewed by: imp, rwatson


# 122678 14-Nov-2003 obrien

Remove duplicate FBSDID's, move others to their right place.


# 122625 13-Nov-2003 obrien

Try to create some sort of consistency in how the routings to find the
multicast hash are written. There are still two distinct algorithms used,
and there actually isn't any reason each driver should have its own copy
of this function as they could all share one copy of it (if it grew an
additional argument).


# 121939 03-Nov-2003 dfr

Remove explicit cardbus attachments from drivers where this is identical
to the pci attachment. Cardbus is a derived class of pci so all pci
drivers are automatically available for matching against cardbus devices.

Reviewed by: imp


# 121816 31-Oct-2003 brooks

Replace the if_name and if_unit members of struct ifnet with new members
if_xname, if_dname, and if_dunit. if_xname is the name of the interface
and if_dname/unit are the driver name and instance.

This change paves the way for interface renaming and enhanced pseudo
device creation and configuration symantics.

Approved By: re (in principle)
Reviewed By: njl, imp
Tested On: i386, amd64, sparc64
Obtained From: NetBSD (if_xname)


# 119977 11-Sep-2003 wpaul

Re-enable VLAN_MTU capability for this driver. (Got reverted when
I pulled out the C+/8169 bits.)


# 119976 11-Sep-2003 wpaul

Add a PHY driver to support the built-in gigE PHY in the 8169S/8110S
ethernet chips. This driver is pretty simple, however it contains
special DSP initialization code which is needed in order to get
the chip to negotiate a gigE link. (This special initialization
may not be needed in subsequent chip revs.) Also:

- Fix typo in if_rlreg.h (RL_GMEDIASTAT_1000MPS -> RL_GMEDIASTAT_1000MBPS)

- Deal with shared interrupts in re_intr(): if interface isn't up,
return.

- Fix another bug in re_gmii_writereg() (properly apply data field mask)

- Allow PHY driver to read the RL_GMEDIASTAT register via the
re_gmii_readreg() register (this is register needed to determine
real time link/media status).


# 119954 10-Sep-2003 wpaul

Teach rl(4) about new hwrev codes.


# 119871 08-Sep-2003 wpaul

Fix path of pci #includes that I botched.

Also pointed out by: Larry Rosenman


# 119868 08-Sep-2003 wpaul

Take the support for the 8139C+/8169/8169S/8110S chips out of the
rl(4) driver and put it in a new re(4) driver. The re(4) driver shares
the if_rlreg.h file with rl(4) but is a separate module. (Ultimately
I may change this. For now, it's convenient.)

rl(4) has been modified so that it will never attach to an 8139C+
chip, leaving it to re(4) instead. Only re(4) has the PCI IDs to
match the 8169/8169S/8110S gigE chips. if_re.c contains the same
basic code that was originally bolted onto if_rl.c, with the
following updates:

- Added support for jumbo frames. Currently, there seems to be
a limit of approximately 6200 bytes for jumbo frames on transmit.
(This was determined via experimentation.) The 8169S/8110S chips
apparently are limited to 7.5K frames on transmit. This may require
some more work, though the framework to handle jumbo frames on RX
is in place: the re_rxeof() routine will gather up frames than span
multiple 2K clusters into a single mbuf list.

- Fixed bug in re_txeof(): if we reap some of the TX buffers,
but there are still some pending, re-arm the timer before exiting
re_txeof() so that another timeout interrupt will be generated, just
in case re_start() doesn't do it for us.

- Handle the 'link state changed' interrupt

- Fix a detach bug. If re(4) is loaded as a module, and you do
tcpdump -i re0, then you do 'kldunload if_re,' the system will
panic after a few seconds. This happens because ether_ifdetach()
ends up calling the BPF detach code, which notices the interface
is in promiscuous mode and tries to switch promisc mode off while
detaching the BPF listner. This ultimately results in a call
to re_ioctl() (due to SIOCSIFFLAGS), which in turn calls re_init()
to handle the IFF_PROMISC flag change. Unfortunately, calling re_init()
here turns the chip back on and restarts the 1-second timeout loop
that drives re_tick(). By the time the timeout fires, if_re.ko
has been unloaded, which results in a call to invalid code and
blows up the system.

To fix this, I cleared the IFF_UP flag before calling ether_ifdetach(),
which stops the ioctl routine from trying to reset the chip.

- Modified comments in re_rxeof() relating to the difference in
RX descriptor status bit layout between the 8139C+ and the gigE
chips. The layout is different because the frame length field
was expanded from 12 bits to 13, and they got rid of one of the
status bits to make room.

- Add diagnostic code (re_diag()) to test for the case where a user
has installed a broken 32-bit 8169 PCI NIC in a 64-bit slot. Some
NICs have the REQ64# and ACK64# lines connected even though the
board is 32-bit only (in this case, they should be pulled high).
This fools the chip into doing 64-bit DMA transfers even though
there is no 64-bit data path. To detect this, re_diag() puts the
chip into digital loopback mode and sets the receiver to promiscuous
mode, then initiates a single 64-byte packet transmission. The
frame is echoed back to the host, and if the frame contents are
intact, we know DMA is working correctly, otherwise we complain
loudly on the console and abort the device attach. (At the moment,
I don't know of any way to work around the problem other than
physically modifying the board, so until/unless I can think of a
software workaround, this will have do to.)

- Created re(4) man page

- Modified rlphy.c to allow re(4) to attach as well as rl(4).

Note that this code works for the sample 8169/Marvell 88E1000 NIC
that I have, but probably won't work for the 8169S/8110S chips.
RealTek has sent me some sample NICs, but they haven't arrived yet.
I will probably need to add an rlgphy driver to handle the on-board
PHY in the 8169S/8110S (it needs special DSP initialization).


# 119738 04-Sep-2003 tmm

Use stream bus space accesses to program the ID (station address)
registers; otherwise, the byte order of the address is changed on
big-endian machines.


# 119690 02-Sep-2003 jhb

Use PCIR_BAR(x) instead of PCIR_MAPS.

Glanced over by: imp, gibbs
Tested by: i386 LINT


# 119288 22-Aug-2003 imp

Prefer new location of pci include files (which have only been in the
tree for two or more years now), except in a few places where there's
code to be compatible with older versions of FreeBSD.


# 118978 15-Aug-2003 wpaul

Argh. Last commit only had the __FBSDID() fix. Really add the device ID
for the 8100 this time.


# 118977 15-Aug-2003 wpaul

It appears in some configurations with an on-board RTL8100 chip (in this
case, a "Vortex86" mini PC), the PCI device ID value in the EEPROM (0x8100)
does not agree with the PCI device ID returned by pci_get_device() (0x8139).
This means that while rl_probe() matches the device, rl_attach() doesn't.
Work around this by adding an entry to the rl_devs table for the 8100 with
a device ID of 0x8100.

Also, get rid of extra instance of __FBSDID(). One is enough.


# 118889 13-Aug-2003 wpaul

Set the TX hardware checksum offload bits on all the descriptors of a
multi-fragment transmission. I'm not sure if this is a bug or a requirement
that I overlooked with going through the documentation, but the sample
8169 NIC that I have seems to require it at least some of the time or
else it botches TCP checksums on segments that span multiple descriptors.


# 118714 10-Aug-2003 wpaul

Grrr. There is a gratuitous difference in the RX descriptor status
word between the 8139C+ and the 8169. The 8139C+ has a 'frame alignment
error bit' (bit 27) but the 8169 does not. Rather than simply mark this
bit as reserved, RealTek removed it completely and shifted the remaining
status bits one space to the left. This was causing rl_rxeofcplus()
to misparse the error and checksum bits.

To workaround this, rl_rxeofcplus() now shifts the rxstat word one
bit to the right before testing any of the status bits (but after
the frame length has been extracted).


# 118712 09-Aug-2003 wpaul

- Update some comments regarding hardware details of the 8169 and
note the existence of the 8169S and 8110S components. (The 8169
is just a MAC, the 8169S and 8110S contain both a MAC and PHY.)

- Properly handle list and buffer addresses as 64-bit. The RX and
TX DMA list addresses should be bus_addr_t's. Added RL_ADDR_HI()
and RL_ADDR_LO() macros to obtain values for writing into chip
registers.

- Set a slightly different TIMERINT value for 8169 NICs for improved
performance.

- Change left out of previous commit log: added some additional
hardware rev codes for other 10/100 chips and for the 8169S/8110S
'rev C' gigE MACs.


# 118586 07-Aug-2003 wpaul

Add preliminary support for the RealTek 8169 gigE chip. Changes:

- Fix a bug in rl_dma_map_desc(): set the 'end of ring' bit in the
right descriptor (DESC_CNT - 1, not DESC_CNT). The 8139C+ is limited
to 64 descriptors and automatically wraps at 64 descriptors even
if the EOR bit isn't set, but the 8169 NIC can have up to 1024
descriptors per ring, so we must set the wrap point in the right
place.

- RealTek moved the RL_TIMERINT register from offset 0x54 to 0x58 in
the 8169 -- account for this.

- Added rl_gmii_readreg() and rl_gmii_writereg() routines.

- Fix rl_probe() to deal with the case where the base type is
not RL_8139.

The next step is to add jumbo buffer support.

Tested with the Xterasys XN-152 NIC (hard to beat $29 for a gigE NIC).


# 118089 27-Jul-2003 mux

Use the BUS_DMA_ZERO flag.


# 117748 18-Jul-2003 wpaul

Fix a busdma bogon:

Some of the calls to bus_dmamap_sync() were syncing the DMA descriptor
ring maps using the mbuf tag, when they should have been using the
descriptor ring tag instead.


# 117388 10-Jul-2003 wpaul

Add support for the 8139C+ chipset. Unlike the other chips in the 8139
series, the 8139C+ has a descriptor-based DMA mechanism, and its
performance is actually pretty respectable. Note: the 8139D chip does
not support C+ mode. Only the 8139C+ and 8169 gigE chips support C+ mode.

Supported features:

- RX and TX checksum offload
- hardware VLAN tag insertion/extraction
- TX interrupt moderation using the 8139's on-board timer

Everything should be properly busdma'ed and endian-independent, so
things should work ok on non-x86 platforms. Unfortunately, my call
for testers on this code was met with deafening silence, and I don't
have access to any non-x86 FreeBSD boxes at the moment, so this is
speculation.

The device detection code has been cleaned up a little as well
(thanks to Michal Mertl) for the patches.

There are also updates to the rl(4) man page (which I accidentally
checked in before when I updated the dc(4) man page. Oops.)

Todo: finish support for the 8169 gigabit ethernet chip. This
mainly requires writing an rlgphy driver to handle the 8169's built-in
PHY. This will have to wait until I actually get my hands on an 8169
card for testing though. (I still can't find a source for one in the
U.S. Suggestions/pointers welcome.)


# 117208 03-Jul-2003 imp

Due to extreme bogusness in the pci bus layer, these drivers were
forced to do slightly bogus power state manipulation. However, this
is one of those features that is preventing further progress, so mark
them as BURN_BIRDGES like I did for the drivers in sys/dev/...

This, like the other change, are a no-op unless you have BURN_BRIDGES
in your kernel.


# 117126 01-Jul-2003 scottl

Mega busdma API commit.

Add two new arguments to bus_dma_tag_create(): lockfunc and lockfuncarg.
Lockfunc allows a driver to provide a function for managing its locking
semantics while using busdma. At the moment, this is used for the
asynchronous busdma_swi and callback mechanism. Two lockfunc implementations
are provided: busdma_lock_mutex() performs standard mutex operations on the
mutex that is specified from lockfuncarg. dftl_lock() is a panic
implementation and is defaulted to when NULL, NULL are passed to
bus_dma_tag_create(). The only time that NULL, NULL should ever be used is
when the driver ensures that bus_dmamap_load() will not be deferred.
Drivers that do not provide their own locking can pass
busdma_lock_mutex,&Giant args in order to preserve the former behaviour.

sparc64 and powerpc do not provide real busdma_swi functions, so this is
largely a noop on those platforms. The busdma_swi on is64 is not properly
locked yet, so warnings will be emitted on this platform when busdma
callback deferrals happen.

If anyone gets panics or warnings from dflt_lock() being called, please
let me know right away.

Reviewed by: tmm, gibbs


# 117029 29-Jun-2003 wpaul

In order to set the MAC address on RealTek NICs, you must flip WRITECFG
bit in the EEPROM mode register on. Also, the address must be written
in two 32-bit register accesses instead of 6 8-bit accesses.

Tested with my 8139B cardbus NIC.

PR: kern/35900
Submitted by: Mark Kettenis <kettenis@chello.nl>


# 116192 11-Jun-2003 obrien

Use __FBSDID().


# 115530 31-May-2003 phk

Remove break after return;

Found by: FlexeLint


# 113812 21-Apr-2003 imp

Use newly minted device_is_attached rather than device_is_alive to see
if attach succeeded. device_is_alive just tells us that probe
succeeded. Since we were using it to do things like detach net
interfaces, this caused problems when there were errors in the attach
routine.

Symptoms of problem reported by: martin blapp


# 113609 17-Apr-2003 njl

Revise attach/detach resource cleanup
- Unconditionally call *_stop() if device is in the tree. This is to
prevent callouts from happening after the device is gone. Checks for
bus_child_present() should be added in the future to keep from touching
potentially non-existent hardware in *_detach(). Found by iedowse@.
- Always check for and free miibus children, even if the device is not in
the tree since some failure cases could have gotten here.
- Call ether_ifdetach() in the irq setup failure case
- ti(4), xl(4): move ifmedia_init() calls to the beginning of attach so
that ifmedia_removeall() can be unconditionally called on detach. There
is no way to detect whether ifmedia has been initialized without using
a separate variable (as tl(4) does).
- Add comments to indicate assumptions of code path


# 113545 16-Apr-2003 mdodd

- Don't call pci_enable_io() in drivers (unless needed for resume).
- Don't test memory/port status and emit an error message; the PCI
bus code will do this now.


# 113506 15-Apr-2003 mdodd

- Express hard dependencies on bus (pci, isa, pccard) and
network layer (ether).
- Don't abuse module names to facilitate ifconfig module loading;
such abuse isn't really needed. (And if we do need type information
associated with a module then we should make it explicit and not
use hacks.)


# 113496 15-Apr-2003 silby

Rework the rl_encap failure case. Previously, we would stuff the
unencapsulated packet back into the IFQ. Unfortunately, the only reason
rl_encap would fail was due to m_defrag failing, which should only happen
when we're low on mbufs. Hence, it was possible for us to end up with
an IFQ full of packets which could never clear the queue because they could
never be defragmented because they were themselves taking up all the mbufs.

To solve this, take if_xl's approach to the problem of encapsulation failure:
drop the packet.

MFC after: 3 days


# 113237 08-Apr-2003 silby

Quick fix so that the watchdog timer is not set unless packets are
actually queued for transmission. Without this, a low memory situation
would trigger false watchdog timeouts.

MFC after: 1 week


# 112880 31-Mar-2003 jhb

Add missing ()'s so that these drivers all compile again.

Noticed by: jake
Tested on: i386 (compile)


# 112872 31-Mar-2003 njl

Clean up locking and resource management for pci/if_*

- Remove locking of the softc in the attach method, instead depending on
bus_setup_intr being at the end of attach (delaying interrupt enable until
after ether_ifattach is called)
- Call *_detach directly in the error case of attach, depending on checking
in detach to only free resources that were allocated. This puts all
resource freeing in one place, avoiding thinkos that lead to memory leaks.
- Add bus_child_present check to calls to *_stop in the detach method to
be sure hw is present before touching its registers.
- Remove bzero softc calls since device_t should do this for us.
- dc: move interrupt allocation back where it was before. It was unnecessary
to move it. This reverts part of 1.88
- rl: move irq allocation before ether_ifattach. Problems might have been
caused by allocating the irq after enabling interrupts on the card.
- rl: call rl_stop before ether_ifdetach
- sf: call sf_stop before ether_ifdetach
- sis: add missed free of sis_tag
- sis: check errors from tag creation
- sis: move dmamem_alloc and dmamap_load to happen at same time as tag creation
- sk: remove duplicate initialization of sk_dev
- ste: add missed bus_generic_detach
- ti: call ti_stop before ether_ifdetach
- ti: add missed error setting in ti_rdata alloc failure
- vr: add missed error setting in I/O, memory mapping cases
- xl: add missed error setting in I/O, memory mapping cases
- xl: remove multi-level goto on attach failure
- xl: move dmamem_alloc and dmamap_load to happen at same time as tag creation
- Calls to free(9) are unconditional because it is valid to call free with a
null pointer.

Reviewed by: imp, mdodd


# 112839 30-Mar-2003 silby

Switch rl_encap over to using m_defrag.

No functional change, the previous rl_encap was correct wrt long
mbuf chains; this just reduces code duplication.

MFC after: 2 weeks


# 112379 18-Mar-2003 sanpei

Add support for Planex FNW-3800-TX(CardBus 100M/10M).

Submitted by: Kunihiro Arai <araik@attglobal.net>
Obtained from: [bsd-nomads:16625]


# 111381 23-Feb-2003 dan

Add support for Peppercon ROL-F Card.

Submitted by: Sascha Holzeiter <sascha@root-login.org>
PR: 48559


# 111119 19-Feb-2003 imp

Back out M_* changes, per decision of the TRB.

Approved by: trb


# 110601 09-Feb-2003 njl

Clean up exit path from rl_attach() to remove multiple returns


# 109623 21-Jan-2003 alfred

Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.
Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.


# 109109 11-Jan-2003 des

FBSDIDize and clean up whitespace nits.


# 109108 11-Jan-2003 des

Read sanpei's mind, and unbreak the build.


# 109095 11-Jan-2003 sanpei

Add support for Corega FEtherII CB-TXD (CardBus 100M/10M).
Fix typo (Coreaga->Corega)


# 109058 10-Jan-2003 mbr

When reading PHY regs over the i2c bus, the turnaround ACK bit
is read one clock edge too late. This bit is driven low by
slave (as any other input data bits from slave) when the clock
is LOW. The current code did read the bit after the clock was
driven high again.

Reviewed by: luoqi
MFC after: 2 weeks


# 108729 05-Jan-2003 jake

Tweaks to make if_rl work on sparc64.

Mostly submitted by: tmm
Tested on: i386, sparc64


# 106936 14-Nov-2002 sam

o track either_ifattach/ether_ifdetach API changes
o use if_input for input packet processing
o don't strip the Ethernet header for input packets
o use BPF_* macros bpf tapping
o call ether_ioctl to handle default ioctl case
o track vlan changes

Reviewed by: many
Approved by: re


# 106157 29-Oct-2002 imp

Don't take out the rl_mtx lock in the attach routine. The only way
we'd need it is if we're interrupted. So, register the interrupt last
in the attach routine.


# 105221 16-Oct-2002 phk

Be consistent about functions being static.
Properly put macro args in ().

Spotted by: FlexeLint.


# 104324 01-Oct-2002 phk

Fix two misindents.

Spotted by: FlexeLint


# 103020 06-Sep-2002 iwasaki

Add support for Corega FEther CB-TXD (CardBus 100M/10M).


# 102335 23-Aug-2002 alfred

style:
put return values on a line by themselves.
fix some paste issues where whitespace was used instead of tabs.


# 102052 18-Aug-2002 sobomax

Increase size of ifnet.if_flags from 16 bits (short) to 32 bits (int). To avoid
breaking application ABI use unused ifreq.ifru_flags[1] for upper 16 bits in
SIOCSIFFLAGS and SIOCGIFFLAGS ioctl's.

Reviewed by: -hackers, -net


# 100957 30-Jul-2002 jhb

If we get 0xffff back when reading the status register, assume the card
has gone away instead of spinning in the interrupt handler. This stops
my machine from hanging when I eject a rl(4)-based cardbus card.

Reviewed by: imp


# 99165 30-Jun-2002 luigi

Fix if_timer logic to make sure that there is always a timeout
pending if there are packets queued for transmission.

Several drivers still have the same problem.

MFC after: 3 days


# 96112 06-May-2002 jhb

Add support for the D-Link DFE-690TXD Cardbus card which has a RealTek 8139
with its own PCI ID.


# 94883 16-Apr-2002 luigi

Add DEVICE_POLLING support to the "rl" driver.
The diffs are very similar to the ones for the "sis" driver.

MFC After: 5 days


# 94400 11-Apr-2002 wpaul

Nortel Networks sells a RealTek 8139-based NIC that's basically
the same thing as the SMC 1211, but with their own vendor ID.
Update the device list to support this NIC. (Discovered these
cards lying around the lab at work.)


# 94149 07-Apr-2002 wpaul

Teach the rlphy driver how to do parallel link detection. If the link partner
doesn't support NWAY, the RealTek PHY (both the integrated ones on 8139
chips and the RTL8201L 10/100 PHY) will not report the link speed via
the ANLPAR or BMSR registers. For the 8201L, we need to look in magic
vendor-specific PHY register 0x19. For the 8139 MAC+PHY combo, we have
to be able to test the RL_MEDIASTAT register.

The changes to rlphy.c are based largely on the patch from PR 30836,
however I tried to eliminate some magic numbers by creating an entry
for the 8201 PHY in miidevs.

Also updated if_rl.c to allow the rlphy driver to read the RL_MEDIASTAT
register via the rl_miibus_readreg() routine.


# 93818 04-Apr-2002 jhb

Change callers of mtx_init() to pass in an appropriate lock type name. In
most cases NULL is passed, but in some cases such as network driver locks
(which use the MTX_NETWORK_LOCK macro) and UMA zone locks, a name is used.

Tested on: i386, alpha, sparc64


# 92739 20-Mar-2002 alfred

Remove __P.


# 90548 11-Feb-2002 silby

Remove mbuf exhaustion warning messages; these are handled by the
mbuf system in a rate-limited fashion now.

MFC after: 3 days


# 87846 14-Dec-2001 luigi

Remove printf's on mbuf/cluster allocation failures. There are now
equivalent and less dangerous (rate limited) messages in
the mbuf allocation code.

MFC after: 3 days


# 86822 23-Nov-2001 iwasaki

Add suspend/resume code mostly merged from fxp driver.


# 81713 15-Aug-2001 wpaul

Convert the if_sis and if_rl drivers to use the bus_dma API instead of
calling vtophys() and contigmalloc()/contigfree() directly. Hopefully,
I have shaken out all of the problems with busdma on the alpha now.
(Everything seems to work as expected.)

Also, change the max RX DMA limit to 1024 bytes instead of "unlimited,"
as the latter seems not to work correctly on the alpha that I tested.
(At 100Mbps, all attempts to receive frames yield RX errors.)


# 79472 09-Jul-2001 wpaul

Apply patch supplied by Jonathan Chen: use the correct arguments to
pci_enable_io(). We need to use SYS_RES_IOPORT/SYS_RES_MEMORY instead
of PCIM_CMD_PORTEN/PCIM_CMD_MEMEN.


# 78508 20-Jun-2001 bmilekic

Change m_devget()'s outdated and unused `offset' argument to actually mean
something: offset into the first mbuf of the target chain before copying
the source data over.

Make drivers using m_devget() with a first argument "data - ETHER_ALIGN"
to use the offset argument to pass ETHER_ALIGN in. The way it was previously
done is potentially dangerous if the source data was at the top of a page
and the offset caused the previous page to be copied (if the
previous page has not yet been appropriately mapped).

The old `offset' argument in m_devget() is not used anywhere (it's always
0) and dates back to ~1995 (and earlier?) when support for ethernet trailers
existed. With that support gone, it was merely collecting dust.

Tested on alpha by: jlemon
Partially submitted by: jlemon
Reviewed by: jlemon
MFC after: 3 weeks


# 72813 21-Feb-2001 wpaul

Big round of minor updates:

- Use pci_get_powerstate()/pci_set_powerstate() in all the other drivers
that need them so we don't have to fiddle with the PCI power management
registers directly.
- Use pci_enable_busmaster()/pci_enable_io() to turn on busmastering and
PIO/memory mapped accesses.
- Add support to the RealTek driver for the D-Link DFE-530TX+ which has
a RealTek 8139 with its own PCI ID. (Submitted by Jason Wright)
- Have the SiS 900/National DP83815 driver be sure to disable PME
mode in sis_reset(). This apparently fixes a problem on some
motherboards where the DP83815 chip fails to receive packets.
(Submitted by Chuck McCrobie <mccrobie@cablespeed.com>)


# 72645 18-Feb-2001 asmodai

Preceed/preceeding are not english words. Use precede and preceding.


# 72084 06-Feb-2001 phk

Convert if_multiaddrs from LIST to TAILQ so that it can be traversed
backwards in the three drivers which want to do that.

Reviewed by: mikeh


# 71962 03-Feb-2001 phk

Use LIST_FOREACH() to traverse ifp->if_multiaddrs list, instead of
<sys/queue.h> implementation details.

Created with: /usr/sbin/sed
Reviewed with: /sbin/md5


# 71228 18-Jan-2001 bmilekic

Implement MTX_RECURSE flag for mtx_init().
All calls to mtx_init() for mutexes that recurse must now include
the MTX_RECURSE bit in the flag argument variable. This change is in
preparation for an upcoming (further) mutex API cleanup.
The witness code will call panic() if a lock is found to recurse but
the MTX_RECURSE bit was not set during the lock's initialization.

The old MTX_RECURSE "state" bit (in mtx_lock) has been renamed to
MTX_RECURSED, which is more appropriate given its meaning.

The following locks have been made "recursive," thus far:
eventhandler, Giant, callout, sched_lock, possibly some others declared
in the architecture-specific code, all of the network card driver locks
in pci/, as well as some other locks in dev/ stuff that I've found to
be recursive.

Reviewed by: jhb


# 70167 18-Dec-2000 wpaul

Use pci_get_powerstate()/pci_set_powerstate() which now exists in the
PCI code. This saves each driver from having to grovel around looking
for the right registers to twiddle.

I should eventually convert the other PCI drivers to do this; for now,
these three are ones which I know need power state handling.


# 69583 04-Dec-2000 wpaul

Initialize/grab the mutex earlier in the attach phase, so that
bailing out to the fail: label where we release/destroy the mutex
will work without exploding.


# 69127 24-Nov-2000 roger

Print a warning when we detect a Realtek 8139B chip
(identified by the IO map being 256 bytes long instead of 128)

This chip works very unreliably on my Lanner embedded PC with the rl driver.
Lots of watchdog timeouts or poor performance.

Forcing the media type to 10 Meg (ifconfig rl0 media 10baseT/UTP) is a good
workaround.

This looks very similar to the problem reported in PR kern/18790

It is interesting to note that the linux driver has lots of special
case code for this chip.


# 68215 01-Nov-2000 wpaul

Fix 8-bit EEPROM breakage: compare against 0x8129, not 8129.


# 67931 30-Oct-2000 wpaul

Fix support for cardbus cards:
- Add DRIVER_MODULE() declaration to make this driver a
child of cardbus
- Handle different width EEPROMs

The CIS parser still barfs when scanning this card, but it seems to
probe/attach correctly anyway. I can't do a traffic test just yet
since I don't have a proper crossover cable handy.


# 67771 28-Oct-2000 wpaul

Add PCI IDs for some additional cardbus cards. Yes, there really is
a RealTek 8139 cardbus device. Unfortunately it doesn't quite work yet
because the CIS parser barfs on it.

Submitted by msmith, with some small tweaks by me.


# 67164 15-Oct-2000 phk

Remove unneeded #include <machine/clock.h>


# 67089 13-Oct-2000 wpaul

Use device_get_nameunit(dev) as the mutex string when calling
mtx_init() instead of hard-coded string constant. Also remember to do
the mutex changes to the ste driver, which I forgot in the first commit.


# 67087 13-Oct-2000 wpaul

First round of converting network drivers from spls to mutexes. This
takes care of all the 10/100 and gigE PCI drivers that I've done.
Next will be the wireless drivers, then the USB ones. I may pick up
some stragglers along the way. I'm sort of playing this by ear: if
anyone spots any places where I've screwed up horribly, please let me
know.


# 63090 13-Jul-2000 archie

Make all Ethernet drivers attach using ether_ifattach() and detach using
ether_ifdetach().

The former consolidates the operations of if_attach(), ng_ether_attach(),
and bpfattach(). The latter consolidates the corresponding detach operations.

Reviewed by: julian, freebsd-net


# 61041 28-May-2000 peter

Use the correct register name. s/PCI_COMMAND_STATUS_REG/PCIR_COMMAND/


# 60536 14-May-2000 archie

Move code to handle BPF and bridging for incoming Ethernet packets out
of the individual drivers and into the common routine ether_input().
Also, remove the (incomplete) hack for matching ethernet headers
in the ip_fw code.

The good news: net result of 1016 lines removed, and this should make
bridging now work with *all* Ethernet drivers.

The bad news: it's nearly impossible to test every driver, especially
for bridging, and I was unable to get much testing help on the mailing
lists.

Reviewed by: freebsd-net


# 60043 05-May-2000 wpaul

Apply patch to rl_rxeof() to really enforce payload alignment in
the case where we receive a packet that wraps from the end of the
RX buffer back to the start. This fixes an unaligned access trap on
the alpha with NFS.


# 59758 29-Apr-2000 peter

Depend on miibus.

Note that if_aue doesn't strictly depend on usb because it uses the
method interface for calls rather than using internal symbols, and
because it's a child driver of usb and therefore will not try and do
anything unless the parent usb code is loaded at some point. if_aue does
strictly depend on miibus as it will fail to link if it is missing.


# 58801 29-Mar-2000 wpaul

Two fixes for the RealTek:

- Only call m_pullup() when necessary.

- Check return value from rl_encap() in rl_start() to avoid panic when
we run out of mbufs. (Fixes PR kern/17582)

PR: kern/17582


# 55170 28-Dec-1999 billf

Fix a small typo in the comments.


# 55058 23-Dec-1999 wpaul

Fix problem reported by Matt Dillon. Occasionally, very small received
frames would be handled incorrectly due to bad usage of m_pullup() in
the case where the frame wraps from the end of the receive buffer back
the beginning.

Also, when manually extending small packets to pad them to the minimum
frame length during transmission, zero out the pad area to make some
really paranoid people happy.


# 53223 16-Nov-1999 wpaul

Fix usage of m_pullup().


# 52426 21-Oct-1999 wpaul

Make some tweaks to the RealTek driver:

- Fix a bug in rl_rxeof() handler: in the case where the packet wraps
from the end of the receive buffer back to the beginning, we need to
insure that at least sizeof(ether_header) bytes make it into the first
mbuf. If we don't, then doing eh = mtod(m, struct ether_header *)
loses. To avoid this, we use m_pullup() to suck at least MHLEN -
RL_ETHER_ALIGN bytes into the first mbuf, which should also help
small packets fit into a single mbuf.

Pointed out by: Philip A. Prindeville <philipp@zembu.com>

- Make the transmit threshold autotuning: start off with a small value
and jack it up when TX underruns are detected.

- Also improve TX error recovery: kick the chip in the head with a
reset/init sequence to make sure it recovers afer a transmit error.


# 51657 25-Sep-1999 wpaul

Change contigmalloc() lower memory bound from 1MB to 0 to improve
chances of allocations succeeding on systems with small amounts of
RAM.

Pointed out by: bde


# 51583 23-Sep-1999 wpaul

As suggested by phk, unconditionalize BPF support in these drivers. Since
there are stubs compiled into the kernel if BPF support is not enabled,
there aren't any problems with unresolved symbols. The modules in /modules
are compiled with BPF support enabled anyway, so the most this will do is
bloat GENERIC a little.


# 51533 22-Sep-1999 wpaul

Tweak these for what I hope is the last time: change the DRIVER_MODULE()
declaration for the interface driver from "foo" to "if_foo" but leave the
declaration for the miibus attached to the interface driver alone. This
lets the internal module name be "if_foo" while still allowing the miibus
instances to attach to "foo."

This should allow ifconfig to autoload driver modules again without
breaking the miibus attach.


# 51473 20-Sep-1999 wpaul

Un-do the changes to the DRIVER_MODULE() declarations in these drivers.
This whole idea isn't going to work until somebody makes the bus/kld
code smarter. The idea here is to change the module's internal name
from "foo" to "if_foo" so that ifconfig can tell a network driver from
a non-network one. However doing this doesn't work correctly no matter
how you slice it. For everything to work, you have to change the name
in both the driver_t struct and the DRIVER_MODULE() declaration. The
problems are:

- If you change the name in both places, then the kernel thinks that
the device's name is now "if_foo", so you get things like:

if_foo0: <FOO ethernet> irq foo at device foo on pcifoo
if_foo0: Ethernet address: foo:foo:foo:foo:foo:foo

This is bogus. Now the device name doesn't agree with the logical
interface name. There's no reason for this, and it violates the
principle of least astonishment.

- If you leave the name in the driver_t struct as "foo" and only
change the names in the DRIVER_MODULE() declaration to "if_foo" then
attaching drivers to child devices doesn't work because the names don't
agree. This breaks miibus: drivers that need to have miibuses and PHY
drivers attached never get them.

In other words: damned if you do, damned if you don't.

This needs to be thought through some more. Since the drivers that
use miibus are broken, I have to change these all back in order to
make them work again. Yes this will stop ifconfig from being able
to demand load driver modules. On the whole, I'd rather have that
than having the drivers not work at all.


# 51455 20-Sep-1999 wpaul

Grrr. Okay, changing the devnames was a bad idea. Put them back the way
they were.


# 51453 20-Sep-1999 wpaul

Fix the strings in the driver_t structs so that they match the new names
in the DRIVER_MODULES() declarations. *sigh*


# 51450 20-Sep-1999 obrien

Goofed and didn't change the second DRIVER_MODULE() linking these with
the miibus.

Noticed by: wpaul


# 51446 20-Sep-1999 obrien

Change the name we register with DRIVER_MODULE() to include the leading
"if_".

Reviewed by: msmith, wpaul


# 51089 08-Sep-1999 peter

Add a pointer to "controller miibus0" for people who will not read the
commit messages or GENERIC and insist on running -CURRENT.
It probably won't work, but it's worth a try.


# 50703 31-Aug-1999 wpaul

Convert the RealTek 8139 driver to newbus and miibus in one swell foop.
Also set it up to be compiled as a module.


# 50548 29-Aug-1999 bde

Don't restrict our requests for contiguous memory to addresses >= 1MB.
This fixes, at least, panics in ncr_attach() on i386's with about 5MB
of memory. The restriction was a hack to leave some low memory for ISA
DMA, but on i386's we now allocate pages from the top down, so all the
restriction did was cause our allocations to fail when there is no free
memory above 1MB.


# 50477 27-Aug-1999 peter

$Id$ -> $FreeBSD$


# 50135 21-Aug-1999 msmith

Clean up after removing sys/eventhandler.h from sys/systm.h at the last
minute. This should cover all of the missed cases (and should let LINT
build again).


# 50107 21-Aug-1999 msmith

Implement a new generic mechanism for attaching handler functions to
events, in order to pave the way for removing a number of the ad-hoc
implementations currently in use.

Retire the at_shutdown family of functions and replace them with
new event handler lists.

Rework kern_shutdown.c to take greater advantage of the use of event
handlers.

Reviewed by: green


# 49001 22-Jul-1999 wpaul

Remove the definitions for the SiS 900 chip. This is not a RealTek
clone after all. I have the datasheets for this part; hopefully I can
write a proper driver soon.


# 48645 06-Jul-1999 des

Rename bpfilter to bpf.


# 48443 02-Jul-1999 peter

Change the cast in pci_map_port() from u_short * to pci_port_t * so it
compiles cleanly on the Alpha. (On the alpha, the port type is an int,
not a short).
Cast a couple of pointers to ints via 'uintptr_t' rather than 'unsigned
int' since uintptr_t is long (64 bit) on Alpha, as are pointers.


# 48028 19-Jun-1999 wpaul

Fix up the RealTek 8139 driver to work on FreeBSD/alpha. This involves a
few changes:

- there was a bug in rl_list_tx_init(): it was calculating the registers
to initialize incorrectly. Not a problem on the x86 where unaligned
access are allowed, but a problem on the alpha.

- set rl_btag accordingly depending on the machine type

- rl_rxeof() needs to be sure to longword-align the packet data. This
is a little tricky since we copy the data out of the receive buffer
using m_devget(), however there's no way to tell m_devget() to fill
in the mbufs starting at a particular offset. To get around this,
we tell m_devget to copy bytes+2 bytes starting at offset offset-2. This
results in the proper alignment, and we can trim off the two leading
bytes afterwards with m_adj(). We also allocate some extra space before
the start of the receive buffer so that we don't get into trouble in
the case where offset == 0.

- redefine vtophys() in if_rlreg.h for the alpha.

Making this chipset work on the alpha is sort of the inverse of putting
a jet engine on a rowboat (putting a propeller on a 747?) but when
you can get these things for $5 a pop, it's hard to stop people from
buying them.


# 47632 30-May-1999 wpaul

Add support for SiS 900 chipset (PCI ID 0x1039/0x0900), which appears to
be yet another rebadged RealTek 8139.


# 46813 09-May-1999 peter

Simplify the COMPAT_PCI_DRIVER/DATA_SET hack. We can add:
#define COMPAT_PCI_DRIVER(name,data) DATA_SET(pcidevice_set,data)
.. to 2.2.x and 3.x if people think it's worth it. Driver writers can do
this if it's not defined. (The reason for this is that I'm trying to
progressively eliminate use of linker_sets where it hurts modularity and
runtime load capability, and these DATA_SET's keep getting in the way.)


# 46024 24-Apr-1999 peter

Use COMPAT_PCI_DRIVER() for registration if it exists. This shouldn't
hurt the driver portability to 3.x too much for where drivers are shared.


# 45633 12-Apr-1999 wpaul

Merge in some updates for the RealTek driver, mainly:

- Rewrite the transmit section to be a little less bogus.
- Set ifq_maxlen correctly. RL_TX_LIST_CNT - 1 is wrong, because for the
RealTek, RL_TX_LIST_CNT is 4. Set it to IFQ_MAXLEN instead.


# 44238 23-Feb-1999 wpaul

Add support for still more cheapo 10/100 cards: Delta Electronics and
Addtron appear to have their own VIA Rhine II and RealTek 8139 boards
with custom PCI vendor and device IDs. This commit updates the PCI
vendor and device lists in the vr and rl drivers so that we can probe
the additional devices.

Found by: nosing around the PCI vendor and device code list at:
http://www.halcyon.com/scripts/jboemler/pci/pcicode


# 43515 01-Feb-1999 wpaul

Remember to initialize ifp->if_snd.ifq_maxlen.


# 43062 22-Jan-1999 wpaul

Multicast code isn't quite correct. The RealTek wants the upper six bits
of the CRC as the multicast hash table bit, not the lower six bits. Plus
we have to flip on all bits in the table for multicast mode.

Pointed out by: Kazushi SUGYO <k-sugyou@nwsl.mesh.ad.jp>


# 42738 16-Jan-1999 wpaul

Small cosmetic tweak: in rl_rxeof(), use the constant RX_CMD_EMPTY_RXBUF
instead of the magic number 1.


# 42051 24-Dec-1998 wpaul

Grrrr... The RealTek 8139 is yet another chip that includes the ethernet
CRC in received frames, which we need to trim manually.


# 41771 14-Dec-1998 dillon

probe function changed from returning char * to const char *.


# 41656 10-Dec-1998 wpaul

Silence gcc -Wall -ansi -pedantic.

Pointed out by: Eivind


# 41591 07-Dec-1998 archie

The "easy" fixes for compiling the kernel -Wunused: remove unreferenced static
and local variables, goto labels, and functions declared but not defined.


# 41569 06-Dec-1998 wpaul

if_rl.c: make a small tweak to properly handle the Accton MPX 5030/5038
as a RealTek 8139
if_rlreg.h: use bus_space_read_X() in CSR_READ_X() macros instead of
directly calling inb()/outb() etc...
rl.4 + RELNOTES.TXT: mention that SMC EtherEZ PCI 1211-TX is supported
by the RealTek driver


# 41273 20-Nov-1998 wpaul

Add missing return statement to rl_phy_writereg(). This bug didn't actually
hurt anything, but it's still a bug.

Pointed out by: Jason Wright <jason@thought.net>


# 41243 18-Nov-1998 wpaul

The Accton 1207D adapter uses a chip called the MXP 5030 (or 5038)
which is either a RealTek 8139 in disguise or a RealTek workalike.
This commit fixes the PCI vendor/device ID for this device
and updates the description string to reflect the actual identity
of the device.

I also changed the transmit encapsulation routine to always to
buffer copies on transmit. We end up doing this 99% of the time
anyway. I also tweaked the code that pads packets out to the minimum
length (60) bytes. I was fixing up the m_pkthdr.len value but not
m_len. I don't think this makes that much difference in the grand
scheme of things, but it makes me feel better.


# 40516 18-Oct-1998 wpaul

Add driver support for PCI fast ethernet adapters based on the
RealTek 8129/8139 chipset like I've been threatening. Update kernel
configs, userconfig.c, relnotes and sysinstall. No man page yet;
comming soon.

I consider this driver stable enough that I want to give it some
exposure in -current.