Commit Graph

92 Commits

Author SHA1 Message Date
John Baldwin
59f47d29b7 Add missing ()'s so that these drivers all compile again.
Noticed by:	jake
Tested on:	i386 (compile)
2003-03-31 20:22:00 +00:00
Nate Lawson
54f1f1d1e6 Clean up locking and resource management for pci/if_*
- Remove locking of the softc in the attach method, instead depending on
  bus_setup_intr being at the end of attach (delaying interrupt enable until
  after ether_ifattach is called)
- Call *_detach directly in the error case of attach, depending on checking
  in detach to only free resources that were allocated.  This puts all
  resource freeing in one place, avoiding thinkos that lead to memory leaks.
- Add bus_child_present check to calls to *_stop in the detach method to
  be sure hw is present before touching its registers.
- Remove bzero softc calls since device_t should do this for us.
- dc: move interrupt allocation back where it was before.  It was unnecessary
  to move it.  This reverts part of 1.88
- rl: move irq allocation before ether_ifattach.  Problems might have been
  caused by allocating the irq after enabling interrupts on the card.
- rl: call rl_stop before ether_ifdetach
- sf: call sf_stop before ether_ifdetach
- sis: add missed free of sis_tag
- sis: check errors from tag creation
- sis: move dmamem_alloc and dmamap_load to happen at same time as tag creation
- sk: remove duplicate initialization of sk_dev
- ste: add missed bus_generic_detach
- ti: call ti_stop before ether_ifdetach
- ti: add missed error setting in ti_rdata alloc failure
- vr: add missed error setting in I/O, memory mapping cases
- xl: add missed error setting in I/O, memory mapping cases
- xl: remove multi-level goto on attach failure
- xl: move dmamem_alloc and dmamap_load to happen at same time as tag creation
- Calls to free(9) are unconditional because it is valid to call free with a
  null pointer.

Reviewed by:	imp, mdodd
2003-03-31 17:29:43 +00:00
Mike Silbersack
709b85c372 Switch rl_encap over to using m_defrag.
No functional change, the previous rl_encap was correct wrt long
mbuf chains; this just reduces code duplication.

MFC after:	2 weeks
2003-03-30 03:45:28 +00:00
MIHIRA Sanpei Yoshiro
1017eea32d Add support for Planex FNW-3800-TX(CardBus 100M/10M).
Submitted by:	Kunihiro Arai <araik@attglobal.net>
Obtained from:	[bsd-nomads:16625]
2003-03-18 14:57:09 +00:00
Dan Moschuk
25b803ef49 Add support for Peppercon ROL-F Card.
Submitted by: Sascha Holzeiter <sascha@root-login.org>
PR: 48559
2003-02-23 23:35:35 +00:00
Warner Losh
a163d034fa Back out M_* changes, per decision of the TRB.
Approved by: trb
2003-02-19 05:47:46 +00:00
Nate Lawson
3f54508cba Clean up exit path from rl_attach() to remove multiple returns 2003-02-09 22:32:50 +00:00
Alfred Perlstein
44956c9863 Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.
Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.
2003-01-21 08:56:16 +00:00
Dag-Erling Smørgrav
9af714a731 FBSDIDize and clean up whitespace nits. 2003-01-11 16:11:21 +00:00
Dag-Erling Smørgrav
f4be139a67 Read sanpei's mind, and unbreak the build. 2003-01-11 16:08:59 +00:00
MIHIRA Sanpei Yoshiro
fe41c67cfc Add support for Corega FEtherII CB-TXD (CardBus 100M/10M).
Fix typo (Coreaga->Corega)
2003-01-11 07:10:35 +00:00
Martin Blapp
e808cf6260 When reading PHY regs over the i2c bus, the turnaround ACK bit
is read one clock edge too late. This bit is driven low by
slave (as any other input data bits from slave) when the clock
is LOW. The current code did read the bit after the clock was
driven high again.

Reviewed by:	luoqi
MFC after:	2 weeks
2003-01-10 08:09:58 +00:00
Jake Burkholder
69a0015af3 Tweaks to make if_rl work on sparc64.
Mostly submitted by:	tmm
Tested on:		i386, sparc64
2003-01-05 21:36:59 +00:00
Sam Leffler
9ef8b52020 o track either_ifattach/ether_ifdetach API changes
o use if_input for input packet processing
o don't strip the Ethernet header for input packets
o use BPF_* macros bpf tapping
o call ether_ioctl to handle default ioctl case
o track vlan changes

Reviewed by:	many
Approved by:	re
2002-11-14 23:49:09 +00:00
Warner Losh
16093e3f47 Don't take out the rl_mtx lock in the attach routine. The only way
we'd need it is if we're interrupted.  So, register the interrupt last
in the attach routine.
2002-10-29 19:02:19 +00:00
Poul-Henning Kamp
88647b6de5 Be consistent about functions being static.
Properly put macro args in ().

Spotted by:	FlexeLint.
2002-10-16 09:14:59 +00:00
Poul-Henning Kamp
1878960dc9 Fix two misindents.
Spotted by:	FlexeLint
2002-10-01 22:27:03 +00:00
Mitsuru IWASAKI
efd1491c3f Add support for Corega FEther CB-TXD (CardBus 100M/10M). 2002-09-06 16:38:06 +00:00
Alfred Perlstein
e3d2833a26 style:
put return values on a line by themselves.
 fix some paste issues where whitespace was used instead of tabs.
2002-08-23 23:49:02 +00:00
Maxim Sobolev
62f7648682 Increase size of ifnet.if_flags from 16 bits (short) to 32 bits (int). To avoid
breaking application ABI use unused ifreq.ifru_flags[1] for upper 16 bits in
SIOCSIFFLAGS and SIOCGIFFLAGS ioctl's.

Reviewed by:	-hackers, -net
2002-08-18 07:05:00 +00:00
John Baldwin
c038666eae If we get 0xffff back when reading the status register, assume the card
has gone away instead of spinning in the interrupt handler.  This stops
my machine from hanging when I eject a rl(4)-based cardbus card.

Reviewed by:	imp
2002-07-30 17:31:42 +00:00
Luigi Rizzo
2e4fb41fa5 Fix if_timer logic to make sure that there is always a timeout
pending if there are packets queued for transmission.

Several drivers still have the same problem.

MFC after: 3 days
2002-06-30 22:16:22 +00:00
John Baldwin
d204693572 Add support for the D-Link DFE-690TXD Cardbus card which has a RealTek 8139
with its own PCI ID.
2002-05-06 13:43:00 +00:00
Luigi Rizzo
7632341a30 Add DEVICE_POLLING support to the "rl" driver.
The diffs are very similar to the ones for the "sis" driver.

MFC After: 5 days
2002-04-16 22:03:14 +00:00
Bill Paul
9a29439fb9 Nortel Networks sells a RealTek 8139-based NIC that's basically
the same thing as the SMC 1211, but with their own vendor ID.
Update the device list to support this NIC. (Discovered these
cards lying around the lab at work.)
2002-04-11 06:12:51 +00:00
Bill Paul
a72c060fb0 Teach the rlphy driver how to do parallel link detection. If the link partner
doesn't support NWAY, the RealTek PHY (both the integrated ones on 8139
chips and the RTL8201L 10/100 PHY) will not report the link speed via
the ANLPAR or BMSR registers. For the 8201L, we need to look in magic
vendor-specific PHY register 0x19. For the 8139 MAC+PHY combo, we have
to be able to test the RL_MEDIASTAT register.

The changes to rlphy.c are based largely on the patch from PR 30836,
however I tried to eliminate some magic numbers by creating an entry
for the 8201 PHY in miidevs.

Also updated if_rl.c to allow the rlphy driver to read the RL_MEDIASTAT
register via the rl_miibus_readreg() routine.
2002-04-07 20:55:50 +00:00
John Baldwin
6008862bc2 Change callers of mtx_init() to pass in an appropriate lock type name. In
most cases NULL is passed, but in some cases such as network driver locks
(which use the MTX_NETWORK_LOCK macro) and UMA zone locks, a name is used.

Tested on:	i386, alpha, sparc64
2002-04-04 21:03:38 +00:00
Alfred Perlstein
e51a25f850 Remove __P. 2002-03-20 02:08:01 +00:00
Mike Silbersack
27d5f39f68 Remove mbuf exhaustion warning messages; these are handled by the
mbuf system in a rate-limited fashion now.

MFC after:	3 days
2002-02-11 23:38:30 +00:00
Luigi Rizzo
268cc03905 Remove printf's on mbuf/cluster allocation failures. There are now
equivalent and less dangerous (rate limited) messages in
the mbuf allocation code.

MFC after: 3 days
2001-12-14 05:56:35 +00:00
Mitsuru IWASAKI
0c66d318dd Add suspend/resume code mostly merged from fxp driver. 2001-11-23 14:27:33 +00:00
Bill Paul
0219a42155 Convert the if_sis and if_rl drivers to use the bus_dma API instead of
calling vtophys() and contigmalloc()/contigfree() directly. Hopefully,
I have shaken out all of the problems with busdma on the alpha now.
(Everything seems to work as expected.)

Also, change the max RX DMA limit to 1024 bytes instead of "unlimited,"
as the latter seems not to work correctly on the alpha that I tested.
(At 100Mbps, all attempts to receive frames yield RX errors.)
2001-08-15 17:38:43 +00:00
Bill Paul
75ff968cd5 Apply patch supplied by Jonathan Chen: use the correct arguments to
pci_enable_io(). We need to use SYS_RES_IOPORT/SYS_RES_MEMORY instead
of PCIM_CMD_PORTEN/PCIM_CMD_MEMEN.
2001-07-09 17:58:42 +00:00
Bosko Milekic
f5eece3fb9 Change m_devget()'s outdated and unused `offset' argument to actually mean
something: offset into the first mbuf of the target chain before copying
the source data over.

Make drivers using m_devget() with a first argument "data - ETHER_ALIGN"
to use the offset argument to pass ETHER_ALIGN in. The way it was previously
done is potentially dangerous if the source data was at the top of a page
and the offset caused the previous page to be copied (if the
previous page has not yet been appropriately mapped).

The old `offset' argument in m_devget() is not used anywhere (it's always
0) and dates back to ~1995 (and earlier?) when support for ethernet trailers
existed. With that support gone, it was merely collecting dust.

Tested on alpha by: jlemon
Partially submitted by: jlemon
Reviewed by: jlemon
MFC after: 3 weeks
2001-06-20 19:48:35 +00:00
Bill Paul
07f65363cd Big round of minor updates:
- Use pci_get_powerstate()/pci_set_powerstate() in all the other drivers
  that need them so we don't have to fiddle with the PCI power management
  registers directly.
- Use pci_enable_busmaster()/pci_enable_io() to turn on busmastering and
  PIO/memory mapped accesses.
- Add support to the RealTek driver for the D-Link DFE-530TX+ which has
  a RealTek 8139 with its own PCI ID. (Submitted by Jason Wright)
- Have the SiS 900/National DP83815 driver be sure to disable PME
  mode in sis_reset(). This apparently fixes a problem on some
  motherboards where the DP83815 chip fails to receive packets.
  (Submitted by Chuck McCrobie <mccrobie@cablespeed.com>)
2001-02-21 20:54:22 +00:00
Jeroen Ruigrok van der Werven
d7d97eb0aa Preceed/preceeding are not english words. Use precede and preceding. 2001-02-18 10:43:53 +00:00
Poul-Henning Kamp
6817526d14 Convert if_multiaddrs from LIST to TAILQ so that it can be traversed
backwards in the three drivers which want to do that.

Reviewed by:    mikeh
2001-02-06 10:12:15 +00:00
Poul-Henning Kamp
78d82c8c59 Use LIST_FOREACH() to traverse ifp->if_multiaddrs list, instead of
<sys/queue.h> implementation details.

Created with:   /usr/sbin/sed
Reviewed with:  /sbin/md5
2001-02-03 16:29:10 +00:00
Bosko Milekic
08812b3925 Implement MTX_RECURSE flag for mtx_init().
All calls to mtx_init() for mutexes that recurse must now include
the MTX_RECURSE bit in the flag argument variable. This change is in
preparation for an upcoming (further) mutex API cleanup.
The witness code will call panic() if a lock is found to recurse but
the MTX_RECURSE bit was not set during the lock's initialization.

The old MTX_RECURSE "state" bit (in mtx_lock) has been renamed to
MTX_RECURSED, which is more appropriate given its meaning.

The following locks have been made "recursive," thus far:
eventhandler, Giant, callout, sched_lock, possibly some others declared
in the architecture-specific code, all of the network card driver locks
in pci/, as well as some other locks in dev/ stuff that I've found to
be recursive.

Reviewed by: jhb
2001-01-19 01:59:14 +00:00
Bill Paul
14a00c6c68 Use pci_get_powerstate()/pci_set_powerstate() which now exists in the
PCI code. This saves each driver from having to grovel around looking
for the right registers to twiddle.

I should eventually convert the other PCI drivers to do this; for now,
these three are ones which I know need power state handling.
2000-12-18 21:53:05 +00:00
Bill Paul
031fc810ab Initialize/grab the mutex earlier in the attach phase, so that
bailing out to the fail: label where we release/destroy the mutex
will work without exploding.
2000-12-04 22:46:50 +00:00
Roger Hardiman
0eaa901ba7 Print a warning when we detect a Realtek 8139B chip
(identified by the IO map being 256 bytes long instead of 128)

This chip works very unreliably on my Lanner embedded PC with the rl driver.
Lots of watchdog timeouts or poor performance.

Forcing the media type to 10 Meg (ifconfig rl0 media 10baseT/UTP) is a good
workaround.

This looks very similar to the problem reported in PR kern/18790

It is interesting to note that the linux driver has lots of special
case code for this chip.
2000-11-24 17:36:07 +00:00
Bill Paul
57c19b2049 Fix 8-bit EEPROM breakage: compare against 0x8129, not 8129. 2000-11-01 23:56:46 +00:00
Bill Paul
78d2de28df Fix support for cardbus cards:
- Add DRIVER_MODULE() declaration to make this driver a
	  child of cardbus
	- Handle different width EEPROMs

The CIS parser still barfs when scanning this card, but it seems to
probe/attach correctly anyway. I can't do a traffic test just yet
since I don't have a proper crossover cable handy.
2000-10-30 07:54:38 +00:00
Bill Paul
1d5e53109c Add PCI IDs for some additional cardbus cards. Yes, there really is
a RealTek 8139 cardbus device. Unfortunately it doesn't quite work yet
because the CIS parser barfs on it.

Submitted by msmith, with some small tweaks by me.
2000-10-28 09:00:20 +00:00
Poul-Henning Kamp
db7e3af111 Remove unneeded #include <machine/clock.h> 2000-10-15 14:19:01 +00:00
Bill Paul
1e856a7b34 Use device_get_nameunit(dev) as the mutex string when calling
mtx_init() instead of hard-coded string constant. Also remember to do
the mutex changes to the ste driver, which I forgot in the first commit.
2000-10-13 18:35:49 +00:00
Bill Paul
d1ce910572 First round of converting network drivers from spls to mutexes. This
takes care of all the 10/100 and gigE PCI drivers that I've done.
Next will be the wireless drivers, then the USB ones. I may pick up
some stragglers along the way. I'm sort of playing this by ear: if
anyone spots any places where I've screwed up horribly, please let me
know.
2000-10-13 17:54:19 +00:00
Archie Cobbs
21b8ebd926 Make all Ethernet drivers attach using ether_ifattach() and detach using
ether_ifdetach().

The former consolidates the operations of if_attach(), ng_ether_attach(),
and bpfattach(). The latter consolidates the corresponding detach operations.

Reviewed by:	julian, freebsd-net
2000-07-13 22:54:34 +00:00
Peter Wemm
86b0a953e2 Use the correct register name. s/PCI_COMMAND_STATUS_REG/PCIR_COMMAND/ 2000-05-28 16:13:43 +00:00