Commit Graph

44 Commits

Author SHA1 Message Date
jym 941517f6e2 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.
2011-07-15 11:29:31 +00:00
jym a30b258c9c 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!)
2011-05-02 09:03:10 +00:00
dyoung e664fe9f2c Get out of the interrupt handler early if !IFF_RUNNING. 2011-01-26 00:09:27 +00:00
jym 6da35ef6e8 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)
2011-01-06 03:37:55 +00:00
jym 53a9d61cb0 Reflect 5709S support in bnx(4) (comment fix) 2011-01-06 02:02:43 +00:00
martin 6251718992 Sanitize names a bit, still could use more namespace cleanup 2010-12-11 14:28:38 +00:00
pgoyette 3670e11cda Fix a couple of name-space changes that fell through the cracks.
Hello, martin!
2010-12-11 14:19:29 +00:00
jym 19179df1ef 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.
2010-12-09 23:14:06 +00:00
jym 92c8678b42 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
2010-12-09 22:34:37 +00:00
jym e8fab53aa6 Missing break in switch case. From OpenBSD. 2010-11-27 17:48:58 +00:00
dholland 71d00f92fa Don't test flags with &&. From Henning Petersen in PR 44151. 2010-11-26 21:59:49 +00:00
joerg 58e867556f 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.
2010-04-05 07:19:28 +00:00
msaitoh ff15f2a4f8 Add missing ifmedia_delete_instance() in bnx_detach(). 2010-03-11 04:55:04 +00:00
pooka 10fe49d72c 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.
2010-01-19 22:06:18 +00:00
bouyer 7f7593a68d Remove duplicate PCI_PRODUCT_BROADCOM_BCM5709 entries.
BNX_MAX_MRU is now the 1500-bytes MTU; use BNX_MAX_JUMBO_MRU instead.
2009-11-20 18:24:29 +00:00
bouyer 1f4d2fce07 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
2009-11-18 23:11:16 +00:00
tsutsui 64cbab9fdb Invert logic around nested pmf(9) registrations for readability. 2009-09-05 14:09:55 +00:00
cegger 73af259591 Attach on BCM5709 chip.
XXX Firmware fails to complete initialization on this chip.
2009-05-05 10:21:22 +00:00
dyoung 2e016b467d Bug fix: don't release the Rx DMA maps twice. 2009-04-17 23:23:23 +00:00
dyoung f26cbc49c7 Destroy sc->bnx_timeout in bnx_detach(). 2009-04-07 18:07:10 +00:00
dyoung 8f20e30696 Fix SIOCSIFFLAGS. Mark as safe to detach at shutdown. 2009-04-03 00:14:42 +00:00
cegger c363a9cb62 bzero -> memset 2009-03-18 16:00:08 +00:00
cegger 35fb64746b bcmp -> memcmp 2009-03-18 15:14:29 +00:00
dyoung 6ebb93d58e 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.
2009-01-27 21:15:38 +00:00
mhitch 70a12d51ab Add support for SerDes controllers; from the OpenBSD driver. Tested on a
Dell Blade server by me, and an HP Blade server by Havard.
2008-09-09 20:12:18 +00:00
mhitch 2478b16894 In bnx_release_resources(), don't de-reference a NULL pointer if the
rx_mbuf_map has not been allocated yet.  From Havard Eidnes.
2008-09-09 17:34:10 +00:00
dyoung 2ccede0a9c 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.
2008-02-07 01:21:52 +00:00
joerg 577c689497 Don't use misaligned PCI config access. Reported by Christoph Egger. 2008-02-06 16:50:38 +00:00
dyoung 73a1d6fbf5 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.
2007-12-31 22:52:14 +00:00
dyoung 7be7d500af For consistency with other softc members, s/ethercom/bnx_ec/. 2007-12-30 00:56:45 +00:00
dyoung 66c8374872 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.
2007-12-29 19:51:38 +00:00
dyoung d2a6fcd7d7 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().
2007-12-26 04:06:29 +00:00
perry 9b2b412c19 __FUNCTION__ -> __func__ 2007-12-15 00:39:14 +00:00
dyoung 2fae21685a 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.
2007-12-04 09:22:05 +00:00
martti a43b234985 Added missing newline. 2007-11-09 08:26:47 +00:00
dyoung f59a11881a Constify: LLADDR() -> CLLADDR(). 2007-08-29 22:33:42 +00:00
bouyer 67f8e5f5ce Pass the right value to VLAN_INPUT_TAG(), this makes vlan(4) on bnx(4) work. 2007-08-09 18:10:20 +00:00
ad 88ab7da936 Merge some of the less invasive changes from the vmlocking branch:
- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
2007-07-09 20:51:58 +00:00
bouyer 1fde203078 Fix build on 32bit ports; should fix GENERIC_DIAGNOSTIC build problem reported
by Hisashi T Fujinaka on current-users.
2007-04-10 12:18:26 +00:00
bouyer 0c0eb2bdf5 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.
2007-04-09 19:34:50 +00:00
bouyer a17f6ef0b7 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
2007-04-09 14:23:03 +00:00
christos 53524e44ef Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
bouyer c2d281f97e 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.
2007-02-15 19:24:47 +00:00
bouyer ea4f35dcd0 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.
2006-12-17 23:02:06 +00:00