History log of /freebsd-11-stable/sys/dev/sk/if_sk.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 331722 29-Mar-2018 eadler

Revert r330897:

This was intended to be a non-functional change. It wasn't. The commit
message was thus wrong. In addition it broke arm, and merged crypto
related code.

Revert with prejudice.

This revert skips files touched in r316370 since that commit was since
MFCed. This revert also skips files that require $FreeBSD$ property
changes.

Thank you to those who helped me get out of this mess including but not
limited to gonzo, kevans, rgrimes.

Requested by: gjb (re)


# 330897 14-Mar-2018 eadler

Partial merge of the SPDX changes

These changes are incomplete but are making it difficult
to determine what other changes can/should be merged.

No objections from: pfg


# 302408 07-Jul-2016 gjb

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

Additional commits post-branch will follow.

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


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

sys/dev: minor spelling fixes.

Most affect comments, very few have user-visible effects.


# 295873 21-Feb-2016 yongari

ifnet lock was changed to use sx(9) long time ago.
Don't hold a driver lock for if_free(9).


# 273028 13-Oct-2014 rwatson

Eliminate unnecessary checking for M_EXT on mbufs returned by m_getjcl().

Reviewed by: bz, glebius, yongari
MFC after: 3 days
Sponsored by: EMC / Isilon Storage Division
Differential Revision: https://reviews.freebsd.org/D938


# 271849 19-Sep-2014 glebius

Mechanically convert to if_inc_counter().


# 270856 30-Aug-2014 glebius

Use define from if_var.h to access a field inside struct if_data,
that resides in struct ifnet.

Sponsored by: Nginx, Inc.


# 267363 11-Jun-2014 jhb

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

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

Reviewed by: yongari
MFC after: 2 weeks


# 266270 16-May-2014 brueffer

Remove some unused variables.

Found with: Clang Static Analyzer
MFC after: 2 weeks


# 260016 28-Dec-2013 dim

Remove superfluous old-style rcsid[] from if_sk.c. There is already an
__FBSDID() at the top of the file.

MFC after: 3 days


# 257176 26-Oct-2013 glebius

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

Sponsored by: Netflix
Sponsored by: Nginx, Inc.


# 251133 30-May-2013 marius

- Merge from r249476: Ensure that PCI bus BUS_GET_DMA_TAG() method sees
the actual PCI device which makes the request for DMA tag, instead of
some descendant of the PCI device, by creating a pass-through trampoline.
- Sprinkle const on tables.
- Use NULL instead of 0 for pointers.
- Take advantage of nitems().

MFC after: 1 week


# 243857 04-Dec-2012 glebius

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


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


# 219544 11-Mar-2011 marius

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

MFC after: 2 weeks


# 214899 06-Nov-2010 yongari

Fix a long standing bug in programming station address for Yukon
controllers. sk(4) never reprogrammed station address for Yukon
controllers so overriding station address with ifconfig(8) was not
possible.
Fix the bug by reprogramming all registers that control station
address, flow-control and virtual station address. Virtual station
address has no use at this moment since driver does not make use of
fail over feature.

Tested by: "Mikhail T." <mi+thun <> aldan.algebra.com>
MFC after: 1 week


# 214898 06-Nov-2010 yongari

If we got an invalid station address, generate random address. This
might be caused by broken BIOS.

Reported by: "Mikhail T." <mi+thun <> aldan.algebra.com>
MFC after: 1 week


# 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


# 209865 09-Jul-2010 yongari

Some revision of Yukon controller generates corrupted frame when TX
checksum offloading is enabled. The frame has a valid checksum
value so payload might be modified during TX checksum calculation.
Disable TX checksum offloading but give users chance to enable it
when they know their controller works without problems with TX
checksum offloading.

Reported by: Andrzej Tobola <ato <> iem dot pw dot edu dot pl>


# 198988 06-Nov-2009 jhb

Take a step towards removing if_watchdog/if_timer. Don't explicitly set
if_watchdog/if_timer to NULL/0 when initializing an ifnet. if_alloc()
sets those members to NULL/0 already.


# 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


# 191716 01-May-2009 yongari

Separate multicast filtering of SysKonnect GENESIS and Marvell
Yukon from common multicast handling code. Yukon uses hash-based
multicast filtering(big endian form) but GENESIS uses perfect
multicast filtering as well as hash-based one(little endian form).
Due to the differences of multicast filtering there is no much
sense to have a common code.
o Remove sk_setmulti() and introduce sk_rxfilter_yukon(),
sk_rxfilter_yukon() that handles multicast filtering setup.
o Have sk_rxfilter_{yukon, genesis} handle promiscuous mode and
nuke sk_setpromisc(). This simplifies ioctl handler as well as
giving a chance to check validity of Rx control register of
Yukon.
o Don't reinitialize controller when IFF_ALLMULTI flags is changed.
o Nuke sk_gmchash(), it's not needed anymore.
o Always reconfigure Rx control register whenever a new multicast
filtering condition is changed. This fixes multicast filtering
setup on Yukon.

PR: kern/134051


# 176265 13-Feb-2008 yongari

Prefer NULL over integer 0 for pointer type.


# 176264 13-Feb-2008 yongari

Nuke local jumbo allocator and switch to use of UMA backed page
allocator for jumbo frame.
o Removed unneeded jlist lock which was used to manage jumbo
buffers.
o Don't reinitialize hardware if MTU was not changed.
o Added additional check for minimal MTU size.
o Added a new tunable hw.skc.jumbo_disable to disable jumbo frame
support for the driver. The tunable could be set for systems that
do not need to use jumbo frames and it would save
(9K * number of Rx descriptors) bytes kernel memory.
o Jumbo buffer allocation failure is no longer critical error for
the operation of sk(4). If sk(4) encounter the allocation failure
it just disables jumbo frame support and continues to work without
user intervention.

With these changes jumbo frame performance of sk(4) was slightly
increased and users should not encounter jumbo buffer allocation
failure. Previously sk(4) tried to allocate physically contiguous
memory, 3388KB for 256 Rx descriptors. Sometimes that amount of
contiguous memory region could not be available for running systems
which in turn resulted in failure of loading the driver.

Tested by: Cy Schubert < Cy.Schubert () komquats dot com >


# 175872 01-Feb-2008 phk

Give MEXTADD() another argument to make both void pointers to the
free function controlable, instead of passing the KVA of the buffer
storage as the first argument.

Fix all conventional users of the API to pass the KVA of the buffer
as the first argument, to make this a no-op commit.

Likely break the only non-convetional user of the API, after informing
the relevant committer.

Update the mbuf(9) manual page, which was already out of sync on
this point.

Bump __FreeBSD_version to 800016 as there is no way to tell how
many arguments a CPP macro needs any other way.

This paves the way for giving sendfile(9) a way to wait for the
passed storage to have been accessed before returning.

This does not affect the memory layout or size of mbufs.

Parental oversight by: sam and rwatson.

No MFC is anticipated.


# 173839 22-Nov-2007 yongari

Fix function prototype for device_shutdown method.


# 170035 27-May-2007 rwatson

Universally adopt most conventional spelling of acquire.


# 169443 10-May-2007 mckay

Make a missing or empty VPD non-fatal, as it was prior to rev 1.131.
With this change, my D-Link DGE-530T rev A1 is operational again.


# 168251 02-Apr-2007 yongari

Use our own timer for watchdog instead of if_watchdog/if_timer
interface.


# 166901 23-Feb-2007 piso

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

o add an int return code to all fast handlers

o retire INTR_FAST/IH_FAST

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

Reviewed by: many
Approved by: re@


# 166165 21-Jan-2007 marius

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


# 165197 14-Dec-2006 yongari

Remove incomplete Yukon II support code which was added in if_sk.c, rev 1.123.
Yukon II users should use msk(4).


# 163163 09-Oct-2006 jmg

provide routines to access VPD data at the PCI layer...

remove sk's own implementation, and use the new calls to get the data...

Reviewed by: -arch


# 161235 11-Aug-2006 yongari

Fix invalid reference of mbuf chains.
Use proper pointer dereference to inform modified mbuf chains to
caller.

In collaboration with: glebius


# 160898 02-Aug-2006 yongari

Fix incorrect busy check for PHY write operation.
While I'm here remove unnecessary return statement.


# 160738 27-Jul-2006 yongari

Add device ID for second generation D-Link DGE-530T.

PR: kern/99903


# 160492 19-Jul-2006 yongari

Convert sk(4) to use the new bus_alloc_resources() API and
bus_{read,write}_* macros.

Submitted by: Antoine Brodin <antoine.brodin AT laposte DOT net>
Reviewed by: imp (initial version)


# 160104 05-Jul-2006 yongari

Fix typo in comment.

Submitted by: brad AT OpenBSD DOT org


# 159366 07-Jun-2006 yongari

Fix watchdog timeout errors seen on a few systems.
SK-NET GENESIS document says reading SK_ISSR should stop generating
further interrupts(Since we drop a driver lock before invoking
ifp->if_input handler we should disable interrupts in ISR in order
to protect integrity of softc from subsequent interrupts). But it
seems that there is possibility of loosing interrupts between
reading SK_ISSR and determining which interrupts are reported.
To cope with the situation we continuously read SK_ISSR register
until there are no interrupts. However, it seems that the above
work around doesn't fix all cases. To protect watchdog handler
from triggering false alarm add a work around code which try to
reclaim pending Tx descriptors before resetting hardware. This
should fix occasional watchdog timeout errors seen on this driver.

Reported by: Frank Behrens <frank AT pinky dot sax dot de >
Tested by: Frank Behrens <frank AT pinky dot sax dot de >


# 158586 15-May-2006 yongari

Re-wrok PHY setup, media handling and dual-port detection.
With this change SysKonnect SK-9521 v2.0 and SK-9821 v2.0
adapter now works.

Obtained from: OpenBSD
Reported by: Ganbold ganbold ! micom ( mng $ net
Tested by: Ganbold ganbold ! micom ( mng $ net


# 158205 01-May-2006 sobomax

Don't attach to Marvell 88E805X (Yukon-II) by default, the driver is not
functional yet.

Requested by: bz


# 158096 28-Apr-2006 sobomax

Add some incomplete support for Marvell Yukon EC controllers based on
OpenBSD changes. With these changes, PHY part of the driver becomes
functional (it senses media changes and negotiates speed just fine),
previously it just hang with no PHY message, but no data goes through
interface (error message is "can not stop transfer of Tx/Rx descriptor).

Hopefully somebody with more clue/free time will be able to pick up
after me.


# 158070 27-Apr-2006 yongari

Bring busdmafied sk(4) to all architectures.
- MPSAFE. No more recursive lock required.
- bus_dma(9) conversion. I think it should work on all architectures.
- optimized Rx handler for each normal and jumbo frames. Previously
sk(4) used jumbo frame management code to handle normal sized
frames. As the handler needs an additional lock to protect jumbo
frame management structure from races, it used two lock operations
for each received packet. Now sk(4) uses single lock operation for
normal frame.(Jumbo frame still needs two lock operations as before.)
The hardware supports DMA scatter operations for Rx descriptors such
that it's possible to take advantagee of m_cljget(9) for jumbo frames.
However, due to a unknown reasons it resulted in poor performance on
sparc64. So I dropped m_cljget(9) approach. This should be revisited
since it would reduce one lock operation for jumbo frame handling.
- Tx TCP/Rx IP checksum offload support. According to the data sheet
of SK-NET GENESIS the hardware supports Rx IP/TCP/UDP offload.
But I couldn't make it work on my Yukon hardware. So Rx TCP/UDP was
disabled at the moment. It seems that newer Yukon chips can support
Tx UDP checksum offload too. But I need more documentation first.
- Added more wait time in reading VPD data. It seems that ASUS LOM
takes a very long time to respond VPD read signal.
- Added an additional lock for MII register access callbacks.
- Added more strict received packet validation routine. Previously it
passed corrupted packets to upper layers under certain conditions.
- A new function sk_yukon_tick() to handle auto-negotiation properly.
- Interrupt handler now checks shared interrupt source and protects
the interrupt handler from NULL pointer dereference which was caused
by odd status word value. The status word can returns 0xffffffff if
cable is unplugged while Rx/Tx/auto-negotiation is in progress.
- suspend/resume support(not tested).
- Added Rx/Tx FIFO flush routine for Yukon
- Activate Tx descriptor poll timer in order to protect possible loss
of SK_TXBMU_TX_START command. Previously the driver continuously issued
SK_TXBMU_TX_START when it notices pending Tx descriptors not processed
yet in interrupt handler. That approach would add additional PCI
write access overhead under high Tx load situations and it might fail
if the first SK_TXBMU_TX_START was lost and no interrupt is generated
from the first SK_TXBMU_TX_START command.
- s/printf/if_printf/, s/printf/device_printf/, Axe sk_unit in softc.
- Setting multicast/station address is now safe on strict-alignment
architectures.
- Fix long standing bug in VLAN header length setup.
- Added/corrected register definitions for Yukon.
(Register information from Linux skge driver.)
- Added Rx status definition for Marvell Yukon/XaQti XMAC.
(Rx status register information from Linux skge driver.)
- Update if_oerrors if we encounter watchdog error.
- callout(9) conversion

Special thanks to jkim who let me know RX status differences between
Yukon and XaQti XMAC.
It seems that there is still occasional watchdog timeout error but I
couldn't reproduce it and need more information to analyze it from
users.

Tested by: bz(amd64), me(i386, sparc64), current ML
Frank Behrens frank ! pinky ( sax $ de


# 158065 27-Apr-2006 yongari

Correct DRIVER_MODULE declaration.
skc does attach to pci bus instead of sk.

Submitted by: jmg


# 158061 26-Apr-2006 yongari

The sk(4) driver has moved to /sys/dev/sk


# 155671 14-Feb-2006 glebius

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


# 154448 17-Jan-2006 yongari

fix interrupt moderation timer frequencies for Yukon

Obtained from: OpenBSD


# 154447 17-Jan-2006 yongari

remove trailing spaces


# 154388 14-Jan-2006 bz

Remove unused code.

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.


# 151545 22-Oct-2005 imp

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


# 151341 14-Oct-2005 jhb

Only allow the sk(4) driver to attach to revision 2 of the LinkSys EG1032
cards and teach the re(4) driver to attach to revision 3 cards.

Submitted by: Fredrik Lindberg fli+freebsd-current at shapeshifter dot se
MFC after: 2 weeks
Reviewed by: imp, mdodd


# 151242 11-Oct-2005 yar

Mark sk(4) as capable of handling extended VLAN frames. NICs
based on XMAC II chip should be ready for this in their initial
mode of operation, and Yukon-based NICs are configured so by
the driver.

PR: kern/79998
MFC after: 1 month


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


# 149021 13-Aug-2005 bz

* Solve "No PHY found" problem for more Yukon Lite variants.
* Catch a bus attach error.
* Improve locking.

MFC after: 6 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


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


# 145501 25-Apr-2005 bz

Deal with failed malloc calls[1].
While there also check for failed device_add_child calls.

Found by: Coventry Analysis tool[1].
Submitted by: sam[1]
Approved by: pjd (mentor)
MFC after: 1 week


# 144164 26-Mar-2005 sam

handle malloc failure and sk_vpd_prodname potentially being null for
other reasons

Noticed by: Coverity Prevent analysis tool
Reviewed by: bz, jmg


# 143754 17-Mar-2005 bz

Do not try to free non allocated memory in error case.
Do our best to plug some memory leaks (VPD data, jumbo memory buffer,...).
Log if we cannot free because memory still in use[1].
Change locking to avoid ''acquiring duplicate lock of same
type: "network driver"'' and potential deadlock. Also seems to fix LOR #063.

[1] This change does not solve problems if buffers are still in use when
unloading if_sk.ko. There is ongoing work which will address jumbogram
allocations in a more general way.

PR: kern/75677 (with changes, no mii fixes in here)
Tested by: net, Antoine Brodin (slightly different version)
Approved by: rwatson (mentor)
MFC after: 5 days


# 143753 17-Mar-2005 bz

* Lower interrupt moderation timer 200->100.
Obtained from: NetBSD if_sk.c rev. 1.11

* Make interrupt moderation configurable via sysctl/tuneable.
PR: kern/41220
Approved by: rwatson (mentor)


# 143752 17-Mar-2005 bz

* Improve chip identification.
Obtained from: NetBSD if_sk.c rev. 1.11

* Take PHY out of reset for Yukon Lite Rev. A3.
Submitted by: postings on net@ in thread "skc0: no PHY found", 2005-02-22

Tested by: net
Approved by: rwatson (mentor)
MFC after: 5 days


# 143751 17-Mar-2005 bz

* When adding/deleting multicast addresses, only whack the address filter
if the interface is marked RUNNING.
Obtained from: NetBSD if_sk.c rev. 1.12

* Don't initialize the card (and start an autonegotiation) every time the IP
address changes. Makes 'dhclient sk0' invocations way faster and more
consistant. i.e. one DHCPREQUEST elicits the DHCPACK.
Obtained from: OpenBSD if_sk.c rev. 1.56

* Additional locking changes in sk_ioctl.

PR: kern/61296 should see improvements by the last two.
Approved by: rwatson (mentor)
MFC after: 5 days


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


# 140970 29-Jan-2005 bz

Cleanup debugging code and put it under bootverbose
(includes minor style polishing).

Approved by: rwatson (mentor)


# 139825 07-Jan-2005 imp

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


# 139263 24-Dec-2004 mlaier

Enable sk(4) for ATLQ.

Thoroughly tested by: Ender <ender NO tog SPAM net>
MFC after: 4 weeks


# 139059 20-Dec-2004 bz

Enable jumbo frames on Yukon variants of sk(4).

In contrast to OpenBSD we enable jumbo frame support
depending on MTU setting (like done for xmac).

Approved by: pjd (mentor)
Obtained from: OpenBSD if_sk.c r1.52 (YU_SMR_MFL_JUMBO flag)
Tested by: Heinz Knocke <knockefreebsd at o2 dot pl>
MFC after: 5 days


# 137827 17-Nov-2004 jmg

only clear the IFF_OACTIVE flag when we have a chance of being able to
queue a packet to the hardware... instead of when the hardware queue is
empty..

don't initalize cur_tx now that it doesn't need to be...

Pointed out by: bde


# 137756 15-Nov-2004 jmg

move the lock after the NULL check so we don't have a hard(er) to diagnose
panic...

Pointed out by: Bjoern A. Zeeb


# 137743 15-Nov-2004 jmg

fix the missing lock in sk_jfree (verified w/ an assert)
also fix up handling and proding of the tx, _OACTIVE is now handled
better...

Submitted by: Peter Edwards (sk_jfree)
Obtained from: OpenBSD and/or NetBSD (tx prod)


# 137699 14-Nov-2004 obrien

Commit more debugging output. This is a little bit of using a large hammer,
but sk(4) is so prevalent on AMD64 motherboards we need to reduce the number
of round trips in the mailing lists trying to get sufficient information to
make sure we've got a handle on all the problems and are working towards
making sk(4) solid.

Submitted by: bz


# 137674 13-Nov-2004 bz

Set ramsize depending on a value from eprom instead of using
hardcoded 128k for Yukon devices. 88E8001 only has 64k of on-chip RAM[1].

[1] http://www.marvell.com/products/pcconn/yukon/Yukon_88E8001_10_073103_final.pdf

Tested by: amd64, current
Approved by: rwatson (mentor)
MFC after: 1 week


# 137111 01-Nov-2004 obrien

* Correct an off-by-one reading vpd ro data.
* Announce some more fields from ro area for better debugging of broken
sk(4)s on various boards.

Submitted by: Bjoern A. Zeeb <bzeeb-lists@lists.zabbadoz.net>


# 134072 20-Aug-2004 jmg

fix LOR's in sk. Original patch from dwhite. This moves the memory
allocation earlier on in sk_attach so we don't have to lock until a bit
later.

PR: 69752


# 134066 20-Aug-2004 jmg

put function's name at begining of column...


# 134064 20-Aug-2004 jmg

add pci id for Belkin F5D5005 Gigabit ethernet card.


# 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


# 129413 19-May-2004 imp

Replace the lame big endian crc with wpaul's standard big endian crc
algorithm, supplied by wpaul himself. The lame one has an origin
that's been called into question, so rather than argue about that (one
could make an excellent fair use argument), replace it with better
code since that's what FreeBSD is about.

Submitted by: wpaul[1], Klaus Klein

[1] Bill called this a silly bikeshed. Maybe his is not incorrect.


# 128439 19-Apr-2004 obrien

Use BSD spelling, no SysV.


# 127672 31-Mar-2004 mckay

Support the D-Link DGE-530T. Mine appears to have a blank eeprom, so assume
they all do and handle that without alarming the user. Also pull in a bit
of defensive code from OpenBSD that triggers when a card is recognised but
not properly classified as either Genesis or Yukon. Not that I could ever
have needed this. :-)

Obtained from: OpenBSD/NetBSD (partially)
MFC after: 2 weeks


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


# 124817 21-Jan-2004 wpaul

Fix multicast and promiscuous mode handling for Yukon devices.

Submitted by: Jung-uk Kim <jkim@niksun.com>


# 123289 08-Dec-2003 obrien

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

Requested by: bde,imp


# 123052 29-Nov-2003 sam

correct typo in interrupt handling for the 2nd port of 2-port cards

Submitted by: luigi
Reviewed by: checking original openbsd code
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).


# 122586 12-Nov-2003 wilko

Add vendor ID to make Marvell chipset work. E.g. to be found
on SMC9452TX it seems

Submitted by: Jung-uk Kim <jkim@niksun.com>
Tested by: <Radu Bogdan 'veedee' Rusu> veedee@c7.campus.utcluj.ro
MFC after: 2 weeks


# 122258 07-Nov-2003 peter

Ahh, the joys of badge engineering. Tell the sk driver that the
Linksys EG1032 is yet another variation. It looks just like the 3c940
except it only has a Marvell logo and no 3com logo.


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


# 120281 20-Sep-2003 wilko

Add support for SK-9521 V2.0 and 3COM 3C940.

Tested at 100Mbit only, using Asus P4P800 onboard 3C940.
The -stable version of this patch I have in use for ~2 weeks now, and works
just fine for me.

Based on: Nathan L. Binkert's patch for OpenBSD
Patch submitted by and thanks to: Jung-uk Kim <jkim@niksun.com>
MFC after: 2 weeks


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


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


# 115528 31-May-2003 phk

Remove unused variables.

Found by: FlexeLint


# 113812 21-Apr-2003 imp

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

Symptoms of problem reported by: martin blapp


# 113609 17-Apr-2003 njl

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


# 113545 16-Apr-2003 mdodd

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


# 113506 15-Apr-2003 mdodd

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


# 113038 03-Apr-2003 obrien

Use __FBSDID rather than rcsid[].


# 112928 01-Apr-2003 phk

Fix KASSERT syntax errors.

Please compile LINT before commiting.


# 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


# 111119 19-Feb-2003 imp

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

Approved by: trb


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


# 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


# 102335 23-Aug-2002 alfred

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


# 99008 28-Jun-2002 alfred

catch up with mextadd callback taking a void argument instead of a caddr_t.


# 95673 28-Apr-2002 phk

Follow NetBSD and s/IFM_1000_TX/IFM_1000_T/


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


# 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


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


# 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


# 76412 09-May-2001 wpaul

The sk driver developed a bug when the multicast code was changed to
use TAILQ macros. The sk_attach_xmac() routine calls sk_init_xmac()
before doing the transceiver probe, but *before* ether_ifattach()
is called. This causes sk_init_xmac() to call sk_setmulti(), which
tries to do a TAILQ_FOREACH(), which it can't do because ether_ifattach()
hasn't done a TAILQ_INIT() yet. This causes a NULL pointer dereference
and panic in sk_setmulti() at driver load/initialization time.

Fixed by calling ether_ifattach() before the MII probe.

The code in RELENG_4 still uses the old way of enumerating the
multicast list and doesn't have this problem. Yet.


# 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


# 71999 04-Feb-2001 phk

Mechanical change to use <sys/queue.h> macro API instead of
fondling implementation details.

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.


# 68621 11-Nov-2000 bmilekic

Change MEXTADD usage to pass the two new arguments.

Reviewed by: jlemon


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


# 67594 25-Oct-2000 wpaul

Add a missing SK_UNLOCK() to sk_attach_xmac().


# 67380 20-Oct-2000 archie

Add actual URL for XMAC II datasheet in comments.


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


# 66997 12-Oct-2000 bmilekic

Make if_sk stop using the "hide the softc structure in the jumbo buffer"
now that the mbuf system can handle passing it to the driver itself.

Reviewed by: wpaul
Tested by: wpaul (Bill Paul) with "jumbograms" enabled


# 64837 19-Aug-2000 dwmalone

Replace the mbuf external reference counting code with something
that should be better.

The old code counted references to mbuf clusters by using the offset
of the cluster from the start of memory allocated for mbufs and
clusters as an index into an array of chars, which did the reference
counting. If the external storage was not a cluster then reference
counting had to be done by the code using that external storage.

NetBSD's system of linked lists of mbufs was cosidered, but Alfred
felt it would have locking issues when the kernel was made more
SMP friendly.

The system implimented uses a pool of unions to track external
storage. The union contains an int for counting the references and
a pointer for forming a free list. The reference counts are
incremented and decremented atomically and so should be SMP friendly.
This system can track reference counts for any sort of external
storage.

Access to the reference counting stuff is now through macros defined
in mbuf.h, so it should be easier to make changes to the system in
the future.

The possibility of storing the reference count in one of the
referencing mbufs was considered, but was rejected 'cos it would
often leave extra mbufs allocated. Storing the reference count in
the cluster was also considered, but because the external storage
may not be a cluster this isn't an option.

The size of the pool of reference counters is available in the
stats provided by "netstat -m".

PR: 19866
Submitted by: Bosko Milekic <bmilekic@dsuper.net>
Reviewed by: alfred (glanced at by others on -net)


# 64137 02-Aug-2000 wpaul

Add call to bus_generic_attach() at the end of sk_attach(). It turns out that
if you kldload this driver, all the subordinate devices are probed/attached
as expected. But this is not the case when the driver is statically compiled
into the kernel. Since I do most of my testing with modules, I failed to
notice this. I'm not sure if it's intended behavior or not. I think it may
be, but it seems a little counter-intuitive.


# 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


# 61317 06-Jun-2000 wpaul

- Call mii_pollstat() after we bring up the link on a 1000baseTX card
after autoneg so we make sure to set the link state and duplex mode
correctly.
- Make sure to set the 'ignore pause frames' bit on the XMAC.
- Small linewrap fix.


# 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


# 59759 29-Apr-2000 peter

Add a missing MODULE_DEPEND() on miibus.. I was working from
KMODDEPS which this driver didn't have.


# 59478 22-Apr-2000 wpaul

Reoganize/update the SysKonnect driver:

- Break out the support for the XMAC II's PHY into an miibus driver.

- Reorganize the probe/attach stuff using newbus. Each XMAC is now
attached to the parent GEnesis controller using newbus. This is
necessary since each XMAC must also have an attached miibus, and
the miibus read/write register routines need to be able to get
at the softc struct for each XMAC, not the one for the parent
controller. This allows me to get rid of the grotty code I added
for selecting the unit numbers for the ifnet interfaces: the unit
numbers are now derived from the newbus-assigned unit numbers,
which should track with the ifnet interface numbers. I think.
At the very least, there should never be any collisions.

- Add support for the SK-9821 and SK-9822 1000baseTX adapters. Special
thanks to SysKonnect for loaning me two adapters for testing.


# 51641 25-Sep-1999 wpaul

Call sk_start() at the end of sk_intr() if there's packets in the
interface send queue that need to be processed.


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


# 51446 20-Sep-1999 obrien

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

Reviewed by: msmith, wpaul


# 51359 18-Sep-1999 wpaul

Fix the mechanism used to choose the unit numbers for the IP interfaces
attached by the SysKonnect driver. Use ifunit() to scan for existing
skN interfaces and pick the first unused one.


# 50548 29-Aug-1999 bde

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


# 50477 27-Aug-1999 peter

$Id$ -> $FreeBSD$


# 49077 25-Jul-1999 wpaul

Remember to clear the IFF_RUNNING and IFF_OACTIVE flags in sf_stop() and
sk_stop().


# 49017 23-Jul-1999 wpaul

One last tweak before I turn in for the evening: the driver name in
the driver_t declaration should be "skc" not "sk". Technically, "skc"
is the parent PCI device (the SysKonnect GEnesis controller) and "sk0"
and "sk1" are the network interfaces that get attached to it.


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


# 48987 22-Jul-1999 wpaul

Fix a small mind-o: one instance of SYS_RES_IOPORT should have been
SYS_RES_MEMOTY in sk_detatch().


# 48973 22-Jul-1999 wpaul

Convert the SysKonnect gigabit ethernet driver to newbus.


# 48813 14-Jul-1999 wpaul

Make a few other cleanups while I'm in the area. Typo in comment, unused
structure members, etc. No functional changes.


# 48812 14-Jul-1999 wpaul

Revert some changes I had made to try and cut down on the number of TX EOF
interrupts that were scheduled. Testing shows it didn't really do very much
and it makes the code a little more complicated (which is never a good thing).

Also fix the rambuffer offset initialization for the 512K/64K SRAM case
(512K total using 64K chips). It should be 0. The only case with a
non-standard rambuffer offset address is 1024K/64K according to the
SysKonnect manual. (My card has the 1024/64 configuration and I don't know
which card uses the 512/64 configuration, if any, so I'm not sure that
this was really a problem for anyone.)


# 48712 09-Jul-1999 wpaul

if_sk.c: use pci_port_t instead of u_short
if_skreg.h: use alpha_XXX_dmamap() instead of pmap_kextract hackery on
alpha platform


# 48693 09-Jul-1999 wpaul

This commit adds driver support for the SysKonnect SK-984x series
gigabit ethernet adapters. This includes two single port cards
(single mode and multimode fiber) and two dual port cards (also single
mode and multimode fiber). SysKonnect is currently the only
vendor with a dual port gigabit ethernet NIC.

The ports on dual port adapters are treated as separate network
interfaces. Thus, if you have an SK-9844 dual port SX card, you
should have both sk0 and sk1 interfaces attached. Dual port cards
are implemented using two XMAC II chips connected to a single
SysKonnect GEnesis controller. Hence, dual port cards are really
one PCI device, as opposed to two separate PCI devices connected
through a PCI to PCI bridge. Note that SysKonnect's drivers use
the two ports for failover purposes rather that as two separate
interfaces, plus they don't support jumbo frames. This applies to
their Linux driver too. :)

Support is provided for hardware multicast filtering, BPF and
jumbo frames. The SysKonnect cards support TCP checksum offload
however this feature is not currently enabled (hopefully it will
be once we get checksum offload support).

There are still a few things that need to be implemeted, like
the ability to communicate with the on-board LM80 voltage/temperature
monitor, but I wanted to get the driver under CVS control and into
-current so people could bang on it.

A big thanks for SysKonnect for making all their programming info
for these cards (and for their FDDI and token ring cards) available
without NDA (see www.syskonnect.com).