static void wi_recv_mgmt(struct ieee80211_node *ni, struct mbuf *m,
int subtype, int rssi, int nf);
static int wi_reset(struct wi_softc *);
-static void wi_watchdog(void *);
+static void wi_watchdog_callout(void *);
static int wi_ioctl(struct ifnet *, u_long, caddr_t, struct ucred *);
static void wi_media_status(struct ifnet *, struct ifmediareq *);
SYSCTL_ADD_STRING(sctx, SYSCTL_CHILDREN(soid), OID_AUTO, "nic_name",
CTLFLAG_RD, sc->sc_nic_name, 0, "NIC name");
- lockinit(&sc->sc_lock, __DECONST(char *, device_get_nameunit(dev)),
- 0, LK_CANRECURSE);
callout_init(&sc->sc_watchdog);
/*
struct ifnet *ifp = sc->sc_ifp;
struct ieee80211com *ic = ifp->if_l2com;
- WI_LOCK(sc);
-
/* check if device was removed */
sc->wi_gone |= !bus_child_present(dev);
wi_stop_locked(sc, 0);
- WI_UNLOCK(sc);
ieee80211_ifdetach(ic);
bus_teardown_intr(dev, sc->irq, sc->wi_intrhand);
if_free(sc->sc_ifp);
wi_free(dev);
- lockuninit(&sc->sc_lock);
return (0);
}
struct ifnet *ifp = sc->sc_ifp;
u_int16_t status;
- WI_LOCK(sc);
-
if (sc->wi_gone || !sc->sc_enabled || (ifp->if_flags & IFF_UP) == 0) {
CSR_WRITE_2(sc, WI_INT_EN, 0);
CSR_WRITE_2(sc, WI_EVENT_ACK, 0xFFFF);
- WI_UNLOCK(sc);
return;
}
/* Re-enable interrupts. */
CSR_WRITE_2(sc, WI_INT_EN, WI_INTRS);
- WI_UNLOCK(sc);
-
return;
}
struct ifnet *ifp = sc->sc_ifp;
int wasenabled;
- WI_LOCK_ASSERT(sc);
-
wasenabled = sc->sc_enabled;
if (wasenabled)
wi_stop_locked(sc, 1);
ifp->if_flags |= IFF_RUNNING;
ifp->if_flags &= ~IFF_OACTIVE;
- callout_reset(&sc->sc_watchdog, hz, wi_watchdog, sc);
+ callout_reset(&sc->sc_watchdog, hz, wi_watchdog_callout, sc);
wi_enable(sc); /* Enable desired port */
}
struct ifnet *ifp = sc->sc_ifp;
struct ieee80211com *ic = ifp->if_l2com;
- WI_LOCK(sc);
wi_init_locked(sc);
- WI_UNLOCK(sc);
if (ifp->if_flags & IFF_RUNNING)
ieee80211_start_all(ic); /* start all vap's */
{
struct ifnet *ifp = sc->sc_ifp;
- WI_LOCK_ASSERT(sc);
-
if (sc->sc_enabled && !sc->wi_gone) {
CSR_WRITE_2(sc, WI_INT_EN, 0);
wi_cmd(sc, WI_CMD_DISABLE | sc->sc_portnum, 0, 0, 0);
void
wi_stop(struct wi_softc *sc, int disable)
{
- WI_LOCK(sc);
wi_stop_locked(sc, disable);
- WI_UNLOCK(sc);
}
static void
ieee80211_chan2ieee(ic, ic->ic_curchan),
ic->ic_flags & IEEE80211_F_SCAN ? "" : "!"));
- WI_LOCK(sc);
wi_write_val(sc, WI_RID_OWN_CHNL,
ieee80211_chan2ieee(ic, ic->ic_curchan));
- WI_UNLOCK(sc);
}
static void
DPRINTF(("%s\n", __func__));
- WI_LOCK(sc);
/*
* Switch device to monitor mode.
*/
}
/* force full dwell time to compensate for firmware overhead */
ss->ss_mindwell = ss->ss_maxdwell = msecs_to_ticks(400);
- WI_UNLOCK(sc);
}
DPRINTF(("%s: restore port type %d\n", __func__, sc->sc_porttype));
- WI_LOCK(sc);
wi_write_val(sc, WI_RID_PORTTYPE, sc->sc_porttype);
if (sc->sc_firmware_type == WI_INTERSIL) {
wi_cmd(sc, WI_CMD_DISABLE | WI_PORT0, 0, 0, 0);
wi_cmd(sc, WI_CMD_ENABLE | WI_PORT0, 0, 0, 0);
}
- WI_UNLOCK(sc);
}
static void
ieee80211_state_name[nstate]));
if (nstate == IEEE80211_S_AUTH) {
- WI_LOCK(sc);
wi_setup_locked(sc, WI_PORTTYPE_BSS, 3, vap->iv_myaddr);
if (vap->iv_flags & IEEE80211_F_PMGTON) {
ieee80211_chan2ieee(ic, bss->ni_chan));
wi_write_rid(sc, WI_RID_JOIN_REQ, &join, sizeof(join));
}
- WI_UNLOCK(sc);
/*
* NB: don't go through 802.11 layer, it'll send auth frame;
error = WI_VAP(vap)->wv_newstate(vap, nstate, arg);
if (error == 0 && nstate == IEEE80211_S_RUN) {
- WI_LOCK(sc);
wi_setup_locked(sc, WI_PORTTYPE_HOSTAP, 0, vap->iv_myaddr);
bss = vap->iv_bss;
sc->sc_encryption = 0;
wi_enable(sc); /* enable port */
- WI_UNLOCK(sc);
}
return error;
}
const struct llc *llc;
int cur;
- WI_LOCK_ASSERT(sc);
-
if (sc->wi_gone)
return;
{
struct wi_softc *sc = ifp->if_softc;
- WI_LOCK(sc);
wi_start_locked(ifp);
- WI_UNLOCK(sc);
}
static int
int cur;
int rc = 0;
- WI_LOCK(sc);
-
if (sc->wi_gone) {
rc = ENETDOWN;
goto out;
sc->sc_txnext = cur = (cur + 1) % sc->sc_ntxbuf;
out:
- WI_UNLOCK(sc);
if (m0 != NULL)
m_freem(m0);
}
static void
-wi_watchdog(void *arg)
+wi_watchdog_callout(void *arg)
{
struct wi_softc *sc = arg;
struct ifnet *ifp = sc->sc_ifp;
- WI_LOCK(sc);
-
if (!sc->sc_enabled)
return;
wi_init_locked(ifp->if_softc);
return;
}
- callout_reset(&sc->sc_watchdog, hz, wi_watchdog, sc);
+ callout_reset(&sc->sc_watchdog, hz, wi_watchdog_callout, sc);
}
static int
switch (cmd) {
case SIOCSIFFLAGS:
- WI_LOCK(sc);
/*
* Can't do promisc and hostap at the same time. If all that's
* changing is the promisc flag, try to short-circuit a call to
sc->wi_gone = 0;
}
sc->sc_if_flags = ifp->if_flags;
- WI_UNLOCK(sc);
if (startall)
ieee80211_start_all(ic);
break;
if (ic->ic_opmode == IEEE80211_M_IBSS && dir == IEEE80211_FC1_DIR_NODS)
wi_sync_bssid(sc, wh->i_addr3);
- WI_UNLOCK(sc);
-
ni = ieee80211_find_rxnode(ic, mtod(m, struct ieee80211_frame_min *));
if (ni != NULL) {
(void) ieee80211_input(ni, m, rssi, nf);
} else
(void) ieee80211_input_all(ic, m, rssi, nf);
- WI_LOCK(sc);
}
static __noinline void
break;
/* fall thru... */
case WI_INFO_LINK_STAT_AP_CHG:
- IEEE80211_LOCK(ic);
vap->iv_bss->ni_associd = 1 | 0xc000; /* NB: anything will do */
ieee80211_new_state(vap, IEEE80211_S_RUN, 0);
- IEEE80211_UNLOCK(ic);
break;
case WI_INFO_LINK_STAT_AP_INR:
break;
case WI_INFO_LINK_STAT_DISCONNECTED:
/* we dropped off the net; e.g. due to deauth/disassoc */
- IEEE80211_LOCK(ic);
vap->iv_bss->ni_associd = 0;
vap->iv_stats.is_rx_deauth++;
ieee80211_new_state(vap, IEEE80211_S_SCAN, 0);
- IEEE80211_UNLOCK(ic);
break;
case WI_INFO_LINK_STAT_AP_OOR:
/* XXX does this need to be per-vap? */
struct wi_softc *sc = ifp->if_softc;
struct ieee80211com *ic = ifp->if_l2com;
- WI_LOCK(sc);
/* XXX handle WEP special case handling? */
wi_write_val(sc, WI_RID_PROMISC,
(ic->ic_opmode == IEEE80211_M_MONITOR ||
(ifp->if_flags & IFF_PROMISC)));
- WI_UNLOCK(sc);
}
static void
struct wi_softc *sc;
int i;
+ wlan_serialize_enter();
sc = device_get_softc(dev);
for(i=0; pci_ids[i].vendor != 0; i++) {
if ((pci_get_vendor(dev) == pci_ids[i].vendor) &&
(pci_get_device(dev) == pci_ids[i].device)) {
sc->wi_bus_type = pci_ids[i].bus_type;
device_set_desc(dev, pci_ids[i].desc);
+ wlan_serialize_exit();
return (BUS_PROBE_DEFAULT);
}
}
+ wlan_serialize_exit();
return(ENXIO);
}
int error;
int timeout;
+ wlan_serialize_enter();
sc = device_get_softc(dev);
command = pci_read_config(dev, PCIR_COMMAND, 4);
command = pci_read_config(dev, PCIR_COMMAND, 4);
if ((command & wanted) != wanted) {
device_printf(dev, "wi_pci_attach() failed to enable pci!\n");
+ wlan_serialize_exit();
return (ENXIO);
}
if (sc->wi_bus_type != WI_BUS_PCI_NATIVE) {
error = wi_alloc(dev, WI_PCI_IORES);
- if (error)
+ if (error) {
+ wlan_serialize_exit();
return (error);
+ }
/* Make sure interrupts are disabled. */
CSR_WRITE_2(sc, WI_INT_EN, 0);
if (sc->mem == NULL) {
device_printf(dev, "couldn't allocate memory\n");
wi_free(dev);
+ wlan_serialize_exit();
return (ENXIO);
}
sc->wi_bmemtag = rman_get_bustag(sc->mem);
device_printf(dev, "CSM_READ_1(WI_COR_OFFSET) "
"wanted %d, got %d\n", WI_COR_VALUE, reg);
wi_free(dev);
+ wlan_serialize_exit();
return (ENXIO);
}
} else {
error = wi_alloc(dev, WI_PCI_LMEMRES);
- if (error)
+ if (error) {
+ wlan_serialize_exit();
return (error);
+ }
CSR_WRITE_2(sc, WI_PCICOR_OFF, WI_PCICOR_RESET);
DELAY(250000);
if (timeout == 0) {
device_printf(dev, "couldn't reset prism pci core.\n");
wi_free(dev);
+ wlan_serialize_exit();
return(ENXIO);
}
}
"CSR_READ_2(WI_HFA384X_SWSUPPORT0_OFF) "
"wanted %d, got %d\n", WI_PRISM2STA_MAGIC, reg);
wi_free(dev);
+ wlan_serialize_exit();
return (ENXIO);
}
error = wi_attach(dev);
if (error != 0)
wi_free(dev);
+ wlan_serialize_exit();
return (error);
}
{
struct wi_softc *sc = device_get_softc(dev);
+ wlan_serialize_enter();
wi_stop(sc, 1);
+ wlan_serialize_exit();
return (0);
}
struct wi_softc *sc = device_get_softc(dev);
struct ifnet *ifp = sc->sc_ifp;
- if (sc->wi_bus_type != WI_BUS_PCI_NATIVE)
+ wlan_serialize_enter();
+ if (sc->wi_bus_type != WI_BUS_PCI_NATIVE) {
+ wlan_serialize_exit();
return (0);
+ }
if (ifp->if_flags & IFF_UP) {
ifp->if_init(ifp->if_softc);
if (ifp->if_flags & IFF_RUNNING)
ifp->if_start(ifp);
}
+ wlan_serialize_exit();
return (0);
}