Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1 | /* |
Sujith | cee075a | 2009-03-13 09:07:23 +0530 | [diff] [blame] | 2 | * Copyright (c) 2008-2009 Atheros Communications Inc. |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 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 | 990b70a | 2009-09-13 23:55:05 -0700 | [diff] [blame] | 17 | #include "hw.h" |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 18 | |
Vasanthakumar Thiagarajan | cee1f62 | 2010-04-15 17:38:26 -0400 | [diff] [blame] | 19 | static void ar9002_hw_rx_enable(struct ath_hw *ah) |
| 20 | { |
| 21 | REG_WRITE(ah, AR_CR, AR_CR_RXE); |
| 22 | } |
| 23 | |
Vasanthakumar Thiagarajan | 87d5efb | 2010-04-15 17:38:43 -0400 | [diff] [blame] | 24 | static void ar9002_hw_set_desc_link(void *ds, u32 ds_link) |
| 25 | { |
| 26 | ((struct ath_desc *) ds)->ds_link = ds_link; |
| 27 | } |
| 28 | |
| 29 | static void ar9002_hw_get_desc_link(void *ds, u32 **ds_link) |
| 30 | { |
| 31 | *ds_link = &((struct ath_desc *)ds)->ds_link; |
| 32 | } |
| 33 | |
Vasanthakumar Thiagarajan | 55e82df | 2010-04-15 17:39:06 -0400 | [diff] [blame^] | 34 | static bool ar9002_hw_get_isr(struct ath_hw *ah, enum ath9k_int *masked) |
| 35 | { |
| 36 | u32 isr = 0; |
| 37 | u32 mask2 = 0; |
| 38 | struct ath9k_hw_capabilities *pCap = &ah->caps; |
| 39 | u32 sync_cause = 0; |
| 40 | bool fatal_int = false; |
| 41 | struct ath_common *common = ath9k_hw_common(ah); |
| 42 | |
| 43 | if (!AR_SREV_9100(ah)) { |
| 44 | if (REG_READ(ah, AR_INTR_ASYNC_CAUSE) & AR_INTR_MAC_IRQ) { |
| 45 | if ((REG_READ(ah, AR_RTC_STATUS) & AR_RTC_STATUS_M) |
| 46 | == AR_RTC_STATUS_ON) { |
| 47 | isr = REG_READ(ah, AR_ISR); |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | sync_cause = REG_READ(ah, AR_INTR_SYNC_CAUSE) & |
| 52 | AR_INTR_SYNC_DEFAULT; |
| 53 | |
| 54 | *masked = 0; |
| 55 | |
| 56 | if (!isr && !sync_cause) |
| 57 | return false; |
| 58 | } else { |
| 59 | *masked = 0; |
| 60 | isr = REG_READ(ah, AR_ISR); |
| 61 | } |
| 62 | |
| 63 | if (isr) { |
| 64 | if (isr & AR_ISR_BCNMISC) { |
| 65 | u32 isr2; |
| 66 | isr2 = REG_READ(ah, AR_ISR_S2); |
| 67 | if (isr2 & AR_ISR_S2_TIM) |
| 68 | mask2 |= ATH9K_INT_TIM; |
| 69 | if (isr2 & AR_ISR_S2_DTIM) |
| 70 | mask2 |= ATH9K_INT_DTIM; |
| 71 | if (isr2 & AR_ISR_S2_DTIMSYNC) |
| 72 | mask2 |= ATH9K_INT_DTIMSYNC; |
| 73 | if (isr2 & (AR_ISR_S2_CABEND)) |
| 74 | mask2 |= ATH9K_INT_CABEND; |
| 75 | if (isr2 & AR_ISR_S2_GTT) |
| 76 | mask2 |= ATH9K_INT_GTT; |
| 77 | if (isr2 & AR_ISR_S2_CST) |
| 78 | mask2 |= ATH9K_INT_CST; |
| 79 | if (isr2 & AR_ISR_S2_TSFOOR) |
| 80 | mask2 |= ATH9K_INT_TSFOOR; |
| 81 | } |
| 82 | |
| 83 | isr = REG_READ(ah, AR_ISR_RAC); |
| 84 | if (isr == 0xffffffff) { |
| 85 | *masked = 0; |
| 86 | return false; |
| 87 | } |
| 88 | |
| 89 | *masked = isr & ATH9K_INT_COMMON; |
| 90 | |
| 91 | if (ah->config.rx_intr_mitigation) { |
| 92 | if (isr & (AR_ISR_RXMINTR | AR_ISR_RXINTM)) |
| 93 | *masked |= ATH9K_INT_RX; |
| 94 | } |
| 95 | |
| 96 | if (isr & (AR_ISR_RXOK | AR_ISR_RXERR)) |
| 97 | *masked |= ATH9K_INT_RX; |
| 98 | if (isr & |
| 99 | (AR_ISR_TXOK | AR_ISR_TXDESC | AR_ISR_TXERR | |
| 100 | AR_ISR_TXEOL)) { |
| 101 | u32 s0_s, s1_s; |
| 102 | |
| 103 | *masked |= ATH9K_INT_TX; |
| 104 | |
| 105 | s0_s = REG_READ(ah, AR_ISR_S0_S); |
| 106 | ah->intr_txqs |= MS(s0_s, AR_ISR_S0_QCU_TXOK); |
| 107 | ah->intr_txqs |= MS(s0_s, AR_ISR_S0_QCU_TXDESC); |
| 108 | |
| 109 | s1_s = REG_READ(ah, AR_ISR_S1_S); |
| 110 | ah->intr_txqs |= MS(s1_s, AR_ISR_S1_QCU_TXERR); |
| 111 | ah->intr_txqs |= MS(s1_s, AR_ISR_S1_QCU_TXEOL); |
| 112 | } |
| 113 | |
| 114 | if (isr & AR_ISR_RXORN) { |
| 115 | ath_print(common, ATH_DBG_INTERRUPT, |
| 116 | "receive FIFO overrun interrupt\n"); |
| 117 | } |
| 118 | |
| 119 | if (!AR_SREV_9100(ah)) { |
| 120 | if (!(pCap->hw_caps & ATH9K_HW_CAP_AUTOSLEEP)) { |
| 121 | u32 isr5 = REG_READ(ah, AR_ISR_S5_S); |
| 122 | if (isr5 & AR_ISR_S5_TIM_TIMER) |
| 123 | *masked |= ATH9K_INT_TIM_TIMER; |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | *masked |= mask2; |
| 128 | } |
| 129 | |
| 130 | if (AR_SREV_9100(ah)) |
| 131 | return true; |
| 132 | |
| 133 | if (isr & AR_ISR_GENTMR) { |
| 134 | u32 s5_s; |
| 135 | |
| 136 | s5_s = REG_READ(ah, AR_ISR_S5_S); |
| 137 | if (isr & AR_ISR_GENTMR) { |
| 138 | ah->intr_gen_timer_trigger = |
| 139 | MS(s5_s, AR_ISR_S5_GENTIMER_TRIG); |
| 140 | |
| 141 | ah->intr_gen_timer_thresh = |
| 142 | MS(s5_s, AR_ISR_S5_GENTIMER_THRESH); |
| 143 | |
| 144 | if (ah->intr_gen_timer_trigger) |
| 145 | *masked |= ATH9K_INT_GENTIMER; |
| 146 | |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | if (sync_cause) { |
| 151 | fatal_int = |
| 152 | (sync_cause & |
| 153 | (AR_INTR_SYNC_HOST1_FATAL | AR_INTR_SYNC_HOST1_PERR)) |
| 154 | ? true : false; |
| 155 | |
| 156 | if (fatal_int) { |
| 157 | if (sync_cause & AR_INTR_SYNC_HOST1_FATAL) { |
| 158 | ath_print(common, ATH_DBG_ANY, |
| 159 | "received PCI FATAL interrupt\n"); |
| 160 | } |
| 161 | if (sync_cause & AR_INTR_SYNC_HOST1_PERR) { |
| 162 | ath_print(common, ATH_DBG_ANY, |
| 163 | "received PCI PERR interrupt\n"); |
| 164 | } |
| 165 | *masked |= ATH9K_INT_FATAL; |
| 166 | } |
| 167 | if (sync_cause & AR_INTR_SYNC_RADM_CPL_TIMEOUT) { |
| 168 | ath_print(common, ATH_DBG_INTERRUPT, |
| 169 | "AR_INTR_SYNC_RADM_CPL_TIMEOUT\n"); |
| 170 | REG_WRITE(ah, AR_RC, AR_RC_HOSTIF); |
| 171 | REG_WRITE(ah, AR_RC, 0); |
| 172 | *masked |= ATH9K_INT_FATAL; |
| 173 | } |
| 174 | if (sync_cause & AR_INTR_SYNC_LOCAL_TIMEOUT) { |
| 175 | ath_print(common, ATH_DBG_INTERRUPT, |
| 176 | "AR_INTR_SYNC_LOCAL_TIMEOUT\n"); |
| 177 | } |
| 178 | |
| 179 | REG_WRITE(ah, AR_INTR_SYNC_CAUSE_CLR, sync_cause); |
| 180 | (void) REG_READ(ah, AR_INTR_SYNC_CAUSE_CLR); |
| 181 | } |
| 182 | |
| 183 | return true; |
| 184 | } |
| 185 | |
Vasanthakumar Thiagarajan | cee1f62 | 2010-04-15 17:38:26 -0400 | [diff] [blame] | 186 | void ar9002_hw_attach_mac_ops(struct ath_hw *ah) |
| 187 | { |
| 188 | struct ath_hw_ops *ops = ath9k_hw_ops(ah); |
| 189 | |
| 190 | ops->rx_enable = ar9002_hw_rx_enable; |
Vasanthakumar Thiagarajan | 87d5efb | 2010-04-15 17:38:43 -0400 | [diff] [blame] | 191 | ops->set_desc_link = ar9002_hw_set_desc_link; |
| 192 | ops->get_desc_link = ar9002_hw_get_desc_link; |
Vasanthakumar Thiagarajan | 55e82df | 2010-04-15 17:39:06 -0400 | [diff] [blame^] | 193 | ops->get_isr = ar9002_hw_get_isr; |
Vasanthakumar Thiagarajan | cee1f62 | 2010-04-15 17:38:26 -0400 | [diff] [blame] | 194 | } |
Vasanthakumar Thiagarajan | 87d5efb | 2010-04-15 17:38:43 -0400 | [diff] [blame] | 195 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 196 | static void ath9k_hw_set_txq_interrupts(struct ath_hw *ah, |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 197 | struct ath9k_tx_queue_info *qi) |
| 198 | { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 199 | ath_print(ath9k_hw_common(ah), ATH_DBG_INTERRUPT, |
| 200 | "tx ok 0x%x err 0x%x desc 0x%x eol 0x%x urn 0x%x\n", |
| 201 | ah->txok_interrupt_mask, ah->txerr_interrupt_mask, |
| 202 | ah->txdesc_interrupt_mask, ah->txeol_interrupt_mask, |
| 203 | ah->txurn_interrupt_mask); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 204 | |
| 205 | REG_WRITE(ah, AR_IMR_S0, |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 206 | SM(ah->txok_interrupt_mask, AR_IMR_S0_QCU_TXOK) |
| 207 | | SM(ah->txdesc_interrupt_mask, AR_IMR_S0_QCU_TXDESC)); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 208 | REG_WRITE(ah, AR_IMR_S1, |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 209 | SM(ah->txerr_interrupt_mask, AR_IMR_S1_QCU_TXERR) |
| 210 | | SM(ah->txeol_interrupt_mask, AR_IMR_S1_QCU_TXEOL)); |
Pavel Roskin | 74bad5c | 2010-02-23 18:15:27 -0500 | [diff] [blame] | 211 | |
| 212 | ah->imrs2_reg &= ~AR_IMR_S2_QCU_TXURN; |
| 213 | ah->imrs2_reg |= (ah->txurn_interrupt_mask & AR_IMR_S2_QCU_TXURN); |
| 214 | REG_WRITE(ah, AR_IMR_S2, ah->imrs2_reg); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 215 | } |
| 216 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 217 | u32 ath9k_hw_gettxbuf(struct ath_hw *ah, u32 q) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 218 | { |
| 219 | return REG_READ(ah, AR_QTXDP(q)); |
| 220 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 221 | EXPORT_SYMBOL(ath9k_hw_gettxbuf); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 222 | |
Sujith | 54e4cec | 2009-08-07 09:45:09 +0530 | [diff] [blame] | 223 | void ath9k_hw_puttxbuf(struct ath_hw *ah, u32 q, u32 txdp) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 224 | { |
| 225 | REG_WRITE(ah, AR_QTXDP(q), txdp); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 226 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 227 | EXPORT_SYMBOL(ath9k_hw_puttxbuf); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 228 | |
Sujith | 54e4cec | 2009-08-07 09:45:09 +0530 | [diff] [blame] | 229 | void ath9k_hw_txstart(struct ath_hw *ah, u32 q) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 230 | { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 231 | ath_print(ath9k_hw_common(ah), ATH_DBG_QUEUE, |
| 232 | "Enable TXE on queue: %u\n", q); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 233 | REG_WRITE(ah, AR_Q_TXE, 1 << q); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 234 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 235 | EXPORT_SYMBOL(ath9k_hw_txstart); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 236 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 237 | u32 ath9k_hw_numtxpending(struct ath_hw *ah, u32 q) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 238 | { |
| 239 | u32 npend; |
| 240 | |
| 241 | npend = REG_READ(ah, AR_QSTS(q)) & AR_Q_STS_PEND_FR_CNT; |
| 242 | if (npend == 0) { |
| 243 | |
| 244 | if (REG_READ(ah, AR_Q_TXE) & (1 << q)) |
| 245 | npend = 1; |
| 246 | } |
| 247 | |
| 248 | return npend; |
| 249 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 250 | EXPORT_SYMBOL(ath9k_hw_numtxpending); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 251 | |
Luis R. Rodriguez | f4709fd | 2009-11-24 21:37:57 -0500 | [diff] [blame] | 252 | /** |
| 253 | * ath9k_hw_updatetxtriglevel - adjusts the frame trigger level |
| 254 | * |
| 255 | * @ah: atheros hardware struct |
| 256 | * @bIncTrigLevel: whether or not the frame trigger level should be updated |
| 257 | * |
| 258 | * The frame trigger level specifies the minimum number of bytes, |
| 259 | * in units of 64 bytes, that must be DMA'ed into the PCU TX FIFO |
| 260 | * before the PCU will initiate sending the frame on the air. This can |
| 261 | * mean we initiate transmit before a full frame is on the PCU TX FIFO. |
| 262 | * Resets to 0x1 (meaning 64 bytes or a full frame, whichever occurs |
| 263 | * first) |
| 264 | * |
| 265 | * Caution must be taken to ensure to set the frame trigger level based |
| 266 | * on the DMA request size. For example if the DMA request size is set to |
| 267 | * 128 bytes the trigger level cannot exceed 6 * 64 = 384. This is because |
| 268 | * there need to be enough space in the tx FIFO for the requested transfer |
| 269 | * size. Hence the tx FIFO will stop with 512 - 128 = 384 bytes. If we set |
| 270 | * the threshold to a value beyond 6, then the transmit will hang. |
| 271 | * |
| 272 | * Current dual stream devices have a PCU TX FIFO size of 8 KB. |
| 273 | * Current single stream devices have a PCU TX FIFO size of 4 KB, however, |
| 274 | * there is a hardware issue which forces us to use 2 KB instead so the |
| 275 | * frame trigger level must not exceed 2 KB for these chipsets. |
| 276 | */ |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 277 | bool ath9k_hw_updatetxtriglevel(struct ath_hw *ah, bool bIncTrigLevel) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 278 | { |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 279 | u32 txcfg, curLevel, newLevel; |
| 280 | enum ath9k_int omask; |
| 281 | |
Luis R. Rodriguez | f4709fd | 2009-11-24 21:37:57 -0500 | [diff] [blame] | 282 | if (ah->tx_trig_level >= ah->config.max_txtrig_level) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 283 | return false; |
| 284 | |
Pavel Roskin | 152d530 | 2010-03-31 18:05:37 -0400 | [diff] [blame] | 285 | omask = ath9k_hw_set_interrupts(ah, ah->imask & ~ATH9K_INT_GLOBAL); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 286 | |
| 287 | txcfg = REG_READ(ah, AR_TXCFG); |
| 288 | curLevel = MS(txcfg, AR_FTRIG); |
| 289 | newLevel = curLevel; |
| 290 | if (bIncTrigLevel) { |
Luis R. Rodriguez | f4709fd | 2009-11-24 21:37:57 -0500 | [diff] [blame] | 291 | if (curLevel < ah->config.max_txtrig_level) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 292 | newLevel++; |
| 293 | } else if (curLevel > MIN_TX_FIFO_THRESHOLD) |
| 294 | newLevel--; |
| 295 | if (newLevel != curLevel) |
| 296 | REG_WRITE(ah, AR_TXCFG, |
| 297 | (txcfg & ~AR_FTRIG) | SM(newLevel, AR_FTRIG)); |
| 298 | |
| 299 | ath9k_hw_set_interrupts(ah, omask); |
| 300 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 301 | ah->tx_trig_level = newLevel; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 302 | |
| 303 | return newLevel != curLevel; |
| 304 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 305 | EXPORT_SYMBOL(ath9k_hw_updatetxtriglevel); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 306 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 307 | bool ath9k_hw_stoptxdma(struct ath_hw *ah, u32 q) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 308 | { |
Sujith | 94ff91d | 2009-01-27 15:06:38 +0530 | [diff] [blame] | 309 | #define ATH9K_TX_STOP_DMA_TIMEOUT 4000 /* usec */ |
| 310 | #define ATH9K_TIME_QUANTUM 100 /* usec */ |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 311 | struct ath_common *common = ath9k_hw_common(ah); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 312 | struct ath9k_hw_capabilities *pCap = &ah->caps; |
Sujith | 94ff91d | 2009-01-27 15:06:38 +0530 | [diff] [blame] | 313 | struct ath9k_tx_queue_info *qi; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 314 | u32 tsfLow, j, wait; |
Sujith | 94ff91d | 2009-01-27 15:06:38 +0530 | [diff] [blame] | 315 | u32 wait_time = ATH9K_TX_STOP_DMA_TIMEOUT / ATH9K_TIME_QUANTUM; |
| 316 | |
| 317 | if (q >= pCap->total_queues) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 318 | ath_print(common, ATH_DBG_QUEUE, "Stopping TX DMA, " |
| 319 | "invalid queue: %u\n", q); |
Sujith | 94ff91d | 2009-01-27 15:06:38 +0530 | [diff] [blame] | 320 | return false; |
| 321 | } |
| 322 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 323 | qi = &ah->txq[q]; |
Sujith | 94ff91d | 2009-01-27 15:06:38 +0530 | [diff] [blame] | 324 | if (qi->tqi_type == ATH9K_TX_QUEUE_INACTIVE) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 325 | ath_print(common, ATH_DBG_QUEUE, "Stopping TX DMA, " |
| 326 | "inactive queue: %u\n", q); |
Sujith | 94ff91d | 2009-01-27 15:06:38 +0530 | [diff] [blame] | 327 | return false; |
| 328 | } |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 329 | |
| 330 | REG_WRITE(ah, AR_Q_TXD, 1 << q); |
| 331 | |
Sujith | 94ff91d | 2009-01-27 15:06:38 +0530 | [diff] [blame] | 332 | for (wait = wait_time; wait != 0; wait--) { |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 333 | if (ath9k_hw_numtxpending(ah, q) == 0) |
| 334 | break; |
Sujith | 94ff91d | 2009-01-27 15:06:38 +0530 | [diff] [blame] | 335 | udelay(ATH9K_TIME_QUANTUM); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 336 | } |
| 337 | |
| 338 | if (ath9k_hw_numtxpending(ah, q)) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 339 | ath_print(common, ATH_DBG_QUEUE, |
| 340 | "%s: Num of pending TX Frames %d on Q %d\n", |
| 341 | __func__, ath9k_hw_numtxpending(ah, q), q); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 342 | |
| 343 | for (j = 0; j < 2; j++) { |
| 344 | tsfLow = REG_READ(ah, AR_TSF_L32); |
| 345 | REG_WRITE(ah, AR_QUIET2, |
| 346 | SM(10, AR_QUIET2_QUIET_DUR)); |
| 347 | REG_WRITE(ah, AR_QUIET_PERIOD, 100); |
| 348 | REG_WRITE(ah, AR_NEXT_QUIET_TIMER, tsfLow >> 10); |
| 349 | REG_SET_BIT(ah, AR_TIMER_MODE, |
| 350 | AR_QUIET_TIMER_EN); |
| 351 | |
| 352 | if ((REG_READ(ah, AR_TSF_L32) >> 10) == (tsfLow >> 10)) |
| 353 | break; |
| 354 | |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 355 | ath_print(common, ATH_DBG_QUEUE, |
| 356 | "TSF has moved while trying to set " |
| 357 | "quiet time TSF: 0x%08x\n", tsfLow); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 358 | } |
| 359 | |
| 360 | REG_SET_BIT(ah, AR_DIAG_SW, AR_DIAG_FORCE_CH_IDLE_HIGH); |
| 361 | |
| 362 | udelay(200); |
| 363 | REG_CLR_BIT(ah, AR_TIMER_MODE, AR_QUIET_TIMER_EN); |
| 364 | |
Sujith | 94ff91d | 2009-01-27 15:06:38 +0530 | [diff] [blame] | 365 | wait = wait_time; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 366 | while (ath9k_hw_numtxpending(ah, q)) { |
| 367 | if ((--wait) == 0) { |
Sujith | e8009e9 | 2009-12-14 14:57:08 +0530 | [diff] [blame] | 368 | ath_print(common, ATH_DBG_FATAL, |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 369 | "Failed to stop TX DMA in 100 " |
| 370 | "msec after killing last frame\n"); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 371 | break; |
| 372 | } |
Sujith | 94ff91d | 2009-01-27 15:06:38 +0530 | [diff] [blame] | 373 | udelay(ATH9K_TIME_QUANTUM); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 374 | } |
| 375 | |
| 376 | REG_CLR_BIT(ah, AR_DIAG_SW, AR_DIAG_FORCE_CH_IDLE_HIGH); |
| 377 | } |
| 378 | |
| 379 | REG_WRITE(ah, AR_Q_TXD, 0); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 380 | return wait != 0; |
Sujith | 94ff91d | 2009-01-27 15:06:38 +0530 | [diff] [blame] | 381 | |
| 382 | #undef ATH9K_TX_STOP_DMA_TIMEOUT |
| 383 | #undef ATH9K_TIME_QUANTUM |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 384 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 385 | EXPORT_SYMBOL(ath9k_hw_stoptxdma); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 386 | |
Sujith | 54e4cec | 2009-08-07 09:45:09 +0530 | [diff] [blame] | 387 | void ath9k_hw_filltxdesc(struct ath_hw *ah, struct ath_desc *ds, |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 388 | u32 segLen, bool firstSeg, |
Vasanthakumar Thiagarajan | 3f3a1c8 | 2010-04-15 17:38:42 -0400 | [diff] [blame] | 389 | bool lastSeg, const struct ath_desc *ds0, |
| 390 | dma_addr_t buf_addr) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 391 | { |
| 392 | struct ar5416_desc *ads = AR5416DESC(ds); |
| 393 | |
Vasanthakumar Thiagarajan | 3f3a1c8 | 2010-04-15 17:38:42 -0400 | [diff] [blame] | 394 | ads->ds_data = buf_addr; |
| 395 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 396 | if (firstSeg) { |
| 397 | ads->ds_ctl1 |= segLen | (lastSeg ? 0 : AR_TxMore); |
| 398 | } else if (lastSeg) { |
| 399 | ads->ds_ctl0 = 0; |
| 400 | ads->ds_ctl1 = segLen; |
| 401 | ads->ds_ctl2 = AR5416DESC_CONST(ds0)->ds_ctl2; |
| 402 | ads->ds_ctl3 = AR5416DESC_CONST(ds0)->ds_ctl3; |
| 403 | } else { |
| 404 | ads->ds_ctl0 = 0; |
| 405 | ads->ds_ctl1 = segLen | AR_TxMore; |
| 406 | ads->ds_ctl2 = 0; |
| 407 | ads->ds_ctl3 = 0; |
| 408 | } |
| 409 | ads->ds_txstatus0 = ads->ds_txstatus1 = 0; |
| 410 | ads->ds_txstatus2 = ads->ds_txstatus3 = 0; |
| 411 | ads->ds_txstatus4 = ads->ds_txstatus5 = 0; |
| 412 | ads->ds_txstatus6 = ads->ds_txstatus7 = 0; |
| 413 | ads->ds_txstatus8 = ads->ds_txstatus9 = 0; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 414 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 415 | EXPORT_SYMBOL(ath9k_hw_filltxdesc); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 416 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 417 | void ath9k_hw_cleartxdesc(struct ath_hw *ah, struct ath_desc *ds) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 418 | { |
| 419 | struct ar5416_desc *ads = AR5416DESC(ds); |
| 420 | |
| 421 | ads->ds_txstatus0 = ads->ds_txstatus1 = 0; |
| 422 | ads->ds_txstatus2 = ads->ds_txstatus3 = 0; |
| 423 | ads->ds_txstatus4 = ads->ds_txstatus5 = 0; |
| 424 | ads->ds_txstatus6 = ads->ds_txstatus7 = 0; |
| 425 | ads->ds_txstatus8 = ads->ds_txstatus9 = 0; |
| 426 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 427 | EXPORT_SYMBOL(ath9k_hw_cleartxdesc); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 428 | |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 429 | int ath9k_hw_txprocdesc(struct ath_hw *ah, struct ath_desc *ds, |
| 430 | struct ath_tx_status *ts) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 431 | { |
| 432 | struct ar5416_desc *ads = AR5416DESC(ds); |
| 433 | |
| 434 | if ((ads->ds_txstatus9 & AR_TxDone) == 0) |
| 435 | return -EINPROGRESS; |
| 436 | |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 437 | ts->ts_seqnum = MS(ads->ds_txstatus9, AR_SeqNum); |
| 438 | ts->ts_tstamp = ads->AR_SendTimestamp; |
| 439 | ts->ts_status = 0; |
| 440 | ts->ts_flags = 0; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 441 | |
Luis R. Rodriguez | e7824a5 | 2009-11-24 02:53:25 -0500 | [diff] [blame] | 442 | if (ads->ds_txstatus1 & AR_FrmXmitOK) |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 443 | ts->ts_status |= ATH9K_TX_ACKED; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 444 | if (ads->ds_txstatus1 & AR_ExcessiveRetries) |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 445 | ts->ts_status |= ATH9K_TXERR_XRETRY; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 446 | if (ads->ds_txstatus1 & AR_Filtered) |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 447 | ts->ts_status |= ATH9K_TXERR_FILT; |
Sujith | daa9deb | 2008-11-18 09:10:22 +0530 | [diff] [blame] | 448 | if (ads->ds_txstatus1 & AR_FIFOUnderrun) { |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 449 | ts->ts_status |= ATH9K_TXERR_FIFO; |
Sujith | daa9deb | 2008-11-18 09:10:22 +0530 | [diff] [blame] | 450 | ath9k_hw_updatetxtriglevel(ah, true); |
| 451 | } |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 452 | if (ads->ds_txstatus9 & AR_TxOpExceeded) |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 453 | ts->ts_status |= ATH9K_TXERR_XTXOP; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 454 | if (ads->ds_txstatus1 & AR_TxTimerExpired) |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 455 | ts->ts_status |= ATH9K_TXERR_TIMER_EXPIRED; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 456 | |
| 457 | if (ads->ds_txstatus1 & AR_DescCfgErr) |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 458 | ts->ts_flags |= ATH9K_TX_DESC_CFG_ERR; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 459 | if (ads->ds_txstatus1 & AR_TxDataUnderrun) { |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 460 | ts->ts_flags |= ATH9K_TX_DATA_UNDERRUN; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 461 | ath9k_hw_updatetxtriglevel(ah, true); |
| 462 | } |
| 463 | if (ads->ds_txstatus1 & AR_TxDelimUnderrun) { |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 464 | ts->ts_flags |= ATH9K_TX_DELIM_UNDERRUN; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 465 | ath9k_hw_updatetxtriglevel(ah, true); |
| 466 | } |
| 467 | if (ads->ds_txstatus0 & AR_TxBaStatus) { |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 468 | ts->ts_flags |= ATH9K_TX_BA; |
| 469 | ts->ba_low = ads->AR_BaBitmapLow; |
| 470 | ts->ba_high = ads->AR_BaBitmapHigh; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 471 | } |
| 472 | |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 473 | ts->ts_rateindex = MS(ads->ds_txstatus9, AR_FinalTxIdx); |
| 474 | switch (ts->ts_rateindex) { |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 475 | case 0: |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 476 | ts->ts_ratecode = MS(ads->ds_ctl3, AR_XmitRate0); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 477 | break; |
| 478 | case 1: |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 479 | ts->ts_ratecode = MS(ads->ds_ctl3, AR_XmitRate1); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 480 | break; |
| 481 | case 2: |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 482 | ts->ts_ratecode = MS(ads->ds_ctl3, AR_XmitRate2); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 483 | break; |
| 484 | case 3: |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 485 | ts->ts_ratecode = MS(ads->ds_ctl3, AR_XmitRate3); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 486 | break; |
| 487 | } |
| 488 | |
Felix Fietkau | db1a052 | 2010-03-29 20:07:11 -0700 | [diff] [blame] | 489 | ts->ts_rssi = MS(ads->ds_txstatus5, AR_TxRSSICombined); |
| 490 | ts->ts_rssi_ctl0 = MS(ads->ds_txstatus0, AR_TxRSSIAnt00); |
| 491 | ts->ts_rssi_ctl1 = MS(ads->ds_txstatus0, AR_TxRSSIAnt01); |
| 492 | ts->ts_rssi_ctl2 = MS(ads->ds_txstatus0, AR_TxRSSIAnt02); |
| 493 | ts->ts_rssi_ext0 = MS(ads->ds_txstatus5, AR_TxRSSIAnt10); |
| 494 | ts->ts_rssi_ext1 = MS(ads->ds_txstatus5, AR_TxRSSIAnt11); |
| 495 | ts->ts_rssi_ext2 = MS(ads->ds_txstatus5, AR_TxRSSIAnt12); |
| 496 | ts->evm0 = ads->AR_TxEVM0; |
| 497 | ts->evm1 = ads->AR_TxEVM1; |
| 498 | ts->evm2 = ads->AR_TxEVM2; |
| 499 | ts->ts_shortretry = MS(ads->ds_txstatus1, AR_RTSFailCnt); |
| 500 | ts->ts_longretry = MS(ads->ds_txstatus1, AR_DataFailCnt); |
| 501 | ts->ts_virtcol = MS(ads->ds_txstatus1, AR_VirtRetryCnt); |
| 502 | ts->ts_antenna = 0; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 503 | |
| 504 | return 0; |
| 505 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 506 | EXPORT_SYMBOL(ath9k_hw_txprocdesc); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 507 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 508 | void ath9k_hw_set11n_txdesc(struct ath_hw *ah, struct ath_desc *ds, |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 509 | u32 pktLen, enum ath9k_pkt_type type, u32 txPower, |
| 510 | u32 keyIx, enum ath9k_key_type keyType, u32 flags) |
| 511 | { |
| 512 | struct ar5416_desc *ads = AR5416DESC(ds); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 513 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 514 | txPower += ah->txpower_indexoffset; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 515 | if (txPower > 63) |
| 516 | txPower = 63; |
| 517 | |
| 518 | ads->ds_ctl0 = (pktLen & AR_FrameLen) |
| 519 | | (flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0) |
| 520 | | SM(txPower, AR_XmitPower) |
| 521 | | (flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0) |
| 522 | | (flags & ATH9K_TXDESC_CLRDMASK ? AR_ClrDestMask : 0) |
| 523 | | (flags & ATH9K_TXDESC_INTREQ ? AR_TxIntrReq : 0) |
| 524 | | (keyIx != ATH9K_TXKEYIX_INVALID ? AR_DestIdxValid : 0); |
| 525 | |
| 526 | ads->ds_ctl1 = |
| 527 | (keyIx != ATH9K_TXKEYIX_INVALID ? SM(keyIx, AR_DestIdx) : 0) |
| 528 | | SM(type, AR_FrameType) |
| 529 | | (flags & ATH9K_TXDESC_NOACK ? AR_NoAck : 0) |
| 530 | | (flags & ATH9K_TXDESC_EXT_ONLY ? AR_ExtOnly : 0) |
| 531 | | (flags & ATH9K_TXDESC_EXT_AND_CTL ? AR_ExtAndCtl : 0); |
| 532 | |
| 533 | ads->ds_ctl6 = SM(keyType, AR_EncrType); |
| 534 | |
Sujith | e492d7c | 2010-03-17 14:25:17 +0530 | [diff] [blame] | 535 | if (AR_SREV_9285(ah) || AR_SREV_9271(ah)) { |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 536 | ads->ds_ctl8 = 0; |
| 537 | ads->ds_ctl9 = 0; |
| 538 | ads->ds_ctl10 = 0; |
| 539 | ads->ds_ctl11 = 0; |
| 540 | } |
| 541 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 542 | EXPORT_SYMBOL(ath9k_hw_set11n_txdesc); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 543 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 544 | void ath9k_hw_set11n_ratescenario(struct ath_hw *ah, struct ath_desc *ds, |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 545 | struct ath_desc *lastds, |
| 546 | u32 durUpdateEn, u32 rtsctsRate, |
| 547 | u32 rtsctsDuration, |
| 548 | struct ath9k_11n_rate_series series[], |
| 549 | u32 nseries, u32 flags) |
| 550 | { |
| 551 | struct ar5416_desc *ads = AR5416DESC(ds); |
| 552 | struct ar5416_desc *last_ads = AR5416DESC(lastds); |
| 553 | u32 ds_ctl0; |
| 554 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 555 | if (flags & (ATH9K_TXDESC_RTSENA | ATH9K_TXDESC_CTSENA)) { |
| 556 | ds_ctl0 = ads->ds_ctl0; |
| 557 | |
| 558 | if (flags & ATH9K_TXDESC_RTSENA) { |
| 559 | ds_ctl0 &= ~AR_CTSEnable; |
| 560 | ds_ctl0 |= AR_RTSEnable; |
| 561 | } else { |
| 562 | ds_ctl0 &= ~AR_RTSEnable; |
| 563 | ds_ctl0 |= AR_CTSEnable; |
| 564 | } |
| 565 | |
| 566 | ads->ds_ctl0 = ds_ctl0; |
| 567 | } else { |
| 568 | ads->ds_ctl0 = |
| 569 | (ads->ds_ctl0 & ~(AR_RTSEnable | AR_CTSEnable)); |
| 570 | } |
| 571 | |
| 572 | ads->ds_ctl2 = set11nTries(series, 0) |
| 573 | | set11nTries(series, 1) |
| 574 | | set11nTries(series, 2) |
| 575 | | set11nTries(series, 3) |
| 576 | | (durUpdateEn ? AR_DurUpdateEna : 0) |
| 577 | | SM(0, AR_BurstDur); |
| 578 | |
| 579 | ads->ds_ctl3 = set11nRate(series, 0) |
| 580 | | set11nRate(series, 1) |
| 581 | | set11nRate(series, 2) |
| 582 | | set11nRate(series, 3); |
| 583 | |
| 584 | ads->ds_ctl4 = set11nPktDurRTSCTS(series, 0) |
| 585 | | set11nPktDurRTSCTS(series, 1); |
| 586 | |
| 587 | ads->ds_ctl5 = set11nPktDurRTSCTS(series, 2) |
| 588 | | set11nPktDurRTSCTS(series, 3); |
| 589 | |
| 590 | ads->ds_ctl7 = set11nRateFlags(series, 0) |
| 591 | | set11nRateFlags(series, 1) |
| 592 | | set11nRateFlags(series, 2) |
| 593 | | set11nRateFlags(series, 3) |
| 594 | | SM(rtsctsRate, AR_RTSCTSRate); |
| 595 | last_ads->ds_ctl2 = ads->ds_ctl2; |
| 596 | last_ads->ds_ctl3 = ads->ds_ctl3; |
| 597 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 598 | EXPORT_SYMBOL(ath9k_hw_set11n_ratescenario); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 599 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 600 | void ath9k_hw_set11n_aggr_first(struct ath_hw *ah, struct ath_desc *ds, |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 601 | u32 aggrLen) |
| 602 | { |
| 603 | struct ar5416_desc *ads = AR5416DESC(ds); |
| 604 | |
| 605 | ads->ds_ctl1 |= (AR_IsAggr | AR_MoreAggr); |
| 606 | ads->ds_ctl6 &= ~AR_AggrLen; |
| 607 | ads->ds_ctl6 |= SM(aggrLen, AR_AggrLen); |
| 608 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 609 | EXPORT_SYMBOL(ath9k_hw_set11n_aggr_first); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 610 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 611 | void ath9k_hw_set11n_aggr_middle(struct ath_hw *ah, struct ath_desc *ds, |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 612 | u32 numDelims) |
| 613 | { |
| 614 | struct ar5416_desc *ads = AR5416DESC(ds); |
| 615 | unsigned int ctl6; |
| 616 | |
| 617 | ads->ds_ctl1 |= (AR_IsAggr | AR_MoreAggr); |
| 618 | |
| 619 | ctl6 = ads->ds_ctl6; |
| 620 | ctl6 &= ~AR_PadDelim; |
| 621 | ctl6 |= SM(numDelims, AR_PadDelim); |
| 622 | ads->ds_ctl6 = ctl6; |
| 623 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 624 | EXPORT_SYMBOL(ath9k_hw_set11n_aggr_middle); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 625 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 626 | void ath9k_hw_set11n_aggr_last(struct ath_hw *ah, struct ath_desc *ds) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 627 | { |
| 628 | struct ar5416_desc *ads = AR5416DESC(ds); |
| 629 | |
| 630 | ads->ds_ctl1 |= AR_IsAggr; |
| 631 | ads->ds_ctl1 &= ~AR_MoreAggr; |
| 632 | ads->ds_ctl6 &= ~AR_PadDelim; |
| 633 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 634 | EXPORT_SYMBOL(ath9k_hw_set11n_aggr_last); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 635 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 636 | void ath9k_hw_clr11n_aggr(struct ath_hw *ah, struct ath_desc *ds) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 637 | { |
| 638 | struct ar5416_desc *ads = AR5416DESC(ds); |
| 639 | |
| 640 | ads->ds_ctl1 &= (~AR_IsAggr & ~AR_MoreAggr); |
| 641 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 642 | EXPORT_SYMBOL(ath9k_hw_clr11n_aggr); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 643 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 644 | void ath9k_hw_set11n_burstduration(struct ath_hw *ah, struct ath_desc *ds, |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 645 | u32 burstDuration) |
| 646 | { |
| 647 | struct ar5416_desc *ads = AR5416DESC(ds); |
| 648 | |
| 649 | ads->ds_ctl2 &= ~AR_BurstDur; |
| 650 | ads->ds_ctl2 |= SM(burstDuration, AR_BurstDur); |
| 651 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 652 | EXPORT_SYMBOL(ath9k_hw_set11n_burstduration); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 653 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 654 | void ath9k_hw_set11n_virtualmorefrag(struct ath_hw *ah, struct ath_desc *ds, |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 655 | u32 vmf) |
| 656 | { |
| 657 | struct ar5416_desc *ads = AR5416DESC(ds); |
| 658 | |
| 659 | if (vmf) |
| 660 | ads->ds_ctl0 |= AR_VirtMoreFrag; |
| 661 | else |
| 662 | ads->ds_ctl0 &= ~AR_VirtMoreFrag; |
| 663 | } |
| 664 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 665 | void ath9k_hw_gettxintrtxqs(struct ath_hw *ah, u32 *txqs) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 666 | { |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 667 | *txqs &= ah->intr_txqs; |
| 668 | ah->intr_txqs &= ~(*txqs); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 669 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 670 | EXPORT_SYMBOL(ath9k_hw_gettxintrtxqs); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 671 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 672 | bool ath9k_hw_set_txq_props(struct ath_hw *ah, int q, |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 673 | const struct ath9k_tx_queue_info *qinfo) |
| 674 | { |
| 675 | u32 cw; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 676 | struct ath_common *common = ath9k_hw_common(ah); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 677 | struct ath9k_hw_capabilities *pCap = &ah->caps; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 678 | struct ath9k_tx_queue_info *qi; |
| 679 | |
| 680 | if (q >= pCap->total_queues) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 681 | ath_print(common, ATH_DBG_QUEUE, "Set TXQ properties, " |
| 682 | "invalid queue: %u\n", q); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 683 | return false; |
| 684 | } |
| 685 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 686 | qi = &ah->txq[q]; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 687 | if (qi->tqi_type == ATH9K_TX_QUEUE_INACTIVE) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 688 | ath_print(common, ATH_DBG_QUEUE, "Set TXQ properties, " |
| 689 | "inactive queue: %u\n", q); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 690 | return false; |
| 691 | } |
| 692 | |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 693 | ath_print(common, ATH_DBG_QUEUE, "Set queue properties for: %u\n", q); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 694 | |
| 695 | qi->tqi_ver = qinfo->tqi_ver; |
| 696 | qi->tqi_subtype = qinfo->tqi_subtype; |
| 697 | qi->tqi_qflags = qinfo->tqi_qflags; |
| 698 | qi->tqi_priority = qinfo->tqi_priority; |
| 699 | if (qinfo->tqi_aifs != ATH9K_TXQ_USEDEFAULT) |
| 700 | qi->tqi_aifs = min(qinfo->tqi_aifs, 255U); |
| 701 | else |
| 702 | qi->tqi_aifs = INIT_AIFS; |
| 703 | if (qinfo->tqi_cwmin != ATH9K_TXQ_USEDEFAULT) { |
| 704 | cw = min(qinfo->tqi_cwmin, 1024U); |
| 705 | qi->tqi_cwmin = 1; |
| 706 | while (qi->tqi_cwmin < cw) |
| 707 | qi->tqi_cwmin = (qi->tqi_cwmin << 1) | 1; |
| 708 | } else |
| 709 | qi->tqi_cwmin = qinfo->tqi_cwmin; |
| 710 | if (qinfo->tqi_cwmax != ATH9K_TXQ_USEDEFAULT) { |
| 711 | cw = min(qinfo->tqi_cwmax, 1024U); |
| 712 | qi->tqi_cwmax = 1; |
| 713 | while (qi->tqi_cwmax < cw) |
| 714 | qi->tqi_cwmax = (qi->tqi_cwmax << 1) | 1; |
| 715 | } else |
| 716 | qi->tqi_cwmax = INIT_CWMAX; |
| 717 | |
| 718 | if (qinfo->tqi_shretry != 0) |
| 719 | qi->tqi_shretry = min((u32) qinfo->tqi_shretry, 15U); |
| 720 | else |
| 721 | qi->tqi_shretry = INIT_SH_RETRY; |
| 722 | if (qinfo->tqi_lgretry != 0) |
| 723 | qi->tqi_lgretry = min((u32) qinfo->tqi_lgretry, 15U); |
| 724 | else |
| 725 | qi->tqi_lgretry = INIT_LG_RETRY; |
| 726 | qi->tqi_cbrPeriod = qinfo->tqi_cbrPeriod; |
| 727 | qi->tqi_cbrOverflowLimit = qinfo->tqi_cbrOverflowLimit; |
| 728 | qi->tqi_burstTime = qinfo->tqi_burstTime; |
| 729 | qi->tqi_readyTime = qinfo->tqi_readyTime; |
| 730 | |
| 731 | switch (qinfo->tqi_subtype) { |
| 732 | case ATH9K_WME_UPSD: |
| 733 | if (qi->tqi_type == ATH9K_TX_QUEUE_DATA) |
| 734 | qi->tqi_intFlags = ATH9K_TXQ_USE_LOCKOUT_BKOFF_DIS; |
| 735 | break; |
| 736 | default: |
| 737 | break; |
| 738 | } |
| 739 | |
| 740 | return true; |
| 741 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 742 | EXPORT_SYMBOL(ath9k_hw_set_txq_props); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 743 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 744 | bool ath9k_hw_get_txq_props(struct ath_hw *ah, int q, |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 745 | struct ath9k_tx_queue_info *qinfo) |
| 746 | { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 747 | struct ath_common *common = ath9k_hw_common(ah); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 748 | struct ath9k_hw_capabilities *pCap = &ah->caps; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 749 | struct ath9k_tx_queue_info *qi; |
| 750 | |
| 751 | if (q >= pCap->total_queues) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 752 | ath_print(common, ATH_DBG_QUEUE, "Get TXQ properties, " |
| 753 | "invalid queue: %u\n", q); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 754 | return false; |
| 755 | } |
| 756 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 757 | qi = &ah->txq[q]; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 758 | if (qi->tqi_type == ATH9K_TX_QUEUE_INACTIVE) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 759 | ath_print(common, ATH_DBG_QUEUE, "Get TXQ properties, " |
| 760 | "inactive queue: %u\n", q); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 761 | return false; |
| 762 | } |
| 763 | |
| 764 | qinfo->tqi_qflags = qi->tqi_qflags; |
| 765 | qinfo->tqi_ver = qi->tqi_ver; |
| 766 | qinfo->tqi_subtype = qi->tqi_subtype; |
| 767 | qinfo->tqi_qflags = qi->tqi_qflags; |
| 768 | qinfo->tqi_priority = qi->tqi_priority; |
| 769 | qinfo->tqi_aifs = qi->tqi_aifs; |
| 770 | qinfo->tqi_cwmin = qi->tqi_cwmin; |
| 771 | qinfo->tqi_cwmax = qi->tqi_cwmax; |
| 772 | qinfo->tqi_shretry = qi->tqi_shretry; |
| 773 | qinfo->tqi_lgretry = qi->tqi_lgretry; |
| 774 | qinfo->tqi_cbrPeriod = qi->tqi_cbrPeriod; |
| 775 | qinfo->tqi_cbrOverflowLimit = qi->tqi_cbrOverflowLimit; |
| 776 | qinfo->tqi_burstTime = qi->tqi_burstTime; |
| 777 | qinfo->tqi_readyTime = qi->tqi_readyTime; |
| 778 | |
| 779 | return true; |
| 780 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 781 | EXPORT_SYMBOL(ath9k_hw_get_txq_props); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 782 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 783 | int ath9k_hw_setuptxqueue(struct ath_hw *ah, enum ath9k_tx_queue type, |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 784 | const struct ath9k_tx_queue_info *qinfo) |
| 785 | { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 786 | struct ath_common *common = ath9k_hw_common(ah); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 787 | struct ath9k_tx_queue_info *qi; |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 788 | struct ath9k_hw_capabilities *pCap = &ah->caps; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 789 | int q; |
| 790 | |
| 791 | switch (type) { |
| 792 | case ATH9K_TX_QUEUE_BEACON: |
| 793 | q = pCap->total_queues - 1; |
| 794 | break; |
| 795 | case ATH9K_TX_QUEUE_CAB: |
| 796 | q = pCap->total_queues - 2; |
| 797 | break; |
| 798 | case ATH9K_TX_QUEUE_PSPOLL: |
| 799 | q = 1; |
| 800 | break; |
| 801 | case ATH9K_TX_QUEUE_UAPSD: |
| 802 | q = pCap->total_queues - 3; |
| 803 | break; |
| 804 | case ATH9K_TX_QUEUE_DATA: |
| 805 | for (q = 0; q < pCap->total_queues; q++) |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 806 | if (ah->txq[q].tqi_type == |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 807 | ATH9K_TX_QUEUE_INACTIVE) |
| 808 | break; |
| 809 | if (q == pCap->total_queues) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 810 | ath_print(common, ATH_DBG_FATAL, |
| 811 | "No available TX queue\n"); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 812 | return -1; |
| 813 | } |
| 814 | break; |
| 815 | default: |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 816 | ath_print(common, ATH_DBG_FATAL, |
| 817 | "Invalid TX queue type: %u\n", type); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 818 | return -1; |
| 819 | } |
| 820 | |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 821 | ath_print(common, ATH_DBG_QUEUE, "Setup TX queue: %u\n", q); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 822 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 823 | qi = &ah->txq[q]; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 824 | if (qi->tqi_type != ATH9K_TX_QUEUE_INACTIVE) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 825 | ath_print(common, ATH_DBG_FATAL, |
| 826 | "TX queue: %u already active\n", q); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 827 | return -1; |
| 828 | } |
| 829 | memset(qi, 0, sizeof(struct ath9k_tx_queue_info)); |
| 830 | qi->tqi_type = type; |
| 831 | if (qinfo == NULL) { |
| 832 | qi->tqi_qflags = |
| 833 | TXQ_FLAG_TXOKINT_ENABLE |
| 834 | | TXQ_FLAG_TXERRINT_ENABLE |
| 835 | | TXQ_FLAG_TXDESCINT_ENABLE | TXQ_FLAG_TXURNINT_ENABLE; |
| 836 | qi->tqi_aifs = INIT_AIFS; |
| 837 | qi->tqi_cwmin = ATH9K_TXQ_USEDEFAULT; |
| 838 | qi->tqi_cwmax = INIT_CWMAX; |
| 839 | qi->tqi_shretry = INIT_SH_RETRY; |
| 840 | qi->tqi_lgretry = INIT_LG_RETRY; |
| 841 | qi->tqi_physCompBuf = 0; |
| 842 | } else { |
| 843 | qi->tqi_physCompBuf = qinfo->tqi_physCompBuf; |
| 844 | (void) ath9k_hw_set_txq_props(ah, q, qinfo); |
| 845 | } |
| 846 | |
| 847 | return q; |
| 848 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 849 | EXPORT_SYMBOL(ath9k_hw_setuptxqueue); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 850 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 851 | bool ath9k_hw_releasetxqueue(struct ath_hw *ah, u32 q) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 852 | { |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 853 | struct ath9k_hw_capabilities *pCap = &ah->caps; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 854 | struct ath_common *common = ath9k_hw_common(ah); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 855 | struct ath9k_tx_queue_info *qi; |
| 856 | |
| 857 | if (q >= pCap->total_queues) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 858 | ath_print(common, ATH_DBG_QUEUE, "Release TXQ, " |
| 859 | "invalid queue: %u\n", q); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 860 | return false; |
| 861 | } |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 862 | qi = &ah->txq[q]; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 863 | if (qi->tqi_type == ATH9K_TX_QUEUE_INACTIVE) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 864 | ath_print(common, ATH_DBG_QUEUE, "Release TXQ, " |
| 865 | "inactive queue: %u\n", q); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 866 | return false; |
| 867 | } |
| 868 | |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 869 | ath_print(common, ATH_DBG_QUEUE, "Release TX queue: %u\n", q); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 870 | |
| 871 | qi->tqi_type = ATH9K_TX_QUEUE_INACTIVE; |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 872 | ah->txok_interrupt_mask &= ~(1 << q); |
| 873 | ah->txerr_interrupt_mask &= ~(1 << q); |
| 874 | ah->txdesc_interrupt_mask &= ~(1 << q); |
| 875 | ah->txeol_interrupt_mask &= ~(1 << q); |
| 876 | ah->txurn_interrupt_mask &= ~(1 << q); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 877 | ath9k_hw_set_txq_interrupts(ah, qi); |
| 878 | |
| 879 | return true; |
| 880 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 881 | EXPORT_SYMBOL(ath9k_hw_releasetxqueue); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 882 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 883 | bool ath9k_hw_resettxqueue(struct ath_hw *ah, u32 q) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 884 | { |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 885 | struct ath9k_hw_capabilities *pCap = &ah->caps; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 886 | struct ath_common *common = ath9k_hw_common(ah); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 887 | struct ath9k_channel *chan = ah->curchan; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 888 | struct ath9k_tx_queue_info *qi; |
| 889 | u32 cwMin, chanCwMin, value; |
| 890 | |
| 891 | if (q >= pCap->total_queues) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 892 | ath_print(common, ATH_DBG_QUEUE, "Reset TXQ, " |
| 893 | "invalid queue: %u\n", q); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 894 | return false; |
| 895 | } |
| 896 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 897 | qi = &ah->txq[q]; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 898 | if (qi->tqi_type == ATH9K_TX_QUEUE_INACTIVE) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 899 | ath_print(common, ATH_DBG_QUEUE, "Reset TXQ, " |
| 900 | "inactive queue: %u\n", q); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 901 | return true; |
| 902 | } |
| 903 | |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 904 | ath_print(common, ATH_DBG_QUEUE, "Reset TX queue: %u\n", q); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 905 | |
| 906 | if (qi->tqi_cwmin == ATH9K_TXQ_USEDEFAULT) { |
| 907 | if (chan && IS_CHAN_B(chan)) |
| 908 | chanCwMin = INIT_CWMIN_11B; |
| 909 | else |
| 910 | chanCwMin = INIT_CWMIN; |
| 911 | |
| 912 | for (cwMin = 1; cwMin < chanCwMin; cwMin = (cwMin << 1) | 1); |
| 913 | } else |
| 914 | cwMin = qi->tqi_cwmin; |
| 915 | |
| 916 | REG_WRITE(ah, AR_DLCL_IFS(q), |
| 917 | SM(cwMin, AR_D_LCL_IFS_CWMIN) | |
| 918 | SM(qi->tqi_cwmax, AR_D_LCL_IFS_CWMAX) | |
| 919 | SM(qi->tqi_aifs, AR_D_LCL_IFS_AIFS)); |
| 920 | |
| 921 | REG_WRITE(ah, AR_DRETRY_LIMIT(q), |
| 922 | SM(INIT_SSH_RETRY, AR_D_RETRY_LIMIT_STA_SH) | |
| 923 | SM(INIT_SLG_RETRY, AR_D_RETRY_LIMIT_STA_LG) | |
| 924 | SM(qi->tqi_shretry, AR_D_RETRY_LIMIT_FR_SH)); |
| 925 | |
| 926 | REG_WRITE(ah, AR_QMISC(q), AR_Q_MISC_DCU_EARLY_TERM_REQ); |
| 927 | REG_WRITE(ah, AR_DMISC(q), |
| 928 | AR_D_MISC_CW_BKOFF_EN | AR_D_MISC_FRAG_WAIT_EN | 0x2); |
| 929 | |
| 930 | if (qi->tqi_cbrPeriod) { |
| 931 | REG_WRITE(ah, AR_QCBRCFG(q), |
| 932 | SM(qi->tqi_cbrPeriod, AR_Q_CBRCFG_INTERVAL) | |
| 933 | SM(qi->tqi_cbrOverflowLimit, AR_Q_CBRCFG_OVF_THRESH)); |
| 934 | REG_WRITE(ah, AR_QMISC(q), |
| 935 | REG_READ(ah, AR_QMISC(q)) | AR_Q_MISC_FSP_CBR | |
| 936 | (qi->tqi_cbrOverflowLimit ? |
| 937 | AR_Q_MISC_CBR_EXP_CNTR_LIMIT_EN : 0)); |
| 938 | } |
| 939 | if (qi->tqi_readyTime && (qi->tqi_type != ATH9K_TX_QUEUE_CAB)) { |
| 940 | REG_WRITE(ah, AR_QRDYTIMECFG(q), |
| 941 | SM(qi->tqi_readyTime, AR_Q_RDYTIMECFG_DURATION) | |
| 942 | AR_Q_RDYTIMECFG_EN); |
| 943 | } |
| 944 | |
| 945 | REG_WRITE(ah, AR_DCHNTIME(q), |
| 946 | SM(qi->tqi_burstTime, AR_D_CHNTIME_DUR) | |
| 947 | (qi->tqi_burstTime ? AR_D_CHNTIME_EN : 0)); |
| 948 | |
| 949 | if (qi->tqi_burstTime |
| 950 | && (qi->tqi_qflags & TXQ_FLAG_RDYTIME_EXP_POLICY_ENABLE)) { |
| 951 | REG_WRITE(ah, AR_QMISC(q), |
| 952 | REG_READ(ah, AR_QMISC(q)) | |
| 953 | AR_Q_MISC_RDYTIME_EXP_POLICY); |
| 954 | |
| 955 | } |
| 956 | |
| 957 | if (qi->tqi_qflags & TXQ_FLAG_BACKOFF_DISABLE) { |
| 958 | REG_WRITE(ah, AR_DMISC(q), |
| 959 | REG_READ(ah, AR_DMISC(q)) | |
| 960 | AR_D_MISC_POST_FR_BKOFF_DIS); |
| 961 | } |
| 962 | if (qi->tqi_qflags & TXQ_FLAG_FRAG_BURST_BACKOFF_ENABLE) { |
| 963 | REG_WRITE(ah, AR_DMISC(q), |
| 964 | REG_READ(ah, AR_DMISC(q)) | |
| 965 | AR_D_MISC_FRAG_BKOFF_EN); |
| 966 | } |
| 967 | switch (qi->tqi_type) { |
| 968 | case ATH9K_TX_QUEUE_BEACON: |
| 969 | REG_WRITE(ah, AR_QMISC(q), REG_READ(ah, AR_QMISC(q)) |
| 970 | | AR_Q_MISC_FSP_DBA_GATED |
| 971 | | AR_Q_MISC_BEACON_USE |
| 972 | | AR_Q_MISC_CBR_INCR_DIS1); |
| 973 | |
| 974 | REG_WRITE(ah, AR_DMISC(q), REG_READ(ah, AR_DMISC(q)) |
| 975 | | (AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL << |
| 976 | AR_D_MISC_ARB_LOCKOUT_CNTRL_S) |
| 977 | | AR_D_MISC_BEACON_USE |
| 978 | | AR_D_MISC_POST_FR_BKOFF_DIS); |
| 979 | break; |
| 980 | case ATH9K_TX_QUEUE_CAB: |
| 981 | REG_WRITE(ah, AR_QMISC(q), REG_READ(ah, AR_QMISC(q)) |
| 982 | | AR_Q_MISC_FSP_DBA_GATED |
| 983 | | AR_Q_MISC_CBR_INCR_DIS1 |
| 984 | | AR_Q_MISC_CBR_INCR_DIS0); |
| 985 | value = (qi->tqi_readyTime - |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 986 | (ah->config.sw_beacon_response_time - |
| 987 | ah->config.dma_beacon_response_time) - |
| 988 | ah->config.additional_swba_backoff) * 1024; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 989 | REG_WRITE(ah, AR_QRDYTIMECFG(q), |
| 990 | value | AR_Q_RDYTIMECFG_EN); |
| 991 | REG_WRITE(ah, AR_DMISC(q), REG_READ(ah, AR_DMISC(q)) |
| 992 | | (AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL << |
| 993 | AR_D_MISC_ARB_LOCKOUT_CNTRL_S)); |
| 994 | break; |
| 995 | case ATH9K_TX_QUEUE_PSPOLL: |
| 996 | REG_WRITE(ah, AR_QMISC(q), |
| 997 | REG_READ(ah, AR_QMISC(q)) | AR_Q_MISC_CBR_INCR_DIS1); |
| 998 | break; |
| 999 | case ATH9K_TX_QUEUE_UAPSD: |
| 1000 | REG_WRITE(ah, AR_DMISC(q), REG_READ(ah, AR_DMISC(q)) | |
| 1001 | AR_D_MISC_POST_FR_BKOFF_DIS); |
| 1002 | break; |
| 1003 | default: |
| 1004 | break; |
| 1005 | } |
| 1006 | |
| 1007 | if (qi->tqi_intFlags & ATH9K_TXQ_USE_LOCKOUT_BKOFF_DIS) { |
| 1008 | REG_WRITE(ah, AR_DMISC(q), |
| 1009 | REG_READ(ah, AR_DMISC(q)) | |
| 1010 | SM(AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL, |
| 1011 | AR_D_MISC_ARB_LOCKOUT_CNTRL) | |
| 1012 | AR_D_MISC_POST_FR_BKOFF_DIS); |
| 1013 | } |
| 1014 | |
| 1015 | if (qi->tqi_qflags & TXQ_FLAG_TXOKINT_ENABLE) |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1016 | ah->txok_interrupt_mask |= 1 << q; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1017 | else |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1018 | ah->txok_interrupt_mask &= ~(1 << q); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1019 | if (qi->tqi_qflags & TXQ_FLAG_TXERRINT_ENABLE) |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1020 | ah->txerr_interrupt_mask |= 1 << q; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1021 | else |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1022 | ah->txerr_interrupt_mask &= ~(1 << q); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1023 | if (qi->tqi_qflags & TXQ_FLAG_TXDESCINT_ENABLE) |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1024 | ah->txdesc_interrupt_mask |= 1 << q; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1025 | else |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1026 | ah->txdesc_interrupt_mask &= ~(1 << q); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1027 | if (qi->tqi_qflags & TXQ_FLAG_TXEOLINT_ENABLE) |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1028 | ah->txeol_interrupt_mask |= 1 << q; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1029 | else |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1030 | ah->txeol_interrupt_mask &= ~(1 << q); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1031 | if (qi->tqi_qflags & TXQ_FLAG_TXURNINT_ENABLE) |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1032 | ah->txurn_interrupt_mask |= 1 << q; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1033 | else |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1034 | ah->txurn_interrupt_mask &= ~(1 << q); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1035 | ath9k_hw_set_txq_interrupts(ah, qi); |
| 1036 | |
| 1037 | return true; |
| 1038 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 1039 | EXPORT_SYMBOL(ath9k_hw_resettxqueue); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1040 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 1041 | int ath9k_hw_rxprocdesc(struct ath_hw *ah, struct ath_desc *ds, |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1042 | struct ath_rx_status *rs, u64 tsf) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1043 | { |
| 1044 | struct ar5416_desc ads; |
| 1045 | struct ar5416_desc *adsp = AR5416DESC(ds); |
| 1046 | u32 phyerr; |
| 1047 | |
| 1048 | if ((adsp->ds_rxstatus8 & AR_RxDone) == 0) |
| 1049 | return -EINPROGRESS; |
| 1050 | |
| 1051 | ads.u.rx = adsp->u.rx; |
| 1052 | |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1053 | rs->rs_status = 0; |
| 1054 | rs->rs_flags = 0; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1055 | |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1056 | rs->rs_datalen = ads.ds_rxstatus1 & AR_DataLen; |
| 1057 | rs->rs_tstamp = ads.AR_RcvTimestamp; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1058 | |
Senthil Balasubramanian | dd8b15b | 2009-07-14 20:17:08 -0400 | [diff] [blame] | 1059 | if (ads.ds_rxstatus8 & AR_PostDelimCRCErr) { |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1060 | rs->rs_rssi = ATH9K_RSSI_BAD; |
| 1061 | rs->rs_rssi_ctl0 = ATH9K_RSSI_BAD; |
| 1062 | rs->rs_rssi_ctl1 = ATH9K_RSSI_BAD; |
| 1063 | rs->rs_rssi_ctl2 = ATH9K_RSSI_BAD; |
| 1064 | rs->rs_rssi_ext0 = ATH9K_RSSI_BAD; |
| 1065 | rs->rs_rssi_ext1 = ATH9K_RSSI_BAD; |
| 1066 | rs->rs_rssi_ext2 = ATH9K_RSSI_BAD; |
Senthil Balasubramanian | dd8b15b | 2009-07-14 20:17:08 -0400 | [diff] [blame] | 1067 | } else { |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1068 | rs->rs_rssi = MS(ads.ds_rxstatus4, AR_RxRSSICombined); |
| 1069 | rs->rs_rssi_ctl0 = MS(ads.ds_rxstatus0, |
Senthil Balasubramanian | dd8b15b | 2009-07-14 20:17:08 -0400 | [diff] [blame] | 1070 | AR_RxRSSIAnt00); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1071 | rs->rs_rssi_ctl1 = MS(ads.ds_rxstatus0, |
Senthil Balasubramanian | dd8b15b | 2009-07-14 20:17:08 -0400 | [diff] [blame] | 1072 | AR_RxRSSIAnt01); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1073 | rs->rs_rssi_ctl2 = MS(ads.ds_rxstatus0, |
Senthil Balasubramanian | dd8b15b | 2009-07-14 20:17:08 -0400 | [diff] [blame] | 1074 | AR_RxRSSIAnt02); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1075 | rs->rs_rssi_ext0 = MS(ads.ds_rxstatus4, |
Senthil Balasubramanian | dd8b15b | 2009-07-14 20:17:08 -0400 | [diff] [blame] | 1076 | AR_RxRSSIAnt10); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1077 | rs->rs_rssi_ext1 = MS(ads.ds_rxstatus4, |
Senthil Balasubramanian | dd8b15b | 2009-07-14 20:17:08 -0400 | [diff] [blame] | 1078 | AR_RxRSSIAnt11); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1079 | rs->rs_rssi_ext2 = MS(ads.ds_rxstatus4, |
Senthil Balasubramanian | dd8b15b | 2009-07-14 20:17:08 -0400 | [diff] [blame] | 1080 | AR_RxRSSIAnt12); |
| 1081 | } |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1082 | if (ads.ds_rxstatus8 & AR_RxKeyIdxValid) |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1083 | rs->rs_keyix = MS(ads.ds_rxstatus8, AR_KeyIdx); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1084 | else |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1085 | rs->rs_keyix = ATH9K_RXKEYIX_INVALID; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1086 | |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1087 | rs->rs_rate = RXSTATUS_RATE(ah, (&ads)); |
| 1088 | rs->rs_more = (ads.ds_rxstatus1 & AR_RxMore) ? 1 : 0; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1089 | |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1090 | rs->rs_isaggr = (ads.ds_rxstatus8 & AR_RxAggr) ? 1 : 0; |
| 1091 | rs->rs_moreaggr = |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1092 | (ads.ds_rxstatus8 & AR_RxMoreAggr) ? 1 : 0; |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1093 | rs->rs_antenna = MS(ads.ds_rxstatus3, AR_RxAntenna); |
| 1094 | rs->rs_flags = |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1095 | (ads.ds_rxstatus3 & AR_GI) ? ATH9K_RX_GI : 0; |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1096 | rs->rs_flags |= |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1097 | (ads.ds_rxstatus3 & AR_2040) ? ATH9K_RX_2040 : 0; |
| 1098 | |
| 1099 | if (ads.ds_rxstatus8 & AR_PreDelimCRCErr) |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1100 | rs->rs_flags |= ATH9K_RX_DELIM_CRC_PRE; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1101 | if (ads.ds_rxstatus8 & AR_PostDelimCRCErr) |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1102 | rs->rs_flags |= ATH9K_RX_DELIM_CRC_POST; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1103 | if (ads.ds_rxstatus8 & AR_DecryptBusyErr) |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1104 | rs->rs_flags |= ATH9K_RX_DECRYPT_BUSY; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1105 | |
| 1106 | if ((ads.ds_rxstatus8 & AR_RxFrameOK) == 0) { |
| 1107 | if (ads.ds_rxstatus8 & AR_CRCErr) |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1108 | rs->rs_status |= ATH9K_RXERR_CRC; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1109 | else if (ads.ds_rxstatus8 & AR_PHYErr) { |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1110 | rs->rs_status |= ATH9K_RXERR_PHY; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1111 | phyerr = MS(ads.ds_rxstatus8, AR_PHYErrCode); |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1112 | rs->rs_phyerr = phyerr; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1113 | } else if (ads.ds_rxstatus8 & AR_DecryptCRCErr) |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1114 | rs->rs_status |= ATH9K_RXERR_DECRYPT; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1115 | else if (ads.ds_rxstatus8 & AR_MichaelErr) |
Felix Fietkau | 8e6f5aa | 2010-03-29 20:09:27 -0700 | [diff] [blame] | 1116 | rs->rs_status |= ATH9K_RXERR_MIC; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1117 | } |
| 1118 | |
| 1119 | return 0; |
| 1120 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 1121 | EXPORT_SYMBOL(ath9k_hw_rxprocdesc); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1122 | |
Sujith | 54e4cec | 2009-08-07 09:45:09 +0530 | [diff] [blame] | 1123 | void ath9k_hw_setuprxdesc(struct ath_hw *ah, struct ath_desc *ds, |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1124 | u32 size, u32 flags) |
| 1125 | { |
| 1126 | struct ar5416_desc *ads = AR5416DESC(ds); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1127 | struct ath9k_hw_capabilities *pCap = &ah->caps; |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1128 | |
| 1129 | ads->ds_ctl1 = size & AR_BufLen; |
| 1130 | if (flags & ATH9K_RXDESC_INTREQ) |
| 1131 | ads->ds_ctl1 |= AR_RxIntrReq; |
| 1132 | |
| 1133 | ads->ds_rxstatus8 &= ~AR_RxDone; |
| 1134 | if (!(pCap->hw_caps & ATH9K_HW_CAP_AUTOSLEEP)) |
| 1135 | memset(&(ads->u), 0, sizeof(ads->u)); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1136 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 1137 | EXPORT_SYMBOL(ath9k_hw_setuprxdesc); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1138 | |
Luis R. Rodriguez | e7824a5 | 2009-11-24 02:53:25 -0500 | [diff] [blame] | 1139 | /* |
| 1140 | * This can stop or re-enables RX. |
| 1141 | * |
| 1142 | * If bool is set this will kill any frame which is currently being |
| 1143 | * transferred between the MAC and baseband and also prevent any new |
| 1144 | * frames from getting started. |
| 1145 | */ |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 1146 | bool ath9k_hw_setrxabort(struct ath_hw *ah, bool set) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1147 | { |
| 1148 | u32 reg; |
| 1149 | |
| 1150 | if (set) { |
| 1151 | REG_SET_BIT(ah, AR_DIAG_SW, |
| 1152 | (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT)); |
| 1153 | |
Sujith | 0caa7b1 | 2009-02-16 13:23:20 +0530 | [diff] [blame] | 1154 | if (!ath9k_hw_wait(ah, AR_OBS_BUS_1, AR_OBS_BUS_1_RX_STATE, |
| 1155 | 0, AH_WAIT_TIMEOUT)) { |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1156 | REG_CLR_BIT(ah, AR_DIAG_SW, |
| 1157 | (AR_DIAG_RX_DIS | |
| 1158 | AR_DIAG_RX_ABORT)); |
| 1159 | |
| 1160 | reg = REG_READ(ah, AR_OBS_BUS_1); |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1161 | ath_print(ath9k_hw_common(ah), ATH_DBG_FATAL, |
| 1162 | "RX failed to go idle in 10 ms RXSM=0x%x\n", |
| 1163 | reg); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1164 | |
| 1165 | return false; |
| 1166 | } |
| 1167 | } else { |
| 1168 | REG_CLR_BIT(ah, AR_DIAG_SW, |
| 1169 | (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT)); |
| 1170 | } |
| 1171 | |
| 1172 | return true; |
| 1173 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 1174 | EXPORT_SYMBOL(ath9k_hw_setrxabort); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1175 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 1176 | void ath9k_hw_putrxbuf(struct ath_hw *ah, u32 rxdp) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1177 | { |
| 1178 | REG_WRITE(ah, AR_RXDP, rxdp); |
| 1179 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 1180 | EXPORT_SYMBOL(ath9k_hw_putrxbuf); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1181 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 1182 | void ath9k_hw_startpcureceive(struct ath_hw *ah) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1183 | { |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1184 | ath9k_enable_mib_counters(ah); |
| 1185 | |
| 1186 | ath9k_ani_reset(ah); |
Senthil Balasubramanian | e759407 | 2008-12-08 19:43:48 +0530 | [diff] [blame] | 1187 | |
Senthil Balasubramanian | 8aa15e1 | 2008-12-08 19:43:50 +0530 | [diff] [blame] | 1188 | REG_CLR_BIT(ah, AR_DIAG_SW, (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT)); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1189 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 1190 | EXPORT_SYMBOL(ath9k_hw_startpcureceive); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1191 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 1192 | void ath9k_hw_stoppcurecv(struct ath_hw *ah) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1193 | { |
| 1194 | REG_SET_BIT(ah, AR_DIAG_SW, AR_DIAG_RX_DIS); |
| 1195 | |
| 1196 | ath9k_hw_disable_mib_counters(ah); |
| 1197 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 1198 | EXPORT_SYMBOL(ath9k_hw_stoppcurecv); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1199 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 1200 | bool ath9k_hw_stopdmarecv(struct ath_hw *ah) |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1201 | { |
Sujith | 0caa7b1 | 2009-02-16 13:23:20 +0530 | [diff] [blame] | 1202 | #define AH_RX_STOP_DMA_TIMEOUT 10000 /* usec */ |
| 1203 | #define AH_RX_TIME_QUANTUM 100 /* usec */ |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1204 | struct ath_common *common = ath9k_hw_common(ah); |
Sujith | 0caa7b1 | 2009-02-16 13:23:20 +0530 | [diff] [blame] | 1205 | int i; |
| 1206 | |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1207 | REG_WRITE(ah, AR_CR, AR_CR_RXD); |
| 1208 | |
Sujith | 0caa7b1 | 2009-02-16 13:23:20 +0530 | [diff] [blame] | 1209 | /* Wait for rx enable bit to go low */ |
| 1210 | for (i = AH_RX_STOP_DMA_TIMEOUT / AH_TIME_QUANTUM; i != 0; i--) { |
| 1211 | if ((REG_READ(ah, AR_CR) & AR_CR_RXE) == 0) |
| 1212 | break; |
| 1213 | udelay(AH_TIME_QUANTUM); |
| 1214 | } |
| 1215 | |
| 1216 | if (i == 0) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1217 | ath_print(common, ATH_DBG_FATAL, |
| 1218 | "DMA failed to stop in %d ms " |
| 1219 | "AR_CR=0x%08x AR_DIAG_SW=0x%08x\n", |
| 1220 | AH_RX_STOP_DMA_TIMEOUT / 1000, |
| 1221 | REG_READ(ah, AR_CR), |
| 1222 | REG_READ(ah, AR_DIAG_SW)); |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1223 | return false; |
| 1224 | } else { |
| 1225 | return true; |
| 1226 | } |
Sujith | 0caa7b1 | 2009-02-16 13:23:20 +0530 | [diff] [blame] | 1227 | |
| 1228 | #undef AH_RX_TIME_QUANTUM |
| 1229 | #undef AH_RX_STOP_DMA_TIMEOUT |
Sujith | f1dc560 | 2008-10-29 10:16:30 +0530 | [diff] [blame] | 1230 | } |
Luis R. Rodriguez | 7322fd1 | 2009-09-23 23:07:00 -0400 | [diff] [blame] | 1231 | EXPORT_SYMBOL(ath9k_hw_stopdmarecv); |
Luis R. Rodriguez | 536b3a7 | 2009-10-06 21:19:11 -0400 | [diff] [blame] | 1232 | |
| 1233 | int ath9k_hw_beaconq_setup(struct ath_hw *ah) |
| 1234 | { |
| 1235 | struct ath9k_tx_queue_info qi; |
| 1236 | |
| 1237 | memset(&qi, 0, sizeof(qi)); |
| 1238 | qi.tqi_aifs = 1; |
| 1239 | qi.tqi_cwmin = 0; |
| 1240 | qi.tqi_cwmax = 0; |
| 1241 | /* NB: don't enable any interrupts */ |
| 1242 | return ath9k_hw_setuptxqueue(ah, ATH9K_TX_QUEUE_BEACON, &qi); |
| 1243 | } |
| 1244 | EXPORT_SYMBOL(ath9k_hw_beaconq_setup); |
Vasanthakumar Thiagarajan | 55e82df | 2010-04-15 17:39:06 -0400 | [diff] [blame^] | 1245 | |
| 1246 | bool ath9k_hw_intrpend(struct ath_hw *ah) |
| 1247 | { |
| 1248 | u32 host_isr; |
| 1249 | |
| 1250 | if (AR_SREV_9100(ah)) |
| 1251 | return true; |
| 1252 | |
| 1253 | host_isr = REG_READ(ah, AR_INTR_ASYNC_CAUSE); |
| 1254 | if ((host_isr & AR_INTR_MAC_IRQ) && (host_isr != AR_INTR_SPURIOUS)) |
| 1255 | return true; |
| 1256 | |
| 1257 | host_isr = REG_READ(ah, AR_INTR_SYNC_CAUSE); |
| 1258 | if ((host_isr & AR_INTR_SYNC_DEFAULT) |
| 1259 | && (host_isr != AR_INTR_SPURIOUS)) |
| 1260 | return true; |
| 1261 | |
| 1262 | return false; |
| 1263 | } |
| 1264 | EXPORT_SYMBOL(ath9k_hw_intrpend); |
| 1265 | |
| 1266 | enum ath9k_int ath9k_hw_set_interrupts(struct ath_hw *ah, |
| 1267 | enum ath9k_int ints) |
| 1268 | { |
| 1269 | enum ath9k_int omask = ah->imask; |
| 1270 | u32 mask, mask2; |
| 1271 | struct ath9k_hw_capabilities *pCap = &ah->caps; |
| 1272 | struct ath_common *common = ath9k_hw_common(ah); |
| 1273 | |
| 1274 | ath_print(common, ATH_DBG_INTERRUPT, "0x%x => 0x%x\n", omask, ints); |
| 1275 | |
| 1276 | if (omask & ATH9K_INT_GLOBAL) { |
| 1277 | ath_print(common, ATH_DBG_INTERRUPT, "disable IER\n"); |
| 1278 | REG_WRITE(ah, AR_IER, AR_IER_DISABLE); |
| 1279 | (void) REG_READ(ah, AR_IER); |
| 1280 | if (!AR_SREV_9100(ah)) { |
| 1281 | REG_WRITE(ah, AR_INTR_ASYNC_ENABLE, 0); |
| 1282 | (void) REG_READ(ah, AR_INTR_ASYNC_ENABLE); |
| 1283 | |
| 1284 | REG_WRITE(ah, AR_INTR_SYNC_ENABLE, 0); |
| 1285 | (void) REG_READ(ah, AR_INTR_SYNC_ENABLE); |
| 1286 | } |
| 1287 | } |
| 1288 | |
| 1289 | /* TODO: global int Ref count */ |
| 1290 | mask = ints & ATH9K_INT_COMMON; |
| 1291 | mask2 = 0; |
| 1292 | |
| 1293 | if (ints & ATH9K_INT_TX) { |
| 1294 | if (ah->config.tx_intr_mitigation) |
| 1295 | mask |= AR_IMR_TXMINTR | AR_IMR_TXINTM; |
| 1296 | if (ah->txok_interrupt_mask) |
| 1297 | mask |= AR_IMR_TXOK; |
| 1298 | if (ah->txdesc_interrupt_mask) |
| 1299 | mask |= AR_IMR_TXDESC; |
| 1300 | if (ah->txerr_interrupt_mask) |
| 1301 | mask |= AR_IMR_TXERR; |
| 1302 | if (ah->txeol_interrupt_mask) |
| 1303 | mask |= AR_IMR_TXEOL; |
| 1304 | } |
| 1305 | if (ints & ATH9K_INT_RX) { |
| 1306 | if (AR_SREV_9300_20_OR_LATER(ah)) { |
| 1307 | mask |= AR_IMR_RXERR | AR_IMR_RXOK_HP; |
| 1308 | if (ah->config.rx_intr_mitigation) { |
| 1309 | mask &= ~AR_IMR_RXOK_LP; |
| 1310 | mask |= AR_IMR_RXMINTR | AR_IMR_RXINTM; |
| 1311 | } else { |
| 1312 | mask |= AR_IMR_RXOK_LP; |
| 1313 | } |
| 1314 | } else { |
| 1315 | if (ah->config.rx_intr_mitigation) |
| 1316 | mask |= AR_IMR_RXMINTR | AR_IMR_RXINTM; |
| 1317 | else |
| 1318 | mask |= AR_IMR_RXOK | AR_IMR_RXDESC; |
| 1319 | } |
| 1320 | if (!(pCap->hw_caps & ATH9K_HW_CAP_AUTOSLEEP)) |
| 1321 | mask |= AR_IMR_GENTMR; |
| 1322 | } |
| 1323 | |
| 1324 | if (ints & (ATH9K_INT_BMISC)) { |
| 1325 | mask |= AR_IMR_BCNMISC; |
| 1326 | if (ints & ATH9K_INT_TIM) |
| 1327 | mask2 |= AR_IMR_S2_TIM; |
| 1328 | if (ints & ATH9K_INT_DTIM) |
| 1329 | mask2 |= AR_IMR_S2_DTIM; |
| 1330 | if (ints & ATH9K_INT_DTIMSYNC) |
| 1331 | mask2 |= AR_IMR_S2_DTIMSYNC; |
| 1332 | if (ints & ATH9K_INT_CABEND) |
| 1333 | mask2 |= AR_IMR_S2_CABEND; |
| 1334 | if (ints & ATH9K_INT_TSFOOR) |
| 1335 | mask2 |= AR_IMR_S2_TSFOOR; |
| 1336 | } |
| 1337 | |
| 1338 | if (ints & (ATH9K_INT_GTT | ATH9K_INT_CST)) { |
| 1339 | mask |= AR_IMR_BCNMISC; |
| 1340 | if (ints & ATH9K_INT_GTT) |
| 1341 | mask2 |= AR_IMR_S2_GTT; |
| 1342 | if (ints & ATH9K_INT_CST) |
| 1343 | mask2 |= AR_IMR_S2_CST; |
| 1344 | } |
| 1345 | |
| 1346 | ath_print(common, ATH_DBG_INTERRUPT, "new IMR 0x%x\n", mask); |
| 1347 | REG_WRITE(ah, AR_IMR, mask); |
| 1348 | ah->imrs2_reg &= ~(AR_IMR_S2_TIM | AR_IMR_S2_DTIM | AR_IMR_S2_DTIMSYNC | |
| 1349 | AR_IMR_S2_CABEND | AR_IMR_S2_CABTO | |
| 1350 | AR_IMR_S2_TSFOOR | AR_IMR_S2_GTT | AR_IMR_S2_CST); |
| 1351 | ah->imrs2_reg |= mask2; |
| 1352 | REG_WRITE(ah, AR_IMR_S2, ah->imrs2_reg); |
| 1353 | |
| 1354 | if (!(pCap->hw_caps & ATH9K_HW_CAP_AUTOSLEEP)) { |
| 1355 | if (ints & ATH9K_INT_TIM_TIMER) |
| 1356 | REG_SET_BIT(ah, AR_IMR_S5, AR_IMR_S5_TIM_TIMER); |
| 1357 | else |
| 1358 | REG_CLR_BIT(ah, AR_IMR_S5, AR_IMR_S5_TIM_TIMER); |
| 1359 | } |
| 1360 | |
| 1361 | if (ints & ATH9K_INT_GLOBAL) { |
| 1362 | ath_print(common, ATH_DBG_INTERRUPT, "enable IER\n"); |
| 1363 | REG_WRITE(ah, AR_IER, AR_IER_ENABLE); |
| 1364 | if (!AR_SREV_9100(ah)) { |
| 1365 | REG_WRITE(ah, AR_INTR_ASYNC_ENABLE, |
| 1366 | AR_INTR_MAC_IRQ); |
| 1367 | REG_WRITE(ah, AR_INTR_ASYNC_MASK, AR_INTR_MAC_IRQ); |
| 1368 | |
| 1369 | |
| 1370 | REG_WRITE(ah, AR_INTR_SYNC_ENABLE, |
| 1371 | AR_INTR_SYNC_DEFAULT); |
| 1372 | REG_WRITE(ah, AR_INTR_SYNC_MASK, |
| 1373 | AR_INTR_SYNC_DEFAULT); |
| 1374 | } |
| 1375 | ath_print(common, ATH_DBG_INTERRUPT, "AR_IMR 0x%x IER 0x%x\n", |
| 1376 | REG_READ(ah, AR_IMR), REG_READ(ah, AR_IER)); |
| 1377 | } |
| 1378 | |
| 1379 | return omask; |
| 1380 | } |
| 1381 | EXPORT_SYMBOL(ath9k_hw_set_interrupts); |