Date: Thu, 22 May 2008 21:49:09 GMT From: Sam Leffler <sam@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 142064 for review Message-ID: <200805222149.m4MLn9CP082795@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=142064 Change 142064 by sam@sam_ebb on 2008/05/22 21:48:09 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 Affected files ... .. //depot/projects/vap/sys/net80211/ieee80211.c#47 edit .. //depot/projects/vap/sys/net80211/ieee80211_freebsd.h#27 edit .. //depot/projects/vap/sys/net80211/ieee80211_scan.c#22 edit Differences ... ==== //depot/projects/vap/sys/net80211/ieee80211.c#47 (text+ko) ==== @@ -220,7 +220,7 @@ 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 ==== //depot/projects/vap/sys/net80211/ieee80211_freebsd.h#27 (text+ko) ==== @@ -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 @@ #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 @@ #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; \ ==== //depot/projects/vap/sys/net80211/ieee80211_scan.c#22 (text+ko) ==== @@ -102,7 +102,7 @@ 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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200805222149.m4MLn9CP082795>