Commit Graph

2357 Commits

Author SHA1 Message Date
John Baldwin
33181681c7 - Use PCIR_BAR() macro for the BAR for the aperture.
- Axe macros used for walking PCI capabilities list.  We now ask the PCI
  bus to find caps for us rather than doing it in the drm and agp drivers.
2005-12-20 22:45:24 +00:00
John Baldwin
e9aa66d283 - Bump FreeBSD version for the hostb(4) and vgapci(4) drivers as well as
the addition of pci_find_extcap().
- Change the drm drivers to attach to vgapci.  This is #ifdef'd so the
  code can be shared across branches.
- Use pci_find_extcap() to look for AGP and PCIE capabilities in drm.
- GC all the drmsub stuff for i810/i830/i915.  The agp and drm devices are
  now both children of vgapci.
2005-12-20 22:44:36 +00:00
John Baldwin
c626f1fe9a Change the various AGP drivers that attach to the Host-PCI bridge device to
attach to the hostb driver instead.  This means that agp can now be loaded
at runtime (in theory at least).  Also, the drivers no longer have to
explicity call device_verbose() to cancel out any earlier calls to
device_quiet() by the hostb(4) driver (this shows a limitation in new-bus,
drivers really shouldn't be doing device_quiet() until they know they are
going to drive that device, i.e. in attach).
2005-12-20 21:12:26 +00:00
John Baldwin
c8d81a41f4 Change the agp_find_device() to return the first agp device that has been
attached to a driver rather than always returning agp0.
2005-12-20 21:06:43 +00:00
John Baldwin
5bcf484019 Don't map the AGP aperture into contiguous KVA. The various graphics
drivers already map sections into KVA as needed anyway.  Note that this
will probably break the nvidia driver, but I will coordinate to get that
fixed.

MFC after:	2 weeks
2005-12-20 20:05:21 +00:00
John Baldwin
4c2546c1a9 Destroy the /dev device before destroying the mutex or releasing resources
rather than afterwards.

MFC after:	1 week
2005-12-20 20:03:16 +00:00
John Baldwin
04d6a912e4 Use pci_find_extcap() to search for AGP capabilities (PCIY_AGP). 2005-12-20 19:58:28 +00:00
Ruslan Ermilov
aa4f8911d7 Backout pseudo nForce2/3/4 support. These devices (as well as
AMD-8111 SMBus 2.0 controller) are all SMBus 2.0 controllers,
and need another implementation of SMBus access methods, while
this driver supports AMD-756 SMBus 1.0 controller and clones,
including AMD-8111 SMBus 1.0 controller.

Tested by:	Vladimir Timofeev (0x006410de),
		mezz (0x008410de),
		ru (0x00d410de)

All of us got the same(!) nonsense when running ``mbmon -S'',
repeated every four rows.
2005-12-16 22:58:51 +00:00
Ruslan Ermilov
1a40739a00 Fix PCI ID of the AMD-8111 System Management controller so it matches
SMBus 1.0 and not SMBus 2.0.

AMD-8111 hub (datasheet is publically available) implements both SMBus
2.0 (a separate PCI device) and SMBus 1.0 (a subfunction of the System
Management Controller device with the base I/O address is accessible
through the CSR 0x58).  This driver only supports AMD-756 SMBus 1.0
compatible devices.

With the patched sysutils/xmbmon port (to also fix PCI ID and to enable
smb(4) support), I now get:

pciconf:
none0@pci0:7:2: class=0x0c0500 card=0x746a1022 chip=0x746a1022 rev=0x02 hdr=0x00
    vendor   = 'Advanced Micro Devices (AMD)'
    device   = 'AMD-8111 SMBus 2.0 Controller'
    class    = serial bus
    subclass = SMBus
amdpm0@pci0:7:3:        class=0x068000 card=0x746b1022 chip=0x746b1022 rev=0x05 hdr=0x00
    vendor   = 'Advanced Micro Devices (AMD)'
    device   = 'AMD-8111 ACPI System Management Controller'
    class    = bridge

dmesg:
amdpm0: <AMD 756/766/768/8111 Power Management Controller> port 0x10e0-0x10ff at device 7.3 on pci0
smbus0: <System Management Bus> on amdpm0

# mbmon -A -d
Summary of Detection:
 * SMB monitor(s)[ioctl:AMD8111]:
  ** Winbond Chip W83627HF/THF/THF-A found at slave address: 0x50.
  ** Analog Dev. Chip ADM1027 found at slave address: 0x5C.
 * ISA monitor(s):
  ** Winbond Chip W83627HF/THF/THF-A found.

I think the confusion comes from the fact that nobody really tried
SMBus with xmbmon :-), since sysutils/xmbmon port doesn't come with
SMBus support enabled, neither in FreeBSD 4, nor in later versions,
so mbmon(1) was just showing the values from the Winbond sensors
accessible through the ISA I/O method (mbmon -I), for me anyway.

On my test machine, the amdpm(4) didn't even attach due to I/O port
allocation failure (who knows what the hell it read from CSR 0x58
of the SMBus 2.0 device :-), which isn't in the CSR space).

I've also checked that lm_sensors.org uses correct PCI ID for SMBus
1.0 of AMD-8111:

i2c-amd756.c:   {PCI_VENDOR_ID_AMD, 0x746B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AMD8111 },

This driver is analogous to our amdpm.c which supports SMBus 1.0
AMD-756 and compatible devices, including SMBus 1.0 on AMD-8111.

i2c-amd8111.c:  { 0x1022, 0x746a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },

This driver is analogous to nForce-2/3/4, i2c-nforce2.c, which
supports SMBus 2.0, and which our amdpm.c does NOT support
(SMBus 2.0 uses a different, ACPI-unified, API to talk to SMBus).
At least I know for sure it doesn't work with my nForce3.  :-)

(The xmbmon port will be fixed to correct the PCI ID too and to
enable the smb(4) support.)
2005-12-16 15:03:16 +00:00
John Baldwin
23de16f9a7 Add support for the nForce2/3/4 SMBus controllers which all contain two
SMBus busses.  Because of limitations in smbus_if.m, the second smbus is
attached to an amdpm1 device that is a child of amdpm0.

Submitted by:	Artemiev Igor ai (at) bmc dot brk dot ru
2005-12-14 17:49:45 +00:00
Scott Long
73c8420784 The if_ti Tigon I/II driver has moved to /sys/dev/ti 2005-12-10 00:38:33 +00:00
Ruslan Ermilov
3238c6bd33 Fix -Wundef from compiling the amd64 LINT. 2005-12-04 10:06:06 +00:00
Eric Anholt
8ec9a6c5a6 Add support for i915 GMCH AGP. This diff is a combination of work by myself
and some fixes from Motomichi Matsuzaki.  Testing involved many people, but the
final, successful testing was from rwatson who endured several rounds of "it
crashes at XYZ stage" "oh, please correct this typo and try again."  The Linux
driver, and to a small extent the limited specs, were both used as a reference
for how to program the chipset.

PR:		kern/80396
Submitted by:	Martin Mersberger
2005-12-02 23:51:36 +00:00
Ruslan Ermilov
6a4cb6fd25 Fix the type of "eaddr" to guarantee the required alignment.
Suggested by:	marcel
2005-12-01 21:18:04 +00:00
Ruslan Ermilov
3faffd5dae Byte copy IF_LLADDR() on stack to align it to be safe for typecasts.
Tested by:	jhb
2005-11-30 17:48:23 +00:00
Eric Anholt
f0fc8e98b3 Add support for the i855GM, tested by an r300 user. 2005-11-29 04:53:22 +00:00
John Baldwin
f5e19c7342 Various fixes to make de(4) not panic after ru@'s IF_LLADDR() changes:
- Don't call tulip_addr_filter() to reset the RX address filter in
  tulip_reset() since that gets called before ether_ifattach().  Just
  call it in tulip_init_locked().
- Use be16dec() and le16dec() to parse MAC addresses when programming
  the RX filter.
- Let ether_ioctl() handle SIOCSIFMTU since we were doing the exact same
  thing with the added bonus that we leaked the driver lock if the MTU
  was > ETHERMTU in the homerolled version.  This part will be MFC'd.

Clue from:	wpaul (1)
Stolen from:	marcel (2 via patch for dc(4))
MFC after:	1 week
2005-11-21 21:50:07 +00:00
Jung-uk Kim
5c0619a7f0 0xb1881106 seems to be an AGP bridge and some BIOSes incorrectly handle
the bridge.  Therefore, we give the same treatment as we did for nForce3-250
and ULi chipsets.  VIA AGPv3 code was copied from agp_via.c.
2005-11-14 21:54:20 +00:00
Ruslan Ermilov
4a0d6638b3 - Store pointer to the link-level address right in "struct ifnet"
rather than in ifindex_table[]; all (except one) accesses are
  through ifp anyway.  IF_LLADDR() works faster, and all (except
  one) ifaddr_byindex() users were converted to use ifp->if_addr.

- Stop storing a (pointer to) Ethernet address in "struct arpcom",
  and drop the IFP2ENADDR() macro; all users have been converted
  to use IF_LLADDR() instead.
2005-11-11 16:04:59 +00:00
Ruslan Ermilov
f5071cacb1 Catch up with IFP2ENADDR() type change (array -> pointer). 2005-11-11 12:17:31 +00:00
John Baldwin
13df733045 - Use callout_*() to manage the callout and make it MPSAFE.
- Fix locking in detach(), we only need to lock across vr_stop().

Tested by:	Mike Tancsa mike at sentex dot net
MFC after:	1 week
2005-10-31 21:37:27 +00:00
John Baldwin
aa14e8f4b4 Add the device ID for the VIA VT8235 south bridge.
PR:		kern/62438
Submitted by:	FUJIMOTO Kou fujimoto at j dot dendai dot ac dot jp
Tested by:	Oliver Fromme olli at secnetix dot de
MFC after:	1 week
2005-10-31 18:43:28 +00:00
John Baldwin
6647585e2d Some of the VIA pm and propm devices are actually the same device as the
PCI-ISA bridge.  Thus, when viapm0 or viapropm0 attaches, isab0 dosen't
attach so there is no isa0 bus hung off of that bridge.  In the non-ACPI
case, legacy0 will add an isa0 anyway as a fail-safe, but ACPI assumes that
any ISA bus will be enumerated via a bridge.  To fix this, call
isab_attach() to attach an isa0 ISA child bus device if the pm or propm
device we are probing is a PCI-ISA bridge.  Both drivers now have to
implement the bus_if interface via the generic methods for resource
allocation, etc. to work.  Also, we now add 2 new ISA bus drivers that
attach to viapm and viapropm devices.

PR:		kern/87363
Reported by:	Oliver Fromme olli at secnetix dot de
Tested by:	glebius
MFC after:	1 week
2005-10-31 18:31:16 +00:00
Bill Paul
bcb02fd532 Remove forgotten, no longer needed WB_UNLOCK() from the end wb_ioctl().
With this change, the driver tests good (at least on i386):

wb0: <Winbond W89C840F 10/100BaseTX> port 0xb800-0xb87f mem 0xe6800000-0xe680007f irq 12 at device 10.0 on pci0
miibus1: <MII bus> on wb0
amphy0: <Am79C873 10/100 media interface> on miibus1
amphy0:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
wb0: Ethernet address: 00:00:e8:18:2a:02
wb0: link state changed to DOWN
wb0: link state changed to UP
2005-10-28 02:17:40 +00:00
John Baldwin
80e963994a Fixup locking and mark MPSAFE.
- Add locked variants of init() and start().
- Use callout_*() to manage callout.
- Test IFF_DRV_RUNNING rather than IFF_UP in wb_intr() to see if we are
  still active when an interrupt comes in.

I couldn't find any of these cards anywhere to test on myself, and google
turns up references to FreeBSD and OpenBSD manpages for this driver when
trying to locate a card that way.  I'm not sure anyone actually uses these
cards with FreeBSD.

Tested by:	NO ONE (despite repeated requests)
2005-10-27 21:22:58 +00:00
John Baldwin
4cc88f8f33 - Use if_printf() and device_printf() and remove vr_unit from the softc.
I had to initialize the ifnet a bit earlier in attach so that the
  if_printf()'s in vr_reset() didn't explode with a page fault.
- Use M_ZERO with contigmalloc() rather than an explicit bzero.
2005-10-27 21:18:37 +00:00
Warner Losh
7b279558cc Replace FreeBSD 3.x syntax (controller miibus0) with 4.x syntax
(device miibus) in time for 7.0 :-)
2005-10-22 05:06:55 +00:00
Warner Losh
349920b201 Remove dc after repo copy. 2005-10-18 06:10:03 +00:00
John Baldwin
26390635de Only allow the sk(4) driver to attach to revision 2 of the LinkSys EG1032
cards and teach the re(4) driver to attach to revision 3 cards.

Submitted by:	Fredrik Lindberg fli+freebsd-current at shapeshifter dot se
MFC after:	2 weeks
Reviewed by:	imp, mdodd
2005-10-14 18:51:30 +00:00
Ruslan Ermilov
e019908ee7 In detach method, move if_free() after bus_teardown_intr(). 2005-10-13 21:11:20 +00:00
Yaroslav Tykhiy
45c11f832a Mark sk(4) as capable of handling extended VLAN frames. NICs
based on XMAC II chip should be ready for this in their initial
mode of operation, and Yukon-based NICs are configured so by
the driver.

PR:		kern/79998
MFC after:	1 month
2005-10-11 22:55:16 +00:00
Gleb Smirnoff
f0796cd26c - Don't pollute opt_global.h with DEVICE_POLLING and introduce
opt_device_polling.h
- Include opt_device_polling.h into appropriate files.
- Embrace with HAVE_KERNEL_OPTION_HEADERS the include in the files that
  can be compiled as loadable modules.

Reviewed by:	bde
2005-10-05 10:09:17 +00:00
Gleb Smirnoff
4092996774 Big polling(4) cleanup.
o Axe poll in trap.

o Axe IFF_POLLING flag from if_flags.

o Rework revision 1.21 (Giant removal), in such a way that
  poll_mtx is not dropped during call to polling handler.
  This fixes problem with idle polling.

o Make registration and deregistration from polling in a
  functional way, insted of next tick/interrupt.

o Obsolete kern.polling.enable. Polling is turned on/off
  with ifconfig.

Detailed kern_poll.c changes:
  - Remove polling handler flags, introduced in 1.21. The are not
    needed now.
  - Forget and do not check if_flags, if_capenable and if_drv_flags.
  - Call all registered polling handlers unconditionally.
  - Do not drop poll_mtx, when entering polling handlers.
  - In ether_poll() NET_LOCK_GIANT prior to locking poll_mtx.
  - In netisr_poll() axe the block, where polling code asks drivers
    to unregister.
  - In netisr_poll() and ether_poll() do polling always, if any
    handlers are present.
  - In ether_poll_[de]register() remove a lot of error hiding code. Assert
    that arguments are correct, instead.
  - In ether_poll_[de]register() use standard return values in case of
    error or success.
  - Introduce poll_switch() that is a sysctl handler for kern.polling.enable.
    poll_switch() goes through interface list and enabled/disables polling.
    A message that kern.polling.enable is deprecated is printed.

Detailed driver changes:
  - On attach driver announces IFCAP_POLLING in if_capabilities, but
    not in if_capenable.
  - On detach driver calls ether_poll_deregister() if polling is enabled.
  - In polling handler driver obtains its lock and checks IFF_DRV_RUNNING
    flag. If there is no, then unlocks and returns.
  - In ioctl handler driver checks for IFCAP_POLLING flag requested to
    be set or cleared. Driver first calls ether_poll_[de]register(), then
    obtains driver lock and [dis/en]ables interrupts.
  - In interrupt handler driver checks IFCAP_POLLING flag in if_capenable.
    If present, then returns.This is important to protect from spurious
    interrupts.

Reviewed by:	ru, sam, jhb
2005-10-01 18:56:19 +00:00
John Baldwin
d1754a9b9c - Use if_printf() and device_printf() in re(4) and remove rl_unit from
the softc.
- Use callout_init_mtx() and rather than timeout/untimeout in both rl(4)
  and re(4).
- Fix locking for ifmedia by locking the driver in the ifmedia handlers
  rather than in the miibus functions.  (re(4) didn't lock the mii stuff
  at all!)
- Fix some locking in re_ioctl().

Note: the two drivers share the same softc declared in if_rlreg.h, so they
had to be change simultaneously.

MFC after:	 1 week
Tested by:	several on rl(4), none on re(4)
2005-09-29 16:52:19 +00:00
John Baldwin
dc6f00687c Use if_printf() and device_printf(). 2005-09-29 16:47:08 +00:00
John Baldwin
ccb7a62ef7 Typo. 2005-09-29 15:04:58 +00:00
Jung-uk Kim
d8e205ef93 - Add a work-around for nForce3-250. Aperture base address encoded in misc.
control register and AGP bridge seems to be inconsistent with some BIOS.
Instead of relying on BIOS settings, we just take the initial aperture size
and encode them for both miscellaneous control register and AGP bridge.
Some idea was borrowed from agp_nvidia.c.

- Add preliminary ULi M1689 chipset support.  The idea was taken from Linux
because hardware and documentation are unavailable.  Not tested.

- Add more VIA chipset PCI IDs taken from Linux driver.

Approved by:	anholt (mentor)
Tested by:	Adam Gregoire <ebola at psychoholics dot org>
		Ganael Laplanche <ganael.laplanche at martymac dot com>
		K Wieland <kwieland at wustl dot edu>
2005-09-27 20:57:50 +00:00
Max Laier
b6de9e91bd Remove bridge(4) from the tree. if_bridge(4) is a full functional
replacement and has additional features which make it superior.

Discussed on:	-arch
Reviewed by:	thompsa
X-MFC-after:	never (RELENG_6 as transition period)
2005-09-27 18:10:43 +00:00
John Baldwin
25067ba265 Small fixes to sis(4):
- Remove sis_unit and use device_printf() and if_printf() instead.
- Use callout_init_mtx() for the callout.
- Remove spls.
- Fix locking for ifmedia to happen in the ifmedia handlers rather than in
  sis_ioctl().
- Log an error message if we fail to allocate any resources.  Perform
  cleanup if we fail to allocate any resources so that we don't leave
  a mutex hanging around.

Tested by:	Jason Tsai jason dot tsai at newcyberian dot com (1-4)
MFC after:	3 days
2005-09-26 18:42:27 +00:00
Poul-Henning Kamp
ca72f67d70 Use the new bus_space/resource convenience functions. 2005-09-24 20:46:02 +00:00
Poul-Henning Kamp
f38deea185 Move code macros from if_sis*reg*.h to if_sis.*c* 2005-09-20 09:52:53 +00:00
Eric Anholt
e3e1ac8615 Add a new AGP driver for ATI IGP chipsets. The driver is based on reading of
the Linux driver, since specs are unavailable.  Many thanks to Adam Kirchhoff
for multiple useful testing cycles, and Ralf Wostrack for the final fix to get
it working.

PR:		i386/75251
Submitted by:	anholt
2005-09-17 03:36:47 +00:00
Eric Anholt
695b15ca91 Fix agp_nvidia.c to behave more like the linux driver, fixing DRI on Radeon
9200 according to one responder.  The primary issue was not setting some bits
to say that the entries were active, but also fix one place where some memory
wasn't being used as volatile as it should.  While here, change some use of ffs
to a relatively short case statement, to make it more obvious what's going on.

PR:		kern/71638, kern/72372, kern/71547?
Submitted by:	Andrew J. Caines <A.J.Caines@halplant.com>,
		Robin Schoonover <end@endif.cjb.net>,
		Jason Henson <jason@ec.rr.com>
2005-09-16 22:59:47 +00:00
Ruslan Ermilov
3badacee8c Fix "struct ifnet" leaks when attach() fails in the middle, e.g.
when mii_phy_probe() or bus_setup_intr() fails.  For drivers that
call their detach() in this case, call if_free() there to cover
this case too.
2005-09-16 11:11:51 +00:00
Giorgos Keramidas
4f867c2d17 When bus_alloc_resource_any() fails, dc_detach() is called and it
attempts to deallocate busdma tags and resources that haven't been
allocated yet, causing a panic every time a dc interface fails to
attach.  Fix by checking that we really have something to dealloc
before calling bus_dma*() functions.

Approved by:	jhb
MFC after:	1 week
2005-09-15 17:51:39 +00:00
John Baldwin
8d75d3087d - Fixup locking and mark MPSAFE.
- Use callout_init_mtx() and static callouts rather than timeout().
- m_getcl() in one place to simplify the code.

Tested by:	Gavin Atkinson gavin dot atkinson at ury dot york dot ac dot uk
MFC after:	1 week
2005-09-15 17:12:29 +00:00
Ruslan Ermilov
8d7a953fb2 Fixed "Memory modified after free" panic in rl_detach() due
to rl_stop() accessing already freed "struct ifnet".

Fixed LOR between rl mutex and some ACPI mutex in rl_detach().
2005-09-14 12:33:23 +00:00
John Baldwin
7afed9d69a Use if_printf() and device_printf() for printf's and remove the unit number
from the softc.

MFC after:	3 days
2005-08-31 18:03:18 +00:00
John Baldwin
a6c222c739 Various locking fixes and mark MPSAFE:
- Add locked variants of start(), init(), ifmedia_upd(), and poll() and stop
  recursing on the driver lock.
- Add locking to ifmedia_upd() and ifmedia_sts().
- Use callout_*() instead of timeout/untimeout.
- Fix locking in ioctl().

Tested by:	Bob Bishop rb at gid dot co dot uk
MFC after:	3 days
2005-08-30 20:35:08 +00:00
Warner Losh
919ccba73e Better comment 2005-08-29 18:45:21 +00:00
Warner Losh
667b0824d7 Fix another instance of old info re: miibus 2005-08-29 17:03:31 +00:00
Warner Losh
c3b6bc1a2a Fix obsolete comment.
MFC After: 2 days
2005-08-29 16:48:28 +00:00
John Baldwin
dbc2a95f40 - Use m_defrag() instead of homerolling our own variant
tulip_mbuf_compress().  If we fail to allocate a new mbuf to copy the
  data into, put the mbuf back in the driver's send queue so that we can
  retry it later rather than throwing the packet away.
- Use m_devget() instead of doing it inline ourselves in the
  TULIP_COPY_RXDATA case.  If we fail to allocate an mbuf to copy the data
  into, don't forget about the original mbuf cluster.  The old code would
  lose the pointer and leak the cluster in that case.  Now it doesn't lose
  it but always sticks the original rx buffer back into the receive ring
  after trying to copy the data out and send it up the stack.  Also, if we
  fail to allocate a new mbuf to copy the data into, log an input error.
  Also, don't combine the priming case with the received-a-packet case to
  make the code flow a bit clearer and easier to follow.
2005-08-26 14:27:38 +00:00
John Baldwin
4faaaed479 - Remove non-bus-dma code.
- Remove form feed characters.
- Fixup style of function declarations.
- Assume that an mbuf cluster is big enough to hold an ethernet frame.
  (This should really be using m_defrag(), but this diff is just simple
  changes for now.)
2005-08-25 21:06:56 +00:00
John Baldwin
f8190d8dc8 Major rototill of this driver to add FreeBSD bus-dma support:
- Allocate arrays of metadata for the descriptors in the rx and tx rings
  and change the ring pointers to walk the metadata array rather than the
  actual descriptor rings.  Each metadata object contains a pointer to its
  descriptor, a pointer to any associated mbuf, and a pointer to the
  associated bus_dmamap_t in the bus_dma case.  The mbuf pointers replace
  the tulip_txq and tulip_rxq local ifqueue's in the softc.
- Add lots of KTR trace entries using a local KTR_TULIP level which
  defaults to 0, but can be changed to KTR_DEV at the top of the file
  when debugging.
- Rename tulip_init(), tulip_start(), tulip_ifinit(), and tulip_ifstart()
  to tulip_init_locked(), tulip_start_locked(), tulip_init(), and
  tulip_start(), respectively, to match the convention in other drivers.
- Add a TULIP_SP_MAC() macro to encode two bytes of the MAC address into
  the setup buffer and use that in place of lots of BYTE_ORDER #ifdef's.
  Also, remove an incorrect XXX comment I added earlier, the driver was
  correct (at least it does the same thing dc(4) does).  TULIP_SP_MAC
  was shamelessly copied from DC_SP_MAC() in dc(4).
- Remove the #ifdef'd NetBSD bus-dma code and replace it with FreeBSD
  bus-dma code that not only compiles but even works at runtime.
- Use callout_init_mtx() instead of just callout_init().
- Correct the various wrapper macros for bus_dmamap_sync() for the rx
  and tx buffers to only ask for the sync ops that they actually need.
- Tidy the #ifdef TULIP_COPY_RXDATA code by expanding an #ifdef a bit
  so it becomes easier to read at the expense of a couple of duplicated
  lines of code.  Also, use m_getcl() to get an mbuf cluster rather than
  MGETHDR() followed by MCLGET().
- Maintain the ring free (ri_free) count for the rx ring metadata since
  we no longer have tulip_rxq.ifq_len around to indicate how many mbuf's
  are currently in the rx ring.
- Add code to teardown bus_dma resources when attach fails and generally
  fixup attach to do a better job of cleaning up when it fails.  This
  gets us a good bit closer to possibly having a detach method someday
  and making this driver an unloadable module.
- Add some functions that can be called from ddb to dump the state of
  a descriptor ring and to dump the state of an individual descriptor.
- Various comment grammer and spelling fixes.

I have bus-dma turned on by default, but I've left the non-bus-dma code
around so that it can be turned off to aid in debugging should any problems
turn up later on.  I'll be removing the non-bus-dma code in a subsequent
commit.
2005-08-25 20:12:43 +00:00
John Baldwin
997452064e Various fixups to locking:
- Remove a lot of superfluous locking during attach.  There is no need
  to lock access to the driver until some other thread has a way of getting
  to it.  For ethernet drivers the other ways include registering an
  interrupt handler via bus_setup_intr(), calling ether_ifattach() to hook
  into the network stack, and kicking off a callout-driven timer via
  callout_reset().
- Use callout_* rather than timeout/untimeout.
- Break out of xl_rxeof() if IFF_DRV_RUNNING is clear after ifp->if_input
  returns to handle the case where the interface was stopped while we were
  passing a packet up the stack.  Don't call xl_rxeof() in xl_rxeof_task()
  unless IFF_DRV_RUNNING is set.  With these fixes in place, any
  outstanding task will gracefully terminate as soon as it gets a chance to
  run after the interface has been stopped via xl_stop().  As a result,
  taskqueue_drain() is no longer required in xl_stop().  The task is still
  drained in detach() however to make sure that detach() can safely destroy
  the driver mutex at the end of the function.
- Lock the driver lock in the ifmedia callouts and don't lock across
  ifmedia_ioctl() in xl_ioctl().

Note: glebius came up with most of (3) as well independently.  I took a
rather roundabout way of arriving at the same conclusion.

MFC after:	3 days
2005-08-18 19:24:30 +00:00
John Baldwin
c8b27aca43 Fixup locking and mark MPSAFE:
- Add locked versions of start and init.  The SRM_MEDIA code in dc_init()
  stayed in dc_init() instead of moving to dc_init_locked() to make the
  locking saner.
- Use callout_init_mtx().
- Fixup locking in detach and ioctl.
- Lock the driver in the ifmedia callouts.
- Don't recurse on the driver lock.
- De-spl.

MFC after:	3 days
2005-08-18 19:10:07 +00:00
John Baldwin
2a3e25a07f Fixup locking for sf(4) and mark MPSAFE:
- Add locked variants of start, init, and ifmedia_upd.
- Use callout_* instead of timeout/untimeout.
- Don't recurse on the driver lock.
- Fixup locking in ioctl.
- Lock the driver lock in the ifmedia handlers rather than across
  ifmedia_ioctl().

Tested by:	brueffer
MFC after:	3 days
2005-08-18 17:09:16 +00:00
John Baldwin
8a8573fdb2 - Use htole32() instead of using bswap32() conditional on #if BYTE_ORDER.
- Don't set IFF_ALLMULTI in our ifnet's if_flags if we end up allowing
  all multicast due to limits in the MAC receive filters in hardware.

Requested by:	rwatson (2)
2005-08-17 17:46:51 +00:00
John Baldwin
6da5b383f1 Remove the unused TULIP_CSR_{READ,WRITE}BYTE macros. 2005-08-17 17:45:19 +00:00
John Baldwin
f512b596a8 Use callout_init_mtx() to simplify the stats callout.
MFC after:	3 days
2005-08-17 17:44:58 +00:00
John Baldwin
f68d1644f8 Use device_printf() and if_printf() and remove ste_unit from the softc. 2005-08-17 14:37:39 +00:00
Bjoern A. Zeeb
e3c18d1d11 * Solve "No PHY found" problem for more Yukon Lite variants.
* Catch a bus attach error.
* Improve locking.

MFC after:	6 days
2005-08-13 11:13:12 +00:00
John Baldwin
22f6205d3b Use device_printf() and if_printf() and remove dc_unit from softc. 2005-08-10 20:33:46 +00:00
John Baldwin
fc8c1e5d98 Use if_printf() and device_printf() and axe sf_unit from the softc as a
result.
2005-08-10 20:24:39 +00:00
John Baldwin
fcde23065f Call tulip_start() rather than tulip_ifstart() from the interrupt handler
to avoid recursing on the driver lock.  Not sure why my test box didn't
catch this earlier.

MFC after:	3 days
2005-08-09 21:53:26 +00:00
Robert Watson
13f4c340ae Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and
IFF_DRV_RUNNING, as well as the move from ifnet.if_flags to
ifnet.if_drv_flags.  Device drivers are now responsible for
synchronizing access to these flags, as they are in if_drv_flags.  This
helps prevent races between the network stack and device driver in
maintaining the interface flags field.

Many __FreeBSD__ and __FreeBSD_version checks maintained and continued;
some less so.

Reviewed by:	pjd, bz
MFC after:	7 days
2005-08-09 10:20:02 +00:00
John Baldwin
718e387c34 Fix up the locking in pcn(4) and mark it MPSAFE.
- Add locked versions of the init() and start() methods.
- Use callout_*() rather than timeout().
- Make the driver lock non-recursive.
- Push down locking in detach() and ioctl().
- Fix the tick routine to bail if the interface has been stopped and use
  callout_drain() in detach() after the call to stop().
- Lock the driver lock in the ifmedia handlers.

Tested by:	Ketrien I. Saihr-Kesenchedra ketrien at error404.nls.net
MFC after:	1 week
2005-08-05 16:03:16 +00:00
Anton Berezin
32aa5f0e3e Recognize D-Link DGE-528(T) Gigabit as an re(4) device.
Submitted by:	Andrus Nomm <andrus@members.ee>
PR:		76780
MFC After:	1 week
2005-08-05 08:19:12 +00:00
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
John Baldwin
d0e98e85f8 - Use callout_*() rather than timeout() to periodically poll the media.
- Add locking to protect the softc and mark this driver as MP safe.  There
  are still some edge cases with multiport cards that need more locking
  work.

MFC after:	1 week
Tested on:	alpha
2005-07-27 13:51:01 +00:00
John Baldwin
8bc92074e8 Fix a typo in the name of the dmamap for a bus_dmamap_sync().
MFC after:	3 days
2005-07-27 13:48:45 +00:00
Warner Losh
6fa45429f9 The 575A doesn't have funcregs in memio. So don't claim that it does.
This gets my 575A card probing.

Card provided by: James Flemer
MFC After: 3 days
2005-07-27 06:38:55 +00:00
John Baldwin
9cc8edda00 - Use the PCIR_BAR() macro rather than hardcoding rids.
- Use pci_enable_busmaster() rather than fiddling with the PCI command
  register directly.
2005-07-21 16:43:07 +00:00
John Baldwin
88519d6427 Don't set if_start to tulip_ifstart all over the place. It is already
set in tulip_attach() and its value is never changed, so all the extra sets
are redundant.  I'm guessing that at some point in time de(4) had an
alternate start routine, but that hasn't been true in recent history.
2005-07-21 16:42:21 +00:00
John Baldwin
fe0c8544ff Remove conditional code that has largely rotted that is also not on by
default:
- TULIP_NEED_FASTTIMEOUT - tulip_fasttimeout() wasn't called anywhere
- BIG_PACKET - only worked on i386 anyway
- TULIP_USE_SOFTINTR - doesn't compile and was never updated to handle
  new netisr registration
- non-FreeBSD code
2005-07-21 16:40:08 +00:00
John Baldwin
9862c11e9d Use get_cyclecount() rather than hardcoding rdtsc and rpcc in asm for i386
and alpha, respectively.
2005-07-21 16:34:14 +00:00
John Baldwin
e5e871963c Fix a typo and some whitespace nits. 2005-07-21 16:33:05 +00:00
Gleb Smirnoff
016fcebe90 NET_LOCK_GIANT() when entering network code.
Pointy hat to:	glebius
Reported by:	rodrigc
2005-07-13 14:06:13 +00:00
Max Laier
ade6e491fc ALTQify ste(4).
Requested and tested by:	<nike_d at cytexbg dot com>
Approved by:			re (scottl)
2005-07-08 13:05:59 +00:00
Scott Long
8225bf4c36 Fix ifnet fallout in if_ti.
Reviewed by: brooks
Approved by: re
2005-07-07 01:05:45 +00:00
Eric Anholt
11b0d58251 Make the initialization in the AGPv3 case match that of Linux. Fixes hangs on
X startup with DRI enabled, with a v3-capable card.

Tested by:	Tom McLaughlin <tmclaugh@sdf.lonestar.org>
Approved by:	re (scottl)
2005-06-26 04:01:11 +00:00
Brooks Davis
cd036ec193 Move if_alloc() up so it's before mii_phy_probe(). 2005-06-11 01:37:46 +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
Yoshihiro Takahashi
d4fcf3cba5 Remove bus_{mem,p}io.h and related code for a micro-optimization on i386
and amd64.  The optimization is a trivial on recent machines.

Reviewed by:	-arch (imp, marcel, dfr)
2005-05-29 04:42:30 +00:00
Gleb Smirnoff
e9ace2571c Calling xl_rxeof() at the end of xl_start_locked() leads to recursion
in case of IP fast forwarding. Enqueue a taskqueue(9) task instead of
calling xl_rxeof() directly.

Reported & tested by:	Slava Alpatov
Reviewed by:		wpaul
MFC after:		1 week
2005-05-20 07:16:09 +00:00
Bjoern A. Zeeb
261a19c1ee Deal with failed malloc calls[1].
While there also check for failed device_add_child calls.

Found by:	Coventry Analysis tool[1].
Submitted by:	sam[1]
Approved by:	pjd (mentor)
MFC after:	1 week
2005-04-25 10:18:24 +00:00
Warner Losh
6d431b17c9 Fix newer Xircom CBE2-100 cards that were reporting
dc0: MII without any PHY!
We have to enable the connection to the MII first.  Doing so fixes the
problem cards without breaking the older, working cards.

Bad card provided by: deischen
2005-04-18 03:31:29 +00:00
Matthew N. Dodd
c7ae8b4fa8 Invert conditional and use continue to reduce nesting. 2005-04-13 01:32:06 +00:00
David E. O'Brien
fd92279bef Add nForce3-250. 2005-04-08 18:04:39 +00:00
David E. O'Brien
824a5e96dc nVidia AGP chipsets beyond nForce2 are AMD64-specific.
So move the AGP support to there.

Submitted by:	Jung-uk Kim <jkim@niksun.com>
2005-04-02 01:10:09 +00:00
Scott Long
69bbb4fe70 If resource allocation fails, we could wind up freeing the cdev without it
being allocated.  Add a simple check for this.

Submitted by: yongari
2005-03-31 17:16:40 +00:00
David E. O'Brien
f6bb4f25a4 Bring rev 1.31 to the AMD64 platform.
This adds support for the SiS intergrated NIC on some Athlon64 motherboards.
The MAC address is stored in the APC CMOS RAM and this fixes the
sis driver ending up with a 00:00:00:00:00:00 MAC address.

Submitted by:	Stasys Smailys <ssmailys@komvista.lt>
2005-03-28 18:06:44 +00:00
Sam Leffler
52c94c38dc deal with malloc failure when setting up the multicast filter
Noticed by:	Coverity Prevent analysis tool
2005-03-26 23:26:49 +00:00
Sam Leffler
af5691cdd5 handle malloc failure and sk_vpd_prodname potentially being null for
other reasons

Noticed by:	Coverity Prevent analysis tool
Reviewed by:	bz, jmg
2005-03-26 22:57:28 +00:00
Ruslan Ermilov
77d23c9bc3 xl(4) meets polling(4). Hardware for this work kindly provided by
Eric Masson.

MFC after:	3 weeks
2005-03-26 20:22:58 +00:00
Scott Long
586cfbb265 Start the process of modernizing the Tigon driver by using busdma for the
descriptor and configuration data.  Thanks to Martin Nilsson for providing
hardware.
2005-03-21 07:17:27 +00:00
Bjoern A. Zeeb
e7f8ebb45e Do not try to free non allocated memory in error case.
Do our best to plug some memory leaks (VPD data, jumbo memory buffer,...).
Log if we cannot free because memory still in use[1].
Change locking to avoid ''acquiring duplicate lock of same
  type: "network driver"'' and potential deadlock. Also seems to fix LOR #063.

[1] This change does not solve problems if buffers are still in use when
    unloading if_sk.ko. There is ongoing work which will address jumbogram
    allocations in a more general way.

PR:		kern/75677 (with changes, no mii fixes in here)
Tested by:	net, Antoine Brodin (slightly different version)
Approved by:	rwatson (mentor)
MFC after:	5 days
2005-03-17 14:27:22 +00:00
Bjoern A. Zeeb
9f0877efe3 * Lower interrupt moderation timer 200->100.
Obtained from:	NetBSD if_sk.c rev. 1.11

* Make interrupt moderation configurable via sysctl/tuneable.
PR:		kern/41220
Approved by:	rwatson (mentor)
2005-03-17 14:23:13 +00:00
Bjoern A. Zeeb
2dfd4c0a21 * Improve chip identification.
Obtained from:	NetBSD if_sk.c rev. 1.11

* Take PHY out of reset for Yukon Lite Rev. A3.
Submitted by:	postings on net@ in thread "skc0: no PHY found", 2005-02-22

Tested by:	net
Approved by:	rwatson (mentor)
MFC after:	5 days
2005-03-17 14:21:51 +00:00