Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 14 Oct 2003 06:53:49 -0700 (PDT)
From:      Sam Leffler <sam@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 39687 for review
Message-ID:  <200310141353.h9EDrnuR054898@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=39687

Change 39687 by sam@sam_ebb on 2003/10/14 06:53:17

	parameterize locking to improve portability and possible
	change to different locking strategies

Affected files ...

.. //depot/projects/netperf/sys/net80211/ieee80211_node.c#11 edit
.. //depot/projects/netperf/sys/net80211/ieee80211_node.h#8 edit
.. //depot/projects/netperf/sys/net80211/ieee80211_proto.c#5 edit

Differences ...

==== //depot/projects/netperf/sys/net80211/ieee80211_node.c#11 (text+ko) ====

@@ -86,7 +86,7 @@
 	struct ieee80211com *ic = (void *)ifp;
 
 	/* XXX need unit */
-	mtx_init(&ic->ic_nodelock, ifp->if_name, "802.11 node table", MTX_DEF);
+	IEEE80211_NODE_LOCK_INIT(ic, ifp->if_name);
 	TAILQ_INIT(&ic->ic_node);
 	ic->ic_node_alloc = ieee80211_node_alloc;
 	ic->ic_node_free = ieee80211_node_free;
@@ -113,7 +113,7 @@
 	if (ic->ic_bss != NULL)
 		(*ic->ic_node_free)(ic, ic->ic_bss);
 	ieee80211_free_allnodes(ic);
-	mtx_destroy(&ic->ic_nodelock);
+	IEEE80211_NODE_LOCK_DESTROY(ic);
 }
 
 /*
@@ -431,7 +431,7 @@
 	IEEE80211_ADDR_COPY(ni->ni_macaddr, macaddr);
 	hash = IEEE80211_NODE_HASH(macaddr);
 	ni->ni_refcnt = 1;		/* mark referenced */
-	mtx_lock(&ic->ic_nodelock);
+	IEEE80211_NODE_LOCK(ic);
 	TAILQ_INSERT_TAIL(&ic->ic_node, ni, ni_list);
 	LIST_INSERT_HEAD(&ic->ic_hash[hash], ni, ni_hash);
 	/* 
@@ -445,7 +445,7 @@
 	 */
 	if (ic->ic_opmode != IEEE80211_M_STA)
 		ic->ic_inact_timer = IEEE80211_INACT_WAIT;
-	mtx_unlock(&ic->ic_nodelock);
+	IEEE80211_NODE_UNLOCK(ic);
 }
 
 struct ieee80211_node *
@@ -475,14 +475,14 @@
 	int hash;
 
 	hash = IEEE80211_NODE_HASH(macaddr);
-	mtx_lock(&ic->ic_nodelock);
+	IEEE80211_NODE_LOCK(ic);
 	LIST_FOREACH(ni, &ic->ic_hash[hash], ni_hash) {
 		if (IEEE80211_ADDR_EQ(ni->ni_macaddr, macaddr)) {
 			atomic_add_int(&ni->ni_refcnt, 1); /* mark referenced */
 			break;
 		}
 	}
-	mtx_unlock(&ic->ic_nodelock);
+	IEEE80211_NODE_UNLOCK(ic);
 	return ni;
 }
 
@@ -497,14 +497,14 @@
 	int hash;
 
 	hash = IEEE80211_NODE_HASH(macaddr);
-	mtx_lock(&ic->ic_nodelock);
+	IEEE80211_NODE_LOCK(ic);
 	LIST_FOREACH(ni, &ic->ic_hash[hash], ni_hash) {
 		if (IEEE80211_ADDR_EQ(ni->ni_macaddr, macaddr) && ni->ni_chan == chan) {
 			atomic_add_int(&ni->ni_refcnt, 1);/* mark referenced */
 			break;
 		}
 	}
-	mtx_unlock(&ic->ic_nodelock);
+	IEEE80211_NODE_UNLOCK(ic);
 	return ni;
 }
 
@@ -528,9 +528,9 @@
 	/* XXX need equivalent of atomic_dec_and_test */
 	atomic_subtract_int(&ni->ni_refcnt, 1);
 	if (atomic_cmpset_int(&ni->ni_refcnt, 0, 1)) {
-		mtx_lock(&ic->ic_nodelock);
+		IEEE80211_NODE_LOCK(ic);
 		_ieee80211_free_node(ic, ni);
-		mtx_unlock(&ic->ic_nodelock);
+		IEEE80211_NODE_UNLOCK(ic);
 	}
 }
 
@@ -539,10 +539,10 @@
 {
 	struct ieee80211_node *ni;
 
-	mtx_lock(&ic->ic_nodelock);
+	IEEE80211_NODE_LOCK(ic);
 	while ((ni = TAILQ_FIRST(&ic->ic_node)) != NULL)
 		_ieee80211_free_node(ic, ni);  
-	mtx_unlock(&ic->ic_nodelock);
+	IEEE80211_NODE_UNLOCK(ic);
 }
 
 /*
@@ -561,7 +561,7 @@
 	u_int gen = ic->ic_scangen++;		/* NB: ok 'cuz single-threaded*/
 
 restart:
-	mtx_lock(&ic->ic_nodelock);
+	IEEE80211_NODE_LOCK(ic);
 	TAILQ_FOREACH(ni, &ic->ic_node, ni_list) {
 		if (ni->ni_scangen == gen)	/* previously handled */
 			continue;
@@ -579,7 +579,7 @@
 			 * a lock, as this will result in a LOR between the     
 			 * node lock and the driver lock.
 			 */
-			mtx_unlock(&ic->ic_nodelock);
+			IEEE80211_NODE_UNLOCK(ic);
 			IEEE80211_SEND_MGMT(ic, ni,
 			    IEEE80211_FC0_SUBTYPE_DEAUTH,
 			    IEEE80211_REASON_AUTH_EXPIRE);
@@ -590,7 +590,7 @@
 	}
 	if (!TAILQ_EMPTY(&ic->ic_node))
 		ic->ic_inact_timer = IEEE80211_INACT_WAIT;
-	mtx_unlock(&ic->ic_nodelock);
+	IEEE80211_NODE_UNLOCK(ic);
 }
 
 void
@@ -598,8 +598,8 @@
 {
 	struct ieee80211_node *ni;
 
-	mtx_lock(&ic->ic_nodelock);
+	IEEE80211_NODE_LOCK(ic);
 	TAILQ_FOREACH(ni, &ic->ic_node, ni_list)
 		(*f)(arg, ni);
-	mtx_unlock(&ic->ic_nodelock);
+	IEEE80211_NODE_UNLOCK(ic);
 }

==== //depot/projects/netperf/sys/net80211/ieee80211_node.h#8 (text+ko) ====

@@ -118,6 +118,14 @@
 	*ni = NULL;			/* guard against use */
 }
 
+#define	IEEE80211_NODE_LOCK_INIT(_ic, _name) \
+	mtx_init(&(_ic)->ic_nodelock, _name, "802.11 node table", MTX_DEF)
+#define	IEEE80211_NODE_LOCK_DESTROY(_ic)	mtx_destroy(&(_ic)->ic_nodelock)
+#define	IEEE80211_NODE_LOCK(_ic)		mtx_lock(&(_ic)->ic_nodelock)
+#define	IEEE80211_NODE_UNLOCK(_ic)		mtx_unlock(&(_ic)->ic_nodelock)
+#define	IEEE80211_NODE_LOCK_ASSERT(_ic) \
+	mtx_assert(&(_ic)->ic_nodelock, MA_OWNED)
+
 struct ieee80211com;
 
 extern	void ieee80211_node_attach(struct ifnet *);

==== //depot/projects/netperf/sys/net80211/ieee80211_proto.c#5 (text+ko) ====

@@ -321,7 +321,7 @@
 				    IEEE80211_REASON_ASSOC_LEAVE);
 				break;
 			case IEEE80211_M_HOSTAP:
-				mtx_lock(&ic->ic_nodelock);
+				IEEE80211_NODE_LOCK(ic);
 				TAILQ_FOREACH(ni, &ic->ic_node, ni_list) {
 					if (ni->ni_associd == 0)
 						continue;
@@ -329,7 +329,7 @@
 					    IEEE80211_FC0_SUBTYPE_DISASSOC,
 					    IEEE80211_REASON_ASSOC_LEAVE);
 				}
-				mtx_unlock(&ic->ic_nodelock);
+				IEEE80211_NODE_UNLOCK(ic);
 				break;
 			default:
 				break;
@@ -343,13 +343,13 @@
 				    IEEE80211_REASON_AUTH_LEAVE);
 				break;
 			case IEEE80211_M_HOSTAP:
-				mtx_lock(&ic->ic_nodelock);
+				IEEE80211_NODE_LOCK(ic);
 				TAILQ_FOREACH(ni, &ic->ic_node, ni_list) {
 					IEEE80211_SEND_MGMT(ic, ni,
 					    IEEE80211_FC0_SUBTYPE_DEAUTH,
 					    IEEE80211_REASON_AUTH_LEAVE);
 				}
-				mtx_unlock(&ic->ic_nodelock);
+				IEEE80211_NODE_UNLOCK(ic);
 				break;
 			default:
 				break;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200310141353.h9EDrnuR054898>