Home | History | Annotate | Download | only in pci
History log of /src/sys/dev/pci/if_bnx.c
RevisionDateAuthorComments
 1.116  10-Nov-2024  mlelstv Add MBUFTRACE
 1.115  29-Jun-2024  riastradh if_stats(9): Add ifp argument to if_stat..._ref.

This will enable us to pass the ifp through to a dtrace probe inside.

No functional change intended in this change, but this is an API
change visible to modules so it shouldn't be pulled up.

PR kern/58377
 1.114  23-Apr-2024  hans Sync the statistics DMA memory correctly before it is accessed.
 1.113  09-Feb-2024  andvar fix spelling mistakes, mainly in comments and log messages.
 1.112  01-Aug-2023  andvar fix various typos in comments.
 1.111  04-Aug-2022  andvar s/bufferred/buffered/ in memory description.L:
 1.110  05-Dec-2021  msaitoh s/exisit/exist/ in comment.
 1.109  13-Aug-2021  andvar s/struture/structure/ s/structre/structure/
 1.108  14-Feb-2021  jakllsch if_bnx.c: fix misleading indentation

suggested by rillig@
 1.107  13-Feb-2021  jakllsch Curb aprint_*() abuse in bnx(4)
 1.106  13-Feb-2021  jakllsch Revert bnx(4) to INTx interrupts.

Should fix PR kern/55974.

This driver does not yet do the special MSI and MSI-X setup that the
chip apparently requires.
 1.105  17-Jul-2020  jdolecek branches: 1.105.2;
if bnx_tx_encap() fails because mbuf is too fragmented or too long,
drop the mbuf instead of wedging the TX queue forever; found by code inspection

this is quite unlikely scenario since it requires mbuf chain consisting of
more than 8 frags and m_defrag() failing, so probably unrelated to PR kern/47229
 1.104  17-Jul-2020  jdolecek make sure bnx_alloc_pkts() always clears BNX_ALLOC_PKTS_FLAG and IFF_OACTIVE,
even on dmamap allocation failure; remove unnecessary IFF_UP condition
 1.103  17-Jul-2020  jdolecek remove mistakely committed in-progress code from previous commit
 1.102  17-Jul-2020  jdolecek re-enable MSI/MSI-X, the TX timeouts were caused by the IFF_OACTIVE handling,
which was fixed in previous revision
 1.101  16-Jul-2020  jdolecek need to clear IFF_OACTIVE after allocating more pkts in order to actually
start processing the queue in bnx_start()
 1.100  16-Jul-2020  jdolecek disable MSI/MSI-X for time being, it causes interrupt timeouts and needs
to be investigated before enabling this again
 1.99  14-Jul-2020  jdolecek make bnx_wk (used to trigger bnx_alloc_pkts()) part of softc instead
of using a static variable, so it's independant for each adapter
 1.98  14-Jul-2020  jdolecek remove call to bnx_alloc_pkts() from bnx_init_tx_chain() - it can
be called from softint context via bnx_watchdog(), and bnx_alloc_pkts()
dmamap allocation can't run in (soft)interrupt context
 1.97  14-Jul-2020  jdolecek only destroy the TX pkgs and dmamaps in bnx_dma_free() called on detach, don't
do it anymore in bnx_free_tx_chain(), called from bnx_init()

avoid occassional panic triggered by the free code having to allocate
memory from interrupt context when bnx_init() is called from bnx_watchdog()
 1.96  12-Jul-2020  jdolecek enable MSI/MSI-X if supported by adapter

tested MSI-X with Broadcom NetXtreme II BCM5709 1000Base-T
 1.95  18-May-2020  msaitoh Fix typo in comment.
 1.94  28-Feb-2020  msaitoh Replace bnx_ifmedia_upd() in bnx_init() with mii_ifmedia_change() for future
locking changes.
 1.93  28-Feb-2020  msaitoh Replace bnx_ifmedia_upd() in bnx_mgmt_init() with mii_ifmedia_change() for
future locking changes. Suggested by thorpej@.

XXX Need more work for bnx_ifmedia_upd() itself.
 1.92  07-Feb-2020  thorpej Use callout_setfunc() / callout_schedule().
 1.91  04-Feb-2020  thorpej Use ifmedia_fini().
 1.90  01-Feb-2020  thorpej Adopt <net/if_stats.h>.
 1.89  27-Dec-2019  msaitoh branches: 1.89.2;
s/recive/receive/ in comment.
 1.88  10-Nov-2019  chs in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.87  26-Jul-2019  msaitoh Calculate the multicast hash table correctly to avoid undefined behavior.
Found by KUBSan.
 1.86  09-Jul-2019  msaitoh Don't automatically set ec_capenable's ETHERCAP_VLAN_HWTAGGING bit in
vlan_config() to make it user-controllable. Instead, set the bit in
xxx_attach().
 1.85  28-May-2019  msaitoh Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.84  23-May-2019  msaitoh Whitespace fix (mainly tabify).
 1.83  23-May-2019  msaitoh No functional change:
- Simplify MII structure initialization and reference.
- u_int*_t -> uint*_t.
- KNF
 1.82  24-Apr-2019  msaitoh This driver uses MII(4) and have hook SIOCGIFMEDIA which just pass to
ifmedia_ioctl(), the hook is not required because ether_ioctl has it
(if_ethersubr.c rev. 1.160). This driver might require some additional fixes
for SIOCSIFMTU and other ioctl()s.
 1.81  11-Apr-2019  msaitoh Fix a bug that the duplex of manual media setting may be wrong
when the IFM_GMASK bit other than IFM_[FH]DX is set.
 1.80  08-Apr-2019  msaitoh Make it compilable with BNX_DEBUG.
 1.79  05-Apr-2019  msaitoh BCM5709 is PCIe based. To wait for pending PCI transactions to complete,
wait until PCIe's transaction pending bit is cleared.
 1.78  05-Apr-2019  msaitoh - Allow time for the management firmware to enter the running state.
- Enable/Disable management frames (NC-SI) to flow to the MCP if MFW exists.
- Print the boot code version, management firmware version and some flags.
- Gbps -> GT/s for PCIe speed.
- Use aprint_*() in bnx_print_adapter_info().
- Use braces for some macors' argument.
- Remove unused macros.
- KNF.
 1.77  05-Apr-2019  msaitoh Fix a bug that BNX_MISC_ENABLE_SET_BITS is not correctly set on BCM5709.
 1.76  04-Apr-2019  msaitoh 0 -> NULL.
 1.75  01-Apr-2019  msaitoh s/adddress/address/
 1.74  29-Mar-2019  msaitoh - Use m_defrag() when bus_dmamap_load_mbuf() returned with EFBIG.
- Style change to reduce diff against {Free,Open}BSD.
- Make it compilable with BNX_DEBUG.
- Use __nothing for null macro.
 1.73  29-Mar-2019  msaitoh Sync with OpenBSD:
- Don't need to clear if_timer during attach. (OpenBSD rev. 1.23)
- Do the minimal initialization of the firmware so that ASF always works.
From ambrisko@FreeBSD (OpenBSD rev. 1.32)
- Move the interrupt establishment till after everything in the softc is set up
(OpenBSD rev. 1.40)
- Let mii_attach() know where the PHY is located instead of scanning for it
since we know where it will be anyway and remove the code from the MII bus
read/write functions to force reading/writing from the predetermined
location. Copied from bge(4) and this is what the upstream FreeBSD bce(4)
driver has done once FreBSD gained a mii_attach().
 1.72  28-Mar-2019  msaitoh - Remove extra cast (from OpenBSD rev. 1.95)
- Add support flow control (from OpenBSD rev. 1.97 and 1.100).
The main difference between NetBSD and other *BSDs is that the flow control
does really works. The lower 8bit of BNX_L2CTX_CTX_TYPE should be 0xff
(from Linux). Note that I have NetXtremeII-PG203-R.pdf and it says the field
is reserved and should be 0.
 1.71  27-Mar-2019  msaitoh - Remove extra check (because the same check is done in
if_schedule_deferred_start().
- Remove extra space.
 1.70  27-Mar-2019  msaitoh Apply OpenBSD rev. 1.94:

> ido not disable interrupts in the isr and then enable them again
> when leaving. when you're handling an interrupt it is masked.
> whacking the chip is work for no gain.
>
> modify the interrupt handler so it only processes the rings once
> rather than looping over them until it runs out of work to do
>
> looping in the isr is bad for several reasons:
>
> firstly, the chip does interrupt mitigation so you have a
> decent/predictable amount of work to do in the isr. your first loop
> will do that chunk of work (ie, it pulls off 50ish packets), and
> then the successive looping aggressively pull one or two packets
> off the rx ring. these extra loops work against the benefit that
> interrupt mitigation provides.
>
> bus space reads are slow. we should avoid doing them where possible
> (but we should always do them when necessary).
>
> doing the loop 5 times per isr works against the mclgeti semantics.
> it knows a nic is busy and therefore needs more rx descriptors by
> watching to see when the nic uses all of its descriptors between
> interrupts. if we're aggressively pulling packets off by looping
> in the isr then we're skewing this check.
>
> ok deraadt@
 1.69  27-Mar-2019  msaitoh Sync with other *BSDs:

From OpenBSD's rev. 1.93:
> to quote from the gospel of bus_dma.9:
>
> Synchronization operations are expressed from the perspective of the host
> RAM, e.g., a device -> memory operation is a READ and a memory -> device
> operation is a WRITE.
>
> the status block that the isr reads is written to by the device.
> the chip writes to memory, it is therefore a READ.
>
> this also adds the preread sync when the map is set up and the postread
> sync when the map is torn down for better symmetry. there are probably
> more issues like this in the code, but this is a start.
>
> discovered while discussing another diff with claudio@
 1.68  22-Jan-2019  msaitoh Change MII PHY read/write API from:

int (*mii_readreg_t)(device_t, int, int);
void (*mii_writereg_t)(device_t, int, int, int);
to:

int (*mii_readreg_t)(device_t, int, int, uint16_t *);
int (*mii_writereg_t)(device_t, int, int, uint16_t);

Now we can test if a read/write operation failed or not by the return value.

In 802.3 spec says that the PHY shall not respond to read/write transaction
to the unimplemented register(22.2.4.3). Detecting timeout can be used to
check whether a register is implemented or not (if the register conforms to
the spec). ukphy(4) can be used this for MII_MMDACR and MII_MMDAADR.

Note that I noticed that the following code do infinite loop in the
read/wirte function. If it accesses unimplemented PHY register, it will hang.
It should be fixed:

arm/at91/at91emac.c
arm/ep93xx/epe.c
arm/omap/omapl1x_emac.c
mips/ralink/ralink_eth.c
arch/powerpc/booke/dev/pq3etsec.c(read)
dev/cadence/if_cemac.c <- hkenken
dev/ic/lan9118.c


Tested with the following device:

axe+ukphy
axe+rgephy
axen+rgephy (tested by Andrius V)
wm+atphy
wm+ukphy
wm+igphy
wm+ihphy
wm+makphy
sk+makphy
sk+brgphy
sk+gentbi
msk+makphy
sip+icsphy
sip+ukphy
re+rgephy
bge+brgphy
bnx+brgphy
gsip+gphyter
rtk+rlphy
fxp+inphy (tested by Andrius V)
tlp+acphy
ex+exphy
epic+qsphy
vge+ciphy (tested by Andrius V)
vr+ukphy (tested by Andrius V)
vte+ukphy (tested by Andrius V)

Not tested (MAC):
arm:at91emac
arm:cemac
arm:epe
arm:geminigmac
arm:enet
arm:cpsw
arm:emac(omac)
arm:emac(sunxi)
arm:npe
evbppc:temac
macppc:bm
macppc:gm
mips:aumac
mips:ae
mips:cnmac
mips:reth
mips:sbmac
playstation2:smap
powerpc:tsec
powerpc:emac(ibm4xx)
sgimips:mec
sparc:be
sf
ne(ax88190, dl10019)
awge
ep
gem
hme
smsh
mtd
sm
age
alc
ale
bce
cas
et
jme
lii
nfe
pcn
ste
stge
tl
xi
aue
mue
smsc
udav
url

Not tested (PHY):
amhphy
bmtphy
dmphy
etphy
glxtphy
ikphy
iophy
lxtphy
nsphyter
pnaphy
rdcphy
sqphy
tlphy
tqphy
urlphy
 1.67  08-Jan-2019  msaitoh Fix a bug that bnx_miibus_read_reg() returns wrong value when
BNX_PHY_INT_MODE_AUTO_POLLING_FLAG is set. This bug doesn't cause a real
problem because BNX_PHY_INT_MODE_AUTO_POLLING_FLAG is not set.
 1.66  08-Jan-2019  msaitoh KNF. No functional change.
 1.65  26-Jun-2018  msaitoh branches: 1.65.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.64  08-May-2018  msaitoh - Fix a bug that bnx(4) panics on shutdown. Stop callout before restroy.
Reported by Andreas Gustafsson in PR#53265.
- Make sure not to re-arm the callout when we are about to detach. Same as
if_bge.c rev. 1.292.
- Use pci_intr_establish_xname().
 1.63  08-Feb-2018  dholland branches: 1.63.2;
Typos.
 1.62  26-Sep-2017  knakahara VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.

I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html

XXX need pullup to -8 branch
 1.61  15-Dec-2016  ozaki-r branches: 1.61.8;
Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
 1.60  08-Dec-2016  ozaki-r Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.
 1.59  10-Jun-2016  ozaki-r branches: 1.59.2;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.58  09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.57  09-Jul-2014  msaitoh branches: 1.57.4;
Call bnx_print_adapter_info() before mii_attach() to not to
split bnx's dmesg into two parts by brgphy's dmesg.
 1.56  01-Jul-2014  msaitoh Print some information (ASIC revision, PCI status, etc). From FreeBSD.
 1.55  01-Jul-2014  msaitoh No functional change.
- s/u_int/uint/
- Modify comment a bit (sync with OpenBSD)
 1.54  24-Jun-2014  msaitoh No functional change:
- Tabify.
- Remove trailing white spaces.
- Fix typo in comment.
 1.53  17-Jun-2014  msaitoh - Fix detection of BGEPHYF_FIBER_{MII|TBI}
- Add BCM5708S support in brgphy(4). The auto negotiation may have some bugs.
- Add 2500SX support (not tested).
- Fix bit definition of BRGPHY_MRBE_MSG_PG5_NP_T2 from FreeBSD.
 1.52  12-Jun-2014  msaitoh No functional change:
- Remove BRGPHY_SERDES_ANAR_* and BRGPHY_SERDES_ANLPAR_*. Those registers
are the same as MII_ANAR_* and MII_ANLPAR_*.
- Fix typo.
- Remove trailing white spaces.
- KNF.
 1.51  29-Mar-2014  christos branches: 1.51.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.50  13-Mar-2014  hannken Add __diagused.
 1.49  13-Sep-2013  martin #ifdef variable declarations/initializations like their use
 1.48  30-Mar-2013  christos branches: 1.48.4;
remove trailing whitespace
 1.47  22-Jul-2012  matt branches: 1.47.2;
Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.
 1.46  06-Mar-2012  bouyer bnx_start() is not MP-safe, so do not create the bnx_alloc_pkts()'s
workqueue MPSAFE. This could lead to bnx_start() being running at
the same time on 2 CPUs, with packets being sent twice.
Problem found and reported by Beverly Schwartz and Greg Troxel.
 1.45  22-Sep-2011  jym branches: 1.45.2; 1.45.6; 1.45.8;
The bnx(4) handler runs at IPL_NET (works with spin mutexes), while
allocations can be deferred to a workqueue(9): set its highest IPL to
IPL_NET and not IPL_NONE, which is protected by an adaptive/sleeping mutex.
 1.44  15-Jul-2011  jym Use a workqueue(9) to defer allocation of TX packets. Loosely inspired
from the OpenBSD bnx(4) driver.

Tested by Roger Pau Monné, roger.pau at entel.upc.edu.

Fixes kern/45051.
 1.43  02-May-2011  jym Fix BCM5709 PHY detection for ethernet PHYs (the SerDes case being already
handled):
- export bge(4) and bnx(4) CHIP ID and PHY flags to brgphy(4). Move to
"unsigned int" rather than "int", and reuse the same softc members for
chipid and phyflags (behavior controlled by the sc_isbge/isbnx boolean).
- apply bug fix for revisions A and B, so that autonegotiation can
complete (from OpenBSD).

Bug reported by Rivo Nurges via private mail, patch tested and
confirmed working by him (with thanks!)
 1.42  26-Jan-2011  dyoung Get out of the interrupt handler early if !IFF_RUNNING.
 1.41  06-Jan-2011  jym branches: 1.41.2; 1.41.4;
bnx(4) SERDES NICs will definitely work better with the PHY initialization
code... rather than without.

(forgot to commit it two weeks ago -- should be part of the BCM 5709S
patch)
 1.40  06-Jan-2011  jym Reflect 5709S support in bnx(4) (comment fix)
 1.39  11-Dec-2010  martin Sanitize names a bit, still could use more namespace cleanup
 1.38  11-Dec-2010  pgoyette Fix a couple of name-space changes that fell through the cracks.

Hello, martin!
 1.37  09-Dec-2010  jym Remove htolexx calls, as bnx(4) NICs are capable of swapping endianess.

The macros for PAGE_SIZE were fixed with the previous patch (if_bnxreg.h
splitting, rev 1.11).

From OpenBSD. Their commit log reads:

bnx(4) is a bit special. The chip itself is capable of swapping endianess
so there is no need for htoleXX calls. The only thing needed is the correct
layout of the DMA-ed structures. Additionally it uses PAGE_SIZE but assumed
that it is always 4k. Fix the macros that failed to respect that so that it
works on 8k PAGE_SIZE systems. This makes bnx(4) work on sparc64.
 1.36  09-Dec-2010  jym Similar to bge(4), split if_bnxreg.h in two parts:
- if_bnxreg.h: general register values, flags... for bnx(4), that can
be included in other drivers
- if_bnxvar.h: PCI or device specific code (device state data, debug
macros etc.), which should remain private to bnx(4)

No comments, no objections on current-users@.

See discussion:
http://mail-index.netbsd.org/current-users/2010/12/01/msg014926.html
 1.35  27-Nov-2010  jym Missing break in switch case. From OpenBSD.
 1.34  26-Nov-2010  dholland Don't test flags with &&. From Henning Petersen in PR 44151.
 1.33  05-Apr-2010  joerg Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.32  11-Mar-2010  msaitoh branches: 1.32.2;
Add missing ifmedia_delete_instance() in bnx_detach().
 1.31  19-Jan-2010  pooka branches: 1.31.2;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.30  20-Nov-2009  bouyer Remove duplicate PCI_PRODUCT_BROADCOM_BCM5709 entries.
BNX_MAX_MRU is now the 1500-bytes MTU; use BNX_MAX_JUMBO_MRU instead.
 1.29  18-Nov-2009  bouyer Sync with OpenBSD: if_bnx.c,v 1.85. Major changes:
Add support for the Broadcom BCM5709 and BCM5716 chips. This upgrade
the B06 firmware, and add the B09 firmware required by the BCM5709.
Remplace TX dmamap array with a dynamically-grown list.

Tested with:
bnx0 at pci4 dev 0 function 0: Broadcom NetXtreme II BCM5708 1000Base-T
and
bnx0 at pci0 dev 0 function 0: Broadcom NetXtreme II BCM5709 1000Base-SX
 1.28  05-Sep-2009  tsutsui Invert logic around nested pmf(9) registrations for readability.
 1.27  05-May-2009  cegger Attach on BCM5709 chip.
XXX Firmware fails to complete initialization on this chip.
 1.26  17-Apr-2009  dyoung Bug fix: don't release the Rx DMA maps twice.
 1.25  07-Apr-2009  dyoung Destroy sc->bnx_timeout in bnx_detach().
 1.24  03-Apr-2009  dyoung Fix SIOCSIFFLAGS. Mark as safe to detach at shutdown.
 1.23  18-Mar-2009  cegger bzero -> memset
 1.22  18-Mar-2009  cegger bcmp -> memcmp
 1.21  27-Jan-2009  dyoung branches: 1.21.2;
Protect against spurious "bnx0: Double mbuf allocation failure!"
panics.

Extract a new function, bnx_add_buf(), from bnx_get_buf().
bnx_add_buf() just tries to add an mbuf to the Rx chain. bnx_get_buf()
tries to allocate an mbuf, first, and then to add the mbuf to the
chain. Use bnx_add_buf() to try to put an mbuf that we took off
of the chain back onto the chain, and use bnx_get_buf() everywhere
else.

This change seems to be in keeping with the author's intent, but
it looks like the code broke at some point.

Thanks to Jarle Greipsland, David Dudley, and others for reporting
this bug and for testing patches.
 1.20  09-Sep-2008  mhitch branches: 1.20.2; 1.20.4; 1.20.10;
Add support for SerDes controllers; from the OpenBSD driver. Tested on a
Dell Blade server by me, and an HP Blade server by Havard.
 1.19  09-Sep-2008  mhitch In bnx_release_resources(), don't de-reference a NULL pointer if the
rx_mbuf_map has not been allocated yet. From Havard Eidnes.
 1.18  07-Feb-2008  dyoung branches: 1.18.6; 1.18.10; 1.18.12; 1.18.16;
Start patching up the kernel so that a network driver always has
the opportunity to handle an ioctl before generic ifioctl handling
occurs. This will ease extending the kernel and sharing of code
between drivers.

First steps: Make the signature of ifioctl_common() match struct
ifinet->if_ioctl. Convert SIOCSIFCAP and SIOCSIFMTU to the new
ifioctl() regime, throughout the kernel.
 1.17  06-Feb-2008  joerg Don't use misaligned PCI config access. Reported by Christoph Egger.
 1.16  31-Dec-2007  dyoung Don't buffer packets while the link is down, but drop them on the
floor like most other ethernet drivers do.

bnx(4) has "vanilla" MII media-handling, so use ether_mediachange
and ether_mediastatus.
 1.15  30-Dec-2007  dyoung For consistency with other softc members, s/ethercom/bnx_ec/.
 1.14  29-Dec-2007  dyoung Get rid of bnx_suspend_resume(), it did redundant resets.

Merge bnx_if_stop() and bnx_stop(). Handle bnx_stop(, 1) by doing
a reset.

Protect the bnx_stop() call in bnx_detach() with splnet().

Thanks to joerg@ for suggesting the above.

In bnx_stop(), deactivate the PHYs with mii_down(). Return right
away if !IFF_RUNNING.

Use LIST_EMPTY().

In bnx_ifmedia_upd(), propagate all mii_mediachg() return codes to
the caller except for ENXIO, which just means that the PHY is
suspended. In bnx_init(), propagate bnx_ifmedia_upd() return codes
to the caller.

In bnx_intr(), replace a common subexpression with a variable,
'sblk'.

In bnx_tick(), let the MII bus keep ticking after the link is up:
check link status and exit after calling mii_tick(), not before.
 1.13  26-Dec-2007  dyoung Add device suspend/resume/detach. (Tested with drvctl -S bnx0,
drvctl -Q bnx0, drvctl -d bnx0.)

Separate device_t storage from softc storage and use CFATTACH_DECL_NEW().
 1.12  15-Dec-2007  perry __FUNCTION__ -> __func__
 1.11  04-Dec-2007  dyoung branches: 1.11.4;
Reprogram multicast filter after SIOCADDMULTI / SIOCDELMULTI.
Fixes IPv6 stateless address configuration problems reported on
tech-net@. Patch tested and found to work by Martti Kuparinen.
 1.10  09-Nov-2007  martti branches: 1.10.2;
Added missing newline.
 1.9  29-Aug-2007  dyoung branches: 1.9.4; 1.9.6;
Constify: LLADDR() -> CLLADDR().
 1.8  09-Aug-2007  bouyer branches: 1.8.2;
Pass the right value to VLAN_INPUT_TAG(), this makes vlan(4) on bnx(4) work.
 1.7  09-Jul-2007  ad branches: 1.7.2; 1.7.6;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.6  10-Apr-2007  bouyer Fix build on 32bit ports; should fix GENERIC_DIAGNOSTIC build problem reported
by Hisashi T Fujinaka on current-users.
 1.5  09-Apr-2007  bouyer RX buffers are malloced memory of 9216 bytes. This can require from 1 to
4 DMA memory segments, depending on how the buffer is in memory.
When receiving a packet, we allocate a new one to remplace the one we've
used. It can need more segments than the one it remplace, leading to
corrution of the RX descriptors, and a panic in bus_dmamap_sync() (DIAGNOSTIC
kernels) or possibly memory corruption.

Fix:
- bnx_get_buf() allocates as many buffer as possible, checking the number
of free RX descriptors. Because one receive buffer is not guaranteed to
be remplaced on receive, call bnx_get_buf() from bnx_tick() too.
This also improve error handling from bnx_get_buf().
- use MCLGET() instead of MEXTMALLOC() if we're running with the standard
ethernet MTU. This gives us more receive buffers and waste less memory.
 1.4  09-Apr-2007  bouyer Protect bnx_tick() with splnet.

Bring in fixes and improvements from OpenBSD:
revision 1.25
- Simplify the arguments to bnx_tx_encap.
- Don't copy the bd_chain head pointers into temporary objects, they are
available globally.

From scottl@FreeBSD

revision 1.26
Overhaul the transmit path:
- Eliminate the bnx_dmamap_arg structure.
- Refactor the loop that fills the buffer descriptor so that it can be done
with a single set of logic in a single loop instead of two sets of logic.
- Eliminate the need to cache and pass descriptor indexes between the start
loop and the encap function.
- Change the start loop to always check the ifnet sendq for more work.

From scottl@FreeBSD

revision 1.27
make the exit label naming scheme match the current function names, removes
a FreeBSD-ism from the original driver.

revision 1.28 -> 1.30
- Ensure that at least 16 TX descriptors are kept unused in the ring.
- Use more complete error handling for TX load problems.

From scottl@FreeBSD

revision 1.31
replace a few more instances of hand rolled code with the LIST_FOREACH macro.

revision 1.33
In bnx_start, check the used_tx_bd count rather than the descriptors
mbuf pointer to see if the transmit ring is full. The mbuf pointer
is set only in the last descriptor of a multi-descriptor packet.
By relying on the mbuf pointers of the earlier descriptors, the
driver would sometimes overwrite a descriptor belonging to a
packet that wasn't completed yet. Also, tx_chain_prod wasn't
updated inside the loop, causing the wrong descriptor to be checked
after the first iteration. The upshot of all this was the loss of
some transmitted packets at medium to high packet rates.

In bnx_tx_encap, remove a couple of old statements that shuffled
around the tx_mbuf_map pointers. These now correspond 1-to-1 with
the transmit descriptors, and they are not supposed to be changed.

Correct a couple of inaccurate comments.

From jdp@FreeBSD

revision 1.43
Allow the bnx(4) driver to make use of all of the available hardware
multicast hash slots. The bnx(4) hardware supports 8 slots instead of
4 like the bge(4) hardware.

From Mike Karels via FreeBSD

Tested by Brad, biorn@ and Johan M:son Lindman
 1.3  04-Mar-2007  christos branches: 1.3.2; 1.3.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.2  15-Feb-2007  bouyer branches: 1.2.2;
Fix 2 panics with DIAGNOSTIC kernels:
- remove the code to bring down the PHY in bnx_stop(), it's wrong
(ifm_data isn't updated) and lead to a panic in mii_phy_setmedia(),
or reading past the end mii_media_table[].
- make sure the dma_map matches the mbuf in the rx structures. We would
sync/unload the wrong map, leading to a DIAGNOSTIC panic, or eventually
leaking memory when bounce buffers are needed.
 1.1  17-Dec-2006  bouyer branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.10;
Add bnx(4), a driver for Broadcom NetXtreme II 10/100/1000 Ethernet device.
Ported from OpenBSD by cube@, with some bus_dma fixes by me.
Tested on i386 and amd64.
 1.1.10.2  12-Jan-2007  ad Sync with head.
 1.1.10.1  17-Dec-2006  ad file if_bnx.c was added on branch newlock2 on 2007-01-12 00:57:41 +0000
 1.1.8.8  11-Feb-2008  yamt sync with head.
 1.1.8.7  21-Jan-2008  yamt sync with head
 1.1.8.6  07-Dec-2007  yamt sync with head
 1.1.8.5  15-Nov-2007  yamt sync with head.
 1.1.8.4  03-Sep-2007  yamt sync with head.
 1.1.8.3  26-Feb-2007  yamt sync with head.
 1.1.8.2  30-Dec-2006  yamt sync with head.
 1.1.8.1  17-Dec-2006  yamt file if_bnx.c was added on branch yamt-lazymbuf on 2006-12-30 20:48:44 +0000
 1.1.6.6  19-Nov-2007  bouyer Pull up following revision(s) (requested by martti in ticket #1876):
sys/dev/pci/if_bnx.c: revision 1.10
Added missing newline.
 1.1.6.5  17-Sep-2007  msaitoh Pull up following revision(s) (requested by bouyer in ticket #1827):
sys/dev/pci/if_bnx.c: revision 1.8
Pass the right value to VLAN_INPUT_TAG(), this makes vlan(4) on bnx(4) work.
 1.1.6.4  25-Apr-2007  ghen Pull up following revision(s) (requested by bouyer in ticket #1762):
sys/dev/pci/if_bnx.c: revision 1.4
sys/dev/pci/if_bnx.c: revision 1.5
sys/dev/pci/if_bnx.c: revision 1.6
sys/dev/pci/if_bnxreg.h: revision 1.2
Protect bnx_tick() with splnet.
Bring in fixes and improvements from OpenBSD:
revision 1.25
- Simplify the arguments to bnx_tx_encap.
- Don't copy the bd_chain head pointers into temporary objects, they are
available globally.
From scottl@FreeBSD
revision 1.26
Overhaul the transmit path:
- Eliminate the bnx_dmamap_arg structure.
- Refactor the loop that fills the buffer descriptor so that it can be done
with a single set of logic in a single loop instead of two sets of logic.
- Eliminate the need to cache and pass descriptor indexes between the start
loop and the encap function.
- Change the start loop to always check the ifnet sendq for more work.
From scottl@FreeBSD
revision 1.27
make the exit label naming scheme match the current function names, removes
a FreeBSD-ism from the original driver.
revision 1.28 -> 1.30
- Ensure that at least 16 TX descriptors are kept unused in the ring.
- Use more complete error handling for TX load problems.
From scottl@FreeBSD
revision 1.31
replace a few more instances of hand rolled code with the LIST_FOREACH macro.
revision 1.33
In bnx_start, check the used_tx_bd count rather than the descriptors
mbuf pointer to see if the transmit ring is full. The mbuf pointer
is set only in the last descriptor of a multi-descriptor packet.
By relying on the mbuf pointers of the earlier descriptors, the
driver would sometimes overwrite a descriptor belonging to a
packet that wasn't completed yet. Also, tx_chain_prod wasn't
updated inside the loop, causing the wrong descriptor to be checked
after the first iteration. The upshot of all this was the loss of
some transmitted packets at medium to high packet rates.
In bnx_tx_encap, remove a couple of old statements that shuffled
around the tx_mbuf_map pointers. These now correspond 1-to-1 with
the transmit descriptors, and they are not supposed to be changed.
Correct a couple of inaccurate comments.
From jdp@FreeBSD
revision 1.43
Allow the bnx(4) driver to make use of all of the available hardware
multicast hash slots. The bnx(4) hardware supports 8 slots instead of
4 like the bge(4) hardware.
From Mike Karels via FreeBSD
Tested by Brad, biorn@ and Johan M:son Lindman
RX buffers are malloced memory of 9216 bytes. This can require from 1 to
4 DMA memory segments, depending on how the buffer is in memory.
When receiving a packet, we allocate a new one to remplace the one we've
used. It can need more segments than the one it remplace, leading to
corrution of the RX descriptors, and a panic in bus_dmamap_sync() (DIAGNOSTIC
kernels) or possibly memory corruption.
Fix:
- bnx_get_buf() allocates as many buffer as possible, checking the number
of free RX descriptors. Because one receive buffer is not guaranteed to
be remplaced on receive, call bnx_get_buf() from bnx_tick() too.
This also improve error handling from bnx_get_buf().
- use MCLGET() instead of MEXTMALLOC() if we're running with the standard
ethernet MTU. This gives us more receive buffers and waste less memory.
Fix build on 32bit ports; should fix GENERIC_DIAGNOSTIC build problem reported
by Hisashi T Fujinaka on current-users.
 1.1.6.3  19-Feb-2007  tron Pull up following revision(s) (requested by bouyer in ticket #1667):
sys/dev/pci/if_bnx.c: revision 1.2
Fix 2 panics with DIAGNOSTIC kernels:
- remove the code to bring down the PHY in bnx_stop(), it's wrong
(ifm_data isn't updated) and lead to a panic in mii_phy_setmedia(),
or reading past the end mii_media_table[].
- make sure the dma_map matches the mbuf in the rx structures. We would
sync/unload the wrong map, leading to a DIAGNOSTIC panic, or eventually
leaking memory when bounce buffers are needed.
 1.1.6.2  23-Dec-2006  ghen Pull up following revision(s) (requested by bouyer in ticket #1608):
sys/arch/i386/conf/INSTALL: revision 1.299 via patch
sys/arch/i386/conf/XEN2_DOM0: revision 1.20 via patch
sys/arch/i386/conf/GENERIC: revision 1.803 via patch
sys/dev/pci/files.pci: revision 1.275 via patch
sys/arch/i386/conf/GENERIC_LAPTOP: revision 1.218 via patch
sys/arch/amd64/conf/GENERIC: revision 1.123 via patch
sys/dev/pci/if_bnx.c: revision 1.1 via patch
share/man/man4/bnx.4: revision 1.1-1.2 via patch
distrib/sets/lists/man/mi: revision 1.959 via patch
sys/arch/amd64/conf/INSTALL: revision 1.62 via patch
sys/dev/microcode/bnx/bnxfw.h: revision 1.1-1.2 via patch
sys/dev/pci/if_bnxreg.h: revision 1.1 via patch
share/man/man4/Makefile: revision 1.417 via patch
sys/arch/i386/conf/INSTALL_LAPTOP: revision 1.112 via patch
Add bnx(4), a driver for Broadcom NetXtreme II 10/100/1000 Ethernet device.
Ported from OpenBSD by cube@, with some bus_dma fixes by me.
Tested on i386 and amd64.
Add a NetBSD RCS tag.
Nx -> Ox; remove trailing whitespace.
 1.1.6.1  17-Dec-2006  ghen file if_bnx.c was added on branch netbsd-3 on 2006-12-23 14:43:47 +0000
 1.1.4.7  01-Feb-2008  riz Pull up following revision(s) (requested by dyoung in ticket #1011):
sys/dev/pci/if_bnx.c: revision 1.11
Reprogram multicast filter after SIOCADDMULTI / SIOCDELMULTI.
Fixes IPv6 stateless address configuration problems reported on
tech-net@. Patch tested and found to work by Martti Kuparinen.
 1.1.4.6  25-Nov-2007  xtraeme Pull up following revision(s) (requested by martti in ticket #986):
sys/dev/pci/if_bnx.c: revision 1.10
Added missing newline.
 1.1.4.5  24-Aug-2007  liamjfoy branches: 1.1.4.5.2;
Pull up following revision(s) (requested by bouyer in ticket #826):
sys/dev/pci/if_bnx.c: revision 1.8
Pass the right value to VLAN_INPUT_TAG(), this makes vlan(4) on bnx(4) work.
 1.1.4.4  20-Apr-2007  pavel branches: 1.1.4.4.2;
Pull up following revision(s) (requested by bouyer in ticket #566):
sys/dev/pci/if_bnx.c: revision 1.4
sys/dev/pci/if_bnx.c: revision 1.5
sys/dev/pci/if_bnx.c: revision 1.6
sys/dev/pci/if_bnxreg.h: revision 1.2
Protect bnx_tick() with splnet.
Bring in fixes and improvements from OpenBSD:
revision 1.25
- Simplify the arguments to bnx_tx_encap.
- Don't copy the bd_chain head pointers into temporary objects, they are
available globally.
From scottl@FreeBSD
revision 1.26
Overhaul the transmit path:
- Eliminate the bnx_dmamap_arg structure.
- Refactor the loop that fills the buffer descriptor so that it can be done
with a single set of logic in a single loop instead of two sets of logic.
- Eliminate the need to cache and pass descriptor indexes between the start
loop and the encap function.
- Change the start loop to always check the ifnet sendq for more work.
From scottl@FreeBSD
revision 1.27
make the exit label naming scheme match the current function names, removes
a FreeBSD-ism from the original driver.
revision 1.28 -> 1.30
- Ensure that at least 16 TX descriptors are kept unused in the ring.
- Use more complete error handling for TX load problems.
From scottl@FreeBSD
revision 1.31
replace a few more instances of hand rolled code with the LIST_FOREACH macro.
revision 1.33
In bnx_start, check the used_tx_bd count rather than the descriptors
mbuf pointer to see if the transmit ring is full. The mbuf pointer
is set only in the last descriptor of a multi-descriptor packet.
By relying on the mbuf pointers of the earlier descriptors, the
driver would sometimes overwrite a descriptor belonging to a
packet that wasn't completed yet. Also, tx_chain_prod wasn't
updated inside the loop, causing the wrong descriptor to be checked
after the first iteration. The upshot of all this was the loss of
some transmitted packets at medium to high packet rates.
In bnx_tx_encap, remove a couple of old statements that shuffled
around the tx_mbuf_map pointers. These now correspond 1-to-1 with
the transmit descriptors, and they are not supposed to be changed.
Correct a couple of inaccurate comments.
From jdp@FreeBSD
revision 1.43
Allow the bnx(4) driver to make use of all of the available hardware
multicast hash slots. The bnx(4) hardware supports 8 slots instead of
4 like the bge(4) hardware.
From Mike Karels via FreeBSD
Tested by Brad, biorn@ and Johan M:son Lindman

RX buffers are malloced memory of 9216 bytes. This can require from 1 to
4 DMA memory segments, depending on how the buffer is in memory.
When receiving a packet, we allocate a new one to remplace the one we've
used. It can need more segments than the one it remplace, leading to
corrution of the RX descriptors, and a panic in bus_dmamap_sync() (DIAGNOSTIC
kernels) or possibly memory corruption.
Fix:
- bnx_get_buf() allocates as many buffer as possible, checking the number
of free RX descriptors. Because one receive buffer is not guaranteed to
be remplaced on receive, call bnx_get_buf() from bnx_tick() too.
This also improve error handling from bnx_get_buf().
- use MCLGET() instead of MEXTMALLOC() if we're running with the standard
ethernet MTU. This gives us more receive buffers and waste less memory.

Fix build on 32bit ports; should fix GENERIC_DIAGNOSTIC build problem reported
by Hisashi T Fujinaka on current-users.
 1.1.4.3  17-Feb-2007  tron Pull up following revision(s) (requested by bouyer in ticket #451):
sys/dev/pci/if_bnx.c: revision 1.2
Fix 2 panics with DIAGNOSTIC kernels:
- remove the code to bring down the PHY in bnx_stop(), it's wrong
(ifm_data isn't updated) and lead to a panic in mii_phy_setmedia(),
or reading past the end mii_media_table[].
- make sure the dma_map matches the mbuf in the rx structures. We would
sync/unload the wrong map, leading to a DIAGNOSTIC panic, or eventually
leaking memory when bounce buffers are needed.
 1.1.4.2  21-Dec-2006  tron Pull up following revision(s) (requested by bouyer in ticket #287):
sys/arch/i386/conf/INSTALL: revision 1.299
sys/arch/i386/conf/XEN2_DOM0: revision 1.20
sys/arch/i386/conf/GENERIC: revision 1.803
sys/dev/pci/files.pci: revision 1.275
sys/arch/i386/conf/GENERIC_LAPTOP: revision 1.218
sys/arch/amd64/conf/GENERIC: revision 1.123
sys/dev/pci/if_bnx.c: revision 1.1
share/man/man4/bnx.4: revision 1.1
distrib/sets/lists/man/mi: revision 1.959
sys/arch/amd64/conf/INSTALL: revision 1.62
sys/dev/microcode/bnx/bnxfw.h: revision 1.1
sys/arch/i386/conf/ALL: revision 1.76
sys/dev/pci/if_bnxreg.h: revision 1.1
share/man/man4/Makefile: revision 1.417
sys/arch/i386/conf/INSTALL_LAPTOP: revision 1.112
Add bnx(4), a driver for Broadcom NetXtreme II 10/100/1000 Ethernet device.
Ported from OpenBSD by cube@, with some bus_dma fixes by me.
Tested on i386 and amd64.
 1.1.4.1  17-Dec-2006  tron file if_bnx.c was added on branch netbsd-4 on 2006-12-21 13:44:01 +0000
 1.1.4.5.2.1  25-Nov-2007  xtraeme Pull up following revision(s) (requested by martti in ticket #986):
sys/dev/pci/if_bnx.c: revision 1.10
Added missing newline.
 1.1.4.4.2.3  03-Jun-2008  skrll Sync with netbsd-4.
 1.1.4.4.2.2  06-Jan-2008  wrstuden Catch up to netbsd-4.0 release.
 1.1.4.4.2.1  03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.1.2.2  18-Dec-2006  yamt sync with head.
 1.1.2.1  17-Dec-2006  yamt file if_bnx.c was added on branch yamt-splraiseipl on 2006-12-18 11:42:13 +0000
 1.2.2.2  15-Apr-2007  yamt sync with head.
 1.2.2.1  12-Mar-2007  rmind Sync with HEAD.
 1.3.4.1  11-Jul-2007  mjf Sync with head.
 1.3.2.4  09-Oct-2007  ad Sync with head.
 1.3.2.3  20-Aug-2007  ad Sync with HEAD.
 1.3.2.2  01-Jul-2007  ad Adapt to callout API change.
 1.3.2.1  10-Apr-2007  ad Sync with head.
 1.7.6.4  09-Dec-2007  jmcneill Sync with HEAD.
 1.7.6.3  11-Nov-2007  joerg Sync with HEAD.
 1.7.6.2  03-Sep-2007  jmcneill Sync with HEAD.
 1.7.6.1  16-Aug-2007  jmcneill Sync with HEAD.
 1.7.2.2  03-Sep-2007  skrll Sync with HEAD.
 1.7.2.1  15-Aug-2007  skrll Sync with HEAD.
 1.8.2.3  23-Mar-2008  matt sync with HEAD
 1.8.2.2  09-Jan-2008  matt sync with HEAD
 1.8.2.1  06-Nov-2007  matt sync with HEAD
 1.9.6.4  18-Feb-2008  mjf Sync with HEAD.
 1.9.6.3  27-Dec-2007  mjf Sync with HEAD.
 1.9.6.2  08-Dec-2007  mjf Sync with HEAD.
 1.9.6.1  19-Nov-2007  mjf Sync with HEAD.
 1.9.4.1  13-Nov-2007  bouyer Sync with HEAD
 1.10.2.2  26-Dec-2007  ad Sync with head.
 1.10.2.1  08-Dec-2007  ad Sync with head.
 1.11.4.1  02-Jan-2008  bouyer Sync with HEAD
 1.18.16.1  19-Oct-2008  haad Sync with HEAD.
 1.18.12.1  24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.18.10.5  11-Aug-2010  yamt sync with head.
 1.18.10.4  11-Mar-2010  yamt sync with head
 1.18.10.3  16-Sep-2009  yamt sync with head
 1.18.10.2  16-May-2009  yamt sync with head
 1.18.10.1  04-May-2009  yamt sync with head.
 1.18.6.1  28-Sep-2008  mjf Sync with HEAD.
 1.20.10.1  21-Apr-2010  matt sync to netbsd-5
 1.20.4.3  09-Nov-2015  sborrill Pull up the following revisions(s) (requested by msaitoh in ticket #1983):
sys/dev/pci/pcidevs: revisions 1.1079, 1.1134, 1.1148-1.1149, 1.1151
sys/dev/pci/pcidevs.h: regen
sys/dev/pci/pcidevs_data.h: regen
sys/dev/pci/if_bge.c: revisions 1.183-1.185, 1.187, 1.189-1.193, 1.195-1.199, 1.202-1.226, 1.228-1.237, 1.240-1.264, 1.267-1.276, 1.278-1.280, 1.283-1.287 via patch
sys/dev/pci/if_bgereg.h: revisions 1.57-1.74, 1.76-1.90 via patch
sys/dev/pci/if_bgevar.h: revisions 1.6, 1.10-1.13, 1.15-1.17 via patch
sys/dev/pci/if_bnx.c: revisions 1.32, 1.34-1.43, 1.48-1.49, 1.52
sys/dev/pci/if_bnxreg.h: revisions 1.8, 1.11-1.14
sys/dev/pci/if_bnxvar.h: revisions 1.1-1.3
sys/dev/mii/brgphy.c: revisions 1.53-1.63, 1.65-69, 1.72-1.74 via patch
sys/dev/mii/brgphyreg.h: revisions 1.5-1.8
sys/dev/mii/miivar.h: revisions 1.61
sys/dev/pci/pcireg.h: patch

Sync bge(4) up to if_bge.c rev. 1.287. Sync brgphy(4) up to 1.74.
Fix some bugs on bnx(4).

Common:
- Add device IDs for Broadcom BCM57710, BCM57711(E), BCM57712(E) and
BCM57766 (pcidevs only).
- Fix BCM5709 PHY detection.
- Fix detection of BGEPHYF_FIBER_{MII|TBI}
- Add BCM5708S support in brgphy(4).
- Don't use the WIRESPEED function for fiber devices.
bge(4):
- Add some Fujitsu's device support from Michael Moll.
- Add BCM57762 support (PR#46961 from Ryo Onodera).
- Add Altima AC1003, APPLE BCM5701, Broadcom BCM5785F. BCM5785G,
BCM5787F, BCM5719, BCM5720, BCM57766, BCM57782 and BCM57786.
- Fix DMA setting for read/write on conventional PCI bus devices.
This bug was added in rev. 1.166.
- Fix printing "discarding oversize frame (len=-4)" message and
crash by NULL pointer dereferencing.
- The BCM5785 is a PCIe chip but does not report PCIe capabilities.
Check for this chip explicitely and enable PCIe. Fixes
'firmware handshake timeout'.
- Allow disabling interrupt mitigation.
- Workaround for BCM5906 silicon bug. When auto-negotiation results
in half-duplex operation, excess collision on the ethernet link may
cause internal chip delays that may result in subsequent valid
frames being dropped due to insufficient receive buffer resources.
(FreeBSD: r214219, r214251, r214292).
- Allow write DMA to request larger DMA burst size to get better
performance on BCM5785. (FreeBSD r213333: OpenBSD 1.294)
- Enable TX MAC state machine lockup fix for both BCM5755 or higher
and BCM5906. Publicly available data sheet just says it may happen
due to corrupted TxMbuf. (FreeBSD r214216)
- Follow Broadcom datasheet:
Delay 100 microseconds after enabling transmit MAC.
Delay 10 microseconds after enabling receive MAC. (FreeBSD
r241220)
- Insert the completion barrier between register write and the
consecutive delay(). It will fix some device timeout problems we have
seen before.
- Add DELAY(40) after turning on write DMA state machine.
- Add some workarounds for 5717 A0 and 5776[56] to be stable.
- Check BGE_RXBDFLAG_IPV6 flag for 5717_PLUS case. Note that
{tcp,udp}6csum flag is currently not added in the capability.
- Add delay after clearing BGE_MACMODE_TBI_SEND_CFGS for the link
checking.
- Do not touch the jumbo replenish threshold register on chips that do
not have jumbo support.
- Wait for the bootcode to complete initialization for 5717 and newer
devices.
- 5718 and 57785 document say we should wait 100us in init.
- Fix a bug that chips which have BCM5906 ASIC touch GPIO wrongly.
- Fix the setting of Tx Random Backoff Register.
- Check the hardware config words and print them.
- Set BGE_MISC_CTL's byte/word swap options before using
bge_readmem_ind(). Fixes PR#47716.
- For BGE_IS_575X_PLUS() devices, don't set
BGE_RXLPSTATCONTROL_DACK_FIX bits because these bits are reserved.
- Document says 5717 and newer chips have no
BGE_PCISTATE_INTR_NOT_ACTIVE bit, so don't use the bit on those
chips. Same as OpenBSD.
- Fix a bug that the PHY address bits in MI_MODE register is wrongly
cleard. Set the PHY address correctly.
- Use BGE_SETBIT() instead of CSR_WRITE_4() for the BGE_MISC_LOCAL_CTL
register to not to modify some GPIO bits.
- Set DMA watermark depend on the PCI max payload size.
- Set BGE_JUMBO_CAPABLE correctly.
- Fix a link detect bug on non-autopoll systems.
- Change the TX ring size for 5717 series and 57764 series.
- Set maximum read byte count to 2048 for PCI-X BCM5703/5704 devices.
- For PCI-X BCM5704, set maximum outstanding split transactions to 0.
- Add 40bit DMA bug workaround(BGEF_40BIT_BUG) from FreeBSD.
This workaround is for 5714/5715 controllers and is not actually a
MAC controller bug but an issue with the embedded PCIe to PCI-X
bridge in the device. This change uses bus_dmatag_subregion(),
so this workaround won't work on some archs which doesn't support
bus_dmatag_subregion().
- Add 2500SX support (not tested).
- Don't use the PHY Auto Poll Mode on many chips. This fixes a bug
that MII Fiber NIC drop packet about 50%. Tested on HP Moonshot.
- Add workaround for PR#48451. Some BCM5717-5720 based systems getNMI
on boot. This problem doesn't occur when we don't use prefetchable
memory in the APE area. Tested with HP MicroServer Gen8.
- In the BCM5703, the DMA read watermark should be set to less than
or equal to the maximum memory read byte count of the PCI-X command
register.
- Fix a bug that BGE_PHY_TEST_CTRL_REG isn't set correctly on some
PCIe devices.
- Use another firmware command in bge_asf_driver_up(). Same as Linux.
This change fixes a bug that watchdog timeout occurs every 25-30
minutes on HP ML110 G6 reported enami@ in PR#49657.
- Fix mbuf leak on failure.
- Remove PCI_PRODUCT_BROADCOM_BCM5724 and
PCI_PRODUCT_BROADCOM_BCM5750M. These devices have not released to
public.
- Add some workaround code for BGE_ASICREV_BCM5784 from Linux.
- Change some printf() to aprint_*().
- Fix typo in comments.
- Cleanup.
brgphy(4):
- Fix bit definition of BRGPHY_MRBE_MSG_PG5_NP_T2 from FreeBSD.
- Add BCM5481, BCM5709S, BCM5756, BCM5717C, BCM5720C, BCM5785,
BCM57765(PR#46961), BCM57780
- In brgphyattach(), set sc_isbge, sc_isbnx and sc_phyflags before
PHY_RESET() because brgphy_reset() refers those flags.
- Call brgpy specific autonego function in MII_TICK. Before this
commit, only MII_MEDIACHG calls brgphy_mii_phy_auto() and MII_TICK
calls MI mii_phy_auto(). That was not intended.
- Remove extra delay in brgphy_mii_phy_auto. Same as {Free,Open}BSD.
bnx(4):
- Add missing ifmedia_delete_instance() in bnx_detach().
- Fix a bug that BNX_NO_WOL_FLAG isn't correctly set on some chips.
Reported by From Henning Petersen in PR#44151.
- Fix SERDES initialization.
- Get out of the interrupt handler early if !IFF_RUNNING.
 1.20.4.2  27-Jan-2010  sborrill Pull up the following revisions(s) (requested by bouyer in ticket #1268):
sys/dev/mii/miidevs: revision 1.90
sys/dev/pci/pcidevs: revision 1.1001
sys/dev/mii/brgphy.c: revision 1.51
sys/dev/microcode/bnx/bnxfw.h: revision 1.3
sys/dev/pci/if_bnx.c: revision 1.29
sys/dev/pci/if_bnxreg.h: revision 1.9
sys/dev/pci/if_bnx.c: revision 1.30

Add support for the Broadcom BCM5709 and BCM5716 chips. Upgrade
the B06 firmware and add the B09 firmware required by the BCM5709.
Replace TX dmamap array with a dynamically-grown list.
Support associated BCM5709CAX and BCM5709C PHYs.
 1.20.4.1  18-May-2009  bouyer Pull up following revision(s) (requested by kefren in ticket #760):
sys/dev/pci/if_bnx.c: revision 1.21
Protect against spurious "bnx0: Double mbuf allocation failure!"
panics.
Extract a new function, bnx_add_buf(), from bnx_get_buf().
bnx_add_buf() just tries to add an mbuf to the Rx chain. bnx_get_buf()
tries to allocate an mbuf, first, and then to add the mbuf to the
chain. Use bnx_add_buf() to try to put an mbuf that we took off
of the chain back onto the chain, and use bnx_get_buf() everywhere
else.
This change seems to be in keeping with the author's intent, but
it looks like the code broke at some point.
Thanks to Jarle Greipsland, David Dudley, and others for reporting
this bug and for testing patches.
 1.20.2.2  28-Apr-2009  skrll Sync with HEAD.
 1.20.2.1  03-Mar-2009  skrll Sync with HEAD.
 1.21.2.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.31.2.1  30-Apr-2010  uebayasi Sync with HEAD.
 1.32.2.3  31-May-2011  rmind sync with head
 1.32.2.2  05-Mar-2011  rmind sync with head
 1.32.2.1  30-May-2010  rmind sync with head
 1.41.4.1  08-Feb-2011  bouyer Sync with HEAD
 1.41.2.1  06-Jun-2011  jruoho Sync with HEAD.
 1.45.8.2  07-Dec-2014  martin Pull up the following, requested by msaitoh in #1207:

sys/dev/mii/brgphy.c 1.69, 1.71-1.76 via patch
sys/dev/mii/brgphyreg.h 1.6-1.7, 1.9
sys/dev/pci/if_bge.c 1.259,1.267-1.276 via patch
sys/dev/pci/if_bgereg.h 1.87-1.88
sys/dev/pci/if_bnx.c 1.48, 1.49, 1.52-1.57 via patch
sys/dev/pci/if_bnxreg.h 1.15-1.18
sys/dev/pci/if_bnxvar.h 1.4-1.6

Changes for bge(4), bnx(4) and brgphy(4):
- Add device IDs for Broadcom BCM57710, BCM57711(E), BCM57712(E) and
BCM5719 into pcidevs.
- Change BCM5720's device ID from 0x1658 to 0x165f. 0x1658 is only for
the pre-product and not released to public.
- Fix detection of BGEPHYF_FIBER_{MII|TBI}
- Fix typo in comment.
- KNF
- brgphy(4):
- Add BCM5708S support.
- Add 2500SX support.
- Fix bit definition of BRGPHY_MRBE_MSG_PG5_NP_T2 from FreeBSD.
- Remove extra delay in brgphy_mii_phy_auto. Same as {Free,Open}BSD.
- Fix media detect on some Fiber chips.
- Add BCM5706.
- bge(4):
- Print yet another hardware config word in SRAM(BGE_SRAM_DATA_CFG_5)
for BCM5717 and newer devices.
- Fix a trivial bug in #ifdef NOTYET.
- Add BGEPHYF_NO_WIRESPEED flag for fiber devices.
- Print APE firmware correctly.
- Don't use the PHY Auto Poll Mode on many chips. This fixes a bug
that MII Fiber NIC drop packets about 50%. Same as {Free,Open}BSD.
Tested on HP Moonshot.
- Add workaround for PR#48451. Some BCM5717-5720 based systems get
NMI on boot. This problem doesn't occur when we don't use
prefetchable memory in the APE area. I don't know the reason...
Tested with HP MicroServer Gen8.
- Fix a bug that bge can't be initialized correctly on some sparc64
systems (PR#49018).
- Change initializaton order as the same as the document, Linux tg3
and FreeBSD (part of r241436).
- In the BCM5703, the DMA read watermark should be set to less than
or equal to the maximum memory read byte count of the PCI-X command
register. Same as FreeBSD r204978 and Linux tg3 driver.
- bnx(4):
- Enclose #ifdef BNX_DEBUG correctly.
- Add 2500SX support.
- Print some information (ASCI revision, PCI status, etc).
From FreeBSD.
 1.45.8.1  07-Mar-2012  riz Pull up following revision(s) (requested by bouyer in ticket #100):
sys/dev/pci/if_bnx.c: revision 1.46
bnx_start() is not MP-safe, so do not create the bnx_alloc_pkts()'s
workqueue MPSAFE. This could lead to bnx_start() being running at
the same time on 2 CPUs, with packets being sent twice.
Problem found and reported by Beverly Schwartz and Greg Troxel.
 1.45.6.1  11-Mar-2012  mrg sync to latest -current
 1.45.2.3  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.45.2.2  30-Oct-2012  yamt sync with head
 1.45.2.1  17-Apr-2012  yamt sync with head
 1.47.2.3  03-Dec-2017  jdolecek update from HEAD
 1.47.2.2  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.47.2.1  23-Jun-2013  tls resync from head
 1.48.4.1  18-May-2014  rmind sync with head
 1.51.2.1  10-Aug-2014  tls Rebase.
 1.57.4.3  05-Feb-2017  skrll Sync with HEAD
 1.57.4.2  09-Jul-2016  skrll Sync with HEAD
 1.57.4.1  19-Mar-2016  skrll Sync with HEAD
 1.59.2.1  07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.61.8.3  13-May-2019  martin Pull up the following, via patch, requested by msaitoh in ticket #1263:

sys/dev/mii/brgphy.c 1.84
sys/dev/mii/ciphy.c 1.33 via patch
sys/dev/mii/rgephy.c 1.53
sys/arch/arm/imx/if_enet.c 1.18
sys/arch/mips/adm5120/dev/if_admsw.c 1.19-1.20
sys/dev/pci/if_bge.c 1.329
sys/dev/pci/if_bnx.c 1.81
sys/dev/pci/if_et.c 1.21
sys/dev/pci/if_lii.c 1.22
sys/dev/pci/if_msk.c 1.87
sys/dev/pci/if_nfe.c 1.68
sys/dev/pci/if_sk.c 1.95
sys/dev/pci/if_ti.c 1.107
sys/dev/pci/if_txp.c 1.52
sys/dev/pci/if_vge.c 1.69
sys/dev/usb/if_axen.c 1.38
sys/dev/usb/if_aue.c 1.149

Fix a bug that the duplex of manual media setting may be wrong
when the IFM_GMASK bit other than IFM_[FH]DX is set.
 1.61.8.2  09-May-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #814):

sys/dev/pci/if_bnxvar.h: revision 1.7
sys/dev/pci/if_bnx.c: revision 1.64

- Fix a bug that bnx(4) panics on shutdown. Stop callout before restroy.
Reported by Andreas Gustafsson in PR#53265.
- Make sure not to re-arm the callout when we are about to detach. Same as
if_bge.c rev. 1.292.
- Use pci_intr_establish_xname().
 1.61.8.1  24-Oct-2017  snj Pull up following revision(s) (requested by knakahara in ticket #302):
sys/arch/powerpc/booke/dev/pq3etsec.c: 1.30-1.31
sys/arch/x86/pci/if_vmx.c: 1.20
sys/dev/ic/i82557.c: 1.148
sys/dev/ic/rtl8169.c: 1.152
sys/dev/pci/cxgb/cxgb_sge.c: 1.5
sys/dev/pci/if_age.c: 1.51
sys/dev/pci/if_alc.c: 1.25
sys/dev/pci/if_ale.c: 1.23
sys/dev/pci/if_bge.c: 1.311
sys/dev/pci/if_bge.c: 1.312
sys/dev/pci/if_bnx.c: 1.62
sys/dev/pci/if_jme.c: 1.32
sys/dev/pci/if_nfe.c: 1.64
sys/dev/pci/if_sip.c: 1.167
sys/dev/pci/if_stge.c: 1.63-1.64
sys/dev/pci/if_ti.c: 1.102
sys/dev/pci/if_txp.c: 1.48
sys/dev/pci/if_vge.c: 1.61
sys/dev/pci/if_wm.c: 1.538
sys/dev/pci/ixgbe/ix_txrx.c: 1.29 via patch
sys/net/agr/if_agrether_hash.c: 1.4
sys/net/if_ether.h: 1.67-1.68
sys/net/if_ethersubr.c: 1.244
sys/net/if_vlan.c: 1.100
sys/net80211/ieee80211_input.c: 1.89
sys/net80211/ieee80211_output.c: 1.59
sys/sys/mbuf.h: 1.171
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.
I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html
--
only get vtag when we have vtag like the other drivers.
--
- only get the vtag if we have it like the other drivers
- mask the hardware vlan tag
--
- add a constant for the vlan mask.
- enforce that we have a tag before we get it.
only get vtag when we have vtag like the other drivers.
like if_bge.c:1.312 and if_stge.c:1.64.
fixed by s-yamaguchi@IIJ, thanks.
 1.63.2.4  26-Jan-2019  pgoyette Sync with HEAD
 1.63.2.3  18-Jan-2019  pgoyette Synch with HEAD
 1.63.2.2  28-Jul-2018  pgoyette Sync with HEAD
 1.63.2.1  21-May-2018  pgoyette Sync with HEAD
 1.65.2.3  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.65.2.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.65.2.1  10-Jun-2019  christos Sync with HEAD
 1.89.2.1  29-Feb-2020  ad Sync with head.
 1.105.2.1  03-Apr-2021  thorpej Sync with HEAD.

RSS XML Feed