Commit Graph

186 Commits

Author SHA1 Message Date
Jung-uk Kim
fd90e2ed54 CALLOUT_MPSAFE has lost its meaning since r141428, i.e., for more than ten
years for head.  However, it is continuously misused as the mpsafe argument
for callout_init(9).  Deprecate the flag and clean up callout_init() calls
to make them more consistent.

Differential Revision:	https://reviews.freebsd.org/D2613
Reviewed by:	jhb
MFC after:	2 weeks
2015-05-22 17:05:21 +00:00
Adrian Chadd
2808a02bf4 Prepare for supporting driver-overridden curchan when submitting scan
results.

Right now the scan infrastructure assumes the channel is under net80211
control, and that when receiving beacon frames for scanning, the
current channel is indeed what ic_curchan is set to.

But firmware NICs with firmware scan support need more than this -
they can do background scans whilst hiding the off-channel behaviour
from net80211.  Ie, net80211 still thinks everything is associated
and on the main channel, but it's getting scan results from all the
background traffic.

However sta_add() pays attention to ic_curchan and discards scan
results that aren't on the right channel.  CCK beacon frames can be
decoded from adjacent channels so the receive path and sta_add
discard these as appropriate.  This is fine for software scanning
like for ath(4), but not for firmware NICs.  So with those, the
whole concept of background firmware scanning won't work without
major hacks (eg, overriding ic_curchan before calling the beacon
input / scan add.)

As part of my scan overhaul, modify sta_add() and the scan_add()
APIs to take an explicit current channel.  The normal RX path
will set it to ic_curchan so it's a no-op.  However, drivers may
decide to (eventually!) override the scan method to set the
"right" current channel based on what the firmware reports the
scan state is.

So for example, iwn, rsu and other NICs will eventually do this:

* driver issues scan start firmware command;
* firmware sends a "scan start on channel X" notify;
* firmware sends a bunch of beacon RX's as part of
  the scan results;
* .. and the driver will replace scan_add() curchan with channel X,
  so scan results are correct.
* firmware sends a "scan start on channel Y" notify;
* firmware sends more beacons...
* .. the driver replaces scan_add() curchan with channel Y.

Note:

* Eventually, net80211 should eventually grow the idea of a per-packet
  current channel.  It's possible in various modes (eg WAVE, P2P, etc)
  that individual frames can come in from different channels and that
  is under firmware control rather than driver/net80211 control, so
  we should support that.
2015-05-10 22:07:53 +00:00
Gleb Smirnoff
c8dfaf382f Mechanically convert to if_inc_counter(). 2014-09-19 03:51:26 +00:00
John Baldwin
d9abd30d22 When anouncing link state changes on an 802.11 interface with a vap,
announce the change on the vap's ifnet instead of the main ifnet.  This
matches the behavior of other wireless drivers in the tree and allows the
default devd configuration to correctly start dhclient automatically after
an ndis wireless device associates.

MFC after:	2 weeks
2014-08-29 22:01:47 +00:00
Gleb Smirnoff
76039bc84f The r48589 promised to remove implicit inclusion of if_var.h soon. Prepare
to this event, adding if_var.h to files that do need it. Also, include
all includes that now are included due to implicit pollution via if_var.h

Sponsored by:	Netflix
Sponsored by:	Nginx, Inc.
2013-10-26 17:58:36 +00:00
Andre Oppermann
bb25e5ab00 Give (*ext_free) an int return value allowing for very sophisticated
external mbuf buffer management capabilities in the future.

For now only EXT_FREE_OK is defined with current legacy behavior.

Sponsored by:	The FreeBSD Foundation
2013-08-25 10:57:09 +00:00
Gleb Smirnoff
c6499eccad Mechanically substitute flags from historic mbuf allocator with
malloc(9) flags in sys/dev.
2012-12-04 09:32:43 +00:00
Kevin Lo
5bbe0c5357 ether_ifattach() sets if_mtu to ETHERMTU, don't bother set it again
Reviewed by:	yongari
2012-01-07 09:41:57 +00:00
Bernhard Schmidt
fcd9500f91 Fix some net80211 enum nits:
- ic_vap_create() uses an ieee80211_opmode argument
- ieee80211_rate2media() takes an ieee80211_phymode argument
- ieee80211_plcp2rate() takes an ieee80211_phytype argument
- cast to enum ieee80211_protmode and ieee80211_roamingmode to silence
  compiler warnings

Submitted by:	arundel@
2011-12-17 10:23:17 +00:00
Bernhard Schmidt
750647ad62 Don't try to free an unassigned pointer.
Submitted by:	Paul B Mahol <onemda at gmail.com>
MFC after:	1 week
2011-01-07 18:41:59 +00:00
Bernhard Schmidt
96a911f614 There is no reason to call rt_ifmsg(), remove it.
Submitted by:	Paul B Mahol <onemda at gmail.com>
MFC after:	1 week
2010-10-19 19:11:36 +00:00
Rui Paulo
a6d8c83fd9 WPA_CSE_WEP104 was being incorrectly checked.
Found with:	clang
2010-10-13 14:37:52 +00:00
Rui Paulo
7edea21b22 len must be int, not size_t
Submitted by:	novel
2010-01-06 13:13:14 +00:00
Rui Paulo
ab925d255d Add net80211 media status reporting.
PR:		142197
Submitted by:	Paul <onemda at gmail.com>
2010-01-05 22:59:59 +00:00
Rui Paulo
2d7340428b Pass all IEs to net80211.
PR:		141376
Submitted by:	Paul <onemda at gmail.com>
MFC after:	1 week
2009-12-14 18:43:27 +00:00
John Baldwin
6b5ba0bba3 ndis_scan_results() can sleep if the scan results are not ready when
ndis_scan() is called.  However, ndis_scan() is invoked from softclock()
and cannot sleep.  Move ndis_scan_results() to the ndis' driver's scan_end
hook instead.

Submitted by:	Paul B Mahol  onemda of gmail
MFC after:	1 week
2009-12-02 16:26:18 +00:00
Rui Paulo
99081d1c61 Big style cleanup. While there remove references to FreeBSD versions
older than 6.0.

Submitted by:	Paul B Mahol <onemda at gmail.com>
2009-11-02 11:07:42 +00:00
Coleman Kane
00e6b158be Fix a bad use of NULL instead of zero for int comparison. Sorry for the
breakage.

Submitted by:	bz, des, onemda
MFC after:	3 days
2009-10-01 11:52:06 +00:00
Coleman Kane
ed44e7ec7d style(9) fixes (always compare pointers to NULL)
Also, the previous commit to sys/dev/if_ndis/if_ndis.c also included the
removal of a call to ndis_setstate_80211 that is no longer needed.

Submitted by:	sam
MFC after:	3 days
2009-10-01 02:43:51 +00:00
Coleman Kane
d63581ec39 Correct a bug that could lead to a kernel panic if a user attempted to
perform 802.11 operations directly on the ndis0 interface before the
first VAP (wlan0) had been created. This would lead to a NULL-pointer
dereference in the kernel.

Submitted by:	Paul B. Mahol <onemda@gmail.com>
MFC after:	3 days
2009-09-30 14:28:38 +00:00
Coleman Kane
52d75a271f The ndis_scan function may be started after ndis vap have been destroyed
PR:		kern/138632
Submitted by:	Paul B. Mahol <onemda at gmail.com>
MFC after:	3 days
2009-09-22 12:36:51 +00:00
Coleman Kane
e0d12c4b94 Fix regression in last set of commits. Submitted via e-mail and then
nagged again via PR. Thank Paul for his persistence and contributions.

PR:		136895
Submitted by:	Paul B. Mahol <onemda@gmail.com>
Reviewed by:	sam (timeout, 10 days), weongyo (timeout, 10 days), me
Approved by:	re (Kostik Belousov <kostikbel@gmail.com>)
2009-07-20 23:21:19 +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
Coleman Kane
7c1a5c7c93 Code cleanup by moving some repetitive code into an ndis_get_bssid_list
helper function. Also, add ieee80211_announce() call for bootverbose case.

Submitted by:	Paul B. Mahol <onemda@gmail.com>
2009-06-23 14:37:07 +00:00
Andrew Thompson
ed6d949afd - Make struct usb_xfer opaque so that drivers can not access the internals
- Reduce the number of headers needed for a usb driver, the common case is just   usb.h and usbdi.h
2009-06-23 02:19:59 +00:00
Coleman Kane
d9cacbcf4f Replace use of ic->ic_flags with vap->iv_flags to operate on per-vap flags
for ndis 802.11 work.

Submitted by:	Paul B. Mahol <onemda@gmail.com>
2009-06-18 11:12:10 +00:00
Coleman Kane
badff0e4d8 Fix an LOR
Submitted by:	Paul B. Mahol <onemda@gmail.com>
MFC after:	1 week
2009-06-10 18:00:10 +00:00
Sam Leffler
e6c3129877 fix setting of ni_txrate
Submitted by:	"Paul B. Mahol" <onemda@gmail.com>
2009-06-02 20:32:13 +00:00
Sam Leffler
74904f7d58 update for net80211 rx api change 2009-05-20 23:33:40 +00:00
Andrew Thompson
5efea30f03 Create a taskqueue for each wireless interface which provides a serialised
sleepable context for net80211 driver callbacks. This removes the need for USB
and firmware based drivers to roll their own code to defer the chip programming
for state changes, scan requests, channel changes and mcast/promisc updates.
When a driver callback completes the hardware state is now guaranteed to have
been updated and is in sync with net80211 layer.

This nukes around 1300 lines of code from the wireless device drivers making
them more readable and less race prone.

The net80211 layer has been updated as follows
 - all state/channel changes are serialised on the taskqueue.
 - ieee80211_new_state() always queues and can now be called from any context
 - scanning runs from a single taskq function and executes to completion. driver
   callbacks are synchronous so the channel, phy mode and rx filters are
   guaranteed to be set in hardware before probe request frames are
   transmitted.

Help and contributions from Sam Leffler.

Reviewed by:	sam
2009-05-02 15:14:18 +00:00
Andrew Thompson
a0c4317cc2 Only call ieee80211_start_all() if its a 80211 device.
Submitted by:	Paul B. Mahol
2009-04-16 23:42:00 +00:00
Sam Leffler
9fb0fccb89 o add a capability for drivers that require 802.3 encapsulation of
frames passed down through the transmit path
o mark ndis requiring 802.3 encap'd frames

Reviewed by:	"Paul B. Mahol" <onemda@gmail.com>, thompsa
2009-04-08 16:19:50 +00:00
Sam Leffler
29aca94080 Eliminate ic_myaddr so changing the mac address of a device works correctly:
o remove ic_myaddr from ieee80211com
o change ieee80211_ifattach to take the mac address of the physical device
  and use that to setup the lladdr.
o replace all references to ic_myaddr in drivers by IF_LLADDR
o related cleanups (e.g. kill dead code)

PR:		kern/133178
Reviewed by:	thompsa, rpaulo
2009-03-29 17:59:14 +00:00
Weongyo Jeong
c4f82f895d set NULL after free to avoid duplicate free.
Tested by:	Ganbold <ganbold_at_micom.mng.net>
2009-03-24 04:20:17 +00:00
Weongyo Jeong
2c964f43b6 o change a lock model based on HAL preemption lock to a normal mtx.
Based on the HAL preemption lock there is a problem on SMP machines
  and causes a panic.
o When a device detached the current tactic to detach NDIS USB driver is
  to call SURPRISE_REMOVED event.  So it don't need to call
  ndis_halt_nic() again.  This fixes some page faults when some drivers
  work abnormal.
o it assumes now that URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER is in
  DISPATCH_LEVEL (non-sleepable) and as further work
  URB_FUNCTION_VENDOR_XXX and URB_FUNCTION_CLASS_XXX should be.

Reviewed by:	Hans Petter Selasky <hselasky_at_freebsd.org>
Tested by:	Paul B. Mahol <onemda_at_gmail.com>
2009-03-12 02:51:55 +00:00
Sam Leffler
f11fe89814 Fix TXPMGT handling:
o correct dBm<->mW conversion logic
o set net80211 TXPMGT capability only if driver reports it is capable

PR:		kern/132342
Submitted by:	"Paul B. Mahol" <onemda@gmail.com>
2009-03-09 02:37:52 +00:00
Weongyo Jeong
6affafd098 o port NDIS USB support from USB1 to the new usb(USB2).
o implement URB_FUNCTION_ABORT_PIPE handling.
o remove unused code related with canceling the timer list for USB
  drivers.
o whitespace cleanup and style(9)

Obtained from:	hps's original patch
2009-03-07 07:26:22 +00:00
Andrew Thompson
3975e3a1ea Move usb to a graveyard location under sys/legacy/dev, it is intended that the
new USB2 stack will fully replace this for 8.0.

Remove kernel modules, a subsequent commit will update conf/files. Unhook
usbdevs from the build.
2009-02-23 18:16:17 +00:00
Andrew Thompson
1e736167a5 Provide a NDIS tx power level converstion to/from net80211, this uses a loookup
table to approximate mW<->dBM.

Submitted by:	Paul B. Mahol
2009-01-12 17:15:09 +00:00
Weongyo Jeong
c862b05ba7 fix a typo to set the 48Mbps data rate.
PR:		kern/130189
Submitted by:	Paul B. Mahol <onemda_at_gmail.com>
Reviewed by:	sam
MFC after:	3 weeks
2009-01-09 02:31:51 +00:00
Weongyo Jeong
b3974c00b5 Integrate the NDIS USB support code to CURRENT.
Now the NDISulator supports NDIS USB drivers that it've tested with
devices as follows:

  - Anygate XM-142 (Conexant)
  - Netgear WG111v2 (Realtek)
  - U-Khan UW-2054u (Marvell)
  - Shuttle XPC Accessory PN20 (Realtek)
  - ipTIME G054U2 (Ralink)
  - UNiCORN WL-54G (ZyDAS)
  - ZyXEL G-200v2 (ZyDAS)

All of them succeeded to attach and worked though there are still some
problems that it's expected to be solved.

To use NDIS USB support, you should rebuild and install ndiscvt(8) and
if you encounter a problem to attach please set `hw.ndisusb.halt' to
0 then retry.

I expect no changes of the NDIS code for PCI, PCMCIA devices.

Obtained from:  //depot/projects/ndisusb/...
2008-12-27 08:03:32 +00:00
Sam Leffler
e0a11d8bec hookup mcast and promisc callbacks
Submitted by:	"Paul B. Mahol" <onemda@gmail.com>
2008-11-30 20:48:57 +00:00
Andrew Thompson
a1f8daf412 Fake the assoc id so that ndis can work on the latest net80211.
PR:		kern/128750
Submitted by:	Paul B. Mahol
2008-11-11 03:36:15 +00:00
Weongyo Jeong
db102f9a37 sc->ndis_txidx should be cycle between 0 and sc->ndis_maxpkts, not
NDIS_TXPKTS and don't allocate unused extra spaces for sc->ndis_txarray
and sc->ndis_txpool.

PR:		kern/127644
Submitted by:	Antoine Pelisse <apelisse_at_gmail.com>
MFC after:	1 week
2008-10-04 04:15:39 +00:00
Coleman Kane
093d7be50e Fix a mutex LOR introduced by the conversion of if_ndis from spinlocks to
mutexes and replacing the obsolete if_watchdog interface. The ndis_ticktask
function calls into ieee80211_new_state under one condition with NDIS_LOCK
held. The ieee80211_new_state would call into ndis_start in some cases too,
resulting in the occasional case where ndis_start acquires NDIS_LOCK from
inside the NDIS_LOCK held by ndis_ticktask.

Obtained from:	Paul B. Mahol <onemda@gmail.com>
MFC after:	1 week
2008-07-09 00:10:55 +00:00
Coleman Kane
21a6592999 Convert ndis_spinlock to ndis_mtx and start using the sleepable
mtx interface for NDIS_LOCK/UNLOCK. This should result in less
CPU utilization on behalf of the ndis driver. Additionally, this
commit also fixes a potential LOR in the ndis_tick code, by
not locking inside the ndis_tick function, but instead delegating
that work to the helpers called through IoQueueWorkItem. The
way that this is currently set up for NDIS prevents us from
simply implementing a callout_init_mtx mechanism.

However, the helper functions that handle the various timeout
cases implement fine-grained locking using the spinlocks provided
by the NDIS-compat layer, and using the mtx that is added with
this commit. This leaves the following ndis_softc members operated
on in ndis_tick in an unlocked context:

  * ndis_hang_timer - Only modified outside of ndis_tick once, before
                      the first callout_reset to schedule ndis_tick
  * ifp->if_oerrors - Only incremented in two places, which should be
                      an atomic op
  * ndis_tx_timer   - Assigned to 5 (when guaranteed to be 0) or 0
                      (in txeof), to indicate to ndis_tick what to
                      do. This is the only member of which I was
                      suspicious for needing the NDIS_LOCK here. My
                      testing (and another's) have been fine so far.
  * ndis_stat_callout - Only uses a simple set of callout routines,
                        callout_reset only called by ndis_tick after
                        the initial reset, and then callout_drain is
                        used exactly once in shutdown code.

The benefit is that ndis_tick doesn't acquire NDIS_LOCK unless one of
the timeout conditions is flagged, and it still obeys the locking
order semantics that are dictated by the NDIS layer at the moment. I
have been investigating a more thorough s/spinlock/mtx/ of the NDIS
layer, but the simplest naive approach (replace KeAcquireSpinLock
with an mtx implementation) has anti-succeeded for me so far. This
is a good first step though.

Tested by:	onemda@gmail.com
Reviewed by:	current@, jhb, thompsa
Proposed by:	jhb
2008-06-11 13:40:15 +00:00
Coleman Kane
e97f228a10 Update if_ndis to remove the legacy if_watchdog interface and
bring it more up to date. The watchdog timer, and its
associated code, is all collapsed into the ndis_tick function
that was implemented for the NDIS-subsystem watchdog. This
implementation is similar to what numerous other drivers use
to implement the watchdog.

Reviewed by:	thompsa, jhb
MFC after:	2 weeks
2008-06-03 00:55:48 +00:00
Weongyo Jeong
e54b92f37b Fix a panic that it's occurred when NDIS init handler returned a error
by unknown reasons.   In this case, sc->ifp is still NULL so it will
cause a page fault during calling ndis_detach()
2008-05-30 07:17:51 +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
6ba643ce87 - Associate from a taskq as we can deadlock on the ndis hal and the com lock.
- Remove double vap init (ieee80211_start_all)
- Keep ic_curchan in sync with the scan results.
2008-05-10 20:12:43 +00:00