From owner-svn-src-projects@FreeBSD.ORG Sun Jun 21 16:42:54 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B9E44106564A; Sun, 21 Jun 2009 16:42:54 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A7E328FC13; Sun, 21 Jun 2009 16:42:54 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n5LGgsSb012509; Sun, 21 Jun 2009 16:42:54 GMT (envelope-from rpaulo@svn.freebsd.org) Received: (from rpaulo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n5LGgsc2012507; Sun, 21 Jun 2009 16:42:54 GMT (envelope-from rpaulo@svn.freebsd.org) Message-Id: <200906211642.n5LGgsc2012507@svn.freebsd.org> From: Rui Paulo Date: Sun, 21 Jun 2009 16:42:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r194594 - projects/mesh11s/sys/net80211 X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Jun 2009 16:42:55 -0000 Author: rpaulo Date: Sun Jun 21 16:42:52 2009 New Revision: 194594 URL: http://svn.freebsd.org/changeset/base/194594 Log: Add HWMP_LOCK/UNLOCK macros and use them. Sponsored by: The FreeBSD Foundation Modified: projects/mesh11s/sys/net80211/ieee80211_hwmp.c Modified: projects/mesh11s/sys/net80211/ieee80211_hwmp.c ============================================================================== --- projects/mesh11s/sys/net80211/ieee80211_hwmp.c Sun Jun 21 16:26:22 2009 (r194593) +++ projects/mesh11s/sys/net80211/ieee80211_hwmp.c Sun Jun 21 16:42:52 2009 (r194594) @@ -114,6 +114,9 @@ static const struct timeval ieee80211_hw #define timeval2msecs(tv) (tv.tv_sec * 1000 + tv.tv_usec / 1000) +#define HWMP_LOCK(hs) mtx_lock(&(hs)->hs_lock) +#define HWMP_UNLOCK(hs) mtx_unlock(&(hs)->hs_lock) + /* * Target Address set in a Proactive PREQ. * XXX @@ -527,12 +530,12 @@ hwmp_recv_preq(struct ieee80211vap *vap, return; } - mtx_lock(&hs->hs_lock); + HWMP_LOCK(hs); TAILQ_FOREACH(fi, &hs->hs_head, fi_next) { if (IEEE80211_ADDR_EQ(preq->preq_origaddr, fi->fi_dest)) break; } - mtx_unlock(&hs->hs_lock); + HWMP_UNLOCK(hs); /* * Record the PREQ ID and the originator MAC address. @@ -545,9 +548,9 @@ hwmp_recv_preq(struct ieee80211vap *vap, fi->fi_seq = preq->preq_origseq; fi->fi_metric = preq->preq_metric; fi->fi_lifetime = preq->preq_lifetime; - mtx_lock(&hs->hs_lock); + HWMP_LOCK(hs); TAILQ_INSERT_TAIL(&hs->hs_head, fi, fi_next); - mtx_unlock(&hs->hs_lock); + HWMP_UNLOCK(hs); } fi->fi_preqid = preq->preq_id; @@ -732,12 +735,12 @@ hwmp_recv_prep(struct ieee80211vap *vap, /* * Find out if this path reply is useful to us. */ - mtx_lock(&hs->hs_lock); + HWMP_LOCK(hs); TAILQ_FOREACH(fi, &hs->hs_head, fi_next) { if (IEEE80211_ADDR_EQ(prep->prep_targetaddr, fi->fi_dest)) break; } - mtx_unlock(&hs->hs_lock); + HWMP_UNLOCK(hs); /* XXX */ if (fi == NULL) @@ -831,12 +834,12 @@ hwmp_recv_perr(struct ieee80211vap *vap, !(vap->iv_meshflags & IEEE80211_MFLAGS_FWRD)) return; - mtx_lock(&hs->hs_lock); + HWMP_LOCK(hs); TAILQ_FOREACH(fi, &hs->hs_head, fi_next) { if (IEEE80211_ADDR_EQ(PERR_DADDR(0), fi->fi_dest)) break; } - mtx_unlock(&hs->hs_lock); + HWMP_UNLOCK(hs); if (fi == NULL) return; @@ -886,12 +889,12 @@ hwmp_recv_rann(struct ieee80211vap *vap, * Acceptance criteria: check the HWMP sequence number * and the path metric is better than what we have. */ - mtx_lock(&hs->hs_lock); + HWMP_LOCK(hs); TAILQ_FOREACH(fi, &hs->hs_head, fi_next) { if (IEEE80211_ADDR_EQ(rann->rann_addr, fi->fi_dest)) break; } - mtx_unlock(&hs->hs_lock); + HWMP_UNLOCK(hs); if (fi == NULL) { struct ieee80211_meshpreq_ie preq; @@ -969,7 +972,7 @@ ieee80211_hwmp_discover(struct ieee80211 if (IEEE80211_IS_MULTICAST(dest)) return ieee80211_find_txnode(vap, dest); - mtx_lock(&hs->hs_lock); + HWMP_LOCK(hs); TAILQ_FOREACH(fi, &hs->hs_head, fi_next) { if (IEEE80211_ADDR_EQ(fi->fi_dest, dest)) { if (IEEE80211_ADDR_EQ(fi->fi_nexthop, invalidaddr)) { @@ -980,7 +983,7 @@ ieee80211_hwmp_discover(struct ieee80211 break; } } - mtx_unlock(&hs->hs_lock); + HWMP_UNLOCK(hs); if (fi == NULL) { fi = malloc(sizeof(struct ieee80211_hwmp_fi), M_80211_HWMP, @@ -990,9 +993,9 @@ ieee80211_hwmp_discover(struct ieee80211 fi->fi_preqid = ++hs->hs_preqid; fi->fi_metric = IEEE80211_MESHLMETRIC_INITIALVAL; fi->fi_lifetime = timeval2msecs(ieee80211_hwmp_pathtimeout); - mtx_lock(&hs->hs_lock); + HWMP_LOCK(hs); TAILQ_INSERT_TAIL(&hs->hs_head, fi, fi_next); - mtx_unlock(&hs->hs_lock); + HWMP_UNLOCK(hs); sendpreq = 1; unknowndst = 1; } @@ -1042,7 +1045,7 @@ hwmp_ioctl_get80211(struct ieee80211vap { int error; size_t len, off; - struct ieee80211_hwmp_state *hs; + struct ieee80211_hwmp_state *hs = vap->iv_hwmp; struct ieee80211_hwmp_fi *fi; uint8_t *p; @@ -1051,13 +1054,12 @@ hwmp_ioctl_get80211(struct ieee80211vap error = 0; switch (ireq->i_type) { case IEEE80211_IOC_HWMP_TABLE: - hs = vap->iv_hwmp; len = 0; - mtx_lock(&hs->hs_lock); + HWMP_LOCK(hs); TAILQ_FOREACH(fi, &hs->hs_head, fi_next) { len += sizeof(*fi); } - mtx_unlock(&hs->hs_lock); + HWMP_UNLOCK(hs); if (len > ireq->i_len || ireq->i_len < sizeof(*fi)) return ENOMEM; ireq->i_len = len; @@ -1065,14 +1067,14 @@ hwmp_ioctl_get80211(struct ieee80211vap if (p == NULL) return ENOMEM; off = 0; - mtx_lock(&hs->hs_lock); + HWMP_LOCK(hs); TAILQ_FOREACH(fi, &hs->hs_head, fi_next) { if (off >= len) break; memcpy(p + off, fi, sizeof(*fi)); off += sizeof(*fi); } - mtx_unlock(&hs->hs_lock); + HWMP_UNLOCK(hs); error = copyout(p, (uint8_t *) ireq->i_data, ireq->i_len); free(p, M_TEMP); break;