recv.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  1. /*
  2. * Copyright (c) 2008 Atheros Communications Inc.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #include "core.h"
  17. /*
  18. * Setup and link descriptors.
  19. *
  20. * 11N: we can no longer afford to self link the last descriptor.
  21. * MAC acknowledges BA status as long as it copies frames to host
  22. * buffer (or rx fifo). This can incorrectly acknowledge packets
  23. * to a sender if last desc is self-linked.
  24. */
  25. static void ath_rx_buf_link(struct ath_softc *sc, struct ath_buf *bf)
  26. {
  27. struct ath_hal *ah = sc->sc_ah;
  28. struct ath_desc *ds;
  29. struct sk_buff *skb;
  30. ATH_RXBUF_RESET(bf);
  31. ds = bf->bf_desc;
  32. ds->ds_link = 0; /* link to null */
  33. ds->ds_data = bf->bf_buf_addr;
  34. /* virtual addr of the beginning of the buffer. */
  35. skb = bf->bf_mpdu;
  36. ASSERT(skb != NULL);
  37. ds->ds_vdata = skb->data;
  38. /* setup rx descriptors */
  39. ath9k_hw_setuprxdesc(ah, ds,
  40. skb_tailroom(skb), /* buffer size */
  41. 0);
  42. if (sc->sc_rxlink == NULL)
  43. ath9k_hw_putrxbuf(ah, bf->bf_daddr);
  44. else
  45. *sc->sc_rxlink = bf->bf_daddr;
  46. sc->sc_rxlink = &ds->ds_link;
  47. ath9k_hw_rxena(ah);
  48. }
  49. static struct sk_buff *ath_rxbuf_alloc(struct ath_softc *sc, u32 len)
  50. {
  51. struct sk_buff *skb;
  52. u32 off;
  53. /*
  54. * Cache-line-align. This is important (for the
  55. * 5210 at least) as not doing so causes bogus data
  56. * in rx'd frames.
  57. */
  58. skb = dev_alloc_skb(len + sc->sc_cachelsz - 1);
  59. if (skb != NULL) {
  60. off = ((unsigned long) skb->data) % sc->sc_cachelsz;
  61. if (off != 0)
  62. skb_reserve(skb, sc->sc_cachelsz - off);
  63. } else {
  64. DPRINTF(sc, ATH_DBG_FATAL,
  65. "%s: skbuff alloc of size %u failed\n",
  66. __func__, len);
  67. return NULL;
  68. }
  69. return skb;
  70. }
  71. static void ath_rx_requeue(struct ath_softc *sc, struct ath_buf *bf)
  72. {
  73. struct sk_buff *skb;
  74. ASSERT(bf != NULL);
  75. if (bf->bf_mpdu == NULL) {
  76. skb = ath_rxbuf_alloc(sc, sc->sc_rxbufsize);
  77. if (skb != NULL) {
  78. bf->bf_mpdu = skb;
  79. bf->bf_buf_addr = pci_map_single(sc->pdev, skb->data,
  80. skb_end_pointer(skb) - skb->head,
  81. PCI_DMA_FROMDEVICE);
  82. bf->bf_dmacontext = bf->bf_buf_addr;
  83. }
  84. }
  85. list_move_tail(&bf->list, &sc->sc_rxbuf);
  86. ath_rx_buf_link(sc, bf);
  87. }
  88. static int ath_rate2idx(struct ath_softc *sc, int rate)
  89. {
  90. int i = 0, cur_band, n_rates;
  91. struct ieee80211_hw *hw = sc->hw;
  92. cur_band = hw->conf.channel->band;
  93. n_rates = sc->sbands[cur_band].n_bitrates;
  94. for (i = 0; i < n_rates; i++) {
  95. if (sc->sbands[cur_band].bitrates[i].bitrate == rate)
  96. break;
  97. }
  98. /*
  99. * NB:mac80211 validates rx rate index against the supported legacy rate
  100. * index only (should be done against ht rates also), return the highest
  101. * legacy rate index for rx rate which does not match any one of the
  102. * supported basic and extended rates to make mac80211 happy.
  103. * The following hack will be cleaned up once the issue with
  104. * the rx rate index validation in mac80211 is fixed.
  105. */
  106. if (i == n_rates)
  107. return n_rates - 1;
  108. return i;
  109. }
  110. /*
  111. * For Decrypt or Demic errors, we only mark packet status here and always push
  112. * up the frame up to let mac80211 handle the actual error case, be it no
  113. * decryption key or real decryption error. This let us keep statistics there.
  114. */
  115. static int ath_rx_prepare(struct sk_buff *skb, struct ath_desc *ds,
  116. struct ieee80211_rx_status *rx_status, bool *decrypt_error,
  117. struct ath_softc *sc)
  118. {
  119. struct ath_rate_table *rate_table = sc->hw_rate_table[sc->sc_curmode];
  120. struct ieee80211_hdr *hdr;
  121. int ratekbps, rix;
  122. u8 ratecode;
  123. __le16 fc;
  124. hdr = (struct ieee80211_hdr *)skb->data;
  125. fc = hdr->frame_control;
  126. memset(rx_status, 0, sizeof(struct ieee80211_rx_status));
  127. if (ds->ds_rxstat.rs_more) {
  128. /*
  129. * Frame spans multiple descriptors; this cannot happen yet
  130. * as we don't support jumbograms. If not in monitor mode,
  131. * discard the frame. Enable this if you want to see
  132. * error frames in Monitor mode.
  133. */
  134. if (sc->sc_ah->ah_opmode != ATH9K_M_MONITOR)
  135. goto rx_next;
  136. } else if (ds->ds_rxstat.rs_status != 0) {
  137. if (ds->ds_rxstat.rs_status & ATH9K_RXERR_CRC)
  138. rx_status->flag |= RX_FLAG_FAILED_FCS_CRC;
  139. if (ds->ds_rxstat.rs_status & ATH9K_RXERR_PHY)
  140. goto rx_next;
  141. if (ds->ds_rxstat.rs_status & ATH9K_RXERR_DECRYPT) {
  142. *decrypt_error = true;
  143. } else if (ds->ds_rxstat.rs_status & ATH9K_RXERR_MIC) {
  144. if (ieee80211_is_ctl(fc))
  145. /*
  146. * Sometimes, we get invalid
  147. * MIC failures on valid control frames.
  148. * Remove these mic errors.
  149. */
  150. ds->ds_rxstat.rs_status &= ~ATH9K_RXERR_MIC;
  151. else
  152. rx_status->flag |= RX_FLAG_MMIC_ERROR;
  153. }
  154. /*
  155. * Reject error frames with the exception of
  156. * decryption and MIC failures. For monitor mode,
  157. * we also ignore the CRC error.
  158. */
  159. if (sc->sc_ah->ah_opmode == ATH9K_M_MONITOR) {
  160. if (ds->ds_rxstat.rs_status &
  161. ~(ATH9K_RXERR_DECRYPT | ATH9K_RXERR_MIC |
  162. ATH9K_RXERR_CRC))
  163. goto rx_next;
  164. } else {
  165. if (ds->ds_rxstat.rs_status &
  166. ~(ATH9K_RXERR_DECRYPT | ATH9K_RXERR_MIC)) {
  167. goto rx_next;
  168. }
  169. }
  170. }
  171. ratecode = ds->ds_rxstat.rs_rate;
  172. rix = rate_table->rateCodeToIndex[ratecode];
  173. ratekbps = rate_table->info[rix].ratekbps;
  174. /* HT rate */
  175. if (ratecode & 0x80) {
  176. if (ds->ds_rxstat.rs_flags & ATH9K_RX_2040)
  177. ratekbps = (ratekbps * 27) / 13;
  178. if (ds->ds_rxstat.rs_flags & ATH9K_RX_GI)
  179. ratekbps = (ratekbps * 10) / 9;
  180. }
  181. rx_status->mactime = ath_extend_tsf(sc, ds->ds_rxstat.rs_tstamp);
  182. rx_status->band = sc->hw->conf.channel->band;
  183. rx_status->freq = sc->hw->conf.channel->center_freq;
  184. rx_status->noise = sc->sc_ani.sc_noise_floor;
  185. rx_status->signal = rx_status->noise + ds->ds_rxstat.rs_rssi;
  186. rx_status->rate_idx = ath_rate2idx(sc, (ratekbps / 100));
  187. rx_status->antenna = ds->ds_rxstat.rs_antenna;
  188. /* at 45 you will be able to use MCS 15 reliably. A more elaborate
  189. * scheme can be used here but it requires tables of SNR/throughput for
  190. * each possible mode used. */
  191. rx_status->qual = ds->ds_rxstat.rs_rssi * 100 / 45;
  192. /* rssi can be more than 45 though, anything above that
  193. * should be considered at 100% */
  194. if (rx_status->qual > 100)
  195. rx_status->qual = 100;
  196. rx_status->flag |= RX_FLAG_TSFT;
  197. return 1;
  198. rx_next:
  199. return 0;
  200. }
  201. static void ath_opmode_init(struct ath_softc *sc)
  202. {
  203. struct ath_hal *ah = sc->sc_ah;
  204. u32 rfilt, mfilt[2];
  205. /* configure rx filter */
  206. rfilt = ath_calcrxfilter(sc);
  207. ath9k_hw_setrxfilter(ah, rfilt);
  208. /* configure bssid mask */
  209. if (ah->ah_caps.hw_caps & ATH9K_HW_CAP_BSSIDMASK)
  210. ath9k_hw_setbssidmask(ah, sc->sc_bssidmask);
  211. /* configure operational mode */
  212. ath9k_hw_setopmode(ah);
  213. /* Handle any link-level address change. */
  214. ath9k_hw_setmac(ah, sc->sc_myaddr);
  215. /* calculate and install multicast filter */
  216. mfilt[0] = mfilt[1] = ~0;
  217. ath9k_hw_setmcastfilter(ah, mfilt[0], mfilt[1]);
  218. DPRINTF(sc, ATH_DBG_CONFIG ,
  219. "%s: RX filter 0x%x, MC filter %08x:%08x\n",
  220. __func__, rfilt, mfilt[0], mfilt[1]);
  221. }
  222. int ath_rx_init(struct ath_softc *sc, int nbufs)
  223. {
  224. struct sk_buff *skb;
  225. struct ath_buf *bf;
  226. int error = 0;
  227. do {
  228. spin_lock_init(&sc->sc_rxflushlock);
  229. sc->sc_flags &= ~SC_OP_RXFLUSH;
  230. spin_lock_init(&sc->sc_rxbuflock);
  231. sc->sc_rxbufsize = roundup(IEEE80211_MAX_MPDU_LEN,
  232. min(sc->sc_cachelsz,
  233. (u16)64));
  234. DPRINTF(sc, ATH_DBG_CONFIG, "%s: cachelsz %u rxbufsize %u\n",
  235. __func__, sc->sc_cachelsz, sc->sc_rxbufsize);
  236. /* Initialize rx descriptors */
  237. error = ath_descdma_setup(sc, &sc->sc_rxdma, &sc->sc_rxbuf,
  238. "rx", nbufs, 1);
  239. if (error != 0) {
  240. DPRINTF(sc, ATH_DBG_FATAL,
  241. "%s: failed to allocate rx descriptors: %d\n",
  242. __func__, error);
  243. break;
  244. }
  245. list_for_each_entry(bf, &sc->sc_rxbuf, list) {
  246. skb = ath_rxbuf_alloc(sc, sc->sc_rxbufsize);
  247. if (skb == NULL) {
  248. error = -ENOMEM;
  249. break;
  250. }
  251. bf->bf_mpdu = skb;
  252. bf->bf_buf_addr = pci_map_single(sc->pdev, skb->data,
  253. skb_end_pointer(skb) - skb->head,
  254. PCI_DMA_FROMDEVICE);
  255. bf->bf_dmacontext = bf->bf_buf_addr;
  256. }
  257. sc->sc_rxlink = NULL;
  258. } while (0);
  259. if (error)
  260. ath_rx_cleanup(sc);
  261. return error;
  262. }
  263. void ath_rx_cleanup(struct ath_softc *sc)
  264. {
  265. struct sk_buff *skb;
  266. struct ath_buf *bf;
  267. list_for_each_entry(bf, &sc->sc_rxbuf, list) {
  268. skb = bf->bf_mpdu;
  269. if (skb)
  270. dev_kfree_skb(skb);
  271. }
  272. if (sc->sc_rxdma.dd_desc_len != 0)
  273. ath_descdma_cleanup(sc, &sc->sc_rxdma, &sc->sc_rxbuf);
  274. }
  275. /*
  276. * Calculate the receive filter according to the
  277. * operating mode and state:
  278. *
  279. * o always accept unicast, broadcast, and multicast traffic
  280. * o maintain current state of phy error reception (the hal
  281. * may enable phy error frames for noise immunity work)
  282. * o probe request frames are accepted only when operating in
  283. * hostap, adhoc, or monitor modes
  284. * o enable promiscuous mode according to the interface state
  285. * o accept beacons:
  286. * - when operating in adhoc mode so the 802.11 layer creates
  287. * node table entries for peers,
  288. * - when operating in station mode for collecting rssi data when
  289. * the station is otherwise quiet, or
  290. * - when operating as a repeater so we see repeater-sta beacons
  291. * - when scanning
  292. */
  293. u32 ath_calcrxfilter(struct ath_softc *sc)
  294. {
  295. #define RX_FILTER_PRESERVE (ATH9K_RX_FILTER_PHYERR | ATH9K_RX_FILTER_PHYRADAR)
  296. u32 rfilt;
  297. rfilt = (ath9k_hw_getrxfilter(sc->sc_ah) & RX_FILTER_PRESERVE)
  298. | ATH9K_RX_FILTER_UCAST | ATH9K_RX_FILTER_BCAST
  299. | ATH9K_RX_FILTER_MCAST;
  300. /* If not a STA, enable processing of Probe Requests */
  301. if (sc->sc_ah->ah_opmode != ATH9K_M_STA)
  302. rfilt |= ATH9K_RX_FILTER_PROBEREQ;
  303. /* Can't set HOSTAP into promiscous mode */
  304. if (((sc->sc_ah->ah_opmode != ATH9K_M_HOSTAP) &&
  305. (sc->rx_filter & FIF_PROMISC_IN_BSS)) ||
  306. (sc->sc_ah->ah_opmode == ATH9K_M_MONITOR)) {
  307. rfilt |= ATH9K_RX_FILTER_PROM;
  308. /* ??? To prevent from sending ACK */
  309. rfilt &= ~ATH9K_RX_FILTER_UCAST;
  310. }
  311. if (sc->sc_ah->ah_opmode == ATH9K_M_STA ||
  312. sc->sc_ah->ah_opmode == ATH9K_M_IBSS)
  313. rfilt |= ATH9K_RX_FILTER_BEACON;
  314. /* If in HOSTAP mode, want to enable reception of PSPOLL frames
  315. & beacon frames */
  316. if (sc->sc_ah->ah_opmode == ATH9K_M_HOSTAP)
  317. rfilt |= (ATH9K_RX_FILTER_BEACON | ATH9K_RX_FILTER_PSPOLL);
  318. return rfilt;
  319. #undef RX_FILTER_PRESERVE
  320. }
  321. int ath_startrecv(struct ath_softc *sc)
  322. {
  323. struct ath_hal *ah = sc->sc_ah;
  324. struct ath_buf *bf, *tbf;
  325. spin_lock_bh(&sc->sc_rxbuflock);
  326. if (list_empty(&sc->sc_rxbuf))
  327. goto start_recv;
  328. sc->sc_rxlink = NULL;
  329. list_for_each_entry_safe(bf, tbf, &sc->sc_rxbuf, list) {
  330. ath_rx_buf_link(sc, bf);
  331. }
  332. /* We could have deleted elements so the list may be empty now */
  333. if (list_empty(&sc->sc_rxbuf))
  334. goto start_recv;
  335. bf = list_first_entry(&sc->sc_rxbuf, struct ath_buf, list);
  336. ath9k_hw_putrxbuf(ah, bf->bf_daddr);
  337. ath9k_hw_rxena(ah);
  338. start_recv:
  339. spin_unlock_bh(&sc->sc_rxbuflock);
  340. ath_opmode_init(sc);
  341. ath9k_hw_startpcureceive(ah);
  342. return 0;
  343. }
  344. bool ath_stoprecv(struct ath_softc *sc)
  345. {
  346. struct ath_hal *ah = sc->sc_ah;
  347. bool stopped;
  348. ath9k_hw_stoppcurecv(ah);
  349. ath9k_hw_setrxfilter(ah, 0);
  350. stopped = ath9k_hw_stopdmarecv(ah);
  351. mdelay(3); /* 3ms is long enough for 1 frame */
  352. sc->sc_rxlink = NULL;
  353. return stopped;
  354. }
  355. void ath_flushrecv(struct ath_softc *sc)
  356. {
  357. spin_lock_bh(&sc->sc_rxflushlock);
  358. sc->sc_flags |= SC_OP_RXFLUSH;
  359. ath_rx_tasklet(sc, 1);
  360. sc->sc_flags &= ~SC_OP_RXFLUSH;
  361. spin_unlock_bh(&sc->sc_rxflushlock);
  362. }
  363. int ath_rx_tasklet(struct ath_softc *sc, int flush)
  364. {
  365. #define PA2DESC(_sc, _pa) \
  366. ((struct ath_desc *)((caddr_t)(_sc)->sc_rxdma.dd_desc + \
  367. ((_pa) - (_sc)->sc_rxdma.dd_desc_paddr)))
  368. struct ath_buf *bf;
  369. struct ath_desc *ds;
  370. struct sk_buff *skb = NULL;
  371. struct ieee80211_rx_status rx_status;
  372. struct ath_hal *ah = sc->sc_ah;
  373. struct ieee80211_hdr *hdr;
  374. int hdrlen, padsize, retval;
  375. bool decrypt_error = false;
  376. u8 keyix;
  377. spin_lock_bh(&sc->sc_rxbuflock);
  378. do {
  379. /* If handling rx interrupt and flush is in progress => exit */
  380. if ((sc->sc_flags & SC_OP_RXFLUSH) && (flush == 0))
  381. break;
  382. if (list_empty(&sc->sc_rxbuf)) {
  383. sc->sc_rxlink = NULL;
  384. break;
  385. }
  386. bf = list_first_entry(&sc->sc_rxbuf, struct ath_buf, list);
  387. ds = bf->bf_desc;
  388. /*
  389. * Must provide the virtual address of the current
  390. * descriptor, the physical address, and the virtual
  391. * address of the next descriptor in the h/w chain.
  392. * This allows the HAL to look ahead to see if the
  393. * hardware is done with a descriptor by checking the
  394. * done bit in the following descriptor and the address
  395. * of the current descriptor the DMA engine is working
  396. * on. All this is necessary because of our use of
  397. * a self-linked list to avoid rx overruns.
  398. */
  399. retval = ath9k_hw_rxprocdesc(ah, ds,
  400. bf->bf_daddr,
  401. PA2DESC(sc, ds->ds_link),
  402. 0);
  403. if (retval == -EINPROGRESS) {
  404. struct ath_buf *tbf;
  405. struct ath_desc *tds;
  406. if (list_is_last(&bf->list, &sc->sc_rxbuf)) {
  407. sc->sc_rxlink = NULL;
  408. break;
  409. }
  410. tbf = list_entry(bf->list.next, struct ath_buf, list);
  411. /*
  412. * On some hardware the descriptor status words could
  413. * get corrupted, including the done bit. Because of
  414. * this, check if the next descriptor's done bit is
  415. * set or not.
  416. *
  417. * If the next descriptor's done bit is set, the current
  418. * descriptor has been corrupted. Force s/w to discard
  419. * this descriptor and continue...
  420. */
  421. tds = tbf->bf_desc;
  422. retval = ath9k_hw_rxprocdesc(ah, tds, tbf->bf_daddr,
  423. PA2DESC(sc, tds->ds_link), 0);
  424. if (retval == -EINPROGRESS) {
  425. break;
  426. }
  427. }
  428. skb = bf->bf_mpdu;
  429. if (!skb)
  430. continue;
  431. /*
  432. * If we're asked to flush receive queue, directly
  433. * chain it back at the queue without processing it.
  434. */
  435. if (flush)
  436. goto rx_next;
  437. if (!ds->ds_rxstat.rs_datalen)
  438. goto rx_next;
  439. /* The status portion of the descriptor could get corrupted. */
  440. if (sc->sc_rxbufsize < ds->ds_rxstat.rs_datalen)
  441. goto rx_next;
  442. if (!ath_rx_prepare(skb, ds, &rx_status, &decrypt_error, sc))
  443. goto rx_next;
  444. /* Sync and unmap the frame */
  445. pci_dma_sync_single_for_cpu(sc->pdev, bf->bf_buf_addr,
  446. skb_tailroom(skb),
  447. PCI_DMA_FROMDEVICE);
  448. pci_unmap_single(sc->pdev, bf->bf_buf_addr,
  449. sc->sc_rxbufsize,
  450. PCI_DMA_FROMDEVICE);
  451. skb_put(skb, ds->ds_rxstat.rs_datalen);
  452. skb->protocol = cpu_to_be16(ETH_P_CONTROL);
  453. /* see if any padding is done by the hw and remove it */
  454. hdr = (struct ieee80211_hdr *)skb->data;
  455. hdrlen = ieee80211_get_hdrlen_from_skb(skb);
  456. if (hdrlen & 3) {
  457. padsize = hdrlen % 4;
  458. memmove(skb->data + padsize, skb->data, hdrlen);
  459. skb_pull(skb, padsize);
  460. }
  461. keyix = ds->ds_rxstat.rs_keyix;
  462. if (!(keyix == ATH9K_RXKEYIX_INVALID) && !decrypt_error) {
  463. rx_status.flag |= RX_FLAG_DECRYPTED;
  464. } else if ((le16_to_cpu(hdr->frame_control) & IEEE80211_FCTL_PROTECTED)
  465. && !decrypt_error && skb->len >= hdrlen + 4) {
  466. keyix = skb->data[hdrlen + 3] >> 6;
  467. if (test_bit(keyix, sc->sc_keymap))
  468. rx_status.flag |= RX_FLAG_DECRYPTED;
  469. }
  470. /* Send the frame to mac80211 */
  471. __ieee80211_rx(sc->hw, skb, &rx_status);
  472. bf->bf_mpdu = NULL;
  473. /*
  474. * change the default rx antenna if rx diversity chooses the
  475. * other antenna 3 times in a row.
  476. */
  477. if (sc->sc_defant != ds->ds_rxstat.rs_antenna) {
  478. if (++sc->sc_rxotherant >= 3)
  479. ath_setdefantenna(sc, ds->ds_rxstat.rs_antenna);
  480. } else {
  481. sc->sc_rxotherant = 0;
  482. }
  483. rx_next:
  484. ath_rx_requeue(sc, bf);
  485. } while (1);
  486. spin_unlock_bh(&sc->sc_rxbuflock);
  487. return 0;
  488. #undef PA2DESC
  489. }