Commit Graph

118 Commits

Author SHA1 Message Date
Doug Ambrisko
ecefd670f5 Style changes from avatar.
Submitted by:	avatar
2008-01-18 16:34:18 +00:00
Doug Ambrisko
f0e1e8d9fb First real attempt at proper locking. The locking is a little complicated
since the the command and data that is being built to be sent to or read
from the HW lives in the softc.  Commands are later run via an_setdef etc.
In the ioctl path various references are kept to the data stored in
the softc so it needs to be protected.  Almost think of the command
in the softc a global variable since it essentially is.  Since locking
wasn't done in this type of context the commands would get corrupted.

Thanks to avatar@ for catching some lock issues and dhw@ for testing.

Things are a lot more stable except for the MPI-350 cards.  My an(4)
remote laptop stays on the network now.

The driver should be changed so that it uses private memory that is passed
to the functions that talk to the card.  Then only those functions would
really need to grab locks.

Reviewed by:	avatar@
2008-01-18 16:31:24 +00:00
Tai-hwa Liang
8c81b154da MFP4(129048): Eliminating an unnecessary check on an_gone inside
an_stats_update() since a properly locked callout_stop(9) does do the
right thing.

Reviewed by:	ambrisko, jhb
MFC after:	3 days
2007-11-27 08:29:24 +00:00
Tai-hwa Liang
6404b10238 MFP4(128855, 129015):
- Trying to eliminate another racing by replacing the timeout(9) with
  callout APIs.  In addition to that, the callout_drain() in an_detach()
  help us to avoid a possible panic-on-free due to the callout API tries
  to lock a destroyed mutex.
- In an_stats_update(), check the return value of an_read_record(). This
  should reduce the chance of device removal(PCCARD) panic [2].
- Adding a comment to state the fact that an_stats_update() is now called
  via callout(9) with a lock held [2].

Submitted by:	jhb [1], ambrisko [2]
Reviewed by:	jhb, ambrisko
Reported by:	dhw
Tested by:	dhw
MFC after:	3 days
2007-11-16 11:22:18 +00:00
Tai-hwa Liang
73474451b9 Fixing invalid channel display in ifconfig(8) by implementing required
ioctl().

Note that other information provided by ifconfig(8) such like "list chan"
or "list ap" are still not available at this moment.

Before an(4) is connected to wlan(4), users are encouraged to use
ancontrol(8) to retrieve aforementioned information.

Reported by:	dhw (http://lists.freebsd.org/pipermail/freebsd-current/2007-July/074848.html)
Reviewed by:	ambrisko
Tested by:	dhw
Approved by:	re (bmah)
2007-09-10 12:53:34 +00:00
Tai-hwa Liang
07b6a9bed8 MFP4(123687): Closing another LOR by dropping the driver lock around calls
to if_input().

Reviewed by:	ambrisko
Tested by:	dhw
Approved by:	re (kensmith)
2007-08-07 12:26:19 +00:00
Tai-hwa Liang
d28ab8736f MFP4(123686): Fixing various ancontrol(8) related panics by dropping locks
around copyin()/copyout().

Reviewed by:	sam, thompsa
Tested by:	dhw
Approved by:	re (kensmith)
2007-08-02 02:20:19 +00:00
Matt Jacob
2342e96586 Remove assignment to uninitialized variable that wasn't then used anyway. 2007-06-08 01:21:20 +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
Robert Watson
acd3428b7d Sweep kernel replacing suser(9) calls with priv(9) calls, assigning
specific privilege names to a broad range of privileges.  These may
require some future tweaking.

Sponsored by:           nCircle Network Security, Inc.
Obtained from:          TrustedBSD Project
Discussed on:           arch@
Reviewed (at least in part) by: mlaier, jmg, pjd, bde, ceri,
                        Alex Lyashkov <umka at sevcity dot net>,
                        Skip Ford <skip dot ford at verizon dot net>,
                        Antoine Brodin <antoine dot brodin at laposte dot net>
2006-11-06 13:42:10 +00:00
Poul-Henning Kamp
c40da00ca3 Since DELAY() was moved, most <machine/clock.h> #includes have been
unnecessary.
2006-05-16 14:37:58 +00:00
Warner Losh
ccc0f2f0af Silence the strict-alias warnings. Make a trip through (void *) when
casting a structure to a uint32_t *.  Many drivers in the tree do this, but
I'll not update them until these changes can be reviewed by the pedantic
standards folks.
2006-02-04 22:51:03 +00:00
Nate Lawson
c74da55a0e Since the A-Z range is contained in the previous check, the else-if is
dead code.  Clean up both by using isprint() instead, since that's what
it really wants.

Coverity ID:	100
Found by:	Coverity Prevent
2006-01-26 19:55:29 +00:00
Robert Watson
f0ee42d0f1 Don't leak mbufs and mbuf clusters in several error-handling situations
in the if_an receive routine.

Found with:	Coverity Prevent (tm)
MFC after:	1 week
2006-01-15 12:09:03 +00:00
Robert Watson
63e0298298 If frame length is excessive, don't leak an mbuf and cluster when
abandoning processing.

Found with:	Coverity Prevent (tm)
MFC after:	1 week
2006-01-15 12:06:09 +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
d09ed26fd8 - Make IFP2ENADDR() a pointer to IF_LLADDR() rather than another
copy of Ethernet address.

- Change iso88025_ifattach() and fddi_ifattach() to accept MAC
  address as an argument, similar to ether_ifattach(), to make
  this work.
2005-11-11 07:36:14 +00:00
Warner Losh
09ec45fd15 MFp4: Remove OLDCARD shims 2005-09-22 04:51:11 +00:00
Warner Losh
b1d1a29cf6 MFp4: trivial KNF nits 2005-09-22 04:49:17 +00:00
Warner Losh
2a5481cafd MFp4: KNF (mostly remove K&R function definitions). Fix some spaces left
over from de__Ping.

# Didn't fix the -Exxxx return statements that appaer to be linuxisms
# (and wrong) since I don't have hardware to test with.
2005-09-22 04:46:56 +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
c2e94196e3 Minor style nits. 2005-08-03 15:07:14 +00:00
Maksim Yevmenkin
c20990577c Do not lock an to check gone flag. Only need to hold the lock to set
the gone flag.

Reviewed by:	imp
MFC after:	1 day
2005-08-02 16:03:51 +00:00
Maksim Yevmenkin
8a03cf5c82 Reorganize an_detach() a bit. Make sure ether_ifdetach() and if_free()
are called outside of AN_LOCK()/AN_UNLOCK. This fixes the following
WITNESS warning (produced when an(4) PCMCIA card is detached).

taskqueue_drain with the following non-sleepable locks held:
exclusive sleep mutex an0 (network driver) r = 0 (0xc59af168) locked @ /usr/src/sys/dev/an/if_an.c:2836

MFC after:	3 days
Silence from:	current@
2005-07-27 21:03:35 +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
Xin LI
2d0d7ca29f Initialize sc->an_ifp when doing if_alloc(). This prevents an(4)
from being panic when attaching.

Approved by:	re (scottl)
2005-06-14 14:50:40 +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
Sam Leffler
8f593c02c3 check copyin/copyout return values
Noticed by:	Coverity Prevent analysis tool
2005-03-28 17:52:12 +00:00
Warner Losh
53ee71735f Use BUS_PROBE_DEFAULT for pci probe return value 2005-03-05 19:06:12 +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
Max Laier
154b8df2ed Second part of ALTQ driver modifications, covering:
an(4), ath(4), hme(4), ndis(4), vr(4) and wi(4)

Please help testing: http://people.freebsd.org/~mlaier/ALTQ_driver/

Tested by:	Vaidas Damosevicius (an, ath, wi)
		Roman Divacky (vr)
Submitted by:	yongari (hme)
2004-08-01 23:58:04 +00:00
Doug Ambrisko
6cca5e3463 While setting up a transmit packet disable interupts on the card then
re-enable them after we are done setting up the packet.  This seems
to fix the MPI350 newer firmware hangs.
2004-06-17 02:19: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
fbfb97942e It turns out that the module dependency on pccard is in error. Since
there's not dependencies on pccard symboles, such a dependency is not
necessary.  This means that drivers that have multiple attachments can
not drag bogus devices into the kernel at load time.

We can't (yet) do this with pci and isa.  Drivers written for them
actually do seem to have symbols that depend on these busses'
implementation code.

ndis not touched until other things can be tested.
2004-05-08 06:04:06 +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
Doug Ambrisko
e2297e59c8 Remove the HACK section it breaks the older firmware and doesn't totally
fix the new firmware so remove it.
2004-01-10 03:02:04 +00:00
Doug Ambrisko
e84c87915b - Bump up the general and status RID sizes
- Clear out an_dma_vaddr on free so we can test to see if dma is
  setup when the card is kldunloaded/kldloaded etc. only for MPI350
- Use a common detach like wi(4)
- Notify on RID read overflow and truncate this currently causes
  a panic in -stable when the stack during an ifconfig an0 is done
  with newer firmware
- Convert from UNLOCK/tsleep/LOCK to msleep.  I thought I did that
  a while ago.
2003-12-30 01:07:12 +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
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
Warner Losh
146143aa36 Xircom Wireless Ethernet card is a rebadged Cisco 340, but with a
different vendor id/product id.

Submitted by: Keith Davis
2003-10-08 01:20:00 +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
Doug Ambrisko
50b09b375f Fix panic from having multiple locks held when updating firmware. AN_LOCK
was asserted during a tsleep resulting in a panic in tsleep.
2003-08-20 05:52:48 +00:00
Doug Ambrisko
e8ef0c2923 - Add support for Cisco latest firmware RID sizes that supports 25 SSIDs!
- Fix up TX speed changes.
- Make mpi-350 cards sort-of work with new firmware.  It RXs okay but TXs
  only work for about 14 packets then fails to get an interrupt.  The
  TX watchdog fires.  It has been reported that my hack for now doesn't
  break cards with the older firmware.  It appears my card has lost
  the ability to RX or TX at all but other peoples cards work.  I assume
  it got damaged in tansport.

MFC:	1 week.
2003-08-20 03:46:05 +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