History log of /freebsd-9.3-release/sys/dev/xl/if_xl.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 267654 19-Jun-2014 gjb

Copy stable/9 to releng/9.3 as part of the 9.3-RELEASE cycle.

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

# 248078 08-Mar-2013 marius

MFC: r243857 (partial)

Mechanically substitute flags from historic mbuf allocator with
malloc(9) flags in sys/dev.


# 242908 12-Nov-2012 dim

MFC r242625:

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


# 235422 14-May-2012 marius

MFC: r235255

- Change the module order of these MAC drivers to be last so they are
deterministically handled after the corresponding PHY drivers when
loaded as modules. Otherwise, when these MAC/PHY driver pairs are
compiled into a single module probing the PHY driver may fail. This
makes r151438 and r226154 actually work. [1]
Reported and tested by: yongari (fxp(4))
- Use DEVMETHOD_END.
- Use NULL instead of 0 for pointers.

Submitted by: jhb [1]


# 229093 31-Dec-2011 hselasky

MFC r226173, r227843, r227848 and r227908:
Use DEVMETHOD_END to mark end of device methods.
Remove superfluous device methods.
Add some missing __FBSBID() macros.


# 227277 06-Nov-2011 marius

MFC: r226995, r227042

- 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 8k. The only potential in-tree users left
unconverted are ed(4) and xe(4). Xe(4) 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 it
just for the MII bitbang'ing code. Ed(4) has some chip specific things
interwinded with the MII bitbang'ing code and it's unclear whether it can
be converted to common code, at least not without thorough testing of all
the various chips supported by ed(4).
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)
Approved by: re (kib)
Obtained from: NetBSD (partially)


# 225736 22-Sep-2011 kensmith

Copy head to stable/9 as part of 9.0-RELEASE release cycle.

Approved by: re (implicit)


# 223385 21-Jun-2011 imp

Really spell suppress the right way


# 223384 21-Jun-2011 imp

My broken 'u' key scks!


# 223380 21-Jun-2011 imp

Supress warning that command didn't complete when the parent bus
thinks the card is gone.


# 221579 07-May-2011 yongari

Fix build.


# 221571 07-May-2011 yongari

Remove unneeded use of variable status. This should have been done
in r221557.


# 221568 06-May-2011 yongari

XL_DMACTL is 32bit register, use 32bit write macro.
While I'm here add more bits for the register.


# 221567 06-May-2011 yongari

Rearm watchdog timer if driver kick controller to recover from TX
underrun error.
While here, prepend 0x to status code to show TX status is hex
number.


# 221566 06-May-2011 yongari

Rename xl_stats_update() callout handler to xl_tick() and move MII
tick driving logic to xl_tick(). Now xl_tick() handles MII tick as
well as periodic updating of statistics.
This change removes a hack used in interrupt handler where it
wanted to update statistics without driving MII tick.


# 221565 06-May-2011 yongari

Reuse the TX descriptor(DPD) if xl_encap() failed instead of just
picking the next available one. This may explain why xl(4) sees TX
underrun error with no queued frame. I hope this addresses a long
standing xl(4) watchdog timeout issue as well.

Obtained from: OpenBSD


# 221564 06-May-2011 yongari

Change xl_rxeof() a bit to return the number of processed frames in
RX descriptor ring. Previously it returned the number of frames
that were successfully passed to upper stack which in turn means it
ignored frames that were discarded due to errors. The number of
processed frames in RX descriptor ring is used to detect whether
driver is out of sync with controller's current descriptor pointer.
Returning number of processed frames reduces unnecessary (probably
wrong) re-synchronization.

While here, remove unnecessary local variable initialization.


# 221563 06-May-2011 yongari

Terminate interrupt handler if driver detect it's not running.
Also add check for driver running state before trying to send
frames. While I'm here, use for loop.


# 221561 06-May-2011 yongari

Updating status word should be the last operation of UPD structure
renewal. Disable instruction reordering by adding volatile to
xl_list_onefrag structure.


# 221560 06-May-2011 yongari

Call bus_dmamap_sync() only after TX DPD update.


# 221558 06-May-2011 yongari

Set status word once instead of twice. For 3C90xB/3C90xC, frame
length of status word is ignored. While here move bus_dmamap_sync()
up where DMA map is loaded.


# 221557 06-May-2011 yongari

Remove unnecessary htole32/le32toh dance.


# 221555 06-May-2011 yongari

Rewrite RX filter logic and provide controller specific filter
handler for 3C90x and 3C90xB/C respectively. This simplifies ioctl
handler as well as enhancing readability.
While I'm here don't reprogram multicast filter when driver is not
running.


# 219902 23-Mar-2011 jhb

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


# 219546 11-Mar-2011 marius

Allocate the DMA memory shared between the host and the controller as
coherent.

MFC after: 2 weeks


# 215328 14-Nov-2010 yongari

Add flow control for 3C905B and newer controllers. Note, these
controllers support RX pause only.

Reviewed by: marius


# 214846 05-Nov-2010 marius

Correct an inverted check in r213893.


# 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


# 211717 23-Aug-2010 yongari

Implement basic WOL support. Note, not all xl(4) controllers
support WOL. Some controllers require additional 3-wire auxiliary
remote wakeup connector to draw power. More recent xl(4)
controllers may not need the wakeup connector though.


# 211716 23-Aug-2010 yongari

Move xl_reset() to xl_init_locked(). This will make driver
initialize controller from a known good state. Previously driver
used to issue controller reset while TX/RX DMA are in progress.
I guess resetting controller in active TX/RX DMA cycle is to ensure
stopping I/Os in xl_shutdown(). I remember some buggy controllers
didn't respond with stop command if controller is under high
network load at the time of shutdown so resetting controller was
the only safe way to stop the I/Os. However, from my experiments,
controller always responded with stop command under high network
load so I think it's okay to remove the xl_reset() in
device_shutdown handler.
Resetting controller also will clear configured RX filter which
in turn will make WOL support hard because driver have to reprogram
RX filter in WOL handler as well as setting station address.


# 211671 22-Aug-2010 yongari

Remove unnecessary controller reinitialization by checking
IFF_DRV_RUNNING flag.


# 211670 22-Aug-2010 yongari

Clean up SIOCSIFCAP handler and allow RX checksum offloading could
be controlled by user.


# 201452 03-Jan-2010 imp

cardbus -> CardBus


# 195484 09-Jul-2009 yongari

Make xl(4) build with Tx checksum offload.

PR: kern/136409
Approved by: re (kib)


# 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


# 191609 27-Apr-2009 kmacy

remove dead code with reference to IFQ_HANDOFF


# 191345 20-Apr-2009 yongari

To make it easy whether xl(4) missed Tx completion interrupt check
number of queued packets in watchdog timeout handler. If there are
no queued packets just print a informational message and return
without resetting controller. Also fix to invoke correct Tx
completion handler as 3C905B needs different handler.


# 191344 20-Apr-2009 yongari

Clear IFF_DRV_OACTIVE flag if one of queued packets was transmitted.
Previously it used to clear the flag only when the transmit queue
is empty which may slow down Tx performance.
While I'm here check whether driver is running and whether we can
queue more packets in if_start handler. This fixes occasional
watchdog timeouts.

Reported by: xer < xernet <> hotmail dot it >
Tested by: xer < xernet <> hotmail dot it >


# 189575 09-Mar-2009 imp

remove now-redunant cardbus attachment.


# 183714 09-Oct-2008 peter

Clean out some empty mergeinfo records, presumably by people doing local
cp/mv operations. The full repo-relative URL should be specified for the
source in these cases.


# 181522 10-Aug-2008 imp

Move the xl driver form sys/pci to sys/dev/xl for consistency.


# 179378 28-May-2008 jhb

Remove unused 'xl_unit' member from softc.


# 177562 24-Mar-2008 marius

- Take advantage of bus_dmamap_load_mbuf_sg(9).
- Take advantage of m_collapse(9).
- Sync with other NIC drivers and prepend a TX mbuf if the first attempt
to load it fails with an error other than EFBIG and stop trying instead
of freeing it and keeping on trying to enqueue more mbufs. Also ensure
the driver queue isn't empty before trying to enqueue mbufs in order to
reduce locking operations.
- In xl_ifmedia_upd() add a missing XL_UNLOCK(). [1]
- Const'ify the xl_devs array.
- Remove an outdated comment.

PR: 113406 [1]
MFC after: 1 month


# 173839 22-Nov-2007 yongari

Fix function prototype for device_shutdown method.


# 172568 12-Oct-2007 kevlo

Spelling fix for interupt -> interrupt


# 171744 06-Aug-2007 rwatson

Remove the now-unused NET_{LOCK,UNLOCK,ASSERT}_GIANT() macros, which
previously conditionally acquired Giant based on debug.mpsafenet. As that
has now been removed, they are no longer required. Removing them
significantly simplifies error-handling in the socket layer, eliminated
quite a bit of unwinding of locking in error cases.

While here clean up the now unneeded opt_net.h, which previously was used
for the NET_WITH_GIANT kernel option. Clean up some related gotos for
consistency.

Reviewed by: bz, csjp
Tested by: kris
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@


# 164999 08-Dec-2006 marius

- Revert the parts of the previous revision which reloaded the watchdog
timer in xl_txeof()/xl_txeof_90xB(); xl_poll_locked() unconditionally
invokes xl_txeof()/xl_txeof_90xB(), effectively circumventing that
the watchdog ever fires in the DEVICE_POLLING case as its timer is
constantly reloaded.
- Remove the banal and pedantically outdated comment regarding setting
xl_wdog_timer to 0 in xl_txeof().

Pointed out by: bde


# 164935 06-Dec-2006 marius

- Use the xl_stats_update() callout instead of if_slowtimo() for
driving xl_watchdog() in order to avoid races accessing if_timer.
While at it relax the watchdog a bit by reloading it in xl_txeof()/
xl_txeof_90xB() if there are still packets enqueued.
- Use bus_get_dma_tag() so xl(4) works on platforms requiring it.
- Don't bother to set if_mtu to ETHERMTU, ether_ifattach() does that.


# 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>


# 161239 12-Aug-2006 yongari

Don't reset Tx threshold value whenever xl_init_locked() is called.
Instead the threshould is initialized in device attach. Later the
threshold could be increased in Tx underrun error and the new
threshold should be used in xl_init_locked().


# 161238 11-Aug-2006 yongari

Make sure to check frames in Tx queue are empty before clearing
watchdog timer.


# 155671 14-Feb-2006 glebius

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


# 154509 18-Jan-2006 glebius

Check ifp before dereferencing it in xl_detach(). xl_detach() can be called
from xl_attach(), when ifp is not defined yet.

Found with: Coverity Prevent(tm)


# 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.


# 152311 11-Nov-2005 ru

Catch up with IFP2ENADDR() type change (array -> pointer).


# 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


# 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.


# 149251 18-Aug-2005 jhb

Various fixups to locking:
- Remove a lot of superfluous locking during attach. There is no need
to lock access to the driver until some other thread has a way of getting
to it. For ethernet drivers the other ways include registering an
interrupt handler via bus_setup_intr(), calling ether_ifattach() to hook
into the network stack, and kicking off a callout-driven timer via
callout_reset().
- Use callout_* rather than timeout/untimeout.
- Break out of xl_rxeof() if IFF_DRV_RUNNING is clear after ifp->if_input
returns to handle the case where the interface was stopped while we were
passing a packet up the stack. Don't call xl_rxeof() in xl_rxeof_task()
unless IFF_DRV_RUNNING is set. With these fixes in place, any
outstanding task will gracefully terminate as soon as it gets a chance to
run after the interface has been stopped via xl_stop(). As a result,
taskqueue_drain() is no longer required in xl_stop(). The task is still
drained in detach() however to make sure that detach() can safely destroy
the driver mutex at the end of the function.
- Lock the driver lock in the ifmedia callouts and don't lock across
ifmedia_ioctl() in xl_ioctl().

Note: glebius came up with most of (3) as well independently. I took a
rather roundabout way of arriving at the same conclusion.

MFC after: 3 days


# 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


# 148434 27-Jul-2005 imp

The 575A doesn't have funcregs in memio. So don't claim that it does.
This gets my 575A card probing.

Card provided by: James Flemer
MFC After: 3 days


# 147954 13-Jul-2005 glebius

NET_LOCK_GIANT() when entering network code.

Pointy hat to: glebius
Reported by: rodrigc


# 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)


# 146435 20-May-2005 glebius

Calling xl_rxeof() at the end of xl_start_locked() leads to recursion
in case of IP fast forwarding. Enqueue a taskqueue(9) task instead of
calling xl_rxeof() directly.

Reported & tested by: Slava Alpatov
Reviewed by: wpaul
MFC after: 1 week


# 144155 26-Mar-2005 ru

xl(4) meets polling(4). Hardware for this work kindly provided by
Eric Masson.

MFC after: 3 weeks


# 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.


# 139825 07-Jan-2005 imp

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


# 139649 03-Jan-2005 rwatson

Add PCI and device ID's to if_xl to support:

3C920B-EMB-WNM Integrated Fast Ethernet Controller

Submitter reports that the card appears to autonegotiate properly, and
operate well with high levels of NFS traffic.

PR: 75253
Submitted by: "Oleg V. Nauman" <oleg at reis dot zp dot ua>
MFC after: 2 weeks


# 137387 08-Nov-2004 mlaier

Another missing ! in front of IFQ_DRV_IS_EMPTY, this time in an even more
sensitive, but less excercised location (the watchdog). While here use the
*_start_locked function directly to avoid drop, grab, drop lock.

I have to be very careful with future ALTQ patches!

Found & reviewed by: rwatson
MFC after: 3 days


# 135813 26-Sep-2004 johan

style: Move the { back to the else line to match the }.

Discussed with: glebius
X-MFC after: 5.3-Release


# 134989 09-Sep-2004 glebius

Do not call xl_init_locked() unconditionally when we are bringed UP. Call
it only if we weren't UP before. In some cases xl_init causes long media
re-negotiation, and ppp(8) fails to open PPPoE connection because it sets
IFF_UP every time before opening PPPoE connection.

PR: kern/69133
Patch by: mdodd
Approved by: wpaul, julian (mentor)
MFC after: 1 week


# 133200 06-Aug-2004 roam

Do not attempt to clean up data that has not been initialized yet.
This fixes two kernel panics on boot when the xl driver fails to
allocate bus/port/memory resources.

Reviewed by: silence on -net


# 131848 09-Jul-2004 bms

Further improve locking in xl(4):

- Avoid an additional lock acquire/release when leaving xl_intr(), by
changing xl_start*() to xl_start*_locked(), and calling the appropriate
routine by chip revision (as the DMA descriptors are different).

- Simplify the appropriate routines now that they are called with the
lock held.

This should save a significant amount of CPU cycles spent on servicing
each interrupt for both UP and SMP whilst remaining MPSAFE.

Tested by: rwatson


# 131604 05-Jul-2004 bms

Reintroduce and clean up locking in xl(4).

- Eliminate the use of a recursive mutex.
- Mark the driver as INTR_MPSAFE.
- Split the default media choice code out into xl_choose_media() to
avoid making poor assumptions about the state of the lock during attach.
- The miibus upcall/downcall paths may still be racy.
Change to commented-out locking assertions there for now.
- Tested with nfsclient, routed, ssh, ntp, dhclient and quagga bgpd.
- This needs SMP test coverage. I do not have such resources.

Tested on: UP, !debug.mpsafenet && debug.mpsafenet
Hardware: 3C905B-TX (0x905510b7)


# 131601 04-Jul-2004 bms

Use if_printf() and device_printf() where appropriate, i.e.:
- Use device_printf() during device probe/attach.
- Move if_xname initialization to before xl_reset() is called.
- Use if_printf() at all other times after struct ifnet has been
initialized.


# 131600 04-Jul-2004 bms

ANSIfy function definitions.
Remove unnecessary return keywords.
Other minor stylistic changes.


# 131597 04-Jul-2004 bms

Fix whitespace, indentation, long line wrapping and comments.


# 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


# 128199 13-Apr-2004 imp

Boomerang 10/100BT (found in 2c905-TX) chips apparently suffer the
same problems as their Hurricane 575* bretheren in that one could set
the memory mapped port, but that has no effect. Add a quirk for this.

# I'll have to see if I can dig up documentation on these parts to see
# if there's someway software can know this other than a table...


# 127216 20-Mar-2004 silby

Forced commit to correct 1.167's truncated commit log:

Disable hardware TX checksumming for 3c905 series chips, as we have
solid reports that it is buggy *and* that it slows down transmit speed.


# 127213 19-Mar-2004 silby

solid reports that it is buggy *and* that it slows down transmit
speed.

Buggy report: Matt Dillon & others
Slowness report: I can't find the e-mail

MFC After: 1 minute


# 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.


# 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).


# 122160 06-Nov-2003 imp

s/driver/device/ for config file line


# 122136 05-Nov-2003 imp

Change config file syntax to be less FreeBSD 3.x


# 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)


# 120565 29-Sep-2003 silby

Add a tiny bit more delay in the xl_mii_sync function; this is necessary
for proper intialization in certain 905B + old system combinations.

Tested by: Jakub Miziolek <jxm@obta.uw.edu.pl>


# 120058 14-Sep-2003 mdodd

- Avoid calling pci_get_device() more than once in a single function.
- Provide a mechanism to prevent the use of MMIO.
- Prevent the use of MMIO for all 3c575 cardbus cards.


# 119369 23-Aug-2003 mdodd

Report media status for bitrate PHYs.


# 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.


# 118082 27-Jul-2003 mux

Use the BUS_DMA_ZERO flag instead of bzero()'ing DMA memory.


# 117375 10-Jul-2003 wpaul

Support for large frames for VLANs was added by tweaking the packet size
register, present only on 3c90xB and later NICs. This meant that you could
not use a 1500 byte MTU with VLANs on original 3c905/3c900 cards (boomerang
chipset). The boomerang chip does support large frames though, just not
in the same way: you can set the 'allow large frames' bit in the MAC
control register to receive frames up to 4K in size.

Changes:

- Set the 'allow large frames' bit for boomerang chips and increase
the packet size register for cyclone and later chips. This allows
us to use IFCAP_VLAN_MTU on all supported xl(4) NICs.
- Actually set the IFCAP_VLAN_MTU flag in the capabilities word
in xl_attach().
- Change the method used to detect older boomerang chips. My 3c575C
cardbus NIC was being incorrectly identified as 3c90x chip instead
of 3c90xB because the capabilities word in its EEPROM reports
a bizzare value. In addition to checking for the supportsNoTxLength
bit, also check for the absence of the supportsLargePackets bit.
Both of these cases denote a 3c90xB chip.
- Make RX and TX checksums configurable via the SIOCSIFCAP ioctl.
- Avoid an unecessary le32toh() in xl_rxeof(): we already have the
received frame size in the lower 16 bits of rxstat, no need to
read it again.

Tested with 3c905-TX, 3c900-TPO, 3c980C and 3c575C NICs.


# 117220 04-Jul-2003 mux

- Ensure that the busdma API won't do deferred loads by using the
BUS_DMA_NOWAIT flag, since the code can't handle this.
- Use NULL, NULL for the lockfunc and lockfuncarg parameters of
bus_dma_tag_create() since deferred loads can't happen now.


# 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


# 117016 28-Jun-2003 wpaul

Modify the xl_reset() routine slightly so that, if we're using memory
mapped I/O mode, we pause for .1 seconds after issuing the reset command
before trying to poll the 'command busy' bit in the status register.
With my 3c575C cardbus NIC, my Sony Picturebook locks up when it tries
to read the status register immediately after the reset. This appears
to be a problem only with certain NICs on certain hardware, but the
added delay should not hurt cards that already work.

This bug seems to have been brought to light by the fact that the xl
driver now defaults to memory mapped I/O mode instead of programmed
I/O mode like it used to. With PIO mode, the delay isn't needed and
everything works (which is why this NIC worked with 5.0-RELEASE but
not 5.1). I suspect that what's happening is that when the chip is
reset, it takes a little while for the memory-mapped decoding logic
to recover. Trying to access the chip's registers during this period
causes an error condition of some kind that wedges the system.


# 116192 11-Jun-2003 obrien

Use __FBSDID().


# 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.)


# 113298 09-Apr-2003 mux

Correct maxsize/maxsegsz parameters to bus_dma_tag_create().


# 113236 07-Apr-2003 silby

Fix up callers of xl_encap so that they handle a failure response
properly (likely due to mbuf exhaustion.) Previously, the driver
got somewhat wedged.

Also, remove the annoying messages printed every time xl_encap
couldn't allocate a mbuf; they served no useful purpose, and just made
an mbuf exhaustion situation more annoying.

MFC after: 1 week


# 113150 05-Apr-2003 mux

Use bus_dmamap_load_mbuf() instead of bus_dmamap_load() for the
RX part of this driver too. It's better since the code wasn't
dealing with bus_dmamap_load() returning EINPROGRESS, and this
can't happen with bus_dmamap_load_mbuf().

Submitted by: jake


# 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


# 112779 29-Mar-2003 silby

Fix up the long mbuf chain recovery code to use m_defrag; the old
code messed up on B & C chipsets because it lost the packet header
and therefore the flag indicating the need for hardware checksums.

MFC after: 2 weeks


# 112393 18-Mar-2003 silby

Make sure to free the correct resources when the card fails to attach
properly. (Broken in the previous commit.)

Noticed by: "Niels Chr. Bank-Pedersen" <ncbp@bank-pedersen.dk>


# 112364 18-Mar-2003 silby

Instead of relying on a compile time define to determine whether the xl
driver should use port or memory based IO, determine it dynamically
at runtime, preferring MMIO where possible. This helps us support newer
arches which dislike port based access better.

Tested on i386 & sparc64, with 3c900, 905, 905b, and 905C cards.
(in varying combinations by both jake and myself)


# 111877 04-Mar-2003 bmilekic

Fix bug introduced in 1.130. For the < MHLEN case, we should
be doing a m_gethdr(), not an m_get().

Pointed out by: Hiten Pandya <hiten@unixdaemons.com>
Pointy hat to: Me


# 111257 22-Feb-2003 bmilekic

Make xl use m_getcl() to allocate an mbuf and a cluster in one shot,
as opposed to one after the other. This is faster in both -CURRENT
and -STABLE. Additionally, there is less code duplication for
error-checking.

One thing to note is that this code seems to return(1) when no buffers
are available; perhaps ENOBUFS should be the correct return value?

Partially submitted & tested by: Hiten Pandya <hiten@unixdaemons.com>
MFC after: 1 week


# 111136 19-Feb-2003 mux

Fix panic on sparc64 introduced in my last commit. I really
wish the busdma APIs were more consistent accross architectures.

We should probably move all the other DMA map creations in
xl_attach() where we can really handle them failing, since
xl_init() is void and shouldn't fail.

Pointy hat to: mux
Tested by: Anders Andersson <anders@hack.org>


# 111119 19-Feb-2003 imp

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

Approved by: trb


# 111091 18-Feb-2003 mux

- Fix mbuf leak when we successfully allocate a new mbuf but fail to
bus_dmamap_load() it.
- Make it so reusing mbufs when we can't allocate (or map) new ones
actually works. We were previously trying to reuse a mbuf which
was already bus_dmamap_unload()'ed.

Reviewed by: silby


# 109784 24-Jan-2003 mux

Remove the now unused sys/malloc.h header.


# 109688 22-Jan-2003 silby

Correctly identify the 3C920B chipset; although it may ship with some Nforce2
boards, it's definitely not an Nvidia chip.

Info from: Nvidia's Linux Network driver & pciids.sourceforge.net


# 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.


# 109517 19-Jan-2003 obrien

Complete the support of the on-board xl(4) on nVidia nForce2 mobo's.

Submitted by: Mikko S. Hyvarinen <morphy@morphy.iki.fi>


# 109503 18-Jan-2003 tmm

Make the xl driver work on sparc64:
- Add conversions to/from little endian for fields that the NIC accesses
by DMA as required.
- Add some bus_dmamap_sync() calls, and correct some existing ones.
- Read the receiver information from the EEPROM in an endian-neutral
manner.
- Load all RX and TX descriptors in a single DMA map up front, and
get the bus addresses of individual descriptors by address arithmetic;
this fixes multiple use of the descriptor tags, which would have
undesired effects.
It seems that xl still does not work on e250 boxen, for reasons which
are not clear yet.

Reviewed by: mux


# 109147 12-Jan-2003 obrien

Partial support for the nVidia nForce2 chipset's on-board Broadcom/Altima PHY
and 3com MAC. Specifications for the Altima PHY are available at:
http://www.altimacom.com/products/ac101L.html

Submitted by: Mikko S. Hyvarinen <morphy@morphy.iki.fi>


# 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


# 108849 06-Jan-2003 mux

o Only try to recopy the mbuf into an mbuf cluster if
bus_dmamap_load_mbuf() returned EFBIG.
o Fix mbuf leaks in an error (rare) code path.
o Reuse the TX descriptor if xl_encap() failed instead of
just picking the next one.
o Better error messages.


# 108758 05-Jan-2003 silby

Ooops, use the full name of XL_FLAG_EEPROM_OFFSET_30

Noticed by: Niels Chr. Bank-Pedersen <ncbp@bank-pedersen.dk>


# 108752 05-Jan-2003 silby

Add support for the 3c555 miniPCI chipset.

Submitted by: johannes <johannes@paradise.net.nz>
PR: 46603
MFC after: 3 days


# 108750 05-Jan-2003 silby

Add two MII_SETs to provide a bit more time between operations in
xl_sync; this appears to be necessary with certain systems.

Requested by: Michael Class <michael_class@gmx.net>


# 108533 01-Jan-2003 schweikh

Correct typos, mostly s/ a / an / where appropriate. Some whitespace cleanup,
especially in troff files.


# 108449 30-Dec-2002 mux

Leave only one of the two $FreeBSD$ tag, and use __FBSDID().


# 108065 18-Dec-2002 mux

Fix bug with 3c90xB cards and newer. We weren't trying to
copy the mbuf chain into an mbuf cluster when there is
more than 63 mbufs in the chain. We were trying with older
cards though.


# 107959 16-Dec-2002 mux

Convert the xl(4) driver to the busdma API. This should make
it possible to use this driver under ia64, sparc64 (though
there may be endianness issues with this one) and other archs.

Tested on: i386, alpha (gallatin)


# 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


# 105675 22-Oct-2002 silby

Add some magic bits necessary to turn the transmitter on for some
(newer) 556B chips.

Requested & tested by: Dinesh Nambisan <dinesh@nambisan.net>
Magic bits found by: Dave Dribin & Donald Becker

MFC After: 3 days


# 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


# 103779 22-Sep-2002 silby

Remove all DELAY(1) calls around MII operations in the XL driver.
According to the MII specification, the delay produced by our
reads alone are sufficient for correct operation.

This reduces the time mii_tick takes from 10ms to ~1ms here. That's
still a lot, but much better than before.

Submitted by: Harti Brandt <brandt@fokus.gmd.de>
MFC after: 3 weeks


# 103139 09-Sep-2002 ticso

add missing \n to printf

Approved by: gallatin (mentor)


# 102336 23-Aug-2002 alfred

style: put return types on a line by themselves.


# 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.


# 88079 17-Dec-2001 silby

Fix a problem where stats overflow interrupts would cause
a major slowdown, and re-enable stats overflow interrupts.

For future reference, the bug was in our code, and not
some bug in the 3com chips.

Reviewed by: wpaul
MFC after: 2 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


# 87392 05-Dec-2001 guido

Add suspend/resume hooks to this driver; necessary to overcome
problems on HP Omnibook 500.

MFC after: 1 week


# 85303 22-Oct-2001 alc

Implement TCP/IP checksum off-loading on send for the 3c905B and later
generation cards.


# 83849 23-Sep-2001 alc

Implement TCP/IP checksum off-loading on receive. Announce
rxcsum capabilities.

Reviewed by: wpaul


# 82446 27-Aug-2001 wpaul

Add support for the 3c656B cardbus adapter. This is one half of a
dual function card. It needs pretty much the same flags as the 656C,
except that it seems to need both the INVERT_MII_PWR and INVERT_LED_PWR
flags set. Tested with cardbus in -current as of today.

Also added support for the 3c656, which looks to be the same as
the 656B, except it doesn't need the EEPROM_8BIT flag. I think. This
one is untested, but the added support should not break any of the
other cards.


# 80459 27-Jul-2001 wpaul

Pacify users who get all bent out of shape when they see the "xl%d: command
never completed" message. The RX reset takes longer complete than it
used to, a lot longer in fact than xl_wait() is prepared to wait.
When we do the RX reset in xl_reset(), this cases xl_wait() to time out
and whine. We wait a little extra time now after the RX reset, which
should silence the warning.

Thanks to obrien for finally getting me a box with a NIC that
causes this problem for me to tinker with.


# 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.


# 77558 31-May-2001 wpaul

Grrr. Fix PR 27742 correctly this time. (At least I got -stable right.)


# 77548 31-May-2001 wpaul

Close PR #27742: allow the xl driver to receive VLAN tagged frames by
setting the 'max packet size' register in window 3. This only
works for cards based on the cyclone or newer chipsets (i.e. it
won't work with the original 3c905/boomerang cards).

There is a trick which will work with the boomerang, which is to turn
on the 'large packets ok' bit in the MAC control register, however this
lets the chip accept any frame up to 4K in length, which is larger than
the mbuf cluster buffers we use to receive frames. If somebody sends us
such a frame and the chip DMAs it to us, it could write past the end
of the cluster buffer and clobber something.

PR: kern/27742


# 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>)


# 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.


# 69490 01-Dec-2000 imp

Add device ID for the 3c565C card. I followed exactly the 3c575c, but
further tweaks may be necessary down the road. This does nothing with
the serial side of the card.


# 68227 02-Nov-2000 sanpei

add support for 3Com 3c575TX Fast Etherlink XL.

Device information for 3C575-TX is from NetBSD,
sys/dev/cardbus/if_ex_cardbus.c file.

Reviewed by: wpaul, imp


# 67233 16-Oct-2000 imp

Add support for cardbus card's chips. This will make the 3c575 cards
work once the rest of the cardbus infrastructure has been committed.

Submitted by: Jonathan Chen <jon@spook.org>


# 67231 16-Oct-2000 imp

When wierdreset flag is set, turn on the DISADVFD flag when we reset
rather than all the flags. This prevents setting being read from ROM,
which is a problem. If this breaks anything, it will only break the
3C556B cards minipci cards, which mainly exist at rpi as far as rpi
has been able to tell.

Submitted by: Louis Gerbarg <gerbal@rpi.edu>


# 67219 16-Oct-2000 wpaul

Remove an errant splimp() that I missed when I went through this driver
the first time.


# 67177 15-Oct-2000 wpaul

Fix one instance of XL_LOCK() that should have been XL_UNLOCK(). After
doing this so many times, I guess I was entitled to at least one typo.
Thanks to all who spotted this.


# 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.


# 65170 28-Aug-2000 wpaul

Add support for the 3Com 556 and 556B mini-pci adapters used on some
laptops. I've checked that this still works with the other cards and
it works with the 3c556 that I have access to, but I want to check that
it works with the 556B mentioned in PR #20878 before I close out the PR
and merge to -stable.


# 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


# 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.


# 55686 09-Jan-2000 wpaul

Close PR# 15986: issue an RX reset command when initializing the interface,
but only for those cards that don't use miibus (i.e. all the 10mbps only
cards, and the 100baseFX card).

PR: kern/15986


# 55340 03-Jan-2000 wpaul

It appears that under certain circumstances that I still can't quite pin
down, the dc driver and receiver can fall out of sync with one another,
resulting in a condition where the chip continues to receive packets
but the driver never notices. Normally, the receive handler checks each
descriptor starting from the current producer index to see if the chip
has relinquished ownership, indicating that a packet has been received.
The driver hands the packet off to ether_input() and then prepares the
descriptor to receive another frame before moving on to the next
descriptor in the ring. But sometimes, the chip appears to skip a
descriptor. This leaves the driver testing the status word in a descriptor
that never gets updated. The driver still gets "RX done" interrupts but
never advances further into the RX ring, until the ring fills up and the
chip interrupts again to signal an error condition. Sometimes, the
driver will remain in this desynchronized state, resulting in spotty
performance until the interface is reset.

Fortunately, it's fairly simple to detect this condition: if we call
the rxeof routine but the number of received packets doesn't increase,
we suspect that there could be a problem. In this case, we call a new
routine called dc_rx_resync(), which scans ahead in the RX ring to see
if there's a frame waiting for us somewhere beyond that the driver thinks
is the current producer index. If it finds one, it bumps up the index
and calls the rxeof handler again to snarf up the packet and bring the
driver back in sync with the chip. (It may actually do this several times
in the event that there's more than one "hole" in the ring.)

So far the only card supported by if_dc which has exhibited this problem
is a LinkSys LNE100TX v2.0 (82c115 PNIC II), and it only seems to happen
on one particular system, however the fix is general enough and has low
enough overhead that we may as well apply it for all supported chipsets.
I also implemented the same fix for the 3Com xl driver, which is apparently
vulnerable to the same problem.

Problem originally noted and patch tested by: Matt Dillon


# 54697 16-Dec-1999 wpaul

Update the xl driver to recognize yet another 3c905B/3c905C class NIC:
the 3c450-TX HomeConnect. Like the 3cSOHO100-TX OfficeConnect, this NIC
uses the same ASIC as the 3c905B/3c905C but is targeted for a particular
market segment (home users). It is somewhat less expensive than the
3c905B/3c905C ($49, according to the 3Com web site), comes with its
own custom driver kit and is bundled with various goofy Windows software
packages designed to demonstrate the niftyness of home networking (networked
game demos, etc...).

Changes are:

- Add PCI ID to list in if_xlreg.h.
- Update xl_devs table in if_xl.c.
- Update xl_choose_xcvr() to consider the HomeConnect the
same as all the other 10baseT/100baseTX cards.


# 52494 25-Oct-1999 wpaul

Small tweak: just reset the transmit block instead of doing a global reset
in xl_init(). This achieves the effect that I wanted without totally
resetting the chip.


# 52244 14-Oct-1999 wpaul

Make some small tweaks:

- When setting/clearing promisc mode, just update the filter, don't
reset the whole interface.

- Call xl_init() in xl_ifmedia_upd() when setting miibus media modes. This
fixes a problem with the 3c905B-COMBO where switching from 10base5/AUI
or 10base2/BNC to a 10/100 mode doesn't always work right.

- Attempt to reset the interface in xl_init() so that we know we're getting
the receive and transmit rings reset properly.


# 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.


# 51481 20-Sep-1999 wpaul

Close PR #13665. I managed to figure out the problem, no thanks to the
submitter, who *still* hasn't bothered to answer me back.

The thing which the submitter completely failed to mention is that
his 3c900B-TPO card has the transceiver selection in the EEPROM set
to "auto." You can tweak the setting using the 3C90XCFG.EXE utility
that 3Com provides with the card. I'm not sure if it's supposed to
default to auto or if the user fiddled with it. Currently, the xl
driver only does autoselection for 10/100 NICs (i.e. those with NWAY
autonegotiation capabilities). For the 10baseT, 10base5, 10base2,
10baseFL and 100baseFX cards, the driver sets the default media to
whatever the EEPROM transceiver selector says. The problem is that
the "auto" selection is mistakenly identified as "10/100 NWAY
autoselection mode" and this is not handled correctly: the default
media ends up being chosen as 100baseTX, which doesn't work because
we've only added 10baseT media types to the ifmedia word. This leads
to a panic in ifmedia_set() (something else which the submitter never
bothered to mention).

A workaround for this is to re-run the 3C90XCFG.EXE utility and change
the transceiver selection to something besides "auto." I have also
patched the driver to watch for the "auto" setting in the non-miibus
case and select a reasonable default based on the card type instead of
falling through to 100baseTX and exploding.

PR: misc/13665


# 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


# 51441 19-Sep-1999 wpaul

Add an alternate transmit strategy for 3c90xB adapters based on the transmit
strategy used in the 3Com Linux driver. The new strategy is to use transmit
descriptor polling -- that is, the NIC polls the descriptors to see when
new packets are available for transmission. The advantage to the new scheme
is that no register accesses are needed in the transmit routine. The old
scheme requires several register accesses to stall the TX engine, update the
TX DMA list pointer register, then unstall the TX engine. Hopefully the new
scheme will provide improved transmit performance with less CPU overhead.

This only affects the 3c90xB or 3c90xC cards, not the 3c90x cards. This
means the original 3c900 and 3c905 cards are unaffected. Newer cards include
the 3c900B series, the 3c905B, 3c980, 3c980B, 3c905C and 3c905C, and the
3cSOHO100-TX OfficeConnect.


# 51302 15-Sep-1999 wpaul

Dangit: mispelled TORNADO in one place.


# 51301 15-Sep-1999 wpaul

3Com has produced their own Linux driver for the 3c90x/3c90xB series cards.
It's GPL'ed of course, but looking over it tonight I learned of Yet Another
Fast EtherLink XL Adapter: the 3c980C server adapter. This is basically
an updated version of the 3c980 that uses the Tornado ASIC instead of the
earlier Hurricane ASIC. The only change here is to add the new PCI device
ID (0x9805) and corresponding table entries.


# 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.


# 50722 01-Sep-1999 wpaul

Just when I thought it was safe. In the original 3c905-TX NICs, the
external NatSemi PHY chip was programmed to respond to MII address 24.
In the 3c905B ASICs, the transceiver is internal but it's still mapped
to MII address 24. But *some* 3Com 3c905B ASIC revisions map the
transceiver control registers to *all* MII addresses (0 through 31).
The miibus code probes for PHYs at all MII addresses and because of
this unusual behavior, it will attempt to map the same PHY registers
several times over, which doesn't work.

Naturally, the 3c905B NIC that I tested happened not to exhibit this
behavior.

The fix is to tweak xl_miibus_readreg() and xl_miibus_writereg()
to only respond when attempting to read from MII address 24. This
is safe to do since the 3Com documentation indicates that the PHY
and/or internal transceiver will always be mapped to address 24,
and there are no 3Com XL NICs with more than one PHY.


# 50579 29-Aug-1999 wpaul

Convert the 3Com XL driver to miibus. This one is a little tricky
due to the fact that there are non-MII cards supported by the same
driver and I don't have all of the cards available for testing. There's
also the 3c905B-COMBO which has MII, AUI and BNC media ports all in one
package. Supporting the COMBO is difficult because we have to add the
10base5 and 10base2 media types to the same ifmedia struct as the
MII-attached types, however there is no way to force the miibus and
child PHYs into existence before xl_attach() completes, so there is
no ifmedia struct available in xl_attach(). What we do inistead is
use the mediainit method as a callback: when a child PHY is attached,
it calls the miibus mediainit routine which selects a default media.
This routing also calls the NIC driver's mediainit method (if it
implements one) at which point we can safely add the other media
types.


# 50477 27-Aug-1999 peter

$Id$ -> $FreeBSD$


# 50040 19-Aug-1999 wpaul

Small tweak: in xl_rxeof(), rxstat should be u_int32_t, not u_int16_t.


# 49389 02-Aug-1999 wpaul

Minor tweak for last commit: insert extra delay between issuing master
reset and RX/TX resets.


# 49384 02-Aug-1999 wpaul

Perform an RX reset and TX reset in xl_reset() along with the master
reset command.

I observed some anomalous behavior while testing a 3c905C with a
Dell PowerEdge 4300/500 dual PIII 500Mhz system. The NIC would seem
to work correctly most of the time but would sometimes fail to receive
certain packets, in particular NFS create requests. I could mount
an NFS filesystem from the PowerEdge and do an ls on it, but trying
to do a "touch foo" would hang. Monitoring traffic from another host
revealed that the client was properly sending an NFS create request
but the server was not receiving it. It *did* receive it when I
ran the same test with an Intel fxp card.

I don't understand the exact mechanics of this strange behavior, but
resetting the receiver and transmitter seems to get rid of it. I used
to perform an RX and TX reset in xl_init(), but stopped doing it there
because on 3c905B and later cards this causes the autoneg session to
restart, which would lead to the NIC waiting a long time before exchanging
traffic after being brought up the first time. Apparently the receiver
and transmitter resets should be performed at least once when initializing
the card.

Hopefully this will cure problems that people have been having with the
3c905C -- this was the only strange behavior that I have observed with
the 3c905C so far which does not appear with the 3c905B or 3c905.


# 49010 23-Jul-1999 wpaul

Some more small newbus cleanups. Remember to free all resources in case
of failures in foo_attach(), simplify iospace/memspace things a little.


# 48999 22-Jul-1999 wpaul

Well, it seems that loading a PCI driver module after the system has
been booted works too -- very neat. However I don't want the system to
stop for 5 seconds when the MII autoprobe is triggered in the xl and
tl drivers since that's lame. Instead, only use the hard delay when
we've been cold booted. If not, use the timeout mechanism instead.
(The SysKonnect driver doesn't use the same autonegotiation scheme, so
no change is required there.)


# 48972 22-Jul-1999 wpaul

Small tweak to newbus changes: return error status on failure correctly
in xl_attach() (not a problem if the attach never fails, but if it does
the function would still return 0, which is wrong).


# 48947 20-Jul-1999 wpaul

Convert the xl driver to newbus. It is now possible to make this driver
into a loadable module, and all of the platform dependencies are gone
(except for the alpha_XXX_dmamap() thing, which is another issue -- I
still don't know how to use the busdma stuff with a network driver).

Also increase the delay in xl_reset(); testing on a 486/66 with a 3c905C
shows that reading the EEPROM fails immediately after a reset. Waiting
a little longer after the reset completes seems to fix it.


# 48675 07-Jul-1999 wpaul

Grrr.... forgot one line from the previous fix.


# 48673 07-Jul-1999 wpaul

Fix a potential race condition that can occur in xl_start(). If the NIC
clears out the transmit queue and zeroes the downlist pointer register,
but xl_txeof() isn't called before xl_start() tries to queue more packets,
xl_start() will think that the DMA is still in progress and not update
the downlist register again, thus causing packets to sit in the transmit
queue forever.

Patch provided by: Russell T Hunt <alaric@MIT.EDU>


# 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.


# 47681 01-Jun-1999 wpaul

Change the warning message issued if pci_map_port() fails. I think this
happens if you have a BIOS with a 'Plug & Play OS' setting and you leave
it set to 'Yes.' This is wrong for FreeBSD (and LoseNT): it should be set
to 'No.' Apparently it's still possible to map the iobase of the NIC and
have the card work by reading the config space manually (which is what
the driver does if pci_map_port() fails) but we need to warn the user to
do fix their machine anyway. Anyway, warn the user to check the 'Plug &
Play OS' setting in their BIOS if mapping the io space fails.


# 47628 30-May-1999 wpaul

Whoops, forgot to update xl_mediacheck() to account for the 3c905C.


# 47627 30-May-1999 wpaul

Head for the hills friends and neighbors, 3Com has yet another 3c90X
chipset. First you thrilled to the 3c905, then you trembled at the
3c905B, now gaze in wonder at: the 3c905C! This appears to be another
3c90X series chip called the Tornado (PCI ID 0x10B7/0x9200) and should
be equivalent (from the driver API perspective) to the 3c905B, so all
we have to do is add the PCI ID to the list.


# 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.)


# 46514 05-May-1999 wpaul

Dynamically increase TX start threshold if TX underruns are detected.


# 46448 04-May-1999 wpaul

Fix the media selection for the 3c900B-FL 10baseFL adapter. It actually
uses the AUI port with an on-board AUI to 10baseFL transceiver, not the
10baseT port like I had earlier suspected. The 3c900B-FL should be properly
supported now.


# 46204 30-Apr-1999 wpaul

Bunch of updates:

- Try to unbreak what I broke by screwing with the tx queuing again.
I'm waiting for a few more people to test out this code and report back
before I move it into current. Hopefully it will be soon. Basically I
reverted to the old TX queuing strategy.

- Add experimental support for the 3c900B-FL (10mbps ST fiber). The card
should be detected properly and the 10baseFL mode supported, but again
I'm still waiting for word from a tester to see if this actually works.
It shouldn't affect the other cards though; all the differences are in
media selection.

- Set the TX start threshold register to get better performance.

- Increase the size of the RX and TX rings. UDP performance was pretty
bad because the TX ring was too small. Should be substantially better
now (I can saturate the link with either TCP or UDP now).

- Change some of the #defines to reflect proper 3Com ASIC names (boomerang,
cyclone, krakatoa, hurricane).

- Simplify and reorganize interrupt handler; ack all interrupts right
away and then process them. This avoids a potential race condition.
(Noted by Matt Dillon.)

- Reorganize the bridging code to eliminate using a goto to jump into
the middle of an if() {} clause. Sorry, that just made my brain itch.

- Use m_adj() in xl_rxeof().

- Make the payload alignment in xl_newbuf() the default (instead of
just conditionally defined for the alpha) to improve NFS performance
(avoids need for nfs_realign()).


# 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.


# 45720 16-Apr-1999 peter

Bring the 'new-bus' to the i386. This extensively changes the way the
i386 platform boots, it is no longer ISA-centric, and is fully dynamic.
Most old drivers compile and run without modification via 'compatability
shims' to enable a smoother transition. eisa, isapnp and pccard* are
not yet using the new resource manager. Once fully converted, all drivers
will be loadable, including PCI and ISA.

(Some other changes appear to have snuck in, including a port of Soren's
ATA driver to the Alpha. Soren, back this out if you need to.)

This is a checkpoint of work-in-progress, but is quite functional.

The bulk of the work was done over the last few years by Doug Rabson and
Garrett Wollman.

Approved by: core


# 45707 15-Apr-1999 ghelmer

Add bridging support (tested in 3.1-RELEASE by Steven Vetzal
<svetzal@icom.ca>).


# 45693 15-Apr-1999 wpaul

- Close PR #11136: add PCI ID for another new cyclone device: the
3c900B-TPC (twisted pair and coax). Treated similarly to the
3c900B-COMBO, except no AUI port.

- Fix media selection so that it's possible to select the AUI and BNC
ports on the 3c905B-COMBO. This board is now fully supported.

- Change TX queueing strategy to hopefully be more efficient by avoiding
register accesses in xl_start(). Should provide small performance
improvement and a little better reliability.


# 45629 12-Apr-1999 wpaul

Add support for the 3cSOHO100-TX, which is a "hurricane" chipset
(cut-down version of the "cyclone" for the small office/home office
"cheap bastard" market). Basically the same as a 3c905B but without
Wake-on-LAN, ROM socket, etc...


# 45601 11-Apr-1999 wpaul

Some small updates:

- Wait longer for the reset to complete in xl_attach() to try and avoid
'command never completed' warnings.

- Clean up a few odds and ends in xl_attach().

- Add PCI ID for the 3c905B-COMBO (a new card). Right now this is
treated as a 3c905B; I need to dig up one of these cards for testing
before I can make the AUI and BNC ports work.

- Add a hack to force reading the I/O address directly from the PCI
registers if pci_map_port() fails. I SHOULD NOT HAVE TO DO THIS:
SOMEBODY WITH MORE PCI CLUES THAN I SHOULD INVESTIGATE WHY THIS
HAPPENS.


# 45198 31-Mar-1999 wpaul

Shorten device names so that the pci probe lines don't exceed 80 chars
and wrap to a second line.

Put 'command never completed' message inside #ifdef DIAGNOSTIC/#endif to
stop people worrying about it (it's harmless).


# 45062 27-Mar-1999 wpaul

Make the xl and pn drivers work on FreeBSD/alpha and add them to
sys/alpha/conf/GENERIC.

Note: the PNIC ignores the lower few bits of the RX buffer DMA address,
which means we have to add yet another kludge to make it happy. Since
we can't offset the packet data, we copy the first few bytes of the
received data into a separate mbuf with proper alignment. This puts
the IP header where it needs to be to prevent unaligned accesses.

Also modified the PNIC driver to use a non-interrupt driven TX
strategy. This improves performance somewhat on x86/SMP systems where
interrupt delivery doesn't seem to be as fast with an SMP kernel as
with a UP kernel.


# 44294 26-Feb-1999 wpaul

Remove call to DELAY() from xl_wait(), since xl_wait() is in the
interrupt handler codepath. Having the delay there didn't really
accomplish much anyway.


# 43916 11-Feb-1999 wpaul

Do not issue RX and TX reset commands in xl_stop() and xl_init(). On the
3c905B, the RX and TX reset commands also reset the cyclone chip's internal
PHY, which causes it to restart its autonegotiation session. This takes a
second or two to complete, which makes the interface seem to stop responding
for a few seconds every time you do something that reinitializes it.

Issuing the RX and TX resets on the older 3c905 boomerang adapters doesn't
cause any delay because the boomerang chip requires an external PHY.

This should fix the problem where people doing network installs via 3c905B
cards experience a delay after the interface is first initialized, among
other things.


# 43515 01-Feb-1999 wpaul

Remember to initialize ifp->if_snd.ifq_maxlen.


# 42046 24-Dec-1998 wpaul

Fix a small bug in xl_start(): when queuing a packet onto the end of
an existing chain, don't forget to move xl_tx_tail to point to the new
tail end.


# 41771 14-Dec-1998 dillon

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


# 41651 10-Dec-1998 wpaul

Silence gcc -Wall -ansi -pedantic and fix minor bug in xl_txeof().

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.


# 41526 05-Dec-1998 wpaul

Add sanity check to foo_start() routines: in the unlikely (though
apparently possible) event that the transmit start routine is
called with and empty if_snd queue, bail out instead of dereferencing
unilitialized transmit list pointers and panicking.


# 41239 18-Nov-1998 wpaul

Fix a minor bug in xl_attach() where the list buffer region is rounded
to a longword boundary.

Noticed by: Jason Wright <jason@thought.net>


# 40594 22-Oct-1998 wpaul

Close PR #8409:

Fix syntax errors inside #ifdef FORCE_AUTONEG_TFOUR.


# 40588 22-Oct-1998 wpaul

Close PR #8384:

Revert the transmission packet queueing strategy changes. Clearly I missed
something while debugging this, although I never encountered any problems
on my test machines.

Also make one other minor change: jack up the TX reclaim threshold for
3c90xB adapters in order to stave off 'transmission error: 82' errors.

Document the existence of the tx reclaim register (for inspecting the
current reclaim threshold) in register window 5 (if_xlreg.h).


# 40528 19-Oct-1998 wpaul

Modify the transmit packet queuing strategy a bit to be a little less
agressive. With the old code, if a descriptor chain was already on its
way to the chip, xl_start() would try to splice new chains onto the end
of the current chain by stopping the transmitter, modifying the tail
pointer of the current chain to point to the head of the new chain, then
restart the transmitter. The manual says you're allowed to do this and
it works, but I'm not too keen on it anymore.

The new code waits until the eixsting chain has been sent and then
queues the next waiting chain in the 'transmit ok' handler.

Performance still looks good one way or the other.


# 40097 09-Oct-1998 wpaul

Add support for yet another "cyclone" board, with PCI device id 0x905A.
This is a 100BaseFX board with SC fiber media connectors. I don't actually
have one of these but I've been told it works with the xl driver.

Submitted by: Jason Wright from the openbsd group


# 39647 25-Sep-1998 wpaul

Apply patch graciously provided by Jason Wright <jason@thought.net> from
the OpenBSD group to fix a problem with the default ifmedia not being
set properly in some cases with a 3c905B, leading to a panic in ifmedia_set().

Also apply a patch to force the transmit start routine to check the
transmitter to make sure it isn't wedged if the outbound tx queue appears
full. This seems to cure some problems with 'watchdog timeout' errors
cropping up in some cases. I tried to do this before by checking for the
IFF_OACTIVE flag on entry to xl_start(), but if the IFF_OACTIVE flag is
set, ether_output() won't even call xl_start(). It should work now.

Lastly, increase the size of the TX queue from 10 descriptors to 16 to
hopefully make it less likely that the TX queue will fill up.


# 38957 08-Sep-1998 wpaul

- If the OACTIVE flag is set on entry to xl_start(), check to see if the
transmitter is wedged. If so, try to unwedge it, process any descriptors
that might need to be free()d, then proceed.

- Disable the 'background' autonegotiation performed during bootstrap.
What happens currently is that the driver starts an autoneg session,
the sets a timeout in the ifnet structure and returns. Later, when the
timer expires, the watchdog routine calls the autoneg handler to check
the results of the session. The problem with this is that the session
may not complete until some point after we have started to mount NFS
filesystems, which can cause the mounts to fail. This is especially
troublesome if booting with an NFS rootfs: we need the interface up
and running before reaching the mountroot() code.

The default behavior now is to do the autoneg synchronously, i.e. wait
5 seconds for the autoneg to complete before exiting the driver attach
routine. People who want the old behavior can compile the driver with
XL_BACKGROUND_AUTONEG #defined. This has no effect on autoneg sessions
initiated by 'ifconfig xl0 media autoselect.'

This slows the probe down a little, but it's either that or botching
NFS mounts at bootup.

- If xl_setmode_mii() is called and there's an autoneg session in progress,
cancel it, _then_ set the modes.


# 38882 06-Sep-1998 wpaul

Patch the transmit error handler to avoid following NULL pointers and
generating a trap 12 panic. The code blindly assumed that in the event
of a transmit error, the packet that caused the error would still be
at the head of the driver's transmit queue (sc->xl_cdata.xl_tx_head).
However in the case of error 82 (which indicates that a transmit error
occurred after part of the transmit FIFO memory has been reclaimed)
this is not true: the TX queue has already been flushed, and the
pointer to the head of the queue is NULL, so trying to dereference
the pointer to find the transmit descriptor address causes a crash.

The code now checks for a NULL pointer before trying to reload the
chip's download pointer register. There may still be error messages
printed warning of the transmit error, but no panic should occur.

Note that this eror code is only generated with "cyclone" chipsets
(3c900B, 3c905B, and presumeably the 3c980 server adapter). It should
only appear during periods of heavy traffic, probably only on
non-switched networks.

Problem reported by: Darcy Buskermolen <darcy@ok-connect.com>


# 38810 04-Sep-1998 wpaul

Modify the xl_mediacheck() routine to also test for the case where the
XCVR value read from the EEPROM is completely wrong. I've had one report
of a 3c900 card that returns an xcvr value of 14, which is impossible
(the manual states that all vales above 8 are reserved). If the value
is out of the expe

Add PCI vendor ID for the 3c980-TX server adapter card, which apparently
also uses the cyclone chip. Graciously supplied Mats O Jansson
<maja@cntw.com>.

Also noted by Mats, the 10mpbs cyclone adapters should be named 3c900B,
not 3c905B. I haven't actually encountered a 10mbps only cyclone adapter
yet, nor anybody who has one, but this makes sense given the naming
scheme used for the older boomerang adapters.


# 38730 01-Sep-1998 wpaul

"xl%d: chip is is in D%d power mode " -> "xl%d: chip is in D%d power mode "


# 38697 31-Aug-1998 wpaul

Fix handling of ENOBUFS condition. During reception, the filled mbuf
cluster from the RX descriptor is passed up to the higher layers and
replaced with an empty buffer for the next time the descriptor comes
up in the RX ring. The xl_newbuf() routine returns ENOBUFS if it can't
obtain a new mbuf cluster, but this return value was being ignored.
Now, if buffer allocation fails, we leave the old one in place and
drop the packet. This is rude, but there's not much else that can be
done in this situation.

Without this, the driver can cause a panic if the system runs out of
MBUF clusters. Now it will complain loudly, but it shouldn't cause a
panic.

Also added another pair of missing newlines to some printf()s.


# 38660 30-Aug-1998 wpaul

Change the autonegotiation waiting period from 3 seconds to 5. This
delay controls how long the driver waits for autonegotiation to
complete after setting the 'autoneg restart bit' in a PHY. In some
cases, it seems 3 seconds is not long enough: with 3c905-TX cards
(external PHY), you sometimes see 'autoneg not complete; no carrier'
errors due to the timeout being too short. (3c905B adapters seem to
be happy with 3 seconds though.)


# 38526 24-Aug-1998 wpaul

- #define mask of enabled interrupts/indications in if_xlreg.h instead of
constructing local copy in xl_init()
- disable interrupts on entry to xl_intr(), re-enable them on exit.
- fix a few typos in some comments


# 38457 20-Aug-1998 wpaul

Fix small printf() bogon (forgot newline, and the message was longer that
80 cols).


# 38442 19-Aug-1998 wpaul

Make two changes:

If I'm reading the manual correctly, the 3c905B actually loses its
PCI configuration during the transition from D3(hot) back to D0, not
during the transition from D0 to D3(hot). This means it should be possible
to save the existing PCI settings, restet the power state, then restore
the PCI settings afterwards. Changed xl_attach() to attempt this first
thing before the normal PCI setup. I'm not certain this will work correctly,
but it shouldn't hurt.

If xl_init() is called while an autoneg session is in progress, the
autoneg timeout and chip state will get clobbered. Try to avoid this
by checking sc->xl_autoneg at the start of xl_init() and defer
the initialization until later if it's set. (xl_init() is always called
at the end of an autoneg session by xl_autoneg_mii().)

Problem pointed out by: Larry Baird <lab@gta.com>


# 38407 17-Aug-1998 bde

Fixed printf format errors (none detected in GENERIC again).


# 38363 16-Aug-1998 wpaul

Import the (Fast) Etherlink XL driver. I'm reasonally confident in its
stability now. ALso modify /sys/conf/files, /sys/i386/conf/GENERIC
and /sys/i386/conf/LINT to add entries for the XL driver. Deactivate
support for the XL adapters in the vortex driver. LAstly, add a man
page.

(Also added an MLINKS entry for the ThunderLAN man page which I forgot
previously.)