Begin sync with 802.11 framework in FreeBSD: adopt macros for

locking.
This commit is contained in:
dyoung 2003-05-13 09:22:31 +00:00
parent e91ed415cd
commit 1786077eef
2 changed files with 26 additions and 16 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ieee80211.h,v 1.28 2003/05/13 05:51:46 dyoung Exp $ */
/* $NetBSD: if_ieee80211.h,v 1.29 2003/05/13 09:22:31 dyoung Exp $ */
/*-
* Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@ -539,8 +539,19 @@ struct ieee80211com {
u_int32_t ic_aid_bitmap[IEEE80211_MAX_AID / 32 + 1];
u_int16_t ic_max_aid;
};
#ifdef __NetBSD__
#define ic_if ic_ec.ec_if
#define ic_softc ic_ec.ec_if.if_softc
#define IEEE80211_LOCK_DECL() int s
#define IEEE80211_LOCK(_ic) do { s = splnet(); } while (0)
#define IEEE80211_UNLOCK(_ic) splx(s)
#endif
#ifdef __FreeBSD__
#define ic_if ic_ac.ac_if
#define IEEE80211_LOCK_DECL()
#define IEEE80211_LOCK(_ic) mtx_lock(&(_ic)->ic_mtx)
#define IEEE80211_UNLOCK(_ic) mtx_unlock(&(_ic)->ic_mtx)
#endif
#define ic_softc ic_if.if_softc
#define IEEE80211_SEND_MGMT(ic,ni,type,arg) do { \
if ((ic)->ic_send_mgmt[(type)>>IEEE80211_FC0_SUBTYPE_SHIFT] != NULL) \

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ieee80211subr.c,v 1.26 2003/05/13 05:43:43 dyoung Exp $ */
/* $NetBSD: if_ieee80211subr.c,v 1.27 2003/05/13 09:22:31 dyoung Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_ieee80211subr.c,v 1.26 2003/05/13 05:43:43 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_ieee80211subr.c,v 1.27 2003/05/13 09:22:31 dyoung Exp $");
#include "opt_inet.h"
#include "bpfilter.h"
@ -217,9 +217,9 @@ void
ieee80211_ifdetach(struct ifnet *ifp)
{
struct ieee80211com *ic = (void *)ifp;
int s;
IEEE80211_LOCK_DECL();
s = splnet();
IEEE80211_LOCK(ic);
IF_PURGE(&ic->ic_mgtq);
IF_PURGE(&ic->ic_pwrsaveq);
if (ic->ic_wep_ctx != NULL) {
@ -1306,7 +1306,7 @@ ieee80211_alloc_node(struct ieee80211com *ic, u_int8_t *macaddr, int copy)
{
struct ieee80211_node *ni;
int hash;
int s;
IEEE80211_LOCK_DECL();
ni = malloc(sizeof(struct ieee80211_node) + ic->ic_node_privlen,
M_DEVBUF, M_NOWAIT);
@ -1324,10 +1324,10 @@ ieee80211_alloc_node(struct ieee80211com *ic, u_int8_t *macaddr, int copy)
ni->ni_private = NULL;
hash = IEEE80211_NODE_HASH(macaddr);
s = splnet();
IEEE80211_LOCK(ic);
TAILQ_INSERT_TAIL(&ic->ic_node, ni, ni_list);
LIST_INSERT_HEAD(&ic->ic_hash[hash], ni, ni_hash);
splx(s);
IEEE80211_UNLOCK(ic);
ic->ic_inact_timer = IEEE80211_INACT_WAIT;
return ni;
}
@ -1337,24 +1337,23 @@ ieee80211_find_node(struct ieee80211com *ic, u_int8_t *macaddr)
{
struct ieee80211_node *ni;
int hash;
int s;
IEEE80211_LOCK_DECL();
hash = IEEE80211_NODE_HASH(macaddr);
s = splnet();
IEEE80211_LOCK(ic);
LIST_FOREACH(ni, &ic->ic_hash[hash], ni_hash) {
if (IEEE80211_ADDR_EQ(ni->ni_macaddr, macaddr))
break;
}
splx(s);
IEEE80211_UNLOCK(ic);
return ni;
}
void
ieee80211_free_node(struct ieee80211com *ic, struct ieee80211_node *ni)
{
int s;
s = splnet();
IEEE80211_LOCK_DECL();
IEEE80211_LOCK(ic);
if (ic->ic_node_free != NULL)
(*ic->ic_node_free)(ic, ni);
IEEE80211_AID_CLR(ni->ni_associd, ic->ic_aid_bitmap);
@ -1365,7 +1364,7 @@ ieee80211_free_node(struct ieee80211com *ic, struct ieee80211_node *ni)
if (ic->ic_set_tim)
ic->ic_set_tim(ic, ni->ni_associd, 0);
}
splx(s);
IEEE80211_UNLOCK(ic);
free(ni, M_DEVBUF);
if (TAILQ_EMPTY(&ic->ic_node))
ic->ic_inact_timer = 0;