Commit Graph

151 Commits

Author SHA1 Message Date
Warner Losh
19b7ffd1b8 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 07:20:27 +00:00
Maxime Henrion
42e85383ff Use the BUS_DMA_ZERO flag instead of bzero()'ing DMA memory. 2003-07-27 13:56:03 +00:00
Bill Paul
e4cffe95c7 Support for large frames for VLANs was added by tweaking the packet size
register, present only on 3c90xB and later NICs. This meant that you could
not use a 1500 byte MTU with VLANs on original 3c905/3c900 cards (boomerang
chipset). The boomerang chip does support large frames though, just not
in the same way: you can set the 'allow large frames' bit in the MAC
control register to receive frames up to 4K in size.

Changes:

- Set the 'allow large frames' bit for boomerang chips and increase
  the packet size register for cyclone and later chips. This allows
  us to use IFCAP_VLAN_MTU on all supported xl(4) NICs.
- Actually set the IFCAP_VLAN_MTU flag in the capabilities word
  in xl_attach().
- Change the method used to detect older boomerang chips. My 3c575C
  cardbus NIC was being incorrectly identified as 3c90x chip instead
  of 3c90xB because the capabilities word in its EEPROM reports
  a bizzare value. In addition to checking for the supportsNoTxLength
  bit, also check for the absence of the supportsLargePackets bit.
  Both of these cases denote a 3c90xB chip.
- Make RX and TX checksums configurable via the SIOCSIFCAP ioctl.
- Avoid an unecessary le32toh() in xl_rxeof(): we already have the
  received frame size in the lower 16 bits of rxstat, no need to
  read it again.

Tested with 3c905-TX, 3c900-TPO, 3c980C and 3c575C NICs.
2003-07-10 05:24:33 +00:00
Maxime Henrion
139cfa581e - Ensure that the busdma API won't do deferred loads by using the
BUS_DMA_NOWAIT flag, since the code can't handle this.
- Use NULL, NULL for the lockfunc and lockfuncarg parameters of
  bus_dma_tag_create() since deferred loads can't happen now.
2003-07-04 11:46:23 +00:00
Warner Losh
b84e866a18 Due to extreme bogusness in the pci bus layer, these drivers were
forced to do slightly bogus power state manipulation.  However, this
is one of those features that is preventing further progress, so mark
them as BURN_BIRDGES like I did for the drivers in sys/dev/...

This, like the other change, are a no-op unless you have BURN_BRIDGES
in your kernel.
2003-07-03 21:39:53 +00:00
Scott Long
f6b1c44d1f Mega busdma API commit.
Add two new arguments to bus_dma_tag_create(): lockfunc and lockfuncarg.
Lockfunc allows a driver to provide a function for managing its locking
semantics while using busdma.  At the moment, this is used for the
asynchronous busdma_swi and callback mechanism.  Two lockfunc implementations
are provided: busdma_lock_mutex() performs standard mutex operations on the
mutex that is specified from lockfuncarg.  dftl_lock() is a panic
implementation and is defaulted to when NULL, NULL are passed to
bus_dma_tag_create().  The only time that NULL, NULL should ever be used is
when the driver ensures that bus_dmamap_load() will not be deferred.
Drivers that do not provide their own locking can pass
busdma_lock_mutex,&Giant args in order to preserve the former behaviour.

sparc64 and powerpc do not provide real busdma_swi functions, so this is
largely a noop on those platforms.  The busdma_swi on is64 is not properly
locked yet, so warnings will be emitted on this platform when busdma
callback deferrals happen.

If anyone gets panics or warnings from dflt_lock() being called, please
let me know right away.

Reviewed by:	tmm, gibbs
2003-07-01 15:52:06 +00:00
Bill Paul
ac8824dbea Modify the xl_reset() routine slightly so that, if we're using memory
mapped I/O mode, we pause for .1 seconds after issuing the reset command
before trying to poll the 'command busy' bit in the status register.
With my 3c575C cardbus NIC, my Sony Picturebook locks up when it tries
to read the status register immediately after the reset. This appears
to be a problem only with certain NICs on certain hardware, but the
added delay should not hurt cards that already work.

This bug seems to have been brought to light by the fact that the xl
driver now defaults to memory mapped I/O mode instead of programmed
I/O mode like it used to. With PIO mode, the delay isn't needed and
everything works (which is why this NIC worked with 5.0-RELEASE but
not 5.1). I suspect that what's happening is that when the chip is
reset, it takes a little while for the memory-mapped decoding logic
to recover. Trying to access the chip's registers during this period
causes an error condition of some kind that wedges the system.
2003-06-29 01:38:57 +00:00
David E. O'Brien
f4636c5959 Use __FBSDID(). 2003-06-11 06:34:30 +00:00
Warner Losh
214073e5e4 Use newly minted device_is_attached rather than device_is_alive to see
if attach succeeded.  device_is_alive just tells us that probe
succeeded.  Since we were using it to do things like detach net
interfaces, this caused problems when there were errors in the attach
routine.

Symptoms of problem reported by: martin blapp
2003-04-21 18:34:04 +00:00
Nate Lawson
693f4477b1 Revise attach/detach resource cleanup
- Unconditionally call *_stop() if device is in the tree. This is to
  prevent callouts from happening after the device is gone. Checks for
  bus_child_present() should be added in the future to keep from touching
  potentially non-existent hardware in *_detach().  Found by iedowse@.
- Always check for and free miibus children, even if the device is not in
  the tree since some failure cases could have gotten here.
- Call ether_ifdetach() in the irq setup failure case
- ti(4), xl(4): move ifmedia_init() calls to the beginning of attach so
  that ifmedia_removeall() can be unconditionally called on detach. There
  is no way to detect whether ifmedia has been initialized without using
  a separate variable (as tl(4) does).
- Add comments to indicate assumptions of code path
2003-04-17 20:32:06 +00:00
Matthew N. Dodd
533294b956 - Don't call pci_enable_io() in drivers (unless needed for resume).
- Don't test memory/port status and emit an error message; the PCI
  bus code will do this now.
2003-04-16 03:16:57 +00:00
Matthew N. Dodd
f246e4a17f - Express hard dependencies on bus (pci, isa, pccard) and
network layer (ether).
- Don't abuse module names to facilitate ifconfig module loading;
  such abuse isn't really needed.  (And if we do need type information
  associated with a module then we should make it explicit and not
  use hacks.)
2003-04-15 06:37:30 +00:00
Maxime Henrion
acabcf7d83 Correct maxsize/maxsegsz parameters to bus_dma_tag_create(). 2003-04-09 15:05:19 +00:00
Mike Silbersack
ee9ad95f0e Fix up callers of xl_encap so that they handle a failure response
properly (likely due to mbuf exhaustion.)  Previously, the driver
got somewhat wedged.

Also, remove the annoying messages printed every time xl_encap
couldn't allocate a mbuf; they served no useful purpose, and just made
an mbuf exhaustion situation more annoying.

MFC after:	1 week
2003-04-08 01:05:54 +00:00
Maxime Henrion
cc9beb7b77 Use bus_dmamap_load_mbuf() instead of bus_dmamap_load() for the
RX part of this driver too.  It's better since the code wasn't
dealing with bus_dmamap_load() returning EINPROGRESS, and this
can't happen with bus_dmamap_load_mbuf().

Submitted by:	jake
2003-04-05 23:24:23 +00:00
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
cb3b23ef1e Fix up the long mbuf chain recovery code to use m_defrag; the old
code messed up on B & C chipsets because it lost the packet header
and therefore the flag indicating the need for hardware checksums.

MFC after:	2 weeks
2003-03-29 06:34:25 +00:00
Mike Silbersack
af498ca9eb Make sure to free the correct resources when the card fails to attach
properly.  (Broken in the previous commit.)

Noticed by:	"Niels Chr. Bank-Pedersen" <ncbp@bank-pedersen.dk>
2003-03-19 01:48:14 +00:00
Mike Silbersack
16a930f6cb Instead of relying on a compile time define to determine whether the xl
driver should use port or memory based IO, determine it dynamically
at runtime, preferring MMIO where possible.  This helps us support newer
arches which dislike port based access better.

Tested on i386 & sparc64, with 3c900, 905, 905b, and 905C cards.
(in varying combinations by both jake and myself)
2003-03-18 06:29:51 +00:00
Bosko Milekic
544244654a Fix bug introduced in 1.130. For the < MHLEN case, we should
be doing a m_gethdr(), not an m_get().

Pointed out by: Hiten Pandya <hiten@unixdaemons.com>
Pointy hat to: Me
2003-03-04 20:19:26 +00:00
Bosko Milekic
fd18f292bd Make xl use m_getcl() to allocate an mbuf and a cluster in one shot,
as opposed to one after the other.  This is faster in both -CURRENT
and -STABLE.  Additionally, there is less code duplication for
error-checking.

One thing to note is that this code seems to return(1) when no buffers
are available; perhaps ENOBUFS should be the correct return value?

Partially submitted & tested by: Hiten Pandya <hiten@unixdaemons.com>
MFC after: 1 week
2003-02-22 14:46:31 +00:00
Maxime Henrion
5e303db539 Fix panic on sparc64 introduced in my last commit. I really
wish the busdma APIs were more consistent accross architectures.

We should probably move all the other DMA map creations in
xl_attach() where we can really handle them failing, since
xl_init() is void and shouldn't fail.

Pointy hat to:	mux
Tested by:	Anders Andersson <anders@hack.org>
2003-02-19 18:33:29 +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
Maxime Henrion
44250c5cd8 - Fix mbuf leak when we successfully allocate a new mbuf but fail to
bus_dmamap_load() it.
- Make it so reusing mbufs when we can't allocate (or map) new ones
  actually works.  We were previously trying to reuse a mbuf which
  was already bus_dmamap_unload()'ed.

Reviewed by:	silby
2003-02-18 18:50:54 +00:00
Maxime Henrion
ff301db64c Remove the now unused sys/malloc.h header. 2003-01-24 02:42:22 +00:00
Mike Silbersack
e02d5926c3 Correctly identify the 3C920B chipset; although it may ship with some Nforce2
boards, it's definitely not an Nvidia chip.

Info from: Nvidia's Linux Network driver & pciids.sourceforge.net
2003-01-22 17:14:33 +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
David E. O'Brien
aac0e9388e Complete the support of the on-board xl(4) on nVidia nForce2 mobo's.
Submitted by:	Mikko S. Hyvarinen <morphy@morphy.iki.fi>
2003-01-19 04:47:54 +00:00
Thomas Moestl
a712d94e68 Make the xl driver work on sparc64:
- Add conversions to/from little endian for fields that the NIC accesses
  by DMA as required.
- Add some bus_dmamap_sync() calls, and correct some existing ones.
- Read the receiver information from the EEPROM in an endian-neutral
  manner.
- Load all RX and TX descriptors in a single DMA map up front, and
  get the bus addresses of individual descriptors by address arithmetic;
  this fixes multiple use of the descriptor tags, which would have
  undesired effects.
It seems that xl still does not work on e250 boxen, for reasons which
are not clear yet.

Reviewed by:	mux
2003-01-19 00:23:59 +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
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
Maxime Henrion
d21682e5d3 o Only try to recopy the mbuf into an mbuf cluster if
bus_dmamap_load_mbuf() returned EFBIG.
o Fix mbuf leaks in an error (rare) code path.
o Reuse the TX descriptor if xl_encap() failed instead of
  just picking the next one.
o Better error messages.
2003-01-07 01:01:20 +00:00
Mike Silbersack
81f045c0d2 Ooops, use the full name of XL_FLAG_EEPROM_OFFSET_30
Noticed by:	Niels Chr. Bank-Pedersen <ncbp@bank-pedersen.dk>
2003-01-06 01:55:12 +00:00
Mike Silbersack
9363b90153 Add support for the 3c555 miniPCI chipset.
Submitted by:	johannes <johannes@paradise.net.nz>
PR:		46603
MFC after:	3 days
2003-01-06 00:46:03 +00:00
Mike Silbersack
e7e21ec663 Add two MII_SETs to provide a bit more time between operations in
xl_sync; this appears to be necessary with certain systems.

Requested by:	Michael Class <michael_class@gmx.net>
2003-01-06 00:36:13 +00:00
Jens Schweikhardt
9d5abbddbf Correct typos, mostly s/ a / an / where appropriate. Some whitespace cleanup,
especially in troff files.
2003-01-01 18:49:04 +00:00
Maxime Henrion
c9257029fd Leave only one of the two $FreeBSD$ tag, and use __FBSDID(). 2002-12-30 12:46:08 +00:00
Maxime Henrion
71ffa67746 Fix bug with 3c90xB cards and newer. We weren't trying to
copy the mbuf chain into an mbuf cluster when there is
more than 63 mbufs in the chain.  We were trying with older
cards though.
2002-12-18 23:16:22 +00:00
Maxime Henrion
e7c30f884f Convert the xl(4) driver to the busdma API. This should make
it possible to use this driver under ia64, sparc64 (though
there may be endianness issues with this one) and other archs.

Tested on:	i386, alpha (gallatin)
2002-12-17 00:08:49 +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
Mike Silbersack
26c138c5e2 Add some magic bits necessary to turn the transmitter on for some
(newer) 556B chips.

Requested & tested by:	Dinesh Nambisan <dinesh@nambisan.net>
Magic bits found by:	Dave Dribin & Donald Becker

MFC After:	3 days
2002-10-22 02:33:50 +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
Mike Silbersack
f8f4148236 Remove all DELAY(1) calls around MII operations in the XL driver.
According to the MII specification, the delay produced by our
reads alone are sufficient for correct operation.

This reduces the time mii_tick takes from 10ms to ~1ms here.  That's
still a lot, but much better than before.

Submitted by:	Harti Brandt <brandt@fokus.gmd.de>
MFC after:	3 weeks
2002-09-22 04:48:30 +00:00
Bernd Walter
82026026e0 add missing \n to printf
Approved by:	gallatin (mentor)
2002-09-09 17:39:48 +00:00
Alfred Perlstein
8e708563c7 style: put return types on a line by themselves. 2002-08-24 00:02:03 +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
dcf11ee64e Fix a problem where stats overflow interrupts would cause
a major slowdown, and re-enable stats overflow interrupts.

For future reference, the bug was in our code, and not
some bug in the 3com chips.

Reviewed by:	wpaul
MFC after:	2 days
2001-12-17 22:24:19 +00:00