Commit Graph

227 Commits

Author SHA1 Message Date
Stanislav Sedov
3889907fb2 - Give a name to the host coalescing bug fix WDMA mode register bit instead
of using hardcoded value in the code.
Obtained from:	OpenBSD
2009-10-07 14:29:48 +00:00
Stanislav Sedov
a57795536a - Add support for new BGE chips (5761, 5784 and 57780). These chips uses new
BGE_PCI_PRODID_ASICREV register to store the chip identifier and its revision.
- Add new grouping macro for 7575+ chips (BGE_IS_5755_PLUS).
- Add IDs for Fujitsu-branded Broadcom adapters.

PR:             kern/127587
Tested by:      Thomas Quinot <thomas@quinot.org> (BCM7561 A0)
MFC after:	2 weeks
Obtained from:  OpenBSD
2009-10-07 13:12:43 +00:00
Stanislav Sedov
7f21e273a8 - Do not try to reevaluate current RX production index on each
loop iteration as it can be updated by the card while we
  process the RX ring forcing us to process RX descriptors
  for which DMA synchronisation operation has not been
  performed.  This fixes the bug when bge(4) drops packets
  under high load.

Discussed with:	yongari, marius
Approved by:	re (kib)
MFC after:	1 week
2009-08-18 21:07:39 +00:00
Robert Watson
eb956cd041 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
2009-06-26 11:45:06 +00:00
Attilio Rao
8cf7d13d7a Fix return values appropriately.
Tested by:	zec
2009-05-30 17:56:19 +00:00
Attilio Rao
d4da719cf6 s/rk_npkts/rx_npkts
Reported by:	zec
2009-05-30 17:25:14 +00:00
Attilio Rao
1abcdbd127 When user_frac in the polling subsystem is low it is going to busy the
CPU for too long period than necessary.  Additively, interfaces are kept
polled (in the tick) even if no more packets are available.
In order to avoid such situations a new generic mechanism can be
implemented in proactive way, keeping track of the time spent on any
packet and fragmenting the time for any tick, stopping the processing
as soon as possible.

In order to implement such mechanism, the polling handler needs to
change, returning the number of packets processed.
While the intended logic is not part of this patch, the polling KPI is
broken by this commit, adding an int return value and the new flag
IFCAP_POLLING_NOCOUNT (which will signal that the return value is
meaningless for the installed handler and checking should be skipped).

Bump __FreeBSD_version in order to signal such situation.

Reviewed by:	emaste
Sponsored by:	Sandvine Incorporated
2009-05-30 15:14:44 +00:00
Xin LI
9fe569d8f9 Some comment/space changes (FALLTHRU -> FALLTHROUGH, space after while). 2009-05-14 22:36:56 +00:00
Xin LI
25e13e6895 Try to workaround a race where bge_stop() may sneak in when bge_rxeof()
drops and re-grabs the softc mutex in the middle, resulting in kernel
trap 12.  This may happen when a lot of traffic is being hammered on
one bge(4) interface while the system is shutting down.

Reported by:	Alexander Sack <pisymbol gmail com>
PR:		kern/134548
MFC After:	2 weeks
2009-05-14 22:33:37 +00:00
Marius Strobl
c9ffd9f058 - Ensure that INTx isn't disabled, as these chips apparently have a
quirk requiring it to be enabled even when using MSI. This makes
  the latter work again after r189285.
- Remove a comment which no longer applies since r190194.
2009-03-23 14:36:50 +00:00
Marius Strobl
4f09c4c7e5 - In bge_ifmedia_upd_locked() take advantrage of LIST_FOREACH().
- If boot verbose, print asicrev, chiprev and bus type on attach.
- For PCI Express devices:
  1) Adjust max read request size to 4Kbytes
  2) Turn on FIFO_LONG_BURST in RDMA during bge_blockinit()
  Though 1) does not seem to have much to do with the poor TX performance
  observed on PCI Express bge(4), 2) does fix the problem. [1]
- Nuke the RX CPU self-diag, which prevents working cards from working
  (Linux tg3 does not have this diag neither does OpenBSD's bge(4)).
  The increasing of the firmware handshaking timeout to 20000 retries
  done as part of the original commit isn't merged as way already have a
  way higher BGE_TIMEOUT of 100000.

PR:		119361 [1]
Obtained from:	tg3 via DragonflyBSD [1], DragonflyBSD
2009-03-21 00:23:07 +00:00
Marius Strobl
4012d104cd Don't reset the PHY probe retry counter within the loop so
it will eventually terminate as intended.

Submitted by:	Helen Zhang
2009-02-10 21:54:23 +00:00
Warner Losh
b6c974e8da device_shutdown returns an int. 2009-02-05 18:43:13 +00:00
Marius Strobl
90447aad0a - Limit BCM5701 B5 to 32-bit mode as a workaround for a bug which
causes data corruption in combination with certain bridges.
  Information about this problem was kindly provided by davidch. [1]
- As BGE_FLAG_PCIX is meant to indicate that the controller is in
  PCI-X mode, revert to the pre __FreeBSD_version 602101 method of
  reading the bus mode register rather than checking the mere
  existence of a PCI-X capability, which is also there when the
  NIC f.e. is put into a 32-bit slot causing it not to be in PCI-X
  mode. Setting BGE_FLAG_PCIX inappropriately could cause the NIC
  to be tuned incorrectly.

PR:		128833 [1]
Reviewed by:	jhb
MFC after:	3 days
2008-12-09 21:34:22 +00:00
Marius Strobl
a8376f70e7 Do as the Linux tg3 driver does and enable MSI support also
for the BCM5714 revision A0 when in a multi-port configuration
and unconditionally for the remainder of the class of BCM575X
and beyond chips.
This was prodded by mav and is based on a suggestion and a
patch submitted by jhb.

Reviewed by:	jhb
MFC after:	2 months
2008-10-27 22:10:01 +00:00
Marius Strobl
c00cf72245 Use bus_{read,write}_4(9) instead of bus_space_{read,write}_4(9)
in order to get rid of the bus space handle and tag in the softc.

MFC after:	1 month
2008-10-14 20:28:42 +00:00
Marius Strobl
852c67f994 - Don't read the identifier string from the VPD if there's no chip
containing an Ethernet address fitted as this is yet another thing
  that fails in that case in order to avoid the one second delay
  until pci_read_vpd_reg() times out.
- Const'ify the bge_devs array.
2008-09-22 20:55:19 +00:00
Oleg Bulyzhin
82b67c0132 bge_tick(): do not touch PHY if link is up. This should solve problem with
extra input errors for some BCM57XX chips.

PR:		kern/122295
2008-09-08 18:10:15 +00:00
Marius Strobl
5fea260f19 Improve the integration of BCM5906[M] support:
- Rename BGE_FLAG_EEPROM to BGE_FLAG_EADDR to underline it's absence means
  "there's no chip containing an Ethernet address fitted to the BGE chip
  so we have to get it from the firmware instead" rather than "there's no
  EEPROM, but maybe NVRAM or something else".
- Don't treat BCM5906[M] generally like chips w/o BGE_FLAG_EADDR set, just
  in the two cases really necessary. This gets us line with the original
  patch for DragonFlyBSD.
- For sparc64 restore the intended behavior of obtaining the Ethernet
  address from the firmware in case BGE_FLAG_EADDR is not set, even for
  BCM5906[M].
- Fix some style(9) bugs introduced with rev. 1.208 of if_bge.c

Approved by:		jhb
Additional testing by:	Thomas Nystroem (BCM5906)
2008-05-14 21:00:27 +00:00
Bjoern A. Zeeb
4f0794ff96 Use a better approach to force the interrupt which should work for
all cards/modes.
In addition to the intr forcing added with rev. 1.205 adopt the other
places to use the same logic.

We need to exclude a few chips/revisions (5700, 5788) from using the
enhanced version and fall back to the old way as that is the only
method they support.

Tested by:	phk
Suggested by:	davidch, Broadcom (thanks a lot for the help!)
MFC after:	16 days
2008-05-05 18:42:17 +00:00
Bjoern A. Zeeb
63ccfe30a1 Use the correct bit when trying to force an interrupt through the HCC reg.
It's not a problem as this is a #ifdef notyet.
2008-05-01 13:10:03 +00:00
John Baldwin
38cc658ff6 Add support for the BCM5906[M] adapters. These adapters only support
10/100 operation and place the mailbox registers at a different offset.
They also do not have an EEPROM, so the MAC address must be read from
NVRAM instead.

MFC after:	1 month
PR:		kern/118975
Submitted by:	benjsc, Thomas Nyström  thn at saeab dot se
Submitted by:	sephe (original patch for DragonflyBSD)
2008-04-29 19:47:13 +00:00
Marius Strobl
44f8f2fc05 Remove some remnant alpha hacks.
Approved by:	PCI-maintainers (imp, jhb)
2008-04-26 14:13:48 +00:00
Marius Strobl
4eee14cb27 - Use more appropriate maxsize, nsegments and maxsegsize parameters
when creating the parent bus DMA tag. While at it correct the style
  and a nearby comment.
- Take advantage of m_collapse(9) for performance reasons.

MFC after:	2 weeks
2008-04-26 10:54:17 +00:00
Bjoern A. Zeeb
902827f6f3 In some situations we were not clearing pending link state attentions.
Because of this we were not getting further interrupts for link state
changes, thus never went into iface UP state and thus could not transmit.

The only way out of this was an incoming packet generating an rx interrupt
and making us call into bge_link_upd.

Up to rev. 1.101, in bge_start_locked, we only returned instantly
if there was 'no link AND nothing queued for tx'. So with a packet queued
for tx, we hit the register scrubbing at the end of bge_start_locked
and were out fine. We simply lost a packet or two but got the interrupts
need to get into UP state.
With rev. 1.102 this was turned into 'if there is no link OR there is
nothing to send' (correct behaviour) and as long as there is no link
we never hit the register scrubbing and consequently never got the link UP.

What we do now is force an interrupt at the end of bge_ifmedia_upd_locked
so we will call bge_link_upd, clear the link state attention and get
further interrupts.
This helps to get the iface UP on an idle network or at least to get
it UP faster not depending on an rx intr anymore.
In case you could not get a DHCP lease or it took very long,
it was because of this.

It is unknown which chips are affected by this. ASIC rev. 0x2003 was the
most popular trouble candidate.
At least the fiber cards should have been working fine.

Which register to scrub is currently under discussion. The comitted
solution was tested and found to work for a lot of setups. It might
not help with MSI.
The reason why we end up in such a situation is entirely unknown.

PR:		kern/111804
Tested by:	phk, scottl at Y!
MFC after:	14 days
2008-04-08 11:51:17 +00:00
John Baldwin
4fcf220b00 Don't enable the workaround for the jitter bug on the 5722.
Obtained from:	Linux tg3 driver
2008-03-11 15:05:54 +00:00
John Baldwin
bcc20328f5 Flesh out support for the BCM5722 by recognizing the phy on the 5722 and
the specific ASIC revision.

MFC after:	1 week
Obtained from:	OpenBSD (mii/phy bits)
2008-03-06 21:42:48 +00:00
Jung-uk Kim
86543395c1 Add a flag for Ethernet@WireSpeed capability and correct chip revisions.
The idea was taken from OpenBSD and cross-referenced with Linux driver.
2008-01-18 22:09:50 +00:00
Jung-uk Kim
e4be3198af Fix mbuf pool watermark configuration (mismerged from OpenBSD in 1.132).
Submitted by:	sephe
MFC after:	3 days
2008-01-18 20:33:21 +00:00
Remko Lodder
effef9789a Add support for the BMC5722.
Reported by:		Chris Shenton <chris at shenton dot org> on current@
Approved by:		imp (mentor)
2007-12-25 19:51:18 +00:00
Jung-uk Kim
d949071d71 Do not report MAC, TX, and RX stats via sysctl(8) with BCM5705+.
The register layout is little different from memory-mapped stats
in the previous generation chips.  In fact, it is bad because
registers in this range are cleared after reading them.

Reviewed by:	scottl
MFC after:	3 days
2007-11-16 16:39:27 +00:00
Marius Strobl
55aaf894e8 Make the PCI code aware of PCI domains (aka PCI segments) so we can
support machines having multiple independently numbered PCI domains
and don't support reenumeration without ambiguity amongst the
devices as seen by the OS and represented by PCI location strings.
This includes introducing a function pci_find_dbsf(9) which works
like pci_find_bsf(9) but additionally takes a domain number argument
and limiting pci_find_bsf(9) to only search devices in domain 0 (the
only domain in single-domain systems). Bge(4) and ofw_pcibus(4) are
changed to use pci_find_dbsf(9) instead of pci_find_bsf(9) in order
to no longer report false positives when searching for siblings and
dupe devices in the same domain respectively.
Along with this change the sole host-PCI bridge driver converted to
actually make use of PCI domain support is uninorth(4), the others
continue to use domain 0 only for now and need to be converted as
appropriate later on.
Note that this means that the format of the location strings as used
by pciconf(8) has been changed and that consumers of <sys/pciio.h>
potentially need to be recompiled.

Suggested by:	jhb
Reviewed by:	grehan, jhb, marcel
Approved by:	re (kensmith), jhb (PCI maintainer hat)
2007-09-30 11:05:18 +00:00
David Malone
041b706b2f Despite several examples in the kernel, the third argument of
sysctl_handle_int is not sizeof the int type you want to export.
The type must always be an int or an unsigned int.

Remove the instances where a sizeof(variable) is passed to stop
people accidently cut and pasting these examples.

In a few places this was sysctl_handle_int was being used on 64 bit
types, which would truncate the value to be exported.  In these
cases use sysctl_handle_quad to export them and change the format
to Q so that sysctl(1) can still print them.
2007-06-04 18:25:08 +00:00
Yaroslav Tykhiy
cb2eacc7dd Add on/off controls for VLAN_MTU and VLAN_HWTAGGING to bge(4). 2007-06-01 02:02:39 +00:00
Jung-uk Kim
e629eb82ba Remove an empty line. 2007-05-22 20:24:07 +00:00
Jung-uk Kim
0f89fde22c Remove BCM5704S specific tunable (hw.bge.fake_autoneg) and
auto-detect the condition.
2007-05-22 19:35:34 +00:00
Jung-uk Kim
186f842beb Rearrange DMA read/write control register settings based on document snippet
provided by davidch via glebius.

PR:		kern/96806
2007-05-22 19:22:58 +00:00
Jung-uk Kim
410c2bebd2 Remove stale alpha support code. 2007-05-22 19:11:39 +00:00
Jung-uk Kim
d5d2385773 Fix time out check in EEPROM read and move delays to give some settle time.
Submitted by:	mjacob
2007-05-22 18:51:05 +00:00
Jung-uk Kim
ca0ba1d16f Add delays in MI communication register R/W loops. 2007-05-22 18:16:23 +00:00
Jung-uk Kim
fe09b799f1 Reflect MFC of pci_find_extcap().
MFC after:	3 days
2007-05-01 19:18:12 +00:00
Marius Strobl
08013fd336 - Add support/quirks for the on-board BGEs found in Sun Blade 1500
Blade 2500, Fire V210 and probably some other sparc64 machines.
  These chips are typically not fitted with an EEPROM which means
  that we have to obtain the MAC address via OFW and that some chip
  tests will just always fail.
  These changes are based on the respective code found in OpenBSD
  with some additional info obtained from OpenSolaris and some style
  suggestions by jkim@. They also have the desired side-effect of
  respecting the 'local-mac-address?' system configuration variable
  for the affected BGEs.
- In bge_attach() factor out calling bge_release_resources() before
  going to the fail label into the fail label as well as replace a
  magic 6 with ETHER_ADDR_LEN.

Reviewed by:	yongari (before style changes), jkim
2007-04-30 21:55:27 +00:00
Jung-uk Kim
0a55a034ba Enable MSI support on RELENG_6.
MFC after:	3 days
2007-04-02 19:09:06 +00:00
Scott Long
06e83c7e86 Fix some OID names and minor style as per feedback from various people.
Also, apparently quad support is broken in the sysctl infrastructure, so don't
pretend that it works.

Submitted by: ru, bde
2007-03-13 00:41:55 +00:00
Scott Long
763757b2a4 Add MAC, RX, and TX stats reporting via sysctl. 2007-03-12 09:25:57 +00:00
Jung-uk Kim
0c4a1ef8dc Add more chipset revision IDs.
Obtained from:	OpenBSD
2007-03-09 01:30:23 +00:00
Jung-uk Kim
39153c5a23 Use correct bits to stop firmware when ASF mode is enabled. 2007-03-08 00:49:26 +00:00
Jung-uk Kim
0c8aa4eacd Fix more style(9) bugs.
- Remove some excessive parentheses around shift operators.
- Use macro instead of magic number where it is applicable.
- Change lower-case hexdecimals to upper cases to match wpaul's style.
- Revert some unnecessary line wraps and changes from the previous commit.

Pointed out by:	bde
2007-03-08 00:29:18 +00:00
Jung-uk Kim
6098821ce7 Fix style(9) and consistency. 2007-03-06 20:14:48 +00:00
Jung-uk Kim
4e35d186f1 Pollute bge(4) with #if's and #ifdef's to make MFC easier.
MFC after:	3 days
2007-03-06 19:15:16 +00:00