Deleted Added
full compact
ieee80211.c (283566) ieee80211.c (283568)
1/*-
2 * Copyright (c) 2001 Atsushi Onoe
3 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 11 unchanged lines hidden (view full) ---

20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2001 Atsushi Onoe
3 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 11 unchanged lines hidden (view full) ---

20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/net80211/ieee80211.c 283566 2015-05-26 12:40:27Z glebius $");
28__FBSDID("$FreeBSD: head/sys/net80211/ieee80211.c 283568 2015-05-26 13:19:05Z glebius $");
29
30/*
31 * IEEE 802.11 generic handler
32 */
33#include "opt_wlan.h"
34
35#include <sys/param.h>
36#include <sys/systm.h>

--- 53 unchanged lines hidden (view full) ---

90static void ieee80211_syncflag_ext_locked(struct ieee80211com *ic, int flag);
91static int ieee80211_media_setup(struct ieee80211com *ic,
92 struct ifmedia *media, int caps, int addsta,
93 ifm_change_cb_t media_change, ifm_stat_cb_t media_stat);
94static void ieee80211com_media_status(struct ifnet *, struct ifmediareq *);
95static int ieee80211com_media_change(struct ifnet *);
96static int media_status(enum ieee80211_opmode,
97 const struct ieee80211_channel *);
29
30/*
31 * IEEE 802.11 generic handler
32 */
33#include "opt_wlan.h"
34
35#include <sys/param.h>
36#include <sys/systm.h>

--- 53 unchanged lines hidden (view full) ---

90static void ieee80211_syncflag_ext_locked(struct ieee80211com *ic, int flag);
91static int ieee80211_media_setup(struct ieee80211com *ic,
92 struct ifmedia *media, int caps, int addsta,
93 ifm_change_cb_t media_change, ifm_stat_cb_t media_stat);
94static void ieee80211com_media_status(struct ifnet *, struct ifmediareq *);
95static int ieee80211com_media_change(struct ifnet *);
96static int media_status(enum ieee80211_opmode,
97 const struct ieee80211_channel *);
98static uint64_t ieee80211_get_counter(struct ifnet *, ift_counter);
98
99MALLOC_DEFINE(M_80211_VAP, "80211vap", "802.11 vap state");
100
101/*
102 * Default supported rates for 802.11 operation (in IEEE .5Mb units).
103 */
104#define B(r) ((r) | IEEE80211_RATE_BASIC)
105static const struct ieee80211_rateset ieee80211_rateset_11a =

--- 192 unchanged lines hidden (view full) ---

298 IEEE80211_TX_LOCK_INIT(ic, ic->ic_name);
299 TAILQ_INIT(&ic->ic_vaps);
300
301 /* Create a taskqueue for all state changes */
302 ic->ic_tq = taskqueue_create("ic_taskq", M_WAITOK | M_ZERO,
303 taskqueue_thread_enqueue, &ic->ic_tq);
304 taskqueue_start_threads(&ic->ic_tq, 1, PI_NET, "%s net80211 taskq",
305 ic->ic_name);
99
100MALLOC_DEFINE(M_80211_VAP, "80211vap", "802.11 vap state");
101
102/*
103 * Default supported rates for 802.11 operation (in IEEE .5Mb units).
104 */
105#define B(r) ((r) | IEEE80211_RATE_BASIC)
106static const struct ieee80211_rateset ieee80211_rateset_11a =

--- 192 unchanged lines hidden (view full) ---

299 IEEE80211_TX_LOCK_INIT(ic, ic->ic_name);
300 TAILQ_INIT(&ic->ic_vaps);
301
302 /* Create a taskqueue for all state changes */
303 ic->ic_tq = taskqueue_create("ic_taskq", M_WAITOK | M_ZERO,
304 taskqueue_thread_enqueue, &ic->ic_tq);
305 taskqueue_start_threads(&ic->ic_tq, 1, PI_NET, "%s net80211 taskq",
306 ic->ic_name);
307 ic->ic_ierrors = counter_u64_alloc(M_WAITOK);
308 ic->ic_oerrors = counter_u64_alloc(M_WAITOK);
306 /*
307 * Fill in 802.11 available channel set, mark all
308 * available channels as active, and pick a default
309 * channel if not already specified.
310 */
311 ieee80211_media_init(ic);
312
313 ic->ic_update_mcast = null_update_mcast;

--- 82 unchanged lines hidden (view full) ---

396 /* NB: must be called before ieee80211_node_detach */
397 ieee80211_proto_detach(ic);
398 ieee80211_crypto_detach(ic);
399 ieee80211_power_detach(ic);
400 ieee80211_node_detach(ic);
401
402 /* XXX VNET needed? */
403 ifmedia_removeall(&ic->ic_media);
309 /*
310 * Fill in 802.11 available channel set, mark all
311 * available channels as active, and pick a default
312 * channel if not already specified.
313 */
314 ieee80211_media_init(ic);
315
316 ic->ic_update_mcast = null_update_mcast;

--- 82 unchanged lines hidden (view full) ---

399 /* NB: must be called before ieee80211_node_detach */
400 ieee80211_proto_detach(ic);
401 ieee80211_crypto_detach(ic);
402 ieee80211_power_detach(ic);
403 ieee80211_node_detach(ic);
404
405 /* XXX VNET needed? */
406 ifmedia_removeall(&ic->ic_media);
407 counter_u64_free(ic->ic_ierrors);
408 counter_u64_free(ic->ic_oerrors);
404
405 taskqueue_free(ic->ic_tq);
406 IEEE80211_TX_LOCK_DESTROY(ic);
407 IEEE80211_LOCK_DESTROY(ic);
408}
409
410/*
411 * Default reset method for use with the ioctl support. This

--- 6 unchanged lines hidden (view full) ---

418 */
419static int
420default_reset(struct ieee80211vap *vap, u_long cmd)
421{
422 return ENETRESET;
423}
424
425/*
409
410 taskqueue_free(ic->ic_tq);
411 IEEE80211_TX_LOCK_DESTROY(ic);
412 IEEE80211_LOCK_DESTROY(ic);
413}
414
415/*
416 * Default reset method for use with the ioctl support. This

--- 6 unchanged lines hidden (view full) ---

423 */
424static int
425default_reset(struct ieee80211vap *vap, u_long cmd)
426{
427 return ENETRESET;
428}
429
430/*
431 * Add underlying device errors to vap errors.
432 */
433static uint64_t
434ieee80211_get_counter(struct ifnet *ifp, ift_counter cnt)
435{
436 struct ieee80211vap *vap = ifp->if_softc;
437 struct ieee80211com *ic = vap->iv_ic;
438 uint64_t rv;
439
440 rv = if_get_counter_default(ifp, cnt);
441 switch (cnt) {
442 case IFCOUNTER_OERRORS:
443 rv += counter_u64_fetch(ic->ic_oerrors);
444 break;
445 case IFCOUNTER_IERRORS:
446 rv += counter_u64_fetch(ic->ic_ierrors);
447 break;
448 default:
449 break;
450 }
451
452 return (rv);
453}
454
455/*
426 * Prepare a vap for use. Drivers use this call to
427 * setup net80211 state in new vap's prior attaching
428 * them with ieee80211_vap_attach (below).
429 */
430int
431ieee80211_vap_setup(struct ieee80211com *ic, struct ieee80211vap *vap,
432 const char name[IFNAMSIZ], int unit, enum ieee80211_opmode opmode,
433 int flags, const uint8_t bssid[IEEE80211_ADDR_LEN],

--- 9 unchanged lines hidden (view full) ---

443 }
444 if_initname(ifp, name, unit);
445 ifp->if_softc = vap; /* back pointer */
446 ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST;
447 ifp->if_transmit = ieee80211_vap_transmit;
448 ifp->if_qflush = ieee80211_vap_qflush;
449 ifp->if_ioctl = ieee80211_ioctl;
450 ifp->if_init = ieee80211_init;
456 * Prepare a vap for use. Drivers use this call to
457 * setup net80211 state in new vap's prior attaching
458 * them with ieee80211_vap_attach (below).
459 */
460int
461ieee80211_vap_setup(struct ieee80211com *ic, struct ieee80211vap *vap,
462 const char name[IFNAMSIZ], int unit, enum ieee80211_opmode opmode,
463 int flags, const uint8_t bssid[IEEE80211_ADDR_LEN],

--- 9 unchanged lines hidden (view full) ---

473 }
474 if_initname(ifp, name, unit);
475 ifp->if_softc = vap; /* back pointer */
476 ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST;
477 ifp->if_transmit = ieee80211_vap_transmit;
478 ifp->if_qflush = ieee80211_vap_qflush;
479 ifp->if_ioctl = ieee80211_ioctl;
480 ifp->if_init = ieee80211_init;
481 ifp->if_get_counter = ieee80211_get_counter;
451
452 vap->iv_ifp = ifp;
453 vap->iv_ic = ic;
454 vap->iv_flags = ic->ic_flags; /* propagate common flags */
455 vap->iv_flags_ext = ic->ic_flags_ext;
456 vap->iv_flags_ven = ic->ic_flags_ven;
457 vap->iv_caps = ic->ic_caps &~ IEEE80211_C_OPMODE;
458 vap->iv_htcaps = ic->ic_htcaps;

--- 1388 unchanged lines hidden ---
482
483 vap->iv_ifp = ifp;
484 vap->iv_ic = ic;
485 vap->iv_flags = ic->ic_flags; /* propagate common flags */
486 vap->iv_flags_ext = ic->ic_flags_ext;
487 vap->iv_flags_ven = ic->ic_flags_ven;
488 vap->iv_caps = ic->ic_caps &~ IEEE80211_C_OPMODE;
489 vap->iv_htcaps = ic->ic_htcaps;

--- 1388 unchanged lines hidden ---