Commit Graph

316 Commits

Author SHA1 Message Date
Warner Losh
db4ba9a33e Remove opt_wi.h 2008-08-27 05:39:44 +00:00
Warner Losh
dcf77c235d The APDL-325 is a Wireless LAN pcmcia adapter that sits inside some
Billion Access Points.  Fix wi(4) to recognise the adapter.

PR:		77913
Submitted by:	Daan Vreeken [PA4DAN]
MFC after:	3 days
2008-08-27 04:52:27 +00:00
Warner Losh
24b934392e Add an altnerative Siemens SpeedStream ID. This one is for a Prism 3
card.  I got a pair of these at a garage sale for US$1.00 today...
2008-08-02 20:50:13 +00:00
Warner Losh
15820ef70c Report what kind of chip only under bootverbose since that's now
exported via a sysctl.
2008-08-02 20:49:01 +00:00
Warner Losh
f043f9621e Minor tweaks to names and comments now that I understand what's going
on better.
2008-08-02 20:45:28 +00:00
Warner Losh
0c5544bb64 Export the hardware type (as number and name), the secondary firmware
revision and (on Prism cards) the primary firmware revision via
sysctl.  Move the printing of this information under bootverbose,
since it is relatively easy to get to it now.
2008-07-28 17:00:37 +00:00
Warner Losh
febcff0a3b Register the interrupt handler at the end of wi_attach rather than at
the beginning.  There's a race in the shared interrutp case.  If
another interrupt happens after the interrupt is setup, then we'd try
to lock an uninitialized mutex.  In addition, if we bailed out due to
a too old version of firmware, we'd leave the interrupt enabled with
all the fun that ensues....
2008-07-26 17:04:30 +00:00
Sam Leffler
c43feede8b Minor cleanup of vap create work:
o add IEEE80211_C_STA capability to indicate sta mode is supported
  (was previously assumed) and mark drivers as capable
o add ieee80211_opcap array to map an opmode to the equivalent capability bit
o move IEEE80211_C_OPMODE definition to where capabilities are defined so it's
  clear it should be kept in sync (on future additions)
o check device capabilities in clone create before trying to create a vap;
  this makes driver checks unneeded
o make error codes return on failed clone request unique
o temporarily add console printfs on clone request failures to aid in
  debugging; these will move under DIAGNOSTIC or similar before release
2008-05-12 00:15:30 +00:00
Andrew Thompson
77197f9ce4 Only start the vaps if the init routine completed. 2008-05-10 20:25:59 +00:00
Andrew Thompson
31a8c1edd8 Unify all the wifi *_ioctl routines
- Limit grabbing the lock to SIOCSIFFLAGS.
 - Move ieee80211_start_all() to SIOCSIFFLAGS.
 - Remove SIOCSIFMEDIA as it is not useful.
 - Limit ether_ioctl to only SIOCGIFADDR. SIOCSIFADDR and SIOCSIFMTU have no
   affect as there is no input/output path in the vap parent.  The vap code
   will handle the reinit of the mac address changes.
 - Split off ndis_ioctl_80211 as it was getting too different to wired devices.

This fixes a copyout while locked and a lock recursion.

Reviewed by:		sam
2008-05-01 04:55:00 +00:00
Sam Leffler
b032f27c36 Multi-bss (aka vap) support for 802.11 devices.
Note this includes changes to all drivers and moves some device firmware
loading to use firmware(9) and a separate module (e.g. ral).  Also there
no longer are separate wlan_scan* modules; this functionality is now
bundled into the wlan module.

Supported by:	Hobnob and Marvell
Reviewed by:	many
Obtained from:	Atheros (some bits)
2008-04-20 20:35:46 +00:00
Andrew Thompson
18337730db Make wi_set_channel() actually change the channel in hardware so that hostap
mode works properly, previously the hostap channel could not be changed off #3.

Fix an ifp/sc misuse while I am here.

Reported by:	many
Approved by:	re (bmah)
2007-09-16 20:02:29 +00:00
Sam Leffler
14fb6b8fe2 o add 802.11 state machine states for DFS and client-side power save
o fixup drivers to ignore new states

Reviewed by:	avatar (?)
Approved by:	re (blanket wireless)
2007-09-05 21:31:32 +00:00
Tai-hwa Liang
c7f6197937 MFP4(123963): Fixing a possible NULL pointer dereference by making
the actual assignment after the NULL check.

Found by:	Coverity Prevent(tm)
CID:		2303 (run 4156)
Reviewed by:	sam
Approved by:	re (bmah)
2007-08-09 13:29:26 +00:00
Andrew Thompson
9baf942d49 Now that wicontrol has been removed from the base system the corresponding
ioctls can be removed. These have been #ifdef'd out and left as a reference in
case any of the RIDs need to be turned into sysctls at a later date.

Reviewed by:	sam, avatar
Approved by:	re (kensmith)
2007-07-11 21:25:48 +00:00
Andrew Thompson
d81b3a5588 Fix scanning issues since the new net80211 code went in
- provide dummy routines for ic_scan_curchan and ic_scan_mindwell, we do not support those operations.
- add ieee80211_scan_done() to tell the scanning module that all channels have been scanned.
- pass IEEE80211_S_SCAN state off to net80211 so it can initiate scanning
- fix overflow in the rates array
- scale the rate value passed back from the firmware scan to the units that net80211 uses.

Submitted by:	Token
Reviewed by:	sam, avatar
Approved by:	re (kensmith)
2007-06-30 21:39:21 +00:00
Andrew Thompson
b54b1bab4b Change the channel number in the scan results struct to be a pointer to the
operating channel and use this in the scan cache rather than directly using
ic_curchan. Some firmware cards can only do a full scan and so ic_curchan does
not have the correct value.

Also add IEEE80211_CHAN2IEEE to directly dereference ic_ieee from the channel
to be used in the fast path.

Reviewed by:	sam, sephe
Approved by:	re (kensmith)
2007-06-30 21:23:23 +00:00
Andrew Thompson
d35985e711 Fix the channel reporting when the card is associated. The channel array used
to be index by IEEE channel number but that is no longer the case and it needs
to be searched for.

Submitted by:	avatar
Reviewed by:	sam
Approved by:	re (kensmith)
2007-06-30 21:12:41 +00:00
Sam Leffler
68e8e04e93 Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
  fully enumerated and uniquely identify the operating characteristics;
  these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
  background scanning and roaming
o move scanning support into loadable modules based on the operating
  mode to enable different policies and reduce the memory footprint
  on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
  mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
  we use a simple algorithm to trigger a roam: we threshold the rssi
  and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
  drivers but is incomplete; it's included now to establish a baseline
  for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
  prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
  encapsulation (note this can be used with any card that can tx+rx
  large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
  authentication and association failures
o enable the addition of sta mode power save support for drivers that need
  net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
  results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
  index into the rate set; this needs to be extended to deal with
  multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing

Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
       dynamic turbo (lightly tested), 11n (sniffing only and needs
       new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
       rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested

This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others.  Much of the scanning work was supported by
Atheros.  The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
Sepherosa Ziehau
b03cfe2396 - Fix mbuf/node leakage in drivers' raw_xmit().
- For ural(4):
  o  Fix node leakage in ural_start(), if ural_tx_mgt() fails.
  o  Fix mbuf leakage in ural_tx_{mgt,data}(), if usbd_transfer() fails.
  o  In ural_tx_{mgt,data}(), set ural_tx_data.{m,ni} to NULL, if
     usbd_transfer() fails, so they will not be freed again in ural_stop().

Approved by:	sam (mentor)
2007-04-19 13:09:57 +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
Sam Leffler
a5d62f191b replace if_watchdog w/ a private callout
MFC after:	1 month
2006-12-11 00:41:22 +00:00
Sam Leffler
fe8184b687 drop softc lock when passing rx frames up the stack
MFC after:	1 month
2006-12-11 00:37:12 +00:00
Sam Leffler
f8f1546232 split wi_start int locked+unlocked variants and use the unlocked
one from the isr to eliminate a recursive lock

MFC after:	1 month
2006-12-11 00:35:51 +00:00
Sam Leffler
df64e1e4ef nuke compatibility cruft
MFC after:	1 month
2006-12-11 00:32:15 +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
Sam Leffler
330608ccb6 raw 802.11 packet transmit support
Submitted by:	Andrea Bittau <a.bittau@cs.ucl.ac.uk>
2006-08-05 04:58:25 +00:00
Tai-hwa Liang
334ee2771b Really fix the typo this time: it should be sc->sc_drvbpf to be verified,
not ic->ic_drvbpf.
2006-06-05 23:06:03 +00:00
Tai-hwa Liang
edc428baef Fixing a typo in rev1.196. 2006-06-05 22:59:14 +00:00
Christian S.J. Peron
16d878cc99 Fix the following bpf(4) race condition which can result in a panic:
(1) bpf peer attaches to interface netif0
	(2) Packet is received by netif0
	(3) ifp->if_bpf pointer is checked and handed off to bpf
	(4) bpf peer detaches from netif0 resulting in ifp->if_bpf being
	    initialized to NULL.
	(5) ifp->if_bpf is dereferenced by bpf machinery
	(6) Kaboom

This race condition likely explains the various different kernel panics
reported around sending SIGINT to tcpdump or dhclient processes. But really
this race can result in kernel panics anywhere you have frequent bpf attach
and detach operations with high packet per second load.

Summary of changes:

- Remove the bpf interface's "driverp" member
- When we attach bpf interfaces, we now set the ifp->if_bpf member to the
  bpf interface structure. Once this is done, ifp->if_bpf should never be
  NULL. [1]
- Introduce bpf_peers_present function, an inline operation which will do
  a lockless read bpf peer list associated with the interface. It should
  be noted that the bpf code will pickup the bpf_interface lock before adding
  or removing bpf peers. This should serialize the access to the bpf descriptor
  list, removing the race.
- Expose the bpf_if structure in bpf.h so that the bpf_peers_present function
  can use it. This also removes the struct bpf_if; hack that was there.
- Adjust all consumers of the raw if_bpf structure to use bpf_peers_present

Now what happens is:

	(1) Packet is received by netif0
	(2) Check to see if bpf descriptor list is empty
	(3) Pickup the bpf interface lock
	(4) Hand packet off to process

From the attach/detach side:

	(1) Pickup the bpf interface lock
	(2) Add/remove from bpf descriptor list

Now that we are storing the bpf interface structure with the ifnet, there is
is no need to walk the bpf interface list to locate the correct bpf interface.
We now simply look up the interface, and initialize the pointer. This has a
nice side effect of changing a bpf interface attach operation from O(N) (where
N is the number of bpf interfaces), to O(1).

[1] From now on, we can no longer check ifp->if_bpf to tell us whether or
    not we have any bpf peers that might be interested in receiving packets.

In collaboration with:	sam@
MFC after:	1 month
2006-06-02 19:59:33 +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
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
Warner Losh
29d8617285 Add ELSA XI330 product. This is rebadged and sold as SMC 2532W-B and
I/O Data also resells it.  Add an alternative airvast an100 id.
2005-10-14 15:06:16 +00:00
Tai-hwa Liang
fec39060e2 Fixing WEP bustage in hostap mode since 5.2-RELEASE.
- WEP TX fix:

  The original code called software crypto, ieee80211_crypto_encap(),
which never worked since IEEE80211_KEY_SWCRYPT was never flagged due to
ieee80211_crypto_newkey() assumes that wi always supports hardware based
crypto regardless of operational mode(by virtue of IEEE80211_C_WEP).
This fix works around that issue by adding wi_key_alloc() to force
the use of s/w crypto.  Also if anyone ever decides to cleanup ioctl
handling where key changes wouldn't cause a call to wi_init() every time,
we'll need wi_key_alloc() to DTRT.

  In addition to that, this fix also adds code to wi_write_wep() to force
existing keys to be switched between h/w and s/w crypto such that an
operation mode change(sta <-> hostap) will flag IEEE80211_KEY_SWCRYPT
properly.

- WEP RX fix:

  Clear IEEE80211_F_DROPUNENC even in hostap mode.  Quote from Sam:

	"This is really gross but I don't see an easy way around it.
	By doing it we lose the ability to independently drop unencode
	frames (and support mixed wep/!wep use).  We should really be
	setting the EXCLUDE_UNENCRYPTED flag written in wi_write_wep
	based on IEEE80211_F_DROPUNENC but with our clearing it we can't
	depend on it being set properly."

Reported by:	Holm Tiffe <holm at freibergnet dot de>
Submitted by:	sam
MFC after:	3 days
2005-10-02 04:29:08 +00:00
Tai-hwa Liang
4f4035be47 Honouring ic->ic_dtim_period.
Submitted by:	sam
MFC after:	3 days
2005-10-02 03:55:07 +00:00
Ruslan Ermilov
a2f9548d05 Fix "taskqueue_drain with the following non-sleepable locks held"
witness(9) warning on detach.
2005-09-28 09:27:46 +00:00
Warner Losh
0ed03bc788 MFp4: save mac addr hint, eliminage OLDCARD shims 2005-09-22 05:11:50 +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
Scott Long
d85dcbcd54 Correct previous commit. 2005-08-29 20:06:02 +00:00
Warner Losh
08daf78765 Eliminate bogus seatbelt in wi_cmd. This may have been appropriate
for the spl-era locking, but now that we can have multiple, concurrent
interrupts for multiple wi devices, having a global check to make sure
at most one of them was in wi_cmd no longer makes sense.

MFC After: 2 decifortnight
2005-08-29 15:46:41 +00:00
Sam Leffler
80f05a81d9 fix media_status so devd recognizes the device as an 802.11 interface
Submitted by:	Robert C. Noland III
2005-08-13 00:04:42 +00:00
Sam Leffler
b5c9941514 Clarify/fix handling of the current channel:
o add ic_curchan and use it uniformly for specifying the current
  channel instead of overloading ic->ic_bss->ni_chan (or in some
  drivers ic_ibss_chan)
o add ieee80211_scanparams structure to encapsulate scanning-related
  state captured for rx frames
o move rx beacon+probe response frame handling into separate routines
o change beacon+probe response handling to treat the scan table
  more like a scan cache--look for an existing entry before adding
  a new one; this combined with ic_curchan use corrects handling of
  stations that were previously found at a different channel
o move adhoc neighbor discovery by beacon+probe response frames to
  a new ieee80211_add_neighbor routine

Reviewed by:	avatar
Tested by:	avatar, Michal Mertl
MFC after:	2 weeks
2005-08-10 16:22:30 +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
Sam Leffler
d365f9c760 Cleanup beacon/listen interval handling:
o separate configured beacon interval from listen interval; this
  avoids potential use of one value for the other (e.g. setting
  powersavesleep to 0 clobbers the beacon interval used in hostap
  or ibss mode)
o bounds check the beacon interval received in probe response and
  beacon frames and drop frames with bogus settings; not clear
  if we should instead clamp the value as any alteration would
  result in mismatched sta+ap configuration and probably be more
  confusing (don't want to log to the console but perhaps ok with
  rate limiting)
o while here up max beacon interval to reflect WiFi standard

Noticed by:	Martin <nakal@nurfuerspam.de>
MFC after:	1 week
2005-08-08 03:30:57 +00:00
Warner Losh
584d11ee54 When the MAC address is reported all zeros, then error is necessarily
0.  This means that we 'succeed' the attach, even after we've freed
the internal data bits.  This leads to a panic when you eject the card
with this problem.

Set error = ENXIO in the mac read zeros case.
2005-08-05 04:56:14 +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
Sam Leffler
2c39b32c94 diff reduction against p4: define IEEE80211_FIXED_RATE_NONE and use
it instead of -1
2005-07-22 16:50:18 +00:00
Warner Losh
ba8f34770d Add a boatload of new device ids, gleaned from the pcmcia-cs-3.2.8
distribution.  Add the appropriate devices to the man pages.

Obtained from: pcmcia-cs
Approved by: re (scottl)
2005-07-10 02:00: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
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