}
sc->sc_flags |= RT2560_F_INPUT_RUNNING;
- RAL_UNLOCK(sc);
+ RAL_UNLOCK();
wh = mtod(m, struct ieee80211_frame *);
ni = ieee80211_find_rxnode(ic,
(struct ieee80211_frame_min *)wh);
} else
(void) ieee80211_input_all(ic, m, rssi, nf);
- RAL_LOCK(sc);
+ RAL_LOCK();
sc->sc_flags &= ~RT2560_F_INPUT_RUNNING;
skip: desc->flags = htole32(RT2560_RX_BUSY);
struct ifnet *ifp = sc->sc_ifp;
uint32_t r;
- RAL_LOCK(sc);
+ RAL_LOCK();
/* disable interrupts */
RAL_WRITE(sc, RT2560_CSR8, 0xffffffff);
/* don't re-enable interrupts if we're shutting down */
if (!(ifp->if_flags & IFF_RUNNING)) {
- RAL_UNLOCK(sc);
+ RAL_UNLOCK();
return;
}
/* re-enable interrupts */
RAL_WRITE(sc, RT2560_CSR8, RT2560_INTR_MASK);
- RAL_UNLOCK(sc);
+ RAL_UNLOCK();
}
#define RAL_SIFS 10 /* us */
struct mbuf *m;
struct ieee80211_node *ni;
- RAL_LOCK_ASSERT(sc);
+ RAL_LOCK_ASSERT();
for (;;) {
IF_DEQUEUE(&ifp->if_snd, m);
static void
rt2560_start(struct ifnet *ifp)
{
- struct rt2560_softc *sc = ifp->if_softc;
+ struct rt2560_softc *sc;
+
+ sc = ifp->if_softc;
- RAL_LOCK(sc);
+ RAL_LOCK();
rt2560_start_locked(ifp);
- RAL_UNLOCK(sc);
+ RAL_UNLOCK();
}
static void
struct rt2560_softc *sc = arg;
struct ifnet *ifp = sc->sc_ifp;
- RAL_LOCK(sc);
+ RAL_LOCK();
KASSERT(ifp->if_flags & IFF_RUNNING, ("not running"));
return;
}
callout_reset(&sc->watchdog_ch, hz, rt2560_watchdog, sc);
- RAL_UNLOCK(sc);
+ RAL_UNLOCK();
}
static int
switch (cmd) {
case SIOCSIFFLAGS:
- RAL_LOCK(sc);
+ RAL_LOCK();
if (ifp->if_flags & IFF_UP) {
if ((ifp->if_flags & IFF_RUNNING) == 0) {
rt2560_init_locked(sc);
if (ifp->if_flags & IFF_RUNNING)
rt2560_stop_locked(sc);
}
- RAL_UNLOCK(sc);
+ RAL_UNLOCK();
if (startall)
ieee80211_start_all(ic);
break;
struct ifnet *ifp = ic->ic_ifp;
struct rt2560_softc *sc = ifp->if_softc;
- RAL_LOCK(sc);
+ RAL_LOCK();
rt2560_set_chan(sc, ic->ic_curchan);
- RAL_UNLOCK(sc);
+ RAL_UNLOCK();
}
uint32_t tmp;
int i;
- RAL_LOCK_ASSERT(sc);
+ RAL_LOCK_ASSERT();
rt2560_stop_locked(sc);
if (rt2560_bbp_init(sc) != 0) {
rt2560_stop(sc);
- RAL_UNLOCK(sc);
+ RAL_UNLOCK();
return;
}
struct ifnet *ifp = sc->sc_ifp;
struct ieee80211com *ic = ifp->if_l2com;
- RAL_LOCK(sc);
+ RAL_LOCK();
rt2560_init_locked(sc);
- RAL_UNLOCK(sc);
+ RAL_UNLOCK();
if (ifp->if_flags & IFF_RUNNING)
ieee80211_start_all(ic); /* start all vap's */
struct ifnet *ifp = sc->sc_ifp;
volatile int *flags = &sc->sc_flags;
- RAL_LOCK_ASSERT(sc);
+ RAL_LOCK_ASSERT();
while (*flags & RT2560_F_INPUT_RUNNING)
lksleep(sc, &sc->sc_lock, 0, "ralrunning", hz/10);
{
struct rt2560_softc *sc = arg;
- RAL_LOCK(sc);
+ RAL_LOCK();
rt2560_stop_locked(sc);
- RAL_UNLOCK(sc);
+ RAL_UNLOCK();
}
static int
struct ifnet *ifp = ic->ic_ifp;
struct rt2560_softc *sc = ifp->if_softc;
- RAL_LOCK(sc);
+ RAL_LOCK();
/* prevent management frames from being sent if we're not ready */
if (!(ifp->if_flags & IFF_RUNNING)) {
- RAL_UNLOCK(sc);
+ RAL_UNLOCK();
m_freem(m);
ieee80211_free_node(ni);
return ENETDOWN;
if (sc->prioq.queued >= RT2560_PRIO_RING_COUNT) {
ifp->if_flags |= IFF_OACTIVE;
sc->sc_flags |= RT2560_F_PRIO_OACTIVE;
- RAL_UNLOCK(sc);
+ RAL_UNLOCK();
m_freem(m);
ieee80211_free_node(ni);
return ENOBUFS; /* XXX */
}
sc->sc_tx_timer = 5;
- RAL_UNLOCK(sc);
+ RAL_UNLOCK();
return 0;
bad:
ifp->if_oerrors++;
ieee80211_free_node(ni);
- RAL_UNLOCK(sc);
+ RAL_UNLOCK();
return EIO; /* XXX */
}
void rt2560_resume(void *);
void rt2560_intr(void *);
-#define RAL_LOCK(sc) lockmgr(&(sc)->sc_lock, LK_EXCLUSIVE)
-#define RAL_LOCK_ASSERT(sc) \
- KKASSERT(lockstatus(&(sc)->sc_lock, curthread) == LK_EXCLUSIVE)
-#define RAL_UNLOCK(sc) lockmgr(&(sc)->sc_lock, LK_RELEASE)
+#define RAL_LOCK() lwkt_gettoken(&wlan_token)
+#define RAL_LOCK_ASSERT() ASSERT_LWKT_TOKEN_HELD(&wlan_token)
+#define RAL_UNLOCK() lwkt_reltoken(&wlan_token)
struct ifnet *ifp = sc->sc_ifp;
struct ieee80211com *ic = ifp->if_l2com;
- RAL_LOCK(sc);
+ RAL_LOCK();
rt2661_stop_locked(sc);
- RAL_UNLOCK(sc);
+ RAL_UNLOCK();
ieee80211_ifdetach(ic);
tap->wr_antnoise = nf;
}
sc->sc_flags |= RAL_INPUT_RUNNING;
- RAL_UNLOCK(sc);
+ RAL_UNLOCK();
wh = mtod(m, struct ieee80211_frame *);
/* send the frame to the 802.11 layer */
} else
(void) ieee80211_input_all(ic, m, rssi, nf);
- RAL_LOCK(sc);
+ RAL_LOCK();
sc->sc_flags &= ~RAL_INPUT_RUNNING;
skip: desc->flags |= htole32(RT2661_RX_BUSY);
struct ifnet *ifp = sc->sc_ifp;
uint32_t r1, r2;
- RAL_LOCK(sc);
+ RAL_LOCK();
/* disable MAC and MCU interrupts */
RAL_WRITE(sc, RT2661_INT_MASK_CSR, 0xffffff7f);
/* don't re-enable interrupts if we're shutting down */
if (!(ifp->if_flags & IFF_RUNNING)) {
- RAL_UNLOCK(sc);
+ RAL_UNLOCK();
return;
}
RAL_WRITE(sc, RT2661_INT_MASK_CSR, 0x0000ff10);
RAL_WRITE(sc, RT2661_MCU_INT_MASK_CSR, 0);
- RAL_UNLOCK(sc);
+ RAL_UNLOCK();
}
static uint8_t
struct ieee80211_node *ni;
int ac;
- RAL_LOCK_ASSERT(sc);
+ RAL_LOCK_ASSERT();
/* prevent management frames from being sent if we're not ready */
if (!(ifp->if_flags & IFF_RUNNING) || sc->sc_invalid)
static void
rt2661_start(struct ifnet *ifp)
{
- struct rt2661_softc *sc = ifp->if_softc;
+ struct rt2661_softc *sc;
+
+ sc = ifp->if_softc;
- RAL_LOCK(sc);
+ RAL_LOCK();
rt2661_start_locked(ifp);
- RAL_UNLOCK(sc);
+ RAL_UNLOCK();
}
static int
struct ifnet *ifp = ic->ic_ifp;
struct rt2661_softc *sc = ifp->if_softc;
- RAL_LOCK(sc);
+ RAL_LOCK();
/* prevent management frames from being sent if we're not ready */
if (!(ifp->if_flags & IFF_RUNNING)) {
- RAL_UNLOCK(sc);
+ RAL_UNLOCK();
m_freem(m);
ieee80211_free_node(ni);
return ENETDOWN;
}
if (sc->mgtq.queued >= RT2661_MGT_RING_COUNT) {
ifp->if_flags |= IFF_OACTIVE;
- RAL_UNLOCK(sc);
+ RAL_UNLOCK();
m_freem(m);
ieee80211_free_node(ni);
return ENOBUFS; /* XXX */
goto bad;
sc->sc_tx_timer = 5;
- RAL_UNLOCK(sc);
+ RAL_UNLOCK();
return 0;
bad:
ifp->if_oerrors++;
ieee80211_free_node(ni);
- RAL_UNLOCK(sc);
+ RAL_UNLOCK();
return EIO; /* XXX */
}
struct rt2661_softc *sc = (struct rt2661_softc *)arg;
struct ifnet *ifp = sc->sc_ifp;
- RAL_LOCK(sc);
+ RAL_LOCK();
KASSERT(ifp->if_flags & IFF_RUNNING, ("not running"));
}
callout_reset(&sc->watchdog_ch, hz, rt2661_watchdog, sc);
- RAL_UNLOCK(sc);
+ RAL_UNLOCK();
}
static int
switch (cmd) {
case SIOCSIFFLAGS:
- RAL_LOCK(sc);
+ RAL_LOCK();
if (ifp->if_flags & IFF_UP) {
if ((ifp->if_flags & IFF_RUNNING) == 0) {
rt2661_init_locked(sc);
if (ifp->if_flags & IFF_RUNNING)
rt2661_stop_locked(sc);
}
- RAL_UNLOCK(sc);
+ RAL_UNLOCK();
if (startall)
ieee80211_start_all(ic);
break;
uint32_t tmp, sta[3];
int i, error, ntries;
- RAL_LOCK_ASSERT(sc);
+ RAL_LOCK_ASSERT();
if ((sc->sc_flags & RAL_FW_LOADED) == 0) {
error = rt2661_load_microcode(sc);
struct ifnet *ifp = sc->sc_ifp;
struct ieee80211com *ic = ifp->if_l2com;
- RAL_LOCK(sc);
+ RAL_LOCK();
rt2661_init_locked(sc);
- RAL_UNLOCK(sc);
+ RAL_UNLOCK();
if (ifp->if_flags & IFF_RUNNING)
ieee80211_start_all(ic); /* start all vap's */
{
struct rt2661_softc *sc = priv;
- RAL_LOCK(sc);
+ RAL_LOCK();
rt2661_stop_locked(sc);
- RAL_UNLOCK(sc);
+ RAL_UNLOCK();
}
static int
const char *imagename;
int ntries, error;
- RAL_LOCK_ASSERT(sc);
+ RAL_LOCK_ASSERT();
switch (sc->sc_id) {
case 0x0301: imagename = "rt2561sfw"; break;
__func__, sc->sc_id);
return EINVAL;
}
- RAL_UNLOCK(sc);
+ RAL_UNLOCK();
fp = firmware_get(imagename);
- RAL_LOCK(sc);
+ RAL_LOCK();
if (fp == NULL) {
if_printf(ifp, "%s: unable to retrieve firmware image %s\n",
__func__, imagename);
struct ifnet *ifp = ic->ic_ifp;
struct rt2661_softc *sc = ifp->if_softc;
- RAL_LOCK(sc);
+ RAL_LOCK();
rt2661_set_chan(sc, ic->ic_curchan);
- RAL_UNLOCK(sc);
+ RAL_UNLOCK();
}
void rt2661_resume(void *);
void rt2661_intr(void *);
-#define RAL_LOCK(sc) lockmgr(&(sc)->sc_lock, LK_EXCLUSIVE)
-#define RAL_LOCK_ASSERT(sc) \
- KKASSERT(lockstatus(&(sc)->sc_lock, curthread) == LK_EXCLUSIVE)
-#define RAL_UNLOCK(sc) lockmgr(&(sc)->sc_lock, LK_RELEASE)
+#define RAL_LOCK() lwkt_gettoken(&wlan_token)
+#define RAL_LOCK_ASSERT() ASSERT_LWKT_TOKEN_HELD(&wlan_token)
+#define RAL_UNLOCK() lwkt_reltoken(&wlan_token)