History log of /freebsd-current/sys/dev/nge/if_nge.c
Revision Date Author Comments
# 685dc743 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 76cb2c1c 01-Mar-2022 Justin Hibbits <jhibbits@FreeBSD.org>

Mechanically convert nge(4) to IfAPI

Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D37811


# e7451a6b 06-May-2022 John Baldwin <jhb@FreeBSD.org>

nge: Remove unused devclass argument to DRIVER_MODULE.


# 3e38757d 19-Apr-2022 John Baldwin <jhb@FreeBSD.org>

Remove unused miibus_devclass and miibus_fdt_devclass.


# b1603638 28-Aug-2021 Gordon Bergling <gbe@FreeBSD.org>

Fix a common typo in man pages and src comments

- s/desciptor/descriptor/

MFC after: 5 days


# 7029da5c 26-Feb-2020 Pawel Biernacki <kaktus@FreeBSD.org>

Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)

r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are
still not MPSAFE (or already are but aren’t properly marked).
Use it in preparation for a general review of all nodes.

This is non-functional change that adds annotations to SYSCTL_NODE and
SYSCTL_PROC nodes using one of the soon-to-be-required flags.

Mark all obvious cases as MPSAFE. All entries that haven't been marked
as MPSAFE before are by default marked as NEEDGIANT

Approved by: kib (mentor, blanket)
Commented by: kib, gallatin, melifaro
Differential Revision: https://reviews.freebsd.org/D23718


# 9bf5c8b4 21-Oct-2019 Gleb Smirnoff <glebius@FreeBSD.org>

Convert to if_foreach_llmaddr() KPI.


# d7c5a620 18-May-2018 Matt Macy <mmacy@FreeBSD.org>

ifnet: Replace if_addr_lock rwlock with epoch + mutex

Run on LLNW canaries and tested by pho@

gallatin:
Using a 14-core, 28-HTT single socket E5-2697 v3 with a 40GbE MLX5
based ConnectX 4-LX NIC, I see an almost 12% improvement in received
packet rate, and a larger improvement in bytes delivered all the way
to userspace.

When the host receiving 64 streams of netperf -H $DUT -t UDP_STREAM -- -m 1,
I see, using nstat -I mce0 1 before the patch:

InMpps OMpps InGbs OGbs err TCP Est %CPU syscalls csw irq GBfree
4.98 0.00 4.42 0.00 4235592 33 83.80 4720653 2149771 1235 247.32
4.73 0.00 4.20 0.00 4025260 33 82.99 4724900 2139833 1204 247.32
4.72 0.00 4.20 0.00 4035252 33 82.14 4719162 2132023 1264 247.32
4.71 0.00 4.21 0.00 4073206 33 83.68 4744973 2123317 1347 247.32
4.72 0.00 4.21 0.00 4061118 33 80.82 4713615 2188091 1490 247.32
4.72 0.00 4.21 0.00 4051675 33 85.29 4727399 2109011 1205 247.32
4.73 0.00 4.21 0.00 4039056 33 84.65 4724735 2102603 1053 247.32

After the patch

InMpps OMpps InGbs OGbs err TCP Est %CPU syscalls csw irq GBfree
5.43 0.00 4.20 0.00 3313143 33 84.96 5434214 1900162 2656 245.51
5.43 0.00 4.20 0.00 3308527 33 85.24 5439695 1809382 2521 245.51
5.42 0.00 4.19 0.00 3316778 33 87.54 5416028 1805835 2256 245.51
5.42 0.00 4.19 0.00 3317673 33 90.44 5426044 1763056 2332 245.51
5.42 0.00 4.19 0.00 3314839 33 88.11 5435732 1792218 2499 245.52
5.44 0.00 4.19 0.00 3293228 33 91.84 5426301 1668597 2121 245.52

Similarly, netperf reports 230Mb/s before the patch, and 270Mb/s after the patch

Reviewed by: gallatin
Sponsored by: Limelight Networks
Differential Revision: https://reviews.freebsd.org/D15366


# df57947f 18-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

spdx: initial adoption of licensing ID tags.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.

Initially, only tag files that use BSD 4-Clause "Original" license.

RelNotes: yes
Differential Revision: https://reviews.freebsd.org/D13133


# 453130d9 02-May-2016 Pedro F. Giffuni <pfg@FreeBSD.org>

sys/dev: minor spelling fixes.

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


# a2621dd2 12-Jan-2015 Pyun YongHyeon <yongari@FreeBSD.org>

Receive filter configuration is done in nge_rxfilter(). Remove
unnecessary filter configuration code in nge_init_locked().
While I'm here add a check for driver running state for multicast
filter handling. Also remove unnecessary assignment to error
variable since it is cleared in the function entry.

Suggested by: brad@OpenBSD.org


# e09fdb02 18-Sep-2014 Gleb Smirnoff <glebius@FreeBSD.org>

Mechanically convert to if_inc_counter().


# 1bffa951 30-Aug-2014 Gleb Smirnoff <glebius@FreeBSD.org>

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

Sponsored by: Nginx, Inc.


# 068d8643 11-Jun-2014 John Baldwin <jhb@FreeBSD.org>

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


# 76039bc8 26-Oct-2013 Gleb Smirnoff <glebius@FreeBSD.org>

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.


# c6499ecc 04-Dec-2012 Gleb Smirnoff <glebius@FreeBSD.org>

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


# 29658c96 05-Nov-2012 Dimitry Andric <dim@FreeBSD.org>

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


# 4b7ec270 22-Nov-2011 Marius Strobl <marius@FreeBSD.org>

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


# 8c1093fc 01-Nov-2011 Marius Strobl <marius@FreeBSD.org>

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


# 57c81d92 17-Oct-2011 Pyun YongHyeon <yongari@FreeBSD.org>

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)


# 3fcb7a53 03-May-2011 Marius Strobl <marius@FreeBSD.org>

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


# 3b0a4aef 23-Mar-2011 John Baldwin <jhb@FreeBSD.org>

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


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# d6c65d27 15-Oct-2010 Marius Strobl <marius@FreeBSD.org>

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


# eb956cd0 26-Jun-2009 Robert Watson <rwatson@FreeBSD.org>

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


# 56e13f2a 30-May-2009 Attilio Rao <attilio@FreeBSD.org>

Unbreak build.

Pointy hat to: attilio


# f6bc9430 20-May-2009 Pyun YongHyeon <yongari@FreeBSD.org>

bus_dma(9) conversion and make nge(4) work on all architectures.
o Header file cleanup.
o bus_dma(9) conversion.
- Removed all consumers of vtophys(9) and converted to use
bus_dma(9).
- 64bit DMA support was disabled because DP83821 is not capable
of handling the DMA request. 64bit DMA request on DP83820
requires different descriptor structures and it's hard to
dynamically change descriptor format at run time so I disabled
it. Note, this is the same behavior as previous one but
previously nge(4) didn't explicitly disable 64bit mode on
DP83820.
- Added Tx/Rx descriptor ring alignment requirements(8 bytes
alignment).
- Limit maximum number of Tx DMA segments to 16. In fact,
controller does not seem to have limitations on number of Tx
DMA segments but 16 should be enough for most cases and
m_collapse(9) will handle highly fragmented frames without
consuming a lot of CPU cycles.
- Added Rx buffer alignment requirements(8 bytes alignment). This
means driver should fixup received frames to align on 16bits
boundary on strict-alignment architectures.
- Nuked driver private data structure in descriptor ring.
- Added endianness support code in Tx/Rx descriptor access.
o Prefer faster memory mapped register access to I/O mapped access.
Added fall-back mechanism to use alternative register access.
The hardware supports both memory and I/O mapped access.
o Added suspend/resume methods but it wasn't tested as controller I
have does not support PCI PME.
o Removed swap argument in nge_read_eeprom() since endianness
should be handled after reading EEPROM.
o Implemented experimental 802.3x full-duplex flow-control. ATM
it was commented out but will be activated after we have generic
flow-control framework in mii(4) layer.
o Rearranged promiscuous mode settings and simplified logic.
o Always disable Rx filter prior to changing Rx filter functions as
indicated in DP83820/DP83821 datasheet.
o Added an explicit DELAY in timeout loop of nge_reset().
o Added a sysctl variable dev.nge.%d.int_holdoff to control
interrupt moderation. Valid ranges are 1 to 255(default 1) in
units of 100us. The actual delivery of interrupt would be delayed
based on the sysctl value. The interface has to be brought down
and up again before a change takes effect. With proper tuning
value, users do not need to resort to polling(4) anymore.
o Added ALTQ(4) support.
o Added missing IFCAP_VLAN_HWCSUM as nge(4) can offload Tx/Rx
checksum calculation on VLAN tagged frames as well as VLAN tag
insertion/stripping. Also add IFCAP_VLAN_MTU capability as nge(4)
can handle VLAN tagged oversized frames.
o Fixed media header length for VLAN.
o Rearranged nge_detach routine such that it's now used for general
clean-up routine.
o Enabled MWI.
o Accessing EEPROM takes very long time so read 6 bytes ethernet
address with one call instead of 3 separate accesses.
o Don't set if_mtu in device attach, it's already set in
ether_ifattach().
o Don't do any special things for TBI interface. Remove TBI
specific media handling in the driver and have gentbi(4) handle
it. Add glue code to read/write TBI PHY registers in miibus
method. This change removes a lot of PHY handling code in driver
and now its functionality is handled by mii(4).
o Alignment fixup code is now applied only for strict-alignment
architectures. Previously the code was applied for all
architectures except i386. With this change amd64 will get
instant Rx performance boost.
o When driver fails to allocate a new mbuf, update if_qdrops so
users can see what was wrong in Rx path.
o Added a workaround for a hardware bug which resulted in short
VLAN tagged frames(e.g. ARP) was rejected as if runt frame was
received. With this workaround nge(4) now accepts the short VLAN
tagged frame and nge(4) can take full advantage of hardware VLAN
tag stripping. I have no idea how this bug wasn't known so far,
without the workaround nge(4) may never work on VLAN
environments.
o Fixed Rx checksum offload logic such that it now honors active
interface capability configured with ifconfig(8).
o In nge_start()/nge_txencap(), always leave at least one free
descriptor as indicated in datasheet. Without this the hardware
would be confused with ring descriptor structure(e.g. no clue
for the end of descriptor ring).
o Removed dead-code that checks interrupts on PHY hardware. The
code was designed to detect link state changes but it was
disabled as driving nge_tick clock would break auto-negotiation
timer. This code is no longer needed as nge(4) now uses mii(4)
and link state change handling is done with mii callback.
o Rearranged ethernet address programming logic such that it works
on strict-alignment architectures.
o Added IFCAP_VLAN_HWTAGGING/IFCAP_VLAN_HWCSUM handler in
nge_ioctl() such that the functionality is configurable with
ifconfig(8). DP83820/DP83821 can do checksum offload for VLAN
tagged frames so enable Tx/Rx checksum offload for VLAN
interfaces.
o Simplified IFCAP_POLLING selection logic in nge_ioctl().
o Fixed module unload panic when bpf listeners are active.
o Tx/Rx descriptor ring address uses 64bit DMA address for
readability. High address part of DMA would be 0 as nge(4)
disabled 64bit DMA transfers so it's ok for DP83821.
o Removed volatile keyword in softc as bus_dmamap_sync(9) should
take care of this.
o Removed extra driver private structures in descriptor ring. These
extra elements are not part of descriptor structure. Embedding
private driver structure into descriptor ring is not good idea
as its size may be different on 32bit/64bit architectures.
o Added miibus_linkchg method handler to catch link state changes.
o Removed unneeded nge_ifmedia in softc. All TBI access is handled
in gentbi(4). There is no difference between TBI and non-TBI case
now.
o Removed "gigabit link up" message handling in nge_tick. Link
state change notification is already performed by mii(4) and
checking link state by accessing PHY registers in periodic timer
handler of driver is wrong. All link state and speed/duplex
monitoring should be handled in PHY driver.
o Use our own timer for watchdog instead of if_watchdog/if_timer
interface.
o Added hardware MAC statistics counter, users canget current MAC
statistics from dev.nge.%d.stats sysctl node(%d is unit number of
a device).
o Removed unused macros, NGE_LASTDESC, NGE_MODE, NGE_OWNDESC,
NGE_RXBYTES.
o Increased number of Tx/Rx descriptors from 128 to 256. From my
experience on gigabit ethernet controllers, number of descriptors
should be 256 or higher to get an optimal performance on gigabit
link.
o Increased jumbo frame length to 9022 bytes to cope with other
gigabit ethernet drivers. Experimentation shows no problems with
9022 bytes.
o Removed unused member variables in softc.
o Switched from bus_space_{read|write}_4 to bus_{read|write}_4.
o Added support for WOL.


# 056e0442 18-May-2009 Pyun YongHyeon <yongari@FreeBSD.org>

Consistently use tab characters instead of spaces.


# 6f94c0fd 18-May-2009 Pyun YongHyeon <yongari@FreeBSD.org>

style(9)


# 3929ff51 18-May-2009 Pyun YongHyeon <yongari@FreeBSD.org>

s/u_int8_t/uint8_t/g
s/u_int16_t/uint16_t/g
s/u_int32_t/uint32_t/g


# 25d7155f 18-May-2009 Pyun YongHyeon <yongari@FreeBSD.org>

style(9) - space after keyword.


# 2da9a170 18-May-2009 Pyun YongHyeon <yongari@FreeBSD.org>

Remove return statement at the end of functions that return void.


# a13d3502 18-May-2009 Pyun YongHyeon <yongari@FreeBSD.org>

Remove trailling whitespaces.


# 2cf2d799 18-May-2009 Pyun YongHyeon <yongari@FreeBSD.org>

Remove register keyword.


# 284c81cb 18-May-2009 Pyun YongHyeon <yongari@FreeBSD.org>

Use ANSI C declarations for all functions.


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# 6a087a87 21-Nov-2007 Pyun YongHyeon <yongari@FreeBSD.org>

Fix function prototype for device_shutdown method.


# 59a0d28b 03-Mar-2007 Christian S.J. Peron <csjp@FreeBSD.org>

Catch up the rest of the drivers with the ether_vlan_mtap modifications.
If these drivers are setting M_VLANTAG because they are stripping the
layer 2 802.1Q headers, then they need to be re-inserting them so any
bpf(4) peers can properly decode them.

It should be noted that this is compiled tested only.

MFC after: 3 weeks


# ef544f63 22-Feb-2007 Paolo Pisati <piso@FreeBSD.org>

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@


# 78ba57b9 17-Sep-2006 Andre Oppermann <andre@FreeBSD.org>

Move ethernet VLAN tags from mtags to its own mbuf packet header field
m_pkthdr.ether_vlan. The presence of the M_VLANTAG flag on the mbuf
signifies the presence and validity of its content.

Drivers that support hardware VLAN tag stripping fill in the received
VLAN tag (containing both vlan and priority information) into the
ether_vtag mbuf packet header field:

m->m_pkthdr.ether_vtag = vlan_id; /* ntohs()? */
m->m_flags |= M_VLANTAG;

to mark the packet m with the specified VLAN tag.

On output the driver should check the mbuf for the M_VLANTAG flag to
see if a VLAN tag is present and valid:

if (m->m_flags & M_VLANTAG) {
... = m->m_pkthdr.ether_vtag; /* htons()? */
... pass tag to hardware ...
}

VLAN tags are stored in host byte order. Byte swapping may be necessary.

(Note: This driver conversion was mechanic and did not add or remove any
byte swapping in the drivers.)

Remove zone_mtag_vlan UMA zone and MTAG_VLAN definition. No more tag
memory allocation have to be done.

Reviewed by: thompsa, yar
Sponsored by: TCP/IP Optimization Fundraise 2005


# 6b9f5c94 15-Sep-2006 Gleb Smirnoff <glebius@FreeBSD.org>

- Consistently use if_printf() only in interface methods: if_start(),
if_watchdog, etc., or in functions used only in these methods.
In all other functions in the driver use device_printf().
- Use __func__ instead of typing function name.

Submitted by: Alex Lyashkov <umka sevcity.net>


# c40da00c 16-May-2006 Poul-Henning Kamp <phk@FreeBSD.org>

Since DELAY() was moved, most <machine/clock.h> #includes have been
unnecessary.


# 23033eeb 13-Feb-2006 Gleb Smirnoff <glebius@FreeBSD.org>

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


# d147662c 18-Dec-2005 Gleb Smirnoff <glebius@FreeBSD.org>

- Fix VLAN_INPUT_TAG() macro, so that it doesn't touch mtag in
case if memory allocation failed.
- Remove fourth argument from VLAN_INPUT_TAG(), that was used
incorrectly in almost all drivers. Indicate failure with
mbuf value of NULL.

In collaboration with: yongari, ru, sam


# 4a0d6638 11-Nov-2005 Ruslan Ermilov <ru@FreeBSD.org>

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


# 7b279558 21-Oct-2005 Warner Losh <imp@FreeBSD.org>

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


# 646abee6 13-Oct-2005 John Baldwin <jhb@FreeBSD.org>

Minor tweaks and fixups:
- Use device_printf() and if_printf() and remove nge_unit.
- Use callout_init_mtx() and remove nge_tick_locked() as nge_tick() is now
always called with the driver lock held.
- Use M_ZERO to contigmalloc() when allocating nge_ldata. It was possible
for the random garbage to be used in certain cases otherwise.
- Cleanup attach error handling including no longer leaking nge_ldata.
- Add locking to the ifmedia callouts.
- Lock accesses to if_hwassist and if_capenable in nge_ioctl().

Submitted by: Yuriy N. Shkandybin jura at networks dot ru (1, 3, 4)
Tested by: Yuriy N. Shkandybin jura at networks dot ru
MFC after: 3 days


# f0796cd2 05-Oct-2005 Gleb Smirnoff <glebius@FreeBSD.org>

- 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


# 40929967 01-Oct-2005 Gleb Smirnoff <glebius@FreeBSD.org>

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


# ad4f426e 18-Sep-2005 Warner Losh <imp@FreeBSD.org>

Make sure that we call if_free(ifp) after bus_teardown_intr. Since we
could get an interrupt after we free the ifp, and the interrupt
handler depended on the ifp being still alive, this could, in theory,
cause a crash. Eliminate this possibility by moving the if_free to
after the bus_teardown_intr() call.


# 5ae7c95c 15-Sep-2005 Ruslan Ermilov <ru@FreeBSD.org>

Add two missing if_free() calls.


# 13f4c340 09-Aug-2005 Robert Watson <rwatson@FreeBSD.org>

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


# 13b203d0 02-Aug-2005 Robert Watson <rwatson@FreeBSD.org>

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


# fc74a9f9 10-Jun-2005 Brooks Davis <brooks@FreeBSD.org>

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


# d4fcf3cb 28-May-2005 Yoshihiro Takahashi <nyan@FreeBSD.org>

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)


# 6c772336 28-Mar-2005 Sam Leffler <sam@FreeBSD.org>

fix null ptr deref when nge_newbuf is called with an existing mbuf

Noticed by: Coverity Prevent analysis tool


# 2307fc82 26-Mar-2005 Sam Leffler <sam@FreeBSD.org>

deref correct mbuf ptr to collect any vlan tag

Noticed by: Coverity Prevent analysis tool


# 6b9907e7 05-Mar-2005 Warner Losh <imp@FreeBSD.org>

Use BUS_PROBE_DEFAULT for pci probe return value


# 098ca2bd 05-Jan-2005 Warner Losh <imp@FreeBSD.org>

Start each of the license/copyright comments with /*-, minor shuffle of lines


# 6d6b7a18 08-Nov-2004 Poul-Henning Kamp <phk@FreeBSD.org>

Hide link up/down/media printfs behind bootverbose


# 5a71a6fe 14-Sep-2004 Alan Cox <alc@FreeBSD.org>

Fix a typo that affects !i386.


# 6ba160b6 14-Sep-2004 Bill Paul <wpaul@FreeBSD.org>

Add missing NGE_LOCK_DESTROY() to nge_detach().


# ad6c618b 14-Sep-2004 Bill Paul <wpaul@FreeBSD.org>

Make two major changes to this code to address some stability/corruption
problems:

1) Add locking for SMP, code provided by Alan Cox
2) While testing Alan's patches, I observed serious problems with
the jumbo buffer allocation code (machine crashed twice), so I gutted
it and rewrote the receive handler to use multiple chained descriptors.
Each RX descriptor gets a single 2K cluster, and the chip will fill in
as many as it needs to hold the complete packet.

User reports that this corrects the data corruption issues previously
observed and discussed on -current.

Note that this driver still needs to be hit with the busdma stick.
I intend to inflict said beating in the near future.

MFC after: 1 week


# fc4af83a 13-Aug-2004 Robert Watson <rwatson@FreeBSD.org>

Since if_nge doesn't contain locking or run with INTR_MPSAFE, mark
the interface as IFF_NEEDSGIANT so if_start is run holding Giant.

Note: this driver does declare and occasionally reference mutexes,
but I believe not nearly enough to provide safety.


# 79495006 28-Jun-2004 Warner Losh <imp@FreeBSD.org>

Remove the setting of the pci config variables on power state changes.
The bus does this now.


# 0e939c0c 09-Jun-2004 Christian Weisgerber <naddy@FreeBSD.org>

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


# fe12f24b 30-May-2004 Poul-Henning Kamp <phk@FreeBSD.org>

Add missing <sys/module.h> includes


# 25fbb2c3 23-May-2004 Yaroslav Tykhiy <ytykhiy@gmail.com>

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


# a5820ecb 23-May-2004 Yaroslav Tykhiy <ytykhiy@gmail.com>

According to the design of checksum offloading framework,
if_hwassist should be in accord with the IFCAP_TXCSUM bit
of if_capenable.


# 866a788c 23-May-2004 Maxime Henrion <mux@FreeBSD.org>

We don't need to initialize if_output, ether_ifattach() does it
for us.


# 37f5f239 11-Apr-2004 Ruslan Ermilov <ru@FreeBSD.org>

Implemented per-interface polling(4) control.


# 1e73ec7d 11-Apr-2004 Ruslan Ermilov <ru@FreeBSD.org>

Fixed resetting of the watchdog timer and queue full flag.


# fa9336b8 11-Apr-2004 Robert Watson <rwatson@FreeBSD.org>

Compare IFF_POLLING flag with ifp->if_flags rather than ifp->if_ipending,
which was almost certainly a bug since polling support was introduced
in this driver.

Found during discussion with: mlaier


# 53090724 30-Mar-2004 Ruslan Ermilov <ru@FreeBSD.org>

The VLAN TCI field should be operated in network byte order.
This fixes the VLAN support for nge(4).

Reported by: Jacob S. Barrett
MFC after: 3 days


# 5f96beb9 17-Mar-2004 Nate Lawson <njl@FreeBSD.org>

Convert callers to the new bus_alloc_resource_any(9) API.

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


# e3bbbec2 14-Mar-2004 Matthew N. Dodd <mdodd@FreeBSD.org>

Announce ethernet MAC addresss in ether_ifattach().


# a55a017f 08-Dec-2003 David E. O'Brien <obrien@FreeBSD.org>

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

Requested by: bde,imp


# 4dc52c32 14-Nov-2003 David E. O'Brien <obrien@FreeBSD.org>

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


# aa825502 13-Nov-2003 David E. O'Brien <obrien@FreeBSD.org>

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


# 9bf40ede 31-Oct-2003 Brooks Davis <brooks@FreeBSD.org>

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)


# aad970f1 24-Aug-2003 David E. O'Brien <obrien@FreeBSD.org>

Use __FBSDID().
Also some minor style cleanups.


# 38d8c994 22-Aug-2003 Warner Losh <imp@FreeBSD.org>

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.


# fa4b32fa 03-Jul-2003 Warner Losh <imp@FreeBSD.org>

All current uses of pci_set_powerstate are bogus, at least in theory.
However, they are presently necessary due to bigger bogusness in the
pci bus layer not doing the right thing on suspend/resume or on
initial device probe. This is exactly the sort of thing that the
BURN_BRIDGES option was invented for. Mark all of them as
BURN_BRIDGES. As soon as I have the powerstate stuff properly
integrated into the pci bus code, I intend to remove all these
workarounds.


# 533294b9 15-Apr-2003 Matthew N. Dodd <mdodd@FreeBSD.org>

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


# f246e4a1 15-Apr-2003 Matthew N. Dodd <mdodd@FreeBSD.org>

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


# 8368cf8f 03-Apr-2003 David E. O'Brien <obrien@FreeBSD.org>

Use __FBSDID rather than rcsid[].


# a163d034 18-Feb-2003 Warner Losh <imp@FreeBSD.org>

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

Approved by: trb


# 44956c98 21-Jan-2003 Alfred Perlstein <alfred@FreeBSD.org>

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


# e808cf62 10-Jan-2003 Martin Blapp <mbr@FreeBSD.org>

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

Reviewed by: luoqi
MFC after: 2 weeks


# d64ada50 30-Dec-2002 Jens Schweikhardt <schweikh@FreeBSD.org>

Fix typos, mostly s/ an / a / where appropriate and a few s/an/and/
Add FreeBSD Id tag where missing.


# 673d9191 14-Nov-2002 Sam Leffler <sam@FreeBSD.org>

network interface driver changes:

o don't strip the Ethernet header from inbound packets; pass packets
up the stack intact (required significant changes to some drivers)
o reference common definitions in net/ethernet.h (e.g. ETHER_ALIGN)
o track ether_ifattach/ether_ifdetach API changes
o track bpf changes (use BPF_TAP and BPF_MTAP)
o track vlan changes (ifnet capabilities, revised processing scheme, etc.)
o use if_input to pass packets "up"
o call ether_ioctl for default handling of ioctls

Reviewed by: many
Approved by: re


# 29f19445 08-Nov-2002 Alfred Perlstein <alfred@FreeBSD.org>

Fix instances of macros with improperly parenthasized arguments.

Verified by: md5


# 196c0df6 06-Nov-2002 Hidetoshi Shimokawa <simokawa@FreeBSD.org>

Add support for DEVICE_POLLING.

PR: kern/44772
Submitted by: Takashi Oono <takashi@yha.att.ne.jp>
MFC after: 1 week


# 1f548804 08-Aug-2002 Doug Ambrisko <ambrisko@FreeBSD.org>

Add support for SX cards using TBI such as Netgear GA621.

Sponsored by: Vernier Networks.
MFC after: 1 week


# eaabec55 06-Jul-2002 Alfred Perlstein <alfred@FreeBSD.org>

Cleanup after my de-__P (remove leading whitespace before prototype args).
Add newlines after function return types in function declarations.

Approved by: wpaul (a long time ago)


# 914596ab 28-Jun-2002 Alfred Perlstein <alfred@FreeBSD.org>

catch up with ext_free prototype change.


# d9fc2b81 04-May-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Do not call nge_tick() if we get an PHY interrupt, nge_tick() calls
mii_tick() which should only be called once per second.

Our current MII/PHY state-engine is not able to deal with PHY
interrupts as far as I can tell, and most net drivers don't seem
to use the link/status change call-back mechanism. It seems that
MII/PHY was orphaned before it grew up.


# 279fe8d1 29-Apr-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Make one generic mii_phy_detach() to replace 19 slightly different ones.

Rename mii_phy_auto_stop() mii_phy_down().

Introduce mii_down(), use it from nge. Do not indirect it to 19 identical
case's in 19 switchstatements like NetBSD did.


# 78c8c3db 29-Apr-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Move a lot closer to NetBSDs MII support for GigE.

Move fxp and nge drivers over to use the new stuff.


# b418ad5c 28-Apr-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Follow NetBSD and s/IFM_1000_TX/IFM_1000_T/


# ff7ed9f7 13-Apr-2002 Poul-Henning Kamp <phk@FreeBSD.org>

If the receiver runs out of space for an received frame in the internal
FIFO or the in-RAM descriptors it will switch to RX_IDLE from where it
is not restarted.

We used to deal with RX_IDLE by doing a total reinit but this lost
our link and caused a potential 30sec autonegotiation against
switches. This was changed to a less heavyhanded approach, but this
failed to restart the receiver it it were in the RX_IDLE state.

This change adds the RX_IDLE and the RX_FIFO_OFLOW conditions as
triggers for interrupts and receive side processing, and restarts
the receiver when it is RX_IDLE.

Remove the #ifdef notyet'ed nge_rxeoc() function.

Sponsored by: Cybercity Internet, Denmark.
MFC after: 7 days


# 6008862b 04-Apr-2002 John Baldwin <jhb@FreeBSD.org>

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


# e51a25f8 19-Mar-2002 Alfred Perlstein <alfred@FreeBSD.org>

Remove __P.


# 3ffc8ab1 26-Feb-2002 Julian Elischer <julian@FreeBSD.org>

Remove errors in LINT (now that they are fatal)


# 437e48e9 03-Dec-2001 Brooks Davis <brooks@FreeBSD.org>

Don't pass an interface pointer to VLAN_INPUT{,_TAG}. Get it from the
mbuf instead.

Suggested by: fenner


# b2561871 29-Sep-2001 Jonathan Lemon <jlemon@FreeBSD.org>

Do not call mii_polltick() immediately after mii_tick().

Poiinted out by: wpaul


# 8ce3678a 19-Sep-2001 Bill Paul <wpaul@FreeBSD.org>

Handle the RX FIFO overflow condition with the rxeof handler instead
of the rxeoc handler for now. The rxeoc handler will reset the link,
and the NatSemi chip's RX FIFO will overflow on a 32-bit bus once you
start hitting it with 500Mbps or more of traffic.

Also increase the size of the RX ring to 128 descriptors (was 64).


# 84e4de28 18-Sep-2001 Jonathan Lemon <jlemon@FreeBSD.org>

Have the driver to announce what capabilitis it supports.


# 9d4fe4b2 05-Sep-2001 Brooks Davis <brooks@FreeBSD.org>

Make vlan(4) loadable, unloadable, and clonable. As a side effect,
interfaces must now always enable VLAN support.

Reviewed by: jlemon
MFC after: 3 weeks


# bbce7eba 24-Jul-2001 Brooks Davis <brooks@FreeBSD.org>

IFT_8021_VLAN -> IFT_L2VLAN per if_vlan_var.h rev 1.9. With this change
LINT compiles, but doesn't link.


# 248fa967 16-Jul-2001 Bill Paul <wpaul@FreeBSD.org>

Change the interrupt handler a bit so that we call the nge_rxeof() handler
when we get an RX_ERR interrupt rather than the nge_rxeoc() handler. The
rxeoc (end of channel) handler attempts to reinitialize the whole NIC,
which we don't want to do if we only received a bad packet.


# 962315f6 10-Jul-2001 Bill Paul <wpaul@FreeBSD.org>

Two optimizations:

1) Bite the bullet, and allow unaligned accesses without buffer copies
on the i386 platform. According to some tests run by Andrew Gallatin,
the buffer copy performance hit is greater than the unaligned access
performance hit (especially with jumbo frames). We still need to copy
everywhere else.

2) Enable interrupt moderation with a 100us timeout.

Submitted by: Andrew Gallatin <no longer at duke.edu>
MFC after: 1 week


# 75ff968c 09-Jul-2001 Bill Paul <wpaul@FreeBSD.org>

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.


# 2ce0498b 08-Jul-2001 Bill Paul <wpaul@FreeBSD.org>

Do not set the MODE_1000 bit unless we actually have a gigabit link.
Previously, I had the MODE_1000 bit in the global config register set
unconditionally, which was wrong: we have to turn it off if we have
a 10/100 link. This is now handled in the nge_miibus_statchg() routine.

Discovered by: Nathan Binkert <binkertn@eecs.umich.edu>

(Note: this commit is being done from JFK airport. :P )


# f5eece3f 20-Jun-2001 Bosko Milekic <bmilekic@FreeBSD.org>

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


# 7437599f 18-Jun-2001 Bill Paul <wpaul@FreeBSD.org>

Fix some memory bugs with regard to jumbo buffers. I made a mistake when
converting from the old external mbuf buffer code to the new (with the
MEXTADD() macro). Also free free list memory correctly in
foo_free_jumbo_mem() routines: grab the head of the list, then
remove it, _then_ free() it.

This fixes the memory corruption problem I've been chasing in the level 1
driver.


# 80782fbf 15-Jun-2001 Bill Paul <wpaul@FreeBSD.org>

Mind-o in last commit: s/==/>=/ when checking MTU size. *blush*


# cb2f755c 15-Jun-2001 Bill Paul <wpaul@FreeBSD.org>

Fix the last serious bug I've been chasing:

The DP83820/83821 has an undocumented limitation concerning jumbo frames
and TX checksum offload. In order for TX checksum offload to work, the
outgoing frame must fit entirely within the TX FIFO, which is 8192 bytes
in size. This isn't a problem, until you try to send a 9000-byte frame,
at which point the TX DMA engine goes to sleep. It turns out that if
you want to send a jumbo frame larger than 8170 bytes (8192 - 64), you
have to turn off the TX checksum support.

As a workaround, I changed nge_ioctl() so that if the user selects an
MTU larger than 8152 bytes, we clear the if_hwassist flags. The flags
will be set again once the MTU is reduced to a smaller value.


# c9215605 15-Jun-2001 Bill Paul <wpaul@FreeBSD.org>

Turn TCP and UDP hardware RX checksumming back on. jlemon pointed out where
I'd gone wrong before: we have to set csum_data to 0xffff, not 0.


# 1bacd83a 15-Jun-2001 Bill Paul <wpaul@FreeBSD.org>

Fix TX bug: when using TCP/IP checksum offload on TX, we tell the chip
we want the checksums calculated on a per-packet basis using control bits
in the extsts field of the DMA descriptor structure. For TX, the chip
seems to want these bits set in the field of the first descriptor in
a fragment chain, not the last.


# 23d3a203 06-Jun-2001 Bill Paul <wpaul@FreeBSD.org>

- Remember to set the 'extsts enable' bit in the CFG register to enable the
use of the extsts field in DMA descriptors. We need this to tell the chip
to calculate TCP/IP checksums in hardware on a per-packet basis.

- Fix the unions in DMA descriptor structures. Breakage on alpha led
me to realize I'd done it wrong the first time.


# 765a54f4 06-Jun-2001 Bill Paul <wpaul@FreeBSD.org>

Disable extra TCP/UCP checksum checking in nge_rxeof() for now.


# 2195de46 29-May-2001 Bill Paul <wpaul@FreeBSD.org>

Per jlemon: add code to nge_rxeof() to allow verification of TCP and
UDP checksums too, not just IP. The chip only tells us if the checksum
is ok, it does not give us a copy of the partial checksum for later
processing. We have to deal with this the right way, but we can deal
with it.


# 01702579 29-May-2001 Bill Paul <wpaul@FreeBSD.org>

Fix mind-o in nge_rxeof(): I used CSUM_IP_CHECKED twice instead of
CSUM_IP_CHECKED|CSUM_IP_VALID.


# 065a7922 15-May-2001 Bill Paul <wpaul@FreeBSD.org>

Fix instance of (struct ti_softc *) that should have been
(struct nge_softc *), which the compiler never complained about.
I guess it doesn't matter, a pointer is a pointer, but looked weird
to me.


# 5da751e4 12-May-2001 Bill Paul <wpaul@FreeBSD.org>

Unbreak release. *sigh*


# e39cd3b2 11-May-2001 Bill Paul <wpaul@FreeBSD.org>

It's vlan.h, not opt_vlan.h.


# ce4946da 11-May-2001 Bill Paul <wpaul@FreeBSD.org>

Add support for gigabit ethernet cards based on the NatSemi DP83820
and DP83821 gigabit ethernet MAC chips and the NatSemi DP83861 10/100/1000
copper PHY. There are a whole bunch of very low cost cards available with
this chipset selling for $150USD or less. This includes the SMC9462TX,
D-Link DGE-500T, Asante GigaNIX 1000TA and 1000TPC, and a couple cards
from Addtron.

This chip supports TCP/IP checksum offload, VLAN tagging/insertion.
2048-bit multicast filter, jumbograms and has 8K TX and 32K RX FIFOs.
I have not done serious performance testing with this driver. I know
it works, and I want it under CVS control so I can keep tabs on it.
Note that there's no serious mutex stuff in here yet either: I need
to talk more with jhb to figure out the right way to do this. That
said, I don't think there will be any problems.

This driver should also work on the alpha. It's not turned on in
GENERIC.