Deleted Added
full compact
rt2560.c (173386) rt2560.c (175938)
1/* $FreeBSD: head/sys/dev/ral/rt2560.c 173386 2007-11-06 07:30:12Z kevlo $ */
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>
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 173386 2007-11-06 07:30:12Z kevlo $");
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);
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_eeprom(struct rt2560_softc *);
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 */
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_eeprom(sc);
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);
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->watchdog_ch);
362 callout_stop(&sc->rssadapt_ch);
363
364 bpfdetach(ifp);
365 ieee80211_ifdetach(ic);
366
367 rt2560_free_tx_ring(sc, &sc->txq);
368 rt2560_free_tx_ring(sc, &sc->atimq);
369 rt2560_free_tx_ring(sc, &sc->prioq);

--- 516 unchanged lines hidden (view full) ---

886
887 /* retrieve last descriptor index processed by cipher engine */
888 hw = RAL_READ(sc, RT2560_SECCSR1) - sc->txq.physaddr;
889 hw /= RT2560_TX_DESC_SIZE;
890
891 bus_dmamap_sync(sc->txq.desc_dmat, sc->txq.desc_map,
892 BUS_DMASYNC_POSTREAD);
893
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
894 for (; sc->txq.next_encrypt != hw;) {
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
895 desc = &sc->txq.desc[sc->txq.next_encrypt];
896
897 if ((le32toh(desc->flags) & RT2560_TX_BUSY) ||
898 (le32toh(desc->flags) & RT2560_TX_CIPHER_BUSY))
899 break;
900
901 /* for TKIP, swap eiv field to fix a bug in ASIC */
902 if ((le32toh(desc->flags) & RT2560_TX_CIPHER_MASK) ==
903 RT2560_TX_CIPHER_TKIP)
904 desc->eiv = bswap32(desc->eiv);
905
906 /* mark the frame ready for transmission */
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 */
907 desc->flags |= htole32(RT2560_TX_BUSY | RT2560_TX_VALID);
912 desc->flags |= htole32(RT2560_TX_VALID);
913 desc->flags |= htole32(RT2560_TX_BUSY);
908
909 DPRINTFN(15, ("encryption done idx=%u\n",
910 sc->txq.next_encrypt));
911
912 sc->txq.next_encrypt =
913 (sc->txq.next_encrypt + 1) % RT2560_TX_RING_COUNT;
914 }
915

--- 76 unchanged lines hidden (view full) ---

992
993 sc->txq.queued--;
994 sc->txq.next = (sc->txq.next + 1) % RT2560_TX_RING_COUNT;
995 }
996
997 bus_dmamap_sync(sc->txq.desc_dmat, sc->txq.desc_map,
998 BUS_DMASYNC_PREWRITE);
999
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
1000 sc->sc_tx_timer = 0;
1001 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
1002 rt2560_start(ifp);
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 }
1003}
1004
1005static void
1006rt2560_prio_intr(struct rt2560_softc *sc)
1007{
1008 struct ieee80211com *ic = &sc->sc_ic;
1009 struct ifnet *ifp = ic->ic_ifp;
1010 struct rt2560_tx_desc *desc;

--- 59 unchanged lines hidden (view full) ---

1070 (RT2560_TX_SUCCESS | RT2560_TX_SUCCESS_RETRY));
1071 m_freem(m);
1072 ieee80211_free_node(ni);
1073 }
1074
1075 bus_dmamap_sync(sc->prioq.desc_dmat, sc->prioq.desc_map,
1076 BUS_DMASYNC_PREWRITE);
1077
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
1078 sc->sc_tx_timer = 0;
1079 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
1080 rt2560_start(ifp);
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 }
1081}
1082
1083/*
1084 * Some frames were processed by the hardware cipher engine and are ready for
1085 * transmission to the IEEE802.11 layer.
1086 */
1087static void
1088rt2560_decryption_intr(struct rt2560_softc *sc)

--- 99 unchanged lines hidden (view full) ---

1188 tap->wr_chan_freq = htole16(ic->ic_curchan->ic_freq);
1189 tap->wr_chan_flags = htole16(ic->ic_curchan->ic_flags);
1190 tap->wr_antenna = sc->rx_ant;
1191 tap->wr_antsignal = RT2560_RSSI(sc, desc->rssi);
1192
1193 bpf_mtap2(sc->sc_drvbpf, tap, sc->sc_rxtap_len, m);
1194 }
1195
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
1196 sc->sc_flags |= RAL_INPUT_RUNNING;
1216 sc->sc_flags |= RT2560_F_INPUT_RUNNING;
1197 RAL_UNLOCK(sc);
1198 wh = mtod(m, struct ieee80211_frame *);
1199 ni = ieee80211_find_rxnode(ic,
1200 (struct ieee80211_frame_min *)wh);
1201
1202 /* send the frame to the 802.11 layer */
1203 ieee80211_input(ic, m, ni, RT2560_RSSI(sc, desc->rssi),
1204 RT2560_NOISE_FLOOR, 0);
1205
1206 /* give rssi to the rate adatation algorithm */
1207 rn = (struct rt2560_node *)ni;
1208 ral_rssadapt_input(ic, ni, &rn->rssadapt,
1209 RT2560_RSSI(sc, desc->rssi));
1210
1211 /* node is no longer needed */
1212 ieee80211_free_node(ni);
1213
1214 RAL_LOCK(sc);
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);
1215 sc->sc_flags &= ~RAL_INPUT_RUNNING;
1235 sc->sc_flags &= ~RT2560_F_INPUT_RUNNING;
1216skip: desc->flags = htole32(RT2560_RX_BUSY);
1217
1218 DPRINTFN(15, ("decryption done idx=%u\n", sc->rxq.cur_decrypt));
1219
1220 sc->rxq.cur_decrypt =
1221 (sc->rxq.cur_decrypt + 1) % RT2560_RX_RING_COUNT;
1222 }
1223

--- 141 unchanged lines hidden (view full) ---

1365 rt2560_tx_intr(sc);
1366
1367 if (r & RT2560_PRIO_DONE)
1368 rt2560_prio_intr(sc);
1369
1370 if (r & RT2560_DECRYPTION_DONE)
1371 rt2560_decryption_intr(sc);
1372
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
1373 if (r & RT2560_RX_DONE)
1393 if (r & RT2560_RX_DONE) {
1374 rt2560_rx_intr(sc);
1394 rt2560_rx_intr(sc);
1395 rt2560_encryption_intr(sc);
1396 }
1375
1376 /* re-enable interrupts */
1377 RAL_WRITE(sc, RT2560_CSR8, RT2560_INTR_MASK);
1378
1379 RAL_UNLOCK(sc);
1380}
1381
1382/* quickly determine if a given rate is CCK or OFDM */

--- 127 unchanged lines hidden (view full) ---

1510 uint32_t flags, int len, int rate, int encrypt, bus_addr_t physaddr)
1511{
1512 struct ieee80211com *ic = &sc->sc_ic;
1513 uint16_t plcp_length;
1514 int remainder;
1515
1516 desc->flags = htole32(flags);
1517 desc->flags |= htole32(len << 16);
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);
1518 desc->flags |= encrypt ? htole32(RT2560_TX_CIPHER_BUSY) :
1519 htole32(RT2560_TX_BUSY | RT2560_TX_VALID);
1520
1521 desc->physaddr = htole32(physaddr);
1522 desc->wme = htole16(
1523 RT2560_AIFSN(2) |
1524 RT2560_LOGCWMIN(3) |
1525 RT2560_LOGCWMAX(8));
1526
1527 /* setup PLCP fields */

--- 15 unchanged lines hidden (view full) ---

1543 desc->plcp_service |= RT2560_PLCP_LENGEXT;
1544 }
1545 desc->plcp_length_hi = plcp_length >> 8;
1546 desc->plcp_length_lo = plcp_length & 0xff;
1547
1548 if (rate != 2 && (ic->ic_flags & IEEE80211_F_SHPREAMBLE))
1549 desc->plcp_signal |= 0x08;
1550 }
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);
1551}
1552
1553static int
1554rt2560_tx_bcn(struct rt2560_softc *sc, struct mbuf *m0,
1555 struct ieee80211_node *ni)
1556{
1557 struct ieee80211com *ic = &sc->sc_ic;
1558 struct rt2560_tx_desc *desc;

--- 438 unchanged lines hidden (view full) ---

1997 return;
1998 }
1999
2000 for (;;) {
2001 IF_POLL(&ic->ic_mgtq, m0);
2002 if (m0 != NULL) {
2003 if (sc->prioq.queued >= RT2560_PRIO_RING_COUNT) {
2004 ifp->if_drv_flags |= IFF_DRV_OACTIVE;
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;
2005 break;
2006 }
2007 IF_DEQUEUE(&ic->ic_mgtq, m0);
2008
2009 ni = (struct ieee80211_node *)m0->m_pkthdr.rcvif;
2010 m0->m_pkthdr.rcvif = NULL;
2011
2012 if (bpf_peers_present(ic->ic_rawbpf))

--- 7 unchanged lines hidden (view full) ---

2020 if (ic->ic_state != IEEE80211_S_RUN)
2021 break;
2022 IFQ_DRV_DEQUEUE(&ifp->if_snd, m0);
2023 if (m0 == NULL)
2024 break;
2025 if (sc->txq.queued >= RT2560_TX_RING_COUNT - 1) {
2026 IFQ_DRV_PREPEND(&ifp->if_snd, m0);
2027 ifp->if_drv_flags |= IFF_DRV_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;
2028 break;
2029 }
2030 /*
2031 * Cancel any background scan.
2032 */
2033 if (ic->ic_flags & IEEE80211_F_SCAN)
2034 ieee80211_cancel_scan(ic);
2035

--- 21 unchanged lines hidden (view full) ---

2057 * The packet we just queued will automatically
2058 * get sent when we drop out of power save.
2059 * XXX locking
2060 */
2061 if (ic->ic_flags & IEEE80211_F_SCAN)
2062 ieee80211_cancel_scan(ic);
2063 ieee80211_free_node(ni);
2064 continue;
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;
2065
2066 }
2067
2068 BPF_MTAP(ifp, m0);
2069
2070 m0 = ieee80211_encap(ic, m0, ni);
2071 if (m0 == NULL) {
2072 ieee80211_free_node(ni);
2073 continue;

--- 6 unchanged lines hidden (view full) ---

2080 ieee80211_free_node(ni);
2081 ifp->if_oerrors++;
2082 break;
2083 }
2084 }
2085
2086 sc->sc_tx_timer = 5;
2087 ic->ic_lastdata = ticks;
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;
2088 callout_reset(&sc->watchdog_ch, hz, rt2560_watchdog, sc);
2089 }
2090
2091 RAL_UNLOCK(sc);
2092}
2093
2094static void
2095rt2560_watchdog(void *arg)
2096{
2097 struct rt2560_softc *sc = arg;
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;
2098
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
2099 if (sc->sc_tx_timer > 0) {
2100 if (--sc->sc_tx_timer == 0) {
2101 device_printf(sc->sc_dev, "device timeout\n");
2102 rt2560_init(sc);
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);
2103 sc->sc_ifp->if_oerrors++;
2135 ifp->if_oerrors++;
2136 /* watchdog timeout is set in rt2560_init() */
2104 return;
2105 }
2137 return;
2138 }
2106 callout_reset(&sc->watchdog_ch, hz, rt2560_watchdog, sc);
2107 }
2139 }
2140 callout_reset(&sc->watchdog_ch, hz, rt2560_watchdog, sc);
2108}
2109
2110/*
2111 * This function allows for fast channel switching in monitor mode (used by
2112 * net-mgmt/kismet). In IBSS mode, we must explicitly reset the interface to
2113 * generate a new beacon frame.
2114 */
2115static int

--- 74 unchanged lines hidden (view full) ---

2190}
2191
2192static uint8_t
2193rt2560_bbp_read(struct rt2560_softc *sc, uint8_t reg)
2194{
2195 uint32_t val;
2196 int ntries;
2197
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
2198 val = RT2560_BBP_BUSY | reg << 8;
2199 RAL_WRITE(sc, RT2560_BBPCSR, val);
2200
2201 for (ntries = 0; ntries < 100; ntries++) {
2202 val = RAL_READ(sc, RT2560_BBPCSR);
2203 if (!(val & RT2560_BBP_BUSY))
2204 return val & 0xff;
2205 DELAY(1);

--- 229 unchanged lines hidden (view full) ---

2435rt2560_update_slot(struct ifnet *ifp)
2436{
2437 struct rt2560_softc *sc = ifp->if_softc;
2438 struct ieee80211com *ic = &sc->sc_ic;
2439 uint8_t slottime;
2440 uint16_t tx_sifs, tx_pifs, tx_difs, eifs;
2441 uint32_t tmp;
2442
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
2443 slottime = (ic->ic_flags & IEEE80211_F_SHSLOT) ? 9 : 20;
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
2444
2445 /* update the MAC slot boundaries */
2446 tx_sifs = RAL_SIFS - RT2560_TXRX_TURNAROUND;
2447 tx_pifs = tx_sifs + slottime;
2448 tx_difs = tx_sifs + 2 * slottime;
2449 eifs = (ic->ic_curmode == IEEE80211_MODE_11B) ? 364 : 60;
2450
2451 tmp = RAL_READ(sc, RT2560_CSR11);

--- 110 unchanged lines hidden (view full) ---

2562 case RT2560_RF_2525E: return "RT2525e";
2563 case RT2560_RF_2526: return "RT2526";
2564 case RT2560_RF_5222: return "RT5222";
2565 default: return "unknown";
2566 }
2567}
2568
2569static void
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
2570rt2560_read_eeprom(struct rt2560_softc *sc)
2633rt2560_read_config(struct rt2560_softc *sc)
2571{
2572 uint16_t val;
2573 int i;
2574
2575 val = rt2560_eeprom_read(sc, RT2560_EEPROM_CONFIG0);
2576 sc->rf_rev = (val >> 11) & 0x7;
2577 sc->hw_radio = (val >> 10) & 0x1;
2578 sc->led_mode = (val >> 6) & 0x7;
2579 sc->rx_ant = (val >> 4) & 0x3;
2580 sc->tx_ant = (val >> 2) & 0x3;
2581 sc->nb_ant = val & 0x3;
2582
2583 /* read default values for BBP registers */
2584 for (i = 0; i < 16; i++) {
2585 val = rt2560_eeprom_read(sc, RT2560_EEPROM_BBP_BASE + i);
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
2586 sc->bbp_prom[i].reg = val >> 8;
2587 sc->bbp_prom[i].val = val & 0xff;
2588 }
2589
2590 /* read Tx power for all b/g channels */
2591 for (i = 0; i < 14 / 2; i++) {
2592 val = rt2560_eeprom_read(sc, RT2560_EEPROM_TXPOWER + i);
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);
2593 sc->txpow[i * 2] = val >> 8;
2594 sc->txpow[i * 2 + 1] = val & 0xff;
2659 sc->txpow[i * 2] = val & 0xff;
2660 sc->txpow[i * 2 + 1] = val >> 8;
2595 }
2661 }
2662 for (i = 0; i < 14; ++i) {
2663 if (sc->txpow[i] > 31)
2664 sc->txpow[i] = 24;
2665 }
2596
2597 val = rt2560_eeprom_read(sc, RT2560_EEPROM_CALIBRATE);
2598 if ((val & 0xff) == 0xff)
2599 sc->rssi_corr = RT2560_DEFAULT_RSSI_CORR;
2600 else
2601 sc->rssi_corr = val & 0xff;
2602 DPRINTF(("rssi correction %d, calibrate 0x%02x\n",
2603 sc->rssi_corr, val));

--- 39 unchanged lines hidden (view full) ---

2643 return EIO;
2644 }
2645
2646 /* initialize BBP registers to default values */
2647 for (i = 0; i < N(rt2560_def_bbp); i++) {
2648 rt2560_bbp_write(sc, rt2560_def_bbp[i].reg,
2649 rt2560_def_bbp[i].val);
2650 }
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 }
2651#if 0
2721
2652 /* initialize BBP registers to values stored in EEPROM */
2653 for (i = 0; i < 16; i++) {
2722 /* initialize BBP registers to values stored in EEPROM */
2723 for (i = 0; i < 16; i++) {
2654 if (sc->bbp_prom[i].reg == 0xff)
2655 continue;
2724 if (sc->bbp_prom[i].reg == 0 && sc->bbp_prom[i].val == 0)
2725 break;
2656 rt2560_bbp_write(sc, sc->bbp_prom[i].reg, sc->bbp_prom[i].val);
2657 }
2726 rt2560_bbp_write(sc, sc->bbp_prom[i].reg, sc->bbp_prom[i].val);
2727 }
2658#endif
2728 rt2560_bbp_write(sc, 17, 0x48); /* XXX restore bbp17 */
2659
2660 return 0;
2661#undef N
2662}
2663
2664static void
2665rt2560_set_txantenna(struct rt2560_softc *sc, int antenna)
2666{

--- 80 unchanged lines hidden (view full) ---

2747 RAL_WRITE(sc, rt2560_def_mac[i].reg, rt2560_def_mac[i].val);
2748
2749 IEEE80211_ADDR_COPY(ic->ic_myaddr, IF_LLADDR(ifp));
2750 rt2560_set_macaddr(sc, ic->ic_myaddr);
2751
2752 /* set basic rate set (will be updated later) */
2753 RAL_WRITE(sc, RT2560_ARSP_PLCP_1, 0x153);
2754
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
2755 rt2560_set_txantenna(sc, sc->tx_ant);
2756 rt2560_set_rxantenna(sc, sc->rx_ant);
2757 rt2560_update_slot(ifp);
2758 rt2560_update_plcp(sc);
2759 rt2560_update_led(sc, 0, 0);
2760
2761 RAL_WRITE(sc, RT2560_CSR1, RT2560_RESET_ASIC);
2762 RAL_WRITE(sc, RT2560_CSR1, RT2560_HOST_READY);
2763
2764 if (rt2560_bbp_init(sc) != 0) {
2765 rt2560_stop(sc);
2766 RAL_UNLOCK(sc);
2767 return;
2768 }
2769
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
2770 /* set default BSS channel */
2771 rt2560_set_chan(sc, ic->ic_curchan);
2772
2773 /* kick Rx */
2774 tmp = RT2560_DROP_PHY_ERROR | RT2560_DROP_CRC_ERROR;
2775 if (ic->ic_opmode != IEEE80211_M_MONITOR) {
2776 tmp |= RT2560_DROP_CTL | RT2560_DROP_VERSION_ERROR;
2777 if (ic->ic_opmode != IEEE80211_M_HOSTAP)

--- 11 unchanged lines hidden (view full) ---

2789 RAL_WRITE(sc, RT2560_CSR7, 0xffffffff);
2790
2791 /* enable interrupts */
2792 RAL_WRITE(sc, RT2560_CSR8, RT2560_INTR_MASK);
2793
2794 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
2795 ifp->if_drv_flags |= IFF_DRV_RUNNING;
2796
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
2797 if (ic->ic_opmode != IEEE80211_M_MONITOR) {
2798 if (ic->ic_roaming != IEEE80211_ROAMING_MANUAL)
2799 ieee80211_new_state(ic, IEEE80211_S_SCAN, -1);
2800 } else
2801 ieee80211_new_state(ic, IEEE80211_S_RUN, -1);
2802
2803 RAL_UNLOCK(sc);
2804#undef N
2805}
2806
2807void
2808rt2560_stop(void *arg)
2809{
2810 struct rt2560_softc *sc = arg;
2811 struct ieee80211com *ic = &sc->sc_ic;
2812 struct ifnet *ifp = ic->ic_ifp;
2813 volatile int *flags = &sc->sc_flags;
2814
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
2815 while (*flags & RAL_INPUT_RUNNING) {
2888 while (*flags & RT2560_F_INPUT_RUNNING) {
2816 tsleep(sc, 0, "ralrunning", hz/10);
2817 }
2818
2819 RAL_LOCK(sc);
2889 tsleep(sc, 0, "ralrunning", hz/10);
2890 }
2891
2892 RAL_LOCK(sc);
2893
2894 callout_stop(&sc->watchdog_ch);
2895
2820 if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
2821 ieee80211_new_state(ic, IEEE80211_S_INIT, -1);
2896 if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
2897 ieee80211_new_state(ic, IEEE80211_S_INIT, -1);
2822 sc->sc_tx_timer = 0;
2823 ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
2824
2825 /* abort Tx */
2826 RAL_WRITE(sc, RT2560_TXCSR0, RT2560_ABORT_TX);
2827
2828 /* disable Rx */
2829 RAL_WRITE(sc, RT2560_RXCSR0, RT2560_DISABLE_RX);
2830

--- 6 unchanged lines hidden (view full) ---

2837
2838 /* reset Tx and Rx rings */
2839 rt2560_reset_tx_ring(sc, &sc->txq);
2840 rt2560_reset_tx_ring(sc, &sc->atimq);
2841 rt2560_reset_tx_ring(sc, &sc->prioq);
2842 rt2560_reset_tx_ring(sc, &sc->bcnq);
2843 rt2560_reset_rx_ring(sc, &sc->rxq);
2844 }
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
2845 RAL_UNLOCK(sc);
2846}
2847
2848static int
2849rt2560_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
2850 const struct ieee80211_bpf_params *params)
2851{
2852 struct ieee80211com *ic = ni->ni_ic;

--- 33 unchanged lines hidden (view full) ---

2886 /*
2887 * Caller supplied explicit parameters to use in
2888 * sending the frame.
2889 */
2890 if (rt2560_tx_raw(sc, m, ni, params))
2891 goto bad;
2892 }
2893 sc->sc_tx_timer = 5;
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;
2894 callout_reset(&sc->watchdog_ch, hz, rt2560_watchdog, sc);
2895
2896 RAL_UNLOCK(sc);
2897
2898 return 0;
2899bad:
2900 ifp->if_oerrors++;
2901 ieee80211_free_node(ni);
2902 RAL_UNLOCK(sc);
2903 return EIO; /* XXX */
2904}
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}
2905