History log of /freebsd-10.1-release/sys/dev/sis/if_sis.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 272461 02-Oct-2014 gjb

Copy stable/10@r272459 to releng/10.1 as part of
the 10.1-RELEASE process.

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

# 266921 31-May-2014 brueffer

MFC: r266270

Remove some unused variables.


# 256281 10-Oct-2013 gjb

Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.

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


# 248456 18-Mar-2013 yongari

r119712 introduced SIS_TYPE_83816 but it was not actually set in
driver such that checking against the type was always false.
To detect NS DP83816, driver should have checked silicon revision
register for NS controllers. While here, remove SIS_TYPE_83816 to
not make the similar mistake again.

Reported by: Brad Smith ( brad@openbsd )


# 243857 04-Dec-2012 glebius

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


# 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


# 229767 07-Jan-2012 kevlo

ether_ifattach() sets if_mtu to ETHERMTU, don't bother set it again

Reviewed by: yongari


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


# 223624 28-Jun-2011 kevlo

Remove duplicate header includes


# 221407 03-May-2011 marius

- Remove attempts to implement setting of BMCR_LOOP/MIIF_NOLOOP
(reporting IFM_LOOP based on BMCR_LOOP is left in place though as
it might provide useful for debugging). For most mii(4) drivers it
was unclear whether the PHYs driven by them actually support
loopback or not. Moreover, typically loopback mode also needs to
be activated on the MAC, which none of the Ethernet drivers using
mii(4) implements. Given that loopback media has no real use (and
obviously hardly had a chance to actually work) besides for driver
development (which just loopback mode should be sufficient for
though, i.e one doesn't necessary need support for loopback media)
support for it is just dropped as both NetBSD and OpenBSD already
did quite some time ago.
- Let mii_phy_add_media() also announce the support of IFM_NONE.
- Restructure the PHY entry points to use a structure of entry points
instead of discrete function pointers, and extend this to include
a "reset" entry point. Make sure any PHY-specific reset routine is
always used, and provide one for lxtphy(4) which disables MII
interrupts (as is done for a few other PHYs we have drivers for).
This includes changing NIC drivers which previously just called the
generic mii_phy_reset() to now actually call the PHY-specific reset
routine, which might be crucial in some cases. While at it, the
redundant checks in these NIC drivers for mii->mii_instance not being
zero before calling the reset routines were removed because as soon
as one PHY driver attaches mii->mii_instance is incremented and we
hardly can end up in their media change callbacks etc if no PHY driver
has attached as mii_attach() would have failed in that case and not
attach a miibus(4) instance.
Consequently, NIC drivers now no longer should call mii_phy_reset()
directly, so it was removed from EXPORT_SYMS.
- Add a mii_phy_dev_attach() as a companion helper to mii_phy_dev_probe().
The purpose of that function is to perform the common steps to attach
a PHY driver instance and to hook it up to the miibus(4) instance and to
optionally also handle the probing, addition and initialization of the
supported media. So all a PHY driver without any special requirements
has to do in its bus attach method is to call mii_phy_dev_attach()
along with PHY-specific MIIF_* flags, a pointer to its PHY functions
and the add_media set to one. All PHY drivers were updated to take
advantage of mii_phy_dev_attach() as appropriate. Along with these
changes the capability mask was added to the mii_softc structure so
PHY drivers taking advantage of mii_phy_dev_attach() but still
handling media on their own do not need to fiddle with the MII attach
arguments anyway.
- Keep track of the PHY offset in the mii_softc structure. This is done
for compatibility with NetBSD/OpenBSD.
- Keep track of the PHY's OUI, model and revision in the mii_softc
structure. Several PHY drivers require this information also after
attaching and previously had to wrap their own softc around mii_softc.
NetBSD/OpenBSD also keep track of the model and revision on their
mii_softc structure. All PHY drivers were updated to take advantage
as appropriate.
- Convert the mebers of the MII data structure to unsigned where
appropriate. This is partly inspired by NetBSD/OpenBSD.
- According to IEEE 802.3-2002 the bits actually have to be reversed
when mapping an OUI to the MII ID registers. All PHY drivers and
miidevs where changed as necessary. Actually this now again allows to
largely share miidevs with NetBSD, which fixed this problem already
9 years ago. Consequently miidevs was synced as far as possible.
- Add MIIF_NOMANPAUSE and mii_phy_flowstatus() calls to drivers that
weren't explicitly converted to support flow control before. It's
unclear whether flow control actually works with these but typically
it should and their net behavior should be more correct with these
changes in place than without if the MAC driver sets MIIF_DOPAUSE.

Obtained from: NetBSD (partially)
Reviewed by: yongari (earlier version), silence on arch@ and net@


# 219902 23-Mar-2011 jhb

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


# 219102 28-Feb-2011 yongari

Make sure changing ownership of RX descriptor to be done as last
operation. Previously ownership was transferred to hardware before
setting address of new RX buffer such that it was possible for
hardware to use wrong RX buffer address.
While here keep compiler from re-ordering instructions by declaring
descriptor members volatile. Memory barriers would do the same job
but volatile is supposed to be cheaper than using memory barriers,
especially on MP systems.

Submitted by: marius
MFC after: 1 week


# 217548 18-Jan-2011 yongari

Rework RX filter programming by providing separate handler for
DP8381[56] and SiS 900/7016 controllers. After r212119, sis(4) no
longer reinitializes controller if ALLMULTI/PROMISC was changed.
However, RX filter handling code assumed some bits of the RX filter
is programmed by driver initialization. This caused ALLMULTI/PROMISC
configuration is ignored under certain conditions.
Fix that issue by reprogramming all bits of RX filter register.
While I'm here follow recommended RX filter programming steps
recommended by National DP8381[56] data sheet(RX filter should be
is disabled before programming).

Reported by: Paul Schenkeveld < freebsd () psconsult dot nl >
Tested by: Paul Schenkeveld < freebsd () psconsult dot nl >
MFC after: 3 days


# 216592 20-Dec-2010 tijl

Merge amd64 and i386 bus.h and move the resulting header to x86. Replace
the original amd64 and i386 headers with stubs.

Rename (AMD64|I386)_BUS_SPACE_* to X86_BUS_SPACE_* everywhere.

Reviewed by: imp (previous version), jhb
Approved by: kib (mentor)


# 214089 19-Oct-2010 yongari

Correct handling of shared interrupt in sis_intr(). r212116 incorrectly
released a drver lock for shared interrupt case such that it caused
panic. While I'm here check whether driver is still running before
serving TX/RX handler.

Reported by: Jerahmy Pocott < QUAKENET1 <> optusnet dot com dot au >
Tested by: Jerahmy Pocott < QUAKENET1 <> optusnet dot com dot au >
MFC after: 3 days


# 213894 15-Oct-2010 marius

Converted the remainder of the NIC drivers to use the mii_attach()
introduced in r213878 instead of mii_phy_probe(). Unlike r213893 these
are only straight forward conversions though.

Reviewed by: yongari


# 212185 03-Sep-2010 yongari

Fix another bug introduced in r212109. We should unload DMA maps
only after sending the last fragment of a frame so the mbuf pointer
also should be stored in the last descriptor index.


# 212167 02-Sep-2010 yongari

Initial WOL support. NS DP8315 was tested but SiS900/SiS7016 was
not tested.
While I'm here, clean up SIOCSIFCAP handler.


# 212166 02-Sep-2010 yongari

Implement initial device suspend/resume method.


# 212157 02-Sep-2010 yongari

Unlike most other controllers, NS DP83815/DP83816 controllers seem
to pad with 0xFF when it encounter short frames. According to RFC
1042 the pad bytes should be 0x00.
Because manual padding consumes extra CPU cycles, introduce a new
tunable which controls the padding behavior. Turning this tunable
on will have driver pad manually but it's disabled by default. Users
can enable software padding by setting the following tunable to
non-zero value.

dev.sis.%d.manual_pad="1"

PR: kern/35422 (patch not used)


# 212156 02-Sep-2010 yongari

Fix the last endianness issue on handling station address which
prevented driver from working on big-endian machines. Also rewrite
station address programming to make it work on strict-alignment
architectures. With this change, sis(4) now works on sparc64 and
performance number looks good even though sis(4) have to apply
fixup code to align received frames on 2 bytes boundary on sparc64.


# 212124 01-Sep-2010 yongari

Fix stupid error in r212109 which didn't swap DMA maps. This caused
IOMMU panic on sparc64 under high TX load.


# 212121 01-Sep-2010 yongari

Move sis_reset() to sis_initl(). This ensures driver starts with
known good state of controller.


# 212120 01-Sep-2010 yongari

Avoid controller reinitialization which could be triggered by
dhclient(8) or alias addresses are added.

PR: kern/87506


# 212119 01-Sep-2010 yongari

Do not reinitialize controller whenever promiscuous mode or
allmulti is toggled. Controller does not require reinitialization.
This removes unnecessary controller reinitialization whenever
tcpdump is used.
While I'm here remove unnecessary variable reinitialization.


# 212117 01-Sep-2010 yongari

Report result of link state change to caller. Previously it always
returned success.


# 212116 01-Sep-2010 yongari

Overhaul link state change handling. Previously sis(4) blindly
configured TX/RX MACs before getting a valid link. After that, when
link state change callback is called, it called device
initialization again to reconfigure TX/RX MACs depending on
resolved link state. This hack created several bad side effects and
it required more hacks to not collide with sis_tick callback as
well as disabling switching to currently selected media in device
initialization. Also it seems sis(4) was used to be a template
driver for long time so other drivers which was modeled after
sis(4) also should be changed.

TX/RX MACs are now reconfigured after getting a valid link. Fix for
short cable error is also applied after getting a link because it's
only valid when the resolved speed is 100Mbps.

While I'm here slightly reorganize interrupt handler such that
sis(4) always read SIS_ISR register to see whether the interrupt is
ours or not. This change removes another hack and make it possible
to nuke sis_stopped variable in softc.


# 212113 01-Sep-2010 yongari

s/u_intXX_t/uintXX_t/g


# 212109 01-Sep-2010 yongari

bus_dma(9) cleanup.
o Enforce TX/RX descriptor ring alignment. NS data sheet says the
controller needs 4 bytes alignment but use 16 to cover both SiS
and NS controllers. I don't have SiS data sheet so I'm not sure
what is alignment restriction of SiS controller but 16 would be
enough because it's larger than the size of a TX/RX descriptor.
Previously sis(4) ignored the alignment restriction.
o Enforce RX buffer alignment, 4.
Previously sis(4) ignored RX buffer alignment restriction.
o Limit number of TX DMA segment to be used to 16. It seems
controller has no restriction on number of DMA segments but
using more than 16 looks resource waste.
o Collapse long mbuf chains with m_collapse(9) instead of calling
expensive m_defrag(9).
o TX/RX side bus_dmamap_load_mbuf_sg(9) support and remove
unnecessary callbacks.
o Initial endianness support.
o Prefer local alignment fixup code to m_devget(9).
o Pre-allocate TX/RX mbuf DMA maps instead of creating/destroying
these maps in fast TX/RX path. On non-x86 architectures, this is
very expensive operation and there is no need to do that.
o Add missing bus_dmamap_sync(9) in TX/RX path.
o watchdog is now unarmed only when there are no pending frames
on controller. Previously sis(4) blindly unarmed watchdog
without checking the number of queued frames.
o For efficiency, loaded DMA map is reused for error frames.
o DMA map loading failure is now gracefully handled. Previously
sis(4) ignored any DMA map loading errors.
o Nuke unused macros which are not appropriate for endianness
operation.
o Stop embedding driver maintained structures into descriptor
rings. Because TX/RX descriptor structures are shared between
host and controller, frequent bus_dmamap_sync(9) operations are
required in fast path. Embedding driver structures will increase
the size of DMA map which in turn will slow down performance.


# 212105 01-Sep-2010 yongari

Nuke unnecessary return at the end of function.


# 212104 01-Sep-2010 yongari

style(9) - space after keywords.


# 212103 01-Sep-2010 yongari

Remove leading and trailing white spaces.
No functional changes.


# 206909 20-Apr-2010 brucec

It's not necessary to reset the chip every time an input overflow event
occurs. In addition, the delay when programming the short cable fix
should be 100us, not 100ms.

PR: kern/64556
Submitted by: Thomas Hurst <tom at hur.st>
Approved by: rrs (mentor)
MFC after: 1 week


# 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


# 188550 13-Feb-2009 yongari

Receving VLAN oversized frames raise SIS_ISR_RX_ERR interrupt, so
make sis_rxeof() handle that too. Previously it used to receive the
frame and reset controller.

PR: kern/131414


# 188463 10-Feb-2009 imp

Fix shutdown prototypes.


# 185784 09-Dec-2008 yongari

Fix a long standing VLAN tagged frame handling bug.
When VLAN tagged frame is received the hardware sets 'LONG' bit of
Rx status word. It is always set when the size of received frame
exceeded 1518 bytes, including CRC. This VLAN tagged frame clears
'OK' bit of Rx status word such that driver should not rely on 'OK'
bit of Rx status word to pass the VLAN tagged frame to upper stack.

To fix the bug, don't use SIS_CMDSTS_PKT_OK for Rx error check and
introduce SIS_RXSTAT_ERROR macro that checks Rx errors. If we are
configured to accept VLAN tagged frames and the received frame size
is less than or equal to maximum allowed length of VLAN tagged
frame, clear 'LONG' bit of Rx status word before checking Rx
errors.

Reported by: Vladimir Ermako < samflanker <> gmail DOT com >
Tested by: Vladimir Ermako < samflanker <> gmail DOT com >


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


# 182065 23-Aug-2008 imp

There actually were bugs in the original handling that I missed last
night.

Free the children after each pci bus that is searched. Otherwise we
leak them. With free in the new place, we also have to free children
before going to done when we find the device we're looking for.

Also, if we can't get the children of a device, just ignore that bus.


# 182036 23-Aug-2008 imp

Actually revert last... Upon closer inspection the code works in the
face of errors already... A bit unorthodox, but none-the-less valid.


# 182035 23-Aug-2008 imp

Handle errors in device_get_children gracefully.


# 181524 10-Aug-2008 imp

Move sis to sys/dev/sis for consistency.


# 181002 30-Jul-2008 jhb

Set all of the "optimum performance" PHY registers for the 15D parts as
well as the 15C since it seems to be required in practice. The Linux
natsemi.c driver mostly does this as well.

PR: kern/112179
Submitted by: Mark Willson mark - hydrus org uk
MFC after: 1 week


# 181000 30-Jul-2008 jhb

SIS_SETBIT() already does a read/modify/write operation, so there isn't
a reason to read the register twice.

MFC after: 1 week


# 166940 24-Feb-2007 delphij

Convert sis(4) to use its own watchdog procedure.

Submitted by: Florian C. Smeets <flo kasimir com>


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


# 163892 01-Nov-2006 marius

Remove <sys/types.h>; including both <sys/param.h> and <sys/types.h>
violates style(9).


# 163773 29-Oct-2006 marius

Wrap code optimized for architectures without alignment constraints
in #ifdef __NO_STRICT_ALIGNMENT rather than #if defined(__i386__) ||
defined(__amd64__). Currently this change is cosmetic only though.
While at it, fix a nearby style(9) bug and remove a no longer used
header.


# 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


# 150583 26-Sep-2005 jhb

Small fixes to sis(4):
- Remove sis_unit and use device_printf() and if_printf() instead.
- Use callout_init_mtx() for the callout.
- Remove spls.
- Fix locking for ifmedia to happen in the ifmedia handlers rather than in
sis_ioctl().
- Log an error message if we fail to allocate any resources. Perform
cleanup if we fail to allocate any resources so that we don't leave
a mutex hanging around.

Tested by: Jason Tsai jason dot tsai at newcyberian dot com (1-4)
MFC after: 3 days


# 150526 24-Sep-2005 phk

Use the new bus_space/resource convenience functions.


# 150369 20-Sep-2005 phk

Move code macros from if_sis*reg*.h to if_sis.*c*


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


# 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


# 148444 27-Jul-2005 jhb

Fix a typo in the name of the dmamap for a bus_dmamap_sync().

MFC after: 3 days


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


# 144243 28-Mar-2005 obrien

Bring rev 1.31 to the AMD64 platform.
This adds support for the SiS intergrated NIC on some Athlon64 motherboards.
The MAC address is stored in the APC CMOS RAM and this fixes the
sis driver ending up with a 00:00:00:00:00:00 MAC address.

Submitted by: Stasys Smailys <ssmailys@komvista.lt>


# 142398 24-Feb-2005 imp

Return BUS_PROBE_DEFAULT instead of 0.


# 139974 10-Jan-2005 ru

Reimplement the fix in rev. 1.126.

OK'ed by: phk


# 139944 09-Jan-2005 sam

correct direction for bus_dma sync of rx buffer

Submitted by: Tai-hwa Liang


# 139887 07-Jan-2005 phk

Fix compilation of DEVICE_POLLING code.


# 139825 07-Jan-2005 imp

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


# 139810 06-Jan-2005 phk

We no longer recurse the mutex.


# 139809 06-Jan-2005 phk

If we get an interrupt and the interface is down, return before we
grab the lock. This should help a tiny bit on machines where unused
if_sis interfaces share IRQ.


# 139808 06-Jan-2005 phk

Don't tweak DSP on the ..16 chips.


# 139807 06-Jan-2005 phk

Fix for an issue with excessive collisions in half duplex mode.


# 139806 06-Jan-2005 phk

Nail the short cable problem the exact way National says it should be.


# 139805 06-Jan-2005 phk

Simplify and fix bugs in rx/tx ring cleanup.


# 139802 06-Jan-2005 phk

Rewrite the rx/tx ring initialization to use pointers instead of arrays.


# 139801 06-Jan-2005 phk

Eliminate a bunch of unnecessary prototypes.


# 139800 06-Jan-2005 phk

Move the module related stuff to the bottom of the file. This will
allow us to save prototypes.


# 139798 06-Jan-2005 phk

Make sure to clear any pending interrupts when we stop the interface.


# 139797 06-Jan-2005 phk

Close a theoretical race: By the time the watchdog comes around
the interface may have been stopped, so we should not restart it.


# 139741 05-Jan-2005 phk

Align if else if properly


# 139740 05-Jan-2005 phk

Style: new-speak functions, remove pointless "return".


# 139717 05-Jan-2005 phk

Make sis_initl() take a typed argument.
Expect caller to lock before calling sis_stop()
Various style stuff.


# 139715 05-Jan-2005 phk

Add locked/unlocked variants of sis_init()


# 139714 05-Jan-2005 phk

Make a locked and unlocked variant of sis_start()


# 139708 05-Jan-2005 phk

Don't declare variables "register", the compiler ought to know what to do.


# 139691 04-Jan-2005 phk

Instead of keeping track of the index into the receive ring use the already
implemented "sis_nextdesc" pointer to keep a pointer instead.


# 139690 04-Jan-2005 phk

Forget about the sis_list_data and sis_ring_data structures and embedd
their fields directly in the softc structure.

This is a no-op which shortens most of the affected source lines
by N * 10 characters.


# 139689 04-Jan-2005 phk

Prototype busdma callback using the typedef.


# 136269 08-Oct-2004 mlaier

Fix sis, bfe and ndis in the same way dc was fixed:
Do not tell the hardware to send when there were no packets enqueued.

Found and reviewed by: green
MFC after: 1 days


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


# 129876 30-May-2004 phk

Add some missing <sys/module.h> includes which are masked by the
one on death-row in <sys/kernel.h>


# 129636 23-May-2004 rwatson

Only initialize the if_sis callout as MPSAFE if debug.mpsafenet is set
true. Otherwise, assertion checks for Giant in the network stack will
fail causing a panic.

Reported by: simon


# 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


# 128138 11-Apr-2004 ru

Implemented per-interface polling(4) control.


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


# 123833 25-Dec-2003 phk

Vastly improve performance of IRQ handling on stopped interfaces with
this driver by introducing a flag saying we already stopped the device.

On my Soekris net4801, this took a ping -i 0.001 from spending 80% of
time in interrupt handling to 10% (approx numbers).

This was a particular problem for the net4801 because the tree
interfaces share the same interrupt, but it would be a problem for
any configuration where an unused if_sis interface shares an interrupt
with a busy device.

Other drivers may have similar problems.

Thanks to: Luigi


# 123491 12-Dec-2003 phk

Attempt to get the short cable fix to work better on the if_sis:

Only do short-cable on revisions that need it.

Move generic initialization before short-cable fix, in order to not
clobber short cable fix register setting.


# 123289 08-Dec-2003 obrien

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

Requested by: bde,imp


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


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


# 121697 29-Oct-2003 sam

mark interrupt handlers MPSAFE


# 121262 19-Oct-2003 silby

Fix m_head handling in sis_encap so that the correct mbuf is always handed
to BPF_MTAP.


# 119785 05-Sep-2003 sam

change timer to MPSAFE

Sponsored by: FreeBSD Foundation


# 119712 03-Sep-2003 phk

Examine and record the Silicon Revision Register on NS parts.

We can't update the device description in attach (why not ?), so
we device_print() what we find.

Conditionalize the short cable fix on this being older than rev 16A.

Call device_printf() when we apply short cable fix.

Include interrupt hold-off setting for rev 16+ under "#ifdef notyet"

The device_printf()'s will go under bootverbose once the various
issues have settled a bit.


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


# 119130 19-Aug-2003 sam

"short cable" fix for DP8315

Derived from: netbsd and tech note at soekris web site
MFC after: 1 week


# 118089 27-Jul-2003 mux

Use the BUS_DMA_ZERO flag.


# 117858 21-Jul-2003 cognet

Erm, my previous commit was wrong and sis_tick() was only called each time
sis_ioctl() was called, so one had to use ifconfig each time the cable got
plugged in to be able to use the connection.
Do it a better way now, add a "in_tick" field in the softc structure,
call timeout() in sis_tick() and don't call it in sis_init() if in_tick is
non-zero.
Reported by: Landmark Networks
Pointy hat to: cognet


# 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


# 116192 11-Jun-2003 obrien

Use __FBSDID().


# 114770 06-May-2003 cognet

Don't call timeout() in sis_tick(), this is done earlier by mii_tick(), and it
leads to a panic at unload time, as we own 2 instances of callout and
untimeout() only one.
Will I'm there, remove a call to callout_handler_init(), one is enough.

Reviewed by: wpaul


# 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


# 113564 16-Apr-2003 jhb

Remove an unused variable so this compiles again.


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


# 113038 03-Apr-2003 obrien

Use __FBSDID rather than rcsid[].


# 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


# 112808 29-Mar-2003 silby

Have sis_encap use m_defrag if:

1. The chain passed in is > 31 fragments long
or
2. The chain will not fit in the remaining descriptors without
defragmentation.

This is slightly less clear than other network drivers because the sis
chips share one descriptor list for all packets, it seems.

Before this change, a > 127 fragment chain would get stuck in the IFQUEUE
permanently, bringing all network traffic to a halt.

MFC after: 2 weeks


# 111119 19-Feb-2003 imp

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

Approved by: trb


# 109976 28-Jan-2003 mbr

Add PCI revision number for 630A and 900B. Enable parity error detection
on 900B and 635(A).

Re-add the enhanced PHY access register method again for older chipsets,
they do not seem to work with all old chips.

Reviewed by: phk
MFC after: 7 days


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


# 109061 10-Jan-2003 mbr

Make newer integrated SiS900 cards working.

Allow to read EEPROM from LAN. It is shared
between a 1394 controller and the NIC and each
time we access it, we need to set SIS_EECMD_REQ.

Idea from: linux driver source

Reviewed by: luoqi
Obtained from: linux driver source (idea)


# 109060 10-Jan-2003 mbr

Sis no longer implements the enhanced phy control
register, and phy has to be directly accessed via mdio.

Patch converted to CURRENT from STABLE.

Submitted by: luoqi
Reviewed by: luoqi (again)
MFC after: 2 weeks


# 109059 10-Jan-2003 mbr

SIS_CFG_EDB_MASTER_EN indicates the EDB bus is used instead of
the PCI bus. When this bit is set, the Max DMA Burst Size
for TX/RX DMA should be no larger than 64 bytes.

Reviewed by: luoqi
Obtained from: (idea from linux driver source)
MFC after: 2 weeks


# 107833 13-Dec-2002 mux

Correct a harmless problem when creating the DMA tag
used to map mbufs. The maximum size should be MCLBYTES
and not SIS_TX_LIST_SZ. This is probably a typo in
the original commit.

Tested by: cognet


# 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


# 105219 16-Oct-2002 phk

Be consistent about functions being static.

Spotted by: FlexeLint.


# 102334 23-Aug-2002 alfred

Put return values from functions on a line by themselves.

Ok'd previously by: wpaul


# 102089 19-Aug-2002 phk

Remove the SIS_LOCK/SIS_UNLOCK from sis_attach(). It makes WITNESS
barf and there seem to be little room for contention during attach.


# 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


# 101464 07-Aug-2002 luigi

Use new interface for ether_input().
Remove some unnecessary assignments to mbuf fields in sis_newbuf(),
the "length" fields are of no use while the mbuf is in the receive ring.

MFC after: 3 days


# 101340 04-Aug-2002 luigi

Use m_getcl() to allocate mbuf+cluster for the receive ring.

Remove the sis_quick variable, as it was there for testing purposes
only.

MFC after: 3 days


# 99163 30-Jun-2002 luigi

Make sure that if_timer does not get reset if there are packets
still queued for transmission. This should solve the problem of
the device stalling on transmissions if some link event prevents
transmission.

There are other drivers which have the same problem and need to be
fixed in the same way.

MFC after: 3 days


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


# 90328 06-Feb-2002 ambrisko

Fix support for 630ET support. We don't need the Linux part to set the
mii access mode. Fix the device ID and make it read the mac via sis_read_mac.

Reviewed by: imp
MFC after: 1 week


# 89374 14-Jan-2002 wpaul

Fix mind-o: compare sc->sis_rev instead of 'command' when trying to
decide how to read the station address.


# 89296 12-Jan-2002 wpaul

Add support for newer integrated SiS 900 controllers on the 635 and 735
motherboard chipsets. We need to force the chip to reload its MAC address
into the receive filter, and enable software access mode for the PHY.

PR: kern/33294


# 87994 15-Dec-2001 archie

Fix access-after-free bug added in revision 1.31.

Detected by: INVARIANTS
MFC after: 2 days


# 87973 15-Dec-2001 peter

Patch up some existing style bugs and some that crept in with the
DEVICE_POLLING stuff.


# 87902 14-Dec-2001 luigi

Device Polling code for -current.

Non-SMP, i386-only, no polling in the idle loop at the moment.

To use this code you must compile a kernel with

options DEVICE_POLLING

and at runtime enable polling with

sysctl kern.polling.enable=1

The percentage of CPU reserved to userland can be set with

sysctl kern.polling.user_frac=NN (default is 50)

while the remainder is used by polling device drivers and netisr's.
These are the only two variables that you should need to touch. There
are a few more parameters in kern.polling but the default values
are adequate for all purposes. See the code in kern_poll.c for
more details on them.

Polling in the idle loop will be implemented shortly by introducing
a kernel thread which does the job. Until then, the amount of CPU
dedicated to polling will never exceed (100-user_frac).
The equivalent (actually, better) code for -stable is at

http://info.iet.unipi.it/~luigi/polling/

and also supports polling in the idle loop.

NOTE to Alpha developers:
There is really nothing in this code that is i386-specific.
If you move the 2 lines supporting the new option from
sys/conf/{files,options}.i386 to sys/conf/{files,options} I am
pretty sure that this should work on the Alpha as well, just that
I do not have a suitable test box to try it. If someone feels like
trying it, I would appreciate it.

NOTE to other developers:
sure some things could be done better, and as always I am open to
constructive criticism, which a few of you have already given and
I greatly appreciated.
However, before proposing radical architectural changes, please
take some time to possibly try out this code, or at the very least
read the comments in kern_poll.c, especially re. the reason why I
am using a soft netisr and cannot (I believe) replace it with a
simple timeout.

Quick description of files touched by this commit:

sys/conf/files.i386
new file kern/kern_poll.c
sys/conf/options.i386
new option
sys/i386/i386/trap.c
poll in trap (disabled by default)
sys/kern/kern_clock.c
initialization and hardclock hooks.
sys/kern/kern_intr.c
minor swi_net changes
sys/kern/kern_poll.c
the bulk of the code.
sys/net/if.h
new flag
sys/net/if_var.h
declaration for functions used in device drivers.
sys/net/netisr.h
NETISR_POLL
sys/dev/fxp/if_fxp.c
sys/dev/fxp/if_fxpvar.h
sys/pci/if_dc.c
sys/pci/if_dcreg.h
sys/pci/if_sis.c
sys/pci/if_sisreg.h
device driver modifications


# 87472 06-Dec-2001 peter

MFS (merge from stable): rev 1.13.4.13, fix ordering of IFF_RUNNING mods.
The reason we are required to commit to -current first is so that later
MFC's do not risk the loss of existing bug fixes. Even if this was not
strictly required in -current, it should still be fixed there too.


# 87390 05-Dec-2001 jhay

Add VLAN support.

MFC after: 7 days


# 87330 04-Dec-2001 luigi

Remove error messages on mbuf allocation failures, now
this is done more safely in kern/subr_mbuf.c

Two-days'-delay-thanks-to: @home shutting down service


# 87102 29-Nov-2001 luigi

Per jlemon request, reintroduce some printf() when an
mbuf allocation fails, and fix (i hope) a couple of style bugs.

I believe these printf() are extremely dangerous because now they can
occur on every incoming packet and are not rate limited. They were
meant to warn the sysadmin about lack of resources, but now they
can become a nice way to panic your system under load.

Other drivers (e.g. the fxp driver) have nothing like this.

There is a pending discussion on putting this kind of warnings
elsewhere, and I hope we can fix this soon.


# 87059 28-Nov-2001 luigi

Remove the need for an expensive m_devget on the i386, which does not
have alignment problems.

On small boxes (e.g. the net4501 from Soekris, featuring a 486/133)
this provides huge performance benefits: the peak forwarding rate
with avg.sized packets goes up by 50-70% because of this change
alone. Faster CPUs might benefit less from this change, but in any
case the CPU has better things to do than waste time on useless
memory-to-memory copies.

Several drivers (for Tulip-like cards) might benefit from a similar
change.

Right now the new behaviour is controlled by a sysctl variable,
hw.sis_quick which defaults to 1 (on), you can set it to 0 to
reintroduce the old behaviour (and compare the results). The
variable is only there to show how much you can gain with this
change, it will go away soon.

Also, slightly simplify the code to initialize the ring buffers,
and remove a couple of dangerous printf's which could trigger on
any packet in case of mbuf shortage.

MFC-after: 3 days


# 86984 27-Nov-2001 luigi

Fix a bug in the driver -- under load, the receive unit could become
idle and the driver would not detect the event, requiring userland
to cycle the interface to bring it up again.
The fix consists in adding SIS_IMR_RX_IDLE to the interrupt mask and
add a command in sis_intr() to restart the receiver when this happens.

While at it, make the test of status bits more efficient.


# 84147 29-Sep-2001 jlemon

Do not call mii_pollstat() from within device tick routines; the status
information is updated by mii_tick().

Pointed out by: wpaul (a while back)


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


# 72197 08-Feb-2001 wpaul

Apply patch to add support for the intergrated ethernet in the SiS630E
chipset. The MAC address is stored in the APC CMOS RAM and we have to
commit trememdous evil in order to read it. The code to do this is only
activated on the i386 platform. Thanks to Cameron Grant for providing
access to a test box for me to tinker with.

This will fix the problem where the sis driver ends up with a station
address of 00:00:00:00:00:00 on boards that use the 630E chipset.


# 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


# 72012 04-Feb-2001 phk

Another round of the <sys/queue.h> FOREACH transmogriffer.

Created with: sed(1)
Reviewed by: md5(1)


# 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


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


# 68216 01-Nov-2000 wpaul

Fix a couple of cases where I tried to release the I/O space resource twice
(once as as an I/O space resource and once as an IRQ resource). There was
a problem with this in if_rl too, which is how I found it.


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


# 64963 22-Aug-2000 wpaul

Fix up the sis driver, largely to improve the NatSemi DP83815 support:

- Modify the driver to poll the link state and positively set the
MAC to full or half duplex as needed. Previously, it was possible
for the MAC to remain in half duplex even though the PHY had negotiated
full duplex with its link partner, which would result in bursty
performance.

- Program some of the NatSemi's registers as specified by the datasheet.
The manual says these are necessary for "optimum perofrmance," though
a couple of them are marked as reserved in the register map. *shrug*

- Select the TX DMA burst size correctly for 10 and 100mbps modes.
Previously I was using 64 bytes in both modes, which worked in
100mbps mode, but resulting in spotty performance in 10mbps.
32 bytes works much better; without this change, the natsemi
chip yields piss poor performance at 10mbps.

With these fixes, the NatSemi chip finally performs to my satisfaction.
I should be merging the support for this controller into -stable shortly.

Phew.


# 63103 14-Jul-2000 wpaul

sis_miibus_writereg() was checking for SIS_TYPE_900 and phy != 0 twice
due to a small cut & paste-o on my part. It happens this didn't hurt
anything, but it's still wrong.


# 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


# 62681 06-Jul-2000 wpaul

Fix a minor bug in the MAC address unscrambling code.
(Some shift rights should have been shift lefts.)


# 62672 06-Jul-2000 wpaul

Add support for the National Semiconductor DP83815 fast ethernet
controller chip. This chip is currently being used on the NetGear
FA312-TX adapter, which I guess is a replacement for the FA310-TX
(PNIC-based).

I added support for this chip by modifying the sis driver since
the SiS 900 and the NS DP83815 have almost the same programming
interface (the RX filter programming and PHY access methods are
different, but the general configuration, DMA scheme and register
layout are identical).

I would have had this done a lot sooner, but getting the damn MAC
address out of the EEPROM proved to be more complicated than expected.


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


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


# 51042 06-Sep-1999 wpaul

Fix an instance of FOO_RX_LIST_CNT that should have been FOO_TX_LIST_CNT.


# 51031 06-Sep-1999 wpaul

Remember to re-arm the timeout for the tick routine.


# 51030 06-Sep-1999 wpaul

Fix definitions for RID and RES if we're not using IOSPACE. I copied the
two lines and forgot to change them for the !IOSPACE case. Not a big deal
since PCI memory mapped mode is off by default, but I still feel silly.


# 50974 05-Sep-1999 wpaul

This commit adds driver support for the Silicon Integrated Systems
SiS 900 and SiS 7016 PCI fast ethernet chipsets. Full manuals for the
SiS chips can be found at www.sis.com.tw.

This is a fairly simple chipset. The receiver uses a 128-bit multicast
hash table and single perfect entry for the station address. Transmit and
receive DMA and FIFO thresholds are easily tuneable. Documentation is
pretty decent and performance is not bad, even on my crufty 486. This
driver uses newbus and miibus and is supported on both the i386 and
alpha architectures.