History log of /freebsd-current/sys/dev/msk/if_msk.c
Revision Date Author Comments
# fdafd315 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

sys: Automated cleanup of cdefs and other formatting

Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by: Netflix


# 685dc743 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

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

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


# 5ab8c4b8 19-Aug-2022 Justin Hibbits <jhibbits@FreeBSD.org>

Mechanically convert msk(4) to IfAPI

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


# ae70e883 05-Oct-2022 John Baldwin <jhb@FreeBSD.org>

msk: Use a void cast to mark values of dummy reads as unused.

Note that this required adding missing ()'s around the outermost level
of MSK_READ_MIB*. Otherwise, the void cast was only applied to the
first register read. This also meant that MSK_READ_MIB64 was pretty
broken as the uint64_t cast only applied to the first 16-bit register
read in each MSK_READ_MIB32 invocation and the 32-bit shift was only
applied to the second register read of the pair.

Reviewed by: imp, emaste
Reported by: GCC -Wunused-value
Differential Revision: https://reviews.freebsd.org/D36777


# aabbe269 05-Oct-2022 John Baldwin <jhb@FreeBSD.org>

msk: Don't bother reading spare stats registers.

msk_stats_update reads stats registers named "spare" whose values are
discarded.

Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D36871


# 7fcc3449 20-Apr-2022 John Baldwin <jhb@FreeBSD.org>

msk: Remove unused devclass arguments to DRIVER_MODULE.


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

Remove unused miibus_devclass and miibus_fdt_devclass.


# 7e5c042c 05-Apr-2022 Warner Losh <imp@FreeBSD.org>

msk: Remove write only variables, but leave hardware reads in place

Sponsored by: Netflix


# 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


# 8227d65b 26-Jan-2020 Alexander Kabaev <kan@FreeBSD.org>

Enter net epoch in msk_tick.

One more instance of if_input being called outside of
interrupt, by means of msk_handle_events.

Differential Revision: https://reviews.freebsd.org/D23379


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


# 9935c65a 14-Apr-2017 Pyun YongHyeon <yongari@FreeBSD.org>

Remove unnecessary assignment.

Found by: PVS-Studio


# 1691e8bf 09-Aug-2016 Edward Tomasz Napierala <trasz@FreeBSD.org>

Remove NULL checks after M_WAITOK allocations from msk(4).

MFC after: 1 month


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

sys/dev: minor spelling fixes.

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


# 15b18534 21-Feb-2016 Pyun YongHyeon <yongari@FreeBSD.org>

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


# 9dda5c8f 17-Feb-2016 Pyun YongHyeon <yongari@FreeBSD.org>

Fix variable assignment.

Found by: PVS-Studio


# 6ad1954b 13-Oct-2014 Robert Watson <rwatson@FreeBSD.org>

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


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


# f6f20128 06-Feb-2014 Pyun YongHyeon <yongari@FreeBSD.org>

Revert r234666. Clearing TWSI IRQ seems to cause watchdog timeout
on old Yukon II controllers.

Tested by: bsam
MFC after: 2 weeks


# b52d3ddb 31-Oct-2013 Pyun YongHyeon <yongari@FreeBSD.org>

Perform media change after setting IFF_DRV_RUNNING flag. Without it,
driver would ignore the first link state update if controller
already established a link.

Reported by: bsam
Tested by: bsam


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


# 2dc26832 29-May-2013 Marius Strobl <marius@FreeBSD.org>

- 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


# ab3f6b34 17-Apr-2013 Gabor Kovesdan <gabor@FreeBSD.org>

- Correct mispellings of the word occurrence

Submitted by: Christoph Mallon <christoph.mallon@gmx.de> (via private mail)


# 1c3515d2 26-Feb-2013 Pyun YongHyeon <yongari@FreeBSD.org>

RX checksum offloading on old Yukon controllers seem to cause more
problems. Disable RX checksum offloading on controllers that don't
use new descriptor format but give chance to enable it with
ifconfig(8).


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

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


# fca56fb2 24-Apr-2012 Pyun YongHyeon <yongari@FreeBSD.org>

For Yukon II controllers that implement optional temperature sensor
and voltage sensor, TWSI is used to get sensor data. msk(4) does
not monitor these sensors and interrupt for TWSI completion is
disabled by default.
However, due to unknown reason, the TWSI completion interrupt fires
and it resulted in interrupt storm. To fix it, acknowledges the
TWSI completion interrupt if driver see the event. Given that not
all Yukon II controllers show the issue it could be a silicon bug
which does not honor interrupt masking.

Probably the right way to address the issue is disabling automatic
TWSI cycle initiation against these sensors. It would be even
better to implement reading voltage/temperature from the NIC but it
requires access to National LM80 through TWSI and documentation to
do that is not available yet(probably will never happen).

Reported by: jhb
Tested by: jhb
MFC after: 2 weeks


# 5bbe0c53 07-Jan-2012 Kevin Lo <kevlo@FreeBSD.org>

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

Reviewed by: yongari


# 7659f3c3 19-Dec-2011 Pyun YongHyeon <yongari@FreeBSD.org>

Increase wait time for OP_TCPSTART command processing. It seems
100us is not enough to ensure prefetch unit work.


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


# 355a415e 16-Nov-2011 Pyun YongHyeon <yongari@FreeBSD.org>

Enable 64bit DMA addressing support for all msk(4) controllers.
Unnecessarily complex LE format used on Marvell controller was
main reason not to enable 64bit DMA addressing in driver. If high
32bit address of DMA address of TX/RX buffer is changed, driver has
to generate a new LE. In TX path, driver will keep track of lastly
used high 32bit address of DMA address and generate a new LE
whenever it sees high address change in the DMA address. In RX path,
driver will always use two LEs to specify 64bit DMA address of RX
buffer. If the high 32bit address of DMA address of RX buffer is
the same as previous DMA address of RX buffer, driver does not have
to use two LEs but driver will use two LEs for simplicity in RX
ring management.

One of draw back for switching to 64bit DMA addressing is that the
large amount of LEs are used to specify 64bit DMA address such that
number of available LEs for TX/RX buffers are considerably reduced.
To mitigate the issue, increase number of available LEs from 256 to
384 for TX and from 256 to 512 for RX. For 32bit architectures,
msk(4) does not use 64bit DMA addressing to save resources.

Tested by: das


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


# 7c017a71 30-May-2011 Pyun YongHyeon <yongari@FreeBSD.org>

Correctly check MAC running status before disabling TX/RX MACs.


# 81e2a01a 24-May-2011 Pyun YongHyeon <yongari@FreeBSD.org>

style(9)


# 8be664b8 23-May-2011 Pyun YongHyeon <yongari@FreeBSD.org>

When MTU is changed, check whether driver should be reinitialized or
not. If reinitialized is required, clear driver running flag.


# e0029a72 23-May-2011 Pyun YongHyeon <yongari@FreeBSD.org>

Add initial support for Marvell 88E8055/88E8075 Yukon Supreme.


# fe0b141e 23-May-2011 Pyun YongHyeon <yongari@FreeBSD.org>

Do not touch ASF related register for controllers that do not have
these registers. Also disable Watchdog of ASF microcontroller.


# c6a34f76 23-May-2011 Pyun YongHyeon <yongari@FreeBSD.org>

Make sure to enable all clocks before accessing registers.
Releasing PHY from power down/COMA is done after enabling all
clocks. While I'm here remove unnecessary controller reset.


# d91192e3 23-May-2011 Pyun YongHyeon <yongari@FreeBSD.org>

Do not configure RAM registers for controllers that do not have
them. These registers are defined only for Yukon XL, Yukon EC and
Yukon FE.


# 7b4f47c1 23-May-2011 Pyun YongHyeon <yongari@FreeBSD.org>

Rework store and forward configuration of TX MAC FIFO. Basically it
enables store and forward mode except for jumbo frame on Yukon
Ultra.


# 10e71e22 23-May-2011 Pyun YongHyeon <yongari@FreeBSD.org>

Do not blindly clear entire GPHY control register. It seems some
bits of the register is used for other purposes such that clearing
these bits resulted in unexpected results such as corrupted RX
frames or missing LE status updates. For old controllers like
Yukon EC it had no effect but it caused all kind of troubles on
Yukon Supreme.
This change shall improve stability of controllers like Yukon
Ultra, Ultra2, Extreme, Optima and Supreme.


# 4c5a247b 24-Apr-2011 Gleb Smirnoff <glebius@FreeBSD.org>

When msk_detach() is called from msk_attach(), ifp may be
yet not initialized.


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


# cbc134ad 19-Jan-2011 Matthew D Fleming <mdf@FreeBSD.org>

Introduce signed and unsigned version of CTLTYPE_QUAD, renaming
existing uses. Rename sysctl_handle_quad() to sysctl_handle_64().


# f4f04709 18-Jan-2011 Matthew D Fleming <mdf@FreeBSD.org>

Fix a few more SYSCTL_PROC() that were missing a CTLFLAG type specifier.


# 3c5571b3 31-Dec-2010 Pyun YongHyeon <yongari@FreeBSD.org>

Fix endianness bug introduced in r205091.
After controller updates control word in a RX LE, driver converts
it to host byte order. The checksum value in the control word is
stored in big endian form by controller. r205091 didn't account for
the host byte order conversion such that the checksum value was
incorrectly interpreted on big endian architectures which in turn
made all TCP/UDP frames dropped. Make RX checksum offload work
on any architectures by swapping the checksum value.

Reported by: Sreekanth M. ( kanthms <> netlogicmicro dot com )
Tested by: Sreekanth M. ( kanthms <> netlogicmicro dot com )


# efd4fc3f 14-Nov-2010 Marius Strobl <marius@FreeBSD.org>

o Flesh out the generic IEEE 802.3 annex 31B full duplex flow control
support in mii(4):
- Merge generic flow control advertisement (which can be enabled by
passing by MIIF_DOPAUSE to mii_attach(9)) and parsing support from
NetBSD into mii_physubr.c and ukphy_subr.c. Unlike as in NetBSD,
IFM_FLOW isn't implemented as a global option via the "don't care
mask" but instead as a media specific option this. This has the
following advantages:
o allows flow control advertisement with autonegotiation to be
turned on and off via ifconfig(8) with the default typically
being off (though MIIF_FORCEPAUSE has been added causing flow
control to be always advertised, allowing to easily MFC this
changes for drivers that previously used home-grown support for
flow control that behaved that way without breaking POLA)
o allows to deal with PHY drivers where flow control advertisement
with manual selection doesn't work or at least isn't implemented,
like it's the case with brgphy(4), e1000phy(4) and ip1000phy(4),
by setting MIIF_NOMANPAUSE
o the available combinations of media options are readily available
from the `ifconfig -m` output
- Add IFM_FLOW to IFM_SHARED_OPTION_DESCRIPTIONS and IFM_ETH_RXPAUSE
and IFM_ETH_TXPAUSE to IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS so
these are understood by ifconfig(8).
o Make the master/slave support in mii(4) actually usable:
- Change IFM_ETH_MASTER from being implemented as a global option via
the "don't care mask" to a media specific one as it actually is only
applicable to IFM_1000_T to date.
- Let mii_phy_setmedia() set GTCR_MAN_MS in IFM_1000_T slave mode to
actually configure manually selected slave mode (like we also do in
the PHY specific implementations).
- Add IFM_ETH_MASTER to IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS so it
is understood by ifconfig(8).
o Switch bge(4), bce(4), msk(4), nfe(4) and stge(4) along with brgphy(4),
e1000phy(4) and ip1000phy(4) to use the generic flow control support
instead of home-grown solutions via IFM_FLAGs. This includes changing
these PHY drivers and smcphy(4) to no longer unconditionally advertise
support for flow control but only if the selected media has IFM_FLOW
set (or MIIF_FORCEPAUSE is set) and implemented for these media variants,
i.e. typically only for copper.
o Switch brgphy(4), ciphy(4), e1000phy(4) and ip1000phy(4) to report and
set IFM_1000_T master mode via IFM_ETH_MASTER instead of via IFF_LINK0
and some IFM_FLAGn.
o Switch brgphy(4) to add at least the the supported copper media based on
the contents of the BMSR via mii_phy_add_media() instead of hardcoding
them. The latter approach seems to have developed historically, besides
causing unnecessary code duplication it was also undesirable because
brgphy_mii_phy_auto() already based the capability advertisement on the
contents of the BMSR though.
o Let brgphy(4) set IFM_1000_T master mode on all supported PHY and not
just BCM5701. Apparently this was a misinterpretation of a workaround
in the Linux tg3 driver; BCM5701 seem to require RGPHY_1000CTL_MSE and
BRGPHY_1000CTL_MSC to be set when configuring autonegotiation but
this doesn't mean we can't set these as well on other PHYs for manual
media selection.
o Let ukphy_status() report IFM_1000_T master mode via IFM_ETH_MASTER so
IFM_1000_T master mode support now is generally available with all PHY
drivers.
o Don't let e1000phy(4) set master/slave bits for IFM_1000_SX as it's
not applicable there.

Reviewed by: yongari (plus additional testing)
Obtained from: NetBSD (partially), OpenBSD (partially)
MFC after: 2 weeks


# b1ce21c6 09-Nov-2010 Rebecca Cran <brucec@FreeBSD.org>

Fix typos.

PR: bin/148894
Submitted by: olgeni


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


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

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


# d1a02e09 09-Sep-2010 John Baldwin <jhb@FreeBSD.org>

Catch up to rename of the constant for the Master Data Parity Error bit in
the PCI status register.

Pointed out by: mdf
Pointy hat to: jhb


# 4dd3847d 10-May-2010 Pyun YongHyeon <yongari@FreeBSD.org>

MFC r207622-207623,207638
r207622:
Drop driver lock before exiting from interrupt handler.

r207623:
Make sure to check whether driver is running before processing
received frames. Also check driver has valid ifp pointer before
calling msk_stop() in device_shutdown handler. While I'm here
remove unnecessary accesses to interrupt mask registers in
device_shutdown handler because driver puts the controller into
reset state.
With these changes, msk(4) now survive from heavy RX traffic(1byte
UDP frame) while reboot is in progress.

r207638:
When VLAN hardware tagging is disabled, make sure to disable VLAN
checksum offloading as well as TSO over VLAN.


# 0deeb1ec 06-May-2010 Pyun YongHyeon <yongari@FreeBSD.org>

MFC r207445:
Add basic support for Marvell 88E8059 Yukon Optima.

Tested by: James LaLagna < jameslalagna <> gmail dot com >


# 6c3a42ef 06-May-2010 Pyun YongHyeon <yongari@FreeBSD.org>

MFC r207409,207442:
r207409:
Both RX_GMF_LP_THR and RX_GMF_UP_THR must be 16 bits register. If
it is 8bits register then RX FIFO size can't exceed 2KB which is
not true for almost all Yukon II controller.

r207442:
Disable non-ASF packet flushing on Yukon Extreme as vendor's driver
does. Without this change, Yukon Extreme seems to generate lots of
RX FIFO overruns even though controller has available RX buffers.
These excessive RX FIFO overruns generated lots of pause frames
which in turn killed devices plugged into switch. It seems there is
still occasional RX frame corruption on Yukon Extreme but this
change seems to fix the pause frame storm.

Reported by: jhb
Tested by: jhb


# 3edfecaa 04-May-2010 Pyun YongHyeon <yongari@FreeBSD.org>

When VLAN hardware tagging is disabled, make sure to disable VLAN
checksum offloading as well as TSO over VLAN.

Reported by: jhb


# 31fefd0d 04-May-2010 Pyun YongHyeon <yongari@FreeBSD.org>

Make sure to check whether driver is running before processing
received frames. Also check driver has valid ifp pointer before
calling msk_stop() in device_shutdown handler. While I'm here
remove unnecessary accesses to interrupt mask registers in
device_shutdown handler because driver puts the controller into
reset state.
With these changes, msk(4) now survive from heavy RX traffic(1byte
UDP frame) while reboot is in progress.

Reported by: Mark Atkinson < atkin901 <> gmail dot com >


# 3d763c31 04-May-2010 Pyun YongHyeon <yongari@FreeBSD.org>

Drop driver lock before exiting from interrupt handler.

Submitted by: jhb
MFC after: 3 days


# e19bd6ee 30-Apr-2010 Pyun YongHyeon <yongari@FreeBSD.org>

Add basic support for Marvell 88E8059 Yukon Optima.

Tested by: James LaLagna < jameslalagna <> gmail dot com >
MFC after: 5 days


# 7c8db6fd 30-Apr-2010 Pyun YongHyeon <yongari@FreeBSD.org>

Disable non-ASF packet flushing on Yukon Extreme as vendor's driver
does. Without this change, Yukon Extreme seems to generate lots of
RX FIFO overruns even though controller has available RX buffers.
These excessive RX FIFO overruns generated lots of pause frames
which in turn killed devices plugged into switch. It seems there is
still occasional RX frame corruption on Yukon Extreme but this
change seems to fix the pause frame storm.

Reported by: jhb
Tested by: jhb
MFC after: 5 days


# 106b2e2f 29-Apr-2010 Pyun YongHyeon <yongari@FreeBSD.org>

Both RX_GMF_LP_THR and RX_GMF_UP_THR must be 16 bits register. If
it is 8bits register then RX FIFO size can't exceed 2KB which is
not true for almost all Yukon II controller.


# ed0af45a 26-Apr-2010 Pyun YongHyeon <yongari@FreeBSD.org>

MFC r206876:
With r206844, CSUM_TCP is also set for CSUM_TSO case. Modify
drivers to take into account for the change. Basically CSUM_TSO
should be checked before checking CSUM_TCP.


# 6da6d0a9 19-Apr-2010 Pyun YongHyeon <yongari@FreeBSD.org>

With r206844, CSUM_TCP is also set for CSUM_TSO case. Modify
drivers to take into account for the change. Basically CSUM_TSO
should be checked before checking CSUM_TCP.


# b9b10dc4 13-Apr-2010 Pyun YongHyeon <yongari@FreeBSD.org>

MFC r206364:
Partial revert r204545.
Just relying on status LE ownership of status block seems to cause
poor performance. Always read current status index register first
and then check status ownership as we had before. Accessing status
index register seems to trigger immediate status update if
controller have pending status updates.

Reported by: Andre Albsmeier <Andre.Albsmeier <> siemens dot com>
Tested by: Andre Albsmeier <Andre.Albsmeier <> siemens dot com>


# 07fa0751 07-Apr-2010 Pyun YongHyeon <yongari@FreeBSD.org>

Partial revert r204545.
Just relying on status LE ownership of status block seems to cause
poor performance. Always read current status index register first
and then check status ownership as we had before. Accessing status
index register seems to trigger immediate status update if
controller have pending status updates.

MFC after: 1 week
Reported by: Andre Albsmeier <Andre.Albsmeier <> siemens dot com>
Tested by: Andre Albsmeier <Andre.Albsmeier <> siemens dot com>


# 5c55bc1b 24-Mar-2010 Pyun YongHyeon <yongari@FreeBSD.org>

MFC r205161:
It seems PCI_OUR_REG_[1-5] registers are not mapped on PCI
configuration space on Yukon Ultra(88E8056) such that accesses to
these registers were NOPs which in turn make msk(4) instable on
this controller. Use indirect access method to access
PCI_OUR_REG_[1-5] registers. This should fix a long standing
instability bug which prevented msk(4) working on Yukon Ultra.
Special thanks to koitsu who gave me remote access to his system.

PR: kern/114631, kern/116853


# 51e48a8e 24-Mar-2010 Pyun YongHyeon <yongari@FreeBSD.org>

MFC r204545:
Remove taskqueue based interrupt handling. After r204541 msk(4)
does not generate excessive interrupts any more so we don't need
to have two copies of interrupt handler.
While I'm here remove two STAT_PUT_IDX register accesses in LE
status event handler. After r204539 msk(4) always sync status LEs
so there is no need to resort to reading STAT_PUT_IDX register to
know the end of status LE processing. Just trust status LE's
ownership bit.


# 51574f11 24-Mar-2010 Pyun YongHyeon <yongari@FreeBSD.org>

MFC r204541:
Implement rudimentary interrupt moderation with programmable
countdown timer register. The timer resolution may vary among
controllers but the value would be represented by core clock
cycles. msk(4) will automatically computes number of required clock
cycles from given micro-seconds unit.
The default interrupt holdoff timer value is 100us which will
ensure less than 10k interrupts under load. The timer value can be
changed with dev.mskc.0.int_holdoff sysctl node.

Note, the interrupt moderation is shared resource on dual-port
controllers so you can't use separate interrupt moderation value
for each port. This means we can't stop interrupt moderation in
driver stop routine. Also have msk_tick() reclaim transmitted Tx
buffers as safety belt. With this change there is no need to check
missing Tx completion interrupt in watchdog handler, so remove it.


# 5774c1ed 23-Mar-2010 Pyun YongHyeon <yongari@FreeBSD.org>

MFC r204363,204365-204367,204539-204540:
r204363:
Optimize inserting LE for TX checksum computation. Controller does
not require checksum LE configuration if checksum start and write
position is the same as before. So keep track last checksum start
and write position and insert new LE whenever the position is
changed. This reduces number of LEs used in TX path as well as
slightly enhance TX performance.

r204365:
Don't hardcod register offset to set PCIe max read request size.
The register offset is not valid on 88E8072 controller. Also don't
blindly increase max read request size to 4096, instead, use 2048
which seems to be more sane value and only change the value if the
hardware default size(512) was used on that register.
For PCIX controllers, use system defined constant rather than using
magic value.
While I'm here stop showing negotiated link width.

r204366:
Allocate single MSI message. msk(4) used to allocate 2 MSI messages
for controllers like 88E8053 which reports two MSI messages.
Because we don't get anything useful things with 2 MSI messages,
allocating 1 MSI message would be more sane approach.
While I'm here, enable MSI for dual-port controllers too. Because
status block is shared for dual-port controllers, I don't think
msk(4) will encounter problem for using MSI on dual-port
controllers.

r204367:
Remove trailing white spaces.

r204539:
Properly sync status LEs after processing.

r204540:
Make sure to enable flow-control only if established link is
full-duplex. Previously msk(4) used to allow flow-control on
1000baseT half-duplex media. Also GMAC pause is enabled if link
partner is capable of handling it.
While I'm here use IFM_OPTIONS instead of using IFM_GMASK to check
optional flags of link.


# b951499f 23-Mar-2010 Pyun YongHyeon <yongari@FreeBSD.org>

MFC r204361-204362:
r204361:
Reuse the configured LE for VLAN if new LE was created for TSO.
Only old controllers need to create new LE for TSO. This change
makes TSO work over VLANs.

r204362:
Add TSO support on VLANs. Controller requires VLAN hardware tagging
to make TSO work over VLANs.


# 12c4b5ef 18-Mar-2010 Pyun YongHyeon <yongari@FreeBSD.org>

MFC r202826-202827,204146

r202826:
s/Mhz/MHz/g

Submitted by: N.J. Mann <njm <> njm dot me dot uk >

r202827:
Yukon Ultra2 has 125MHz clock.

r204146:
Correct inversed programming of ethernet hardware address on
big-endian architecture.

Submitted by: C. Jayachandran <c.jayachandran at gmail dot com> (initial version)


# b45923a6 14-Mar-2010 Pyun YongHyeon <yongari@FreeBSD.org>

It seems PCI_OUR_REG_[1-5] registers are not mapped on PCI
configuration space on Yukon Ultra(88E8056) such that accesses to
these registers were NOPs which in turn make msk(4) instable on
this controller. Use indirect access method to access
PCI_OUR_REG_[1-5] registers. This should fix a long standing
instability bug which prevented msk(4) working on Yukon Ultra.
Special thanks to koitsu who gave me remote access to his system.

PR: kern/114631, kern/116853
MFC after: 1 week


# 388214e4 12-Mar-2010 Pyun YongHyeon <yongari@FreeBSD.org>

Implement Rx checksum offloading for Yukon EC, Yukon Ultra,
Yukon FE and Yukon Ultra2. These controllers provide very simple
checksum computation mechanism and it requires additional pseudo
header checksum computation in upper stack. Even though I couldn't
see much performance difference with/without Rx checksum offloading
it may help notebook based controllers.

Actually controller can compute two checksum value by giving
different starting position of checksum computation on received
frame. However, for long time, Marvell's checksum offloading engine
have been known to have several silicon bugs so don't blindly trust
computed partial checksum value. Instead, compute partial checksum
twice by giving the same checksum computation position and compare
the result. If the value is different it's clear indication of
hardware bug. This configuration lose IP checksum offloading
capability but I think it's better to take safe route.
Note, Rx checksum offloading for Yukon XL was still disabled due to
known silicon bug.


# c876b43f 01-Mar-2010 Pyun YongHyeon <yongari@FreeBSD.org>

Remove taskqueue based interrupt handling. After r204541 msk(4)
does not generate excessive interrupts any more so we don't need
to have two copies of interrupt handler.
While I'm here remove two STAT_PUT_IDX register accesses in LE
status event handler. After r204539 msk(4) always sync status LEs
so there is no need to resort to reading STAT_PUT_IDX register to
know the end of status LE processing. Just trust status LE's
ownership bit.


# cf570c1f 01-Mar-2010 Pyun YongHyeon <yongari@FreeBSD.org>

Implement rudimentary interrupt moderation with programmable
countdown timer register. The timer resolution may vary among
controllers but the value would be represented by core clock
cycles. msk(4) will automatically computes number of required clock
cycles from given micro-seconds unit.
The default interrupt holdoff timer value is 100us which will
ensure less than 10k interrupts under load. The timer value can be
changed with dev.mskc.0.int_holdoff sysctl node.

Note, the interrupt moderation is shared resource on dual-port
controllers so you can't use separate interrupt moderation value
for each port. This means we can't stop interrupt moderation in
driver stop routine. Also have msk_tick() reclaim transmitted Tx
buffers as safety belt. With this change there is no need to check
missing Tx completion interrupt in watchdog handler, so remove it.


# 42f3ea9f 01-Mar-2010 Pyun YongHyeon <yongari@FreeBSD.org>

Make sure to enable flow-control only if established link is
full-duplex. Previously msk(4) used to allow flow-control on
1000baseT half-duplex media. Also GMAC pause is enabled if link
partner is capable of handling it.
While I'm here use IFM_OPTIONS instead of using IFM_GMASK to check
optional flags of link.


# 17f6f326 01-Mar-2010 Pyun YongHyeon <yongari@FreeBSD.org>

Properly sync status LEs after processing.


# 8c1643b6 26-Feb-2010 Pyun YongHyeon <yongari@FreeBSD.org>

Remove trailing white spaces.


# c72f075a 26-Feb-2010 Pyun YongHyeon <yongari@FreeBSD.org>

Allocate single MSI message. msk(4) used to allocate 2 MSI messages
for controllers like 88E8053 which reports two MSI messages.
Because we don't get anything useful things with 2 MSI messages,
allocating 1 MSI message would be more sane approach.
While I'm here, enable MSI for dual-port controllers too. Because
status block is shared for dual-port controllers, I don't think
msk(4) will encounter problem for using MSI on dual-port
controllers.


# 7420e9dc 26-Feb-2010 Pyun YongHyeon <yongari@FreeBSD.org>

Don't hardcod register offset to set PCIe max read request size.
The register offset is not valid on 88E8072 controller. Also don't
blindly increase max read request size to 4096, instead, use 2048
which seems to be more sane value and only change the value if the
hardware default size(512) was used on that register.
For PCIX controllers, use system defined constant rather than using
magic value.
While I'm here stop showing negotiated link width.


# 1b7757c0 26-Feb-2010 Pyun YongHyeon <yongari@FreeBSD.org>

Optimize inserting LE for TX checksum computation. Controller does
not require checksum LE configuration if checksum start and write
position is the same as before. So keep track last checksum start
and write position and insert new LE whenever the position is
changed. This reduces number of LEs used in TX path as well as
slightly enhance TX performance.


# 4858893b 26-Feb-2010 Pyun YongHyeon <yongari@FreeBSD.org>

Add TSO support on VLANs. Controller requires VLAN hardware tagging
to make TSO work over VLANs.


# d06930af 26-Feb-2010 Pyun YongHyeon <yongari@FreeBSD.org>

Reuse the configured LE for VLAN if new LE was created for TSO.
Only old controllers need to create new LE for TSO. This change
makes TSO work over VLANs.


# cf5756a6 20-Feb-2010 Pyun YongHyeon <yongari@FreeBSD.org>

Correct inversed programming of ethernet hardware address on
big-endian architecture.

Submitted by: C. Jayachandran <c.jayachandran at gmail dot com> (initial version)


# 84e3651e 22-Jan-2010 Pyun YongHyeon <yongari@FreeBSD.org>

Yukon Ultra2 has 126MHz clock.


# a91981e4 22-Jan-2010 Pyun YongHyeon <yongari@FreeBSD.org>

s/Mhz/MHz/g

Submitted by: N.J. Mann <njm <> njm dot me dot uk >


# de75e777 29-Nov-2009 Pyun YongHyeon <yongari@FreeBSD.org>

MFC r199413:
It seems generation of link state change of e1000phy(4) is not
reliable on some Marvell PHYs. If msk(4) know it still does not
have established link check whether msk(4) missed the link state
change by looking into polled link state.

Reported by: Mel Flynn < mel.flynn+fbsd.current <> mailing.thruhere dot net >,
Gleb Kurtsou <gleb.kurtsou <> gmail dot com >
Tested by: Gleb Kurtsou <gleb.kurtsou <> gmail dot com >


# 75c4ab0a 29-Nov-2009 Pyun YongHyeon <yongari@FreeBSD.org>

MFC r199012:
Add preliminary Yukon Ultra 2 support(88E8057). The controller
looks very similar to Yukon EC Ultra.

Tested by: kalin m ( kalin <> el dot net )


# 30c8843f 29-Nov-2009 Pyun YongHyeon <yongari@FreeBSD.org>

MFC 198996-198997.
r198996:
Remove unnecessary header file.

r198997:
It's normal to see Rx FIFO overruns under high network load and
showing the message creates other side-effects. Remove the Rx
FIFO overrun message in interrupt handler. msk(4) should recover
from the FIFO overruns without any user intervention. Users can
still check the Rx FIFO overrun counter from MAC MIB statistics
maintained in driver(dev.msk.0.stats.rx.overflows).


# 02b6f045 29-Nov-2009 Pyun YongHyeon <yongari@FreeBSD.org>

MFC 197592.
Add DGE-560SX(Yukon XL) to the supported device list. Many thanks
to "Eugene Perevyazko <john <> dnepro dot net>" who kindly gave
remote access to system with DGE-560SX.


# 26ac5ae5 29-Nov-2009 Pyun YongHyeon <yongari@FreeBSD.org>

MFC 197591.
Add workaround for Yukon XL which has hardware bug that can't flush
FIFO.


# 4b4edd61 29-Nov-2009 Pyun YongHyeon <yongari@FreeBSD.org>

MFC 197590.
Add hack to pass controller specific information to phy driver.
Unlike most other PHYs there is no easy way to know which media
type the PHY supports on Marvell PHYs. MIIF_HAVEFIBER flags is now
passed via bus-specific instance variable of a device. While I'm
here add 88E1112 specific work around to set SIGDET polarity low.
Many thanks "Eugene Perevyazko <john <> dnepro dot net>" who kindly
gave remote access to system with DGE-560SX.


# b76e9c08 29-Nov-2009 Pyun YongHyeon <yongari@FreeBSD.org>

MFC 197589.
Fix MIB statistics clear routine. This should fix alignment errors on sparc64.

Reported by: Garrett Damore < gdamore <> opensolaris dot org >


# 77e6010f 17-Nov-2009 Pyun YongHyeon <yongari@FreeBSD.org>

It seems generation of link state change of e1000phy(4) is not
reliable on some Marvell PHYs. If msk(4) know it still does not
have established link check whether msk(4) missed the link state
change by looking into polled link state.

Reported by: Mel Flynn < mel.flynn+fbsd.current <> mailing.thruhere dot net >,
Gleb Kurtsou <gleb.kurtsou <> gmail dot com >
Tested by: Gleb Kurtsou <gleb.kurtsou <> gmail dot com >


# 6ab1fc9f 08-Nov-2009 Ulf Lilleengen <lulf@FreeBSD.org>

MFC r198475:

- Add support for Marvell Yukon 88E8042 device.

Submitted by: Mario Lobo <mlobo -at- digiart.art.br>


# 76202a16 06-Nov-2009 Pyun YongHyeon <yongari@FreeBSD.org>

Add preliminary Yukon Ultra 2 support(88E8057). The controller
looks very similar to Yukon EC Ultra.

Tested by: kalin m ( kalin <> el dot net )


# f802264d 06-Nov-2009 John Baldwin <jhb@FreeBSD.org>

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.

(Missed this driver in the earlier commit.)


# ff080216 06-Nov-2009 Pyun YongHyeon <yongari@FreeBSD.org>

It's normal to see Rx FIFO overruns under high network load and
showing the message creates other side-effects. Remove the Rx
FIFO overrun message in interrupt handler. msk(4) should recover
from the FIFO overruns without any user intervention. Users can
still check the Rx FIFO overrun counter from MAC MIB statistics
maintained in driver(dev.msk.0.stats.rx.overflows).


# 56964c4c 06-Nov-2009 Pyun YongHyeon <yongari@FreeBSD.org>

Remove unnecessary header file.


# 0e0ed74f 25-Oct-2009 Ulf Lilleengen <lulf@FreeBSD.org>

- Add support for Marvell Yukon 88E8042 device.

Submitted by: Mario Lobo <mlobo -at- digiart.art.br>
Approved by: yongari


# 60d3251a 28-Sep-2009 Pyun YongHyeon <yongari@FreeBSD.org>

Add DGE-560SX(Yukon XL) to the supported device list. Many thanks
to "Eugene Perevyazko <john <> dnepro dot net>" who kindly gave
remote access to system with DGE-560SX.


# cde64af3 28-Sep-2009 Pyun YongHyeon <yongari@FreeBSD.org>

Add workaround for Yukon XL which has hardware bug that can't flush
FIFO.


# fcb62a8b 28-Sep-2009 Pyun YongHyeon <yongari@FreeBSD.org>

Add hack to pass controller specific information to phy driver.
Unlike most other PHYs there is no easy way to know which media
type the PHY supports on Marvell PHYs. MIIF_HAVEFIBER flags is now
passed via bus-specific instance variable of a device. While I'm
here add 88E1112 specific work around to set SIGDET polarity low.
Many thanks "Eugene Perevyazko <john <> dnepro dot net>" who kindly
gave remote access to system with DGE-560SX.


# 40d7192b 28-Sep-2009 Pyun YongHyeon <yongari@FreeBSD.org>

Fix MIB statistics clear routine. This should fix alignment errors on sparc64.

Reported by: Garrett Damore < gdamore <> opensolaris dot org >


# 67784314 08-Sep-2009 Poul-Henning Kamp <phk@FreeBSD.org>

Revert previous commit and add myself to the list of people who should
know better than to commit with a cat in the area.


# b34421bf 08-Sep-2009 Poul-Henning Kamp <phk@FreeBSD.org>

Add necessary include.


# 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


# a56fe1f0 01-Jun-2009 Pyun YongHyeon <yongari@FreeBSD.org>

Add Yukon Extreme device ids, 88E8071 and 88E8072.
While I'm here correct description of 88E8070. 88E8070 is Yukon
Extreme and have gigabit PHY.


# efb74172 01-Jun-2009 Pyun YongHyeon <yongari@FreeBSD.org>

Add Rx checksum offloading support for Yukon FE+ and Yukon Extreme.
These controllers use newer descriptor format and the new descriptor
format uses status LE to indicate the status of checksum. Rx
checksummed value used in previous controllers were very cryptic
and I failed to understand how to use them. In addition most
controllers in previous generations had Rx checksum offloading bug.

While I'm here introduce a MSK_FLAG_NORX_CSUM flag to bypass
checking Rx checksum offloading as Yukon FE+ A0 has status LE bug.


# ebb25bfa 01-Jun-2009 Pyun YongHyeon <yongari@FreeBSD.org>

Add frame parser capability of Yukon FE+ and Yukon Extreme. With
this feature hardware automatically computes TCP/UDP payload
offset. Introduce MSK_FLAG_AUTOTX_CSUM to mark the capability.
Yukon Extreme B0 revision is known to have a silicon for the
feature so disable it. Yukon Extreme B0 still can do Tx checksum
offloading but CPU have to compute TCP/UDP payload offset. To
enable traditional checksum offloading, disable automatic Tx
checksum calculation capability.
Yukon Extreme A0 revision could not use store-and-forward mode for
jumbo frames(silicon bug) so disable Tx checksum offloading for
jumbo frames.

I believe controllers that have MSK_FLAG_AUTOTX_CSUM capability or
new descriptor format do not have Tx checksum offload bug so
disable checksum offloading workaround for for short frames.

Tested by: jhb, Warren Block ( wblock <> wonkity dot com )


# daf29227 01-Jun-2009 Pyun YongHyeon <yongari@FreeBSD.org>

Add preliminary Yukon Extreme support and register definitions.
Yukon Extreme uses new descriptor format for TSO and has Tx frame
parser which greatly reduces CPU cycles spent in computing TCP/UDP
payload offset calculation in Tx checksum offloading path. The new
descriptor format also removed TCP/UDP payload computation for TSO
which in turn results in better TSO performance. It seems Yukon
Extreme has a lot of new (unknown) features but only basic
offloading is supported at this time. So far there are two known
issues.
o Sometimes Rx overrun errors happen when pulling data over
gigabit link. Running over 100Mbps seem to ok.
o Ethernet hardware address shows all-zeroed value on 88E8070.
Assigning ethernet address with ifconfig is necessary to make it
work.
Support for Yukon Extreme is not perfect but it would be better
than having a non-working device. Special thanks to jbh who fixed
several bugs of initial patch.

Tested by: jhb, Warren Block ( wblock <> wonkity dot com )


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

Correct controller description for 88E8035, 88E8036, 88E8038 and
88E8039. These are fast ethernet controllers.


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

Simplify SIOCSIFFLAGS handler.


# 98e02aeb 25-May-2009 Pyun YongHyeon <yongari@FreeBSD.org>

Be consistent with other capability checking.


# 89e22666 25-May-2009 Pyun YongHyeon <yongari@FreeBSD.org>

Don't reinitialize controller when interface is already running.


# 6f5a0d1f 25-May-2009 Pyun YongHyeon <yongari@FreeBSD.org>

If interface is not UP, don't return media status.


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

Add device ids for Yukon FE+(88E8040, 88E8040T, 88E8048 and 88E8070).


# 224003b7 25-May-2009 Pyun YongHyeon <yongari@FreeBSD.org>

Add workaround for Yukon FE+ A0. This controller is known to have
severe silicon bugs that can't handle VLAN hardware tagging as well
as status LE writeback bug. The status LE writeback bug is so
critical we can't trust status word of received frame. To accept
frames on Yukon FE+ A0 msk(4) just do minimal check for received
frames and pass them to upper stack. This means msk(4) can pass
corrupted frames to upper layer. You have been warned!
Also I supposed RX_GMF_FL_THR to be 32bits register but Linux
driver treated it as 16bit register so follow their leads. At least
this does not seem to break msk(4) on Yukon FE+.

Tested by: bz, Tanguy Bouzeloc ( the.zauron <> gmail dot com )
Bruce Cran ( bruce <> cran dot org dot uk )
Michael Reifenberger ( mike <> reifenberger dot com )
Stephen Montgomery-Smith ( stephen <> missouri dot edu )


# 61708f4c 25-May-2009 Pyun YongHyeon <yongari@FreeBSD.org>

Add preliminary Yukon FE+ support and register definitions.
Yukon FE+ is fast ethernet controller and uses new descriptor
format. Since I don't have this controller, the support code was
written from guess and various feedback from enthusiastic users.
Thanks to all users who patiently tested my initial patches.
Special thanks to Tanguy Bouzeloc who fixed critical bug of initial
patch.

Tested by: bz, Tanguy Bouzeloc ( the.zauron <> gmail dot com )
Bruce Cran ( bruce <> cran dot org dot uk )
Michael Reifenberger ( mike <> reifenberger dot com )
Stephen Montgomery-Smith ( stephen <> missouri dot edu )


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

Explicitly reset GMAC Controls and initialize GM_GP_CTRL register.
The GM_GP_CTRL register may have stale content from previous link
information so clearing it will make hardware update the register
correctly when it established a valid link.
While I'm here remove stale comment.


# 846e6d79 25-May-2009 Pyun YongHyeon <yongari@FreeBSD.org>

Disable HW WOL for Yukon EC Ultra. While I'm here use switch
statement over if-else statement. This change will make it easy to
add newer Yukon controllers.


# 6c4d62e1 25-May-2009 Pyun YongHyeon <yongari@FreeBSD.org>

Explicitly check resolved speed/duplex. Just checking IFM_ACTIVE
does not guarantee established link. Also 1000baseT link report for
fast ethernet controller is not valid one so make sure gigabit link
is allowed for this controller.
Whenever we lost link, check whether Rx/Tx MACs were enabled. If both
MAC are not active, do not try to disable it again.


# 262e9dcf 25-May-2009 Pyun YongHyeon <yongari@FreeBSD.org>

Add support for newer descriptor format. This format is used on
Yukon FE+, Yukon Extreme and Yukon Supreme.


# 40d6bed8 24-May-2009 Pyun YongHyeon <yongari@FreeBSD.org>

Oops, add missing ~ operator.


# 4b76fe63 24-May-2009 Pyun YongHyeon <yongari@FreeBSD.org>

Caller already hold a driver lock in mii callback, assert it.


# e2b16603 24-May-2009 Pyun YongHyeon <yongari@FreeBSD.org>

Rather than checking every chip revision, introduce more flags to
mark controller's capability. Controllers that have jumbo frame
support sets MSK_FLAG_JUMBO, and controllers that does not support
checksum offloading for jumbo frames will set MSK_FLAG_JUMBO_NOCSUM.
For Fast Ethernet controllers it will set MSK_FLAG_FASTETHER and it
would be used in link state handling.

While here, disable Tx checksum offloading if jumbo frame is used
on controllers that does not have Tx checksum offloading capability
for jumbo frame(e.g. Yukon EC Ultra).


# 325c534e 24-May-2009 Pyun YongHyeon <yongari@FreeBSD.org>

Correctly return the result of mii_mediachg(). Previously it always
used to return success.


# 7a76e8a4 24-May-2009 Pyun YongHyeon <yongari@FreeBSD.org>

Use bit definition to represent MSI and detach state instead of
using separate variables in softc.


# ab7df1e4 24-May-2009 Pyun YongHyeon <yongari@FreeBSD.org>

Use bit definition to represent link state, device suspend instead
of using separate variables in softc.


# 19585f45 24-May-2009 Pyun YongHyeon <yongari@FreeBSD.org>

Remove link handling taskqueue and use mii callback directly. While
I'm here also checks driver running state.


# 79dd979a 25-Mar-2009 Pyun YongHyeon <yongari@FreeBSD.org>

Fix typo.


# 6d6588a1 22-Mar-2009 Pyun YongHyeon <yongari@FreeBSD.org>

Togging ALLMULTI does not require controller reset so have Rx
filtering handle this. Introduce a new function msk_rxfilter that
handles Rx filter configuration and multicast setup as well as
promiscuous mode. This simplifies code a lot.
Promiscuous mode always have preference to any other Rx
filtering so don't disable the mode when ALLMULTI is set.


# 3a91ee71 16-Jan-2009 Pyun YongHyeon <yongari@FreeBSD.org>

Add hardware MAC statistics support. Also added some reserved
statistics register definition. Users can get current MAC
statistics from dev.msk.%d.stats sysctl node(%d is unit number of
a device).


# 85b340cb 13-Jan-2009 Pyun YongHyeon <yongari@FreeBSD.org>

Remove local jumbo locator and switch to UMA backed page allocator
for jumbo frame.
o Nuke unneeded jlist lock which was used to protect jumbo buffer
management in local allocator.
o Added a new tunable hw.mskc.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 msk(4). If msk(4) encounter the allocation
failure it just disables jumbo frame support and continues to
work without your intervention.

Using local allocator had several drawbacks such as requirement of
large amount of continuous kernel memory and fixed (small) number
of available buffers. The need for large continuous memory resulted
in failure of loading driver with kldload on running systems.
Also small number of buffer used in local allocator showed poor
performance for some applications.


# f9ad2b2f 13-Jan-2009 Pyun YongHyeon <yongari@FreeBSD.org>

Correct frame length argument of in_cksum_skip. While I'm here
remove intermediate variable csum.

Reported by: Kim Culhan < w8hdkim <> gmail DOT com >
Tested by: Kim Culhan < w8hdkim <> gmail DOT com >


# e4816325 23-Nov-2008 Pyun YongHyeon <yongari@FreeBSD.org>

Save the value read from TX queue CSR, so we don't test against a
stale one.

Submitted by: sephe


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

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


# ad415775 29-Sep-2008 Pyun YongHyeon <yongari@FreeBSD.org>

If mbuf is not writable get a writable copy before invoking
m_pullup(9).

Tested by: Garrett Cooper < yanefbsd <at> gmail dot com >


# 925da971 29-Sep-2008 Pyun YongHyeon <yongari@FreeBSD.org>

Always pullup mbuf prior to accessing TCP header.
This should fix occasional Tx checksum corruption issue.

Reported by: Garrett Cooper < yanefbsd <at> gmail dot com >
Tested by: Garrett Cooper < yanefbsd <at> gmail dot com >


# 83c04c93 25-Sep-2008 Pyun YongHyeon <yongari@FreeBSD.org>

Add another hardware bug workaround for Yukon II controllers that
have hardware ram buffer. The silicon bug seem to be triggered by
pause frames if receive buffer is not aligned on FIFO word(8 bytes).
To workaround the issue, make sure to align Rx buffers on 8 bytes.
Unfortunately this workaround requires yet another Rx fixup for
strict alignment architecture machines to align IP header.

For newer hardwares that lacks ram buffer may not have this bug so
check number of available ram buffer size to see the existence of
ram buffer.

Reported by: Ian Freislich (ianf <at> clue dot co dot za), das
Tested by: Ian Freislich (ianf <at> clue dot co dot za)


# 2b71cf86 10-Mar-2008 Pyun YongHyeon <yongari@FreeBSD.org>

Move comments block 1 line up to remark on the setting
if_capabilities. This would make comments clear.

Suggested by: yar


# 06ff0944 06-Mar-2008 Pyun YongHyeon <yongari@FreeBSD.org>

To overcome hardware checksum offload bug msk(4) used to compute
TCP/UDP checksum in driver for short frames. For frames that requires
hardware VLAN tag insertion, the checksum offload trick does not
work due to changes of checksum offset in mbuf after the VLAN tag.

Disable hardware checksum offload for VLAN interface to fix the bug.

Reported by: Christopher Cowart < ccowart AT rescomp DOT berkeley DOT edu >
Tested by: Christopher Cowart < ccowart AT rescomp DOT berkeley DOT edu >
MFC after: 5 days


# d5d60164 28-Feb-2008 Pyun YongHyeon <yongari@FreeBSD.org>

Workaround GMAC hardware hang of Yukon II on the receipt of pause
frames. This bug seems to happen on certain hardware model/revision
(e.g. 88E8053) but it's not identified which hardwares are affected.
Revision 1.4 of if_mskreg.h was not enough to workaround the bug.
To workaround it, inrease GMAC FIFO threshold by one FIFO word to
flush received pause frames.

Reported by: das, Kirill Nuzhdin < kirill.nuzhdin AT rad dot chem dot msu dot ru >
Tested by: das, Kirill Nuzhdin


# cf827063 01-Feb-2008 Poul-Henning Kamp <phk@FreeBSD.org>

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.


# 304a4c6f 17-Jan-2008 John Baldwin <jhb@FreeBSD.org>

- Retire npe_defrag(), gem_defrag(), msk_defrag(), nfe_defrag(), and
re_defrag() and use m_collapse() instead.
- Replace a reference to ath_defrag() in a comment in if_wpi.c with
m_collapse().


# 28d34c0e 05-Dec-2007 Remko Lodder <remko@FreeBSD.org>

Bring in support for: Marvell Yukon 8039

PR: 118401
Submitted by: Skip Ford <skip at menantico dot com>
Approved by: imp (mentor), yongari
MFC After: 3 days


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

Fix function prototype for device_shutdown method.


# 8463d7a0 20-Nov-2007 Pyun YongHyeon <yongari@FreeBSD.org>

Add MSI support for 88E8058(Yukon EC Ultra). Unlike other Yukon II
family 88E8058 supports only one MSI message. Teach msk(4) to handle
that case.

Tested by: Ed Schouten < ed AT fxq DOT nl >


# 75ef16df 20-Nov-2007 Pyun YongHyeon <yongari@FreeBSD.org>

Add device id for 88E8058(Yukon EC Ultra) which is found on 3rd
generation MacBooks.
Unfortunately 88E8058 supports one MSI message so msk(4) needs more
generic way to handle the MSI capability.

PR: 118110


# 431e606d 20-Nov-2007 Pyun YongHyeon <yongari@FreeBSD.org>

Make phy respond only at address 0. This makes phy driver attached
only at address 0 which is supposed to be the only valid phy address
on Marvell PHY. The more correct solution would be masking PHY
address ranges allowable in PHY probe routine. Unfortunately,
FreeBSD has no way to retrict the PHY address ranges or to pass special
flags to PHY driver.
This change assumes that PHY hardwares attached to msk(4) would be
Marvell made 88E11xx PHY.

With this changes the phantom phys attached on 88E8036(Yukon FE)
should disappear.

Reported by: Oleg Lomaka < oleg AT lomaka DOT org DOT ua >
Tested by: Oleg Lomaka < oleg AT lomaka DOT org DOT ua >


# e4a5f4e0 20-Nov-2007 Pyun YongHyeon <yongari@FreeBSD.org>

o Don't hardcode that Yukon FE has 16KB SRAM. In fact, Yukon FE has
only 4KB SRAM.
o Rework setting Tx/Rx RAM buffer size. Give receiver 2/3 of memory
and round it down to the multiple of 1024. The RAM buffer size of
Yukon II should be multiple of 1024. This fixes bogus RAM buffer
configuration used in Yukon FE.

Reported by: Oleg Lomaka < oleg AT lomaka DOT org DOT ua >
Tested by: Oleg Lomaka < oleg AT lomaka DOT org DOT ua >


# cfd540e7 19-Nov-2007 Pyun YongHyeon <yongari@FreeBSD.org>

Drop maintaing hardware feature(bug) lists for Yukon II. We don't have
publicly available datasheet for Yukon II and don't know what
bug/workaround exist for the specific hardware revision. Also I don't
think the vendor will release hardware errata in near future.
The hardware feature lists were not used at all except setting water
mark registers. Since msk(4) should know exact chip model/revision
number to decide which hardware capability could be used the extra
feature lists were redundant.


# a109c74f 19-Nov-2007 Pyun YongHyeon <yongari@FreeBSD.org>

Various fixes for EC Ultra.
o Enable jumbo frame support for EC Ultra and disable jumbo frame
for FE.
o Enable store and forward mode for standard MTU sized frame.
o Enable TSO for EC Ultra. However TSO/checksum offload is disabled
for jumbo frame case. Because EC Ultra can't use store and forward
mode for jumbo frame TSO/checksum offload is not available.
o Adjust Tx GMAC almost empty threshold value and add a jumbo frame
water mark. The maic value was obtained from Marvell's sk98lin
driver.
o Fix EC Ultra chip revision number.


# 53dcfbd1 19-Jul-2007 Pyun YongHyeon <yongari@FreeBSD.org>

Add legacy interrupt handler which would be more appropriate for
interrupt that is shared with other devices(e.g. USB) in system and
provide a new tunable "hw.msk.legacy_intr" to activate the legacy
interrupt handler. Setting the tunable automatically disables MSI
for msk(4). Previously msk(4) used adoptive polling with taskqueue(9)
as all msk(4) hardwares I know supports MSI. However, there are cases
that MSI couldn't be used on some hardwares due to bugs in MSI
implementatins.

Tested by: Li-Lun Wang < llwang AT infor DOT org >
Approved by: re (kensmith)


# 8b51df84 10-Jun-2007 Pyun YongHyeon <yongari@FreeBSD.org>

Increase a maximum segment size of DMA to 4096. Previously it used
MCLBYTES for the segment size but it used too many Tx descriptors in
TSO case.
While I'm here adjust maximum size of the sum of all segment lengths
in a given DMA mapping to 65535, the maximum size, in bytes, of a IP
packet.


# cf7a67bf 10-Jun-2007 Pyun YongHyeon <yongari@FreeBSD.org>

Disable automatic IP ID increment. Due to a hardware bug the automatic
IP ID increment in TSO case generated corrupted IP packets.
This change brings back TSO capability.


# b2313f58 24-Apr-2007 Pyun YongHyeon <yongari@FreeBSD.org>

Disable TSO support.
Under certain circumtances, if TSO is active, Yukon II generates
corrupted IP packets. All corrupted IP packets I noticed were the the
last segmented packet in a TSO request. The corrupted packet resulted
in retransmission of the damaged packet which in turn decreased network
performance dramatically.
Unfortunately it seems that there is no way to workaround this bug
as TSO is completely handled in hardware. Disable TSO until we find a
working workaround or a new silicon revision that doesn't have this
hardware bug.


# 3326191f 24-Apr-2007 Pyun YongHyeon <yongari@FreeBSD.org>

Fix TCP header size calculation logic which is used for setting
TSO MTU.


# b5898b80 10-Apr-2007 Pyun YongHyeon <yongari@FreeBSD.org>

Add work around for hardware Tx checksum offload bug in Yukon II.
Yukon II generated corrupted TCP checksum for short TCP packets
that's less than 60 bytes in size(e.g. window probe packet, pure ACK
packet etc). Padding the frame with zeros to make the frame minimum
ethernet frame size didn't work at all. Instead of dropping Tx
checksum offload support we calculate TCP checksum with S/W method
when we encounter short TCP frames.
Fortunately it seems that short UDP datagrams appear to be handled
correctly by Yukon II.

While I'm here simplify ethernet/VLAN header size calculation logic.

PR: 111384


# ad6d01d1 05-Apr-2007 Pyun YongHyeon <yongari@FreeBSD.org>

If we've encountered unrecognized chipset don't access hardware
anymore. Previously it tried to access interrupt register to disable
interrupts which could result in hang if the hardware was not
properly initialized by system BIOS/ACPI.

Tested by: Benjamin Hansmann (benjamin.hansmann AT rub dot de)
MFC after: 3 days


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


# 71e88667 14-Feb-2007 Pyun YongHyeon <yongari@FreeBSD.org>

Unbreak non-H/W VLAN extraction case.
Unlike other GigEs Yukon II always set VLAN bit when it detects VLAN
tagged packet regardless of H/W VLAN processing configuration state.
So it need to check IFCAP_VLAN_HWTAGGING bit to know whether driver
is configured to take advantage of H/W VLAN processing. If H/W VLAN
processing was disabled don't adjust received packet length such that
subsequent validation logic works for software VLAN processing.

Reported by: bms
Tested by: bms


# 6ec27c17 08-Jan-2007 Pyun YongHyeon <yongari@FreeBSD.org>

Remove duplicated legacy SYS_RES_IRQ resources assignment.

Noticed by: jhb


# 303cb733 07-Jan-2007 Pyun YongHyeon <yongari@FreeBSD.org>

Fix a typo which blindly enabled TSO capability without respect to
chip type.


# bf59599f 07-Jan-2007 Pyun YongHyeon <yongari@FreeBSD.org>

Don't rely on GM_GP_CTRL register contents when mii(4) layer reports
link state changes. Instead, build new speed/duplex/flow-control
settings from the values reported from PHY.
This should fix speed/duplex/flow-control mismatches between GMAC and
PHY which resulted in very poor Rx performance due to lots of
out-of-order packet delivery.

Reported by: Arno J. Klaassen <arno AT heho DOT snv DOT jussieu DOT fr>
Tested by: Arno J. Klaassen <arno AT heho DOT snv DOT jussieu DOT fr>


# a485f97a 07-Jan-2007 Pyun YongHyeon <yongari@FreeBSD.org>

Initialize legacy SYS_RES_IRQ resources before attempting to use MSI.
This fixes legacy SYS_RES_IRQ resource allocation failure when MSI is
disabled.

Reported by: rrs
Tested by: rrs


# 2271eac7 28-Dec-2006 Pyun YongHyeon <yongari@FreeBSD.org>

Piggyback watchdog timer handling with msk_tick which is called every
hz. This will result in slightly faster Tx processing as it does not
need lock operations for callouts in msk_start/msk_txeof.


# b55031fd 28-Dec-2006 Pyun YongHyeon <yongari@FreeBSD.org>

Fix interrupt handling on a dual port card. Previously it ignored
the second port interrupt if the first port was in down state.
Since I don't have a dual port card it's just guess work.

Noticed by: jhb


# 298946a9 28-Dec-2006 Pyun YongHyeon <yongari@FreeBSD.org>

Fix MSI support. Now it correctly allocates SYS_RES_IRQ resources
on Yukon II which reports it can handle two messages.

Submitted by: jhb
Tested by: bms


# 0dbe28b3 12-Dec-2006 Pyun YongHyeon <yongari@FreeBSD.org>

Add msk(4), a driver for Marvell/SysKonnect Yukon II Gigabit Ethernet
controller. Due to lack of documentation, this driver is based on the
code from sk(4) and Marvell's myk(4) driver for FreeBSD. I've also
adopted the OpenBSD interface name, msk(4) in order to reduce naming
differences between BSDs.
The msk(4) driver supports the following Gigabit Ethernet adapters.

o SysKonnect SK-9Sxx Gigabit Ethernet
o SysKonnect SK-9Exx Gigabit Ethernet
o Marvell Yukon 88E8021CU Gigabit Ethernet
o Marvell Yukon 88E8021 SX/LX Gigabit Ethernet
o Marvell Yukon 88E8022CU Gigabit Ethernet
o Marvell Yukon 88E8022 SX/LX Gigabit Ethernet
o Marvell Yukon 88E8061CU Gigabit Ethernet
o Marvell Yukon 88E8061 SX/LX Gigabit Ethernet
o Marvell Yukon 88E8062CU Gigabit Ethernet
o Marvell Yukon 88E8062 SX/LX Gigabit Ethernet
o Marvell Yukon 88E8035 Gigabit Ethernet
o Marvell Yukon 88E8036 Gigabit Ethernet
o Marvell Yukon 88E8038 Gigabit Ethernet
o Marvell Yukon 88E8050 Gigabit Ethernet
o Marvell Yukon 88E8052 Gigabit Ethernet
o Marvell Yukon 88E8053 Gigabit Ethernet
o Marvell Yukon 88E8055 Gigabit Ethernet
o Marvell Yukon 88E8056 Gigabit Ethernet
o D-Link 550SX Gigabit Ethernet
o D-Link 560T Gigabit Ethernet

Unlike OpenBSD/NetBSD msk(4), the msk(4) driver supports all hardware
features including TCP/UDP checksum offload for transmit, MSI, TCP
segmentation offload(TSO), hardware VLAN tag stripping/insertion,
and jumbo frames(up to 9022 bytes). The only unsupported hardware
feature except RLMT is Rx checksum offload which I don't know how to
make it work reliably.

Known Issues:
It seems msk(4) does not work on the second port of dual port NIC.
(The first port works without problems.)

Thanks to Marvell for releasing the BSD licensed myk(4) driver and
thanks to all users helped fixing bugs.

Tested by: bz, philip, bms,
YAMAMOTO Shigeru < shigeru AT iij DOT ad DOT jp >,
Dmitry Pryanishnikov < dmitry AT atlantis DOT dp DOT ua >,
Jia-Shiun Li < jiashiun AT gmail DOT com >,
David Duchscher < daved AT tamu DOT edu >,
Arno J. Klaassen < arno AT heho DOT snv DOT jussieu DOT fr>,
Nicolae Namolovan < adrenalinup AT gmail DOT com>,
Andre Guibert de Bruet < andy AT siliconlandmark DOT com >
current ML
Tested on: i386, amd64