if_wpi.c (200530) | if_wpi.c (206358) |
---|---|
1/*- 2 * Copyright (c) 2006,2007 3 * Damien Bergamini <damien.bergamini@free.fr> 4 * Benjamin Close <Benjamin.Close@clearchain.com> 5 * 6 * Permission to use, copy, modify, and distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. --- 5 unchanged lines hidden (view full) --- 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19#define VERSION "20071127" 20 21#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2006,2007 3 * Damien Bergamini <damien.bergamini@free.fr> 4 * Benjamin Close <Benjamin.Close@clearchain.com> 5 * 6 * Permission to use, copy, modify, and distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. --- 5 unchanged lines hidden (view full) --- 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19#define VERSION "20071127" 20 21#include <sys/cdefs.h> |
22__FBSDID("$FreeBSD: head/sys/dev/wpi/if_wpi.c 200530 2009-12-14 19:18:02Z gavin $"); | 22__FBSDID("$FreeBSD: head/sys/dev/wpi/if_wpi.c 206358 2010-04-07 15:29:13Z rpaulo $"); |
23 24/* 25 * Driver for Intel PRO/Wireless 3945ABG 802.11 network adapters. 26 * 27 * The 3945ABG network adapter doesn't use traditional hardware as 28 * many other adaptors do. Instead at run time the eeprom is set into a known 29 * state and told to load boot firmware. The boot firmware loads an init and a 30 * main binary firmware image into SRAM on the card via DMA. --- 57 unchanged lines hidden (view full) --- 88#include <net/ethernet.h> 89#include <net/if_dl.h> 90#include <net/if_media.h> 91#include <net/if_types.h> 92 93#include <net80211/ieee80211_var.h> 94#include <net80211/ieee80211_radiotap.h> 95#include <net80211/ieee80211_regdomain.h> | 23 24/* 25 * Driver for Intel PRO/Wireless 3945ABG 802.11 network adapters. 26 * 27 * The 3945ABG network adapter doesn't use traditional hardware as 28 * many other adaptors do. Instead at run time the eeprom is set into a known 29 * state and told to load boot firmware. The boot firmware loads an init and a 30 * main binary firmware image into SRAM on the card via DMA. --- 57 unchanged lines hidden (view full) --- 88#include <net/ethernet.h> 89#include <net/if_dl.h> 90#include <net/if_media.h> 91#include <net/if_types.h> 92 93#include <net80211/ieee80211_var.h> 94#include <net80211/ieee80211_radiotap.h> 95#include <net80211/ieee80211_regdomain.h> |
96#include <net80211/ieee80211_ratectl.h> |
|
96 97#include <netinet/in.h> 98#include <netinet/in_systm.h> 99#include <netinet/in_var.h> 100#include <netinet/ip.h> 101#include <netinet/if_ether.h> 102 103#include <dev/wpi/if_wpireg.h> --- 64 unchanged lines hidden (view full) --- 168static void wpi_free_shared(struct wpi_softc *); 169static int wpi_alloc_rx_ring(struct wpi_softc *, struct wpi_rx_ring *); 170static void wpi_reset_rx_ring(struct wpi_softc *, struct wpi_rx_ring *); 171static void wpi_free_rx_ring(struct wpi_softc *, struct wpi_rx_ring *); 172static int wpi_alloc_tx_ring(struct wpi_softc *, struct wpi_tx_ring *, 173 int, int); 174static void wpi_reset_tx_ring(struct wpi_softc *, struct wpi_tx_ring *); 175static void wpi_free_tx_ring(struct wpi_softc *, struct wpi_tx_ring *); | 97 98#include <netinet/in.h> 99#include <netinet/in_systm.h> 100#include <netinet/in_var.h> 101#include <netinet/ip.h> 102#include <netinet/if_ether.h> 103 104#include <dev/wpi/if_wpireg.h> --- 64 unchanged lines hidden (view full) --- 169static void wpi_free_shared(struct wpi_softc *); 170static int wpi_alloc_rx_ring(struct wpi_softc *, struct wpi_rx_ring *); 171static void wpi_reset_rx_ring(struct wpi_softc *, struct wpi_rx_ring *); 172static void wpi_free_rx_ring(struct wpi_softc *, struct wpi_rx_ring *); 173static int wpi_alloc_tx_ring(struct wpi_softc *, struct wpi_tx_ring *, 174 int, int); 175static void wpi_reset_tx_ring(struct wpi_softc *, struct wpi_tx_ring *); 176static void wpi_free_tx_ring(struct wpi_softc *, struct wpi_tx_ring *); |
176static struct ieee80211_node *wpi_node_alloc(struct ieee80211vap *, 177 const uint8_t mac[IEEE80211_ADDR_LEN]); | |
178static int wpi_newstate(struct ieee80211vap *, enum ieee80211_state, int); 179static void wpi_mem_lock(struct wpi_softc *); 180static void wpi_mem_unlock(struct wpi_softc *); 181static uint32_t wpi_mem_read(struct wpi_softc *, uint16_t); 182static void wpi_mem_write(struct wpi_softc *, uint16_t, uint32_t); 183static void wpi_mem_write_region_4(struct wpi_softc *, uint16_t, 184 const uint32_t *, int); 185static uint16_t wpi_read_prom_data(struct wpi_softc *, uint32_t, void *, int); --- 44 unchanged lines hidden (view full) --- 230static void wpi_hwreset(void *, int); 231static void wpi_rfreset(void *, int); 232static void wpi_hw_config(struct wpi_softc *); 233static void wpi_init(void *); 234static void wpi_init_locked(struct wpi_softc *, int); 235static void wpi_stop(struct wpi_softc *); 236static void wpi_stop_locked(struct wpi_softc *); 237 | 177static int wpi_newstate(struct ieee80211vap *, enum ieee80211_state, int); 178static void wpi_mem_lock(struct wpi_softc *); 179static void wpi_mem_unlock(struct wpi_softc *); 180static uint32_t wpi_mem_read(struct wpi_softc *, uint16_t); 181static void wpi_mem_write(struct wpi_softc *, uint16_t, uint32_t); 182static void wpi_mem_write_region_4(struct wpi_softc *, uint16_t, 183 const uint32_t *, int); 184static uint16_t wpi_read_prom_data(struct wpi_softc *, uint32_t, void *, int); --- 44 unchanged lines hidden (view full) --- 229static void wpi_hwreset(void *, int); 230static void wpi_rfreset(void *, int); 231static void wpi_hw_config(struct wpi_softc *); 232static void wpi_init(void *); 233static void wpi_init_locked(struct wpi_softc *, int); 234static void wpi_stop(struct wpi_softc *); 235static void wpi_stop_locked(struct wpi_softc *); 236 |
238static void wpi_newassoc(struct ieee80211_node *, int); | |
239static int wpi_set_txpower(struct wpi_softc *, struct ieee80211_channel *, 240 int); 241static void wpi_calib_timeout(void *); 242static void wpi_power_calibration(struct wpi_softc *, int); 243static int wpi_get_power_index(struct wpi_softc *, 244 struct wpi_power_group *, struct ieee80211_channel *, int); 245#ifdef WPI_DEBUG 246static const char *wpi_cmd_str(int); --- 416 unchanged lines hidden (view full) --- 663 ifp->if_ioctl = wpi_ioctl; 664 ifp->if_start = wpi_start; 665 IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN); 666 ifp->if_snd.ifq_drv_maxlen = IFQ_MAXLEN; 667 IFQ_SET_READY(&ifp->if_snd); 668 669 ieee80211_ifattach(ic, macaddr); 670 /* override default methods */ | 237static int wpi_set_txpower(struct wpi_softc *, struct ieee80211_channel *, 238 int); 239static void wpi_calib_timeout(void *); 240static void wpi_power_calibration(struct wpi_softc *, int); 241static int wpi_get_power_index(struct wpi_softc *, 242 struct wpi_power_group *, struct ieee80211_channel *, int); 243#ifdef WPI_DEBUG 244static const char *wpi_cmd_str(int); --- 416 unchanged lines hidden (view full) --- 661 ifp->if_ioctl = wpi_ioctl; 662 ifp->if_start = wpi_start; 663 IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN); 664 ifp->if_snd.ifq_drv_maxlen = IFQ_MAXLEN; 665 IFQ_SET_READY(&ifp->if_snd); 666 667 ieee80211_ifattach(ic, macaddr); 668 /* override default methods */ |
671 ic->ic_node_alloc = wpi_node_alloc; 672 ic->ic_newassoc = wpi_newassoc; | |
673 ic->ic_raw_xmit = wpi_raw_xmit; 674 ic->ic_wme.wme_update = wpi_wme_update; 675 ic->ic_scan_start = wpi_scan_start; 676 ic->ic_scan_end = wpi_scan_end; 677 ic->ic_set_channel = wpi_set_channel; 678 ic->ic_scan_curchan = wpi_scan_curchan; 679 ic->ic_scan_mindwell = wpi_scan_mindwell; 680 --- 96 unchanged lines hidden (view full) --- 777 if (wvp == NULL) 778 return NULL; 779 vap = &wvp->vap; 780 ieee80211_vap_setup(ic, vap, name, unit, opmode, flags, bssid, mac); 781 /* override with driver methods */ 782 wvp->newstate = vap->iv_newstate; 783 vap->iv_newstate = wpi_newstate; 784 | 669 ic->ic_raw_xmit = wpi_raw_xmit; 670 ic->ic_wme.wme_update = wpi_wme_update; 671 ic->ic_scan_start = wpi_scan_start; 672 ic->ic_scan_end = wpi_scan_end; 673 ic->ic_set_channel = wpi_set_channel; 674 ic->ic_scan_curchan = wpi_scan_curchan; 675 ic->ic_scan_mindwell = wpi_scan_mindwell; 676 --- 96 unchanged lines hidden (view full) --- 773 if (wvp == NULL) 774 return NULL; 775 vap = &wvp->vap; 776 ieee80211_vap_setup(ic, vap, name, unit, opmode, flags, bssid, mac); 777 /* override with driver methods */ 778 wvp->newstate = vap->iv_newstate; 779 vap->iv_newstate = wpi_newstate; 780 |
785 ieee80211_amrr_init(&wvp->amrr, vap, 786 IEEE80211_AMRR_MIN_SUCCESS_THRESHOLD, 787 IEEE80211_AMRR_MAX_SUCCESS_THRESHOLD, 788 500 /*ms*/); 789 | 781 ieee80211_ratectl_init(vap); |
790 /* complete setup */ 791 ieee80211_vap_attach(vap, ieee80211_media_change, ieee80211_media_status); 792 ic->ic_opmode = opmode; 793 return vap; 794} 795 796static void 797wpi_vap_delete(struct ieee80211vap *vap) 798{ 799 struct wpi_vap *wvp = WPI_VAP(vap); 800 | 782 /* complete setup */ 783 ieee80211_vap_attach(vap, ieee80211_media_change, ieee80211_media_status); 784 ic->ic_opmode = opmode; 785 return vap; 786} 787 788static void 789wpi_vap_delete(struct ieee80211vap *vap) 790{ 791 struct wpi_vap *wvp = WPI_VAP(vap); 792 |
801 ieee80211_amrr_cleanup(&wvp->amrr); | 793 ieee80211_ratectl_deinit(vap); |
802 ieee80211_vap_detach(vap); 803 free(wvp, M_80211_VAP); 804} 805 806static void 807wpi_dma_map_addr(void *arg, bus_dma_segment_t *segs, int nsegs, int error) 808{ 809 if (error != 0) --- 421 unchanged lines hidden (view full) --- 1231 if (ifp->if_flags & IFF_UP) { 1232 wpi_init(ifp->if_softc); 1233 if (ifp->if_drv_flags & IFF_DRV_RUNNING) 1234 wpi_start(ifp); 1235 } 1236 return 0; 1237} 1238 | 794 ieee80211_vap_detach(vap); 795 free(wvp, M_80211_VAP); 796} 797 798static void 799wpi_dma_map_addr(void *arg, bus_dma_segment_t *segs, int nsegs, int error) 800{ 801 if (error != 0) --- 421 unchanged lines hidden (view full) --- 1223 if (ifp->if_flags & IFF_UP) { 1224 wpi_init(ifp->if_softc); 1225 if (ifp->if_drv_flags & IFF_DRV_RUNNING) 1226 wpi_start(ifp); 1227 } 1228 return 0; 1229} 1230 |
1239/* ARGSUSED */ 1240static struct ieee80211_node * 1241wpi_node_alloc(struct ieee80211vap *vap __unused, 1242 const uint8_t mac[IEEE80211_ADDR_LEN] __unused) 1243{ 1244 struct wpi_node *wn; 1245 1246 wn = malloc(sizeof (struct wpi_node), M_80211_NODE, M_NOWAIT | M_ZERO); 1247 1248 return &wn->ni; 1249} 1250 | |
1251/** 1252 * Called by net80211 when ever there is a change to 80211 state machine 1253 */ 1254static int 1255wpi_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) 1256{ 1257 struct wpi_vap *wvp = WPI_VAP(vap); 1258 struct ieee80211com *ic = vap->iv_ic; --- 303 unchanged lines hidden (view full) --- 1562 1563static void 1564wpi_tx_intr(struct wpi_softc *sc, struct wpi_rx_desc *desc) 1565{ 1566 struct ifnet *ifp = sc->sc_ifp; 1567 struct wpi_tx_ring *ring = &sc->txq[desc->qid & 0x3]; 1568 struct wpi_tx_data *txdata = &ring->data[desc->idx]; 1569 struct wpi_tx_stat *stat = (struct wpi_tx_stat *)(desc + 1); | 1231/** 1232 * Called by net80211 when ever there is a change to 80211 state machine 1233 */ 1234static int 1235wpi_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) 1236{ 1237 struct wpi_vap *wvp = WPI_VAP(vap); 1238 struct ieee80211com *ic = vap->iv_ic; --- 303 unchanged lines hidden (view full) --- 1542 1543static void 1544wpi_tx_intr(struct wpi_softc *sc, struct wpi_rx_desc *desc) 1545{ 1546 struct ifnet *ifp = sc->sc_ifp; 1547 struct wpi_tx_ring *ring = &sc->txq[desc->qid & 0x3]; 1548 struct wpi_tx_data *txdata = &ring->data[desc->idx]; 1549 struct wpi_tx_stat *stat = (struct wpi_tx_stat *)(desc + 1); |
1570 struct wpi_node *wn = (struct wpi_node *)txdata->ni; | 1550 struct ieee80211_node *ni = txdata->ni; 1551 struct ieee80211vap *vap = ni->ni_vap; 1552 int retrycnt = 0; |
1571 1572 DPRINTFN(WPI_DEBUG_TX, ("tx done: qid=%d idx=%d retries=%d nkill=%d " 1573 "rate=%x duration=%d status=%x\n", desc->qid, desc->idx, 1574 stat->ntries, stat->nkill, stat->rate, le32toh(stat->duration), 1575 le32toh(stat->status))); 1576 1577 /* 1578 * Update rate control statistics for the node. 1579 * XXX we should not count mgmt frames since they're always sent at 1580 * the lowest available bit-rate. 1581 * XXX frames w/o ACK shouldn't be used either 1582 */ | 1553 1554 DPRINTFN(WPI_DEBUG_TX, ("tx done: qid=%d idx=%d retries=%d nkill=%d " 1555 "rate=%x duration=%d status=%x\n", desc->qid, desc->idx, 1556 stat->ntries, stat->nkill, stat->rate, le32toh(stat->duration), 1557 le32toh(stat->status))); 1558 1559 /* 1560 * Update rate control statistics for the node. 1561 * XXX we should not count mgmt frames since they're always sent at 1562 * the lowest available bit-rate. 1563 * XXX frames w/o ACK shouldn't be used either 1564 */ |
1583 wn->amn.amn_txcnt++; | |
1584 if (stat->ntries > 0) { 1585 DPRINTFN(WPI_DEBUG_TX, ("%d retries\n", stat->ntries)); | 1565 if (stat->ntries > 0) { 1566 DPRINTFN(WPI_DEBUG_TX, ("%d retries\n", stat->ntries)); |
1586 wn->amn.amn_retrycnt++; | 1567 retrycnt = 1; |
1587 } | 1568 } |
1569 ieee80211_ratectl_tx_complete(vap, ni, IEEE80211_RATECTL_TX_SUCCESS, 1570 &retrycnt, NULL); |
|
1588 1589 /* XXX oerrors should only count errors !maxtries */ 1590 if ((le32toh(stat->status) & 0xff) != 1) 1591 ifp->if_oerrors++; 1592 else 1593 ifp->if_opackets++; 1594 1595 bus_dmamap_sync(ring->data_dmat, txdata->map, BUS_DMASYNC_POSTWRITE); --- 318 unchanged lines hidden (view full) --- 1914 else 1915 tx->timeout = htole16(2); 1916 rate = tp->mgmtrate; 1917 } else if (ismcast) { 1918 rate = tp->mcastrate; 1919 } else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) { 1920 rate = tp->ucastrate; 1921 } else { | 1571 1572 /* XXX oerrors should only count errors !maxtries */ 1573 if ((le32toh(stat->status) & 0xff) != 1) 1574 ifp->if_oerrors++; 1575 else 1576 ifp->if_opackets++; 1577 1578 bus_dmamap_sync(ring->data_dmat, txdata->map, BUS_DMASYNC_POSTWRITE); --- 318 unchanged lines hidden (view full) --- 1897 else 1898 tx->timeout = htole16(2); 1899 rate = tp->mgmtrate; 1900 } else if (ismcast) { 1901 rate = tp->mcastrate; 1902 } else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) { 1903 rate = tp->ucastrate; 1904 } else { |
1922 (void) ieee80211_amrr_choose(ni, &WPI_NODE(ni)->amn); | 1905 (void) ieee80211_ratectl_rate(ni, NULL, 0); |
1923 rate = ni->ni_txrate; 1924 } 1925 tx->rate = wpi_plcp_signal(rate); 1926 1927 /* be very persistant at sending frames out */ 1928#if 0 1929 tx->data_ntries = tp->maxretry; 1930#else --- 1276 unchanged lines hidden (view full) --- 3207wpi_stop(struct wpi_softc *sc) 3208{ 3209 WPI_LOCK(sc); 3210 wpi_stop_locked(sc); 3211 WPI_UNLOCK(sc); 3212} 3213 3214static void | 1906 rate = ni->ni_txrate; 1907 } 1908 tx->rate = wpi_plcp_signal(rate); 1909 1910 /* be very persistant at sending frames out */ 1911#if 0 1912 tx->data_ntries = tp->maxretry; 1913#else --- 1276 unchanged lines hidden (view full) --- 3190wpi_stop(struct wpi_softc *sc) 3191{ 3192 WPI_LOCK(sc); 3193 wpi_stop_locked(sc); 3194 WPI_UNLOCK(sc); 3195} 3196 3197static void |
3215wpi_newassoc(struct ieee80211_node *ni, int isnew) 3216{ 3217 struct ieee80211vap *vap = ni->ni_vap; 3218 struct wpi_vap *wvp = WPI_VAP(vap); 3219 3220 ieee80211_amrr_node_init(&wvp->amrr, &WPI_NODE(ni)->amn, ni); 3221} 3222 3223static void | |
3224wpi_calib_timeout(void *arg) 3225{ 3226 struct wpi_softc *sc = arg; 3227 struct ifnet *ifp = sc->sc_ifp; 3228 struct ieee80211com *ic = ifp->if_l2com; 3229 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); 3230 int temp; 3231 --- 469 unchanged lines hidden (view full) --- 3701 return "UNKNOWN CMD"; /* Make the compiler happy */ 3702 } 3703} 3704#endif 3705 3706MODULE_DEPEND(wpi, pci, 1, 1, 1); 3707MODULE_DEPEND(wpi, wlan, 1, 1, 1); 3708MODULE_DEPEND(wpi, firmware, 1, 1, 1); | 3198wpi_calib_timeout(void *arg) 3199{ 3200 struct wpi_softc *sc = arg; 3201 struct ifnet *ifp = sc->sc_ifp; 3202 struct ieee80211com *ic = ifp->if_l2com; 3203 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); 3204 int temp; 3205 --- 469 unchanged lines hidden (view full) --- 3675 return "UNKNOWN CMD"; /* Make the compiler happy */ 3676 } 3677} 3678#endif 3679 3680MODULE_DEPEND(wpi, pci, 1, 1, 1); 3681MODULE_DEPEND(wpi, wlan, 1, 1, 1); 3682MODULE_DEPEND(wpi, firmware, 1, 1, 1); |
3709MODULE_DEPEND(wpi, wlan_amrr, 1, 1, 1); | |