Commit Graph

57 Commits

Author SHA1 Message Date
Marius Strobl
155781198a - According to the corresponding Linux, NetBSD and OpenSolaris
drivers, there should be a 1us delay after every write when
  bit-banging the MII. Also insert barriers in order to ensure
  the intended ordering. These changes hopefully will solve the
  bus wedging occasionally experienced with DM9102A since r182461.
- Deobfuscate dc_mii_readreg() a bit.
2008-12-07 23:02:37 +00:00
Marius Strobl
d0d67284f8 For chips with a broken DC_ISR_RX_STATE which f.e. never signals
stopped nor the waiting state and also no other means to check
whether the receiver is idle (see also r163774), we have no choice
than to call mii_tick(9) unconditionally even in the case of the
DC_REDUCED_MII_POLL handling as far as the RX side is concerned.
This isn't necessarily worse than checking whether RX is idle
though because unlike as with TX we're racing with the hardware,
which might receive packets any time while we poll the MII, anyway.

Reported and tested by:	Jacob Owens
Reviewed by:		yongari
MFC after:		3 days
2008-08-29 20:31:41 +00:00
Marius Strobl
ebc284cc83 - Const'ify the dc_devs array.
- Correct the maxsize parameter when creating the mbufs busdma tag to
  reflect the actual requirement of dc(4).
- Move the KASSERT in dc_newbuf() to the right spot.
- Also convert the TX side to take advantage of bus_dmamap_load_mbuf_sg(9).
- Move the comment regarding dc_start_locked() to the right spot.

MFC after:	2 weeks
2008-03-24 17:38:24 +00:00
Marius Strobl
82a67a70a2 o In order to reduce bug and code duplication fold handling of NICs
requiring DC_TX_ALIGN or DC_TX_COALESCE, which was previously done
  in dc_start_locked(), into dc_encap().
o In dc_encap():
  - If m_defrag() fails just drop the packet like other NIC drivers
    do. This should only happen when there's a mbuf shortage, in which
    case it was possible to end up with an IFQ full of packets which
    couldn't be processed as they couldn't be defragmented as they
    were taking up all the mbufs themselves. This includes adjusting
    dc_start_locked() to not trying to prepend the mbuf (chain) if
    dc_encap() has freed it.
  - Likewise, if bus_dmamap_load_mbuf() fails as dc_dma_map_txbuf()
    failed, free the mbuf possibly allocated by the above call to
    m_defrag() and drop the packet.
o In dc_txeof():
  - Don't clear IFF_DRV_OACTIVE unless there are at least 6 free TX
    descriptors. Further down the road dc_encap() will bail if there
    are only 5 or fewer free TX descriptors, causing dc_start_locked()
    to abort and prepend the dequeued mbuf again so it makes no sense
    to pretend we could process mbufs again when in fact we won't.
    While at it replace this magic 5 with a macro DC_TX_LIST_RSVD.
  - Just always assign idx to sc->dc_cdata.dc_tx_cons; it doesn't
    make much sense to exclude the idx == sc->dc_cdata.dc_tx_cons
    case.
o In dc_dma_map_txbuf() there's no need to set sc->dc_cdata.dc_tx_err
  to error if the latter is != 0, bus_dmamap_load_mbuf() already
  returns the same error value in that case anyway.
o For less overhead, convert to use bus_dmamap_load_mbuf_sg() for
  loading RX buffers.
o Remove some banal and/or outdated comments.

Approved by:	re (kensmith)
MFC after:	1 week
2007-08-05 11:28:19 +00:00
Marius Strobl
b1d161435e - Use our own callout (the dc_tick() callout uses varying periods
depending on the NIC and isn't used at all with HomePNA links)
  instead of if_slowtimo() for driving dc_watchdog() in order to
  avoid races accessing if_timer.
- Use bus_get_dma_tag() so dc(4) works on platforms requiring it.
- Don't bother to set if_mtu to ETHERMTU, ether_ifattach() does that.
- Remove an alpha remnant in dc_softc.
2006-12-06 01:56:38 +00:00
Gleb Smirnoff
6b9f5c941c - Consistently use if_printf() only in interface methods: if_start(),
if_watchdog, etc., or in functions used only in these methods.
  In all other functions in the driver use device_printf().
- Use __func__ instead of typing function name.

Submitted by:	Alex Lyashkov <umka sevcity.net>
2006-09-15 15:16:12 +00:00
Gleb Smirnoff
177625694d Fix the last commit.
Submitted by:	jhb
Pointy hat to:	glebius
2006-06-08 08:15:21 +00:00
Gleb Smirnoff
f67dea8260 Add device IDs for Linksys PCMPC200 Cardbus card.
PR:		kern/75582
Submitted by:	Gary Palmer
2006-06-07 12:26:23 +00:00
John Baldwin
1e2e70b1d6 - Switch on the full 32-bit device ID to avoid collisions between the
vendor-specific device ids across vendors.
- Include the revision in the dc_devs[] array instead of special casing
  the revid handling in dc_devtype().
- Use PCI bus accessors to read registers instead of pci_read_config()
  where possible.
- Use an 8-bit write to update the latency timer.
- Use PCIR_xxx constants and remove unused DC_xxx related to standard
  PCI config registers.

MFC after:	1 week
2006-06-03 20:41:55 +00:00
John Baldwin
9be0993cdb Add device-id for the Neteasy DRP-32TXD cardbus 10/100 card. It's another
ADMTek AN985 clone.

MFC after:	3 days
Tested by:	Lila liladude at aruba dot it
2006-03-16 20:00:39 +00:00
Marcel Moolenaar
8df1ebe9aa Fix the misalignment bugs differently than was done in the previous
commit. Copy the ethernet address into a local buffer, which we know
is sufficiently aligned for the width of the memory accesses that we
do. This also eliminates all suspicious and potentionally harmful
casts.

In collaboration with: ru
2005-12-02 01:23:20 +00:00
Marcel Moolenaar
829733d045 Resolve misalignment traps caused by changes to IF_LLADDR().
Use de16dec() and le16dec() to fetch the link-level address
from struct ifnet.

Tested on: alpha
Reviewed by: jhb
See also: de(4)
2005-11-22 01:51:57 +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
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
60727d8b86 /* -> /*- for license, minor formatting changes 2005-01-07 02:29:27 +00:00
Warner Losh
2756272aea Remove saved_* from dc_softc. They are now no longer needed.
Submitted by: Marius Strobl
2004-06-29 20:38:44 +00:00
Don Lewis
4ff4a9bee9 The transmit frame status is stored in the last transmit descriptor for the
frame, not the first.  It is probably also not safe to free the mbuf chain
as soon as the OWN bit is cleared on the first descriptor since the chip
may not be done copying the frame into the transmit FIFO.  Revert the part of
of busdma conversion (if_dc.c rev 1.115) which changed dc_txeof() to look for
the status in the first descriptor and free the mbuf chain when processing
the first descriptor for the frame, and revert the matching changes elsewhere
in the driver.  This part of the busdma change caused the driver to report
spurious collisions and output errors, even when running in full-duplex mode.
Reverting the mbuf chain handling slightly complicates dc_dma_map_txbuf(),
since it is responsible for setting the OWN bits on the descriptors, but does
not normally have direct access to the mbuf chain.

Tested by:
  Dejan Lesjak <dejan.lesjak at ijs.si>  alpha/<Intel 21143 10/100BaseTX>
  "Xin LI" <delphij at frontfree.net>    i386/<Macronix 98713 10/100BaseTX>
  Wiktor Niesiobedzki <bsd at w.evip.pl> i386/<3Com OfficeConnect 10/100B>

Reviewed by:	mux
2004-01-08 06:22:15 +00:00
MIHIRA Sanpei Yoshiro
773c505f3c Add support for ELECOM/Laneed CardBus FastEtherner Card(LD-CBL/TXA)
Submitted by:	Masahiro Yamagishi <night@pluto.dti.ne.jp>
Approved by:	re (scottl)
2003-12-06 02:29:31 +00:00
Sam Leffler
5120abbfb4 Drop the driver lock around calls to if_input to avoid a LOR when
the packets are immediately returned for sending (e.g.  when bridging
or packet forwarding).  There are more efficient ways to do this
but for now use the least intrusive approach.

Reviewed by:	imp, rwatson
2003-11-14 19:00:32 +00:00
Martin Blapp
87f4fa1512 Ignore CSR13, CSR14, CSR15 'Media Specific Data' registers
for 21143 based cards which use SIA mode.

This fixes 10mbit mode for ZNYX ZX346Q cards and other
21143 based cards.

PR:		32118
Submitted by:	Rene de Vries <rene@tunix.nl>
		Geert Jan de Groot <GeertJan.deGroot@tunix.nl>

Obtained from:	BSDI

MFC after:	2 weeks
2003-10-05 19:57:10 +00:00
Warner Losh
4c16d09eda Add support for FA-511; Submitted by: Kenneth P. Stox; Pr 42858 2003-07-19 06:01:15 +00:00
Bill Paul
e7b9ab3aaa Add support for a bunch of Microsoft networking products:
- MN-110 10/100 USB ethernet (ADMtek Pegasus II, if_aue)
- MN-120 10/100 cardbus (ADMtek Centaur-C, if_dc)
- MN-130 10/100 PCI (ADMtek Centaur-P, if_dc)

Also update dc(4) man page to mention support for MN-120 and MN-130.
2003-07-10 18:43:17 +00:00
Maxime Henrion
af4358c71e Make the dc(4) driver endian-clean, so to that it works on sparc64.
There are such cards in Netra X1 boxes, which should thus be fully
supported now.

Tested by:	jake
2003-07-09 15:03:10 +00:00
Maxime Henrion
56e5e7ae57 Convert the dc(4) driver to the busdma API. This is a necessary step
to have this driver working on sparc64.  It still needs to be made
endian-clean before it can work there.

Special thanks to dragonk@evilcode.net for sending me a dc(4) card so
that I was able to do this work.

Many cheers to all the people that tested this change, thanks to them,
this change shouldn't break anything :-).

Tested by:	marcel (i386 and ia64), ru (i386), wilko (alpha),
		mbr (i386), wpaul (i386) and
		Will Saxon <WillS@housing.ufl.edu> (i386)
2003-07-06 21:45:31 +00:00
Martin Blapp
e351d778f2 Add ADMtek ADM9511 and ADM9513 device ID's.
PR:		PR51823
Submitted by:	Kaho Toshikazu <kaho@elam.kais.kyoto-u.ac.jp>
Reviewed by:	phk
MFC after:	2 days
2003-06-08 10:11:55 +00:00
Martin Blapp
7eac366be1 Add support for 3Com OfficeConnect 10/100B.
PR:		49059, 50747
Submitted by:	Dax Eckenberg <daxbert@dweebsoft.com>
Reviewed by:	imp, jhb
Approved by:	jhb
MFC after:	2 weeks
2003-05-12 19:50:21 +00:00
MIHIRA Sanpei Yoshiro
97f9172896 Add support for Planex FNW-3602-T(CardBus 100M/10M).
Submitted by:	kazz <kazz@v001.vaio.ne.jp>
Obtained from:	[bsd-nomads:16637]
2003-04-18 15:42:25 +00:00
Warner Losh
948c244d94 Add preliminary support for the Hawking PN672TX CardBus cards.
# Preliminary because there are some subtle things the NetBSD driver does
# that we don't do yet.  My card works for me w/o them.
2003-01-10 05:37:15 +00:00
Tom Rhodes
38deb45fc3 Add support for the Davicom DM9009 chipset.
PR:		46859
Submitted by:	Boaz Haberman <boaz@ool-182f8b09.dyn.optonline.net>
Approved by:	rwatson
2003-01-09 20:51:39 +00:00
Semen Ustimenko
0f953c65d1 Fix the missspelt letter in DC_CTYPE_PUP_AUTOSENSe define.
Submitted by:	marius@alchemy.franken.de
MFC after:	3 days
2002-12-18 22:45:43 +00:00
Warner Losh
3097aa70be Dynamically configure the width of the srom. This code comes from
OpenBSD who got the code (or the idea) from the NetBSD tlp driver.

This gets some cardbus dc cards working (either completely or nearly
so).  It also appears to get additional pci cards working, without
breaking working ones.

# Maybe some additional work is needed here.  Also, the cardbus attachment
# might need to match on the CIS rather than on the vendor/device so we have
# a finer level of detail as to what the card is.  Technically, the
# vendor/device fields are undefined for CardBus (even though most cards are
# using common silicon with pci models).
2002-10-07 05:26:35 +00:00
Martin Blapp
7e346229db Enable the automatic TX underrun recovery for the ADMtek chips.
This solves cvsup update on my laptop which aborts after a while
without this patch.

PR:		34236
Reviewed by:	phk
MFC after:	2 weeks
2002-09-20 15:16:06 +00:00
Mitsuru IWASAKI
e8388e1466 Add suspend/resume code mostly merged from fxp/rl driver.
This is temporary hack, better and generalized solution probably
should be implemented at lower layer(MII or PCI?).
Tested by:	shoko.araki@soliton.co.jp
MFC after:	1 week
2002-05-06 10:55:42 +00:00
Doug Ambrisko
45fe21a0a2 Forgot one part of the VLAN support for the dc(4) driver.
Pointed out by: Shin-ichi YOSHIMOTO <yosimoto@waishi.jp>
2002-01-16 21:34:11 +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
Luigi Rizzo
2dfc960a5b Avoid an unnecessary copy of a packet if it is already in a single mbuf.
Introduce an additional device flag for those NICs which require the
transmit buffers to be aligned to 32-bit boundaries.

(the equivalen fix for STABLE is slightly simpler because there are
no supported chips which require this alignment there.)
2001-12-11 02:47:53 +00:00
Luigi Rizzo
617b3dd758 Defs for three (unused so far) bits in PCI command/status register
were off by one bit.
2001-10-25 17:43:26 +00:00
Bill Paul
1af8bec768 Add support for Conexant LANfinity miniPCI controllers. People who have
laptops with this chip should test this and report back as I don't have
access to this hardware myself. People with -stable systems should try
the patch at:

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

Submitted by:	Phil Kernick <Phil@Kernick.org>
2001-09-04 17:10:11 +00:00
Bill Paul
d467c136d0 Apply patch to allow TX underrun handling without issuing a complete
chip reset. Just temporarily turn off the transmitter instead.

Submitted by:	Stephen McKay <mckay@freebsd.org>
2001-02-22 19:26:55 +00:00
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
Jonathan Lemon
b50c63121d Change the driver to allocate its own callout structure, and modify
the interface to use callout_* instead of timeout().  Also add an
IS_MPSAFE #define (currently off) which will mark the driver as mpsafe
to the upper layers.
2000-11-25 08:00:10 +00:00
Bill Paul
fa167b8eaa Add support for the Accton EN2242 MiniPCI adapter. This is just an
ADMtek Centaur chip, so all we need is the PCI ID.

Submitted by:	Scott Lang <scottl@FreeBSD.org>
2000-11-14 19:35:22 +00:00
Bill Paul
1d5e53109c Add PCI IDs for some additional cardbus cards. Yes, there really is
a RealTek 8139 cardbus device. Unfortunately it doesn't quite work yet
because the CIS parser barfs on it.

Submitted by msmith, with some small tweaks by me.
2000-10-28 09:00:20 +00:00
Jonathan Chen
feb78939ee NEWCARD/Cardbus -
This commit adds support for Xircom X3201 based cardbus cards.
Support for the TDK 78Q2120 MII is also added.
IBM Etherjet, Intel and Xircom cards uses these chips.

Note that as a result of this commit, some Intel/DEC 21143 based cardbus
cards will also attach, but not get link.  That is being looked at.
2000-10-19 08:34:32 +00:00
Bill Paul
d1ce910572 First round of converting network drivers from spls to mutexes. This
takes care of all the 10/100 and gigE PCI drivers that I've done.
Next will be the wireless drivers, then the USB ones. I may pick up
some stragglers along the way. I'm sort of playing this by ear: if
anyone spots any places where I've screwed up horribly, please let me
know.
2000-10-13 17:54:19 +00:00
Bill Paul
5c1cfac46e Add support for parsing the media blocks from the SROM on 21143
adapters. This is necessary in order to make this driver work with
the built-in ethernet on the alpha Miata machines. These systems
have a 21143-PC chip on-board and optional daughtercards with either
a 10/100 MII transceiver or a 10baseT/10base2 transceiver. In both
cases, you need to twiddle the GPIO bits on the controller in order
to turn the transceivers on, and you have to read the media info
from the SROM in order to find out what bits to twiddle.
2000-10-05 17:36:14 +00:00
Bill Paul
78999dd117 Special-case the LED twiddling code so that it doesn't do anything
on the NEC VersaPro NoteBook PC. This 21143 implementation has no LEDs,
and flipping the LED control bits somehow stops it from establishing
a link. We check the subsystem ID and don't flip the LED control
bits for the NEC NIC.
2000-09-07 18:51:04 +00:00
Bill Paul
21aff61248 Define some more bits in CSR15 needed for previous change. 2000-09-02 00:02:51 +00:00
Bill Paul
c400cb27d2 Grrrr. Add definition for DC_WDOG_CTLWREN. I made this change yesterday
but stupidly only commited to if_dc.c.
2000-08-02 16:31:11 +00:00
Bill Paul
ead7cde9d1 Add the PCI IDs for the Macronix 98727 and 98732 parts. These are
3.3volt PCI/cardbus chipsets similar to the 98715 (and they have
512-bit hash tables). Also update the man page to mention the 98727/98732
and the SOHOware SFA110A Rev B4 card with the 98715AEC-C chip.
2000-07-17 19:27:41 +00:00