main.c 58 KB

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