Commit Graph

68 Commits

Author SHA1 Message Date
John Baldwin
99efe4f0f8 Remove ifnet.if_mpsafe for now. If this is needed, it won't be needed
until much later when the network stack locking is farther along.

Approved by:	jlemon
2001-11-14 18:36:37 +00:00
Luigi Rizzo
935fe01014 Enable round-robin arbitration between transmit and receive unit
in the 21143, instead of giving priority to the receive unit.
This gives a 10-15% performance improvement in the forwarding rate
under heavy load.

Reviewed-by: Bill Paul
2001-10-27 00:59:17 +00:00
Luigi Rizzo
617b3dd758 Defs for three (unused so far) bits in PCI command/status register
were off by one bit.
2001-10-25 17:43:26 +00:00
Jonathan Lemon
cd62a9cb38 Do not call mii_pollstat() from within device tick routines; the status
information is updated by mii_tick().

Pointed out by: wpaul (a while back)
2001-09-29 19:28:31 +00:00
Jonathan Lemon
d9730b8b53 Cleanup pass for mii drivers.
. Make internal service routines static.
   . Use a consistent ordering of checks in MII_TICK.  Do the work in the
     mii_phy_tick() subroutine if appropriate.
   . Call mii_phy_update() to trigger the callbacks.
2001-09-29 19:18:52 +00:00
Bill Paul
1af8bec768 Add support for Conexant LANfinity miniPCI controllers. People who have
laptops with this chip should test this and report back as I don't have
access to this hardware myself. People with -stable systems should try
the patch at:

	http://www.freebsd.org/~wpaul/conexant.patch.gz

Submitted by:	Phil Kernick <Phil@Kernick.org>
2001-09-04 17:10:11 +00:00
Bill Paul
e7be9f9a1a Deal with the condition where we lose link in the middle of transmitting
a bunch of frames. In this case, the dc_link flag is cleared, and dc_start()
stops draining the if_snd send queue, which results in lots of 'no buffers
available' errors being reported to applications. The whole idea behind
not draining the send queue until the link comes up was to avoid having
the gratuitous ARP being lost while we're waiting for autoneg to complete
after the interface is first brought up. As an optimization, change the
test in dc_start() so that we only bail if dc_link is not set _and_ there
are less than 10 packets in the send queue. If the queue has many frames
in it, we need to drain them. If the queue has a small number of frames
in it, we can hold off on sending them until the link comes up.

MFC after: 1 week
2001-07-12 22:51:59 +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
John Baldwin
f34fa851e0 Catch up to header include changes:
- <sys/mutex.h> now requires <sys/systm.h>
- <sys/mutex.h> and <sys/sx.h> now require <sys/lock.h>
2001-03-28 09:17:56 +00:00
Bill Paul
d467c136d0 Apply patch to allow TX underrun handling without issuing a complete
chip reset. Just temporarily turn off the transmitter instead.

Submitted by:	Stephen McKay <mckay@freebsd.org>
2001-02-22 19:26:55 +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
Warner Losh
d2a1864b0a Take luigi's suggestion and move the check for nothing to do to before the
lock so we don't have lots of null lock/release pairs.
2001-02-20 04:43:59 +00:00
Warner Losh
0aa477423a Add DC_UNLOCK before first return. This caused returns when dc was on
a shared interrupt.

Pointed out by tegge.
2001-02-20 04:21:27 +00:00
Luigi Rizzo
d88a358c86 Add a check in the interrupt service routine to return quickly in
case there is nothing to do. This happens normally when the card shares
the interrupt line with other devices.

This code saves a couple of microseconds per interrupt even on a
fast CPU. You normally would not care, except under heavy tinygram
traffic where you can have some 50-100.000 interrupts per second...

On passing, correct a spelling error.
2001-02-18 07:21:28 +00:00
Bosko Milekic
9ed346bab0 Change and clean the mutex lock interface.
mtx_enter(lock, type) becomes:

mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks)
mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized)

similarily, for releasing a lock, we now have:

mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN.
We change the caller interface for the two different types of locks
because the semantics are entirely different for each case, and this
makes it explicitly clear and, at the same time, it rids us of the
extra `type' argument.

The enter->lock and exit->unlock change has been made with the idea
that we're "locking data" and not "entering locked code" in mind.

Further, remove all additional "flags" previously passed to the
lock acquire/release routines with the exception of two:

MTX_QUIET and MTX_NOSWITCH

The functionality of these flags is preserved and they can be passed
to the lock/unlock routines by calling the corresponding wrappers:

mtx_{lock, unlock}_flags(lock, flag(s)) and
mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN
locks, respectively.

Re-inline some lock acq/rel code; in the sleep lock case, we only
inline the _obtain_lock()s in order to ensure that the inlined code
fits into a cache line. In the spin lock case, we inline recursion and
actually only perform a function call if we need to spin. This change
has been made with the idea that we generally tend to avoid spin locks
and that also the spin locks that we do have and are heavily used
(i.e. sched_lock) do recurse, and therefore in an effort to reduce
function call overhead for some architectures (such as alpha), we
inline recursion for this case.

Create a new malloc type for the witness code and retire from using
the M_DEV type. The new type is called M_WITNESS and is only declared
if WITNESS is enabled.

Begin cleaning up some machdep/mutex.h code - specifically updated the
"optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN
and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently
need those.

Finally, caught up to the interface changes in all sys code.

Contributors: jake, jhb, jasone (in no particular order)
2001-02-09 06:11:45 +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
Bill Paul
c85c46678d Silence compiler warnings. 2001-01-20 00:07:49 +00:00
Bill Paul
419146d944 Bug fixes that I've put together while working on a project in the office:
if_vr: handle the case where vr_encap() returns failure: bust out of the
       packet sending loop instead of panicking. Also add some missing
       newlines to some printf()s.

if_dc: The miibus_read and miibus_write methods keep swapping in and
       out of MII mode by fiddling with CSR6 for cards with MII PHYs.
       This is a hack to support the original Macronix 98713 card which
       has built-in NWAY that uses an MII-like management interface
       even though it uses serial transceivers. Conditionalize this
       so that we only do this on 98713 chips, since it does bad things
       to genuine tulip chips (and maybe other clones).
2001-01-19 23:55:07 +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
Jonathan Lemon
b50c63121d Change the driver to allocate its own callout structure, and modify
the interface to use callout_* instead of timeout().  Also add an
IS_MPSAFE #define (currently off) which will mark the driver as mpsafe
to the upper layers.
2000-11-25 08:00:10 +00:00
Bill Paul
fa167b8eaa Add support for the Accton EN2242 MiniPCI adapter. This is just an
ADMtek Centaur chip, so all we need is the PCI ID.

Submitted by:	Scott Lang <scottl@FreeBSD.org>
2000-11-14 19:35:22 +00:00
Bill Paul
3019f2bf08 Grrrr. Remember to bzero() the mediainfo structures after we allocate
them. If we leave garbage in them, the dc_apply_fixup() routine may
try to follow bogus pointers when applying the reset fixup.

Noticed by: Andrew Gallatin
2000-11-03 00:03:03 +00:00
Bill Paul
e99285a4f7 Call dc_apply_fixup() in dc_setcfg() for the MII case. 2000-10-31 00:06:39 +00:00
Bill Paul
5d801891d3 Grrr. The 'reg' variable in dc_apply_fixup() needs to be a u_int32_t, not
a u_int8_t. Pass the conical hat. This should fix certain cardbus 21143
cards that require SROM h0h0magic in order to enable their transceivers.
2000-10-30 23:51:39 +00:00
Peter Wemm
41fced74eb Fix typo s/DE_DEVICEID_FE2500/DC_DEVICEID_FE2500/ 2000-10-28 10:03:54 +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
Bill Paul
0a46b1dccc Yet another bug fix/optimization for the Davicom DM9100/9102: increase
the PCI latency timer value to 0x80. Davicom's Linux driver does this,
and it drastically reduces the number of TX underruns in my tests. (Note:
this is done only for the Davicom chips. I'm not sure it's a good idea to
do it for all of them.)

Again, still waiting on confirmation before merging to stable.
2000-10-27 00:15:04 +00:00
Bill Paul
318a72d7b0 Set the DC_TX_INTR_ALWAYS and DC_TX_STORENFWD flags for the Davicom
DM9100/DM9102 chips. Do not set DC_TX_ONE. The DC_TX_USE_TX_INTR flag
causes dc_encap() to set the 'interrupt on TX completion' bit only
once every 64 packets. This is an attempt to reduce the number
of interrupts generated by the chip. You're supposed to get a 'no more
TX buffers left' interrupt once you hit the last packet whether you
ask for one or not, however it seems the Davicom chip doesn't generate
this interrupt, or at least it doesn't generate it under the same
circumstances. The result is that if you transmit n packets, where
n is less than 64, and then wait 5 seconds, you'll get a watchdog
timeout whether you want one or not. The DC_TX_INTR_ALWAYS causes
dc_encap() to request an interrupt for every frame.

I'm still waiting on confirmation from a couple of users to see if this
fixes their problems with the Davicom DM9102 before I merge this into
-stable, but this fixed the problem for me in my own testing so I'm
willing to make the change to -current right away.
2000-10-25 23:46:31 +00:00
John Baldwin
35e0e5b311 Catch up to moving headers:
- machine/ipl.h -> sys/ipl.h
- machine/mutex.h -> sys/mutex.h
2000-10-20 07:58:15 +00:00
John Baldwin
36f8814a83 Remove unnecessary machine/mutex.h include. 2000-10-20 07:54:21 +00:00
Jonathan Chen
feb78939ee NEWCARD/Cardbus -
This commit adds support for Xircom X3201 based cardbus cards.
Support for the TDK 78Q2120 MII is also added.
IBM Etherjet, Intel and Xircom cards uses these chips.

Note that as a result of this commit, some Intel/DEC 21143 based cardbus
cards will also attach, but not get link.  That is being looked at.
2000-10-19 08:34:32 +00:00
Poul-Henning Kamp
db7e3af111 Remove unneeded #include <machine/clock.h> 2000-10-15 14:19:01 +00:00
Bill Paul
4c2efe270a Clean up a few things in dc_setcfg() pointed out to be me by
aaron@openbsd.com on IRC earlier today.
2000-10-14 00:40:14 +00:00
Bill Paul
d308faacc2 Add #include <machine/mutex.h> since these files need it and don't
include anything else that includes mutex.h. Needed to resolve struct mtx
from struct dc_softc.
2000-10-13 19:15:50 +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
Bill Paul
5c1cfac46e Add support for parsing the media blocks from the SROM on 21143
adapters. This is necessary in order to make this driver work with
the built-in ethernet on the alpha Miata machines. These systems
have a 21143-PC chip on-board and optional daughtercards with either
a 10/100 MII transceiver or a 10baseT/10base2 transceiver. In both
cases, you need to twiddle the GPIO bits on the controller in order
to turn the transceivers on, and you have to read the media info
from the SROM in order to find out what bits to twiddle.
2000-10-05 17:36:14 +00:00
Bill Paul
857fd445c3 If this is a Davicom DM9102A and we're enabling the homePNA link, force
dc_link to 1 and don't activate the tick routine. Without this, dc_start()
always thinks the link is down and never transmits in homePNA mode.
2000-09-20 00:59:17 +00:00
Bill Paul
78999dd117 Special-case the LED twiddling code so that it doesn't do anything
on the NEC VersaPro NoteBook PC. This 21143 implementation has no LEDs,
and flipping the LED control bits somehow stops it from establishing
a link. We check the subsystem ID and don't flip the LED control
bits for the NEC NIC.
2000-09-07 18:51:04 +00:00
Bill Paul
21aff61248 Define some more bits in CSR15 needed for previous change. 2000-09-02 00:02:51 +00:00
Bill Paul
918434c883 Make the blinkylights on non-MII 21143 cards work. We need to enable
the link and activity LED control bits in CSR15 in order for the
controller to drive the LEDs correctly. This was largely done for the
ZNYX multiport cards, but should also work with the DEC DE500-BA
and other non-MII cards.
2000-09-01 23:59:54 +00:00
Bill Paul
bf64541762 Close PR 20438. Make fix for preserving LED settings conditional on
presence Intel 21143 chip.
2000-08-07 17:03:20 +00:00
Bill Paul
c400cb27d2 Grrrr. Add definition for DC_WDOG_CTLWREN. I made this change yesterday
but stupidly only commited to if_dc.c.
2000-08-02 16:31:11 +00:00
Bill Paul
8273d5f8b1 Apply patch supplied by John Hood <jhood@sitaranetworks.com> to fix problems
with LEDs on some cards being stomped on when clearing the "jabber disable"
bit. Using DC_SETBIT() has an unwanted side effect of setting a write enable
bit in the watchdog timer register which we really want to be cleared when
we do a write.
2000-08-01 19:34:13 +00:00
Bill Paul
ead7cde9d1 Add the PCI IDs for the Macronix 98727 and 98732 parts. These are
3.3volt PCI/cardbus chipsets similar to the 98715 (and they have
512-bit hash tables). Also update the man page to mention the 98727/98732
and the SOHOware SFA110A Rev B4 card with the 98715AEC-C chip.
2000-07-17 19:27:41 +00:00
Bill Paul
79d11e0960 Apply patch to the dc driver to handle Macronix MX98715AEC-C/D/E chips,
which differ slightly from the Macronix MX98715AEC chip on the sample
adapter that I have in that the multicast hash table is only 128 bits
wide instead of 512. New adapters are popping up with this chip, and
due to improper handling of the smaller hash table, broadcast packets
were not being received correctly.
2000-07-15 17:54:30 +00:00