{
const struct ral_pci_ident *ident;
+ wlan_serialize_enter();
+
for (ident = ral_pci_ids; ident->name != NULL; ident++) {
if (pci_get_vendor(dev) == ident->vendor &&
pci_get_device(dev) == ident->device) {
device_set_desc(dev, ident->name);
+ wlan_serialize_exit();
return 0;
}
}
+ wlan_serialize_exit();
return ENXIO;
}
struct ifnet *ifp;
int error;
+ wlan_serialize_enter();
if (pci_get_powerstate(dev) != PCI_POWERSTATE_D0) {
device_printf(dev, "chip is in D%d power mode "
"-- setting to D0\n", pci_get_powerstate(dev));
RF_ACTIVE);
if (psc->mem == NULL) {
device_printf(dev, "could not allocate memory resource\n");
+ wlan_serialize_exit();
return ENXIO;
}
RF_ACTIVE | RF_SHAREABLE);
if (psc->irq == NULL) {
device_printf(dev, "could not allocate interrupt resource\n");
+ wlan_serialize_exit();
return ENXIO;
}
error = (*psc->sc_opns->attach)(dev, pci_get_device(dev));
- if (error != 0)
+ if (error != 0) {
+ wlan_serialize_exit();
return error;
+ }
ifp = sc->sc_ifp;
/*
* Hook our interrupt after all initialization is complete.
*/
error = bus_setup_intr(dev, psc->irq, INTR_MPSAFE,
- psc->sc_opns->intr, psc, &psc->sc_ih, ifp->if_serializer);
+ psc->sc_opns->intr, psc, &psc->sc_ih, &wlan_global_serializer);
if (error != 0) {
device_printf(dev, "could not set up interrupt\n");
+ wlan_serialize_exit();
return error;
}
sc->sc_invalid = 0;
+ wlan_serialize_exit();
return 0;
}
struct ral_pci_softc *psc = device_get_softc(dev);
struct rt2560_softc *sc = &psc->u.sc_rt2560;
+ wlan_serialize_enter();
/* check if device was removed */
sc->sc_invalid = !bus_child_present(dev);
bus_release_resource(dev, SYS_RES_MEMORY, psc->mem_rid, psc->mem);
+ wlan_serialize_exit();
return 0;
}
{
struct ral_pci_softc *psc = device_get_softc(dev);
+ wlan_serialize_enter();
(*psc->sc_opns->shutdown)(psc);
+ wlan_serialize_exit();
return 0;
}
{
struct ral_pci_softc *psc = device_get_softc(dev);
+ wlan_serialize_enter();
(*psc->sc_opns->suspend)(psc);
+ wlan_serialize_exit();
return 0;
}
{
struct ral_pci_softc *psc = device_get_softc(dev);
+ wlan_serialize_enter();
(*psc->sc_opns->resume)(psc);
+ wlan_serialize_exit();
return 0;
}
struct ieee80211_node *);
static void rt2560_start_locked(struct ifnet *);
static void rt2560_start(struct ifnet *);
-static void rt2560_watchdog(void *);
+static void rt2560_watchdog_callout(void *);
static int rt2560_ioctl(struct ifnet *, u_long, caddr_t,
struct ucred *);
static void rt2560_bbp_write(struct rt2560_softc *, uint8_t,
sc->sc_dev = dev;
- lockinit(&sc->sc_lock, __DECONST(char *, device_get_nameunit(dev)),
- 0, LK_CANRECURSE);
-
callout_init(&sc->watchdog_ch);
/* retrieve RT2560 rev. no */
fail4: rt2560_free_tx_ring(sc, &sc->prioq);
fail3: rt2560_free_tx_ring(sc, &sc->atimq);
fail2: rt2560_free_tx_ring(sc, &sc->txq);
-fail1: lockuninit(&sc->sc_lock);
+fail1:
return ENXIO;
}
if_free(ifp);
- lockuninit(&sc->sc_lock);
-
return 0;
}
}
sc->sc_flags |= RT2560_F_INPUT_RUNNING;
- 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->sc_flags &= ~RT2560_F_INPUT_RUNNING;
skip: desc->flags = htole32(RT2560_RX_BUSY);
struct ifnet *ifp = sc->sc_ifp;
uint32_t r;
- 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();
return;
}
/* re-enable interrupts */
RAL_WRITE(sc, RT2560_CSR8, RT2560_INTR_MASK);
-
- RAL_UNLOCK();
}
#define RAL_SIFS 10 /* us */
struct mbuf *m;
struct ieee80211_node *ni;
- RAL_LOCK_ASSERT();
-
for (;;) {
IF_DEQUEUE(&ifp->if_snd, m);
if (m == NULL)
static void
rt2560_start(struct ifnet *ifp)
{
- RAL_LOCK();
rt2560_start_locked(ifp);
- RAL_UNLOCK();
}
static void
-rt2560_watchdog(void *arg)
+rt2560_watchdog_callout(void *arg)
{
struct rt2560_softc *sc = arg;
struct ifnet *ifp = sc->sc_ifp;
- RAL_LOCK();
-
KASSERT(ifp->if_flags & IFF_RUNNING, ("not running"));
if (sc->sc_invalid) /* card ejected */
/* NB: callout is reset in rt2560_init() */
return;
}
- callout_reset(&sc->watchdog_ch, hz, rt2560_watchdog, sc);
- RAL_UNLOCK();
+ callout_reset(&sc->watchdog_ch, hz, rt2560_watchdog_callout, sc);
}
static int
switch (cmd) {
case SIOCSIFFLAGS:
- 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();
if (startall)
ieee80211_start_all(ic);
break;
struct ifnet *ifp = ic->ic_ifp;
struct rt2560_softc *sc = ifp->if_softc;
- RAL_LOCK();
rt2560_set_chan(sc, ic->ic_curchan);
- RAL_UNLOCK();
}
uint32_t tmp;
int i;
- RAL_LOCK_ASSERT();
-
rt2560_stop_locked(sc);
/* setup tx rings */
if (rt2560_bbp_init(sc) != 0) {
rt2560_stop(sc);
- RAL_UNLOCK();
return;
}
ifp->if_flags &= ~IFF_OACTIVE;
ifp->if_flags |= IFF_RUNNING;
- callout_reset(&sc->watchdog_ch, hz, rt2560_watchdog, sc);
+ callout_reset(&sc->watchdog_ch, hz, rt2560_watchdog_callout, sc);
#undef N
}
struct ifnet *ifp = sc->sc_ifp;
struct ieee80211com *ic = ifp->if_l2com;
- RAL_LOCK();
rt2560_init_locked(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();
-
while (*flags & RT2560_F_INPUT_RUNNING)
- lksleep(sc, &sc->sc_lock, 0, "ralrunning", hz/10);
+ zsleep(sc, &wlan_global_serializer, 0, "ralrunning", hz/10);
callout_stop(&sc->watchdog_ch);
sc->sc_tx_timer = 0;
{
struct rt2560_softc *sc = arg;
- RAL_LOCK();
rt2560_stop_locked(sc);
- RAL_UNLOCK();
}
static int
struct ifnet *ifp = ic->ic_ifp;
struct rt2560_softc *sc = ifp->if_softc;
- RAL_LOCK();
-
/* prevent management frames from being sent if we're not ready */
if (!(ifp->if_flags & IFF_RUNNING)) {
- 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();
m_freem(m);
ieee80211_free_node(ni);
return ENOBUFS; /* XXX */
}
sc->sc_tx_timer = 5;
- RAL_UNLOCK();
-
return 0;
bad:
ifp->if_oerrors++;
ieee80211_free_node(ni);
- RAL_UNLOCK();
return EIO; /* XXX */
}
bus_space_tag_t sc_st;
bus_space_handle_t sc_sh;
- struct lock sc_lock;
-
struct callout watchdog_ch;
int sc_tx_timer;
void rt2560_stop(void *);
void rt2560_resume(void *);
void rt2560_intr(void *);
-
-#define RAL_LOCK() lwkt_gettoken(&wlan_token)
-#define RAL_LOCK_ASSERT() ASSERT_LWKT_TOKEN_HELD(&wlan_token)
-#define RAL_UNLOCK() lwkt_reltoken(&wlan_token)
static void rt2661_start(struct ifnet *);
static int rt2661_raw_xmit(struct ieee80211_node *, struct mbuf *,
const struct ieee80211_bpf_params *);
-static void rt2661_watchdog(void *);
+static void rt2661_watchdog_callout(void *);
static int rt2661_ioctl(struct ifnet *, u_long, caddr_t,
struct ucred *);
static void rt2661_bbp_write(struct rt2661_softc *, uint8_t,
}
ic = ifp->if_l2com;
- lockinit(&sc->sc_lock, __DECONST(char *, device_get_nameunit(dev)),
- 0, LK_CANRECURSE);
-
callout_init(&sc->watchdog_ch);
/* wait for NIC to initialize */
fail3: rt2661_free_tx_ring(sc, &sc->mgtq);
fail2: while (--ac >= 0)
rt2661_free_tx_ring(sc, &sc->txq[ac]);
-fail1: lockuninit(&sc->sc_lock);
+fail1:
if_free(ifp);
return error;
}
struct ifnet *ifp = sc->sc_ifp;
struct ieee80211com *ic = ifp->if_l2com;
- RAL_LOCK();
rt2661_stop_locked(sc);
- RAL_UNLOCK();
ieee80211_ifdetach(ic);
if_free(ifp);
- lockuninit(&sc->sc_lock);
-
return 0;
}
tap->wr_antnoise = nf;
}
sc->sc_flags |= RAL_INPUT_RUNNING;
- 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->sc_flags &= ~RAL_INPUT_RUNNING;
skip: desc->flags |= htole32(RT2661_RX_BUSY);
struct ifnet *ifp = sc->sc_ifp;
uint32_t r1, r2;
- RAL_LOCK();
-
/* disable MAC and MCU interrupts */
RAL_WRITE(sc, RT2661_INT_MASK_CSR, 0xffffff7f);
RAL_WRITE(sc, RT2661_MCU_INT_MASK_CSR, 0xffffffff);
/* don't re-enable interrupts if we're shutting down */
if (!(ifp->if_flags & IFF_RUNNING)) {
- RAL_UNLOCK();
return;
}
RAL_WRITE(sc, RT2661_INT_MASK_CSR, 0x0000ff10);
RAL_WRITE(sc, RT2661_MCU_INT_MASK_CSR, 0);
- RAL_UNLOCK();
}
static uint8_t
struct ieee80211_node *ni;
int ac;
- RAL_LOCK_ASSERT();
-
/* prevent management frames from being sent if we're not ready */
if (!(ifp->if_flags & IFF_RUNNING) || sc->sc_invalid)
return;
static void
rt2661_start(struct ifnet *ifp)
{
- RAL_LOCK();
rt2661_start_locked(ifp);
- RAL_UNLOCK();
}
static int
struct ifnet *ifp = ic->ic_ifp;
struct rt2661_softc *sc = ifp->if_softc;
- RAL_LOCK();
-
/* prevent management frames from being sent if we're not ready */
if (!(ifp->if_flags & IFF_RUNNING)) {
- 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();
m_freem(m);
ieee80211_free_node(ni);
return ENOBUFS; /* XXX */
goto bad;
sc->sc_tx_timer = 5;
- RAL_UNLOCK();
-
return 0;
bad:
ifp->if_oerrors++;
ieee80211_free_node(ni);
- RAL_UNLOCK();
return EIO; /* XXX */
}
static void
-rt2661_watchdog(void *arg)
+rt2661_watchdog_callout(void *arg)
{
struct rt2661_softc *sc = (struct rt2661_softc *)arg;
struct ifnet *ifp = sc->sc_ifp;
- RAL_LOCK();
-
KASSERT(ifp->if_flags & IFF_RUNNING, ("not running"));
if (sc->sc_invalid) /* card ejected */
/* NB: callout is reset in rt2661_init() */
return;
}
- callout_reset(&sc->watchdog_ch, hz, rt2661_watchdog, sc);
+ callout_reset(&sc->watchdog_ch, hz, rt2661_watchdog_callout, sc);
- RAL_UNLOCK();
}
static int
switch (cmd) {
case SIOCSIFFLAGS:
- 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();
if (startall)
ieee80211_start_all(ic);
break;
uint32_t tmp, sta[3];
int i, error, ntries;
- RAL_LOCK_ASSERT();
-
if ((sc->sc_flags & RAL_FW_LOADED) == 0) {
error = rt2661_load_microcode(sc);
if (error != 0) {
ifp->if_flags &= ~IFF_OACTIVE;
ifp->if_flags |= IFF_RUNNING;
- callout_reset(&sc->watchdog_ch, hz, rt2661_watchdog, sc);
+ callout_reset(&sc->watchdog_ch, hz, rt2661_watchdog_callout, sc);
#undef N
}
struct ifnet *ifp = sc->sc_ifp;
struct ieee80211com *ic = ifp->if_l2com;
- RAL_LOCK();
rt2661_init_locked(sc);
- RAL_UNLOCK();
if (ifp->if_flags & IFF_RUNNING)
ieee80211_start_all(ic); /* start all vap's */
volatile int *flags = &sc->sc_flags;
while (*flags & RAL_INPUT_RUNNING)
- lksleep(sc, &sc->sc_lock, 0, "ralrunning", hz/10);
+ zsleep(sc, &wlan_global_serializer, 0, "ralrunning", hz/10);
callout_stop(&sc->watchdog_ch);
sc->sc_tx_timer = 0;
{
struct rt2661_softc *sc = priv;
- RAL_LOCK();
rt2661_stop_locked(sc);
- RAL_UNLOCK();
}
static int
const char *imagename;
int ntries, error;
- RAL_LOCK_ASSERT();
-
switch (sc->sc_id) {
case 0x0301: imagename = "rt2561sfw"; break;
case 0x0302: imagename = "rt2561fw"; break;
__func__, sc->sc_id);
return EINVAL;
}
- RAL_UNLOCK();
fp = firmware_get(imagename);
- 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();
rt2661_set_chan(sc, ic->ic_curchan);
- RAL_UNLOCK();
-
}
bus_space_tag_t sc_st;
bus_space_handle_t sc_sh;
- struct lock sc_lock;
-
struct callout watchdog_ch;
int sc_tx_timer;
void rt2661_suspend(void *);
void rt2661_resume(void *);
void rt2661_intr(void *);
-
-#define RAL_LOCK() lwkt_gettoken(&wlan_token)
-#define RAL_LOCK_ASSERT() ASSERT_LWKT_TOKEN_HELD(&wlan_token)
-#define RAL_UNLOCK() lwkt_reltoken(&wlan_token)