From owner-p4-projects@FreeBSD.ORG Thu May 22 21:49:10 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 2D3001065677; Thu, 22 May 2008 21:49:10 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E1F7A106566B for ; Thu, 22 May 2008 21:49:09 +0000 (UTC) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id CF8378FC16 for ; Thu, 22 May 2008 21:49:09 +0000 (UTC) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m4MLn9w2082797 for ; Thu, 22 May 2008 21:49:09 GMT (envelope-from sam@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m4MLn9CP082795 for perforce@freebsd.org; Thu, 22 May 2008 21:49:09 GMT (envelope-from sam@freebsd.org) Date: Thu, 22 May 2008 21:49:09 GMT Message-Id: <200805222149.m4MLn9CP082795@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to sam@freebsd.org using -f From: Sam Leffler To: Perforce Change Reviews Cc: Subject: PERFORCE change 142064 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 May 2008 21:49:10 -0000 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;