From e8361ca0ffd3961053bf9f10c70e5be9ea1831ec Mon Sep 17 00:00:00 2001 From: Joe Talbott Date: Sun, 25 Jul 2010 16:08:19 -0400 Subject: [PATCH] wlan - Convert lockmgr locking to a global token. Use the lwkt_token API to synchronize the wlan layer entry points. Discussed-With: dillon --- sys/netproto/802_11/ieee80211.h | 2 ++ sys/netproto/802_11/ieee80211_dragonfly.h | 8 ++++++++ sys/netproto/802_11/wlan/ieee80211.c | 4 ++++ sys/netproto/802_11/wlan/ieee80211_ioctl.c | 1 + sys/netproto/802_11/wlan/ieee80211_power.c | 1 + sys/netproto/802_11/wlan/ieee80211_proto.c | 3 +++ sys/netproto/802_11/wlan/ieee80211_scan.c | 2 ++ 7 files changed, 21 insertions(+) diff --git a/sys/netproto/802_11/ieee80211.h b/sys/netproto/802_11/ieee80211.h index d6ab4ba420..fdd4d5d9f1 100644 --- a/sys/netproto/802_11/ieee80211.h +++ b/sys/netproto/802_11/ieee80211.h @@ -1085,4 +1085,6 @@ struct ieee80211_duration { IEEE80211_DUR_DS_SLOW_PLCPHDR + \ IEEE80211_DUR_DIFS) +extern lwkt_token wlan_token; + #endif /* _NET80211_IEEE80211_H_ */ diff --git a/sys/netproto/802_11/ieee80211_dragonfly.h b/sys/netproto/802_11/ieee80211_dragonfly.h index 03a5eac4e7..04d6370e64 100644 --- a/sys/netproto/802_11/ieee80211_dragonfly.h +++ b/sys/netproto/802_11/ieee80211_dragonfly.h @@ -46,6 +46,7 @@ typedef struct { char name[16]; /* e.g. "ath0_com_lock" */ struct lock lock; } ieee80211_com_lock_t; +/* #define IEEE80211_LOCK_INIT(_ic, _name) do { \ ieee80211_com_lock_t *cl = &(_ic)->ic_comlock; \ ksnprintf(cl->name, sizeof(cl->name), "%s_com_lock", _name); \ @@ -58,6 +59,13 @@ typedef struct { #define IEEE80211_UNLOCK(_ic) lockmgr(IEEE80211_LOCK_OBJ(_ic), LK_RELEASE) #define IEEE80211_LOCK_ASSERT(_ic) \ KKASSERT(lockstatus(IEEE80211_LOCK_OBJ(_ic), curthread) != 0) +*/ +#define IEEE80211_LOCK_INIT(_ic, _name) +#define IEEE80211_LOCK_OBJ(_ic) (NULL) +#define IEEE80211_LOCK_DESTROY(_ic) +#define IEEE80211_LOCK(_ic) lwkt_gettoken(&wlan_token) +#define IEEE80211_UNLOCK(_ic) lwkt_reltoken(&wlan_token) +#define IEEE80211_LOCK_ASSERT(_ic) ASSERT_LWKT_TOKEN_HELD(&wlan_token) /* * Node locking definitions. diff --git a/sys/netproto/802_11/wlan/ieee80211.c b/sys/netproto/802_11/wlan/ieee80211.c index e98f5b9972..2d3e5d9d59 100644 --- a/sys/netproto/802_11/wlan/ieee80211.c +++ b/sys/netproto/802_11/wlan/ieee80211.c @@ -37,6 +37,7 @@ #include #include +#include #include #include @@ -115,6 +116,9 @@ static const struct ieee80211_rateset ieee80211_rateset_11g = { 12, { B(2), B(4), B(11), B(22), 12, 18, 24, 36, 48, 72, 96, 108 } }; #undef B +/* Global token used for wlan layer and wireless NIC driver layer */ +lwkt_token wlan_token; + /* * Fill in 802.11 available channel set, mark * all available channels as active, and pick diff --git a/sys/netproto/802_11/wlan/ieee80211_ioctl.c b/sys/netproto/802_11/wlan/ieee80211_ioctl.c index 5e44f28722..c5244a7496 100644 --- a/sys/netproto/802_11/wlan/ieee80211_ioctl.c +++ b/sys/netproto/802_11/wlan/ieee80211_ioctl.c @@ -2298,6 +2298,7 @@ ieee80211_ioctl_setappie(struct ieee80211vap *vap, int error; uint8_t fc0; + ic = vap->iv_ic; fc0 = ireq->i_val & 0xff; if ((fc0 & IEEE80211_FC0_TYPE_MASK) != IEEE80211_FC0_TYPE_MGT) return EINVAL; diff --git a/sys/netproto/802_11/wlan/ieee80211_power.c b/sys/netproto/802_11/wlan/ieee80211_power.c index a3d4541485..a3b31e7e94 100644 --- a/sys/netproto/802_11/wlan/ieee80211_power.c +++ b/sys/netproto/802_11/wlan/ieee80211_power.c @@ -285,6 +285,7 @@ ieee80211_set_tim(struct ieee80211_node *ni, int set) uint16_t aid; int changed; + ic = ni->ni_ic; KASSERT(vap->iv_opmode == IEEE80211_M_HOSTAP || vap->iv_opmode == IEEE80211_M_IBSS, ("operating mode %u", vap->iv_opmode)); diff --git a/sys/netproto/802_11/wlan/ieee80211_proto.c b/sys/netproto/802_11/wlan/ieee80211_proto.c index 7c38085d88..6e8d0f3948 100644 --- a/sys/netproto/802_11/wlan/ieee80211_proto.c +++ b/sys/netproto/802_11/wlan/ieee80211_proto.c @@ -936,6 +936,7 @@ ieee80211_wme_initparams(struct ieee80211vap *vap) { struct ieee80211com *ic = vap->iv_ic; + ic = vap->iv_ic; IEEE80211_LOCK(ic); ieee80211_wme_initparams_locked(vap); IEEE80211_UNLOCK(ic); @@ -1293,6 +1294,7 @@ ieee80211_stop(struct ieee80211vap *vap) { struct ieee80211com *ic = vap->iv_ic; + ic = vap->iv_ic; IEEE80211_LOCK(ic); ieee80211_stop_locked(vap); IEEE80211_UNLOCK(ic); @@ -1881,6 +1883,7 @@ ieee80211_new_state(struct ieee80211vap *vap, struct ieee80211com *ic = vap->iv_ic; int rc; + ic = vap->iv_ic; IEEE80211_LOCK(ic); rc = ieee80211_new_state_locked(vap, nstate, arg); IEEE80211_UNLOCK(ic); diff --git a/sys/netproto/802_11/wlan/ieee80211_scan.c b/sys/netproto/802_11/wlan/ieee80211_scan.c index 432637a1c6..43b7b75f20 100644 --- a/sys/netproto/802_11/wlan/ieee80211_scan.c +++ b/sys/netproto/802_11/wlan/ieee80211_scan.c @@ -453,6 +453,7 @@ ieee80211_start_scan(struct ieee80211vap *vap, int flags, const struct ieee80211_scanner *scan; int result; + ic = vap->iv_ic; scan = ieee80211_scanner_get(vap->iv_opmode); if (scan == NULL) { IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN, @@ -831,6 +832,7 @@ scan_mindwell(struct ieee80211_scan_state *ss) { struct ieee80211com *ic = ss->ss_ic; + ic = ss->ss_ic; IEEE80211_LOCK(ic); scan_signal(ss); IEEE80211_UNLOCK(ic); -- 2.41.0