Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 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 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 17 | #include "core.h" |
| 18 | |
| 19 | /* |
| 20 | * Setup and link descriptors. |
| 21 | * |
| 22 | * 11N: we can no longer afford to self link the last descriptor. |
| 23 | * MAC acknowledges BA status as long as it copies frames to host |
| 24 | * buffer (or rx fifo). This can incorrectly acknowledge packets |
| 25 | * to a sender if last desc is self-linked. |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 26 | */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 27 | static void ath_rx_buf_link(struct ath_softc *sc, struct ath_buf *bf) |
| 28 | { |
| 29 | struct ath_hal *ah = sc->sc_ah; |
| 30 | struct ath_desc *ds; |
| 31 | struct sk_buff *skb; |
| 32 | |
| 33 | ATH_RXBUF_RESET(bf); |
| 34 | |
| 35 | ds = bf->bf_desc; |
Sujith | be0418a | 2008-11-18 09:05:55 +0530 | [diff] [blame] | 36 | ds->ds_link = 0; /* link to null */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 37 | ds->ds_data = bf->bf_buf_addr; |
| 38 | |
Sujith | be0418a | 2008-11-18 09:05:55 +0530 | [diff] [blame] | 39 | /* virtual addr of the beginning of the buffer. */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 40 | skb = bf->bf_mpdu; |
| 41 | ASSERT(skb != NULL); |
| 42 | ds->ds_vdata = skb->data; |
| 43 | |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 44 | /* setup rx descriptors. The rx.bufsize here tells the harware |
Luis R. Rodriguez | b4b6cda | 2008-11-20 17:15:13 -0800 | [diff] [blame] | 45 | * how much data it can DMA to us and that we are prepared |
| 46 | * to process */ |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 47 | ath9k_hw_setuprxdesc(ah, ds, |
| 48 | sc->rx.bufsize, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 49 | 0); |
| 50 | |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 51 | if (sc->rx.rxlink == NULL) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 52 | ath9k_hw_putrxbuf(ah, bf->bf_daddr); |
| 53 | else |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 54 | *sc->rx.rxlink = bf->bf_daddr; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 55 | |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 56 | sc->rx.rxlink = &ds->ds_link; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 57 | ath9k_hw_rxena(ah); |
| 58 | } |
| 59 | |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 60 | static void ath_setdefantenna(struct ath_softc *sc, u32 antenna) |
| 61 | { |
| 62 | /* XXX block beacon interrupts */ |
| 63 | ath9k_hw_setantenna(sc->sc_ah, antenna); |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 64 | sc->rx.defant = antenna; |
| 65 | sc->rx.rxotherant = 0; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | /* |
| 69 | * Extend 15-bit time stamp from rx descriptor to |
| 70 | * a full 64-bit TSF using the current h/w TSF. |
| 71 | */ |
| 72 | static u64 ath_extend_tsf(struct ath_softc *sc, u32 rstamp) |
| 73 | { |
| 74 | u64 tsf; |
| 75 | |
| 76 | tsf = ath9k_hw_gettsf64(sc->sc_ah); |
| 77 | if ((tsf & 0x7fff) < rstamp) |
| 78 | tsf -= 0x8000; |
| 79 | return (tsf & ~0x7fff) | rstamp; |
| 80 | } |
| 81 | |
Sujith | be0418a | 2008-11-18 09:05:55 +0530 | [diff] [blame] | 82 | static struct sk_buff *ath_rxbuf_alloc(struct ath_softc *sc, u32 len) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 83 | { |
| 84 | struct sk_buff *skb; |
| 85 | u32 off; |
| 86 | |
| 87 | /* |
| 88 | * Cache-line-align. This is important (for the |
| 89 | * 5210 at least) as not doing so causes bogus data |
| 90 | * in rx'd frames. |
| 91 | */ |
| 92 | |
Luis R. Rodriguez | b4b6cda | 2008-11-20 17:15:13 -0800 | [diff] [blame] | 93 | /* Note: the kernel can allocate a value greater than |
| 94 | * what we ask it to give us. We really only need 4 KB as that |
| 95 | * is this hardware supports and in fact we need at least 3849 |
| 96 | * as that is the MAX AMSDU size this hardware supports. |
| 97 | * Unfortunately this means we may get 8 KB here from the |
| 98 | * kernel... and that is actually what is observed on some |
| 99 | * systems :( */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 100 | skb = dev_alloc_skb(len + sc->sc_cachelsz - 1); |
| 101 | if (skb != NULL) { |
| 102 | off = ((unsigned long) skb->data) % sc->sc_cachelsz; |
| 103 | if (off != 0) |
| 104 | skb_reserve(skb, sc->sc_cachelsz - off); |
| 105 | } else { |
| 106 | DPRINTF(sc, ATH_DBG_FATAL, |
Sujith | 04bd4638 | 2008-11-28 22:18:05 +0530 | [diff] [blame] | 107 | "skbuff alloc of size %u failed\n", len); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 108 | return NULL; |
| 109 | } |
| 110 | |
| 111 | return skb; |
| 112 | } |
| 113 | |
Sujith | be0418a | 2008-11-18 09:05:55 +0530 | [diff] [blame] | 114 | static int ath_rate2idx(struct ath_softc *sc, int rate) |
| 115 | { |
| 116 | int i = 0, cur_band, n_rates; |
| 117 | struct ieee80211_hw *hw = sc->hw; |
| 118 | |
| 119 | cur_band = hw->conf.channel->band; |
| 120 | n_rates = sc->sbands[cur_band].n_bitrates; |
| 121 | |
| 122 | for (i = 0; i < n_rates; i++) { |
| 123 | if (sc->sbands[cur_band].bitrates[i].bitrate == rate) |
| 124 | break; |
| 125 | } |
| 126 | |
| 127 | /* |
| 128 | * NB:mac80211 validates rx rate index against the supported legacy rate |
| 129 | * index only (should be done against ht rates also), return the highest |
| 130 | * legacy rate index for rx rate which does not match any one of the |
| 131 | * supported basic and extended rates to make mac80211 happy. |
| 132 | * The following hack will be cleaned up once the issue with |
| 133 | * the rx rate index validation in mac80211 is fixed. |
| 134 | */ |
| 135 | if (i == n_rates) |
| 136 | return n_rates - 1; |
| 137 | |
| 138 | return i; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | /* |
Sujith | be0418a | 2008-11-18 09:05:55 +0530 | [diff] [blame] | 142 | * For Decrypt or Demic errors, we only mark packet status here and always push |
| 143 | * up the frame up to let mac80211 handle the actual error case, be it no |
| 144 | * decryption key or real decryption error. This let us keep statistics there. |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 145 | */ |
Sujith | be0418a | 2008-11-18 09:05:55 +0530 | [diff] [blame] | 146 | static int ath_rx_prepare(struct sk_buff *skb, struct ath_desc *ds, |
| 147 | struct ieee80211_rx_status *rx_status, bool *decrypt_error, |
| 148 | struct ath_softc *sc) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 149 | { |
Sujith | 3706de6 | 2008-12-07 21:42:10 +0530 | [diff] [blame] | 150 | struct ath_rate_table *rate_table = sc->cur_rate_table; |
Sujith | be0418a | 2008-11-18 09:05:55 +0530 | [diff] [blame] | 151 | struct ieee80211_hdr *hdr; |
Sujith | e63835b | 2008-11-18 09:07:53 +0530 | [diff] [blame] | 152 | int ratekbps, rix; |
Sujith | be0418a | 2008-11-18 09:05:55 +0530 | [diff] [blame] | 153 | u8 ratecode; |
| 154 | __le16 fc; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 155 | |
Sujith | be0418a | 2008-11-18 09:05:55 +0530 | [diff] [blame] | 156 | hdr = (struct ieee80211_hdr *)skb->data; |
| 157 | fc = hdr->frame_control; |
| 158 | memset(rx_status, 0, sizeof(struct ieee80211_rx_status)); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 159 | |
Sujith | be0418a | 2008-11-18 09:05:55 +0530 | [diff] [blame] | 160 | if (ds->ds_rxstat.rs_more) { |
| 161 | /* |
| 162 | * Frame spans multiple descriptors; this cannot happen yet |
| 163 | * as we don't support jumbograms. If not in monitor mode, |
| 164 | * discard the frame. Enable this if you want to see |
| 165 | * error frames in Monitor mode. |
| 166 | */ |
Colin McCabe | d97809d | 2008-12-01 13:38:55 -0800 | [diff] [blame] | 167 | if (sc->sc_ah->ah_opmode != NL80211_IFTYPE_MONITOR) |
Sujith | be0418a | 2008-11-18 09:05:55 +0530 | [diff] [blame] | 168 | goto rx_next; |
| 169 | } else if (ds->ds_rxstat.rs_status != 0) { |
| 170 | if (ds->ds_rxstat.rs_status & ATH9K_RXERR_CRC) |
| 171 | rx_status->flag |= RX_FLAG_FAILED_FCS_CRC; |
| 172 | if (ds->ds_rxstat.rs_status & ATH9K_RXERR_PHY) |
| 173 | goto rx_next; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 174 | |
Sujith | be0418a | 2008-11-18 09:05:55 +0530 | [diff] [blame] | 175 | if (ds->ds_rxstat.rs_status & ATH9K_RXERR_DECRYPT) { |
| 176 | *decrypt_error = true; |
| 177 | } else if (ds->ds_rxstat.rs_status & ATH9K_RXERR_MIC) { |
| 178 | if (ieee80211_is_ctl(fc)) |
| 179 | /* |
| 180 | * Sometimes, we get invalid |
| 181 | * MIC failures on valid control frames. |
| 182 | * Remove these mic errors. |
| 183 | */ |
| 184 | ds->ds_rxstat.rs_status &= ~ATH9K_RXERR_MIC; |
| 185 | else |
| 186 | rx_status->flag |= RX_FLAG_MMIC_ERROR; |
| 187 | } |
| 188 | /* |
| 189 | * Reject error frames with the exception of |
| 190 | * decryption and MIC failures. For monitor mode, |
| 191 | * we also ignore the CRC error. |
| 192 | */ |
Colin McCabe | d97809d | 2008-12-01 13:38:55 -0800 | [diff] [blame] | 193 | if (sc->sc_ah->ah_opmode == NL80211_IFTYPE_MONITOR) { |
Sujith | be0418a | 2008-11-18 09:05:55 +0530 | [diff] [blame] | 194 | if (ds->ds_rxstat.rs_status & |
| 195 | ~(ATH9K_RXERR_DECRYPT | ATH9K_RXERR_MIC | |
| 196 | ATH9K_RXERR_CRC)) |
| 197 | goto rx_next; |
| 198 | } else { |
| 199 | if (ds->ds_rxstat.rs_status & |
| 200 | ~(ATH9K_RXERR_DECRYPT | ATH9K_RXERR_MIC)) { |
| 201 | goto rx_next; |
| 202 | } |
| 203 | } |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 204 | } |
| 205 | |
Sujith | be0418a | 2008-11-18 09:05:55 +0530 | [diff] [blame] | 206 | ratecode = ds->ds_rxstat.rs_rate; |
Sujith | e63835b | 2008-11-18 09:07:53 +0530 | [diff] [blame] | 207 | rix = rate_table->rateCodeToIndex[ratecode]; |
| 208 | ratekbps = rate_table->info[rix].ratekbps; |
Sujith | be0418a | 2008-11-18 09:05:55 +0530 | [diff] [blame] | 209 | |
| 210 | /* HT rate */ |
| 211 | if (ratecode & 0x80) { |
| 212 | if (ds->ds_rxstat.rs_flags & ATH9K_RX_2040) |
| 213 | ratekbps = (ratekbps * 27) / 13; |
| 214 | if (ds->ds_rxstat.rs_flags & ATH9K_RX_GI) |
| 215 | ratekbps = (ratekbps * 10) / 9; |
| 216 | } |
| 217 | |
| 218 | rx_status->mactime = ath_extend_tsf(sc, ds->ds_rxstat.rs_tstamp); |
| 219 | rx_status->band = sc->hw->conf.channel->band; |
| 220 | rx_status->freq = sc->hw->conf.channel->center_freq; |
| 221 | rx_status->noise = sc->sc_ani.sc_noise_floor; |
| 222 | rx_status->signal = rx_status->noise + ds->ds_rxstat.rs_rssi; |
| 223 | rx_status->rate_idx = ath_rate2idx(sc, (ratekbps / 100)); |
| 224 | rx_status->antenna = ds->ds_rxstat.rs_antenna; |
| 225 | |
| 226 | /* at 45 you will be able to use MCS 15 reliably. A more elaborate |
| 227 | * scheme can be used here but it requires tables of SNR/throughput for |
| 228 | * each possible mode used. */ |
| 229 | rx_status->qual = ds->ds_rxstat.rs_rssi * 100 / 45; |
| 230 | |
| 231 | /* rssi can be more than 45 though, anything above that |
| 232 | * should be considered at 100% */ |
| 233 | if (rx_status->qual > 100) |
| 234 | rx_status->qual = 100; |
| 235 | |
| 236 | rx_status->flag |= RX_FLAG_TSFT; |
| 237 | |
| 238 | return 1; |
| 239 | rx_next: |
| 240 | return 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | static void ath_opmode_init(struct ath_softc *sc) |
| 244 | { |
| 245 | struct ath_hal *ah = sc->sc_ah; |
| 246 | u32 rfilt, mfilt[2]; |
| 247 | |
| 248 | /* configure rx filter */ |
| 249 | rfilt = ath_calcrxfilter(sc); |
| 250 | ath9k_hw_setrxfilter(ah, rfilt); |
| 251 | |
| 252 | /* configure bssid mask */ |
Sujith | 60b67f5 | 2008-08-07 10:52:38 +0530 | [diff] [blame] | 253 | if (ah->ah_caps.hw_caps & ATH9K_HW_CAP_BSSIDMASK) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 254 | ath9k_hw_setbssidmask(ah, sc->sc_bssidmask); |
| 255 | |
| 256 | /* configure operational mode */ |
| 257 | ath9k_hw_setopmode(ah); |
| 258 | |
| 259 | /* Handle any link-level address change. */ |
| 260 | ath9k_hw_setmac(ah, sc->sc_myaddr); |
| 261 | |
| 262 | /* calculate and install multicast filter */ |
| 263 | mfilt[0] = mfilt[1] = ~0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 264 | ath9k_hw_setmcastfilter(ah, mfilt[0], mfilt[1]); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 265 | } |
| 266 | |
| 267 | int ath_rx_init(struct ath_softc *sc, int nbufs) |
| 268 | { |
| 269 | struct sk_buff *skb; |
| 270 | struct ath_buf *bf; |
| 271 | int error = 0; |
| 272 | |
| 273 | do { |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 274 | spin_lock_init(&sc->rx.rxflushlock); |
Sujith | 98deeea | 2008-08-11 14:05:46 +0530 | [diff] [blame] | 275 | sc->sc_flags &= ~SC_OP_RXFLUSH; |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 276 | spin_lock_init(&sc->rx.rxbuflock); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 277 | |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 278 | sc->rx.bufsize = roundup(IEEE80211_MAX_MPDU_LEN, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 279 | min(sc->sc_cachelsz, |
| 280 | (u16)64)); |
| 281 | |
Sujith | 04bd4638 | 2008-11-28 22:18:05 +0530 | [diff] [blame] | 282 | DPRINTF(sc, ATH_DBG_CONFIG, "cachelsz %u rxbufsize %u\n", |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 283 | sc->sc_cachelsz, sc->rx.bufsize); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 284 | |
| 285 | /* Initialize rx descriptors */ |
| 286 | |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 287 | error = ath_descdma_setup(sc, &sc->rx.rxdma, &sc->rx.rxbuf, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 288 | "rx", nbufs, 1); |
| 289 | if (error != 0) { |
| 290 | DPRINTF(sc, ATH_DBG_FATAL, |
Sujith | 04bd4638 | 2008-11-28 22:18:05 +0530 | [diff] [blame] | 291 | "failed to allocate rx descriptors: %d\n", error); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 292 | break; |
| 293 | } |
| 294 | |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 295 | list_for_each_entry(bf, &sc->rx.rxbuf, list) { |
| 296 | skb = ath_rxbuf_alloc(sc, sc->rx.bufsize); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 297 | if (skb == NULL) { |
| 298 | error = -ENOMEM; |
| 299 | break; |
| 300 | } |
| 301 | |
| 302 | bf->bf_mpdu = skb; |
Sujith | 927e70e | 2008-08-14 13:26:34 +0530 | [diff] [blame] | 303 | bf->bf_buf_addr = pci_map_single(sc->pdev, skb->data, |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 304 | sc->rx.bufsize, |
| 305 | PCI_DMA_FROMDEVICE); |
Luis R. Rodriguez | f8316df | 2008-12-03 03:35:29 -0800 | [diff] [blame] | 306 | if (unlikely(pci_dma_mapping_error(sc->pdev, |
| 307 | bf->bf_buf_addr))) { |
| 308 | dev_kfree_skb_any(skb); |
| 309 | bf->bf_mpdu = NULL; |
| 310 | DPRINTF(sc, ATH_DBG_CONFIG, |
| 311 | "pci_dma_mapping_error() on RX init\n"); |
| 312 | error = -ENOMEM; |
| 313 | break; |
| 314 | } |
Sujith | 927e70e | 2008-08-14 13:26:34 +0530 | [diff] [blame] | 315 | bf->bf_dmacontext = bf->bf_buf_addr; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 316 | } |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 317 | sc->rx.rxlink = NULL; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 318 | |
| 319 | } while (0); |
| 320 | |
| 321 | if (error) |
| 322 | ath_rx_cleanup(sc); |
| 323 | |
| 324 | return error; |
| 325 | } |
| 326 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 327 | void ath_rx_cleanup(struct ath_softc *sc) |
| 328 | { |
| 329 | struct sk_buff *skb; |
| 330 | struct ath_buf *bf; |
| 331 | |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 332 | list_for_each_entry(bf, &sc->rx.rxbuf, list) { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 333 | skb = bf->bf_mpdu; |
| 334 | if (skb) |
| 335 | dev_kfree_skb(skb); |
| 336 | } |
| 337 | |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 338 | if (sc->rx.rxdma.dd_desc_len != 0) |
| 339 | ath_descdma_cleanup(sc, &sc->rx.rxdma, &sc->rx.rxbuf); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | /* |
| 343 | * Calculate the receive filter according to the |
| 344 | * operating mode and state: |
| 345 | * |
| 346 | * o always accept unicast, broadcast, and multicast traffic |
| 347 | * o maintain current state of phy error reception (the hal |
| 348 | * may enable phy error frames for noise immunity work) |
| 349 | * o probe request frames are accepted only when operating in |
| 350 | * hostap, adhoc, or monitor modes |
| 351 | * o enable promiscuous mode according to the interface state |
| 352 | * o accept beacons: |
| 353 | * - when operating in adhoc mode so the 802.11 layer creates |
| 354 | * node table entries for peers, |
| 355 | * - when operating in station mode for collecting rssi data when |
| 356 | * the station is otherwise quiet, or |
| 357 | * - when operating as a repeater so we see repeater-sta beacons |
| 358 | * - when scanning |
| 359 | */ |
| 360 | |
| 361 | u32 ath_calcrxfilter(struct ath_softc *sc) |
| 362 | { |
| 363 | #define RX_FILTER_PRESERVE (ATH9K_RX_FILTER_PHYERR | ATH9K_RX_FILTER_PHYRADAR) |
Sujith | 7dcfdcd | 2008-08-11 14:03:13 +0530 | [diff] [blame] | 364 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 365 | u32 rfilt; |
| 366 | |
| 367 | rfilt = (ath9k_hw_getrxfilter(sc->sc_ah) & RX_FILTER_PRESERVE) |
| 368 | | ATH9K_RX_FILTER_UCAST | ATH9K_RX_FILTER_BCAST |
| 369 | | ATH9K_RX_FILTER_MCAST; |
| 370 | |
| 371 | /* If not a STA, enable processing of Probe Requests */ |
Colin McCabe | d97809d | 2008-12-01 13:38:55 -0800 | [diff] [blame] | 372 | if (sc->sc_ah->ah_opmode != NL80211_IFTYPE_STATION) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 373 | rfilt |= ATH9K_RX_FILTER_PROBEREQ; |
| 374 | |
| 375 | /* Can't set HOSTAP into promiscous mode */ |
Colin McCabe | d97809d | 2008-12-01 13:38:55 -0800 | [diff] [blame] | 376 | if (((sc->sc_ah->ah_opmode != NL80211_IFTYPE_AP) && |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 377 | (sc->rx.rxfilter & FIF_PROMISC_IN_BSS)) || |
Colin McCabe | d97809d | 2008-12-01 13:38:55 -0800 | [diff] [blame] | 378 | (sc->sc_ah->ah_opmode == NL80211_IFTYPE_MONITOR)) { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 379 | rfilt |= ATH9K_RX_FILTER_PROM; |
| 380 | /* ??? To prevent from sending ACK */ |
| 381 | rfilt &= ~ATH9K_RX_FILTER_UCAST; |
| 382 | } |
| 383 | |
Colin McCabe | d97809d | 2008-12-01 13:38:55 -0800 | [diff] [blame] | 384 | if (sc->sc_ah->ah_opmode == NL80211_IFTYPE_STATION || |
| 385 | sc->sc_ah->ah_opmode == NL80211_IFTYPE_ADHOC) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 386 | rfilt |= ATH9K_RX_FILTER_BEACON; |
| 387 | |
| 388 | /* If in HOSTAP mode, want to enable reception of PSPOLL frames |
| 389 | & beacon frames */ |
Colin McCabe | d97809d | 2008-12-01 13:38:55 -0800 | [diff] [blame] | 390 | if (sc->sc_ah->ah_opmode == NL80211_IFTYPE_AP) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 391 | rfilt |= (ATH9K_RX_FILTER_BEACON | ATH9K_RX_FILTER_PSPOLL); |
Sujith | be0418a | 2008-11-18 09:05:55 +0530 | [diff] [blame] | 392 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 393 | return rfilt; |
Sujith | 7dcfdcd | 2008-08-11 14:03:13 +0530 | [diff] [blame] | 394 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 395 | #undef RX_FILTER_PRESERVE |
| 396 | } |
| 397 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 398 | int ath_startrecv(struct ath_softc *sc) |
| 399 | { |
| 400 | struct ath_hal *ah = sc->sc_ah; |
| 401 | struct ath_buf *bf, *tbf; |
| 402 | |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 403 | spin_lock_bh(&sc->rx.rxbuflock); |
| 404 | if (list_empty(&sc->rx.rxbuf)) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 405 | goto start_recv; |
| 406 | |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 407 | sc->rx.rxlink = NULL; |
| 408 | list_for_each_entry_safe(bf, tbf, &sc->rx.rxbuf, list) { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 409 | ath_rx_buf_link(sc, bf); |
| 410 | } |
| 411 | |
| 412 | /* We could have deleted elements so the list may be empty now */ |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 413 | if (list_empty(&sc->rx.rxbuf)) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 414 | goto start_recv; |
| 415 | |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 416 | bf = list_first_entry(&sc->rx.rxbuf, struct ath_buf, list); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 417 | ath9k_hw_putrxbuf(ah, bf->bf_daddr); |
Sujith | be0418a | 2008-11-18 09:05:55 +0530 | [diff] [blame] | 418 | ath9k_hw_rxena(ah); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 419 | |
| 420 | start_recv: |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 421 | spin_unlock_bh(&sc->rx.rxbuflock); |
Sujith | be0418a | 2008-11-18 09:05:55 +0530 | [diff] [blame] | 422 | ath_opmode_init(sc); |
| 423 | ath9k_hw_startpcureceive(ah); |
| 424 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 425 | return 0; |
| 426 | } |
| 427 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 428 | bool ath_stoprecv(struct ath_softc *sc) |
| 429 | { |
| 430 | struct ath_hal *ah = sc->sc_ah; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 431 | bool stopped; |
| 432 | |
Sujith | be0418a | 2008-11-18 09:05:55 +0530 | [diff] [blame] | 433 | ath9k_hw_stoppcurecv(ah); |
| 434 | ath9k_hw_setrxfilter(ah, 0); |
| 435 | stopped = ath9k_hw_stopdmarecv(ah); |
| 436 | mdelay(3); /* 3ms is long enough for 1 frame */ |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 437 | sc->rx.rxlink = NULL; |
Sujith | be0418a | 2008-11-18 09:05:55 +0530 | [diff] [blame] | 438 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 439 | return stopped; |
| 440 | } |
| 441 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 442 | void ath_flushrecv(struct ath_softc *sc) |
| 443 | { |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 444 | spin_lock_bh(&sc->rx.rxflushlock); |
Sujith | 98deeea | 2008-08-11 14:05:46 +0530 | [diff] [blame] | 445 | sc->sc_flags |= SC_OP_RXFLUSH; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 446 | ath_rx_tasklet(sc, 1); |
Sujith | 98deeea | 2008-08-11 14:05:46 +0530 | [diff] [blame] | 447 | sc->sc_flags &= ~SC_OP_RXFLUSH; |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 448 | spin_unlock_bh(&sc->rx.rxflushlock); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 449 | } |
| 450 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 451 | int ath_rx_tasklet(struct ath_softc *sc, int flush) |
| 452 | { |
| 453 | #define PA2DESC(_sc, _pa) \ |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 454 | ((struct ath_desc *)((caddr_t)(_sc)->rx.rxdma.dd_desc + \ |
| 455 | ((_pa) - (_sc)->rx.rxdma.dd_desc_paddr))) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 456 | |
Sujith | be0418a | 2008-11-18 09:05:55 +0530 | [diff] [blame] | 457 | struct ath_buf *bf; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 458 | struct ath_desc *ds; |
Luis R. Rodriguez | cb71d9b | 2008-11-21 17:41:33 -0800 | [diff] [blame] | 459 | struct sk_buff *skb = NULL, *requeue_skb; |
Sujith | be0418a | 2008-11-18 09:05:55 +0530 | [diff] [blame] | 460 | struct ieee80211_rx_status rx_status; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 461 | struct ath_hal *ah = sc->sc_ah; |
Sujith | be0418a | 2008-11-18 09:05:55 +0530 | [diff] [blame] | 462 | struct ieee80211_hdr *hdr; |
| 463 | int hdrlen, padsize, retval; |
| 464 | bool decrypt_error = false; |
| 465 | u8 keyix; |
| 466 | |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 467 | spin_lock_bh(&sc->rx.rxbuflock); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 468 | |
| 469 | do { |
| 470 | /* If handling rx interrupt and flush is in progress => exit */ |
Sujith | 98deeea | 2008-08-11 14:05:46 +0530 | [diff] [blame] | 471 | if ((sc->sc_flags & SC_OP_RXFLUSH) && (flush == 0)) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 472 | break; |
| 473 | |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 474 | if (list_empty(&sc->rx.rxbuf)) { |
| 475 | sc->rx.rxlink = NULL; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 476 | break; |
| 477 | } |
| 478 | |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 479 | bf = list_first_entry(&sc->rx.rxbuf, struct ath_buf, list); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 480 | ds = bf->bf_desc; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 481 | |
| 482 | /* |
| 483 | * Must provide the virtual address of the current |
| 484 | * descriptor, the physical address, and the virtual |
| 485 | * address of the next descriptor in the h/w chain. |
| 486 | * This allows the HAL to look ahead to see if the |
| 487 | * hardware is done with a descriptor by checking the |
| 488 | * done bit in the following descriptor and the address |
| 489 | * of the current descriptor the DMA engine is working |
| 490 | * on. All this is necessary because of our use of |
| 491 | * a self-linked list to avoid rx overruns. |
| 492 | */ |
Sujith | be0418a | 2008-11-18 09:05:55 +0530 | [diff] [blame] | 493 | retval = ath9k_hw_rxprocdesc(ah, ds, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 494 | bf->bf_daddr, |
| 495 | PA2DESC(sc, ds->ds_link), |
| 496 | 0); |
| 497 | if (retval == -EINPROGRESS) { |
| 498 | struct ath_buf *tbf; |
| 499 | struct ath_desc *tds; |
| 500 | |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 501 | if (list_is_last(&bf->list, &sc->rx.rxbuf)) { |
| 502 | sc->rx.rxlink = NULL; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 503 | break; |
| 504 | } |
| 505 | |
| 506 | tbf = list_entry(bf->list.next, struct ath_buf, list); |
| 507 | |
| 508 | /* |
| 509 | * On some hardware the descriptor status words could |
| 510 | * get corrupted, including the done bit. Because of |
| 511 | * this, check if the next descriptor's done bit is |
| 512 | * set or not. |
| 513 | * |
| 514 | * If the next descriptor's done bit is set, the current |
| 515 | * descriptor has been corrupted. Force s/w to discard |
| 516 | * this descriptor and continue... |
| 517 | */ |
| 518 | |
| 519 | tds = tbf->bf_desc; |
Sujith | be0418a | 2008-11-18 09:05:55 +0530 | [diff] [blame] | 520 | retval = ath9k_hw_rxprocdesc(ah, tds, tbf->bf_daddr, |
| 521 | PA2DESC(sc, tds->ds_link), 0); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 522 | if (retval == -EINPROGRESS) { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 523 | break; |
| 524 | } |
| 525 | } |
| 526 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 527 | skb = bf->bf_mpdu; |
Sujith | be0418a | 2008-11-18 09:05:55 +0530 | [diff] [blame] | 528 | if (!skb) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 529 | continue; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 530 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 531 | /* |
Sujith | be0418a | 2008-11-18 09:05:55 +0530 | [diff] [blame] | 532 | * If we're asked to flush receive queue, directly |
| 533 | * chain it back at the queue without processing it. |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 534 | */ |
Sujith | be0418a | 2008-11-18 09:05:55 +0530 | [diff] [blame] | 535 | if (flush) |
Luis R. Rodriguez | cb71d9b | 2008-11-21 17:41:33 -0800 | [diff] [blame] | 536 | goto requeue; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 537 | |
Sujith | be0418a | 2008-11-18 09:05:55 +0530 | [diff] [blame] | 538 | if (!ds->ds_rxstat.rs_datalen) |
Luis R. Rodriguez | cb71d9b | 2008-11-21 17:41:33 -0800 | [diff] [blame] | 539 | goto requeue; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 540 | |
Sujith | be0418a | 2008-11-18 09:05:55 +0530 | [diff] [blame] | 541 | /* The status portion of the descriptor could get corrupted. */ |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 542 | if (sc->rx.bufsize < ds->ds_rxstat.rs_datalen) |
Luis R. Rodriguez | cb71d9b | 2008-11-21 17:41:33 -0800 | [diff] [blame] | 543 | goto requeue; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 544 | |
Sujith | be0418a | 2008-11-18 09:05:55 +0530 | [diff] [blame] | 545 | if (!ath_rx_prepare(skb, ds, &rx_status, &decrypt_error, sc)) |
Luis R. Rodriguez | cb71d9b | 2008-11-21 17:41:33 -0800 | [diff] [blame] | 546 | goto requeue; |
| 547 | |
| 548 | /* Ensure we always have an skb to requeue once we are done |
| 549 | * processing the current buffer's skb */ |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 550 | requeue_skb = ath_rxbuf_alloc(sc, sc->rx.bufsize); |
Luis R. Rodriguez | cb71d9b | 2008-11-21 17:41:33 -0800 | [diff] [blame] | 551 | |
| 552 | /* If there is no memory we ignore the current RX'd frame, |
| 553 | * tell hardware it can give us a new frame using the old |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 554 | * skb and put it at the tail of the sc->rx.rxbuf list for |
Luis R. Rodriguez | cb71d9b | 2008-11-21 17:41:33 -0800 | [diff] [blame] | 555 | * processing. */ |
| 556 | if (!requeue_skb) |
| 557 | goto requeue; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 558 | |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 559 | /* Sync and unmap the frame */ |
| 560 | pci_dma_sync_single_for_cpu(sc->pdev, bf->bf_buf_addr, |
| 561 | sc->rx.bufsize, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 562 | PCI_DMA_FROMDEVICE); |
Sujith | be0418a | 2008-11-18 09:05:55 +0530 | [diff] [blame] | 563 | pci_unmap_single(sc->pdev, bf->bf_buf_addr, |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 564 | sc->rx.bufsize, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 565 | PCI_DMA_FROMDEVICE); |
| 566 | |
Sujith | be0418a | 2008-11-18 09:05:55 +0530 | [diff] [blame] | 567 | skb_put(skb, ds->ds_rxstat.rs_datalen); |
| 568 | skb->protocol = cpu_to_be16(ETH_P_CONTROL); |
| 569 | |
| 570 | /* see if any padding is done by the hw and remove it */ |
| 571 | hdr = (struct ieee80211_hdr *)skb->data; |
| 572 | hdrlen = ieee80211_get_hdrlen_from_skb(skb); |
| 573 | |
| 574 | if (hdrlen & 3) { |
| 575 | padsize = hdrlen % 4; |
| 576 | memmove(skb->data + padsize, skb->data, hdrlen); |
| 577 | skb_pull(skb, padsize); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 578 | } |
| 579 | |
Sujith | be0418a | 2008-11-18 09:05:55 +0530 | [diff] [blame] | 580 | keyix = ds->ds_rxstat.rs_keyix; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 581 | |
Sujith | be0418a | 2008-11-18 09:05:55 +0530 | [diff] [blame] | 582 | if (!(keyix == ATH9K_RXKEYIX_INVALID) && !decrypt_error) { |
| 583 | rx_status.flag |= RX_FLAG_DECRYPTED; |
| 584 | } else if ((le16_to_cpu(hdr->frame_control) & IEEE80211_FCTL_PROTECTED) |
| 585 | && !decrypt_error && skb->len >= hdrlen + 4) { |
| 586 | keyix = skb->data[hdrlen + 3] >> 6; |
| 587 | |
| 588 | if (test_bit(keyix, sc->sc_keymap)) |
| 589 | rx_status.flag |= RX_FLAG_DECRYPTED; |
| 590 | } |
| 591 | |
| 592 | /* Send the frame to mac80211 */ |
| 593 | __ieee80211_rx(sc->hw, skb, &rx_status); |
Luis R. Rodriguez | cb71d9b | 2008-11-21 17:41:33 -0800 | [diff] [blame] | 594 | |
| 595 | /* We will now give hardware our shiny new allocated skb */ |
| 596 | bf->bf_mpdu = requeue_skb; |
| 597 | bf->bf_buf_addr = pci_map_single(sc->pdev, requeue_skb->data, |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 598 | sc->rx.bufsize, |
Luis R. Rodriguez | cb71d9b | 2008-11-21 17:41:33 -0800 | [diff] [blame] | 599 | PCI_DMA_FROMDEVICE); |
Luis R. Rodriguez | f8316df | 2008-12-03 03:35:29 -0800 | [diff] [blame] | 600 | if (unlikely(pci_dma_mapping_error(sc->pdev, |
| 601 | bf->bf_buf_addr))) { |
| 602 | dev_kfree_skb_any(requeue_skb); |
| 603 | bf->bf_mpdu = NULL; |
| 604 | DPRINTF(sc, ATH_DBG_CONFIG, |
| 605 | "pci_dma_mapping_error() on RX\n"); |
| 606 | break; |
| 607 | } |
Luis R. Rodriguez | cb71d9b | 2008-11-21 17:41:33 -0800 | [diff] [blame] | 608 | bf->bf_dmacontext = bf->bf_buf_addr; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 609 | |
| 610 | /* |
| 611 | * change the default rx antenna if rx diversity chooses the |
| 612 | * other antenna 3 times in a row. |
| 613 | */ |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 614 | if (sc->rx.defant != ds->ds_rxstat.rs_antenna) { |
| 615 | if (++sc->rx.rxotherant >= 3) |
Sujith | be0418a | 2008-11-18 09:05:55 +0530 | [diff] [blame] | 616 | ath_setdefantenna(sc, ds->ds_rxstat.rs_antenna); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 617 | } else { |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 618 | sc->rx.rxotherant = 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 619 | } |
Luis R. Rodriguez | cb71d9b | 2008-11-21 17:41:33 -0800 | [diff] [blame] | 620 | requeue: |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 621 | list_move_tail(&bf->list, &sc->rx.rxbuf); |
Luis R. Rodriguez | cb71d9b | 2008-11-21 17:41:33 -0800 | [diff] [blame] | 622 | ath_rx_buf_link(sc, bf); |
Sujith | be0418a | 2008-11-18 09:05:55 +0530 | [diff] [blame] | 623 | } while (1); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 624 | |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame^] | 625 | spin_unlock_bh(&sc->rx.rxbuflock); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 626 | |
| 627 | return 0; |
| 628 | #undef PA2DESC |
| 629 | } |