Commit Graph

133 Commits

Author SHA1 Message Date
Poul-Henning Kamp
135bd3f8a1 Make sure set the media type in the phy, we cannot trust it to have chosen
the type we happen to want.

Bug triggered by net-booting soekris hardware which comes up in 10/hdx mode
by default.
2004-01-17 10:44:39 +00:00
Brooks Davis
9bf40ede4a Replace the if_name and if_unit members of struct ifnet with new members
if_xname, if_dname, and if_dunit. if_xname is the name of the interface
and if_dname/unit are the driver name and instance.

This change paves the way for interface renaming and enhanced pseudo
device creation and configuration symantics.

Approved By:	re (in principle)
Reviewed By:	njl, imp
Tested On:	i386, amd64, sparc64
Obtained From:	NetBSD (if_xname)
2003-10-31 18:32:15 +00:00
Paul Saab
786a9b65a9 Typo when setting wirespeed. || != |
Found by:	jake
2003-09-28 04:16:16 +00:00
Wilko Bulte
59ce78fef1 Add support for SK-9521 V2.0 and 3COM 3C940.
Tested at 100Mbit only, using Asus P4P800 onboard 3C940.
The -stable version of this patch I have in use for ~2 weeks now, and works
just fine for me.

Based on: Nathan L. Binkert's patch for OpenBSD
Patch submitted by and thanks to: Jung-uk Kim <jkim@niksun.com>
MFC after: 2 weeks
2003-09-20 10:53:08 +00:00
Bill Paul
d5a5045921 Clean up dead code. 2003-09-11 08:28:38 +00:00
Bill Paul
9bac70b851 Add a PHY driver to support the built-in gigE PHY in the 8169S/8110S
ethernet chips. This driver is pretty simple, however it contains
special DSP initialization code which is needed in order to get
the chip to negotiate a gigE link. (This special initialization
may not be needed in subsequent chip revs.) Also:

- Fix typo in if_rlreg.h (RL_GMEDIASTAT_1000MPS -> RL_GMEDIASTAT_1000MBPS)

- Deal with shared interrupts in re_intr(): if interface isn't up,
  return.

- Fix another bug in re_gmii_writereg() (properly apply data field mask)

- Allow PHY driver to read the RL_GMEDIASTAT register via the
  re_gmii_readreg() register (this is register needed to determine
  real time link/media status).
2003-09-11 03:53:46 +00:00
Bill Paul
b9f78d2b4a Add a device driver for the Broadcom BCM4401 ethernet controller,
written by Stuart Walsh and Duncan Barclay (with some kibbitzing by
me). I'm checking it in on Stuart's behalf.

The BCM4401 is built into several x86 laptop and desktop systems. For the
moment, I have only enabled it in the x86 kernel config because although
it's a PCI device, I haven't heard of any standalone NICs that use it. If
somebody knows of one, we can easily add it to the other arches.

This driver uses register/structure data gleaned from the Linux
driver released by Broadcom, but does not contain any of the code
from the Linux driver itself. It uses busdma.
2003-09-09 18:17:23 +00:00
Bill Paul
a94100fa9b Take the support for the 8139C+/8169/8169S/8110S chips out of the
rl(4) driver and put it in a new re(4) driver. The re(4) driver shares
the if_rlreg.h file with rl(4) but is a separate module. (Ultimately
I may change this. For now, it's convenient.)

rl(4) has been modified so that it will never attach to an 8139C+
chip, leaving it to re(4) instead. Only re(4) has the PCI IDs to
match the 8169/8169S/8110S gigE chips. if_re.c contains the same
basic code that was originally bolted onto if_rl.c, with the
following updates:

- Added support for jumbo frames. Currently, there seems to be
  a limit of approximately 6200 bytes for jumbo frames on transmit.
  (This was determined via experimentation.) The 8169S/8110S chips
  apparently are limited to 7.5K frames on transmit. This may require
  some more work, though the framework to handle jumbo frames on RX
  is in place: the re_rxeof() routine will gather up frames than span
  multiple 2K clusters into a single mbuf list.

- Fixed bug in re_txeof(): if we reap some of the TX buffers,
  but there are still some pending, re-arm the timer before exiting
  re_txeof() so that another timeout interrupt will be generated, just
  in case re_start() doesn't do it for us.

- Handle the 'link state changed' interrupt

- Fix a detach bug. If re(4) is loaded as a module, and you do
  tcpdump -i re0, then you do 'kldunload if_re,' the system will
  panic after a few seconds. This happens because ether_ifdetach()
  ends up calling the BPF detach code, which notices the interface
  is in promiscuous mode and tries to switch promisc mode off while
  detaching the BPF listner. This ultimately results in a call
  to re_ioctl() (due to SIOCSIFFLAGS), which in turn calls re_init()
  to handle the IFF_PROMISC flag change. Unfortunately, calling re_init()
  here turns the chip back on and restarts the 1-second timeout loop
  that drives re_tick(). By the time the timeout fires, if_re.ko
  has been unloaded, which results in a call to invalid code and
  blows up the system.

  To fix this, I cleared the IFF_UP flag before calling ether_ifdetach(),
  which stops the ioctl routine from trying to reset the chip.

- Modified comments in re_rxeof() relating to the difference in
  RX descriptor status bit layout between the 8139C+ and the gigE
  chips. The layout is different because the frame length field
  was expanded from 12 bits to 13, and they got rid of one of the
  status bits to make room.

- Add diagnostic code (re_diag()) to test for the case where a user
  has installed a broken 32-bit 8169 PCI NIC in a 64-bit slot. Some
  NICs have the REQ64# and ACK64# lines connected even though the
  board is 32-bit only (in this case, they should be pulled high).
  This fools the chip into doing 64-bit DMA transfers even though
  there is no 64-bit data path. To detect this, re_diag() puts the
  chip into digital loopback mode and sets the receiver to promiscuous
  mode, then initiates a single 64-byte packet transmission. The
  frame is echoed back to the host, and if the frame contents are
  intact, we know DMA is working correctly, otherwise we complain
  loudly on the console and abort the device attach. (At the moment,
  I don't know of any way to work around the problem other than
  physically modifying the board, so until/unless I can think of a
  software workaround, this will have do to.)

- Created re(4) man page

- Modified rlphy.c to allow re(4) to attach as well as rl(4).

Note that this code works for the sample 8169/Marvell 88E1000 NIC
that I have, but probably won't work for the 8169S/8110S chips.
RealTek has sent me some sample NICs, but they haven't arrived yet.
I will probably need to add an rlgphy driver to handle the on-board
PHY in the 8169S/8110S (it needs special DSP initialization).
2003-09-08 02:11:25 +00:00
David E. O'Brien
aad970f1fe Use __FBSDID().
Also some minor style cleanups.
2003-08-24 17:55:58 +00:00
Warner Losh
38d8c9940b Prefer new location of pci include files (which have only been in the
tree for two or more years now), except in a few places where there's
code to be compatible with older versions of FreeBSD.
2003-08-22 06:42:59 +00:00
Doug Ambrisko
6d2a9bd669 On Dell boxes such as the PE2650 we need to disable 3 led mode for the
link LED to work.

Reviewed by:	wpaul
Obtained from:	Linux driver
2003-08-20 04:06:00 +00:00
Bill Paul
5d99c6417d Add support for the Broadcom BCM5901 and BCM5901 rev A2 chips.
These are 10/100 only NICs found on the IBM Thinkpad R40E and
G40. These seem to be based on the BCM5705 MAC but with a PHY
that doesn't support 1000Mbps modes.

Submitted by:	Igor Sviridov <sia@nest.org>
2003-08-12 05:18:51 +00:00
Bill Paul
0434d1b8d2 Add support for the BCM5705 and its ilk. Changes:
- 5705 doesn't support jumbo frames
- Statistics must be read from registers
- RX return ring must be capped at 512 entries
- Omit initialization of certain device blocks
- Acknowledge link change interrupts by setting the 'link changed'
  bit in the status register (used to have no effect)
- Remember to toggle the MI completion bit too
- Set the mbuf low watermark differently (on-chip memory buffers,
  not BSD mbufs)
- Don't enable Ethernet@WireSpeed feature for certain 5705 chip revs
- Add additional PCI IDs for 5705 and 5782 parts
- Add a forgotten 5704 PCI ID

Most changes ripped kicking and screaming from the Broadcom linux driver.
Thanks to Paul Saab for sanity testing. (My lack of sanity has been
confirmed.)
2003-07-16 00:09:56 +00:00
Paul Saab
fe5c322931 Fix bge at 10Mbit. The defines for 10-Half and 10-Full were swapped.
Shamed into fixing by:	John Cagle <john.cagle@hp.com>
2003-06-17 15:02:28 +00:00
Poul-Henning Kamp
19ca58475e Remove unnecessary breaks.
Remove unused variables.
Add XXX comment where a break may be missing. [lxtphy.c]

Found by:       FlexeLint
2003-05-31 19:48:33 +00:00
Paul Saab
20430a6b04 Something I missed in my tree.
If the media changes, poke the DSP on the 5401/5411 Broadcom PHY's.

Obtained from:	NetBSD
2003-05-04 02:03:20 +00:00
Paul Saab
37ceeb4d9f - Move bge_phy_hack into the phy code and implement the various DSP
patch workarounds for each phy revision.
  Obtained from: NetBSD & Broadcom Linux driver

- Disable AUTOPOLL when accessing the PHY as it may cause PCI errors.
  Obtained from: NetBSD

- Check the UPDATED bit in the status block so the driver knows
  that the status block as indeed changed since the last access.
  Broadcom documentation states drivers should unset the UPDATED/CHANGED
  bits after reading them.

- When changing media types, first loop the phy then set the media.
  Broadcom documentation and Linux drivers do this and I observed
  much better handling of link after this change.

- Broadcom documentation states that for 1000BaseT operation,
  autonegotiation must be enabled.  Fix hard coding of media so that
  the driver only advertises 1000BaseT as the supported media type
  and enable autonegotition.

- Only set Master/Slave on the 5701.
  Obtained from Broadcom Linux driver.
2003-05-03 19:06:50 +00:00
Shunsuke Akiyama
11e04b0528 Add RealTek RTL8150 USB to fast Ethernet controller driver.
This driver now supports the Melco LUA-KTX and the GREEN HOUSE
GH-USB100B.

Reviewed by:	imp
MFC after:	2 weeks
2003-05-03 10:16:56 +00:00
Paul Saab
6ac6d2c895 Add untested support for the Broadcom 5704.
Obtained from:	NetBSD
2003-05-02 19:53:40 +00:00
David E. O'Brien
8368cf8f75 Use __FBSDID rather than rcsid[]. 2003-04-03 21:36:33 +00:00
Peter Wemm
bbf9145de3 Remove unused variable and code. 2003-02-19 00:32:01 +00:00
David E. O'Brien
2d3ce7133a Remove miidevs.h and generate it from miidevs at compile time.
The devlist2h.awk tool to do this has been repocopied to sys/tools/.
2003-01-19 02:59:34 +00:00
David E. O'Brien
44ea4fc8d6 Regenerate 2003-01-13 03:58:41 +00:00
David E. O'Brien
f9b7742405 Partial support for the nVidia nForce2 chipset's on-board Broadcom/Altima PHY
and 3com MAC.  Specifications for the Altima PHY are available at:
   http://www.altimacom.com/products/ac101L.html

Submitted by:	Mikko S. Hyvarinen <morphy@morphy.iki.fi>
2003-01-12 21:03:38 +00:00
Semen Ustimenko
07971c4102 Remove unnecessary <sys/malloc.h> include.
Submitted by:	marius@alchemy.franken.de
MFC after:	1 week
2002-10-29 00:20:47 +00:00
Alfred Perlstein
9c1c2e9924 Put function return types on a line by themselves.
Cleanup my earlier de-__P sweep and remove whitespace between function
names and paramters.
2002-10-14 22:31:52 +00:00
Poul-Henning Kamp
37c841831f Be consistent about "static" functions: if the function is marked
static in its prototype, mark it static at the definition too.

Inspired by:    FlexeLint warning #512
2002-09-28 17:15:38 +00:00
John Polstra
b1265c1a98 Add support for the BCM5703x chips. I do not have one of these
cards to test; however the submitter reports that this patch works
with the on-board interface on the IBM x235 server.

Submitted by:	Jung-uk Kim <jkim@niksun.com>
MFC after:	1 month
2002-09-08 19:12:02 +00:00
Doug Ambrisko
74495bcdab Revert change to detect multiply PHYs in mii code. There might be cases
when this is needed.  Work around bogus second PHY in the DFE-580 card
via a change in the if_ste.c driver.

Suggested by:	jdp
Reviewed by:	jdp
MFC after:	3 days
2002-08-16 23:19:16 +00:00
Doug Ambrisko
130be1f120 Only attach one PHY device to a controller. NetBSD has similar code.
The D-Link DFE-580 card will otherwise show 2 miibuses for each controller
and therefore 2 ukphy's.

Sponsored by:	Vernier Networks
MFC after:	1 week
2002-08-07 22:18:33 +00:00
Benno Rice
2e2ec02fd6 regenerate 2002-07-05 11:07:42 +00:00
Benno Rice
d82bc4fba8 Add a driver for the Broadcom BCM52xx "mini-theta" PHY. This includes the
internal PHY on the 3COM 3C905B and 3C905C parts, however I've rigged it so
that xlphy (aka exphy) takes precedence for the time being.

If people try this with their xl cards and decide that it's a better choice,
we can switch this later.

This is the PHY used in various iMacs and possibly other GMAC-equipped
Macintoshes with 10/100 PHYs (the ones with 10/100/1000 appear to use brgphy).

Obtained from:	NetBSD
2002-07-05 11:07:24 +00:00
Benno Rice
daec3648eb Use 3C905C instead of 3c905Cphy as the identifier for the Broadcom PHY used
in the 3C905C.  This is mainly cosmetic.

I'm doing this mainly so we share the same identifier as NetBSD.
2002-07-05 11:02:17 +00:00
Poul-Henning Kamp
37c0fba7c4 Increase gigE negotiation timeout to 17 seconds.
10 seconds is not enough to negotiate a gigE link with a cisco switch which
holds carrier off for several seconds between tries.
2002-05-04 11:08:49 +00:00
Poul-Henning Kamp
fd94424c78 Clean up mii/phy drivers: Remove the MIIF_DOINGAUTO which doesn't really
do anything at the end of the day except bloat the drivers which has
copy&pasted it.
2002-05-04 11:00:30 +00:00
Semen Ustimenko
4592db4635 MII_TICK handlers need not restart aneg on these PHYs, they behave pretty
well as is, so - just fetch current status upon MII_TICK.

Also do IFM_INST verification at the top of *_service() then doing it
separately for every case in switch.

acphy: do not read MII_ACPHY_DIAG twice, there is nothing latching.
qsphy: always fetch actual link status from MII_QSPHY_PCTL.

MFC after:	1 week
2002-05-01 19:15:54 +00:00
Poul-Henning Kamp
875525d517 Introduce NetBSD's mii_phy_match() API and use it in the nsgphy to
get a description printed.
2002-04-29 14:09:10 +00:00
Poul-Henning Kamp
e5fbad8bca Convert exphy and ukphy over to the new code.
exphy is done flying blind, ukphy is tested on one card.
2002-04-29 13:35:31 +00:00
Poul-Henning Kamp
279fe8d156 Make one generic mii_phy_detach() to replace 19 slightly different ones.
Rename mii_phy_auto_stop() mii_phy_down().

Introduce mii_down(), use it from nge.  Do not indirect it to 19 identical
case's in 19 switchstatements like NetBSD did.
2002-04-29 13:07:38 +00:00
Poul-Henning Kamp
78c8c3db4b Move a lot closer to NetBSDs MII support for GigE.
Move fxp and nge drivers over to use the new stuff.
2002-04-29 11:57:30 +00:00
Poul-Henning Kamp
b7dee1db97 Moving closer to being able to use NetBSD's generic mii_set_media()
function.
2002-04-29 07:18:26 +00:00
Poul-Henning Kamp
a295ccc9f0 Edging ever closer to NetBSD... 2002-04-29 06:48:20 +00:00
Poul-Henning Kamp
45521525a7 Move us yet closer to IFM_* definitions in NetBSD. 2002-04-29 05:32:44 +00:00
Poul-Henning Kamp
b418ad5c2e Follow NetBSD and s/IFM_1000_TX/IFM_1000_T/ 2002-04-28 20:34:20 +00:00
Poul-Henning Kamp
07dd938303 Don't pass three args when one will do just fine, and even prevent
mistakes like the one brgphy.c (now corrected).
2002-04-28 19:25:07 +00:00
Poul-Henning Kamp
83549c664b Improve an API by about 4 lines per driver. 2002-04-28 19:01:32 +00:00
Poul-Henning Kamp
3aae18bde8 Use generic MII #defines instead of private ones when the registers
are IEEE defined.

Object file comes out the same.
2002-04-28 18:47:29 +00:00
Poul-Henning Kamp
1aad4b2a52 Merge in rev 1.9 from NetBSD. 2002-04-28 18:43:30 +00:00
Stephen McKay
e3c5a44915 Work around an Intel 21143 chip bug.
Rev 1.56 of if_dc.c removed calls to mii_pollstat() from the dc_tick()
routine.  dc_tick() is called regularly to detect link up and link down
status, especially when autonegotiating.

The expectation was that mii_tick() (which is still called from dc_tick())
would update status information automatically in all cases where it would
be sensible to do so.

Unfortunately, with authentic 21143 chips this is not the case, and
the driver never successfully autonegotiates.  This is because (despite
what it says in the 21143 manual) the chip always claims that link is not
present while the autonegotiation enable bit is set.  Autonegotation takes
place and succeeds, but the driver tests the link bits before it switches
off the autonegotiation enable bit, and success is not recognised.

The simplest solution is to call dcphy_status() more often for MII_TICK
calls by dropping out of the switch statement instead of exiting when
we are autonegotiating and link appears to not be present.  When
autonegotiation succeeds, dcphy_status() will note the speed and fdx/hdx
state and turn off the autonegotiation enable bit.  The next call to
dcphy_status() will notice that link is present, and the dc driver code
will be notified.

Macronix chips also use this code, but implement link detection as
described in the manual, and hence don't need this patch.  However, tests
on a Macronix 98715AEC-C show that it does not adversely affect them.

This could be done better but is the minimal effective change, and most
closely mimics what was happening prior to rev 1.56 of if_dc.c.  (Actually
I also deleted a small amount of unnecessary code while I was in the area.)

Reviewed by:	wpaul
2002-04-18 14:40:20 +00:00
Bill Paul
85ee6a5781 Regenerate. 2002-04-07 20:56:19 +00:00