Author: korli Date: 2011-04-11 20:02:47 +0200 (Mon, 11 Apr 2011) New Revision: 41221 Changeset: https://dev.haiku-os.org/changeset/41221 Modified: haiku/vendor/freebsd/current/dev/wpi/if_wpi.c haiku/vendor/freebsd/current/dev/wpi/if_wpivar.h Log: updating to FreeBSD 8.2 release Modified: haiku/vendor/freebsd/current/dev/wpi/if_wpi.c =================================================================== --- haiku/vendor/freebsd/current/dev/wpi/if_wpi.c 2011-04-11 18:02:40 UTC (rev 41220) +++ haiku/vendor/freebsd/current/dev/wpi/if_wpi.c 2011-04-11 18:02:47 UTC (rev 41221) @@ -93,6 +93,7 @@ #include <net80211/ieee80211_var.h> #include <net80211/ieee80211_radiotap.h> #include <net80211/ieee80211_regdomain.h> +#include <net80211/ieee80211_ratectl.h> #include <netinet/in.h> #include <netinet/in_systm.h> @@ -126,7 +127,7 @@ WPI_DEBUG_ANY = 0xffffffff }; -static int wpi_debug = 1; +static int wpi_debug = 0; SYSCTL_INT(_debug, OID_AUTO, wpi, CTLFLAG_RW, &wpi_debug, 0, "wpi debug level"); TUNABLE_INT("debug.wpi", &wpi_debug); @@ -173,8 +174,6 @@ int, int); static void wpi_reset_tx_ring(struct wpi_softc *, struct wpi_tx_ring *); static void wpi_free_tx_ring(struct wpi_softc *, struct wpi_tx_ring *); -static struct ieee80211_node *wpi_node_alloc(struct ieee80211vap *, - const uint8_t mac[IEEE80211_ADDR_LEN]); static int wpi_newstate(struct ieee80211vap *, enum ieee80211_state, int); static void wpi_mem_lock(struct wpi_softc *); static void wpi_mem_unlock(struct wpi_softc *); @@ -235,7 +234,6 @@ static void wpi_stop(struct wpi_softc *); static void wpi_stop_locked(struct wpi_softc *); -static void wpi_newassoc(struct ieee80211_node *, int); static int wpi_set_txpower(struct wpi_softc *, struct ieee80211_channel *, int); static void wpi_calib_timeout(void *); @@ -662,14 +660,12 @@ ifp->if_init = wpi_init; ifp->if_ioctl = wpi_ioctl; ifp->if_start = wpi_start; - IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN); - ifp->if_snd.ifq_drv_maxlen = IFQ_MAXLEN; + IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen); + ifp->if_snd.ifq_drv_maxlen = ifqmaxlen; IFQ_SET_READY(&ifp->if_snd); ieee80211_ifattach(ic, macaddr); /* override default methods */ - ic->ic_node_alloc = wpi_node_alloc; - ic->ic_newassoc = wpi_newassoc; ic->ic_raw_xmit = wpi_raw_xmit; ic->ic_wme.wme_update = wpi_wme_update; ic->ic_scan_start = wpi_scan_start; @@ -713,13 +709,14 @@ { struct wpi_softc *sc = device_get_softc(dev); struct ifnet *ifp = sc->sc_ifp; - struct ieee80211com *ic = ifp->if_l2com; + struct ieee80211com *ic; int ac; - ieee80211_draintask(ic, &sc->sc_restarttask); - ieee80211_draintask(ic, &sc->sc_radiotask); + if (ifp != NULL) { + ic = ifp->if_l2com; - if (ifp != NULL) { + ieee80211_draintask(ic, &sc->sc_restarttask); + ieee80211_draintask(ic, &sc->sc_radiotask); wpi_stop(sc); callout_drain(&sc->watchdog_to); callout_drain(&sc->calib_to); @@ -781,11 +778,7 @@ wvp->newstate = vap->iv_newstate; vap->iv_newstate = wpi_newstate; - ieee80211_amrr_init(&wvp->amrr, vap, - IEEE80211_AMRR_MIN_SUCCESS_THRESHOLD, - IEEE80211_AMRR_MAX_SUCCESS_THRESHOLD, - 500 /*ms*/); - + ieee80211_ratectl_init(vap); /* complete setup */ ieee80211_vap_attach(vap, ieee80211_media_change, ieee80211_media_status); ic->ic_opmode = opmode; @@ -797,7 +790,7 @@ { struct wpi_vap *wvp = WPI_VAP(vap); - ieee80211_amrr_cleanup(&wvp->amrr); + ieee80211_ratectl_deinit(vap); ieee80211_vap_detach(vap); free(wvp, M_80211_VAP); } @@ -1057,9 +1050,18 @@ wpi_dma_contig_free(&ring->desc_dma); - for (i = 0; i < WPI_RX_RING_COUNT; i++) - if (ring->data[i].m != NULL) - m_freem(ring->data[i].m); + for (i = 0; i < WPI_RX_RING_COUNT; i++) { + struct wpi_rx_data *data = &ring->data[i]; + + if (data->m != NULL) { + bus_dmamap_sync(ring->data_dmat, data->map, + BUS_DMASYNC_POSTREAD); + bus_dmamap_unload(ring->data_dmat, data->map); + m_freem(data->m); + } + if (data->map != NULL) + bus_dmamap_destroy(ring->data_dmat, data->map); + } } static int @@ -1235,18 +1237,6 @@ return 0; } -/* ARGSUSED */ -static struct ieee80211_node * -wpi_node_alloc(struct ieee80211vap *vap __unused, - const uint8_t mac[IEEE80211_ADDR_LEN] __unused) -{ - struct wpi_node *wn; - - wn = malloc(sizeof (struct wpi_node), M_80211_NODE, M_NOWAIT | M_ZERO); - - return &wn->ni; -} - /** * Called by net80211 when ever there is a change to 80211 state machine */ @@ -1265,8 +1255,25 @@ IEEE80211_UNLOCK(ic); WPI_LOCK(sc); - if (nstate == IEEE80211_S_AUTH) { - /* The node must be registered in the firmware before auth */ + if (nstate == IEEE80211_S_SCAN && vap->iv_state != IEEE80211_S_INIT) { + /* + * On !INIT -> SCAN transitions, we need to clear any possible + * knowledge about associations. + */ + error = wpi_config(sc); + if (error != 0) { + device_printf(sc->sc_dev, + "%s: device config failed, error %d\n", + __func__, error); + } + } + if (nstate == IEEE80211_S_AUTH || + (nstate == IEEE80211_S_ASSOC && vap->iv_state == IEEE80211_S_RUN)) { + /* + * The node must be registered in the firmware before auth. + * Also the associd must be cleared on RUN -> ASSOC + * transitions. + */ error = wpi_auth(sc, vap); if (error != 0) { device_printf(sc->sc_dev, @@ -1461,6 +1468,7 @@ return; } + bus_dmamap_sync(ring->data_dmat, data->map, BUS_DMASYNC_POSTREAD); head = (struct wpi_rx_head *)((caddr_t)(stat + 1) + stat->len); tail = (struct wpi_rx_tail *)((caddr_t)(head + 1) + le16toh(head->len)); @@ -1491,6 +1499,8 @@ ifp->if_ierrors++; return; } + bus_dmamap_unload(ring->data_dmat, data->map); + error = bus_dmamap_load(ring->data_dmat, data->map, mtod(mnew, caddr_t), MJUMPAGESIZE, wpi_dma_map_addr, &paddr, BUS_DMA_NOWAIT); @@ -1566,7 +1576,9 @@ struct wpi_tx_ring *ring = &sc->txq[desc->qid & 0x3]; struct wpi_tx_data *txdata = &ring->data[desc->idx]; struct wpi_tx_stat *stat = (struct wpi_tx_stat *)(desc + 1); - struct wpi_node *wn = (struct wpi_node *)txdata->ni; + struct ieee80211_node *ni = txdata->ni; + struct ieee80211vap *vap = ni->ni_vap; + int retrycnt = 0; DPRINTFN(WPI_DEBUG_TX, ("tx done: qid=%d idx=%d retries=%d nkill=%d " "rate=%x duration=%d status=%x\n", desc->qid, desc->idx, @@ -1579,11 +1591,12 @@ * the lowest available bit-rate. * XXX frames w/o ACK shouldn't be used either */ - wn->amn.amn_txcnt++; if (stat->ntries > 0) { DPRINTFN(WPI_DEBUG_TX, ("%d retries\n", stat->ntries)); - wn->amn.amn_retrycnt++; + retrycnt = 1; } + ieee80211_ratectl_tx_complete(vap, ni, IEEE80211_RATECTL_TX_SUCCESS, + &retrycnt, NULL); /* XXX oerrors should only count errors !maxtries */ if ((le32toh(stat->status) & 0xff) != 1) @@ -1642,9 +1655,15 @@ struct wpi_rx_data *data; uint32_t hw; + bus_dmamap_sync(sc->shared_dma.tag, sc->shared_dma.map, + BUS_DMASYNC_POSTREAD); + hw = le32toh(sc->shared->next); while (sc->rxq.cur != hw) { data = &sc->rxq.data[sc->rxq.cur]; + + bus_dmamap_sync(sc->rxq.data_dmat, data->map, + BUS_DMASYNC_POSTREAD); desc = (void *)data->m->m_ext.ext_buf; DPRINTFN(WPI_DEBUG_NOTIFY, @@ -1918,7 +1937,7 @@ } else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) { rate = tp->ucastrate; } else { - (void) ieee80211_amrr_choose(ni, &WPI_NODE(ni)->amn); + (void) ieee80211_ratectl_rate(ni, NULL, 0); rate = ni->ni_txrate; } tx->rate = wpi_plcp_signal(rate); @@ -2426,6 +2445,9 @@ if (IEEE80211_IS_CHAN_2GHZ(ni->ni_chan)) { sc->config.flags |= htole32(WPI_CONFIG_AUTO | WPI_CONFIG_24GHZ); + } else { + sc->config.flags &= ~htole32(WPI_CONFIG_AUTO | + WPI_CONFIG_24GHZ); } if (IEEE80211_IS_CHAN_A(ni->ni_chan)) { sc->config.cck_mask = 0; @@ -3001,14 +3023,12 @@ if (ntries == 1000) { device_printf(sc->sc_dev, "timeout waiting for thermal calibration\n"); - WPI_UNLOCK(sc); return; } DPRINTFN(WPI_DEBUG_TEMP,("temperature %d\n", sc->temp)); if (wpi_config(sc) != 0) { device_printf(sc->sc_dev, "device config failed\n"); - WPI_UNLOCK(sc); return; } @@ -3211,15 +3231,6 @@ } static void -wpi_newassoc(struct ieee80211_node *ni, int isnew) -{ - struct ieee80211vap *vap = ni->ni_vap; - struct wpi_vap *wvp = WPI_VAP(vap); - - ieee80211_amrr_node_init(&wvp->amrr, &WPI_NODE(ni)->amn, ni); -} - -static void wpi_calib_timeout(void *arg) { struct wpi_softc *sc = arg; @@ -3552,7 +3563,9 @@ * are already taken care of by their respective firmware commands. */ if (ic->ic_opmode == IEEE80211_M_MONITOR) { + WPI_LOCK(sc); error = wpi_config(sc); + WPI_UNLOCK(sc); if (error != 0) device_printf(sc->sc_dev, "error %d settting channel\n", error); @@ -3705,4 +3718,3 @@ MODULE_DEPEND(wpi, pci, 1, 1, 1); MODULE_DEPEND(wpi, wlan, 1, 1, 1); MODULE_DEPEND(wpi, firmware, 1, 1, 1); -MODULE_DEPEND(wpi, wlan_amrr, 1, 1, 1); Modified: haiku/vendor/freebsd/current/dev/wpi/if_wpivar.h =================================================================== --- haiku/vendor/freebsd/current/dev/wpi/if_wpivar.h 2011-04-11 18:02:40 UTC (rev 41220) +++ haiku/vendor/freebsd/current/dev/wpi/if_wpivar.h 2011-04-11 18:02:47 UTC (rev 41221) @@ -106,12 +106,6 @@ int recovery; }; -struct wpi_node { - struct ieee80211_node ni; /* must be the first */ - struct ieee80211_amrr_node amn; -}; -#define WPI_NODE(ni) ((struct wpi_node *)(ni)) - struct wpi_power_sample { uint8_t index; int8_t power; @@ -127,7 +121,6 @@ struct wpi_vap { struct ieee80211vap vap; - struct ieee80211_amrr amrr; int (*newstate)(struct ieee80211vap *, enum ieee80211_state, int);