summaryrefslogtreecommitdiffstats
path: root/sys/net80211
diff options
context:
space:
mode:
authorsam <sam@FreeBSD.org>2008-05-28 23:10:53 +0000
committersam <sam@FreeBSD.org>2008-05-28 23:10:53 +0000
commit24e6f87d1f669ccf1ec84c9f5756542d09f3ef93 (patch)
tree18cfe47136d48ef7269922b95d0a11805ddacab0 /sys/net80211
parent20001eb2e24e4ed036e6fc8a56b3d644856de4eb (diff)
downloadFreeBSD-src-24e6f87d1f669ccf1ec84c9f5756542d09f3ef93.zip
FreeBSD-src-24e6f87d1f669ccf1ec84c9f5756542d09f3ef93.tar.gz
Revise lock name handling:
o construct a name for the com lock as done for other locks o pass the device name to IEEE80211_LOCK_INIT so the mtx name is constructed as foo_com_lock o introduce *_LOCK_OBJ macro's to hide the lock contents and minimize redundant code
Diffstat (limited to 'sys/net80211')
-rw-r--r--sys/net80211/ieee80211.c2
-rw-r--r--sys/net80211/ieee80211_freebsd.h44
-rw-r--r--sys/net80211/ieee80211_scan.c2
3 files changed, 28 insertions, 20 deletions
diff --git a/sys/net80211/ieee80211.c b/sys/net80211/ieee80211.c
index fbea173..ca4113a 100644
--- a/sys/net80211/ieee80211.c
+++ b/sys/net80211/ieee80211.c
@@ -220,7 +220,7 @@ ieee80211_ifattach(struct ieee80211com *ic)
KASSERT(ifp->if_type == IFT_IEEE80211, ("if_type %d", ifp->if_type));
- IEEE80211_LOCK_INIT(ic, "ieee80211com");
+ IEEE80211_LOCK_INIT(ic, ifp->if_xname);
TAILQ_INIT(&ic->ic_vaps);
/*
* Fill in 802.11 available channel set, mark all
diff --git a/sys/net80211/ieee80211_freebsd.h b/sys/net80211/ieee80211_freebsd.h
index bccc0cf..d5b0aa6 100644
--- a/sys/net80211/ieee80211_freebsd.h
+++ b/sys/net80211/ieee80211_freebsd.h
@@ -36,15 +36,21 @@
/*
* Common state locking definitions.
*/
-typedef struct mtx ieee80211_com_lock_t;
-#define IEEE80211_LOCK_INIT(_ic, _name) \
- mtx_init(&(_ic)->ic_comlock, _name, "802.11 com lock", \
- MTX_DEF | MTX_RECURSE)
-#define IEEE80211_LOCK_DESTROY(_ic) mtx_destroy(&(_ic)->ic_comlock)
-#define IEEE80211_LOCK(_ic) mtx_lock(&(_ic)->ic_comlock)
-#define IEEE80211_UNLOCK(_ic) mtx_unlock(&(_ic)->ic_comlock)
+typedef struct {
+ char name[16]; /* e.g. "ath0_com_lock" */
+ struct mtx mtx;
+} ieee80211_com_lock_t;
+#define IEEE80211_LOCK_INIT(_ic, _name) do { \
+ ieee80211_com_lock_t *cl = &(_ic)->ic_comlock; \
+ snprintf(cl->name, sizeof(cl->name), "%s_com_lock", _name); \
+ mtx_init(&cl->mtx, cl->name, NULL, MTX_DEF | MTX_RECURSE); \
+} while (0)
+#define IEEE80211_LOCK_OBJ(_ic) (&(_ic)->ic_comlock.mtx)
+#define IEEE80211_LOCK_DESTROY(_ic) mtx_destroy(IEEE80211_LOCK_OBJ(_ic))
+#define IEEE80211_LOCK(_ic) mtx_lock(IEEE80211_LOCK_OBJ(_ic))
+#define IEEE80211_UNLOCK(_ic) mtx_unlock(IEEE80211_LOCK_OBJ(_ic))
#define IEEE80211_LOCK_ASSERT(_ic) \
- mtx_assert(&(_ic)->ic_comlock, MA_OWNED)
+ mtx_assert(IEEE80211_LOCK_OBJ(_ic), MA_OWNED)
/*
* Node locking definitions.
@@ -56,18 +62,19 @@ typedef struct {
#define IEEE80211_NODE_LOCK_INIT(_nt, _name) do { \
ieee80211_node_lock_t *nl = &(_nt)->nt_nodelock; \
snprintf(nl->name, sizeof(nl->name), "%s_node_lock", _name); \
- mtx_init(&nl->mtx, NULL, nl->name, MTX_DEF | MTX_RECURSE); \
+ mtx_init(&nl->mtx, nl->name, NULL, MTX_DEF | MTX_RECURSE); \
} while (0)
+#define IEEE80211_NODE_LOCK_OBJ(_nt) (&(_nt)->nt_nodelock.mtx)
#define IEEE80211_NODE_LOCK_DESTROY(_nt) \
- mtx_destroy(&(_nt)->nt_nodelock.mtx)
+ mtx_destroy(IEEE80211_NODE_LOCK_OBJ(_nt))
#define IEEE80211_NODE_LOCK(_nt) \
- mtx_lock(&(_nt)->nt_nodelock.mtx)
+ mtx_lock(IEEE80211_NODE_LOCK_OBJ(_nt))
#define IEEE80211_NODE_IS_LOCKED(_nt) \
- mtx_owned(&(_nt)->nt_nodelock.mtx)
+ mtx_owned(IEEE80211_NODE_LOCK_OBJ(_nt))
#define IEEE80211_NODE_UNLOCK(_nt) \
- mtx_unlock(&(_nt)->nt_nodelock.mtx)
+ mtx_unlock(IEEE80211_NODE_LOCK_OBJ(_nt))
#define IEEE80211_NODE_LOCK_ASSERT(_nt) \
- mtx_assert(&(_nt)->nt_nodelock.mtx, MA_OWNED)
+ mtx_assert(IEEE80211_NODE_LOCK_OBJ(_nt), MA_OWNED)
/*
* Node table iteration locking definitions; this protects the
@@ -81,14 +88,15 @@ typedef struct {
#define IEEE80211_NODE_ITERATE_LOCK_INIT(_nt, _name) do { \
ieee80211_scan_lock_t *sl = &(_nt)->nt_scanlock; \
snprintf(sl->name, sizeof(sl->name), "%s_scan_lock", _name); \
- mtx_init(&sl->mtx, NULL, sl->name, MTX_DEF); \
+ mtx_init(&sl->mtx, sl->name, NULL, MTX_DEF); \
} while (0)
+#define IEEE80211_NODE_ITERATE_LOCK_OBJ(_nt) (&(_nt)->nt_scanlock.mtx)
#define IEEE80211_NODE_ITERATE_LOCK_DESTROY(_nt) \
- mtx_destroy(&(_nt)->nt_scanlock.mtx)
+ mtx_destroy(IEEE80211_NODE_ITERATE_LOCK_OBJ(_nt))
#define IEEE80211_NODE_ITERATE_LOCK(_nt) \
- mtx_lock(&(_nt)->nt_scanlock.mtx)
+ mtx_lock(IEEE80211_NODE_ITERATE_LOCK_OBJ(_nt))
#define IEEE80211_NODE_ITERATE_UNLOCK(_nt) \
- mtx_unlock(&(_nt)->nt_scanlock.mtx)
+ mtx_unlock(IEEE80211_NODE_ITERATE_LOCK_OBJ(_nt))
#define _AGEQ_ENQUEUE(_ifq, _m, _qlen, _age) do { \
(_m)->m_nextpkt = NULL; \
diff --git a/sys/net80211/ieee80211_scan.c b/sys/net80211/ieee80211_scan.c
index cec9673..e9c9246c 100644
--- a/sys/net80211/ieee80211_scan.c
+++ b/sys/net80211/ieee80211_scan.c
@@ -102,7 +102,7 @@ ieee80211_scan_attach(struct ieee80211com *ic)
ic->ic_scan = NULL;
return;
}
- callout_init_mtx(&ss->ss_scan_timer, &ic->ic_comlock, 0);
+ callout_init_mtx(&ss->ss_scan_timer, IEEE80211_LOCK_OBJ(ic), 0);
ic->ic_scan = &ss->base;
ic->ic_scan_curchan = scan_curchan;
OpenPOWER on IntegriCloud