Commit Graph

321 Commits

Author SHA1 Message Date
Pyun YongHyeon
d4f5240abd Add more checks for resolved link speed in bge_miibus_statchg().
Link UP state could be reported first before actual completion of
auto-negotiation. This change makes bge(4) reprogram BGE_MAC_MODE,
BGE_TX_MODE and BGE_RX_MODE register only after controller got a
valid link.
2010-10-13 21:53:37 +00:00
Pyun YongHyeon
a4431eba57 Protect bge(4) from accessing invalid NIC internal memory regions
on BCM5906.

Tested by:	Buganini < buganini <> gmail dot com >
2010-10-12 19:31:25 +00:00
Pyun YongHyeon
5e2f96bf69 Fix a regression introduced in r213495. r213495 disabled mini
receive producer ring only for BCM5700. It was believed that
BCM5700 with external SSRAM is the only controller that supports
mini ring but it seems all BCM570[0-4] requires to disable mini
receive producer ring. Otherwise, it caused unexpected RX DMA
error or watchdog timeouts.

Reported by:	marius, Steve Kargl <sgk <> troutmask dot apl dot washington dot edu>
Tested by:	marius, Steve Kargl <sgk <> troutmask dot apl dot washington dot edu>
2010-10-12 19:22:03 +00:00
Pyun YongHyeon
66151edf96 The IFF_DRV_RUNNING flag is set at the end of bge_init_locked. But
before setting the flag, interrupt was already enabled such that
interrupt handler could be run before setting IFF_DRV_RUNNING flag.
This can lose initial link state change interrupt which in turn
make bge(4) think that it still does not have valid link. Fix this
race by protecting the taskqueue with a driver lock.
While I'm here move reenabling interrupt code after handling of link
state chage.

Reviewed by:	davidch
2010-10-11 23:07:12 +00:00
Pyun YongHyeon
6ede2cfa12 Remove one last reference of BGE_MI_MODE register for auto polling.
Previously bge(4) always enabled auto polling for non-BGE_FLAG_TBI
controllers. With this change, auto polling is not used anymore so
polling through mii(4) was introduced.

Reviewed by:	davidch
2010-10-11 22:56:23 +00:00
Pyun YongHyeon
3a429c8f0e Do not blindly UP the interface when interface's MTU is changed. If
driver is not running there is no need to up the interface. While
I'm here hold driver lock before modifying MTU as it is referenced
in RX handler.
2010-10-08 17:58:07 +00:00
Pyun YongHyeon
84ac96f8ab Fix a long standing bug which regarded some revisions of controller
as 5788. This caused BGE_MISC_LOCAL_CTL register is used to
generate link state change interrupt for non-5788 controllers. The
interrupt handler may or may not detect link state attention as
status block wouldn't be updated when an interrupt was generated
with BGE_MISC_LOCAL_CTL register. All controllers except 5700 and
5788 should use host coalescing mode register to trigger an
interrupt.
2010-10-07 17:14:50 +00:00
Pyun YongHyeon
8a315a6de4 Add more comments to rings supported by the controller. Different
versions of controller support different number of ring control
blocks such that adjust code a bit to access known number of
send/receive ring control blocks. Previously bge(4) blindly
accessed 16 send/receive RCBs. Also move initializing standard
receive producer ring producer index, jumbo receive producer ring
producer index and mini receive producer ring producer index to
the end of each receive producer ring initialization.

Do not assume mini receive producer ring is available only when
controller has jumbo frame capability, instead explicitly check
ASIC version BCM5700 to disable mini receive producer ring.

Additionally always enable send ring 0 regardless of controller
versions. Previously bge(4) didn't enable send ring 0 if controller
is BGE_IS_5705_PLUS. Becase bge(4) need 1 send ring to send frames
at least, I have no idea how it would have worked so far.

Submitted by:	davidch
2010-10-06 21:23:57 +00:00
Pyun YongHyeon
a813ed787f Overhaul MII register access routine and remove unnecessary
BGE_MI_MODE register accesses. Previously bge(4) used to read
BGE_MI_MODE register to detect whether it needs to disable
autopolling feature or not. Because we don't touch autopolling in
other part of driver there is no reason to read BGE_MI_MODE
register given that we know default value in advance. In order to
achieve the goal, check whether the controller has CPMU(Central
Power Mangement Unit) capability. If controller has CPMU feature,
use 500KHz MII management interface(mdio/mdc) frequency regardless
core clock frequency. Otherwise use default MII clock. While I'm
here, add CPMU register definition.

In bge_miibus_readreg(), rearrange code a bit and remove goto
statement. In bge_miibus_writereg(), make sure to restore
autopolling even if MII write failed. The delay time inserted after
accessing BGE_MI_MODE register increased from 40us to 80us.

The default PHY address is now stored in softc. All PHYs supported
by bge(4) currently uses PHY address 1 but it will be changed when
we add newer controllers. This change will make it easier to change
default PHY address depending on PHY models.

Submitted by:	davidch
2010-10-06 17:35:27 +00:00
Pyun YongHyeon
7d3d9608d1 Fix bge(4) build breakage when BGE_REGISTER_DEBUG is defined. 2010-10-06 01:23:40 +00:00
Pyun YongHyeon
eea8956a5b Rearrange code a bit to correctly set PHY flags. This change make
it easy to add more newer ASICs.

Obtained from:	OpenBSD
2010-10-05 23:24:58 +00:00
Pyun YongHyeon
757402fba0 Separate common flags into controller specific and PHY related
flags. There should be no functional changes. This change will make
it easy to add more quirk/flags in future.

Reviewed by:	davidch
2010-10-05 23:03:48 +00:00
Pyun YongHyeon
d255f2a9df Enable fix for read DMA FIFO overruns on controllers that have this
fix. Note, we still need workaround for controllers that lacks this
fix and it needs more work in RX BD updating.

Submitted by:	davidch
2010-10-04 18:09:01 +00:00
Pyun YongHyeon
1cd4773b5d Consistently use ifHCOutOctets/ifHCInOctets instead of Octets as
these names are used in data sheet. Also use UnicastPkts,
MulticastPkts and BroadcastPkts instead of UcastPkts, McastPkts
and BcastPkts to clarify its meaning.

Suggested by:	bde
2010-10-04 18:01:23 +00:00
Pyun YongHyeon
1888f3246c Remove extra semicolon. 2010-10-01 17:51:55 +00:00
Pyun YongHyeon
7aa4b937e0 Allow write DMA to request larger DMA burst size to get better
performance on BCM5785.

Obtained from:	OpenBSD
2010-10-01 17:46:15 +00:00
Pyun YongHyeon
d8b57f98ab Fix IFCAP_TXCSUM/IFCAP_RXCSUM handling. Previously bge(4) used
IFCAP_HWCSUM to know which capability should be changed such that
disabling RX checksun offloading resulted in disabling TX checksum
offloading.
2010-09-30 22:34:15 +00:00
Pyun YongHyeon
2280c16b56 Implement hardware MAC statistics for BCM5705 or newer Broadcom
controllers. bge(4) exported MAC statistics on controllers that
maintain the statistics in the NIC's internal memory. Newer
controllers require register access to fetch these values. These
counters provide useful information to diagnose driver issues.
2010-09-29 21:56:31 +00:00
Pyun YongHyeon
6854be25a8 After r207391, brgphy(4) passes resolved flow-control settings to
parent driver. Use that information to configure flow-control.
One drawback is there is no way to disable flow-control as we still
don't have proper way to not advertise RX/TX pause capability to
link partner. But I don't think it would cause severe problems and
users can selectively disable flow-control in switch port.
2010-09-29 21:19:25 +00:00
Pyun YongHyeon
dedcdf574b Set the number of RX frames to receive after RX MBUF low watermark
has reached. This reduced number of dropped frames when
flow-control is enabled. Previously it dropped incoming frames once
RX MBUF low watermark has reached. The value used in MAC RX MBUF
low watermark is greater than or equal to 4 so receiving two more
RX frames should not be a problem.

Obtained from:	OpenBSD
2010-09-29 00:00:45 +00:00
Pyun YongHyeon
1432824670 Always show asic/chip revision in device attach phase. There are
too many bge(4) controllers there and model name does not
necessarily match asic/chip revision. Relying on VPD string made
it hard to identify exact asic/chip revision so the first step to
debug bge(4) was getting exact asic/chip information with verbose
boot which may not be available on production server.
2010-09-23 18:55:54 +00:00
Pyun YongHyeon
767c3593eb Fix incorrect RX BD producer updates. The producer index was
already updated after allocating mbuf so driver had to use the last
index instead of using next producer index. This should fix driver
hang which may happen under high network load.

Reported by:	Igor Sysoev <is <> rambler-co dot ru>, Vlad Galu <dudu <> dudu dot ro>
Tested by:	Igor Sysoev <is <> rambler-co dot ru>, Vlad Galu <dudu <> dudu dot ro>
MFC after:	10 days
2010-09-16 17:32:37 +00:00
Pyun YongHyeon
12c65daeaf Make sure to create DMA'able memory for statistics block. This was
missed in r212061 and it caused crashes for 570x controllers as
controller DMAed statistics to physical address 0.

Reported by:	kan
2010-09-07 18:29:29 +00:00
Pyun YongHyeon
175f87424f Remove unnecessary atomic operation in bge_poll. bge(4) always
holds a driver lock in the function entry and
memory synchronization is handled by bus_dmamap_sync(9).
2010-08-31 20:56:18 +00:00
Pyun YongHyeon
95a0a340f4 bge_txeof() already checks whether it has to free transmitted mbufs
or not by comparing reported TX consumer index with saved index. So
remove unnecessary check done after freeing transmitted mbufs.
While I'm here nuke unnecessary variable initializations.
2010-08-31 19:59:18 +00:00
Pyun YongHyeon
38cc61518b Handle PAE case correctly. You cannot effectively specify a 4GB
boundary in PAE case so use a 2GB boundary for PAE as suggested by
jhb.

Pointed out by:	jhb
Reviewed by:	jhb
2010-08-31 18:48:09 +00:00
Pyun YongHyeon
5b610048ec Split common parent DMA tag into ring DMA tag and TX/RX mbuf DMA
tag. All controllers that are not BCM5755 or higher have 4GB
boundary DMA bug. Previously bge(4) used 32bit DMA address to
workaround the bug(r199670). However this caused the use of bounce
buffers such that it resulted in poor performance for systems which
have more than 4GB memory. Because bus_dma(9) honors boundary
restriction requirement of DMA tag for dynamic buffers, having a
separate TX/RX mbuf DMA tag will greatly reduce the possibility of
using bounce buffers. For DMA buffers allocated with
bus_dmamem_alloc(9), now bge(4) explicitly checks whether the
requested memory region crossed the boundary or not.
With this change, only the DMA buffer that crossed the boundary
will use 32bit DMA address. Other DMA buffers are not affected as
separate DMA tag is created for each DMA buffer.
Even if 32bit DMA address space is used for a buffer, the chance to
use bounce buffer is still very low as the size of buffer is small.
This change should eliminate most usage of bounce buffers on
systems that have more than 4GB memory.

More correct fix would be teaching bus_dma(9) to honor boundary
restriction for buffers created with bus_dmamem_alloc(9) but it
seems that is not easy.

While I'm here cleanup bge_dma_map_addr() and remove unnecessary
member variables in bge_dmamap_arg structure.

Tested by:	marcel
2010-08-31 17:33:48 +00:00
Pyun YongHyeon
35f945cd62 It seems all Broadcom controllers have a bug that can generate UDP
datagrams with checksum value 0 when TX UDP checksum offloading is
enabled.  Generating UDP checksum value 0 is RFC 768 violation.
Even though the probability of generating such UDP datagrams is
low, I don't want to see FreeBSD boxes to inject such datagrams
into network so disable UDP checksum offloading by default.  Users
still override this behavior by setting a sysctl variable or loader
tunable, dev.bge.%d.forced_udpcsum.

I have no idea why this issue was not reported so far given that
bge(4) is one of the most commonly used controller on high-end
server class systems. Thanks to andre@ who passed the PR to me.

PR:	kern/104826
2010-08-22 01:39:09 +00:00
Pyun YongHyeon
7e32f79a44 Load tunable from loader.conf(5) instead of device.hints(5). 2010-08-21 23:13:16 +00:00
Pyun YongHyeon
caf088fc1f Use Miscellaneous Configuration Register bit definition instead of
magic number.
2010-07-15 23:34:58 +00:00
Pyun YongHyeon
a5ad2f1541 Remove enabling Data FIFO protection with indirect memory access.
r165114 added that code and that change ignored the same logic
committed in r135772. In addition, data FIFO protection should be
selectively enabled instead of applying to all PCIe devices.
While I'm here add BCM5785 to devices that do not require this
fix.
2010-07-14 21:47:49 +00:00
Pyun YongHyeon
736b931958 Prefer PCIR_BAR macro over BGE_PCI_BAR0. 2010-07-13 19:45:40 +00:00
Pyun YongHyeon
b65256d7bd Fix error message for jumbo buffer allocation failure. 2010-07-13 19:42:55 +00:00
Pyun YongHyeon
333704a37f style. 2010-07-13 19:39:51 +00:00
Pyun YongHyeon
797ab05ef6 Make bge_stop_fw() static.
While I'm here use ANSI function definitions.
2010-07-13 19:33:46 +00:00
Pyun YongHyeon
864104fe59 Zero entire status block and add missing bus_dmamap_sync(9). 2010-07-06 18:17:31 +00:00
Pyun YongHyeon
55a24a0597 It seems read DMA mode register requires both IPv4 TSO and IPv6 TSO
configuration to get IPv4 TSO work on BCM57780. While I'm here
apply the same fix to BCM5785 which shares similar hardware feature
of BCM57780. This change makes TSO work on BCM57780.

Tested by:	Tong Liu <nemoliu <> gmail dot com>
2010-07-06 02:07:59 +00:00
Pyun YongHyeon
e0b7b101ce Fix a bug introduced in r199011. When bge(4) reuses loaded RX
buffers it should also reinitialize RX descriptors otherwise some
stale data could be passed to controller. This could end up with
mbuf double free or unexpected NULL pointer dereference in upper
stack. To fix the issue, save loaded buffer's length and
reinitialize RX descriptors with the saved value whenever bge(4)
reuses the loaded RX buffers.
While I'm here, increase the number of RX buffers to 512 from 256.
This simplifies RX buffer handling as well as giving more RX
buffers. Controller supports just fixed number of RX buffers
(i.e. 512) and bge(4) used to rely on hope that our CPU is fast
enough to keep up with the controller. With this change, bge(4)
will use 1MB for RX buffers but I don't think it would cause
problems in these days.

Reported by:	marcel
Tested by:	marcel
2010-06-05 23:29:24 +00:00
Marius Strobl
2d857b9b19 For the on-board interfaces found in Fujitsu SPARC64 machines obtain the
MAC address via OFW as well.
2010-04-26 18:56:06 +00:00
Pyun YongHyeon
d2b6e9a0bc Use pci_get_max_read_req() and pci_set_max_read_req() to set maximim
read request size.
2010-03-25 17:17:35 +00:00
Pyun YongHyeon
f584dfd113 Revert r205090.
It's hard to know when the mail box register write will get flushed to
the hardware and it may take longer.

Pointed out by:	scottl
2010-03-16 17:45:16 +00:00
Pyun YongHyeon
5e243d9a49 Reorder interrupt handler a bit such that producer/consumer
index of status block is read first before acknowledging the
interrupts. Otherwise bge(4) may get stale status block as
acknowledging an interrupt may yield another status block update.

Reviewed by:	marius
2010-03-12 18:18:04 +00:00
Pyun YongHyeon
fa8b4d63db Fix typo in r204978.
Pointed out by:	marius
2010-03-10 21:37:19 +00:00
Pyun YongHyeon
d896b3fe8d Fix typo in r204975.
Pointed out by:	marius
2010-03-10 20:55:55 +00:00
Pyun YongHyeon
cbb2b2fe3e Set maximum read byte count to 2048 for PCI-X BCM5703/5704 devices.
Also disable relaxed ordering as recommended by data sheet for
PCI-X devices. For PCI-X BCM5704, set maximum outstanding split
transactions to 0 as indicated by data sheet.
For BCM5703 in PCI-X mode, DMA read watermark should be less than
or equal to maximum read byte count configuration. Enforce this
limitation in DMA read watermark configuration.
2010-03-10 20:54:08 +00:00
Pyun YongHyeon
fbc374af79 Enable hardware fixes for BCM5704 B0 as recommended by data sheet. 2010-03-10 20:22:57 +00:00
Pyun YongHyeon
be95548d86 Disable TSO on BCM5755M controller until I understand better for
the issue. I still have no idea why TSO does not work on this
controller. davidch@ also confirmed there is no known TSO related
issues for this controller.
2010-02-26 22:29:42 +00:00
Pyun YongHyeon
5b355c4fb1 Remove Tx mbuf parsing code for VLAN in TSO path. Controller does
not support TSO over VLAN if VLAN hardware tagging is disabled so
there is no need to check VLAN here.
While I'm here make sure to pullup IP/TCP headers in the first
buffer.
2010-02-22 21:03:15 +00:00
Pyun YongHyeon
04bde8528b Add TSO support on VLAN. Controller requires VLAN hardware tagging
to make TSO work on VLAN. So if VLAN hardware tagging is disabled
explicitly clear TSO on VLAN. While I'm here remove duplicated
VLAN_CAPABILITIES call.
2010-02-20 23:21:06 +00:00
Pyun YongHyeon
4150ce6f17 Move device specific flag configuration to attach routine.
The softc obtained in device probe wouldn't be the same one used in
device attach. Drivers should not assume any values stored in softc
structure in probe routine will be available for its attach routine.
2010-02-09 19:12:06 +00:00