Commit Graph

76 Commits

Author SHA1 Message Date
Andrew Turner
c8045145b7 Use bus space functions rather than inw/outw
to help a future port of the driver to ARM.

Approved by:	imp (mentor)
2011-01-29 00:53:58 +00:00
John Baldwin
f0c734d5e3 Remove some always-true comparisons.
Submitted by:	clang via rdivacky
2011-01-18 15:23:16 +00:00
Maxim Sobolev
e50d35e6c6 Add new tunable 'net.link.ifqmaxlen' to set default send interface
queue length. The default value for this parameter is 50, which is
quite low for many of today's uses and the only way to modify this
parameter right now is to edit if_var.h file. Also add read-only
sysctl with the same name, so that it's possible to retrieve the
current value.

MFC after:	1 month
2010-05-03 07:32:50 +00:00
Warner Losh
73f0e8eb9c Add a warning if we're inw'ing from an odd address. This could happen
due to a bug and might be the real basis for the cardbus workaround
hack.
2010-01-18 17:53:44 +00:00
Warner Losh
9103854246 Fix indentation nit. 2010-01-18 17:52:57 +00:00
Martin Blapp
c2ede4b379 Remove extraneous semicolons, no functional changes.
Submitted by:	Marc Balmer <marc@msys.ch>
MFC after:	1 week
2010-01-07 21:01:37 +00:00
Robert Watson
eb956cd041 Use if_maddr_rlock()/if_maddr_runlock() rather than IF_ADDR_LOCK()/
IF_ADDR_UNLOCK() across network device drivers when accessing the
per-interface multicast address list, if_multiaddrs.  This will
allow us to change the locking strategy without affecting our driver
programming interface or binary interface.

For two wireless drivers, remove unnecessary locking, since they
don't actually access the multicast address list.

Approved by:	re (kib)
MFC after:	6 weeks
2009-06-26 11:45:06 +00:00
Warner Losh
4c1a8a173c Improve the EEPROM parsing, based on finding a datasheet that describes
it in detail.

When setting media, don't error out when a specific media is selected.
# Note: There may be some issues still here since the EtherJet PC Card doesn't
# conform to the datasheet.  Many different kinds of dongles can be plugged in
# and it is unknown how to ask which one it is.

Also, add a /* bad! */ comment to a 1/2 second delay after we set the
DC/DC parameters.  This should be a *sleep of some sort for !cold.
Fortunately it is the only one and is only used when setting media, so
the benefit from removing it is small.  Unfortunately, it likely
serves as an exemplar of good programming techniques, which it isn't.
2008-07-09 16:47:55 +00:00
Warner Losh
aa754333fc Tweak a comment and a constant to restore old 30ms upper bound.
cs_readreg takes ~2us not ~1us to run.
2008-06-06 17:27:19 +00:00
Warner Losh
194dffc052 o Remove unused cs_debug tunable. I think I added it and then nothing with
it.  Bad imp.  Removing us dips us under 10,000 in size too.
o Replace an unconditional 30ms DELAY (yes, busy wait) with a check of the
  SIBUSY bit in the SelfST register before accessing the eeprom.  This changes
  the time to read the EEPROM from 2 * 20 * 30ms (1.2s) to < 20*25us (.0005s)
  and make the attach of the card tolerable when ethernet media is present.
  Include data from the datasheet about why this works.  While this is a 2500x
  speed increase, it doesn't really matter at all once the card is probed...
o set dev earlier in softc.
2008-06-06 17:22:07 +00:00
Warner Losh
836fbcb341 Forgot to commit these files too :-( 2008-06-06 16:10:10 +00:00
Warner Losh
29f92ad3d3 Minor clean up to shave about 1.5k off the size of the driver:
o remove unused fields from softc and args from cs_alloc_irq
o remove some commented code that will never be implemented.
o Don't try to send a packet and see if it worked.  We don't
  need this anymore, and it doesn't add any value.
o tweaks for BNC and AUI.
o limit possible time hung in the kernel to 4s rather than 40s.
2008-06-06 05:25:24 +00:00
Warner Losh
71de0324d9 Simplify error checking when reading the function.... 2008-06-06 05:02:36 +00:00
Warner Losh
97a7fcc1d9 cs has detach, remove bogus ifdef.
Remove dedundant initialization of error to 0.
2008-06-06 05:02:01 +00:00
Warner Losh
b893c8d09d Remove unused fields in softc. If they are ever really needed again,
they can re-added.  Remove CS_NAME.  Don't whine when there's an
ignored checksum error: User has said STFU, so we should S the FU.
(remove mandated properties).
2008-06-06 04:56:27 +00:00
John Baldwin
5d5028e774 Make the cs(4) driver MPSAFE:
- Add a mutex to the softc to protect the softc and the device hardware.
- Add a private timer to manage transmit watchdogs rather than using
  if_timer/if_watchdog.
- Setup the interrupt handler after ether_ifattach().

Tested by:	imp
2008-06-05 14:49:35 +00:00
Warner Losh
c6ac76ad73 Fix the media auto code by breaking it :-). Auto now just means 'use
10BaseT' since it required 10BaseT to have carrier to switch to it.
This chip makes it hard to do proper auto, so we don't do it.  We
can't test carrier on things easily.

Don't insist on carrier when we set the media.  Don't report failures.
Remove a 1s! delay that appears to not be needed.

With these patches, and John Baldwin's patches, I'm able to pass
packets on my IBM EtherJet card again.
2008-06-05 05:51:19 +00:00
Warner Losh
9018f9625d o Improve the probe code dealing with interrupts.
o When forced to be 10baseT, don't require that the 10baseT interface
  have link to succeed.  Still require it for IFM_AUTO, however, since it
  appears that there's no way to tell if a specific type of interface
  worked.  I'm doing a web search for a datasheet now to see if there's
  anything obvious.
o Minor incidental formatting nits, including collapsing code of the form
	if (foo) {
		bar();
	} else {
		if (baz)
			bing();
	}
  into:
	if (foo) {
		bar();
	} else if (baz) {
		bing();
	}
  to save an indentation level.
o Remove stray reference to 3.x config file syntax.

# I believe John's patches still apply after this...
2008-06-04 06:07:13 +00:00
Warner Losh
b56700df65 Correct logic error that would prevent cs pccards from working on
systems where the CardBus bridge was connected to a APIC.  The case
where the probe routine is told to not setup the IRQ was mishandled
but the error was masked in the case where the IRQ was a valid one
for the card.

MFC after:	1 week
2008-06-03 05:47:28 +00:00
Paolo Pisati
ef544f6312 o break newbus api: add a new argument of type driver_filter_t to
bus_setup_intr()

o add an int return code to all fast handlers

o retire INTR_FAST/IH_FAST

For more info: http://docs.freebsd.org/cgi/getmsg.cgi?fetch=465712+0+current/freebsd-current

Reviewed by: many
Approved by: re@
2007-02-23 12:19:07 +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
Philip Paeps
f3953b3844 Fix multicast support for cs89x0 chips. Just setting the RX_MULTCAST_ACCEPT
flag isn't enough - the filter needs to be set up too, or no multicast frames
are accepted.

Sponsored by:	Philips Industrial Applications (indirectly)
MFC after:	3 days
2006-03-10 23:50:53 +00:00
Warner Losh
6600b2ce30 Use ETHER_ADDR_LEN rather than 6. 2006-02-11 03:50:03 +00:00
Warner Losh
7a5b855af3 Remove oldcard support by removing the compat shims. 2005-09-20 19:49:33 +00:00
Warner Losh
ad4f426ef6 Make sure that we call if_free(ifp) after bus_teardown_intr. Since we
could get an interrupt after we free the ifp, and the interrupt
handler depended on the ifp being still alive, this could, in theory,
cause a crash.  Eliminate this possibility by moving the if_free to
after the bus_teardown_intr() call.
2005-09-19 03:10:21 +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
Warner Losh
ab581af779 Eliminate unused argument in PCMCIA_CARD macro.
Provide a backwards compatible way to have the extra macro by defining
PCCARD_API_LEVEL 5 before including pccarddevs for driver writers that
want/need to have the same driver on 5 and 6 with pccard attachments.

Approved by: re (dwhite)
2005-06-24 14:36:54 +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
268334ebbd Fix the worst offenders of style(9) with a small style sweep. 2005-01-28 06:50:59 +00:00
Warner Losh
26cfd0d78b Cleanup tabs vs spaces. 2005-01-28 06:45:42 +00:00
Warner Losh
eb71b55c32 For the PC Card implementation of the CS8920M that's in my IBM
EtherJet, the interrupt is selected in the eeprom based on the layout
of the PC Card board.  Since this is encoded into the EEPROM, and has
no relationship to the IRQ that the pccard bridge routes the PC Card's
interrupt pin to.

As such, stop writing to that register.  This gets my EtherJet working.

# The eeprom reading code appears to be totally wrong for my EtherJet
# card.  This causes the card to bogusly detect the media options
# available.
2005-01-28 06:35:39 +00:00
Warner Losh
ad787127cf Setting hw.cs.recv_delay should set the delay, not the ignore the
eeprom checksum.
2005-01-28 06:13:29 +00:00
Warner Losh
c1195b0646 error = is needed before ether_ioctl() so that unsupported/unknown
IOCLTs are properly handled.  This gets the cs driver properly
reporting things via ifconfig.

# my pccard still doesn't work.
2005-01-28 00:28:22 +00:00
Warner Losh
221db7416d Write cs_detach() and use it. This resolves the twin problems of the
cs1 interface linger on card eject, as well as the warnings about the
card still using resources.  Ooops.
2005-01-27 04:51:44 +00:00
Warner Losh
ca33f4678a Only attach to network functions (unlikely to matter since I'm not
aware of any multi-function cs cards, but it doesn't hurt).
2005-01-20 19:56:22 +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
Robert Watson
de1af409d2 Since if_cs doesn't contain locking or run with INTR_MPSAFE, mark
the interface as IFF_NEEDSGIANT so if_start is run holding Giant.
2004-08-13 23:03:11 +00:00
Warner Losh
2e31e339d1 Fix disordering of pccarddevs.h noticed by bde. Also remove a few
redundant includes and fix some of the include disordering.

Submitted by: bde
2004-05-27 03:49:45 +00:00
Warner Losh
dba6dd177b Move to generating pccarddevs.h on the fly, both for the kernel and
the modules.

Also generate usbdevs.h automatically now, but a non-kernel file is
stopping that at the moment.
2004-05-26 00:53:10 +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
Warner Losh
c7a0a4c076 We don't need the dependency on the pccard module here. 2004-05-08 06:06:13 +00:00
Luigi Rizzo
0318355d0e Remove improper use of if_addrhead in device drivers to check
if the link-level address has been initialized already.

The majority of modern drivers never does this and works fine, which
makes me think that the check is totally unnecessary and a residue
of cut&paste from other drivers.

This change is done to simplify locking because now almost none of the
drivers uses this field. The exceptions are "ct" "ctau" and "cx"
where i am not sure if i can remove that part.
2004-04-15 20:31:10 +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
Matthew N. Dodd
e3bbbec2ca Announce ethernet MAC addresss in ether_ifattach(). 2004-03-14 07:12:25 +00:00
Warner Losh
fcedf425bd o Add sysctl to allow ignoring checksum of eeprom.
o Fix minor type problems
o Fix minor problem with a couple debug printfs.
o Default to a sane media type when none is reported.
o Minor style changes

The PR complains this will fix the IBM 300GL cards.

Submitted by: Max Gotlib
PR: 11462
2003-11-04 02:59:57 +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
c020a92f9f There is no way to enter the attach routine twice with the same softc
without a detach call in between so don't try to deal with that
possiability.

This is a diff-reduction commit for the upcoming if_xname conversion.
2003-10-30 19:45:58 +00:00
David E. O'Brien
aad970f1fe Use __FBSDID().
Also some minor style cleanups.
2003-08-24 17:55:58 +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
Warner Losh
f5746231ff Make sure that pp_name is non-null before setting the device
description.  This allows us to rely entirely on the CIS entries if
necessary...
2003-04-10 04:36:02 +00:00