Commit Graph

358 Commits

Author SHA1 Message Date
Robert Watson
13b203d0d7 Modify device drivers supporting multicast addresses to lock if_addr_mtx
over iteration of their multicast address lists when synchronizing the
hardware address filter with the network stack-maintained list.

Problem reported by:	Ed Maste (emaste at phaedrus dot sandvine dot ca>
MFC after:		1 week
2005-08-03 00:18:35 +00:00
Maxime Henrion
86c8aacb07 Add a new PCI id for fxp(4) cards found on ICH7-based systems.
This commit is a RELENG_6 candidate.

Submitted by:	Martin Nilsson <martin@gneto.com>
2005-07-29 22:40:06 +00:00
Brooks Davis
7ba33d8222 Move if_alloc() up in fxp_attach() so there's an ifp before
mii_phy_probe() is called.

Committed via:	fxp0
2005-06-11 00:47:34 +00:00
Wes Peters
1026fbd360 Avoid deadlock in fxp driver when system runs out of mbufs.
MFC after:	1 week
Provided by:	Ernie Smallis <esmallis@stbernard.com>
2005-06-10 23:54:52 +00:00
Brooks Davis
1b5a39d368 Revert the unnecessicary addition of some braces in fxp_attach(). Don't
explicitly free the ifp in fxp_detach(), the call to fxp_release() takes
care of it.
2005-06-10 20:42:02 +00:00
Brooks Davis
fc74a9f93a Stop embedding struct ifnet at the top of driver softcs. Instead the
struct ifnet or the layer 2 common structure it was embedded in have
been replaced with a struct ifnet pointer to be filled by a call to the
new function, if_alloc(). The layer 2 common structure is also allocated
via if_alloc() based on the interface type. It is hung off the new
struct ifnet member, if_l2com.

This change removes the size of these structures from the kernel ABI and
will allow us to better manage them as interfaces come and go.

Other changes of note:
 - Struct arpcom is no longer referenced in normal interface code.
   Instead the Ethernet address is accessed via the IFP2ENADDR() macro.
   To enforce this ac_enaddr has been renamed to _ac_enaddr.
 - The second argument to ether_ifattach is now always the mac address
   from driver private storage rather than sometimes being ac_enaddr.

Reviewed by:	sobomax, sam
2005-06-10 16:49:24 +00:00
Warner Losh
67ba65663f Correct comment 2005-06-06 03:22:51 +00:00
Brooks Davis
e904a5aa62 Remove some variables the last commit stopped using so the code compiles. 2005-06-06 02:12:12 +00:00
Warner Losh
95af165d7f The PCI bus code saves/restores these config registers now. 2005-06-05 22:50:55 +00:00
Maxime Henrion
507feeafad Be more conservative when enabling extended features. There are fxp(4)
NICs out there that have an utterly bogus revision ID.

Reported by:	Denis Shaposhnikov <dsh@vlink.ru>
2005-04-22 13:05:53 +00:00
Maxime Henrion
de57160389 Add a microcode to implement receive bundling for 82551 chipsets with
a revision ID of 0x0f (D102 E-step).

MFC after:	2 weeks
Tested by:	pav
2005-04-21 19:34:57 +00:00
Maxime Henrion
647ec60cc7 Enable extended RFDs and TCBs, and thus checksum offloading, for
latest 82550 and 82551 chipsets (revision IDs 0x0e, 0x0f and 0x10).
We were only enabling it for revisions 0x0c and 0x0d, now it's
enabled for any 8255x NIC with a revision ID bigger than 0x0c.  It
should be safe, and this is what Intel does in their open source
driver.

MFC after:	2 weeks
Tested by:	Pavel Lobach lobach_pavel at mail dot ru
2005-04-21 13:27:38 +00:00
Maxime Henrion
c4bf1e9092 Unload and destroy the TX DMA maps before destroying the DMA tag
they're attached to, not after.

Spotted by:	Coverity via sam
2005-03-16 16:39:04 +00:00
Maxime Henrion
40c20505a8 - Encapsulate the code responsible for initializing a new TX descriptor
from an mbuf into the fxp_encap() function, as done in other drivers.
- Don't waste time calling bus_dmamap_load_mbuf() if we know the mbuf
  chain is too long to fit in a TX descriptor, call m_defrag() first.
- Convert fxp(4) to use bus_dmamap_load_mbuf_sg().
2005-03-07 13:20:49 +00:00
Maxime Henrion
74d1ed239b Cleanup: u_intXX_t -> uintX_t conversion. 2005-03-06 05:07:26 +00:00
Warner Losh
538565c4a5 Use BUS_PROBE_DEFAULT for pci probe return value 2005-03-05 18:30:12 +00:00
Maxime Henrion
29a8929dfa Add support for fxp(4) cards found in Sony FS570 laptops.
Submitted by:	Gavin Atkinson <gavin.atkinson@ury.york.ac.uk>
2005-03-05 13:52:28 +00:00
Maxime Henrion
6720ebcc9f Fix the panic recently reported on -current@ occuring when configuring
a vlan interface attached to a fxp(4) card when it has not been
initialized yet.  We now set the links from our internel TX descriptor
structure to the TX command blocks at attach time rather than at init
time.  While I'm here, slightly improve the style in fxp_attach().

PR:		kern/78112
Reported by:	Gavin Atkinson <gavin.atkinson@ury.york.ac.uk> and others
Tested by:	flz, Gavin Atkinson <gavin.atkinson@ury.york.ac.uk>
MFC after:	1 week
2005-03-03 00:22:59 +00:00
Maxime Henrion
93b6e2e6ff Fix a stupid bogon from myself, sc->revision wasn't initialized when
testing it to know whether we should enable the 82503 serial mode...
Move code to the right location and disallow the use of the 82503
serial mode if the sc->revision field is 0 again.  This makes fxp(4)
work correctly with ATMEL 350 93C46 cards (3 port 82559 based with a
82555 PHY), as well as with the older ATMEL 220 93C46 (same flavour)
and with the even older 10Mbps-only 82557 cards with the 82503 serial
interface.

Tested by:	Andre Albsmeier <andrer@albsmeier.net>, krion
MFC after:	2 weeks
2005-02-27 15:12:50 +00:00
Ruslan Ermilov
7b6fe3a4c2 Remove an outdated comment about ifnet not being locked.
OK'ed by:	njl, rwatson, sam
2005-02-15 17:47:57 +00:00
Robert Watson
03edfff39a Disable ethernet flow control in if_fxp by default, in order to prevent
unexpected surprises when a system panics or is left in the debugger.

Requested by:	kris
MFC after:	3 days
2005-01-29 23:13:20 +00:00
Warner Losh
098ca2bda9 Start each of the license/copyright comments with /*-, minor shuffle of lines 2005-01-06 01:43:34 +00:00
Maxime Henrion
778ee7be10 Allow fxp(4) cards with a revision id of 0 to use the 82503 serial
interface as well.  This is not an expected revision id per the
datasheet, but unfortunately there are such cards out there with
a 82557 chipset, and they want to use the 82503.

PR:		kern/75739
Reported by:	Andre Albsmeier <andre.albsmeier@siemens.com>
2005-01-04 19:30:14 +00:00
Maxime Henrion
4ed53076ed Only try to use the 82503 serial interface for the 82557 chipsets. The
datasheet says it is only valid for such chipsets and shouldn't be used
with others.  This fixes some 82559 based cards which otherwise only
work at 10Mbit.

MFC after:	5 days
Tested by:	krion
2004-12-20 10:18:21 +00:00
Pyun YongHyeon
94a4f968c1 Make interrupt coalescing work on big endian systems.
Also change struct ucode.length to be in number of elements (u_int32_t)
to help endian handling.

MFC after:	2 weeks
2004-11-17 04:25:10 +00:00
Maxime Henrion
048ca166ff Add support for the fxp(4) based card in ICH6 (i915) chipsets.
This is a RELENG_5 candidate.

Submitted by:	Mike Tancsa <mike@sentex.net>
2004-09-18 19:13:13 +00:00
Don Lewis
414ce15cb3 Deorbit the fxp tuning hint (hint.fxp.UNIT_NUMBER.ipcbxmit_disable)
introduced in if_fxp.c revision 1.180.  The bug fix committed in
revision 1.180 fixed the packet truncation problem.
2004-08-11 21:41:25 +00:00
Max Laier
7929aa036c Bring in the first chunk of altq driver modifications. This covers the
following drivers: bfe(4), em(4), fxp(4), lnc(4), tun(4), de(4) rl(4),
sis(4) and xl(4)

More patches are pending on: http://peoples.freebsd.org/~mlaier/ Please take
a look and tell me if "your" driver is missing, so I can fix this.

Tested-by:	many
No-objection:	-current, -net
2004-07-02 12:16:02 +00:00
Warner Losh
794950069f Remove the setting of the pci config variables on power state changes.
The bus does this now.
2004-06-28 20:26:21 +00:00
Maxime Henrion
67fc050f0c Abstract the locking in fxp(4) a bit more by using macros for
mtx_assert() and mtx_owned(), as it is done in other places,
for instance proc locking.
2004-06-02 22:59:57 +00:00
Maxime Henrion
0f1db1d60f Use the device sysctl tree instead of rolling our own. Some of the
sysctls were global (hw.fxp_rnr and hw.fxp_noflow), all of them are
now per-device.  Sample output of "sysctl dev.fxp0" with this patch,
with the standard %foo nodes removed :

dev.fxp0.int_delay: 1000
dev.fxp0.bundle_max: 6
dev.fxp0.rnr: 0
dev.fxp0.noflow: 0
2004-06-02 22:52:18 +00:00
Poul-Henning Kamp
fe12f24bb0 Add missing <sys/module.h> includes 2004-05-30 20:08:47 +00:00
Yaroslav Tykhiy
44e0bc11b9 POLA dictates that VLAN_MTU be enabled by default.
In particular, disabling it was likely to break configurations
involving ng_vlan(4) since the latter couldn't control
the parent's VLAN_MTU in the way vlan(4) did.

Pointed out by:	ru
2004-05-27 14:36:58 +00:00
Pawel Jakub Dawidek
50a33b6aaa Those sysctls shouldn't be writtable from inside a jail. 2004-05-26 23:03:27 +00:00
Yaroslav Tykhiy
8ef1f631f6 Teach fxp(4) to control VLAN_MTU in the hardware.
Now reception of extended frames can be toggled
through ioctl(SIOCSIFCAP).

The card will also receive extended frames when
in promiscuous mode.
2004-05-25 14:49:46 +00:00
Maxime Henrion
670f5d73a0 Change a if (...) panic() to a KASSERT(). 2004-05-24 18:31:56 +00:00
Yaroslav Tykhiy
25fbb2c38c A handler for ioctl(SIOCSIFCAP) should not alter a bit in
if_capenable unless the interface driver is actually able
to toggle the respective capability on and off.

Reviewed by:	ru
2004-05-23 21:05:08 +00:00
Maxime Henrion
866a788cc2 We don't need to initialize if_output, ether_ifattach() does it
for us.
2004-05-23 16:11:53 +00:00
Yaroslav Tykhiy
5fe9116b72 Cosmetic:
Set capability bits in a consistent way.
Add a comment on why the VLAN_MTU stuff comes after ether_ifattach().
2004-05-21 20:34:04 +00:00
Yaroslav Tykhiy
21ce2bf290 The driver fxp(4) has reception of large frames enabled hardcodedly,
so let VLAN_MTU be marked in if_capenable from the beginning.
2004-05-21 18:11:38 +00:00
Ruslan Ermilov
fb9172265b Implemented per-interface polling(4) control. 2004-04-11 15:35:49 +00:00
Warner Losh
c2b37819e4 Add new ID for Intel 82562ET (ICH5/ICH5R) Pro/100 VE Ethernet.
Submitted by: Stefan Bethke
PR: 61320
2004-04-07 15:47:14 +00:00
Nate Lawson
5f96beb9e0 Convert callers to the new bus_alloc_resource_any(9) API.
Submitted by:	Mark Santcroos <marks@ripe.net>
Reviewed by:	imp, dfr, bde
2004-03-17 17:50:55 +00:00
David E. O'Brien
f7d39bdcb6 Adjust $FreeBSD$'s. 2004-03-17 03:43:53 +00:00
Matthew N. Dodd
e3bbbec2ca Announce ethernet MAC addresss in ether_ifattach(). 2004-03-14 07:12:25 +00:00
Warner Losh
347934fa63 Sometimes cardbus attachments don't attach, so while we track down
this problem put these lines back in.  While they should be
unnecessary, they appear to be sometimes necessary.

Reviewed in concept: dfr
Approved by: re (scottl@)
2003-11-28 05:28:29 +00:00
Doug Rabson
0be389f3ca Remove explicit cardbus attachments from drivers where this is identical
to the pci attachment. Cardbus is a derived class of pci so all pci
drivers are automatically available for matching against cardbus devices.

Reviewed by: imp
2003-11-03 09:22:18 +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
Brooks Davis
083fbfa64a Remove unused FXP_UNIT() macro. 2003-10-30 23:12:24 +00:00
Sam Leffler
b237430cfe mark interrupt handlers MPSAFE 2003-10-29 18:32:14 +00:00
Sam Leffler
45276e4aa4 change timeout to be MPSAFE
Sponsored by:	FreeBSD Foundation
2003-09-05 22:37:31 +00:00
John Baldwin
e27951b29c Use PCIR_BAR(x) instead of PCIR_MAPS.
Glanced over by:	imp, gibbs
Tested by:		i386 LINT
2003-09-02 17:30:40 +00:00
David E. O'Brien
aad970f1fe Use __FBSDID().
Also some minor style cleanups.
2003-08-24 17:55:58 +00:00
Warner Losh
4fbd232c86 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 05:54:52 +00:00
John Polstra
f19fc5d8b3 Use the revision ID from PCI configuration space to identify Intel
8255x chips more precisely.  The information was obtained from Intel's
Open Source Software Developer Manual for the 8255x.

MFC after:	1 day
2003-08-04 00:17:16 +00:00
Maxime Henrion
aafb3ebbe3 Use the BUS_DMA_ZERO flag. 2003-07-27 14:00:02 +00:00
Maxime Henrion
28935f2753 De-inline some functions. It doesn't gain us anything and bloats
code size by 3616 bytes.  Furthemore, it was previously ignored by GCC.

While I'm at it, fix some bogus comments.
2003-07-22 15:50:54 +00:00
John Baldwin
c660bdfa66 Unlock the fxp driver lock before calling fxp_poll() to avoid recursing on
the lock when using DEVICE_POLLING.

Tested by:	Robin P. Blanchard <Robin.Blanchard@gactr.uga.edu>
Reviewed by:	njl
2003-07-11 20:49:36 +00:00
Warner Losh
fa4b32fa80 All current uses of pci_set_powerstate are bogus, at least in theory.
However, they are presently necessary due to bigger bogusness in the
pci bus layer not doing the right thing on suspend/resume or on
initial device probe.  This is exactly the sort of thing that the
BURN_BRIDGES option was invented for.  Mark all of them as
BURN_BRIDGES.  As soon as I have the powerstate stuff properly
integrated into the pci bus code, I intend to remove all these
workarounds.
2003-07-03 14:00:57 +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
Nate Lawson
05fb8c3f73 Drop locks before calling if_input() since it may re-enter fxp_start()
in the netisr case. This would result in a lock reversal.  This
fixes the net.isr.enable=1 case.  Better performance might be
obtained by chaining all packets received, dropping the lock, and
then calling if_input() on each one.

Reported by:	hmp
2003-06-23 23:23:49 +00:00
Maxime Henrion
62c0d1bf0e Add a new device ID.
Submitted by:	Tom Alsberg <alsbergt@cs.huji.ac.il>
2003-06-12 11:21:06 +00:00
Mike Silbersack
1104779b70 Replace if_fxp's handrolled defrag function with m_defrag.
No actual bug with the existing code, just tidying things up.

Submitted by:	hmp
2003-06-02 05:16:42 +00:00
Don Lewis
a35e7eaa1a Always set the hardware parse bit in the IPCB structure when this
structure, which is new to the 82550 and 82551, is used to transmit
a packet.  This appears to fix the packet truncation problem that was
observed when using 82550-based fxp cards to transmit ICMP or fragmented
UDP packets of certain lengths which only had one to three bytes in the
second and final mbuf of the packet.  This matches a note in the "Intel
8255x 10/100 Mbps Ethernet Controller Family Open Source Software Developer
Manual", which says that the hardware parse bit should be set when sending
these types of packets.

There have also been unconfirmed reports of similar problems when
transmitting TCP packets, which should not be affected by the above
mentioned change because the hardware parse bit was already being set
if the stack requested hardware checksumming of the packet.  If the
problem remains, the use of the IPCB structure can be disabled to
cause the driver to fall back to using the older 82559 interface with
82550-based cards by setting
        hint.fxp.UNIT_NUMBER.ipcbxmit_disable
to a non-zero value at boot time, or using kenv to set this variable
before using kldload to load the fxp driver.

Approved by:	re (jhb)
2003-05-25 05:04:26 +00:00
Robert Watson
98b2788832 Add a tunable/sysctl "hw.fxp_noflow" which disables flow control support
on if_fxp cards.  When flow control is enabled, if the operating system
doesn't acknowledge the packet buffer filling, the card will begin to
generate ethernet quench packets, but appears to get into a feedback
loop of some sort, hosing local switches.  This is a temporary workaround
for 5.1: the ability to configure flow control should probably be
exposed by some or another management interface on ethernet link layer
devices.

Approved by:	re (bmah)
Reviewed by:	mux
2003-05-16 01:13:16 +00:00
Maxime Henrion
4d340ec485 GCC 3.3 complains about anonymous structures in unions, so
give the fxp_ipcb structure a name in the fxp_rfa structure.

Submitted by:	peter
Approved by:	re (jhb)
2003-05-14 20:33:41 +00:00
Maxime Henrion
72490791a8 Fix the unaligned access problems that some people saw on alpha
by using a __packed keyword for the fxp_rfa structure.  The Intel
guys who designed this structure with unaligned fields deserve
to be shot.

Tested by:	kris
Approved by:	re@ (jhb)
2003-05-12 18:15:33 +00:00
Warner Losh
1d2945d595 Fix tpyo in last commit.
Noticed by: kuriyama-san
2003-04-30 04:14:56 +00:00
Warner Losh
704d196541 Get rid of the redundant 'gone' field, and overload suspend instead.
Check for suspend before the device polling, rather than after it.
Check to see if the current thread owns the lock in ioctl and return
EBUSY if it does.

This advances the locking to the point that I can eject my fxp card 10
times in a row, but I agree with Jeff Hsu that we need to get the
network layer locking finished before chasing more of the races here
(actually, he doesn't think this set is worth it even).  There's a
number of races between FXP_LOCK in detach and all other users of
FXP_LOCK, and this gets back to the 'device with sleepers being
forcibly detached' problem as well...
2003-04-30 01:54:38 +00:00
Warner Losh
7634f08a29 (5) from last commit was omitted by mistake:
(5) Return immediately from fxp_intr() if gone is set.
2003-04-29 05:47:14 +00:00
Warner Losh
32cd7a9c00 Fix 5 bugs:
1) always call fxp_stop in fxp_detach.  Since we don't read from
	   the card, there's no need to carefully look at things with
	   bus_child_present.
	2) Call FXP_UNLOCK() before calling bus_teardown_intr to avoid
	   a possible deadlock reported by jhb.
	3) add gone to the softc.  Set it to true in detach.
	4) Return immediately if gone is true in fxp_ioctl
	5) Return immediately if gone is true in fxp_intr
2003-04-29 05:45:09 +00:00
Nate Lawson
4953bccacf Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
  then call fxp_start_body().  Places that would call fxp_start() with
  locks held (mutex recursion) now call fxp_start_body() directly.
  Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
  hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
  part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
  fxp_detach().  This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
  media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
  fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
  it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.

Ideas from:	gallatin, mux
Tested by:	>400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
Maxim Sobolev
2bce79a21d Update comment to match reality. 2003-04-16 09:16:55 +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
Maxim Sobolev
cf0d8a1e48 Use pci_enable_{busmaster|io}() instead of directly writing into
PCI configuration register.

Submitted by:	mdodd
2003-04-14 15:50:04 +00:00
Maxim Sobolev
bb342a3713 Before attaching device set PCIM_CMD_PORTEN in addition to
PCIM_CMD_MEMEN and PCIM_CMD_BUSMASTEREN, becaise some braindead
BIOSes (such as one found in my vprmatrix notebook) forget
to initialize it properly resulting in attachment failure.
2003-04-14 09:45:25 +00:00
Maxime Henrion
20f0c80f6f - Call ether_ifdetach() before shutting down the hardware.
- Remove a useless device_is_alive() check.
- Disable interrupts if bus_child_present() so that this
  check is more useful.

This fixes the hangs I was seeing when unloading the fxp driver.

Suggestions from:	hsu, njl
2003-04-11 12:52:52 +00:00
Maxime Henrion
b983c7b3ed - Clean up the fxp_release() and fxp_detach() functions.
- Be sure to teardown the interrupt first so that "kldunload if_fxp"
  doesn't panic the box.  It's now deadlocking rather than crashing,
  which isn't really better, but I'm unsure this is fxp(4)'s fault.
- Change a bus_dmamap_sync() call to also do a BUS_DMASYNC_PREREAD
  now that we can pass several operations.
2003-04-10 23:15:12 +00:00
Maxime Henrion
209b07bc4c - Pass a busdma tag and a busdma map to fxp_dma_wait() so that
it can do the necessary bus_dmamap_sync() calls.
- While I'm here, reorder arguments to match other functions.
2003-04-08 18:56:45 +00:00
Maxime Henrion
14fd107181 Add an XXX comment for the atomic operation in the __alpha__
case so that it doesn't confuse more people.  Use the more
correct atomic_clear_16() instead of atomic_clear_short().
2003-04-08 18:35:51 +00:00
Maxime Henrion
bafb64af4f - Endian fixes.
- 6 -> ETHER_ADDR_LEN.
2003-04-08 17:21:15 +00:00
Maxime Henrion
50d81222d8 Fix the hangs people have been seeing. For some reason, the
atomic operation change caused this, so backout it until I
can figure out what's wrong with it.
2003-04-08 13:05:11 +00:00
Maxime Henrion
d73e2e5593 Correct the maxsize and maxsegsz parameters for the
bus_dma_tag_create() calls.  Without this, fxp(4) + PAE
would consume insane amounts of bounce pages.
2003-04-07 17:02:44 +00:00
Maxime Henrion
2c6c094714 Remove an erroneous htole16(). The byte_count field in the
struct fxp_cb_config is a 6-bit field, not a 16-bit integer
as in struct fxp_cb_tx.
2003-04-07 14:53:30 +00:00
Maxime Henrion
5f361cbe0e Move a bus_dmamap_sync() to the correct place. 2003-04-06 23:16:00 +00:00
Maxime Henrion
ec6b76b760 Because alpha can't access memory in 16-bit granularity,
we're using an atomic operation to clear the suspend flag
in fxp_start().  Since other architectures may need the
same thing, we want to do it all the time and not only
in the __alpha__ case.  However, we don't want to use
atomic operations on 16-bit integers, because those may
not be available on any architecture.  We're thus faking
a 32-bit atomic operation here.  This patch also deals
with endianness here.
2003-04-06 23:09:57 +00:00
Maxime Henrion
d45d97d1fc Revert the s/u_int/u_int8_t/ changes, we can't really use other
integer types than int with bit-fields in a portable way.

Prodded by:	bde
2003-04-06 21:35:45 +00:00
Maxime Henrion
01c516b02a Use __FBSDID. 2003-04-06 01:27:12 +00:00
Maxime Henrion
6835a8accc Correct the definition of the link_addr and rbd_addr fields
in struct fxp_rfa.  This should have been committed with my
last endianness fixes.
2003-04-06 01:11:38 +00:00
Maxime Henrion
83e6547df1 - Instead of rolling our own alignment-safe function, use le32enc()
which deals with both endianness and alignment issues.
- Collect low-hanging fruits for endianness safety.
- Use 0xffffffff instead of -1 where appropriate.
2003-04-06 01:04:17 +00:00
Maxime Henrion
467295e056 - Use __FXP_BITFIELDX macros to make the configuration bitfield
endian safe.
- Change some u_int to u_int8_t which make more sense here since
  we're really defining bytes.  That produces the same code due to
  how bitfields work.
- Add the definition of the vlan_drop_en bit (not used yet).
- Add some useful comments.

Obtained from:	NetBSD
2003-04-05 23:46:58 +00:00
Maxime Henrion
4cec16537d - Change a FXP_NRFABUFS which would have been a FXP_NTXCB.
- Correct some bus_dmamap_sync() calls.

Submitted by:	jake
2003-04-05 12:43:21 +00:00
Maxime Henrion
201afb0e56 Setup our interrupt only at the end of fxp_attach(), when all
other allocations/initializations have been successful.  I kinda
doubt it will fix the recent breakage that some people are seeing,
but this could have caused problems for sure.
2003-04-05 01:27:17 +00:00
Maxime Henrion
5353c9b6ba Remove useless initialization. 2003-04-03 20:39:43 +00:00
Maxime Henrion
c2a2b443e2 Fix fxp(4), this changed shouldn't have crept in.
Pointy hat to:	mux
Reported by:	Pawel Worach <pawel.worach@nordea.com>
2003-04-03 18:39:48 +00:00
Maxime Henrion
e609b4d7db Remove all the bogus volatile qualifiers from the structs definitions
and associated evil casts to discard them.
2003-04-03 14:08:35 +00:00
Maxime Henrion
b2badf0214 Convert the fxp(4) driver to the busdma API.
This patch is rather big because I had to significantly redesign
the driver to make the busdma conversion possible.  Most notably,
hardware and software structures were carefully splitted to get
rid of all the structs overlapping evilness.

Special thanks to phk and Richard Puga <puga@mauibuilt.com> for
providing me with fxp(4) hardware to do this work.

Thanks to marcel for testing this on ia64, and to Fred Clift
<fclift@verio.net> for testing this on alpha.

Tested on:	i386, ia64, alpha
2003-04-02 16:47:16 +00:00
John Polstra
537b41d5ff Correct names for fxp devices. Sort data by devid in
fxp_ident_table.

PR:		kern/48699
Submitted by:	Sergey A. Osokin <osa@FreeBSD.org.ru>
Obtained from:	NetBSD (the device strings, that is)
MFC after:	4 weeks
2003-03-08 21:44:21 +00:00
Peter Wemm
3c6b084e96 Finish driving a stake through the heart of netns and the associated
ifdefs scattered around the place - its dead Jim!

The SMB stuff had stolen AF_NS, make it official.
2003-03-05 19:24:24 +00:00
Bill Paul
c6d8cd1e00 Remember to set if_capenable when setting up checksum offload in fxp_attach().
Pointed out by: jlemon
2003-02-27 19:41:55 +00:00
Bill Paul
c8bca6dc3d As previously threatened, add TCP/IP checksum offload support to
the fxp driver. This is enabled only for the 82550/82551 chips
(PCI revision code 12 or 13). RX and TX checksum offload are
both supported. Transmit offload is limited to TCP and UDP only
right now: there seems to be a problem with IP header checksumming
on transmit in some cases.

This chip has hardware VLAN support as well. I hope to enable
support for this eventually.
2003-02-26 22:12:04 +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
MIHIRA Sanpei Yoshiro
4bfecf88f4 Add PCI id for fxp(Intel Pro/100 M Mobile Connection).
PR:	i386/41915
Submitted by:	Ross A. Lippert <ripper@eskimo.com>
MFC after:	1 week
2003-01-27 14:31:32 +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
Sam Leffler
673d91916d network interface driver changes:
o don't strip the Ethernet header from inbound packets; pass packets
  up the stack intact (required significant changes to some drivers)
o reference common definitions in net/ethernet.h (e.g. ETHER_ALIGN)
o track ether_ifattach/ether_ifdetach API changes
o track bpf changes (use BPF_TAP and BPF_MTAP)
o track vlan changes (ifnet capabilities, revised processing scheme, etc.)
o use if_input to pass packets "up"
o call ether_ioctl for default handling of ioctls

Reviewed by:	many
Approved by:	re
2002-11-14 23:54:55 +00:00
Ian Dowse
947e381597 Properly fix the occassional random crash issue that revision 1.142
just limited to the DEVICE_POLLING case. This removes the FXP_RFA_RNRMARK
hack, and replaces it with a softc flag that is used to record when
the handling of a no-resource condition was deferred due to running
out of DEVICE_POLLING cycles. This was tested on -stable, but the
code is essentially the same as in -current. It should only affect
the case where DEVICE_POLLING is defined.

The details of the mechanism behind the crashes are still uncertain
but the most likely cause seems to be some kind of hardware confusion
when the no-resource recovery code is accidentally invoked while
the receiver is still active. This could have happened if the
hardware left the 0x4000 bit of the RFA status word set. The comments
in the commit log for revision 1.142 stating that the driver could
clash with the hardware writing to this status word were not correct.

Tested by:	Guy Helmer <ghelmer@palisadesys.com>
2002-11-07 16:04:07 +00:00
Ian Dowse
cb0d1e061b Revision 1.136 introduced two features that may cause undefined
behaviour of the hardware: a possibly reserved bit of the receive
descriptor (RFA) `status' field is borrowed to record no-resource
(RNR) events, and the same status field is read and written to at
a time that may clash with the hardware updating this field.

There is no hardware documentation available to determine if these
things are safe to do; the second issue almost certainly isn't, and
the first is only safe if there is documentation saying that this
bit is free to be used by the driver. The PR referenced below
provides extremely convincing evidence that the changes cause random
crashes on some (unusual) hardware.

Since these features are only required by the DEVICE_POLLING case,
this commit makes their use conditional on that option. It does not
change the DEVICE_POLLING case, but at least people with the rare
hardware on which this code causes problems can now avoid the crashes
by not enabling DEVICE_POLLING.

PR:		kern/42260
Reviewed by:	luigi
Problem revision found by: Pawel Malachowski <pawmal@unia.3lo.lublin.pl>
Tested by:	Pawel Malachowski <pawmal@unia.3lo.lublin.pl>
MFC after:	1 week
2002-10-30 19:08:56 +00:00
Poul-Henning Kamp
858b84f550 '&' is not needed to pointerize functions.
Spotted by:	FlexeLint
2002-10-20 20:42:25 +00:00
Paul Saab
a7d681929a Add some PCI id's for fxp. I've only tested 0x103B, but the Intel
Linux driver defines 0x103[B-E] so add those as well.

Obtained from:	Intel Linux e100 driver
MFC:		Immediately if re@ allows it, otherwise after 4.7-RELEASE
2002-09-24 23:13:38 +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
Luigi Rizzo
fd9430fea6 use the new interface to ether_input(), with eh = NULL and
the MAC header in the mbuf.

MFC after: 3 days
2002-08-09 01:48:28 +00:00
Luigi Rizzo
9e2518582d Use m_getcl() to allocate buffers for the receive ring.
MFC after: 3 days
2002-08-05 00:21:24 +00:00
Luigi Rizzo
2b5989e943 Fix handling of Receiver Not Ready errors when doing polling.
Also take this chance to cleanup the code in fxp_intr_body.

Add a missing block of code to disable interrupts when
reinitializing the interface while doing polling (the RELENG_4
version was correct).

MFC after: 3 days
2002-08-04 22:33:28 +00:00
Mike Silbersack
e2102ae475 Revert rev 1.131.
1.131 is slightly broken, and I would commit the fix to that here, but it
has been reported that any deviation from the original code is causing
problems with some 82557 chips, causing them to lock hard.

Until those issues have been figured out, going back to the original
code is the best plan.

Frustrated:	Silby
2002-07-29 04:32:35 +00:00
Luigi Rizzo
e823d3404b whitespace commit: fix indentation in fxp_intr_body.
This is also done in preparation of a subsequent fix
for the handling of RNR conditions in polling mode.
2002-07-29 02:48:09 +00:00
Luigi Rizzo
41aa0ba271 Fix if_timer logic so that there is always a timeout pending if there
are packets queued for transmission.

This driver is strange -- it never sets IFF_OACTIVE, so all
transmissions always cause a call to fxp_start. However, if the
link gets stuck, there was nothing to reset it, so there was still
a possibility of lockups.

MFC after: 3 days
2002-06-30 22:28:00 +00:00
Mike Silbersack
f32932bc1b Add another Intel chipset (i82562).
PR:		39974
Submitted by:	Morten Aaboe Jensen <morten@codemonkey.dk>
MFC after:	1 day
2002-06-29 01:56:14 +00:00
Doug Ambrisko
e94c058ad1 Add device id. for fxp chip on Intel D845EPT2L boards. This seems to
make the onboard NIC work.

Sponsored by:	Vernier Networks
MFC after:	1 day
2002-06-05 18:34:08 +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
Mike Silbersack
c9fbdd0fa4 Remove mbuf exhaustion warning messages; these are handled by the
mbuf system in a rate-limited fashion now.

Reviewed by:	luigi
MFC after:	1 week
2002-02-04 03:15:27 +00:00
Jonathan Lemon
a1a9c8f7e6 Initialize the sysctl_ctx list early, which avoids a panic in case other
allocatiosn fail and fxp_release() is called.
2002-01-22 17:51:44 +00:00
Jonathan Lemon
0988236390 Explicitly reload the multicast filters when the hardware is reinitialized
instead of relying on the previous filters to be present.

Back out r1.125, as a reset is needed to unload any existing microcode,
(which clears the multicast addresses), as it is superceded by this change.
2002-01-07 15:08:54 +00:00
Jun Kuriyama
470c78a6ea Possibly typo fix (s/FXP_PORT_SOFTWARE_RESET/FXP_PORT_SELECTIVE_RESET/)
in fxp_stop().

Reference:	http://www.freebsd.org/cgi/mid.cgi?id=7md718f0qo.wl@waterblue.imgsrc.co.jp
Submitted by:	Keiichi SHIMA <keiichi@iij.ad.jp>
2001-12-24 05:32:58 +00:00
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