1/* $FreeBSD: head/sys/dev/ral/rt2560.c 175938 2008-02-03 11:47:38Z sephe $ */ |
2 3/*- 4 * Copyright (c) 2005, 2006 5 * Damien Bergamini <damien.bergamini@free.fr> 6 * 7 * Permission to use, copy, modify, and distribute this software for any 8 * purpose with or without fee is hereby granted, provided that the above 9 * copyright notice and this permission notice appear in all copies. 10 * 11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20#include <sys/cdefs.h> |
21__FBSDID("$FreeBSD: head/sys/dev/ral/rt2560.c 175938 2008-02-03 11:47:38Z sephe $"); |
22 23/*- 24 * Ralink Technology RT2560 chipset driver 25 * http://www.ralinktech.com/ 26 */ 27 28#include <sys/param.h> 29#include <sys/sysctl.h> --- 115 unchanged lines hidden (view full) --- 145static void rt2560_update_slot(struct ifnet *); 146static void rt2560_set_basicrates(struct rt2560_softc *); 147static void rt2560_update_led(struct rt2560_softc *, int, int); 148static void rt2560_set_bssid(struct rt2560_softc *, const uint8_t *); 149static void rt2560_set_macaddr(struct rt2560_softc *, uint8_t *); 150static void rt2560_get_macaddr(struct rt2560_softc *, uint8_t *); 151static void rt2560_update_promisc(struct rt2560_softc *); 152static const char *rt2560_get_rf(int); |
153static void rt2560_read_config(struct rt2560_softc *); |
154static int rt2560_bbp_init(struct rt2560_softc *); 155static void rt2560_set_txantenna(struct rt2560_softc *, int); 156static void rt2560_set_rxantenna(struct rt2560_softc *, int); 157static void rt2560_init(void *); 158static int rt2560_raw_xmit(struct ieee80211_node *, struct mbuf *, 159 const struct ieee80211_bpf_params *); 160 161static const struct { --- 44 unchanged lines hidden (view full) --- 206 207 /* retrieve RT2560 rev. no */ 208 sc->asic_rev = RAL_READ(sc, RT2560_CSR0); 209 210 /* retrieve MAC address */ 211 rt2560_get_macaddr(sc, ic->ic_myaddr); 212 213 /* retrieve RF rev. no and various other things from EEPROM */ |
214 rt2560_read_config(sc); |
215 216 device_printf(dev, "MAC/BBP RT2560 (rev 0x%02x), RF %s\n", 217 sc->asic_rev, rt2560_get_rf(sc->rf_rev)); 218 219 /* 220 * Allocate Tx and Rx rings. 221 */ 222 error = rt2560_alloc_tx_ring(sc, &sc->txq, RT2560_TX_RING_COUNT); --- 130 unchanged lines hidden (view full) --- 353int 354rt2560_detach(void *xsc) 355{ 356 struct rt2560_softc *sc = xsc; 357 struct ieee80211com *ic = &sc->sc_ic; 358 struct ifnet *ifp = ic->ic_ifp; 359 360 rt2560_stop(sc); |
361 callout_stop(&sc->rssadapt_ch); 362 363 bpfdetach(ifp); 364 ieee80211_ifdetach(ic); 365 366 rt2560_free_tx_ring(sc, &sc->txq); 367 rt2560_free_tx_ring(sc, &sc->atimq); 368 rt2560_free_tx_ring(sc, &sc->prioq); --- 516 unchanged lines hidden (view full) --- 885 886 /* retrieve last descriptor index processed by cipher engine */ 887 hw = RAL_READ(sc, RT2560_SECCSR1) - sc->txq.physaddr; 888 hw /= RT2560_TX_DESC_SIZE; 889 890 bus_dmamap_sync(sc->txq.desc_dmat, sc->txq.desc_map, 891 BUS_DMASYNC_POSTREAD); 892 |
893 while (sc->txq.next_encrypt != hw) { 894 if (sc->txq.next_encrypt == sc->txq.cur_encrypt) { 895 printf("hw encrypt %d, cur_encrypt %d\n", hw, 896 sc->txq.cur_encrypt); 897 break; 898 } 899 |
900 desc = &sc->txq.desc[sc->txq.next_encrypt]; 901 902 if ((le32toh(desc->flags) & RT2560_TX_BUSY) || 903 (le32toh(desc->flags) & RT2560_TX_CIPHER_BUSY)) 904 break; 905 906 /* for TKIP, swap eiv field to fix a bug in ASIC */ 907 if ((le32toh(desc->flags) & RT2560_TX_CIPHER_MASK) == 908 RT2560_TX_CIPHER_TKIP) 909 desc->eiv = bswap32(desc->eiv); 910 911 /* mark the frame ready for transmission */ |
912 desc->flags |= htole32(RT2560_TX_VALID); 913 desc->flags |= htole32(RT2560_TX_BUSY); |
914 915 DPRINTFN(15, ("encryption done idx=%u\n", 916 sc->txq.next_encrypt)); 917 918 sc->txq.next_encrypt = 919 (sc->txq.next_encrypt + 1) % RT2560_TX_RING_COUNT; 920 } 921 --- 76 unchanged lines hidden (view full) --- 998 999 sc->txq.queued--; 1000 sc->txq.next = (sc->txq.next + 1) % RT2560_TX_RING_COUNT; 1001 } 1002 1003 bus_dmamap_sync(sc->txq.desc_dmat, sc->txq.desc_map, 1004 BUS_DMASYNC_PREWRITE); 1005 |
1006 if (sc->prioq.queued == 0 && sc->txq.queued == 0) 1007 sc->sc_tx_timer = 0; 1008 1009 if (sc->txq.queued < RT2560_TX_RING_COUNT - 1) { 1010 sc->sc_flags &= ~RT2560_F_DATA_OACTIVE; 1011 if ((sc->sc_flags & 1012 (RT2560_F_DATA_OACTIVE | RT2560_F_PRIO_OACTIVE)) == 0) 1013 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; 1014 rt2560_start(ifp); 1015 } |
1016} 1017 1018static void 1019rt2560_prio_intr(struct rt2560_softc *sc) 1020{ 1021 struct ieee80211com *ic = &sc->sc_ic; 1022 struct ifnet *ifp = ic->ic_ifp; 1023 struct rt2560_tx_desc *desc; --- 59 unchanged lines hidden (view full) --- 1083 (RT2560_TX_SUCCESS | RT2560_TX_SUCCESS_RETRY)); 1084 m_freem(m); 1085 ieee80211_free_node(ni); 1086 } 1087 1088 bus_dmamap_sync(sc->prioq.desc_dmat, sc->prioq.desc_map, 1089 BUS_DMASYNC_PREWRITE); 1090 |
1091 if (sc->prioq.queued == 0 && sc->txq.queued == 0) 1092 sc->sc_tx_timer = 0; 1093 1094 if (sc->prioq.queued < RT2560_PRIO_RING_COUNT) { 1095 sc->sc_flags &= ~RT2560_F_PRIO_OACTIVE; 1096 if ((sc->sc_flags & 1097 (RT2560_F_DATA_OACTIVE | RT2560_F_PRIO_OACTIVE)) == 0) 1098 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; 1099 rt2560_start(ifp); 1100 } |
1101} 1102 1103/* 1104 * Some frames were processed by the hardware cipher engine and are ready for 1105 * transmission to the IEEE802.11 layer. 1106 */ 1107static void 1108rt2560_decryption_intr(struct rt2560_softc *sc) --- 99 unchanged lines hidden (view full) --- 1208 tap->wr_chan_freq = htole16(ic->ic_curchan->ic_freq); 1209 tap->wr_chan_flags = htole16(ic->ic_curchan->ic_flags); 1210 tap->wr_antenna = sc->rx_ant; 1211 tap->wr_antsignal = RT2560_RSSI(sc, desc->rssi); 1212 1213 bpf_mtap2(sc->sc_drvbpf, tap, sc->sc_rxtap_len, m); 1214 } 1215 |
1216 sc->sc_flags |= RT2560_F_INPUT_RUNNING; |
1217 RAL_UNLOCK(sc); 1218 wh = mtod(m, struct ieee80211_frame *); 1219 ni = ieee80211_find_rxnode(ic, 1220 (struct ieee80211_frame_min *)wh); 1221 1222 /* send the frame to the 802.11 layer */ 1223 ieee80211_input(ic, m, ni, RT2560_RSSI(sc, desc->rssi), 1224 RT2560_NOISE_FLOOR, 0); 1225 1226 /* give rssi to the rate adatation algorithm */ 1227 rn = (struct rt2560_node *)ni; 1228 ral_rssadapt_input(ic, ni, &rn->rssadapt, 1229 RT2560_RSSI(sc, desc->rssi)); 1230 1231 /* node is no longer needed */ 1232 ieee80211_free_node(ni); 1233 1234 RAL_LOCK(sc); |
1235 sc->sc_flags &= ~RT2560_F_INPUT_RUNNING; |
1236skip: desc->flags = htole32(RT2560_RX_BUSY); 1237 1238 DPRINTFN(15, ("decryption done idx=%u\n", sc->rxq.cur_decrypt)); 1239 1240 sc->rxq.cur_decrypt = 1241 (sc->rxq.cur_decrypt + 1) % RT2560_RX_RING_COUNT; 1242 } 1243 --- 141 unchanged lines hidden (view full) --- 1385 rt2560_tx_intr(sc); 1386 1387 if (r & RT2560_PRIO_DONE) 1388 rt2560_prio_intr(sc); 1389 1390 if (r & RT2560_DECRYPTION_DONE) 1391 rt2560_decryption_intr(sc); 1392 |
1393 if (r & RT2560_RX_DONE) { |
1394 rt2560_rx_intr(sc); |
1395 rt2560_encryption_intr(sc); 1396 } |
1397 1398 /* re-enable interrupts */ 1399 RAL_WRITE(sc, RT2560_CSR8, RT2560_INTR_MASK); 1400 1401 RAL_UNLOCK(sc); 1402} 1403 1404/* quickly determine if a given rate is CCK or OFDM */ --- 127 unchanged lines hidden (view full) --- 1532 uint32_t flags, int len, int rate, int encrypt, bus_addr_t physaddr) 1533{ 1534 struct ieee80211com *ic = &sc->sc_ic; 1535 uint16_t plcp_length; 1536 int remainder; 1537 1538 desc->flags = htole32(flags); 1539 desc->flags |= htole32(len << 16); |
1540 1541 desc->physaddr = htole32(physaddr); 1542 desc->wme = htole16( 1543 RT2560_AIFSN(2) | 1544 RT2560_LOGCWMIN(3) | 1545 RT2560_LOGCWMAX(8)); 1546 1547 /* setup PLCP fields */ --- 15 unchanged lines hidden (view full) --- 1563 desc->plcp_service |= RT2560_PLCP_LENGEXT; 1564 } 1565 desc->plcp_length_hi = plcp_length >> 8; 1566 desc->plcp_length_lo = plcp_length & 0xff; 1567 1568 if (rate != 2 && (ic->ic_flags & IEEE80211_F_SHPREAMBLE)) 1569 desc->plcp_signal |= 0x08; 1570 } |
1571 1572 if (!encrypt) 1573 desc->flags |= htole32(RT2560_TX_VALID); 1574 desc->flags |= encrypt ? htole32(RT2560_TX_CIPHER_BUSY) 1575 : htole32(RT2560_TX_BUSY); |
1576} 1577 1578static int 1579rt2560_tx_bcn(struct rt2560_softc *sc, struct mbuf *m0, 1580 struct ieee80211_node *ni) 1581{ 1582 struct ieee80211com *ic = &sc->sc_ic; 1583 struct rt2560_tx_desc *desc; --- 438 unchanged lines hidden (view full) --- 2022 return; 2023 } 2024 2025 for (;;) { 2026 IF_POLL(&ic->ic_mgtq, m0); 2027 if (m0 != NULL) { 2028 if (sc->prioq.queued >= RT2560_PRIO_RING_COUNT) { 2029 ifp->if_drv_flags |= IFF_DRV_OACTIVE; |
2030 sc->sc_flags |= RT2560_F_PRIO_OACTIVE; |
2031 break; 2032 } 2033 IF_DEQUEUE(&ic->ic_mgtq, m0); 2034 2035 ni = (struct ieee80211_node *)m0->m_pkthdr.rcvif; 2036 m0->m_pkthdr.rcvif = NULL; 2037 2038 if (bpf_peers_present(ic->ic_rawbpf)) --- 7 unchanged lines hidden (view full) --- 2046 if (ic->ic_state != IEEE80211_S_RUN) 2047 break; 2048 IFQ_DRV_DEQUEUE(&ifp->if_snd, m0); 2049 if (m0 == NULL) 2050 break; 2051 if (sc->txq.queued >= RT2560_TX_RING_COUNT - 1) { 2052 IFQ_DRV_PREPEND(&ifp->if_snd, m0); 2053 ifp->if_drv_flags |= IFF_DRV_OACTIVE; |
2054 sc->sc_flags |= RT2560_F_DATA_OACTIVE; |
2055 break; 2056 } 2057 /* 2058 * Cancel any background scan. 2059 */ 2060 if (ic->ic_flags & IEEE80211_F_SCAN) 2061 ieee80211_cancel_scan(ic); 2062 --- 21 unchanged lines hidden (view full) --- 2084 * The packet we just queued will automatically 2085 * get sent when we drop out of power save. 2086 * XXX locking 2087 */ 2088 if (ic->ic_flags & IEEE80211_F_SCAN) 2089 ieee80211_cancel_scan(ic); 2090 ieee80211_free_node(ni); 2091 continue; |
2092 } 2093 2094 BPF_MTAP(ifp, m0); 2095 2096 m0 = ieee80211_encap(ic, m0, ni); 2097 if (m0 == NULL) { 2098 ieee80211_free_node(ni); 2099 continue; --- 6 unchanged lines hidden (view full) --- 2106 ieee80211_free_node(ni); 2107 ifp->if_oerrors++; 2108 break; 2109 } 2110 } 2111 2112 sc->sc_tx_timer = 5; 2113 ic->ic_lastdata = ticks; |
2114 } 2115 2116 RAL_UNLOCK(sc); 2117} 2118 2119static void 2120rt2560_watchdog(void *arg) 2121{ 2122 struct rt2560_softc *sc = arg; |
2123 struct ifnet *ifp = sc->sc_ifp; |
2124 |
2125 if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) 2126 return; 2127 2128 rt2560_encryption_intr(sc); 2129 rt2560_tx_intr(sc); 2130 |
2131 if (sc->sc_tx_timer > 0) { 2132 if (--sc->sc_tx_timer == 0) { 2133 device_printf(sc->sc_dev, "device timeout\n"); 2134 rt2560_init(sc); |
2135 ifp->if_oerrors++; 2136 /* watchdog timeout is set in rt2560_init() */ |
2137 return; 2138 } |
2139 } |
2140 callout_reset(&sc->watchdog_ch, hz, rt2560_watchdog, sc); |
2141} 2142 2143/* 2144 * This function allows for fast channel switching in monitor mode (used by 2145 * net-mgmt/kismet). In IBSS mode, we must explicitly reset the interface to 2146 * generate a new beacon frame. 2147 */ 2148static int --- 74 unchanged lines hidden (view full) --- 2223} 2224 2225static uint8_t 2226rt2560_bbp_read(struct rt2560_softc *sc, uint8_t reg) 2227{ 2228 uint32_t val; 2229 int ntries; 2230 |
2231 for (ntries = 0; ntries < 100; ntries++) { 2232 if (!(RAL_READ(sc, RT2560_BBPCSR) & RT2560_BBP_BUSY)) 2233 break; 2234 DELAY(1); 2235 } 2236 if (ntries == 100) { 2237 device_printf(sc->sc_dev, "could not read from BBP\n"); 2238 return 0; 2239 } 2240 |
2241 val = RT2560_BBP_BUSY | reg << 8; 2242 RAL_WRITE(sc, RT2560_BBPCSR, val); 2243 2244 for (ntries = 0; ntries < 100; ntries++) { 2245 val = RAL_READ(sc, RT2560_BBPCSR); 2246 if (!(val & RT2560_BBP_BUSY)) 2247 return val & 0xff; 2248 DELAY(1); --- 229 unchanged lines hidden (view full) --- 2478rt2560_update_slot(struct ifnet *ifp) 2479{ 2480 struct rt2560_softc *sc = ifp->if_softc; 2481 struct ieee80211com *ic = &sc->sc_ic; 2482 uint8_t slottime; 2483 uint16_t tx_sifs, tx_pifs, tx_difs, eifs; 2484 uint32_t tmp; 2485 |
2486#ifndef FORCE_SLOTTIME |
2487 slottime = (ic->ic_flags & IEEE80211_F_SHSLOT) ? 9 : 20; |
2488#else 2489 /* 2490 * Setting slot time according to "short slot time" capability 2491 * in beacon/probe_resp seems to cause problem to acknowledge 2492 * certain AP's data frames transimitted at CCK/DS rates: the 2493 * problematic AP keeps retransmitting data frames, probably 2494 * because MAC level acks are not received by hardware. 2495 * So we cheat a little bit here by claiming we are capable of 2496 * "short slot time" but setting hardware slot time to the normal 2497 * slot time. ral(4) does not seem to have trouble to receive 2498 * frames transmitted using short slot time even if hardware 2499 * slot time is set to normal slot time. If we didn't use this 2500 * trick, we would have to claim that short slot time is not 2501 * supported; this would give relative poor RX performance 2502 * (-1Mb~-2Mb lower) and the _whole_ BSS would stop using short 2503 * slot time. 2504 */ 2505 slottime = 20; 2506#endif |
2507 2508 /* update the MAC slot boundaries */ 2509 tx_sifs = RAL_SIFS - RT2560_TXRX_TURNAROUND; 2510 tx_pifs = tx_sifs + slottime; 2511 tx_difs = tx_sifs + 2 * slottime; 2512 eifs = (ic->ic_curmode == IEEE80211_MODE_11B) ? 364 : 60; 2513 2514 tmp = RAL_READ(sc, RT2560_CSR11); --- 110 unchanged lines hidden (view full) --- 2625 case RT2560_RF_2525E: return "RT2525e"; 2626 case RT2560_RF_2526: return "RT2526"; 2627 case RT2560_RF_5222: return "RT5222"; 2628 default: return "unknown"; 2629 } 2630} 2631 2632static void |
2633rt2560_read_config(struct rt2560_softc *sc) |
2634{ 2635 uint16_t val; 2636 int i; 2637 2638 val = rt2560_eeprom_read(sc, RT2560_EEPROM_CONFIG0); 2639 sc->rf_rev = (val >> 11) & 0x7; 2640 sc->hw_radio = (val >> 10) & 0x1; 2641 sc->led_mode = (val >> 6) & 0x7; 2642 sc->rx_ant = (val >> 4) & 0x3; 2643 sc->tx_ant = (val >> 2) & 0x3; 2644 sc->nb_ant = val & 0x3; 2645 2646 /* read default values for BBP registers */ 2647 for (i = 0; i < 16; i++) { 2648 val = rt2560_eeprom_read(sc, RT2560_EEPROM_BBP_BASE + i); |
2649 if (val == 0 || val == 0xffff) 2650 continue; 2651 |
2652 sc->bbp_prom[i].reg = val >> 8; 2653 sc->bbp_prom[i].val = val & 0xff; 2654 } 2655 2656 /* read Tx power for all b/g channels */ 2657 for (i = 0; i < 14 / 2; i++) { 2658 val = rt2560_eeprom_read(sc, RT2560_EEPROM_TXPOWER + i); |
2659 sc->txpow[i * 2] = val & 0xff; 2660 sc->txpow[i * 2 + 1] = val >> 8; |
2661 } |
2662 for (i = 0; i < 14; ++i) { 2663 if (sc->txpow[i] > 31) 2664 sc->txpow[i] = 24; 2665 } |
2666 2667 val = rt2560_eeprom_read(sc, RT2560_EEPROM_CALIBRATE); 2668 if ((val & 0xff) == 0xff) 2669 sc->rssi_corr = RT2560_DEFAULT_RSSI_CORR; 2670 else 2671 sc->rssi_corr = val & 0xff; 2672 DPRINTF(("rssi correction %d, calibrate 0x%02x\n", 2673 sc->rssi_corr, val)); --- 39 unchanged lines hidden (view full) --- 2713 return EIO; 2714 } 2715 2716 /* initialize BBP registers to default values */ 2717 for (i = 0; i < N(rt2560_def_bbp); i++) { 2718 rt2560_bbp_write(sc, rt2560_def_bbp[i].reg, 2719 rt2560_def_bbp[i].val); 2720 } |
2721 |
2722 /* initialize BBP registers to values stored in EEPROM */ 2723 for (i = 0; i < 16; i++) { |
2724 if (sc->bbp_prom[i].reg == 0 && sc->bbp_prom[i].val == 0) 2725 break; |
2726 rt2560_bbp_write(sc, sc->bbp_prom[i].reg, sc->bbp_prom[i].val); 2727 } |
2728 rt2560_bbp_write(sc, 17, 0x48); /* XXX restore bbp17 */ |
2729 2730 return 0; 2731#undef N 2732} 2733 2734static void 2735rt2560_set_txantenna(struct rt2560_softc *sc, int antenna) 2736{ --- 80 unchanged lines hidden (view full) --- 2817 RAL_WRITE(sc, rt2560_def_mac[i].reg, rt2560_def_mac[i].val); 2818 2819 IEEE80211_ADDR_COPY(ic->ic_myaddr, IF_LLADDR(ifp)); 2820 rt2560_set_macaddr(sc, ic->ic_myaddr); 2821 2822 /* set basic rate set (will be updated later) */ 2823 RAL_WRITE(sc, RT2560_ARSP_PLCP_1, 0x153); 2824 |
2825 rt2560_update_slot(ifp); 2826 rt2560_update_plcp(sc); 2827 rt2560_update_led(sc, 0, 0); 2828 2829 RAL_WRITE(sc, RT2560_CSR1, RT2560_RESET_ASIC); 2830 RAL_WRITE(sc, RT2560_CSR1, RT2560_HOST_READY); 2831 2832 if (rt2560_bbp_init(sc) != 0) { 2833 rt2560_stop(sc); 2834 RAL_UNLOCK(sc); 2835 return; 2836 } 2837 |
2838 rt2560_set_txantenna(sc, sc->tx_ant); 2839 rt2560_set_rxantenna(sc, sc->rx_ant); 2840 |
2841 /* set default BSS channel */ 2842 rt2560_set_chan(sc, ic->ic_curchan); 2843 2844 /* kick Rx */ 2845 tmp = RT2560_DROP_PHY_ERROR | RT2560_DROP_CRC_ERROR; 2846 if (ic->ic_opmode != IEEE80211_M_MONITOR) { 2847 tmp |= RT2560_DROP_CTL | RT2560_DROP_VERSION_ERROR; 2848 if (ic->ic_opmode != IEEE80211_M_HOSTAP) --- 11 unchanged lines hidden (view full) --- 2860 RAL_WRITE(sc, RT2560_CSR7, 0xffffffff); 2861 2862 /* enable interrupts */ 2863 RAL_WRITE(sc, RT2560_CSR8, RT2560_INTR_MASK); 2864 2865 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; 2866 ifp->if_drv_flags |= IFF_DRV_RUNNING; 2867 |
2868 callout_reset(&sc->watchdog_ch, hz, rt2560_watchdog, sc); 2869 |
2870 if (ic->ic_opmode != IEEE80211_M_MONITOR) { 2871 if (ic->ic_roaming != IEEE80211_ROAMING_MANUAL) 2872 ieee80211_new_state(ic, IEEE80211_S_SCAN, -1); 2873 } else 2874 ieee80211_new_state(ic, IEEE80211_S_RUN, -1); 2875 2876 RAL_UNLOCK(sc); 2877#undef N 2878} 2879 2880void 2881rt2560_stop(void *arg) 2882{ 2883 struct rt2560_softc *sc = arg; 2884 struct ieee80211com *ic = &sc->sc_ic; 2885 struct ifnet *ifp = ic->ic_ifp; 2886 volatile int *flags = &sc->sc_flags; 2887 |
2888 while (*flags & RT2560_F_INPUT_RUNNING) { |
2889 tsleep(sc, 0, "ralrunning", hz/10); 2890 } 2891 2892 RAL_LOCK(sc); |
2893 2894 callout_stop(&sc->watchdog_ch); 2895 |
2896 if (ifp->if_drv_flags & IFF_DRV_RUNNING) { 2897 ieee80211_new_state(ic, IEEE80211_S_INIT, -1); |
2898 ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); 2899 2900 /* abort Tx */ 2901 RAL_WRITE(sc, RT2560_TXCSR0, RT2560_ABORT_TX); 2902 2903 /* disable Rx */ 2904 RAL_WRITE(sc, RT2560_RXCSR0, RT2560_DISABLE_RX); 2905 --- 6 unchanged lines hidden (view full) --- 2912 2913 /* reset Tx and Rx rings */ 2914 rt2560_reset_tx_ring(sc, &sc->txq); 2915 rt2560_reset_tx_ring(sc, &sc->atimq); 2916 rt2560_reset_tx_ring(sc, &sc->prioq); 2917 rt2560_reset_tx_ring(sc, &sc->bcnq); 2918 rt2560_reset_rx_ring(sc, &sc->rxq); 2919 } |
2920 sc->sc_tx_timer = 0; 2921 sc->sc_flags &= ~(RT2560_F_PRIO_OACTIVE | RT2560_F_DATA_OACTIVE); 2922 |
2923 RAL_UNLOCK(sc); 2924} 2925 2926static int 2927rt2560_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, 2928 const struct ieee80211_bpf_params *params) 2929{ 2930 struct ieee80211com *ic = ni->ni_ic; --- 33 unchanged lines hidden (view full) --- 2964 /* 2965 * Caller supplied explicit parameters to use in 2966 * sending the frame. 2967 */ 2968 if (rt2560_tx_raw(sc, m, ni, params)) 2969 goto bad; 2970 } 2971 sc->sc_tx_timer = 5; |
2972 2973 RAL_UNLOCK(sc); 2974 2975 return 0; 2976bad: 2977 ifp->if_oerrors++; 2978 ieee80211_free_node(ni); 2979 RAL_UNLOCK(sc); 2980 return EIO; /* XXX */ 2981} |