From b6b2fb599b0e3e606c923e678563d04959a32ad2 Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Tue, 26 May 2015 04:37:59 +0000 Subject: [PATCH] Migrate the scan iterator lock typedefs out into ieee80211_freebsd.h. This removes the final piece of freebsd-specific locking that snuck into the tree - it's now all inside ieee80211_freebsd.h. --- sys/net80211/ieee80211_freebsd.h | 7 +++++++ sys/net80211/ieee80211_scan_sta.c | 10 +++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/sys/net80211/ieee80211_freebsd.h b/sys/net80211/ieee80211_freebsd.h index dc26b9158b89..f9517da78006 100644 --- a/sys/net80211/ieee80211_freebsd.h +++ b/sys/net80211/ieee80211_freebsd.h @@ -183,6 +183,13 @@ typedef struct mtx ieee80211_scan_table_lock_t; #define IEEE80211_SCAN_TABLE_LOCK(_st) mtx_lock(&(_st)->st_lock) #define IEEE80211_SCAN_TABLE_UNLOCK(_st) mtx_unlock(&(_st)->st_lock) +typedef struct mtx ieee80211_scan_iter_lock_t; +#define IEEE80211_SCAN_ITER_LOCK_INIT(_st, _name) \ + mtx_init(&(_st)->st_scanlock, _name, "802.11 scangen", MTX_DEF) +#define IEEE80211_SCAN_ITER_LOCK_DESTROY(_st) mtx_destroy(&(_st)->st_scanlock) +#define IEEE80211_SCAN_ITER_LOCK(_st) mtx_lock(&(_st)->st_scanlock) +#define IEEE80211_SCAN_ITER_UNLOCK(_st) mtx_unlock(&(_st)->st_scanlock) + /* * Mesh node/routing definitions. */ diff --git a/sys/net80211/ieee80211_scan_sta.c b/sys/net80211/ieee80211_scan_sta.c index b1034cedebe1..c0cbb7d2de4f 100644 --- a/sys/net80211/ieee80211_scan_sta.c +++ b/sys/net80211/ieee80211_scan_sta.c @@ -102,7 +102,7 @@ struct sta_table { ieee80211_scan_table_lock_t st_lock; /* on scan table */ TAILQ_HEAD(, sta_entry) st_entry; /* all entries */ LIST_HEAD(, sta_entry) st_hash[STA_HASHSIZE]; - struct mtx st_scanlock; /* on st_scaniter */ + ieee80211_scan_iter_lock_t st_scanlock; /* on st_scaniter */ u_int st_scaniter; /* gen# for iterator */ u_int st_scangen; /* scan generation # */ int st_newscan; @@ -165,7 +165,7 @@ sta_attach(struct ieee80211_scan_state *ss) if (st == NULL) return 0; IEEE80211_SCAN_TABLE_LOCK_INIT(st, "scantable"); - mtx_init(&st->st_scanlock, "scangen", "802.11 scangen", MTX_DEF); + IEEE80211_SCAN_ITER_LOCK_INIT(st, "scangen"); TAILQ_INIT(&st->st_entry); ss->ss_priv = st; nrefs++; /* NB: we assume caller locking */ @@ -183,7 +183,7 @@ sta_detach(struct ieee80211_scan_state *ss) if (st != NULL) { sta_flush_table(st); IEEE80211_SCAN_TABLE_LOCK_DESTROY(st); - mtx_destroy(&st->st_scanlock); + IEEE80211_SCAN_ITER_LOCK_DESTROY(st); IEEE80211_FREE(st, M_80211_SCAN); KASSERT(nrefs > 0, ("imbalanced attach/detach")); nrefs--; /* NB: we assume caller locking */ @@ -1403,7 +1403,7 @@ sta_iterate(struct ieee80211_scan_state *ss, struct sta_entry *se; u_int gen; - mtx_lock(&st->st_scanlock); + IEEE80211_SCAN_ITER_LOCK(st); gen = st->st_scaniter++; restart: IEEE80211_SCAN_TABLE_LOCK(st); @@ -1419,7 +1419,7 @@ sta_iterate(struct ieee80211_scan_state *ss, } IEEE80211_SCAN_TABLE_UNLOCK(st); - mtx_unlock(&st->st_scanlock); + IEEE80211_SCAN_ITER_UNLOCK(st); } static void