Commit Graph

134 Commits

Author SHA1 Message Date
Peter Wemm
6481f3012e Fix (again) some blatent style bugs in DEVICE_POLLING code. 2001-12-15 02:41:52 +00:00
Luigi Rizzo
e4fc250c15 Device Polling code for -current.
Non-SMP, i386-only, no polling in the idle loop at the moment.

To use this code you must compile a kernel with

        options DEVICE_POLLING

and at runtime enable polling with

        sysctl kern.polling.enable=1

The percentage of CPU reserved to userland can be set with

        sysctl kern.polling.user_frac=NN (default is 50)

while the remainder is used by polling device drivers and netisr's.
These are the only two variables that you should need to touch. There
are a few more parameters in kern.polling but the default values
are adequate for all purposes. See the code in kern_poll.c for
more details on them.

Polling in the idle loop will be implemented shortly by introducing
a kernel thread which does the job. Until then, the amount of CPU
dedicated to polling will never exceed (100-user_frac).
The equivalent (actually, better) code for -stable is at

	http://info.iet.unipi.it/~luigi/polling/

and also supports polling in the idle loop.

NOTE to Alpha developers:
There is really nothing in this code that is i386-specific.
If you move the 2 lines supporting the new option from
sys/conf/{files,options}.i386 to sys/conf/{files,options} I am
pretty sure that this should work on the Alpha as well, just that
I do not have a suitable test box to try it. If someone feels like
trying it, I would appreciate it.

NOTE to other developers:
sure some things could be done better, and as always I am open to
constructive criticism, which a few of you have already given and
I greatly appreciated.
However, before proposing radical architectural changes, please
take some time to possibly try out this code, or at the very least
read the comments in kern_poll.c, especially re. the reason why I
am using a soft netisr and cannot (I believe) replace it with a
simple timeout.

Quick description of files touched by this commit:

sys/conf/files.i386
        new file kern/kern_poll.c
sys/conf/options.i386
        new option
sys/i386/i386/trap.c
        poll in trap (disabled by default)
sys/kern/kern_clock.c
        initialization and hardclock hooks.
sys/kern/kern_intr.c
        minor swi_net changes
sys/kern/kern_poll.c
        the bulk of the code.
sys/net/if.h
        new flag
sys/net/if_var.h
        declaration for functions used in device drivers.
sys/net/netisr.h
        NETISR_POLL
sys/dev/fxp/if_fxp.c
sys/dev/fxp/if_fxpvar.h
sys/pci/if_dc.c
sys/pci/if_dcreg.h
sys/pci/if_sis.c
sys/pci/if_sisreg.h
        device driver modifications
2001-12-14 17:56:12 +00:00
Jonathan Lemon
001cfa9228 Tone down and remove some obnoxious warnings that are slightly overkill. 2001-12-13 16:13:31 +00:00
Jonathan Lemon
d9cdd9607f Emit a warning if the mbuf or mbuf cluster allocation failed.
Requested by: Mike Barcroft
2001-11-02 05:10:40 +00:00
Jonathan Lemon
208b417fd5 Aargh. I really shouldn't do late night commits. Remove a floating point
multiply, and replace it with a close equivalent.  1.488 =~ 1.5
2001-10-25 19:36:44 +00:00
Jonathan Lemon
72a32a26aa Add support for loadable microcode which implements interrupt coalescing
and packet bundling.  Make the microcode settings controllable via sysctl
and loader tunables.

Submitted by: Marko Zec <zec@tel.fer.hr>
  (with some munging and dynamic sysctl support by me)

Also extend the workaround for Dynamic Standby mode to later '559 chips,
not just the ICH2 variants.
2001-10-25 05:32:01 +00:00
Jonathan Lemon
9a7a8c90d1 . Add structure elements for sysctl.
. Document default values for microcode
2001-10-25 05:27:25 +00:00
Jonathan Lemon
3ceb25205d . Add structure definition for microcode download.
Submitted by: Marko Zec <zec@tel.fer.hr>

  . Add some PCI chip revision entries.
  . Make size of txcb dependent on pointer size rather than arch #define
2001-10-25 05:25:58 +00:00
Jonathan Lemon
b4c45df0a7 Add Intel's loadable microcode to implement receive side bundling.
This is taken verbatim from the Intel's e100-1.6.22 release, with
the addition of their LICENSE file at the top.

Submitted by: Marko Zec <zec@tel.fer.hr>
2001-10-25 05:23:31 +00:00
Brooks Davis
920b58e88f Deconditionalize vlan support. 2001-09-05 23:33:58 +00:00
Jonathan Lemon
00c4116b3e Systems based on the ICH2/ICH2-M chip from Intel have a defect where
the chip can cause a PCI protocol violation in under certain scenarios.
The workaround is to rewrite the EEPROM to disable Dynamic Standby Mode.

Once the EEPROM is rewritten, the system needs to be rebooted in order
to pick up the new settings.

This has been tested on several ICH2/ICH2-M systems, found in 815E based
boards, and usually identified by the presence of the 82562 ET/EM PHY.

Thanks to: Mike Tansca, Paul Saab for samples of the problematic boards.
2001-08-27 16:07:12 +00:00
Jonathan Lemon
48e417eb5a Reset the device's powerstate to d0 when resuming from a suspend
operation, not just when we initally attach to the device.

Submitted by: warner
2001-07-25 18:00:17 +00:00
Jonathan Lemon
74396a0a26 Only turn on MWI if the PCI configuration word indicates that it
is supported, in addition to checking for a valid cacheline size.
Add a missing splx() in fxp_tick that got dropped.

Found by: peter
MFC in: 3 days
2001-07-19 15:48:00 +00:00
Jonathan Lemon
11457bbf08 While in the interrupt loop, check for a bogus interrupt value of 0xff.
This may be returned if the underlying hardware is a pc-card which has
been ejected.

Reviewed by: warner
2001-06-04 22:01:44 +00:00
Jonathan Lemon
2e2b823898 Add workaround for embedded NICs, in particular, the 815E boards.
There appears to be a bug where the chip will lock up when running
in 10Mb/s mode.
2001-05-17 23:50:24 +00:00
Jonathan Lemon
dedabebf33 Use " |= " to enable special media handling for fxp with no MII, instead
of " &= ".  Also change the MII PHY device mask to check the correct bits.

Cookie to:	Andre Albsmeier <andre.albsmeier@mchp.siemens.de>
Pointy hat to:	me
2001-05-15 18:52:40 +00:00
Jonathan Lemon
db1e093307 Remove safety belt that checks for miibus in the config file. This
was only intended for -stable, not -current.
2001-05-13 05:38:59 +00:00
Jonathan Lemon
e8c8b728c7 Add few cosmetic style fixes, and some debug information for SCB timeouts.
Add VLAN support, obtained from Pedro J. Lobo (through Mike Tancsa).
2001-05-13 00:03:39 +00:00
Jonathan Lemon
e310a419c0 Add a few more register definitions. 2001-05-12 23:59:48 +00:00
Jonathan Lemon
3bd07cfd43 Add some performance features to the fxp driver. If the chip is not
a 82557 (e.g.: a newer chip) then:

   + enable MWI, if the PCI configuration indicates the system supports it
   + enable usage of extended TxCB, for better performance
   + enable hardware flow control.  FC frames will be passed up to the
     host only if promiscuous mode is enabled.
2001-03-14 19:50:35 +00:00
Jonathan Lemon
68311a93fb Fix a whitespace bogon.
Pointed out by:  ps
2001-03-12 21:42:45 +00:00
Jonathan Lemon
f7788e8e9f Convert the fxp driver to miibus, which involves ripping out the PHY
logic and media bits.  Support for Intel PHYs can now be found in
dev/mii/inphy.c.

Clean up the driver, and add various 82558 and 82559 specific bits.
2001-03-12 21:30:52 +00:00
Matt Jacob
2a05a4eb2c A better mousetrap: use device hints, as in:
hint.fxp.0.prefer_iomap="1"

to set IO vs. Memory space mapping.
2001-02-27 22:57:32 +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
Matt Jacob
9fa6ccfb5e Allow fxp to configure in I/O space if the user wants it and specifies
an override as a loader settable variable (fxp_iomap). fxp_iomap is
a bitmap of fxp units that should be configured to use PCI I/O space
in stead of PCI Memory space.

Reviewed by:	Kees Jan Koster <dutchman@tccn.cs.kun.nl>, dg@freebsd.org
2001-01-23 23:22:17 +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
8d79969459 Add power state manipulation to the fxp driver. Some people have
claimed that their Intel NIC is comatose after a warm boot from Windoze.
This is most likely due to the card getting put in the D3 state. This
should bring it back to life.
2000-12-18 22:06:12 +00:00
David Malone
7cc0979fd6 Convert more malloc+bzero to malloc+M_ZERO.
Submitted by:	josh@zipperup.org
Submitted by:	Robert Drehmel <robd@gmx.net>
2000-12-08 21:51:06 +00:00
Warner Losh
869975bf96 Make usual 1-line cardbus support modification.
I'm committing this over an Intel PRO-100 CardBus II card.
2000-10-22 06:41:46 +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
Poul-Henning Kamp
db7e3af111 Remove unneeded #include <machine/clock.h> 2000-10-15 14:19:01 +00:00
Chuck Paterson
f59dd3ae6a Make mutex name reflect device driver name.
Destroy mutex when detaching the device.
Submitted by: John Baldwin <jhb@FreeBSD.ORG>
2000-10-13 18:59:29 +00:00
Jason Evans
9a02e8c68f Don't #include <sys/proc.h>, since machine/mutex.h does it now. 2000-09-23 00:01:37 +00:00
Bill Paul
b2f5cb03e7 Add the PCI device ID for the on-board ethernet controllers on the
Intel 815E motherboard, which I believe is an i82562. Seems to work
just fine with the fxp driver.
2000-09-21 20:01:57 +00:00
David Greenman
9492779067 Removed NetBSD support, which bit-rotted long ago.
Changed new SMP locking macros given the new situation.
2000-09-18 21:12:19 +00:00
David Greenman
7d854d93af Added a couple more missing FXP_SPLVAR()'s. 2000-09-17 23:23:22 +00:00
David Greenman
b184b38e2b As a minor optimization, do suspended checking more like it was originally
in the PR - before the while loop.
2000-09-17 23:04:57 +00:00
David Greenman
04ea20fcf4 Added missing FXP_SPLVAR() to fxp_intr(). 2000-09-17 22:59:58 +00:00
David Greenman
2053b07d7e Attempt to replicate the new fxp SMP locking in the changes committed
in the previous (APM suspend/resume) commit.
2000-09-17 22:20:33 +00:00
David Greenman
7dced78a28 Added support for APM suspend/resume.
PR:		18756
Submitted by:	mike ryan <msr@elision.org>, with modifications by me.
2000-09-17 22:12:12 +00:00
Chuck Paterson
87807fded9 Add include of proc.h to make compile without SMP defined. This
change is likely interm, the include happens automagically
when SMP is defined.

Obtained from:	Jason Evans.
2000-09-17 22:01:21 +00:00
Chuck Paterson
0f4dc94cfc Add locking to make able to run without the Giant lock being held. This
is enabling as all entries are still called with Giant being held.
Maintaining compatability with NetBSD makes what should be very simple
kinda ugly.

Reviewed by:	Jason Evans
2000-09-17 13:26:25 +00:00
Bill Paul
069363018f Fix a bug brought to light by the people working on SMPng. I don't quite
understand exactly what it is about SMPng that tickles this bug. What I
do know is that the foo_init() routine in most drivers is often called
twice when an interface is brought up. One time is due to the ifconfig(8)
command calling the SIOCSIFFLAGS ioctl to set the IFF_UP flag, and another
is probably due to the kernel calling ifp->if_init at some point. In any
case, the SMPng changes seem to affect the timing of these two events in
such a way that there is a significant delay before any packets are sent
onto the wire after the interface is first brought up. This manifested
itself locally as an SMPng test machine which failed to obtain an address
via DHCP when booting up.

It looks like the second call to fxp_init() is happening faster now than
it did before, and I think it catches the chip while it's in the process
of dealing with the configuration command from the first call. Whatever
the case, a FXP_CSR_SCB_CNA interrupt event is now generated shortly after
the second fxp_init() call. (This interrupt is apparently never generated
by a non-SMPng kernel, so nobody noticed.)

There are two problems with this: first, fxp_intr() does not handle the
FXP_CSR_SCB_CNA interrupt event (it never tests for it or does anything
to deal with it), and second, the meaning of FXP_CSR_SCB_CNA is not
documented in the driver. (Apparently it means "command unit not active.")
Bad coder. No biscuit.

The fix is to have the FXP_CSR_SCB_CNA interrupt handled just like the
FXP_SCB_STATACK_CXTNO interrupt. This prevents the state machine for
the configuration/RX filter programming stuff from getting wedged for
several seconds and preventing packet transmission.

Noticed by: jhb
2000-08-11 17:47:55 +00:00
Peter Wemm
d244b0e95b "Fix" cast qualifier warnings using the uintptr_t intermediate trick. 2000-07-28 23:30:30 +00:00
Andrew Gallatin
0617522889 Fix an alpha-only race which causes the transmit side of the chip to
lock up under moderate to heavy load.

The status & command fields share a 32-bit longword.  The programming
API of the eepro apparently requires that you update the command field
of a transmit slot that you've already given to the card.  This means
the card could be updating the status field of the same longword at
the same time. Since alphas can only operate on 32-bit chunks of
memory, both the status & command fields are loaded from memory &
operated on in registers when the following line of C is executed:

                sc->cbl_last->cb_command &= ~FXP_CB_COMMAND_S;

The race is caused by the card DMA'ing up the status at just the wrong
time -- after it has been loaded into a register & before it has been
written back.  The old value of the status is written back, clobbering
the status the card just DMA'ed up. The fact that the card has sent
this frame is missed & the transmit engine appears to hang.

Luckily, as numerous people on the freebsd-alpha list pointed out, the
load-locked/store-conditional instructions used by the atomic
functions work with respect changes in memory due to I/O devices.  We
now use them to safely update the command field.

Tested by: Bernd Walter <ticso@mail.cicely.de>
2000-07-19 14:33:52 +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
David Greenman
aed5349598 Implemented some optimizations which result in 14 fewer instructions in the
receive path.
2000-06-19 00:58:34 +00:00
David Greenman
55ce7b5117 Added support for the i82559ER (10/100Mbps NIC for embedded applications).
Product device ID provided by:	Les Biffle <les@ns3.safety.net>
2000-06-18 10:26:09 +00:00