main.c 58 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403
  1. /*
  2. * Copyright (c) 2008-2011 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 <linux/nl80211.h>
  17. #include <linux/delay.h>
  18. #include "ath9k.h"
  19. #include "btcoex.h"
  20. static void ath9k_set_assoc_state(struct ath_softc *sc,
  21. struct ieee80211_vif *vif);
  22. u8 ath9k_parse_mpdudensity(u8 mpdudensity)
  23. {
  24. /*
  25. * 802.11n D2.0 defined values for "Minimum MPDU Start Spacing":
  26. * 0 for no restriction
  27. * 1 for 1/4 us
  28. * 2 for 1/2 us
  29. * 3 for 1 us
  30. * 4 for 2 us
  31. * 5 for 4 us
  32. * 6 for 8 us
  33. * 7 for 16 us
  34. */
  35. switch (mpdudensity) {
  36. case 0:
  37. return 0;
  38. case 1:
  39. case 2:
  40. case 3:
  41. /* Our lower layer calculations limit our precision to
  42. 1 microsecond */
  43. return 1;
  44. case 4:
  45. return 2;
  46. case 5:
  47. return 4;
  48. case 6:
  49. return 8;
  50. case 7:
  51. return 16;
  52. default:
  53. return 0;
  54. }
  55. }
  56. static bool ath9k_has_pending_frames(struct ath_softc *sc, struct ath_txq *txq)
  57. {
  58. bool pending = false;
  59. spin_lock_bh(&txq->axq_lock);
  60. if (txq->axq_depth || !list_empty(&txq->axq_acq))
  61. pending = true;
  62. spin_unlock_bh(&txq->axq_lock);
  63. return pending;
  64. }
  65. static bool ath9k_setpower(struct ath_softc *sc, enum ath9k_power_mode mode)
  66. {
  67. unsigned long flags;
  68. bool ret;
  69. spin_lock_irqsave(&sc->sc_pm_lock, flags);
  70. ret = ath9k_hw_setpower(sc->sc_ah, mode);
  71. spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
  72. return ret;
  73. }
  74. void ath9k_ps_wakeup(struct ath_softc *sc)
  75. {
  76. struct ath_common *common = ath9k_hw_common(sc->sc_ah);
  77. unsigned long flags;
  78. enum ath9k_power_mode power_mode;
  79. spin_lock_irqsave(&sc->sc_pm_lock, flags);
  80. if (++sc->ps_usecount != 1)
  81. goto unlock;
  82. power_mode = sc->sc_ah->power_mode;
  83. ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_AWAKE);
  84. /*
  85. * While the hardware is asleep, the cycle counters contain no
  86. * useful data. Better clear them now so that they don't mess up
  87. * survey data results.
  88. */
  89. if (power_mode != ATH9K_PM_AWAKE) {
  90. spin_lock(&common->cc_lock);
  91. ath_hw_cycle_counters_update(common);
  92. memset(&common->cc_survey, 0, sizeof(common->cc_survey));
  93. memset(&common->cc_ani, 0, sizeof(common->cc_ani));
  94. spin_unlock(&common->cc_lock);
  95. }
  96. unlock:
  97. spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
  98. }
  99. void ath9k_ps_restore(struct ath_softc *sc)
  100. {
  101. struct ath_common *common = ath9k_hw_common(sc->sc_ah);
  102. enum ath9k_power_mode mode;
  103. unsigned long flags;
  104. bool reset;
  105. spin_lock_irqsave(&sc->sc_pm_lock, flags);
  106. if (--sc->ps_usecount != 0)
  107. goto unlock;
  108. if (sc->ps_idle) {
  109. ath9k_hw_setrxabort(sc->sc_ah, 1);
  110. ath9k_hw_stopdmarecv(sc->sc_ah, &reset);
  111. mode = ATH9K_PM_FULL_SLEEP;
  112. } else if (sc->ps_enabled &&
  113. !(sc->ps_flags & (PS_WAIT_FOR_BEACON |
  114. PS_WAIT_FOR_CAB |
  115. PS_WAIT_FOR_PSPOLL_DATA |
  116. PS_WAIT_FOR_TX_ACK |
  117. PS_WAIT_FOR_ANI))) {
  118. mode = ATH9K_PM_NETWORK_SLEEP;
  119. if (ath9k_hw_btcoex_is_enabled(sc->sc_ah))
  120. ath9k_btcoex_stop_gen_timer(sc);
  121. } else {
  122. goto unlock;
  123. }
  124. spin_lock(&common->cc_lock);
  125. ath_hw_cycle_counters_update(common);
  126. spin_unlock(&common->cc_lock);
  127. ath9k_hw_setpower(sc->sc_ah, mode);
  128. unlock:
  129. spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
  130. }
  131. static void __ath_cancel_work(struct ath_softc *sc)
  132. {
  133. cancel_work_sync(&sc->paprd_work);
  134. cancel_work_sync(&sc->hw_check_work);
  135. cancel_delayed_work_sync(&sc->tx_complete_work);
  136. cancel_delayed_work_sync(&sc->hw_pll_work);
  137. #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
  138. if (ath9k_hw_mci_is_enabled(sc->sc_ah))
  139. cancel_work_sync(&sc->mci_work);
  140. #endif
  141. }
  142. static void ath_cancel_work(struct ath_softc *sc)
  143. {
  144. __ath_cancel_work(sc);
  145. cancel_work_sync(&sc->hw_reset_work);
  146. }
  147. static void ath_restart_work(struct ath_softc *sc)
  148. {
  149. ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 0);
  150. if (AR_SREV_9340(sc->sc_ah) || AR_SREV_9485(sc->sc_ah) ||
  151. AR_SREV_9550(sc->sc_ah))
  152. ieee80211_queue_delayed_work(sc->hw, &sc->hw_pll_work,
  153. msecs_to_jiffies(ATH_PLL_WORK_INTERVAL));
  154. ath_start_rx_poll(sc, 3);
  155. ath_start_ani(sc);
  156. }
  157. static bool ath_prepare_reset(struct ath_softc *sc)
  158. {
  159. struct ath_hw *ah = sc->sc_ah;
  160. bool ret = true;
  161. ieee80211_stop_queues(sc->hw);
  162. sc->hw_busy_count = 0;
  163. ath_stop_ani(sc);
  164. del_timer_sync(&sc->rx_poll_timer);
  165. ath9k_debug_samp_bb_mac(sc);
  166. ath9k_hw_disable_interrupts(ah);
  167. if (!ath_drain_all_txq(sc))
  168. ret = false;
  169. if (!ath_stoprecv(sc))
  170. ret = false;
  171. return ret;
  172. }
  173. static bool ath_complete_reset(struct ath_softc *sc, bool start)
  174. {
  175. struct ath_hw *ah = sc->sc_ah;
  176. struct ath_common *common = ath9k_hw_common(ah);
  177. unsigned long flags;
  178. if (ath_startrecv(sc) != 0) {
  179. ath_err(common, "Unable to restart recv logic\n");
  180. return false;
  181. }
  182. ath9k_cmn_update_txpow(ah, sc->curtxpow,
  183. sc->config.txpowlimit, &sc->curtxpow);
  184. clear_bit(SC_OP_HW_RESET, &sc->sc_flags);
  185. ath9k_hw_set_interrupts(ah);
  186. ath9k_hw_enable_interrupts(ah);
  187. if (!(sc->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL) && start) {
  188. if (!test_bit(SC_OP_BEACONS, &sc->sc_flags))
  189. goto work;
  190. if (ah->opmode == NL80211_IFTYPE_STATION &&
  191. test_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags)) {
  192. spin_lock_irqsave(&sc->sc_pm_lock, flags);
  193. sc->ps_flags |= PS_BEACON_SYNC | PS_WAIT_FOR_BEACON;
  194. spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
  195. } else {
  196. ath9k_set_beacon(sc);
  197. }
  198. work:
  199. ath_restart_work(sc);
  200. }
  201. if ((ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) && sc->ant_rx != 3)
  202. ath_ant_comb_update(sc);
  203. ieee80211_wake_queues(sc->hw);
  204. return true;
  205. }
  206. static int ath_reset_internal(struct ath_softc *sc, struct ath9k_channel *hchan)
  207. {
  208. struct ath_hw *ah = sc->sc_ah;
  209. struct ath_common *common = ath9k_hw_common(ah);
  210. struct ath9k_hw_cal_data *caldata = NULL;
  211. bool fastcc = true;
  212. int r;
  213. __ath_cancel_work(sc);
  214. tasklet_disable(&sc->intr_tq);
  215. spin_lock_bh(&sc->sc_pcu_lock);
  216. if (!(sc->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)) {
  217. fastcc = false;
  218. caldata = &sc->caldata;
  219. }
  220. if (!hchan) {
  221. fastcc = false;
  222. hchan = ah->curchan;
  223. }
  224. if (!ath_prepare_reset(sc))
  225. fastcc = false;
  226. ath_dbg(common, CONFIG, "Reset to %u MHz, HT40: %d fastcc: %d\n",
  227. hchan->channel, IS_CHAN_HT40(hchan), fastcc);
  228. r = ath9k_hw_reset(ah, hchan, caldata, fastcc);
  229. if (r) {
  230. ath_err(common,
  231. "Unable to reset channel, reset status %d\n", r);
  232. ath9k_hw_enable_interrupts(ah);
  233. ath9k_queue_reset(sc, RESET_TYPE_BB_HANG);
  234. goto out;
  235. }
  236. if (ath9k_hw_mci_is_enabled(sc->sc_ah) &&
  237. (sc->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL))
  238. ath9k_mci_set_txpower(sc, true, false);
  239. if (!ath_complete_reset(sc, true))
  240. r = -EIO;
  241. out:
  242. spin_unlock_bh(&sc->sc_pcu_lock);
  243. tasklet_enable(&sc->intr_tq);
  244. return r;
  245. }
  246. /*
  247. * Set/change channels. If the channel is really being changed, it's done
  248. * by reseting the chip. To accomplish this we must first cleanup any pending
  249. * DMA, then restart stuff.
  250. */
  251. static int ath_set_channel(struct ath_softc *sc, struct ieee80211_hw *hw,
  252. struct ath9k_channel *hchan)
  253. {
  254. int r;
  255. if (test_bit(SC_OP_INVALID, &sc->sc_flags))
  256. return -EIO;
  257. r = ath_reset_internal(sc, hchan);
  258. return r;
  259. }
  260. static void ath_node_attach(struct ath_softc *sc, struct ieee80211_sta *sta,
  261. struct ieee80211_vif *vif)
  262. {
  263. struct ath_node *an;
  264. an = (struct ath_node *)sta->drv_priv;
  265. an->sc = sc;
  266. an->sta = sta;
  267. an->vif = vif;
  268. ath_tx_node_init(sc, an);
  269. if (sta->ht_cap.ht_supported) {
  270. an->maxampdu = 1 << (IEEE80211_HT_MAX_AMPDU_FACTOR +
  271. sta->ht_cap.ampdu_factor);
  272. an->mpdudensity = ath9k_parse_mpdudensity(sta->ht_cap.ampdu_density);
  273. }
  274. }
  275. static void ath_node_detach(struct ath_softc *sc, struct ieee80211_sta *sta)
  276. {
  277. struct ath_node *an = (struct ath_node *)sta->drv_priv;
  278. ath_tx_node_cleanup(sc, an);
  279. }
  280. void ath9k_tasklet(unsigned long data)
  281. {
  282. struct ath_softc *sc = (struct ath_softc *)data;
  283. struct ath_hw *ah = sc->sc_ah;
  284. struct ath_common *common = ath9k_hw_common(ah);
  285. enum ath_reset_type type;
  286. unsigned long flags;
  287. u32 status = sc->intrstatus;
  288. u32 rxmask;
  289. ath9k_ps_wakeup(sc);
  290. spin_lock(&sc->sc_pcu_lock);
  291. if ((status & ATH9K_INT_FATAL) ||
  292. (status & ATH9K_INT_BB_WATCHDOG)) {
  293. if (status & ATH9K_INT_FATAL)
  294. type = RESET_TYPE_FATAL_INT;
  295. else
  296. type = RESET_TYPE_BB_WATCHDOG;
  297. ath9k_queue_reset(sc, type);
  298. goto out;
  299. }
  300. spin_lock_irqsave(&sc->sc_pm_lock, flags);
  301. if ((status & ATH9K_INT_TSFOOR) && sc->ps_enabled) {
  302. /*
  303. * TSF sync does not look correct; remain awake to sync with
  304. * the next Beacon.
  305. */
  306. ath_dbg(common, PS, "TSFOOR - Sync with next Beacon\n");
  307. sc->ps_flags |= PS_WAIT_FOR_BEACON | PS_BEACON_SYNC;
  308. }
  309. spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
  310. if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
  311. rxmask = (ATH9K_INT_RXHP | ATH9K_INT_RXLP | ATH9K_INT_RXEOL |
  312. ATH9K_INT_RXORN);
  313. else
  314. rxmask = (ATH9K_INT_RX | ATH9K_INT_RXEOL | ATH9K_INT_RXORN);
  315. if (status & rxmask) {
  316. /* Check for high priority Rx first */
  317. if ((ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) &&
  318. (status & ATH9K_INT_RXHP))
  319. ath_rx_tasklet(sc, 0, true);
  320. ath_rx_tasklet(sc, 0, false);
  321. }
  322. if (status & ATH9K_INT_TX) {
  323. if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
  324. ath_tx_edma_tasklet(sc);
  325. else
  326. ath_tx_tasklet(sc);
  327. }
  328. ath9k_btcoex_handle_interrupt(sc, status);
  329. out:
  330. /* re-enable hardware interrupt */
  331. ath9k_hw_enable_interrupts(ah);
  332. spin_unlock(&sc->sc_pcu_lock);
  333. ath9k_ps_restore(sc);
  334. }
  335. irqreturn_t ath_isr(int irq, void *dev)
  336. {
  337. #define SCHED_INTR ( \
  338. ATH9K_INT_FATAL | \
  339. ATH9K_INT_BB_WATCHDOG | \
  340. ATH9K_INT_RXORN | \
  341. ATH9K_INT_RXEOL | \
  342. ATH9K_INT_RX | \
  343. ATH9K_INT_RXLP | \
  344. ATH9K_INT_RXHP | \
  345. ATH9K_INT_TX | \
  346. ATH9K_INT_BMISS | \
  347. ATH9K_INT_CST | \
  348. ATH9K_INT_TSFOOR | \
  349. ATH9K_INT_GENTIMER | \
  350. ATH9K_INT_MCI)
  351. struct ath_softc *sc = dev;
  352. struct ath_hw *ah = sc->sc_ah;
  353. struct ath_common *common = ath9k_hw_common(ah);
  354. enum ath9k_int status;
  355. bool sched = false;
  356. /*
  357. * The hardware is not ready/present, don't
  358. * touch anything. Note this can happen early
  359. * on if the IRQ is shared.
  360. */
  361. if (test_bit(SC_OP_INVALID, &sc->sc_flags))
  362. return IRQ_NONE;
  363. /* shared irq, not for us */
  364. if (!ath9k_hw_intrpend(ah))
  365. return IRQ_NONE;
  366. if (test_bit(SC_OP_HW_RESET, &sc->sc_flags)) {
  367. ath9k_hw_kill_interrupts(ah);
  368. return IRQ_HANDLED;
  369. }
  370. /*
  371. * Figure out the reason(s) for the interrupt. Note
  372. * that the hal returns a pseudo-ISR that may include
  373. * bits we haven't explicitly enabled so we mask the
  374. * value to insure we only process bits we requested.
  375. */
  376. ath9k_hw_getisr(ah, &status); /* NB: clears ISR too */
  377. status &= ah->imask; /* discard unasked-for bits */
  378. /*
  379. * If there are no status bits set, then this interrupt was not
  380. * for me (should have been caught above).
  381. */
  382. if (!status)
  383. return IRQ_NONE;
  384. /* Cache the status */
  385. sc->intrstatus = status;
  386. if (status & SCHED_INTR)
  387. sched = true;
  388. /*
  389. * If a FATAL or RXORN interrupt is received, we have to reset the
  390. * chip immediately.
  391. */
  392. if ((status & ATH9K_INT_FATAL) || ((status & ATH9K_INT_RXORN) &&
  393. !(ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)))
  394. goto chip_reset;
  395. if ((ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) &&
  396. (status & ATH9K_INT_BB_WATCHDOG)) {
  397. spin_lock(&common->cc_lock);
  398. ath_hw_cycle_counters_update(common);
  399. ar9003_hw_bb_watchdog_dbg_info(ah);
  400. spin_unlock(&common->cc_lock);
  401. goto chip_reset;
  402. }
  403. #ifdef CONFIG_PM_SLEEP
  404. if (status & ATH9K_INT_BMISS) {
  405. if (atomic_read(&sc->wow_sleep_proc_intr) == 0) {
  406. ath_dbg(common, ANY, "during WoW we got a BMISS\n");
  407. atomic_inc(&sc->wow_got_bmiss_intr);
  408. atomic_dec(&sc->wow_sleep_proc_intr);
  409. }
  410. }
  411. #endif
  412. if (status & ATH9K_INT_SWBA)
  413. tasklet_schedule(&sc->bcon_tasklet);
  414. if (status & ATH9K_INT_TXURN)
  415. ath9k_hw_updatetxtriglevel(ah, true);
  416. if (status & ATH9K_INT_RXEOL) {
  417. ah->imask &= ~(ATH9K_INT_RXEOL | ATH9K_INT_RXORN);
  418. ath9k_hw_set_interrupts(ah);
  419. }
  420. if (!(ah->caps.hw_caps & ATH9K_HW_CAP_AUTOSLEEP))
  421. if (status & ATH9K_INT_TIM_TIMER) {
  422. if (ATH_DBG_WARN_ON_ONCE(sc->ps_idle))
  423. goto chip_reset;
  424. /* Clear RxAbort bit so that we can
  425. * receive frames */
  426. ath9k_setpower(sc, ATH9K_PM_AWAKE);
  427. spin_lock(&sc->sc_pm_lock);
  428. ath9k_hw_setrxabort(sc->sc_ah, 0);
  429. sc->ps_flags |= PS_WAIT_FOR_BEACON;
  430. spin_unlock(&sc->sc_pm_lock);
  431. }
  432. chip_reset:
  433. ath_debug_stat_interrupt(sc, status);
  434. if (sched) {
  435. /* turn off every interrupt */
  436. ath9k_hw_disable_interrupts(ah);
  437. tasklet_schedule(&sc->intr_tq);
  438. }
  439. return IRQ_HANDLED;
  440. #undef SCHED_INTR
  441. }
  442. static int ath_reset(struct ath_softc *sc)
  443. {
  444. int i, r;
  445. ath9k_ps_wakeup(sc);
  446. r = ath_reset_internal(sc, NULL);
  447. for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
  448. if (!ATH_TXQ_SETUP(sc, i))
  449. continue;
  450. spin_lock_bh(&sc->tx.txq[i].axq_lock);
  451. ath_txq_schedule(sc, &sc->tx.txq[i]);
  452. spin_unlock_bh(&sc->tx.txq[i].axq_lock);
  453. }
  454. ath9k_ps_restore(sc);
  455. return r;
  456. }
  457. void ath9k_queue_reset(struct ath_softc *sc, enum ath_reset_type type)
  458. {
  459. #ifdef CONFIG_ATH9K_DEBUGFS
  460. RESET_STAT_INC(sc, type);
  461. #endif
  462. set_bit(SC_OP_HW_RESET, &sc->sc_flags);
  463. ieee80211_queue_work(sc->hw, &sc->hw_reset_work);
  464. }
  465. void ath_reset_work(struct work_struct *work)
  466. {
  467. struct ath_softc *sc = container_of(work, struct ath_softc, hw_reset_work);
  468. ath_reset(sc);
  469. }
  470. /**********************/
  471. /* mac80211 callbacks */
  472. /**********************/
  473. static int ath9k_start(struct ieee80211_hw *hw)
  474. {
  475. struct ath_softc *sc = hw->priv;
  476. struct ath_hw *ah = sc->sc_ah;
  477. struct ath_common *common = ath9k_hw_common(ah);
  478. struct ieee80211_channel *curchan = hw->conf.chandef.chan;
  479. struct ath9k_channel *init_channel;
  480. int r;
  481. ath_dbg(common, CONFIG,
  482. "Starting driver with initial channel: %d MHz\n",
  483. curchan->center_freq);
  484. ath9k_ps_wakeup(sc);
  485. mutex_lock(&sc->mutex);
  486. init_channel = ath9k_cmn_get_curchannel(hw, ah);
  487. /* Reset SERDES registers */
  488. ath9k_hw_configpcipowersave(ah, false);
  489. /*
  490. * The basic interface to setting the hardware in a good
  491. * state is ``reset''. On return the hardware is known to
  492. * be powered up and with interrupts disabled. This must
  493. * be followed by initialization of the appropriate bits
  494. * and then setup of the interrupt mask.
  495. */
  496. spin_lock_bh(&sc->sc_pcu_lock);
  497. atomic_set(&ah->intr_ref_cnt, -1);
  498. r = ath9k_hw_reset(ah, init_channel, ah->caldata, false);
  499. if (r) {
  500. ath_err(common,
  501. "Unable to reset hardware; reset status %d (freq %u MHz)\n",
  502. r, curchan->center_freq);
  503. ah->reset_power_on = false;
  504. }
  505. /* Setup our intr mask. */
  506. ah->imask = ATH9K_INT_TX | ATH9K_INT_RXEOL |
  507. ATH9K_INT_RXORN | ATH9K_INT_FATAL |
  508. ATH9K_INT_GLOBAL;
  509. if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
  510. ah->imask |= ATH9K_INT_RXHP |
  511. ATH9K_INT_RXLP |
  512. ATH9K_INT_BB_WATCHDOG;
  513. else
  514. ah->imask |= ATH9K_INT_RX;
  515. ah->imask |= ATH9K_INT_GTT;
  516. if (ah->caps.hw_caps & ATH9K_HW_CAP_HT)
  517. ah->imask |= ATH9K_INT_CST;
  518. ath_mci_enable(sc);
  519. clear_bit(SC_OP_INVALID, &sc->sc_flags);
  520. sc->sc_ah->is_monitoring = false;
  521. if (!ath_complete_reset(sc, false))
  522. ah->reset_power_on = false;
  523. if (ah->led_pin >= 0) {
  524. ath9k_hw_cfg_output(ah, ah->led_pin,
  525. AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
  526. ath9k_hw_set_gpio(ah, ah->led_pin, 0);
  527. }
  528. /*
  529. * Reset key cache to sane defaults (all entries cleared) instead of
  530. * semi-random values after suspend/resume.
  531. */
  532. ath9k_cmn_init_crypto(sc->sc_ah);
  533. spin_unlock_bh(&sc->sc_pcu_lock);
  534. mutex_unlock(&sc->mutex);
  535. ath9k_ps_restore(sc);
  536. return 0;
  537. }
  538. static void ath9k_tx(struct ieee80211_hw *hw,
  539. struct ieee80211_tx_control *control,
  540. struct sk_buff *skb)
  541. {
  542. struct ath_softc *sc = hw->priv;
  543. struct ath_common *common = ath9k_hw_common(sc->sc_ah);
  544. struct ath_tx_control txctl;
  545. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
  546. unsigned long flags;
  547. if (sc->ps_enabled) {
  548. /*
  549. * mac80211 does not set PM field for normal data frames, so we
  550. * need to update that based on the current PS mode.
  551. */
  552. if (ieee80211_is_data(hdr->frame_control) &&
  553. !ieee80211_is_nullfunc(hdr->frame_control) &&
  554. !ieee80211_has_pm(hdr->frame_control)) {
  555. ath_dbg(common, PS,
  556. "Add PM=1 for a TX frame while in PS mode\n");
  557. hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM);
  558. }
  559. }
  560. if (unlikely(sc->sc_ah->power_mode == ATH9K_PM_NETWORK_SLEEP)) {
  561. /*
  562. * We are using PS-Poll and mac80211 can request TX while in
  563. * power save mode. Need to wake up hardware for the TX to be
  564. * completed and if needed, also for RX of buffered frames.
  565. */
  566. ath9k_ps_wakeup(sc);
  567. spin_lock_irqsave(&sc->sc_pm_lock, flags);
  568. if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_AUTOSLEEP))
  569. ath9k_hw_setrxabort(sc->sc_ah, 0);
  570. if (ieee80211_is_pspoll(hdr->frame_control)) {
  571. ath_dbg(common, PS,
  572. "Sending PS-Poll to pick a buffered frame\n");
  573. sc->ps_flags |= PS_WAIT_FOR_PSPOLL_DATA;
  574. } else {
  575. ath_dbg(common, PS, "Wake up to complete TX\n");
  576. sc->ps_flags |= PS_WAIT_FOR_TX_ACK;
  577. }
  578. /*
  579. * The actual restore operation will happen only after
  580. * the ps_flags bit is cleared. We are just dropping
  581. * the ps_usecount here.
  582. */
  583. spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
  584. ath9k_ps_restore(sc);
  585. }
  586. /*
  587. * Cannot tx while the hardware is in full sleep, it first needs a full
  588. * chip reset to recover from that
  589. */
  590. if (unlikely(sc->sc_ah->power_mode == ATH9K_PM_FULL_SLEEP)) {
  591. ath_err(common, "TX while HW is in FULL_SLEEP mode\n");
  592. goto exit;
  593. }
  594. memset(&txctl, 0, sizeof(struct ath_tx_control));
  595. txctl.txq = sc->tx.txq_map[skb_get_queue_mapping(skb)];
  596. txctl.sta = control->sta;
  597. ath_dbg(common, XMIT, "transmitting packet, skb: %p\n", skb);
  598. if (ath_tx_start(hw, skb, &txctl) != 0) {
  599. ath_dbg(common, XMIT, "TX failed\n");
  600. TX_STAT_INC(txctl.txq->axq_qnum, txfailed);
  601. goto exit;
  602. }
  603. return;
  604. exit:
  605. ieee80211_free_txskb(hw, skb);
  606. }
  607. static void ath9k_stop(struct ieee80211_hw *hw)
  608. {
  609. struct ath_softc *sc = hw->priv;
  610. struct ath_hw *ah = sc->sc_ah;
  611. struct ath_common *common = ath9k_hw_common(ah);
  612. bool prev_idle;
  613. mutex_lock(&sc->mutex);
  614. ath_cancel_work(sc);
  615. del_timer_sync(&sc->rx_poll_timer);
  616. if (test_bit(SC_OP_INVALID, &sc->sc_flags)) {
  617. ath_dbg(common, ANY, "Device not present\n");
  618. mutex_unlock(&sc->mutex);
  619. return;
  620. }
  621. /* Ensure HW is awake when we try to shut it down. */
  622. ath9k_ps_wakeup(sc);
  623. spin_lock_bh(&sc->sc_pcu_lock);
  624. /* prevent tasklets to enable interrupts once we disable them */
  625. ah->imask &= ~ATH9K_INT_GLOBAL;
  626. /* make sure h/w will not generate any interrupt
  627. * before setting the invalid flag. */
  628. ath9k_hw_disable_interrupts(ah);
  629. spin_unlock_bh(&sc->sc_pcu_lock);
  630. /* we can now sync irq and kill any running tasklets, since we already
  631. * disabled interrupts and not holding a spin lock */
  632. synchronize_irq(sc->irq);
  633. tasklet_kill(&sc->intr_tq);
  634. tasklet_kill(&sc->bcon_tasklet);
  635. prev_idle = sc->ps_idle;
  636. sc->ps_idle = true;
  637. spin_lock_bh(&sc->sc_pcu_lock);
  638. if (ah->led_pin >= 0) {
  639. ath9k_hw_set_gpio(ah, ah->led_pin, 1);
  640. ath9k_hw_cfg_gpio_input(ah, ah->led_pin);
  641. }
  642. ath_prepare_reset(sc);
  643. if (sc->rx.frag) {
  644. dev_kfree_skb_any(sc->rx.frag);
  645. sc->rx.frag = NULL;
  646. }
  647. if (!ah->curchan)
  648. ah->curchan = ath9k_cmn_get_curchannel(hw, ah);
  649. ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
  650. ath9k_hw_phy_disable(ah);
  651. ath9k_hw_configpcipowersave(ah, true);
  652. spin_unlock_bh(&sc->sc_pcu_lock);
  653. ath9k_ps_restore(sc);
  654. set_bit(SC_OP_INVALID, &sc->sc_flags);
  655. sc->ps_idle = prev_idle;
  656. mutex_unlock(&sc->mutex);
  657. ath_dbg(common, CONFIG, "Driver halt\n");
  658. }
  659. bool ath9k_uses_beacons(int type)
  660. {
  661. switch (type) {
  662. case NL80211_IFTYPE_AP:
  663. case NL80211_IFTYPE_ADHOC:
  664. case NL80211_IFTYPE_MESH_POINT:
  665. return true;
  666. default:
  667. return false;
  668. }
  669. }
  670. static void ath9k_vif_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
  671. {
  672. struct ath9k_vif_iter_data *iter_data = data;
  673. int i;
  674. if (iter_data->has_hw_macaddr) {
  675. for (i = 0; i < ETH_ALEN; i++)
  676. iter_data->mask[i] &=
  677. ~(iter_data->hw_macaddr[i] ^ mac[i]);
  678. } else {
  679. memcpy(iter_data->hw_macaddr, mac, ETH_ALEN);
  680. iter_data->has_hw_macaddr = true;
  681. }
  682. switch (vif->type) {
  683. case NL80211_IFTYPE_AP:
  684. iter_data->naps++;
  685. break;
  686. case NL80211_IFTYPE_STATION:
  687. iter_data->nstations++;
  688. break;
  689. case NL80211_IFTYPE_ADHOC:
  690. iter_data->nadhocs++;
  691. break;
  692. case NL80211_IFTYPE_MESH_POINT:
  693. iter_data->nmeshes++;
  694. break;
  695. case NL80211_IFTYPE_WDS:
  696. iter_data->nwds++;
  697. break;
  698. default:
  699. break;
  700. }
  701. }
  702. static void ath9k_sta_vif_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
  703. {
  704. struct ath_softc *sc = data;
  705. struct ath_vif *avp = (void *)vif->drv_priv;
  706. if (vif->type != NL80211_IFTYPE_STATION)
  707. return;
  708. if (avp->primary_sta_vif)
  709. ath9k_set_assoc_state(sc, vif);
  710. }
  711. /* Called with sc->mutex held. */
  712. void ath9k_calculate_iter_data(struct ieee80211_hw *hw,
  713. struct ieee80211_vif *vif,
  714. struct ath9k_vif_iter_data *iter_data)
  715. {
  716. struct ath_softc *sc = hw->priv;
  717. struct ath_hw *ah = sc->sc_ah;
  718. struct ath_common *common = ath9k_hw_common(ah);
  719. /*
  720. * Use the hardware MAC address as reference, the hardware uses it
  721. * together with the BSSID mask when matching addresses.
  722. */
  723. memset(iter_data, 0, sizeof(*iter_data));
  724. memset(&iter_data->mask, 0xff, ETH_ALEN);
  725. if (vif)
  726. ath9k_vif_iter(iter_data, vif->addr, vif);
  727. /* Get list of all active MAC addresses */
  728. ieee80211_iterate_active_interfaces_atomic(
  729. sc->hw, IEEE80211_IFACE_ITER_RESUME_ALL,
  730. ath9k_vif_iter, iter_data);
  731. memcpy(common->macaddr, iter_data->hw_macaddr, ETH_ALEN);
  732. }
  733. /* Called with sc->mutex held. */
  734. static void ath9k_calculate_summary_state(struct ieee80211_hw *hw,
  735. struct ieee80211_vif *vif)
  736. {
  737. struct ath_softc *sc = hw->priv;
  738. struct ath_hw *ah = sc->sc_ah;
  739. struct ath_common *common = ath9k_hw_common(ah);
  740. struct ath9k_vif_iter_data iter_data;
  741. enum nl80211_iftype old_opmode = ah->opmode;
  742. ath9k_calculate_iter_data(hw, vif, &iter_data);
  743. memcpy(common->bssidmask, iter_data.mask, ETH_ALEN);
  744. ath_hw_setbssidmask(common);
  745. if (iter_data.naps > 0) {
  746. ath9k_hw_set_tsfadjust(ah, true);
  747. ah->opmode = NL80211_IFTYPE_AP;
  748. } else {
  749. ath9k_hw_set_tsfadjust(ah, false);
  750. if (iter_data.nmeshes)
  751. ah->opmode = NL80211_IFTYPE_MESH_POINT;
  752. else if (iter_data.nwds)
  753. ah->opmode = NL80211_IFTYPE_AP;
  754. else if (iter_data.nadhocs)
  755. ah->opmode = NL80211_IFTYPE_ADHOC;
  756. else
  757. ah->opmode = NL80211_IFTYPE_STATION;
  758. }
  759. ath9k_hw_setopmode(ah);
  760. if ((iter_data.nstations + iter_data.nadhocs + iter_data.nmeshes) > 0)
  761. ah->imask |= ATH9K_INT_TSFOOR;
  762. else
  763. ah->imask &= ~ATH9K_INT_TSFOOR;
  764. ath9k_hw_set_interrupts(ah);
  765. /*
  766. * If we are changing the opmode to STATION,
  767. * a beacon sync needs to be done.
  768. */
  769. if (ah->opmode == NL80211_IFTYPE_STATION &&
  770. old_opmode == NL80211_IFTYPE_AP &&
  771. test_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags)) {
  772. ieee80211_iterate_active_interfaces_atomic(
  773. sc->hw, IEEE80211_IFACE_ITER_RESUME_ALL,
  774. ath9k_sta_vif_iter, sc);
  775. }
  776. }
  777. static int ath9k_add_interface(struct ieee80211_hw *hw,
  778. struct ieee80211_vif *vif)
  779. {
  780. struct ath_softc *sc = hw->priv;
  781. struct ath_hw *ah = sc->sc_ah;
  782. struct ath_common *common = ath9k_hw_common(ah);
  783. mutex_lock(&sc->mutex);
  784. ath_dbg(common, CONFIG, "Attach a VIF of type: %d\n", vif->type);
  785. sc->nvifs++;
  786. ath9k_ps_wakeup(sc);
  787. ath9k_calculate_summary_state(hw, vif);
  788. ath9k_ps_restore(sc);
  789. if (ath9k_uses_beacons(vif->type))
  790. ath9k_beacon_assign_slot(sc, vif);
  791. mutex_unlock(&sc->mutex);
  792. return 0;
  793. }
  794. static int ath9k_change_interface(struct ieee80211_hw *hw,
  795. struct ieee80211_vif *vif,
  796. enum nl80211_iftype new_type,
  797. bool p2p)
  798. {
  799. struct ath_softc *sc = hw->priv;
  800. struct ath_common *common = ath9k_hw_common(sc->sc_ah);
  801. ath_dbg(common, CONFIG, "Change Interface\n");
  802. mutex_lock(&sc->mutex);
  803. if (ath9k_uses_beacons(vif->type))
  804. ath9k_beacon_remove_slot(sc, vif);
  805. vif->type = new_type;
  806. vif->p2p = p2p;
  807. ath9k_ps_wakeup(sc);
  808. ath9k_calculate_summary_state(hw, vif);
  809. ath9k_ps_restore(sc);
  810. if (ath9k_uses_beacons(vif->type))
  811. ath9k_beacon_assign_slot(sc, vif);
  812. mutex_unlock(&sc->mutex);
  813. return 0;
  814. }
  815. static void ath9k_remove_interface(struct ieee80211_hw *hw,
  816. struct ieee80211_vif *vif)
  817. {
  818. struct ath_softc *sc = hw->priv;
  819. struct ath_common *common = ath9k_hw_common(sc->sc_ah);
  820. ath_dbg(common, CONFIG, "Detach Interface\n");
  821. mutex_lock(&sc->mutex);
  822. sc->nvifs--;
  823. if (ath9k_uses_beacons(vif->type))
  824. ath9k_beacon_remove_slot(sc, vif);
  825. ath9k_ps_wakeup(sc);
  826. ath9k_calculate_summary_state(hw, NULL);
  827. ath9k_ps_restore(sc);
  828. mutex_unlock(&sc->mutex);
  829. }
  830. static void ath9k_enable_ps(struct ath_softc *sc)
  831. {
  832. struct ath_hw *ah = sc->sc_ah;
  833. struct ath_common *common = ath9k_hw_common(ah);
  834. sc->ps_enabled = true;
  835. if (!(ah->caps.hw_caps & ATH9K_HW_CAP_AUTOSLEEP)) {
  836. if ((ah->imask & ATH9K_INT_TIM_TIMER) == 0) {
  837. ah->imask |= ATH9K_INT_TIM_TIMER;
  838. ath9k_hw_set_interrupts(ah);
  839. }
  840. ath9k_hw_setrxabort(ah, 1);
  841. }
  842. ath_dbg(common, PS, "PowerSave enabled\n");
  843. }
  844. static void ath9k_disable_ps(struct ath_softc *sc)
  845. {
  846. struct ath_hw *ah = sc->sc_ah;
  847. struct ath_common *common = ath9k_hw_common(ah);
  848. sc->ps_enabled = false;
  849. ath9k_hw_setpower(ah, ATH9K_PM_AWAKE);
  850. if (!(ah->caps.hw_caps & ATH9K_HW_CAP_AUTOSLEEP)) {
  851. ath9k_hw_setrxabort(ah, 0);
  852. sc->ps_flags &= ~(PS_WAIT_FOR_BEACON |
  853. PS_WAIT_FOR_CAB |
  854. PS_WAIT_FOR_PSPOLL_DATA |
  855. PS_WAIT_FOR_TX_ACK);
  856. if (ah->imask & ATH9K_INT_TIM_TIMER) {
  857. ah->imask &= ~ATH9K_INT_TIM_TIMER;
  858. ath9k_hw_set_interrupts(ah);
  859. }
  860. }
  861. ath_dbg(common, PS, "PowerSave disabled\n");
  862. }
  863. void ath9k_spectral_scan_trigger(struct ieee80211_hw *hw)
  864. {
  865. struct ath_softc *sc = hw->priv;
  866. struct ath_hw *ah = sc->sc_ah;
  867. struct ath_common *common = ath9k_hw_common(ah);
  868. u32 rxfilter;
  869. if (!ath9k_hw_ops(ah)->spectral_scan_trigger) {
  870. ath_err(common, "spectrum analyzer not implemented on this hardware\n");
  871. return;
  872. }
  873. ath9k_ps_wakeup(sc);
  874. rxfilter = ath9k_hw_getrxfilter(ah);
  875. ath9k_hw_setrxfilter(ah, rxfilter |
  876. ATH9K_RX_FILTER_PHYRADAR |
  877. ATH9K_RX_FILTER_PHYERR);
  878. /* TODO: usually this should not be neccesary, but for some reason
  879. * (or in some mode?) the trigger must be called after the
  880. * configuration, otherwise the register will have its values reset
  881. * (on my ar9220 to value 0x01002310)
  882. */
  883. ath9k_spectral_scan_config(hw, sc->spectral_mode);
  884. ath9k_hw_ops(ah)->spectral_scan_trigger(ah);
  885. ath9k_ps_restore(sc);
  886. }
  887. int ath9k_spectral_scan_config(struct ieee80211_hw *hw,
  888. enum spectral_mode spectral_mode)
  889. {
  890. struct ath_softc *sc = hw->priv;
  891. struct ath_hw *ah = sc->sc_ah;
  892. struct ath_common *common = ath9k_hw_common(ah);
  893. if (!ath9k_hw_ops(ah)->spectral_scan_trigger) {
  894. ath_err(common, "spectrum analyzer not implemented on this hardware\n");
  895. return -1;
  896. }
  897. switch (spectral_mode) {
  898. case SPECTRAL_DISABLED:
  899. sc->spec_config.enabled = 0;
  900. break;
  901. case SPECTRAL_BACKGROUND:
  902. /* send endless samples.
  903. * TODO: is this really useful for "background"?
  904. */
  905. sc->spec_config.endless = 1;
  906. sc->spec_config.enabled = 1;
  907. break;
  908. case SPECTRAL_CHANSCAN:
  909. case SPECTRAL_MANUAL:
  910. sc->spec_config.endless = 0;
  911. sc->spec_config.enabled = 1;
  912. break;
  913. default:
  914. return -1;
  915. }
  916. ath9k_ps_wakeup(sc);
  917. ath9k_hw_ops(ah)->spectral_scan_config(ah, &sc->spec_config);
  918. ath9k_ps_restore(sc);
  919. sc->spectral_mode = spectral_mode;
  920. return 0;
  921. }
  922. static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
  923. {
  924. struct ath_softc *sc = hw->priv;
  925. struct ath_hw *ah = sc->sc_ah;
  926. struct ath_common *common = ath9k_hw_common(ah);
  927. struct ieee80211_conf *conf = &hw->conf;
  928. bool reset_channel = false;
  929. ath9k_ps_wakeup(sc);
  930. mutex_lock(&sc->mutex);
  931. if (changed & IEEE80211_CONF_CHANGE_IDLE) {
  932. sc->ps_idle = !!(conf->flags & IEEE80211_CONF_IDLE);
  933. if (sc->ps_idle) {
  934. ath_cancel_work(sc);
  935. ath9k_stop_btcoex(sc);
  936. } else {
  937. ath9k_start_btcoex(sc);
  938. /*
  939. * The chip needs a reset to properly wake up from
  940. * full sleep
  941. */
  942. reset_channel = ah->chip_fullsleep;
  943. }
  944. }
  945. /*
  946. * We just prepare to enable PS. We have to wait until our AP has
  947. * ACK'd our null data frame to disable RX otherwise we'll ignore
  948. * those ACKs and end up retransmitting the same null data frames.
  949. * IEEE80211_CONF_CHANGE_PS is only passed by mac80211 for STA mode.
  950. */
  951. if (changed & IEEE80211_CONF_CHANGE_PS) {
  952. unsigned long flags;
  953. spin_lock_irqsave(&sc->sc_pm_lock, flags);
  954. if (conf->flags & IEEE80211_CONF_PS)
  955. ath9k_enable_ps(sc);
  956. else
  957. ath9k_disable_ps(sc);
  958. spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
  959. }
  960. if (changed & IEEE80211_CONF_CHANGE_MONITOR) {
  961. if (conf->flags & IEEE80211_CONF_MONITOR) {
  962. ath_dbg(common, CONFIG, "Monitor mode is enabled\n");
  963. sc->sc_ah->is_monitoring = true;
  964. } else {
  965. ath_dbg(common, CONFIG, "Monitor mode is disabled\n");
  966. sc->sc_ah->is_monitoring = false;
  967. }
  968. }
  969. if ((changed & IEEE80211_CONF_CHANGE_CHANNEL) || reset_channel) {
  970. struct ieee80211_channel *curchan = hw->conf.chandef.chan;
  971. enum nl80211_channel_type channel_type =
  972. cfg80211_get_chandef_type(&conf->chandef);
  973. int pos = curchan->hw_value;
  974. int old_pos = -1;
  975. unsigned long flags;
  976. if (ah->curchan)
  977. old_pos = ah->curchan - &ah->channels[0];
  978. ath_dbg(common, CONFIG, "Set channel: %d MHz type: %d\n",
  979. curchan->center_freq, channel_type);
  980. /* update survey stats for the old channel before switching */
  981. spin_lock_irqsave(&common->cc_lock, flags);
  982. ath_update_survey_stats(sc);
  983. spin_unlock_irqrestore(&common->cc_lock, flags);
  984. /*
  985. * Preserve the current channel values, before updating
  986. * the same channel
  987. */
  988. if (ah->curchan && (old_pos == pos))
  989. ath9k_hw_getnf(ah, ah->curchan);
  990. ath9k_cmn_update_ichannel(&sc->sc_ah->channels[pos],
  991. curchan, channel_type);
  992. /*
  993. * If the operating channel changes, change the survey in-use flags
  994. * along with it.
  995. * Reset the survey data for the new channel, unless we're switching
  996. * back to the operating channel from an off-channel operation.
  997. */
  998. if (!(hw->conf.flags & IEEE80211_CONF_OFFCHANNEL) &&
  999. sc->cur_survey != &sc->survey[pos]) {
  1000. if (sc->cur_survey)
  1001. sc->cur_survey->filled &= ~SURVEY_INFO_IN_USE;
  1002. sc->cur_survey = &sc->survey[pos];
  1003. memset(sc->cur_survey, 0, sizeof(struct survey_info));
  1004. sc->cur_survey->filled |= SURVEY_INFO_IN_USE;
  1005. } else if (!(sc->survey[pos].filled & SURVEY_INFO_IN_USE)) {
  1006. memset(&sc->survey[pos], 0, sizeof(struct survey_info));
  1007. }
  1008. if (ath_set_channel(sc, hw, &sc->sc_ah->channels[pos]) < 0) {
  1009. ath_err(common, "Unable to set channel\n");
  1010. mutex_unlock(&sc->mutex);
  1011. ath9k_ps_restore(sc);
  1012. return -EINVAL;
  1013. }
  1014. /*
  1015. * The most recent snapshot of channel->noisefloor for the old
  1016. * channel is only available after the hardware reset. Copy it to
  1017. * the survey stats now.
  1018. */
  1019. if (old_pos >= 0)
  1020. ath_update_survey_nf(sc, old_pos);
  1021. /*
  1022. * Enable radar pulse detection if on a DFS channel. Spectral
  1023. * scanning and radar detection can not be used concurrently.
  1024. */
  1025. if (hw->conf.radar_enabled) {
  1026. u32 rxfilter;
  1027. /* set HW specific DFS configuration */
  1028. ath9k_hw_set_radar_params(ah);
  1029. rxfilter = ath9k_hw_getrxfilter(ah);
  1030. rxfilter |= ATH9K_RX_FILTER_PHYRADAR |
  1031. ATH9K_RX_FILTER_PHYERR;
  1032. ath9k_hw_setrxfilter(ah, rxfilter);
  1033. ath_dbg(common, DFS, "DFS enabled at freq %d\n",
  1034. curchan->center_freq);
  1035. } else {
  1036. /* perform spectral scan if requested. */
  1037. if (sc->scanning &&
  1038. sc->spectral_mode == SPECTRAL_CHANSCAN)
  1039. ath9k_spectral_scan_trigger(hw);
  1040. }
  1041. }
  1042. if (changed & IEEE80211_CONF_CHANGE_POWER) {
  1043. ath_dbg(common, CONFIG, "Set power: %d\n", conf->power_level);
  1044. sc->config.txpowlimit = 2 * conf->power_level;
  1045. ath9k_cmn_update_txpow(ah, sc->curtxpow,
  1046. sc->config.txpowlimit, &sc->curtxpow);
  1047. }
  1048. mutex_unlock(&sc->mutex);
  1049. ath9k_ps_restore(sc);
  1050. return 0;
  1051. }
  1052. #define SUPPORTED_FILTERS \
  1053. (FIF_PROMISC_IN_BSS | \
  1054. FIF_ALLMULTI | \
  1055. FIF_CONTROL | \
  1056. FIF_PSPOLL | \
  1057. FIF_OTHER_BSS | \
  1058. FIF_BCN_PRBRESP_PROMISC | \
  1059. FIF_PROBE_REQ | \
  1060. FIF_FCSFAIL)
  1061. /* FIXME: sc->sc_full_reset ? */
  1062. static void ath9k_configure_filter(struct ieee80211_hw *hw,
  1063. unsigned int changed_flags,
  1064. unsigned int *total_flags,
  1065. u64 multicast)
  1066. {
  1067. struct ath_softc *sc = hw->priv;
  1068. u32 rfilt;
  1069. changed_flags &= SUPPORTED_FILTERS;
  1070. *total_flags &= SUPPORTED_FILTERS;
  1071. sc->rx.rxfilter = *total_flags;
  1072. ath9k_ps_wakeup(sc);
  1073. rfilt = ath_calcrxfilter(sc);
  1074. ath9k_hw_setrxfilter(sc->sc_ah, rfilt);
  1075. ath9k_ps_restore(sc);
  1076. ath_dbg(ath9k_hw_common(sc->sc_ah), CONFIG, "Set HW RX filter: 0x%x\n",
  1077. rfilt);
  1078. }
  1079. static int ath9k_sta_add(struct ieee80211_hw *hw,
  1080. struct ieee80211_vif *vif,
  1081. struct ieee80211_sta *sta)
  1082. {
  1083. struct ath_softc *sc = hw->priv;
  1084. struct ath_common *common = ath9k_hw_common(sc->sc_ah);
  1085. struct ath_node *an = (struct ath_node *) sta->drv_priv;
  1086. struct ieee80211_key_conf ps_key = { };
  1087. int key;
  1088. ath_node_attach(sc, sta, vif);
  1089. if (vif->type != NL80211_IFTYPE_AP &&
  1090. vif->type != NL80211_IFTYPE_AP_VLAN)
  1091. return 0;
  1092. key = ath_key_config(common, vif, sta, &ps_key);
  1093. if (key > 0)
  1094. an->ps_key = key;
  1095. return 0;
  1096. }
  1097. static void ath9k_del_ps_key(struct ath_softc *sc,
  1098. struct ieee80211_vif *vif,
  1099. struct ieee80211_sta *sta)
  1100. {
  1101. struct ath_common *common = ath9k_hw_common(sc->sc_ah);
  1102. struct ath_node *an = (struct ath_node *) sta->drv_priv;
  1103. struct ieee80211_key_conf ps_key = { .hw_key_idx = an->ps_key };
  1104. if (!an->ps_key)
  1105. return;
  1106. ath_key_delete(common, &ps_key);
  1107. an->ps_key = 0;
  1108. }
  1109. static int ath9k_sta_remove(struct ieee80211_hw *hw,
  1110. struct ieee80211_vif *vif,
  1111. struct ieee80211_sta *sta)
  1112. {
  1113. struct ath_softc *sc = hw->priv;
  1114. ath9k_del_ps_key(sc, vif, sta);
  1115. ath_node_detach(sc, sta);
  1116. return 0;
  1117. }
  1118. static void ath9k_sta_notify(struct ieee80211_hw *hw,
  1119. struct ieee80211_vif *vif,
  1120. enum sta_notify_cmd cmd,
  1121. struct ieee80211_sta *sta)
  1122. {
  1123. struct ath_softc *sc = hw->priv;
  1124. struct ath_node *an = (struct ath_node *) sta->drv_priv;
  1125. if (!sta->ht_cap.ht_supported)
  1126. return;
  1127. switch (cmd) {
  1128. case STA_NOTIFY_SLEEP:
  1129. an->sleeping = true;
  1130. ath_tx_aggr_sleep(sta, sc, an);
  1131. break;
  1132. case STA_NOTIFY_AWAKE:
  1133. an->sleeping = false;
  1134. ath_tx_aggr_wakeup(sc, an);
  1135. break;
  1136. }
  1137. }
  1138. static int ath9k_conf_tx(struct ieee80211_hw *hw,
  1139. struct ieee80211_vif *vif, u16 queue,
  1140. const struct ieee80211_tx_queue_params *params)
  1141. {
  1142. struct ath_softc *sc = hw->priv;
  1143. struct ath_common *common = ath9k_hw_common(sc->sc_ah);
  1144. struct ath_txq *txq;
  1145. struct ath9k_tx_queue_info qi;
  1146. int ret = 0;
  1147. if (queue >= IEEE80211_NUM_ACS)
  1148. return 0;
  1149. txq = sc->tx.txq_map[queue];
  1150. ath9k_ps_wakeup(sc);
  1151. mutex_lock(&sc->mutex);
  1152. memset(&qi, 0, sizeof(struct ath9k_tx_queue_info));
  1153. qi.tqi_aifs = params->aifs;
  1154. qi.tqi_cwmin = params->cw_min;
  1155. qi.tqi_cwmax = params->cw_max;
  1156. qi.tqi_burstTime = params->txop * 32;
  1157. ath_dbg(common, CONFIG,
  1158. "Configure tx [queue/halq] [%d/%d], aifs: %d, cw_min: %d, cw_max: %d, txop: %d\n",
  1159. queue, txq->axq_qnum, params->aifs, params->cw_min,
  1160. params->cw_max, params->txop);
  1161. ath_update_max_aggr_framelen(sc, queue, qi.tqi_burstTime);
  1162. ret = ath_txq_update(sc, txq->axq_qnum, &qi);
  1163. if (ret)
  1164. ath_err(common, "TXQ Update failed\n");
  1165. mutex_unlock(&sc->mutex);
  1166. ath9k_ps_restore(sc);
  1167. return ret;
  1168. }
  1169. static int ath9k_set_key(struct ieee80211_hw *hw,
  1170. enum set_key_cmd cmd,
  1171. struct ieee80211_vif *vif,
  1172. struct ieee80211_sta *sta,
  1173. struct ieee80211_key_conf *key)
  1174. {
  1175. struct ath_softc *sc = hw->priv;
  1176. struct ath_common *common = ath9k_hw_common(sc->sc_ah);
  1177. int ret = 0;
  1178. if (ath9k_modparam_nohwcrypt)
  1179. return -ENOSPC;
  1180. if ((vif->type == NL80211_IFTYPE_ADHOC ||
  1181. vif->type == NL80211_IFTYPE_MESH_POINT) &&
  1182. (key->cipher == WLAN_CIPHER_SUITE_TKIP ||
  1183. key->cipher == WLAN_CIPHER_SUITE_CCMP) &&
  1184. !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) {
  1185. /*
  1186. * For now, disable hw crypto for the RSN IBSS group keys. This
  1187. * could be optimized in the future to use a modified key cache
  1188. * design to support per-STA RX GTK, but until that gets
  1189. * implemented, use of software crypto for group addressed
  1190. * frames is a acceptable to allow RSN IBSS to be used.
  1191. */
  1192. return -EOPNOTSUPP;
  1193. }
  1194. mutex_lock(&sc->mutex);
  1195. ath9k_ps_wakeup(sc);
  1196. ath_dbg(common, CONFIG, "Set HW Key\n");
  1197. switch (cmd) {
  1198. case SET_KEY:
  1199. if (sta)
  1200. ath9k_del_ps_key(sc, vif, sta);
  1201. ret = ath_key_config(common, vif, sta, key);
  1202. if (ret >= 0) {
  1203. key->hw_key_idx = ret;
  1204. /* push IV and Michael MIC generation to stack */
  1205. key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
  1206. if (key->cipher == WLAN_CIPHER_SUITE_TKIP)
  1207. key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC;
  1208. if (sc->sc_ah->sw_mgmt_crypto &&
  1209. key->cipher == WLAN_CIPHER_SUITE_CCMP)
  1210. key->flags |= IEEE80211_KEY_FLAG_SW_MGMT_TX;
  1211. ret = 0;
  1212. }
  1213. break;
  1214. case DISABLE_KEY:
  1215. ath_key_delete(common, key);
  1216. break;
  1217. default:
  1218. ret = -EINVAL;
  1219. }
  1220. ath9k_ps_restore(sc);
  1221. mutex_unlock(&sc->mutex);
  1222. return ret;
  1223. }
  1224. static void ath9k_set_assoc_state(struct ath_softc *sc,
  1225. struct ieee80211_vif *vif)
  1226. {
  1227. struct ath_common *common = ath9k_hw_common(sc->sc_ah);
  1228. struct ath_vif *avp = (void *)vif->drv_priv;
  1229. struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
  1230. unsigned long flags;
  1231. set_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags);
  1232. avp->primary_sta_vif = true;
  1233. /*
  1234. * Set the AID, BSSID and do beacon-sync only when
  1235. * the HW opmode is STATION.
  1236. *
  1237. * But the primary bit is set above in any case.
  1238. */
  1239. if (sc->sc_ah->opmode != NL80211_IFTYPE_STATION)
  1240. return;
  1241. memcpy(common->curbssid, bss_conf->bssid, ETH_ALEN);
  1242. common->curaid = bss_conf->aid;
  1243. ath9k_hw_write_associd(sc->sc_ah);
  1244. sc->last_rssi = ATH_RSSI_DUMMY_MARKER;
  1245. sc->sc_ah->stats.avgbrssi = ATH_RSSI_DUMMY_MARKER;
  1246. spin_lock_irqsave(&sc->sc_pm_lock, flags);
  1247. sc->ps_flags |= PS_BEACON_SYNC | PS_WAIT_FOR_BEACON;
  1248. spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
  1249. if (ath9k_hw_mci_is_enabled(sc->sc_ah))
  1250. ath9k_mci_update_wlan_channels(sc, false);
  1251. ath_dbg(common, CONFIG,
  1252. "Primary Station interface: %pM, BSSID: %pM\n",
  1253. vif->addr, common->curbssid);
  1254. }
  1255. static void ath9k_bss_assoc_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
  1256. {
  1257. struct ath_softc *sc = data;
  1258. struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
  1259. if (test_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags))
  1260. return;
  1261. if (bss_conf->assoc)
  1262. ath9k_set_assoc_state(sc, vif);
  1263. }
  1264. static void ath9k_bss_info_changed(struct ieee80211_hw *hw,
  1265. struct ieee80211_vif *vif,
  1266. struct ieee80211_bss_conf *bss_conf,
  1267. u32 changed)
  1268. {
  1269. #define CHECK_ANI \
  1270. (BSS_CHANGED_ASSOC | \
  1271. BSS_CHANGED_IBSS | \
  1272. BSS_CHANGED_BEACON_ENABLED)
  1273. struct ath_softc *sc = hw->priv;
  1274. struct ath_hw *ah = sc->sc_ah;
  1275. struct ath_common *common = ath9k_hw_common(ah);
  1276. struct ath_vif *avp = (void *)vif->drv_priv;
  1277. int slottime;
  1278. ath9k_ps_wakeup(sc);
  1279. mutex_lock(&sc->mutex);
  1280. if (changed & BSS_CHANGED_ASSOC) {
  1281. ath_dbg(common, CONFIG, "BSSID %pM Changed ASSOC %d\n",
  1282. bss_conf->bssid, bss_conf->assoc);
  1283. if (avp->primary_sta_vif && !bss_conf->assoc) {
  1284. clear_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags);
  1285. avp->primary_sta_vif = false;
  1286. if (ah->opmode == NL80211_IFTYPE_STATION)
  1287. clear_bit(SC_OP_BEACONS, &sc->sc_flags);
  1288. }
  1289. ieee80211_iterate_active_interfaces_atomic(
  1290. sc->hw, IEEE80211_IFACE_ITER_RESUME_ALL,
  1291. ath9k_bss_assoc_iter, sc);
  1292. if (!test_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags) &&
  1293. ah->opmode == NL80211_IFTYPE_STATION) {
  1294. memset(common->curbssid, 0, ETH_ALEN);
  1295. common->curaid = 0;
  1296. ath9k_hw_write_associd(sc->sc_ah);
  1297. if (ath9k_hw_mci_is_enabled(sc->sc_ah))
  1298. ath9k_mci_update_wlan_channels(sc, true);
  1299. }
  1300. }
  1301. if (changed & BSS_CHANGED_IBSS) {
  1302. memcpy(common->curbssid, bss_conf->bssid, ETH_ALEN);
  1303. common->curaid = bss_conf->aid;
  1304. ath9k_hw_write_associd(sc->sc_ah);
  1305. }
  1306. if ((changed & BSS_CHANGED_BEACON_ENABLED) ||
  1307. (changed & BSS_CHANGED_BEACON_INT)) {
  1308. if (ah->opmode == NL80211_IFTYPE_AP &&
  1309. bss_conf->enable_beacon)
  1310. ath9k_set_tsfadjust(sc, vif);
  1311. if (ath9k_allow_beacon_config(sc, vif))
  1312. ath9k_beacon_config(sc, vif, changed);
  1313. }
  1314. if (changed & BSS_CHANGED_ERP_SLOT) {
  1315. if (bss_conf->use_short_slot)
  1316. slottime = 9;
  1317. else
  1318. slottime = 20;
  1319. if (vif->type == NL80211_IFTYPE_AP) {
  1320. /*
  1321. * Defer update, so that connected stations can adjust
  1322. * their settings at the same time.
  1323. * See beacon.c for more details
  1324. */
  1325. sc->beacon.slottime = slottime;
  1326. sc->beacon.updateslot = UPDATE;
  1327. } else {
  1328. ah->slottime = slottime;
  1329. ath9k_hw_init_global_settings(ah);
  1330. }
  1331. }
  1332. if (changed & CHECK_ANI)
  1333. ath_check_ani(sc);
  1334. mutex_unlock(&sc->mutex);
  1335. ath9k_ps_restore(sc);
  1336. #undef CHECK_ANI
  1337. }
  1338. static u64 ath9k_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
  1339. {
  1340. struct ath_softc *sc = hw->priv;
  1341. u64 tsf;
  1342. mutex_lock(&sc->mutex);
  1343. ath9k_ps_wakeup(sc);
  1344. tsf = ath9k_hw_gettsf64(sc->sc_ah);
  1345. ath9k_ps_restore(sc);
  1346. mutex_unlock(&sc->mutex);
  1347. return tsf;
  1348. }
  1349. static void ath9k_set_tsf(struct ieee80211_hw *hw,
  1350. struct ieee80211_vif *vif,
  1351. u64 tsf)
  1352. {
  1353. struct ath_softc *sc = hw->priv;
  1354. mutex_lock(&sc->mutex);
  1355. ath9k_ps_wakeup(sc);
  1356. ath9k_hw_settsf64(sc->sc_ah, tsf);
  1357. ath9k_ps_restore(sc);
  1358. mutex_unlock(&sc->mutex);
  1359. }
  1360. static void ath9k_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
  1361. {
  1362. struct ath_softc *sc = hw->priv;
  1363. mutex_lock(&sc->mutex);
  1364. ath9k_ps_wakeup(sc);
  1365. ath9k_hw_reset_tsf(sc->sc_ah);
  1366. ath9k_ps_restore(sc);
  1367. mutex_unlock(&sc->mutex);
  1368. }
  1369. static int ath9k_ampdu_action(struct ieee80211_hw *hw,
  1370. struct ieee80211_vif *vif,
  1371. enum ieee80211_ampdu_mlme_action action,
  1372. struct ieee80211_sta *sta,
  1373. u16 tid, u16 *ssn, u8 buf_size)
  1374. {
  1375. struct ath_softc *sc = hw->priv;
  1376. bool flush = false;
  1377. int ret = 0;
  1378. local_bh_disable();
  1379. switch (action) {
  1380. case IEEE80211_AMPDU_RX_START:
  1381. break;
  1382. case IEEE80211_AMPDU_RX_STOP:
  1383. break;
  1384. case IEEE80211_AMPDU_TX_START:
  1385. ath9k_ps_wakeup(sc);
  1386. ret = ath_tx_aggr_start(sc, sta, tid, ssn);
  1387. if (!ret)
  1388. ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid);
  1389. ath9k_ps_restore(sc);
  1390. break;
  1391. case IEEE80211_AMPDU_TX_STOP_FLUSH:
  1392. case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT:
  1393. flush = true;
  1394. case IEEE80211_AMPDU_TX_STOP_CONT:
  1395. ath9k_ps_wakeup(sc);
  1396. ath_tx_aggr_stop(sc, sta, tid);
  1397. if (!flush)
  1398. ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
  1399. ath9k_ps_restore(sc);
  1400. break;
  1401. case IEEE80211_AMPDU_TX_OPERATIONAL:
  1402. ath9k_ps_wakeup(sc);
  1403. ath_tx_aggr_resume(sc, sta, tid);
  1404. ath9k_ps_restore(sc);
  1405. break;
  1406. default:
  1407. ath_err(ath9k_hw_common(sc->sc_ah), "Unknown AMPDU action\n");
  1408. }
  1409. local_bh_enable();
  1410. return ret;
  1411. }
  1412. static int ath9k_get_survey(struct ieee80211_hw *hw, int idx,
  1413. struct survey_info *survey)
  1414. {
  1415. struct ath_softc *sc = hw->priv;
  1416. struct ath_common *common = ath9k_hw_common(sc->sc_ah);
  1417. struct ieee80211_supported_band *sband;
  1418. struct ieee80211_channel *chan;
  1419. unsigned long flags;
  1420. int pos;
  1421. spin_lock_irqsave(&common->cc_lock, flags);
  1422. if (idx == 0)
  1423. ath_update_survey_stats(sc);
  1424. sband = hw->wiphy->bands[IEEE80211_BAND_2GHZ];
  1425. if (sband && idx >= sband->n_channels) {
  1426. idx -= sband->n_channels;
  1427. sband = NULL;
  1428. }
  1429. if (!sband)
  1430. sband = hw->wiphy->bands[IEEE80211_BAND_5GHZ];
  1431. if (!sband || idx >= sband->n_channels) {
  1432. spin_unlock_irqrestore(&common->cc_lock, flags);
  1433. return -ENOENT;
  1434. }
  1435. chan = &sband->channels[idx];
  1436. pos = chan->hw_value;
  1437. memcpy(survey, &sc->survey[pos], sizeof(*survey));
  1438. survey->channel = chan;
  1439. spin_unlock_irqrestore(&common->cc_lock, flags);
  1440. return 0;
  1441. }
  1442. static void ath9k_set_coverage_class(struct ieee80211_hw *hw, u8 coverage_class)
  1443. {
  1444. struct ath_softc *sc = hw->priv;
  1445. struct ath_hw *ah = sc->sc_ah;
  1446. mutex_lock(&sc->mutex);
  1447. ah->coverage_class = coverage_class;
  1448. ath9k_ps_wakeup(sc);
  1449. ath9k_hw_init_global_settings(ah);
  1450. ath9k_ps_restore(sc);
  1451. mutex_unlock(&sc->mutex);
  1452. }
  1453. static void ath9k_flush(struct ieee80211_hw *hw, u32 queues, bool drop)
  1454. {
  1455. struct ath_softc *sc = hw->priv;
  1456. struct ath_hw *ah = sc->sc_ah;
  1457. struct ath_common *common = ath9k_hw_common(ah);
  1458. int timeout = 200; /* ms */
  1459. int i, j;
  1460. bool drain_txq;
  1461. mutex_lock(&sc->mutex);
  1462. cancel_delayed_work_sync(&sc->tx_complete_work);
  1463. if (ah->ah_flags & AH_UNPLUGGED) {
  1464. ath_dbg(common, ANY, "Device has been unplugged!\n");
  1465. mutex_unlock(&sc->mutex);
  1466. return;
  1467. }
  1468. if (test_bit(SC_OP_INVALID, &sc->sc_flags)) {
  1469. ath_dbg(common, ANY, "Device not present\n");
  1470. mutex_unlock(&sc->mutex);
  1471. return;
  1472. }
  1473. for (j = 0; j < timeout; j++) {
  1474. bool npend = false;
  1475. if (j)
  1476. usleep_range(1000, 2000);
  1477. for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
  1478. if (!ATH_TXQ_SETUP(sc, i))
  1479. continue;
  1480. npend = ath9k_has_pending_frames(sc, &sc->tx.txq[i]);
  1481. if (npend)
  1482. break;
  1483. }
  1484. if (!npend)
  1485. break;
  1486. }
  1487. if (drop) {
  1488. ath9k_ps_wakeup(sc);
  1489. spin_lock_bh(&sc->sc_pcu_lock);
  1490. drain_txq = ath_drain_all_txq(sc);
  1491. spin_unlock_bh(&sc->sc_pcu_lock);
  1492. if (!drain_txq)
  1493. ath_reset(sc);
  1494. ath9k_ps_restore(sc);
  1495. ieee80211_wake_queues(hw);
  1496. }
  1497. ieee80211_queue_delayed_work(hw, &sc->tx_complete_work, 0);
  1498. mutex_unlock(&sc->mutex);
  1499. }
  1500. static bool ath9k_tx_frames_pending(struct ieee80211_hw *hw)
  1501. {
  1502. struct ath_softc *sc = hw->priv;
  1503. int i;
  1504. for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
  1505. if (!ATH_TXQ_SETUP(sc, i))
  1506. continue;
  1507. if (ath9k_has_pending_frames(sc, &sc->tx.txq[i]))
  1508. return true;
  1509. }
  1510. return false;
  1511. }
  1512. static int ath9k_tx_last_beacon(struct ieee80211_hw *hw)
  1513. {
  1514. struct ath_softc *sc = hw->priv;
  1515. struct ath_hw *ah = sc->sc_ah;
  1516. struct ieee80211_vif *vif;
  1517. struct ath_vif *avp;
  1518. struct ath_buf *bf;
  1519. struct ath_tx_status ts;
  1520. bool edma = !!(ah->caps.hw_caps & ATH9K_HW_CAP_EDMA);
  1521. int status;
  1522. vif = sc->beacon.bslot[0];
  1523. if (!vif)
  1524. return 0;
  1525. if (!vif->bss_conf.enable_beacon)
  1526. return 0;
  1527. avp = (void *)vif->drv_priv;
  1528. if (!sc->beacon.tx_processed && !edma) {
  1529. tasklet_disable(&sc->bcon_tasklet);
  1530. bf = avp->av_bcbuf;
  1531. if (!bf || !bf->bf_mpdu)
  1532. goto skip;
  1533. status = ath9k_hw_txprocdesc(ah, bf->bf_desc, &ts);
  1534. if (status == -EINPROGRESS)
  1535. goto skip;
  1536. sc->beacon.tx_processed = true;
  1537. sc->beacon.tx_last = !(ts.ts_status & ATH9K_TXERR_MASK);
  1538. skip:
  1539. tasklet_enable(&sc->bcon_tasklet);
  1540. }
  1541. return sc->beacon.tx_last;
  1542. }
  1543. static int ath9k_get_stats(struct ieee80211_hw *hw,
  1544. struct ieee80211_low_level_stats *stats)
  1545. {
  1546. struct ath_softc *sc = hw->priv;
  1547. struct ath_hw *ah = sc->sc_ah;
  1548. struct ath9k_mib_stats *mib_stats = &ah->ah_mibStats;
  1549. stats->dot11ACKFailureCount = mib_stats->ackrcv_bad;
  1550. stats->dot11RTSFailureCount = mib_stats->rts_bad;
  1551. stats->dot11FCSErrorCount = mib_stats->fcs_bad;
  1552. stats->dot11RTSSuccessCount = mib_stats->rts_good;
  1553. return 0;
  1554. }
  1555. static u32 fill_chainmask(u32 cap, u32 new)
  1556. {
  1557. u32 filled = 0;
  1558. int i;
  1559. for (i = 0; cap && new; i++, cap >>= 1) {
  1560. if (!(cap & BIT(0)))
  1561. continue;
  1562. if (new & BIT(0))
  1563. filled |= BIT(i);
  1564. new >>= 1;
  1565. }
  1566. return filled;
  1567. }
  1568. static bool validate_antenna_mask(struct ath_hw *ah, u32 val)
  1569. {
  1570. if (AR_SREV_9300_20_OR_LATER(ah))
  1571. return true;
  1572. switch (val & 0x7) {
  1573. case 0x1:
  1574. case 0x3:
  1575. case 0x7:
  1576. return true;
  1577. case 0x2:
  1578. return (ah->caps.rx_chainmask == 1);
  1579. default:
  1580. return false;
  1581. }
  1582. }
  1583. static int ath9k_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant)
  1584. {
  1585. struct ath_softc *sc = hw->priv;
  1586. struct ath_hw *ah = sc->sc_ah;
  1587. if (ah->caps.rx_chainmask != 1)
  1588. rx_ant |= tx_ant;
  1589. if (!validate_antenna_mask(ah, rx_ant) || !tx_ant)
  1590. return -EINVAL;
  1591. sc->ant_rx = rx_ant;
  1592. sc->ant_tx = tx_ant;
  1593. if (ah->caps.rx_chainmask == 1)
  1594. return 0;
  1595. /* AR9100 runs into calibration issues if not all rx chains are enabled */
  1596. if (AR_SREV_9100(ah))
  1597. ah->rxchainmask = 0x7;
  1598. else
  1599. ah->rxchainmask = fill_chainmask(ah->caps.rx_chainmask, rx_ant);
  1600. ah->txchainmask = fill_chainmask(ah->caps.tx_chainmask, tx_ant);
  1601. ath9k_reload_chainmask_settings(sc);
  1602. return 0;
  1603. }
  1604. static int ath9k_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant)
  1605. {
  1606. struct ath_softc *sc = hw->priv;
  1607. *tx_ant = sc->ant_tx;
  1608. *rx_ant = sc->ant_rx;
  1609. return 0;
  1610. }
  1611. #ifdef CONFIG_PM_SLEEP
  1612. static void ath9k_wow_map_triggers(struct ath_softc *sc,
  1613. struct cfg80211_wowlan *wowlan,
  1614. u32 *wow_triggers)
  1615. {
  1616. if (wowlan->disconnect)
  1617. *wow_triggers |= AH_WOW_LINK_CHANGE |
  1618. AH_WOW_BEACON_MISS;
  1619. if (wowlan->magic_pkt)
  1620. *wow_triggers |= AH_WOW_MAGIC_PATTERN_EN;
  1621. if (wowlan->n_patterns)
  1622. *wow_triggers |= AH_WOW_USER_PATTERN_EN;
  1623. sc->wow_enabled = *wow_triggers;
  1624. }
  1625. static void ath9k_wow_add_disassoc_deauth_pattern(struct ath_softc *sc)
  1626. {
  1627. struct ath_hw *ah = sc->sc_ah;
  1628. struct ath_common *common = ath9k_hw_common(ah);
  1629. struct ath9k_hw_capabilities *pcaps = &ah->caps;
  1630. int pattern_count = 0;
  1631. int i, byte_cnt;
  1632. u8 dis_deauth_pattern[MAX_PATTERN_SIZE];
  1633. u8 dis_deauth_mask[MAX_PATTERN_SIZE];
  1634. memset(dis_deauth_pattern, 0, MAX_PATTERN_SIZE);
  1635. memset(dis_deauth_mask, 0, MAX_PATTERN_SIZE);
  1636. /*
  1637. * Create Dissassociate / Deauthenticate packet filter
  1638. *
  1639. * 2 bytes 2 byte 6 bytes 6 bytes 6 bytes
  1640. * +--------------+----------+---------+--------+--------+----
  1641. * + Frame Control+ Duration + DA + SA + BSSID +
  1642. * +--------------+----------+---------+--------+--------+----
  1643. *
  1644. * The above is the management frame format for disassociate/
  1645. * deauthenticate pattern, from this we need to match the first byte
  1646. * of 'Frame Control' and DA, SA, and BSSID fields
  1647. * (skipping 2nd byte of FC and Duration feild.
  1648. *
  1649. * Disassociate pattern
  1650. * --------------------
  1651. * Frame control = 00 00 1010
  1652. * DA, SA, BSSID = x:x:x:x:x:x
  1653. * Pattern will be A0000000 | x:x:x:x:x:x | x:x:x:x:x:x
  1654. * | x:x:x:x:x:x -- 22 bytes
  1655. *
  1656. * Deauthenticate pattern
  1657. * ----------------------
  1658. * Frame control = 00 00 1100
  1659. * DA, SA, BSSID = x:x:x:x:x:x
  1660. * Pattern will be C0000000 | x:x:x:x:x:x | x:x:x:x:x:x
  1661. * | x:x:x:x:x:x -- 22 bytes
  1662. */
  1663. /* Create Disassociate Pattern first */
  1664. byte_cnt = 0;
  1665. /* Fill out the mask with all FF's */
  1666. for (i = 0; i < MAX_PATTERN_MASK_SIZE; i++)
  1667. dis_deauth_mask[i] = 0xff;
  1668. /* copy the first byte of frame control field */
  1669. dis_deauth_pattern[byte_cnt] = 0xa0;
  1670. byte_cnt++;
  1671. /* skip 2nd byte of frame control and Duration field */
  1672. byte_cnt += 3;
  1673. /*
  1674. * need not match the destination mac address, it can be a broadcast
  1675. * mac address or an unicast to this station
  1676. */
  1677. byte_cnt += 6;
  1678. /* copy the source mac address */
  1679. memcpy((dis_deauth_pattern + byte_cnt), common->curbssid, ETH_ALEN);
  1680. byte_cnt += 6;
  1681. /* copy the bssid, its same as the source mac address */
  1682. memcpy((dis_deauth_pattern + byte_cnt), common->curbssid, ETH_ALEN);
  1683. /* Create Disassociate pattern mask */
  1684. if (pcaps->hw_caps & ATH9K_HW_WOW_PATTERN_MATCH_EXACT) {
  1685. if (pcaps->hw_caps & ATH9K_HW_WOW_PATTERN_MATCH_DWORD) {
  1686. /*
  1687. * for AR9280, because of hardware limitation, the
  1688. * first 4 bytes have to be matched for all patterns.
  1689. * the mask for disassociation and de-auth pattern
  1690. * matching need to enable the first 4 bytes.
  1691. * also the duration field needs to be filled.
  1692. */
  1693. dis_deauth_mask[0] = 0xf0;
  1694. /*
  1695. * fill in duration field
  1696. FIXME: what is the exact value ?
  1697. */
  1698. dis_deauth_pattern[2] = 0xff;
  1699. dis_deauth_pattern[3] = 0xff;
  1700. } else {
  1701. dis_deauth_mask[0] = 0xfe;
  1702. }
  1703. dis_deauth_mask[1] = 0x03;
  1704. dis_deauth_mask[2] = 0xc0;
  1705. } else {
  1706. dis_deauth_mask[0] = 0xef;
  1707. dis_deauth_mask[1] = 0x3f;
  1708. dis_deauth_mask[2] = 0x00;
  1709. dis_deauth_mask[3] = 0xfc;
  1710. }
  1711. ath_dbg(common, WOW, "Adding disassoc/deauth patterns for WoW\n");
  1712. ath9k_hw_wow_apply_pattern(ah, dis_deauth_pattern, dis_deauth_mask,
  1713. pattern_count, byte_cnt);
  1714. pattern_count++;
  1715. /*
  1716. * for de-authenticate pattern, only the first byte of the frame
  1717. * control field gets changed from 0xA0 to 0xC0
  1718. */
  1719. dis_deauth_pattern[0] = 0xC0;
  1720. ath9k_hw_wow_apply_pattern(ah, dis_deauth_pattern, dis_deauth_mask,
  1721. pattern_count, byte_cnt);
  1722. }
  1723. static void ath9k_wow_add_pattern(struct ath_softc *sc,
  1724. struct cfg80211_wowlan *wowlan)
  1725. {
  1726. struct ath_hw *ah = sc->sc_ah;
  1727. struct ath9k_wow_pattern *wow_pattern = NULL;
  1728. struct cfg80211_wowlan_trig_pkt_pattern *patterns = wowlan->patterns;
  1729. int mask_len;
  1730. s8 i = 0;
  1731. if (!wowlan->n_patterns)
  1732. return;
  1733. /*
  1734. * Add the new user configured patterns
  1735. */
  1736. for (i = 0; i < wowlan->n_patterns; i++) {
  1737. wow_pattern = kzalloc(sizeof(*wow_pattern), GFP_KERNEL);
  1738. if (!wow_pattern)
  1739. return;
  1740. /*
  1741. * TODO: convert the generic user space pattern to
  1742. * appropriate chip specific/802.11 pattern.
  1743. */
  1744. mask_len = DIV_ROUND_UP(wowlan->patterns[i].pattern_len, 8);
  1745. memset(wow_pattern->pattern_bytes, 0, MAX_PATTERN_SIZE);
  1746. memset(wow_pattern->mask_bytes, 0, MAX_PATTERN_SIZE);
  1747. memcpy(wow_pattern->pattern_bytes, patterns[i].pattern,
  1748. patterns[i].pattern_len);
  1749. memcpy(wow_pattern->mask_bytes, patterns[i].mask, mask_len);
  1750. wow_pattern->pattern_len = patterns[i].pattern_len;
  1751. /*
  1752. * just need to take care of deauth and disssoc pattern,
  1753. * make sure we don't overwrite them.
  1754. */
  1755. ath9k_hw_wow_apply_pattern(ah, wow_pattern->pattern_bytes,
  1756. wow_pattern->mask_bytes,
  1757. i + 2,
  1758. wow_pattern->pattern_len);
  1759. kfree(wow_pattern);
  1760. }
  1761. }
  1762. static int ath9k_suspend(struct ieee80211_hw *hw,
  1763. struct cfg80211_wowlan *wowlan)
  1764. {
  1765. struct ath_softc *sc = hw->priv;
  1766. struct ath_hw *ah = sc->sc_ah;
  1767. struct ath_common *common = ath9k_hw_common(ah);
  1768. u32 wow_triggers_enabled = 0;
  1769. int ret = 0;
  1770. mutex_lock(&sc->mutex);
  1771. ath_cancel_work(sc);
  1772. ath_stop_ani(sc);
  1773. del_timer_sync(&sc->rx_poll_timer);
  1774. if (test_bit(SC_OP_INVALID, &sc->sc_flags)) {
  1775. ath_dbg(common, ANY, "Device not present\n");
  1776. ret = -EINVAL;
  1777. goto fail_wow;
  1778. }
  1779. if (WARN_ON(!wowlan)) {
  1780. ath_dbg(common, WOW, "None of the WoW triggers enabled\n");
  1781. ret = -EINVAL;
  1782. goto fail_wow;
  1783. }
  1784. if (!device_can_wakeup(sc->dev)) {
  1785. ath_dbg(common, WOW, "device_can_wakeup failed, WoW is not enabled\n");
  1786. ret = 1;
  1787. goto fail_wow;
  1788. }
  1789. /*
  1790. * none of the sta vifs are associated
  1791. * and we are not currently handling multivif
  1792. * cases, for instance we have to seperately
  1793. * configure 'keep alive frame' for each
  1794. * STA.
  1795. */
  1796. if (!test_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags)) {
  1797. ath_dbg(common, WOW, "None of the STA vifs are associated\n");
  1798. ret = 1;
  1799. goto fail_wow;
  1800. }
  1801. if (sc->nvifs > 1) {
  1802. ath_dbg(common, WOW, "WoW for multivif is not yet supported\n");
  1803. ret = 1;
  1804. goto fail_wow;
  1805. }
  1806. ath9k_wow_map_triggers(sc, wowlan, &wow_triggers_enabled);
  1807. ath_dbg(common, WOW, "WoW triggers enabled 0x%x\n",
  1808. wow_triggers_enabled);
  1809. ath9k_ps_wakeup(sc);
  1810. ath9k_stop_btcoex(sc);
  1811. /*
  1812. * Enable wake up on recieving disassoc/deauth
  1813. * frame by default.
  1814. */
  1815. ath9k_wow_add_disassoc_deauth_pattern(sc);
  1816. if (wow_triggers_enabled & AH_WOW_USER_PATTERN_EN)
  1817. ath9k_wow_add_pattern(sc, wowlan);
  1818. spin_lock_bh(&sc->sc_pcu_lock);
  1819. /*
  1820. * To avoid false wake, we enable beacon miss interrupt only
  1821. * when we go to sleep. We save the current interrupt mask
  1822. * so we can restore it after the system wakes up
  1823. */
  1824. sc->wow_intr_before_sleep = ah->imask;
  1825. ah->imask &= ~ATH9K_INT_GLOBAL;
  1826. ath9k_hw_disable_interrupts(ah);
  1827. ah->imask = ATH9K_INT_BMISS | ATH9K_INT_GLOBAL;
  1828. ath9k_hw_set_interrupts(ah);
  1829. ath9k_hw_enable_interrupts(ah);
  1830. spin_unlock_bh(&sc->sc_pcu_lock);
  1831. /*
  1832. * we can now sync irq and kill any running tasklets, since we already
  1833. * disabled interrupts and not holding a spin lock
  1834. */
  1835. synchronize_irq(sc->irq);
  1836. tasklet_kill(&sc->intr_tq);
  1837. ath9k_hw_wow_enable(ah, wow_triggers_enabled);
  1838. ath9k_ps_restore(sc);
  1839. ath_dbg(common, ANY, "WoW enabled in ath9k\n");
  1840. atomic_inc(&sc->wow_sleep_proc_intr);
  1841. fail_wow:
  1842. mutex_unlock(&sc->mutex);
  1843. return ret;
  1844. }
  1845. static int ath9k_resume(struct ieee80211_hw *hw)
  1846. {
  1847. struct ath_softc *sc = hw->priv;
  1848. struct ath_hw *ah = sc->sc_ah;
  1849. struct ath_common *common = ath9k_hw_common(ah);
  1850. u32 wow_status;
  1851. mutex_lock(&sc->mutex);
  1852. ath9k_ps_wakeup(sc);
  1853. spin_lock_bh(&sc->sc_pcu_lock);
  1854. ath9k_hw_disable_interrupts(ah);
  1855. ah->imask = sc->wow_intr_before_sleep;
  1856. ath9k_hw_set_interrupts(ah);
  1857. ath9k_hw_enable_interrupts(ah);
  1858. spin_unlock_bh(&sc->sc_pcu_lock);
  1859. wow_status = ath9k_hw_wow_wakeup(ah);
  1860. if (atomic_read(&sc->wow_got_bmiss_intr) == 0) {
  1861. /*
  1862. * some devices may not pick beacon miss
  1863. * as the reason they woke up so we add
  1864. * that here for that shortcoming.
  1865. */
  1866. wow_status |= AH_WOW_BEACON_MISS;
  1867. atomic_dec(&sc->wow_got_bmiss_intr);
  1868. ath_dbg(common, ANY, "Beacon miss interrupt picked up during WoW sleep\n");
  1869. }
  1870. atomic_dec(&sc->wow_sleep_proc_intr);
  1871. if (wow_status) {
  1872. ath_dbg(common, ANY, "Waking up due to WoW triggers %s with WoW status = %x\n",
  1873. ath9k_hw_wow_event_to_string(wow_status), wow_status);
  1874. }
  1875. ath_restart_work(sc);
  1876. ath9k_start_btcoex(sc);
  1877. ath9k_ps_restore(sc);
  1878. mutex_unlock(&sc->mutex);
  1879. return 0;
  1880. }
  1881. static void ath9k_set_wakeup(struct ieee80211_hw *hw, bool enabled)
  1882. {
  1883. struct ath_softc *sc = hw->priv;
  1884. mutex_lock(&sc->mutex);
  1885. device_init_wakeup(sc->dev, 1);
  1886. device_set_wakeup_enable(sc->dev, enabled);
  1887. mutex_unlock(&sc->mutex);
  1888. }
  1889. #endif
  1890. static void ath9k_sw_scan_start(struct ieee80211_hw *hw)
  1891. {
  1892. struct ath_softc *sc = hw->priv;
  1893. sc->scanning = 1;
  1894. }
  1895. static void ath9k_sw_scan_complete(struct ieee80211_hw *hw)
  1896. {
  1897. struct ath_softc *sc = hw->priv;
  1898. sc->scanning = 0;
  1899. }
  1900. struct ieee80211_ops ath9k_ops = {
  1901. .tx = ath9k_tx,
  1902. .start = ath9k_start,
  1903. .stop = ath9k_stop,
  1904. .add_interface = ath9k_add_interface,
  1905. .change_interface = ath9k_change_interface,
  1906. .remove_interface = ath9k_remove_interface,
  1907. .config = ath9k_config,
  1908. .configure_filter = ath9k_configure_filter,
  1909. .sta_add = ath9k_sta_add,
  1910. .sta_remove = ath9k_sta_remove,
  1911. .sta_notify = ath9k_sta_notify,
  1912. .conf_tx = ath9k_conf_tx,
  1913. .bss_info_changed = ath9k_bss_info_changed,
  1914. .set_key = ath9k_set_key,
  1915. .get_tsf = ath9k_get_tsf,
  1916. .set_tsf = ath9k_set_tsf,
  1917. .reset_tsf = ath9k_reset_tsf,
  1918. .ampdu_action = ath9k_ampdu_action,
  1919. .get_survey = ath9k_get_survey,
  1920. .rfkill_poll = ath9k_rfkill_poll_state,
  1921. .set_coverage_class = ath9k_set_coverage_class,
  1922. .flush = ath9k_flush,
  1923. .tx_frames_pending = ath9k_tx_frames_pending,
  1924. .tx_last_beacon = ath9k_tx_last_beacon,
  1925. .get_stats = ath9k_get_stats,
  1926. .set_antenna = ath9k_set_antenna,
  1927. .get_antenna = ath9k_get_antenna,
  1928. #ifdef CONFIG_PM_SLEEP
  1929. .suspend = ath9k_suspend,
  1930. .resume = ath9k_resume,
  1931. .set_wakeup = ath9k_set_wakeup,
  1932. #endif
  1933. #ifdef CONFIG_ATH9K_DEBUGFS
  1934. .get_et_sset_count = ath9k_get_et_sset_count,
  1935. .get_et_stats = ath9k_get_et_stats,
  1936. .get_et_strings = ath9k_get_et_strings,
  1937. #endif
  1938. #if defined(CONFIG_MAC80211_DEBUGFS) && defined(CONFIG_ATH9K_DEBUGFS)
  1939. .sta_add_debugfs = ath9k_sta_add_debugfs,
  1940. .sta_remove_debugfs = ath9k_sta_remove_debugfs,
  1941. #endif
  1942. .sw_scan_start = ath9k_sw_scan_start,
  1943. .sw_scan_complete = ath9k_sw_scan_complete,
  1944. };