mac.c 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946
  1. /*
  2. * Copyright (c) 2008 Atheros Communications Inc.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #include "core.h"
  17. #include "hw.h"
  18. #include "reg.h"
  19. #include "phy.h"
  20. static void ath9k_hw_set_txq_interrupts(struct ath_hal *ah,
  21. struct ath9k_tx_queue_info *qi)
  22. {
  23. struct ath_hal_5416 *ahp = AH5416(ah);
  24. DPRINTF(ah->ah_sc, ATH_DBG_INTERRUPT,
  25. "tx ok 0x%x err 0x%x desc 0x%x eol 0x%x urn 0x%x\n",
  26. ahp->ah_txOkInterruptMask, ahp->ah_txErrInterruptMask,
  27. ahp->ah_txDescInterruptMask, ahp->ah_txEolInterruptMask,
  28. ahp->ah_txUrnInterruptMask);
  29. REG_WRITE(ah, AR_IMR_S0,
  30. SM(ahp->ah_txOkInterruptMask, AR_IMR_S0_QCU_TXOK)
  31. | SM(ahp->ah_txDescInterruptMask, AR_IMR_S0_QCU_TXDESC));
  32. REG_WRITE(ah, AR_IMR_S1,
  33. SM(ahp->ah_txErrInterruptMask, AR_IMR_S1_QCU_TXERR)
  34. | SM(ahp->ah_txEolInterruptMask, AR_IMR_S1_QCU_TXEOL));
  35. REG_RMW_FIELD(ah, AR_IMR_S2,
  36. AR_IMR_S2_QCU_TXURN, ahp->ah_txUrnInterruptMask);
  37. }
  38. u32 ath9k_hw_gettxbuf(struct ath_hal *ah, u32 q)
  39. {
  40. return REG_READ(ah, AR_QTXDP(q));
  41. }
  42. bool ath9k_hw_puttxbuf(struct ath_hal *ah, u32 q, u32 txdp)
  43. {
  44. REG_WRITE(ah, AR_QTXDP(q), txdp);
  45. return true;
  46. }
  47. bool ath9k_hw_txstart(struct ath_hal *ah, u32 q)
  48. {
  49. DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "queue %u\n", q);
  50. REG_WRITE(ah, AR_Q_TXE, 1 << q);
  51. return true;
  52. }
  53. u32 ath9k_hw_numtxpending(struct ath_hal *ah, u32 q)
  54. {
  55. u32 npend;
  56. npend = REG_READ(ah, AR_QSTS(q)) & AR_Q_STS_PEND_FR_CNT;
  57. if (npend == 0) {
  58. if (REG_READ(ah, AR_Q_TXE) & (1 << q))
  59. npend = 1;
  60. }
  61. return npend;
  62. }
  63. bool ath9k_hw_updatetxtriglevel(struct ath_hal *ah, bool bIncTrigLevel)
  64. {
  65. struct ath_hal_5416 *ahp = AH5416(ah);
  66. u32 txcfg, curLevel, newLevel;
  67. enum ath9k_int omask;
  68. if (ah->ah_txTrigLevel >= MAX_TX_FIFO_THRESHOLD)
  69. return false;
  70. omask = ath9k_hw_set_interrupts(ah, ahp->ah_maskReg & ~ATH9K_INT_GLOBAL);
  71. txcfg = REG_READ(ah, AR_TXCFG);
  72. curLevel = MS(txcfg, AR_FTRIG);
  73. newLevel = curLevel;
  74. if (bIncTrigLevel) {
  75. if (curLevel < MAX_TX_FIFO_THRESHOLD)
  76. newLevel++;
  77. } else if (curLevel > MIN_TX_FIFO_THRESHOLD)
  78. newLevel--;
  79. if (newLevel != curLevel)
  80. REG_WRITE(ah, AR_TXCFG,
  81. (txcfg & ~AR_FTRIG) | SM(newLevel, AR_FTRIG));
  82. ath9k_hw_set_interrupts(ah, omask);
  83. ah->ah_txTrigLevel = newLevel;
  84. return newLevel != curLevel;
  85. }
  86. bool ath9k_hw_stoptxdma(struct ath_hal *ah, u32 q)
  87. {
  88. u32 tsfLow, j, wait;
  89. REG_WRITE(ah, AR_Q_TXD, 1 << q);
  90. for (wait = 1000; wait != 0; wait--) {
  91. if (ath9k_hw_numtxpending(ah, q) == 0)
  92. break;
  93. udelay(100);
  94. }
  95. if (ath9k_hw_numtxpending(ah, q)) {
  96. DPRINTF(ah->ah_sc, ATH_DBG_QUEUE,
  97. "%s: Num of pending TX Frames %d on Q %d\n",
  98. __func__, ath9k_hw_numtxpending(ah, q), q);
  99. for (j = 0; j < 2; j++) {
  100. tsfLow = REG_READ(ah, AR_TSF_L32);
  101. REG_WRITE(ah, AR_QUIET2,
  102. SM(10, AR_QUIET2_QUIET_DUR));
  103. REG_WRITE(ah, AR_QUIET_PERIOD, 100);
  104. REG_WRITE(ah, AR_NEXT_QUIET_TIMER, tsfLow >> 10);
  105. REG_SET_BIT(ah, AR_TIMER_MODE,
  106. AR_QUIET_TIMER_EN);
  107. if ((REG_READ(ah, AR_TSF_L32) >> 10) == (tsfLow >> 10))
  108. break;
  109. DPRINTF(ah->ah_sc, ATH_DBG_QUEUE,
  110. "TSF have moved while trying to set "
  111. "quiet time TSF: 0x%08x\n", tsfLow);
  112. }
  113. REG_SET_BIT(ah, AR_DIAG_SW, AR_DIAG_FORCE_CH_IDLE_HIGH);
  114. udelay(200);
  115. REG_CLR_BIT(ah, AR_TIMER_MODE, AR_QUIET_TIMER_EN);
  116. wait = 1000;
  117. while (ath9k_hw_numtxpending(ah, q)) {
  118. if ((--wait) == 0) {
  119. DPRINTF(ah->ah_sc, ATH_DBG_XMIT,
  120. "Failed to stop Tx DMA in 100 "
  121. "msec after killing last frame\n");
  122. break;
  123. }
  124. udelay(100);
  125. }
  126. REG_CLR_BIT(ah, AR_DIAG_SW, AR_DIAG_FORCE_CH_IDLE_HIGH);
  127. }
  128. REG_WRITE(ah, AR_Q_TXD, 0);
  129. return wait != 0;
  130. }
  131. bool ath9k_hw_filltxdesc(struct ath_hal *ah, struct ath_desc *ds,
  132. u32 segLen, bool firstSeg,
  133. bool lastSeg, const struct ath_desc *ds0)
  134. {
  135. struct ar5416_desc *ads = AR5416DESC(ds);
  136. if (firstSeg) {
  137. ads->ds_ctl1 |= segLen | (lastSeg ? 0 : AR_TxMore);
  138. } else if (lastSeg) {
  139. ads->ds_ctl0 = 0;
  140. ads->ds_ctl1 = segLen;
  141. ads->ds_ctl2 = AR5416DESC_CONST(ds0)->ds_ctl2;
  142. ads->ds_ctl3 = AR5416DESC_CONST(ds0)->ds_ctl3;
  143. } else {
  144. ads->ds_ctl0 = 0;
  145. ads->ds_ctl1 = segLen | AR_TxMore;
  146. ads->ds_ctl2 = 0;
  147. ads->ds_ctl3 = 0;
  148. }
  149. ads->ds_txstatus0 = ads->ds_txstatus1 = 0;
  150. ads->ds_txstatus2 = ads->ds_txstatus3 = 0;
  151. ads->ds_txstatus4 = ads->ds_txstatus5 = 0;
  152. ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
  153. ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
  154. return true;
  155. }
  156. void ath9k_hw_cleartxdesc(struct ath_hal *ah, struct ath_desc *ds)
  157. {
  158. struct ar5416_desc *ads = AR5416DESC(ds);
  159. ads->ds_txstatus0 = ads->ds_txstatus1 = 0;
  160. ads->ds_txstatus2 = ads->ds_txstatus3 = 0;
  161. ads->ds_txstatus4 = ads->ds_txstatus5 = 0;
  162. ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
  163. ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
  164. }
  165. int ath9k_hw_txprocdesc(struct ath_hal *ah, struct ath_desc *ds)
  166. {
  167. struct ar5416_desc *ads = AR5416DESC(ds);
  168. if ((ads->ds_txstatus9 & AR_TxDone) == 0)
  169. return -EINPROGRESS;
  170. ds->ds_txstat.ts_seqnum = MS(ads->ds_txstatus9, AR_SeqNum);
  171. ds->ds_txstat.ts_tstamp = ads->AR_SendTimestamp;
  172. ds->ds_txstat.ts_status = 0;
  173. ds->ds_txstat.ts_flags = 0;
  174. if (ads->ds_txstatus1 & AR_ExcessiveRetries)
  175. ds->ds_txstat.ts_status |= ATH9K_TXERR_XRETRY;
  176. if (ads->ds_txstatus1 & AR_Filtered)
  177. ds->ds_txstat.ts_status |= ATH9K_TXERR_FILT;
  178. if (ads->ds_txstatus1 & AR_FIFOUnderrun) {
  179. ds->ds_txstat.ts_status |= ATH9K_TXERR_FIFO;
  180. ath9k_hw_updatetxtriglevel(ah, true);
  181. }
  182. if (ads->ds_txstatus9 & AR_TxOpExceeded)
  183. ds->ds_txstat.ts_status |= ATH9K_TXERR_XTXOP;
  184. if (ads->ds_txstatus1 & AR_TxTimerExpired)
  185. ds->ds_txstat.ts_status |= ATH9K_TXERR_TIMER_EXPIRED;
  186. if (ads->ds_txstatus1 & AR_DescCfgErr)
  187. ds->ds_txstat.ts_flags |= ATH9K_TX_DESC_CFG_ERR;
  188. if (ads->ds_txstatus1 & AR_TxDataUnderrun) {
  189. ds->ds_txstat.ts_flags |= ATH9K_TX_DATA_UNDERRUN;
  190. ath9k_hw_updatetxtriglevel(ah, true);
  191. }
  192. if (ads->ds_txstatus1 & AR_TxDelimUnderrun) {
  193. ds->ds_txstat.ts_flags |= ATH9K_TX_DELIM_UNDERRUN;
  194. ath9k_hw_updatetxtriglevel(ah, true);
  195. }
  196. if (ads->ds_txstatus0 & AR_TxBaStatus) {
  197. ds->ds_txstat.ts_flags |= ATH9K_TX_BA;
  198. ds->ds_txstat.ba_low = ads->AR_BaBitmapLow;
  199. ds->ds_txstat.ba_high = ads->AR_BaBitmapHigh;
  200. }
  201. ds->ds_txstat.ts_rateindex = MS(ads->ds_txstatus9, AR_FinalTxIdx);
  202. switch (ds->ds_txstat.ts_rateindex) {
  203. case 0:
  204. ds->ds_txstat.ts_ratecode = MS(ads->ds_ctl3, AR_XmitRate0);
  205. break;
  206. case 1:
  207. ds->ds_txstat.ts_ratecode = MS(ads->ds_ctl3, AR_XmitRate1);
  208. break;
  209. case 2:
  210. ds->ds_txstat.ts_ratecode = MS(ads->ds_ctl3, AR_XmitRate2);
  211. break;
  212. case 3:
  213. ds->ds_txstat.ts_ratecode = MS(ads->ds_ctl3, AR_XmitRate3);
  214. break;
  215. }
  216. ds->ds_txstat.ts_rssi = MS(ads->ds_txstatus5, AR_TxRSSICombined);
  217. ds->ds_txstat.ts_rssi_ctl0 = MS(ads->ds_txstatus0, AR_TxRSSIAnt00);
  218. ds->ds_txstat.ts_rssi_ctl1 = MS(ads->ds_txstatus0, AR_TxRSSIAnt01);
  219. ds->ds_txstat.ts_rssi_ctl2 = MS(ads->ds_txstatus0, AR_TxRSSIAnt02);
  220. ds->ds_txstat.ts_rssi_ext0 = MS(ads->ds_txstatus5, AR_TxRSSIAnt10);
  221. ds->ds_txstat.ts_rssi_ext1 = MS(ads->ds_txstatus5, AR_TxRSSIAnt11);
  222. ds->ds_txstat.ts_rssi_ext2 = MS(ads->ds_txstatus5, AR_TxRSSIAnt12);
  223. ds->ds_txstat.evm0 = ads->AR_TxEVM0;
  224. ds->ds_txstat.evm1 = ads->AR_TxEVM1;
  225. ds->ds_txstat.evm2 = ads->AR_TxEVM2;
  226. ds->ds_txstat.ts_shortretry = MS(ads->ds_txstatus1, AR_RTSFailCnt);
  227. ds->ds_txstat.ts_longretry = MS(ads->ds_txstatus1, AR_DataFailCnt);
  228. ds->ds_txstat.ts_virtcol = MS(ads->ds_txstatus1, AR_VirtRetryCnt);
  229. ds->ds_txstat.ts_antenna = 1;
  230. return 0;
  231. }
  232. void ath9k_hw_set11n_txdesc(struct ath_hal *ah, struct ath_desc *ds,
  233. u32 pktLen, enum ath9k_pkt_type type, u32 txPower,
  234. u32 keyIx, enum ath9k_key_type keyType, u32 flags)
  235. {
  236. struct ar5416_desc *ads = AR5416DESC(ds);
  237. struct ath_hal_5416 *ahp = AH5416(ah);
  238. txPower += ahp->ah_txPowerIndexOffset;
  239. if (txPower > 63)
  240. txPower = 63;
  241. ads->ds_ctl0 = (pktLen & AR_FrameLen)
  242. | (flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
  243. | SM(txPower, AR_XmitPower)
  244. | (flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
  245. | (flags & ATH9K_TXDESC_CLRDMASK ? AR_ClrDestMask : 0)
  246. | (flags & ATH9K_TXDESC_INTREQ ? AR_TxIntrReq : 0)
  247. | (keyIx != ATH9K_TXKEYIX_INVALID ? AR_DestIdxValid : 0);
  248. ads->ds_ctl1 =
  249. (keyIx != ATH9K_TXKEYIX_INVALID ? SM(keyIx, AR_DestIdx) : 0)
  250. | SM(type, AR_FrameType)
  251. | (flags & ATH9K_TXDESC_NOACK ? AR_NoAck : 0)
  252. | (flags & ATH9K_TXDESC_EXT_ONLY ? AR_ExtOnly : 0)
  253. | (flags & ATH9K_TXDESC_EXT_AND_CTL ? AR_ExtAndCtl : 0);
  254. ads->ds_ctl6 = SM(keyType, AR_EncrType);
  255. if (AR_SREV_9285(ah)) {
  256. ads->ds_ctl8 = 0;
  257. ads->ds_ctl9 = 0;
  258. ads->ds_ctl10 = 0;
  259. ads->ds_ctl11 = 0;
  260. }
  261. }
  262. void ath9k_hw_set11n_ratescenario(struct ath_hal *ah, struct ath_desc *ds,
  263. struct ath_desc *lastds,
  264. u32 durUpdateEn, u32 rtsctsRate,
  265. u32 rtsctsDuration,
  266. struct ath9k_11n_rate_series series[],
  267. u32 nseries, u32 flags)
  268. {
  269. struct ar5416_desc *ads = AR5416DESC(ds);
  270. struct ar5416_desc *last_ads = AR5416DESC(lastds);
  271. u32 ds_ctl0;
  272. (void) nseries;
  273. (void) rtsctsDuration;
  274. if (flags & (ATH9K_TXDESC_RTSENA | ATH9K_TXDESC_CTSENA)) {
  275. ds_ctl0 = ads->ds_ctl0;
  276. if (flags & ATH9K_TXDESC_RTSENA) {
  277. ds_ctl0 &= ~AR_CTSEnable;
  278. ds_ctl0 |= AR_RTSEnable;
  279. } else {
  280. ds_ctl0 &= ~AR_RTSEnable;
  281. ds_ctl0 |= AR_CTSEnable;
  282. }
  283. ads->ds_ctl0 = ds_ctl0;
  284. } else {
  285. ads->ds_ctl0 =
  286. (ads->ds_ctl0 & ~(AR_RTSEnable | AR_CTSEnable));
  287. }
  288. ads->ds_ctl2 = set11nTries(series, 0)
  289. | set11nTries(series, 1)
  290. | set11nTries(series, 2)
  291. | set11nTries(series, 3)
  292. | (durUpdateEn ? AR_DurUpdateEna : 0)
  293. | SM(0, AR_BurstDur);
  294. ads->ds_ctl3 = set11nRate(series, 0)
  295. | set11nRate(series, 1)
  296. | set11nRate(series, 2)
  297. | set11nRate(series, 3);
  298. ads->ds_ctl4 = set11nPktDurRTSCTS(series, 0)
  299. | set11nPktDurRTSCTS(series, 1);
  300. ads->ds_ctl5 = set11nPktDurRTSCTS(series, 2)
  301. | set11nPktDurRTSCTS(series, 3);
  302. ads->ds_ctl7 = set11nRateFlags(series, 0)
  303. | set11nRateFlags(series, 1)
  304. | set11nRateFlags(series, 2)
  305. | set11nRateFlags(series, 3)
  306. | SM(rtsctsRate, AR_RTSCTSRate);
  307. last_ads->ds_ctl2 = ads->ds_ctl2;
  308. last_ads->ds_ctl3 = ads->ds_ctl3;
  309. }
  310. void ath9k_hw_set11n_aggr_first(struct ath_hal *ah, struct ath_desc *ds,
  311. u32 aggrLen)
  312. {
  313. struct ar5416_desc *ads = AR5416DESC(ds);
  314. ads->ds_ctl1 |= (AR_IsAggr | AR_MoreAggr);
  315. ads->ds_ctl6 &= ~AR_AggrLen;
  316. ads->ds_ctl6 |= SM(aggrLen, AR_AggrLen);
  317. }
  318. void ath9k_hw_set11n_aggr_middle(struct ath_hal *ah, struct ath_desc *ds,
  319. u32 numDelims)
  320. {
  321. struct ar5416_desc *ads = AR5416DESC(ds);
  322. unsigned int ctl6;
  323. ads->ds_ctl1 |= (AR_IsAggr | AR_MoreAggr);
  324. ctl6 = ads->ds_ctl6;
  325. ctl6 &= ~AR_PadDelim;
  326. ctl6 |= SM(numDelims, AR_PadDelim);
  327. ads->ds_ctl6 = ctl6;
  328. }
  329. void ath9k_hw_set11n_aggr_last(struct ath_hal *ah, struct ath_desc *ds)
  330. {
  331. struct ar5416_desc *ads = AR5416DESC(ds);
  332. ads->ds_ctl1 |= AR_IsAggr;
  333. ads->ds_ctl1 &= ~AR_MoreAggr;
  334. ads->ds_ctl6 &= ~AR_PadDelim;
  335. }
  336. void ath9k_hw_clr11n_aggr(struct ath_hal *ah, struct ath_desc *ds)
  337. {
  338. struct ar5416_desc *ads = AR5416DESC(ds);
  339. ads->ds_ctl1 &= (~AR_IsAggr & ~AR_MoreAggr);
  340. }
  341. void ath9k_hw_set11n_burstduration(struct ath_hal *ah, struct ath_desc *ds,
  342. u32 burstDuration)
  343. {
  344. struct ar5416_desc *ads = AR5416DESC(ds);
  345. ads->ds_ctl2 &= ~AR_BurstDur;
  346. ads->ds_ctl2 |= SM(burstDuration, AR_BurstDur);
  347. }
  348. void ath9k_hw_set11n_virtualmorefrag(struct ath_hal *ah, struct ath_desc *ds,
  349. u32 vmf)
  350. {
  351. struct ar5416_desc *ads = AR5416DESC(ds);
  352. if (vmf)
  353. ads->ds_ctl0 |= AR_VirtMoreFrag;
  354. else
  355. ads->ds_ctl0 &= ~AR_VirtMoreFrag;
  356. }
  357. void ath9k_hw_gettxintrtxqs(struct ath_hal *ah, u32 *txqs)
  358. {
  359. struct ath_hal_5416 *ahp = AH5416(ah);
  360. *txqs &= ahp->ah_intrTxqs;
  361. ahp->ah_intrTxqs &= ~(*txqs);
  362. }
  363. bool ath9k_hw_set_txq_props(struct ath_hal *ah, int q,
  364. const struct ath9k_tx_queue_info *qinfo)
  365. {
  366. u32 cw;
  367. struct ath_hal_5416 *ahp = AH5416(ah);
  368. struct ath9k_hw_capabilities *pCap = &ah->ah_caps;
  369. struct ath9k_tx_queue_info *qi;
  370. if (q >= pCap->total_queues) {
  371. DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "invalid queue num %u\n", q);
  372. return false;
  373. }
  374. qi = &ahp->ah_txq[q];
  375. if (qi->tqi_type == ATH9K_TX_QUEUE_INACTIVE) {
  376. DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "inactive queue\n");
  377. return false;
  378. }
  379. DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "queue %p\n", qi);
  380. qi->tqi_ver = qinfo->tqi_ver;
  381. qi->tqi_subtype = qinfo->tqi_subtype;
  382. qi->tqi_qflags = qinfo->tqi_qflags;
  383. qi->tqi_priority = qinfo->tqi_priority;
  384. if (qinfo->tqi_aifs != ATH9K_TXQ_USEDEFAULT)
  385. qi->tqi_aifs = min(qinfo->tqi_aifs, 255U);
  386. else
  387. qi->tqi_aifs = INIT_AIFS;
  388. if (qinfo->tqi_cwmin != ATH9K_TXQ_USEDEFAULT) {
  389. cw = min(qinfo->tqi_cwmin, 1024U);
  390. qi->tqi_cwmin = 1;
  391. while (qi->tqi_cwmin < cw)
  392. qi->tqi_cwmin = (qi->tqi_cwmin << 1) | 1;
  393. } else
  394. qi->tqi_cwmin = qinfo->tqi_cwmin;
  395. if (qinfo->tqi_cwmax != ATH9K_TXQ_USEDEFAULT) {
  396. cw = min(qinfo->tqi_cwmax, 1024U);
  397. qi->tqi_cwmax = 1;
  398. while (qi->tqi_cwmax < cw)
  399. qi->tqi_cwmax = (qi->tqi_cwmax << 1) | 1;
  400. } else
  401. qi->tqi_cwmax = INIT_CWMAX;
  402. if (qinfo->tqi_shretry != 0)
  403. qi->tqi_shretry = min((u32) qinfo->tqi_shretry, 15U);
  404. else
  405. qi->tqi_shretry = INIT_SH_RETRY;
  406. if (qinfo->tqi_lgretry != 0)
  407. qi->tqi_lgretry = min((u32) qinfo->tqi_lgretry, 15U);
  408. else
  409. qi->tqi_lgretry = INIT_LG_RETRY;
  410. qi->tqi_cbrPeriod = qinfo->tqi_cbrPeriod;
  411. qi->tqi_cbrOverflowLimit = qinfo->tqi_cbrOverflowLimit;
  412. qi->tqi_burstTime = qinfo->tqi_burstTime;
  413. qi->tqi_readyTime = qinfo->tqi_readyTime;
  414. switch (qinfo->tqi_subtype) {
  415. case ATH9K_WME_UPSD:
  416. if (qi->tqi_type == ATH9K_TX_QUEUE_DATA)
  417. qi->tqi_intFlags = ATH9K_TXQ_USE_LOCKOUT_BKOFF_DIS;
  418. break;
  419. default:
  420. break;
  421. }
  422. return true;
  423. }
  424. bool ath9k_hw_get_txq_props(struct ath_hal *ah, int q,
  425. struct ath9k_tx_queue_info *qinfo)
  426. {
  427. struct ath_hal_5416 *ahp = AH5416(ah);
  428. struct ath9k_hw_capabilities *pCap = &ah->ah_caps;
  429. struct ath9k_tx_queue_info *qi;
  430. if (q >= pCap->total_queues) {
  431. DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "invalid queue num %u\n", q);
  432. return false;
  433. }
  434. qi = &ahp->ah_txq[q];
  435. if (qi->tqi_type == ATH9K_TX_QUEUE_INACTIVE) {
  436. DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "inactive queue\n");
  437. return false;
  438. }
  439. qinfo->tqi_qflags = qi->tqi_qflags;
  440. qinfo->tqi_ver = qi->tqi_ver;
  441. qinfo->tqi_subtype = qi->tqi_subtype;
  442. qinfo->tqi_qflags = qi->tqi_qflags;
  443. qinfo->tqi_priority = qi->tqi_priority;
  444. qinfo->tqi_aifs = qi->tqi_aifs;
  445. qinfo->tqi_cwmin = qi->tqi_cwmin;
  446. qinfo->tqi_cwmax = qi->tqi_cwmax;
  447. qinfo->tqi_shretry = qi->tqi_shretry;
  448. qinfo->tqi_lgretry = qi->tqi_lgretry;
  449. qinfo->tqi_cbrPeriod = qi->tqi_cbrPeriod;
  450. qinfo->tqi_cbrOverflowLimit = qi->tqi_cbrOverflowLimit;
  451. qinfo->tqi_burstTime = qi->tqi_burstTime;
  452. qinfo->tqi_readyTime = qi->tqi_readyTime;
  453. return true;
  454. }
  455. int ath9k_hw_setuptxqueue(struct ath_hal *ah, enum ath9k_tx_queue type,
  456. const struct ath9k_tx_queue_info *qinfo)
  457. {
  458. struct ath_hal_5416 *ahp = AH5416(ah);
  459. struct ath9k_tx_queue_info *qi;
  460. struct ath9k_hw_capabilities *pCap = &ah->ah_caps;
  461. int q;
  462. switch (type) {
  463. case ATH9K_TX_QUEUE_BEACON:
  464. q = pCap->total_queues - 1;
  465. break;
  466. case ATH9K_TX_QUEUE_CAB:
  467. q = pCap->total_queues - 2;
  468. break;
  469. case ATH9K_TX_QUEUE_PSPOLL:
  470. q = 1;
  471. break;
  472. case ATH9K_TX_QUEUE_UAPSD:
  473. q = pCap->total_queues - 3;
  474. break;
  475. case ATH9K_TX_QUEUE_DATA:
  476. for (q = 0; q < pCap->total_queues; q++)
  477. if (ahp->ah_txq[q].tqi_type ==
  478. ATH9K_TX_QUEUE_INACTIVE)
  479. break;
  480. if (q == pCap->total_queues) {
  481. DPRINTF(ah->ah_sc, ATH_DBG_QUEUE,
  482. "no available tx queue\n");
  483. return -1;
  484. }
  485. break;
  486. default:
  487. DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "bad tx queue type %u\n", type);
  488. return -1;
  489. }
  490. DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "queue %u\n", q);
  491. qi = &ahp->ah_txq[q];
  492. if (qi->tqi_type != ATH9K_TX_QUEUE_INACTIVE) {
  493. DPRINTF(ah->ah_sc, ATH_DBG_QUEUE,
  494. "tx queue %u already active\n", q);
  495. return -1;
  496. }
  497. memset(qi, 0, sizeof(struct ath9k_tx_queue_info));
  498. qi->tqi_type = type;
  499. if (qinfo == NULL) {
  500. qi->tqi_qflags =
  501. TXQ_FLAG_TXOKINT_ENABLE
  502. | TXQ_FLAG_TXERRINT_ENABLE
  503. | TXQ_FLAG_TXDESCINT_ENABLE | TXQ_FLAG_TXURNINT_ENABLE;
  504. qi->tqi_aifs = INIT_AIFS;
  505. qi->tqi_cwmin = ATH9K_TXQ_USEDEFAULT;
  506. qi->tqi_cwmax = INIT_CWMAX;
  507. qi->tqi_shretry = INIT_SH_RETRY;
  508. qi->tqi_lgretry = INIT_LG_RETRY;
  509. qi->tqi_physCompBuf = 0;
  510. } else {
  511. qi->tqi_physCompBuf = qinfo->tqi_physCompBuf;
  512. (void) ath9k_hw_set_txq_props(ah, q, qinfo);
  513. }
  514. return q;
  515. }
  516. bool ath9k_hw_releasetxqueue(struct ath_hal *ah, u32 q)
  517. {
  518. struct ath_hal_5416 *ahp = AH5416(ah);
  519. struct ath9k_hw_capabilities *pCap = &ah->ah_caps;
  520. struct ath9k_tx_queue_info *qi;
  521. if (q >= pCap->total_queues) {
  522. DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "invalid queue num %u\n", q);
  523. return false;
  524. }
  525. qi = &ahp->ah_txq[q];
  526. if (qi->tqi_type == ATH9K_TX_QUEUE_INACTIVE) {
  527. DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "inactive queue %u\n", q);
  528. return false;
  529. }
  530. DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "release queue %u\n", q);
  531. qi->tqi_type = ATH9K_TX_QUEUE_INACTIVE;
  532. ahp->ah_txOkInterruptMask &= ~(1 << q);
  533. ahp->ah_txErrInterruptMask &= ~(1 << q);
  534. ahp->ah_txDescInterruptMask &= ~(1 << q);
  535. ahp->ah_txEolInterruptMask &= ~(1 << q);
  536. ahp->ah_txUrnInterruptMask &= ~(1 << q);
  537. ath9k_hw_set_txq_interrupts(ah, qi);
  538. return true;
  539. }
  540. bool ath9k_hw_resettxqueue(struct ath_hal *ah, u32 q)
  541. {
  542. struct ath_hal_5416 *ahp = AH5416(ah);
  543. struct ath9k_hw_capabilities *pCap = &ah->ah_caps;
  544. struct ath9k_channel *chan = ah->ah_curchan;
  545. struct ath9k_tx_queue_info *qi;
  546. u32 cwMin, chanCwMin, value;
  547. if (q >= pCap->total_queues) {
  548. DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "invalid queue num %u\n", q);
  549. return false;
  550. }
  551. qi = &ahp->ah_txq[q];
  552. if (qi->tqi_type == ATH9K_TX_QUEUE_INACTIVE) {
  553. DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "inactive queue %u\n", q);
  554. return true;
  555. }
  556. DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, "reset queue %u\n", q);
  557. if (qi->tqi_cwmin == ATH9K_TXQ_USEDEFAULT) {
  558. if (chan && IS_CHAN_B(chan))
  559. chanCwMin = INIT_CWMIN_11B;
  560. else
  561. chanCwMin = INIT_CWMIN;
  562. for (cwMin = 1; cwMin < chanCwMin; cwMin = (cwMin << 1) | 1);
  563. } else
  564. cwMin = qi->tqi_cwmin;
  565. REG_WRITE(ah, AR_DLCL_IFS(q),
  566. SM(cwMin, AR_D_LCL_IFS_CWMIN) |
  567. SM(qi->tqi_cwmax, AR_D_LCL_IFS_CWMAX) |
  568. SM(qi->tqi_aifs, AR_D_LCL_IFS_AIFS));
  569. REG_WRITE(ah, AR_DRETRY_LIMIT(q),
  570. SM(INIT_SSH_RETRY, AR_D_RETRY_LIMIT_STA_SH) |
  571. SM(INIT_SLG_RETRY, AR_D_RETRY_LIMIT_STA_LG) |
  572. SM(qi->tqi_shretry, AR_D_RETRY_LIMIT_FR_SH));
  573. REG_WRITE(ah, AR_QMISC(q), AR_Q_MISC_DCU_EARLY_TERM_REQ);
  574. REG_WRITE(ah, AR_DMISC(q),
  575. AR_D_MISC_CW_BKOFF_EN | AR_D_MISC_FRAG_WAIT_EN | 0x2);
  576. if (qi->tqi_cbrPeriod) {
  577. REG_WRITE(ah, AR_QCBRCFG(q),
  578. SM(qi->tqi_cbrPeriod, AR_Q_CBRCFG_INTERVAL) |
  579. SM(qi->tqi_cbrOverflowLimit, AR_Q_CBRCFG_OVF_THRESH));
  580. REG_WRITE(ah, AR_QMISC(q),
  581. REG_READ(ah, AR_QMISC(q)) | AR_Q_MISC_FSP_CBR |
  582. (qi->tqi_cbrOverflowLimit ?
  583. AR_Q_MISC_CBR_EXP_CNTR_LIMIT_EN : 0));
  584. }
  585. if (qi->tqi_readyTime && (qi->tqi_type != ATH9K_TX_QUEUE_CAB)) {
  586. REG_WRITE(ah, AR_QRDYTIMECFG(q),
  587. SM(qi->tqi_readyTime, AR_Q_RDYTIMECFG_DURATION) |
  588. AR_Q_RDYTIMECFG_EN);
  589. }
  590. REG_WRITE(ah, AR_DCHNTIME(q),
  591. SM(qi->tqi_burstTime, AR_D_CHNTIME_DUR) |
  592. (qi->tqi_burstTime ? AR_D_CHNTIME_EN : 0));
  593. if (qi->tqi_burstTime
  594. && (qi->tqi_qflags & TXQ_FLAG_RDYTIME_EXP_POLICY_ENABLE)) {
  595. REG_WRITE(ah, AR_QMISC(q),
  596. REG_READ(ah, AR_QMISC(q)) |
  597. AR_Q_MISC_RDYTIME_EXP_POLICY);
  598. }
  599. if (qi->tqi_qflags & TXQ_FLAG_BACKOFF_DISABLE) {
  600. REG_WRITE(ah, AR_DMISC(q),
  601. REG_READ(ah, AR_DMISC(q)) |
  602. AR_D_MISC_POST_FR_BKOFF_DIS);
  603. }
  604. if (qi->tqi_qflags & TXQ_FLAG_FRAG_BURST_BACKOFF_ENABLE) {
  605. REG_WRITE(ah, AR_DMISC(q),
  606. REG_READ(ah, AR_DMISC(q)) |
  607. AR_D_MISC_FRAG_BKOFF_EN);
  608. }
  609. switch (qi->tqi_type) {
  610. case ATH9K_TX_QUEUE_BEACON:
  611. REG_WRITE(ah, AR_QMISC(q), REG_READ(ah, AR_QMISC(q))
  612. | AR_Q_MISC_FSP_DBA_GATED
  613. | AR_Q_MISC_BEACON_USE
  614. | AR_Q_MISC_CBR_INCR_DIS1);
  615. REG_WRITE(ah, AR_DMISC(q), REG_READ(ah, AR_DMISC(q))
  616. | (AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL <<
  617. AR_D_MISC_ARB_LOCKOUT_CNTRL_S)
  618. | AR_D_MISC_BEACON_USE
  619. | AR_D_MISC_POST_FR_BKOFF_DIS);
  620. break;
  621. case ATH9K_TX_QUEUE_CAB:
  622. REG_WRITE(ah, AR_QMISC(q), REG_READ(ah, AR_QMISC(q))
  623. | AR_Q_MISC_FSP_DBA_GATED
  624. | AR_Q_MISC_CBR_INCR_DIS1
  625. | AR_Q_MISC_CBR_INCR_DIS0);
  626. value = (qi->tqi_readyTime -
  627. (ah->ah_config.sw_beacon_response_time -
  628. ah->ah_config.dma_beacon_response_time) -
  629. ah->ah_config.additional_swba_backoff) * 1024;
  630. REG_WRITE(ah, AR_QRDYTIMECFG(q),
  631. value | AR_Q_RDYTIMECFG_EN);
  632. REG_WRITE(ah, AR_DMISC(q), REG_READ(ah, AR_DMISC(q))
  633. | (AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL <<
  634. AR_D_MISC_ARB_LOCKOUT_CNTRL_S));
  635. break;
  636. case ATH9K_TX_QUEUE_PSPOLL:
  637. REG_WRITE(ah, AR_QMISC(q),
  638. REG_READ(ah, AR_QMISC(q)) | AR_Q_MISC_CBR_INCR_DIS1);
  639. break;
  640. case ATH9K_TX_QUEUE_UAPSD:
  641. REG_WRITE(ah, AR_DMISC(q), REG_READ(ah, AR_DMISC(q)) |
  642. AR_D_MISC_POST_FR_BKOFF_DIS);
  643. break;
  644. default:
  645. break;
  646. }
  647. if (qi->tqi_intFlags & ATH9K_TXQ_USE_LOCKOUT_BKOFF_DIS) {
  648. REG_WRITE(ah, AR_DMISC(q),
  649. REG_READ(ah, AR_DMISC(q)) |
  650. SM(AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL,
  651. AR_D_MISC_ARB_LOCKOUT_CNTRL) |
  652. AR_D_MISC_POST_FR_BKOFF_DIS);
  653. }
  654. if (qi->tqi_qflags & TXQ_FLAG_TXOKINT_ENABLE)
  655. ahp->ah_txOkInterruptMask |= 1 << q;
  656. else
  657. ahp->ah_txOkInterruptMask &= ~(1 << q);
  658. if (qi->tqi_qflags & TXQ_FLAG_TXERRINT_ENABLE)
  659. ahp->ah_txErrInterruptMask |= 1 << q;
  660. else
  661. ahp->ah_txErrInterruptMask &= ~(1 << q);
  662. if (qi->tqi_qflags & TXQ_FLAG_TXDESCINT_ENABLE)
  663. ahp->ah_txDescInterruptMask |= 1 << q;
  664. else
  665. ahp->ah_txDescInterruptMask &= ~(1 << q);
  666. if (qi->tqi_qflags & TXQ_FLAG_TXEOLINT_ENABLE)
  667. ahp->ah_txEolInterruptMask |= 1 << q;
  668. else
  669. ahp->ah_txEolInterruptMask &= ~(1 << q);
  670. if (qi->tqi_qflags & TXQ_FLAG_TXURNINT_ENABLE)
  671. ahp->ah_txUrnInterruptMask |= 1 << q;
  672. else
  673. ahp->ah_txUrnInterruptMask &= ~(1 << q);
  674. ath9k_hw_set_txq_interrupts(ah, qi);
  675. return true;
  676. }
  677. int ath9k_hw_rxprocdesc(struct ath_hal *ah, struct ath_desc *ds,
  678. u32 pa, struct ath_desc *nds, u64 tsf)
  679. {
  680. struct ar5416_desc ads;
  681. struct ar5416_desc *adsp = AR5416DESC(ds);
  682. u32 phyerr;
  683. if ((adsp->ds_rxstatus8 & AR_RxDone) == 0)
  684. return -EINPROGRESS;
  685. ads.u.rx = adsp->u.rx;
  686. ds->ds_rxstat.rs_status = 0;
  687. ds->ds_rxstat.rs_flags = 0;
  688. ds->ds_rxstat.rs_datalen = ads.ds_rxstatus1 & AR_DataLen;
  689. ds->ds_rxstat.rs_tstamp = ads.AR_RcvTimestamp;
  690. ds->ds_rxstat.rs_rssi = MS(ads.ds_rxstatus4, AR_RxRSSICombined);
  691. ds->ds_rxstat.rs_rssi_ctl0 = MS(ads.ds_rxstatus0, AR_RxRSSIAnt00);
  692. ds->ds_rxstat.rs_rssi_ctl1 = MS(ads.ds_rxstatus0, AR_RxRSSIAnt01);
  693. ds->ds_rxstat.rs_rssi_ctl2 = MS(ads.ds_rxstatus0, AR_RxRSSIAnt02);
  694. ds->ds_rxstat.rs_rssi_ext0 = MS(ads.ds_rxstatus4, AR_RxRSSIAnt10);
  695. ds->ds_rxstat.rs_rssi_ext1 = MS(ads.ds_rxstatus4, AR_RxRSSIAnt11);
  696. ds->ds_rxstat.rs_rssi_ext2 = MS(ads.ds_rxstatus4, AR_RxRSSIAnt12);
  697. if (ads.ds_rxstatus8 & AR_RxKeyIdxValid)
  698. ds->ds_rxstat.rs_keyix = MS(ads.ds_rxstatus8, AR_KeyIdx);
  699. else
  700. ds->ds_rxstat.rs_keyix = ATH9K_RXKEYIX_INVALID;
  701. ds->ds_rxstat.rs_rate = RXSTATUS_RATE(ah, (&ads));
  702. ds->ds_rxstat.rs_more = (ads.ds_rxstatus1 & AR_RxMore) ? 1 : 0;
  703. ds->ds_rxstat.rs_isaggr = (ads.ds_rxstatus8 & AR_RxAggr) ? 1 : 0;
  704. ds->ds_rxstat.rs_moreaggr =
  705. (ads.ds_rxstatus8 & AR_RxMoreAggr) ? 1 : 0;
  706. ds->ds_rxstat.rs_antenna = MS(ads.ds_rxstatus3, AR_RxAntenna);
  707. ds->ds_rxstat.rs_flags =
  708. (ads.ds_rxstatus3 & AR_GI) ? ATH9K_RX_GI : 0;
  709. ds->ds_rxstat.rs_flags |=
  710. (ads.ds_rxstatus3 & AR_2040) ? ATH9K_RX_2040 : 0;
  711. if (ads.ds_rxstatus8 & AR_PreDelimCRCErr)
  712. ds->ds_rxstat.rs_flags |= ATH9K_RX_DELIM_CRC_PRE;
  713. if (ads.ds_rxstatus8 & AR_PostDelimCRCErr)
  714. ds->ds_rxstat.rs_flags |= ATH9K_RX_DELIM_CRC_POST;
  715. if (ads.ds_rxstatus8 & AR_DecryptBusyErr)
  716. ds->ds_rxstat.rs_flags |= ATH9K_RX_DECRYPT_BUSY;
  717. if ((ads.ds_rxstatus8 & AR_RxFrameOK) == 0) {
  718. if (ads.ds_rxstatus8 & AR_CRCErr)
  719. ds->ds_rxstat.rs_status |= ATH9K_RXERR_CRC;
  720. else if (ads.ds_rxstatus8 & AR_PHYErr) {
  721. ds->ds_rxstat.rs_status |= ATH9K_RXERR_PHY;
  722. phyerr = MS(ads.ds_rxstatus8, AR_PHYErrCode);
  723. ds->ds_rxstat.rs_phyerr = phyerr;
  724. } else if (ads.ds_rxstatus8 & AR_DecryptCRCErr)
  725. ds->ds_rxstat.rs_status |= ATH9K_RXERR_DECRYPT;
  726. else if (ads.ds_rxstatus8 & AR_MichaelErr)
  727. ds->ds_rxstat.rs_status |= ATH9K_RXERR_MIC;
  728. }
  729. return 0;
  730. }
  731. bool ath9k_hw_setuprxdesc(struct ath_hal *ah, struct ath_desc *ds,
  732. u32 size, u32 flags)
  733. {
  734. struct ar5416_desc *ads = AR5416DESC(ds);
  735. struct ath9k_hw_capabilities *pCap = &ah->ah_caps;
  736. ads->ds_ctl1 = size & AR_BufLen;
  737. if (flags & ATH9K_RXDESC_INTREQ)
  738. ads->ds_ctl1 |= AR_RxIntrReq;
  739. ads->ds_rxstatus8 &= ~AR_RxDone;
  740. if (!(pCap->hw_caps & ATH9K_HW_CAP_AUTOSLEEP))
  741. memset(&(ads->u), 0, sizeof(ads->u));
  742. return true;
  743. }
  744. bool ath9k_hw_setrxabort(struct ath_hal *ah, bool set)
  745. {
  746. u32 reg;
  747. if (set) {
  748. REG_SET_BIT(ah, AR_DIAG_SW,
  749. (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT));
  750. if (!ath9k_hw_wait(ah, AR_OBS_BUS_1, AR_OBS_BUS_1_RX_STATE, 0)) {
  751. REG_CLR_BIT(ah, AR_DIAG_SW,
  752. (AR_DIAG_RX_DIS |
  753. AR_DIAG_RX_ABORT));
  754. reg = REG_READ(ah, AR_OBS_BUS_1);
  755. DPRINTF(ah->ah_sc, ATH_DBG_FATAL,
  756. "rx failed to go idle in 10 ms RXSM=0x%x\n", reg);
  757. return false;
  758. }
  759. } else {
  760. REG_CLR_BIT(ah, AR_DIAG_SW,
  761. (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT));
  762. }
  763. return true;
  764. }
  765. void ath9k_hw_putrxbuf(struct ath_hal *ah, u32 rxdp)
  766. {
  767. REG_WRITE(ah, AR_RXDP, rxdp);
  768. }
  769. void ath9k_hw_rxena(struct ath_hal *ah)
  770. {
  771. REG_WRITE(ah, AR_CR, AR_CR_RXE);
  772. }
  773. void ath9k_hw_startpcureceive(struct ath_hal *ah)
  774. {
  775. ath9k_enable_mib_counters(ah);
  776. ath9k_ani_reset(ah);
  777. REG_CLR_BIT(ah, AR_DIAG_SW, (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT));
  778. }
  779. void ath9k_hw_stoppcurecv(struct ath_hal *ah)
  780. {
  781. REG_SET_BIT(ah, AR_DIAG_SW, AR_DIAG_RX_DIS);
  782. ath9k_hw_disable_mib_counters(ah);
  783. }
  784. bool ath9k_hw_stopdmarecv(struct ath_hal *ah)
  785. {
  786. REG_WRITE(ah, AR_CR, AR_CR_RXD);
  787. if (!ath9k_hw_wait(ah, AR_CR, AR_CR_RXE, 0)) {
  788. DPRINTF(ah->ah_sc, ATH_DBG_QUEUE,
  789. "dma failed to stop in 10ms\n"
  790. "AR_CR=0x%08x\nAR_DIAG_SW=0x%08x\n",
  791. REG_READ(ah, AR_CR), REG_READ(ah, AR_DIAG_SW));
  792. return false;
  793. } else {
  794. return true;
  795. }
  796. }