main.c 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336
  1. /*
  2. * Copyright (c) 2008-2009 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 "ath9k.h"
  18. #include "btcoex.h"
  19. static void ath_update_txpow(struct ath_softc *sc)
  20. {
  21. struct ath_hw *ah = sc->sc_ah;
  22. if (sc->curtxpow != sc->config.txpowlimit) {
  23. ath9k_hw_set_txpowerlimit(ah, sc->config.txpowlimit, false);
  24. /* read back in case value is clamped */
  25. sc->curtxpow = ath9k_hw_regulatory(ah)->power_limit;
  26. }
  27. }
  28. static u8 parse_mpdudensity(u8 mpdudensity)
  29. {
  30. /*
  31. * 802.11n D2.0 defined values for "Minimum MPDU Start Spacing":
  32. * 0 for no restriction
  33. * 1 for 1/4 us
  34. * 2 for 1/2 us
  35. * 3 for 1 us
  36. * 4 for 2 us
  37. * 5 for 4 us
  38. * 6 for 8 us
  39. * 7 for 16 us
  40. */
  41. switch (mpdudensity) {
  42. case 0:
  43. return 0;
  44. case 1:
  45. case 2:
  46. case 3:
  47. /* Our lower layer calculations limit our precision to
  48. 1 microsecond */
  49. return 1;
  50. case 4:
  51. return 2;
  52. case 5:
  53. return 4;
  54. case 6:
  55. return 8;
  56. case 7:
  57. return 16;
  58. default:
  59. return 0;
  60. }
  61. }
  62. static struct ath9k_channel *ath_get_curchannel(struct ath_softc *sc,
  63. struct ieee80211_hw *hw)
  64. {
  65. struct ieee80211_channel *curchan = hw->conf.channel;
  66. struct ath9k_channel *channel;
  67. u8 chan_idx;
  68. chan_idx = curchan->hw_value;
  69. channel = &sc->sc_ah->channels[chan_idx];
  70. ath9k_update_ichannel(sc, hw, channel);
  71. return channel;
  72. }
  73. bool ath9k_setpower(struct ath_softc *sc, enum ath9k_power_mode mode)
  74. {
  75. unsigned long flags;
  76. bool ret;
  77. spin_lock_irqsave(&sc->sc_pm_lock, flags);
  78. ret = ath9k_hw_setpower(sc->sc_ah, mode);
  79. spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
  80. return ret;
  81. }
  82. void ath9k_ps_wakeup(struct ath_softc *sc)
  83. {
  84. struct ath_common *common = ath9k_hw_common(sc->sc_ah);
  85. unsigned long flags;
  86. enum ath9k_power_mode power_mode;
  87. spin_lock_irqsave(&sc->sc_pm_lock, flags);
  88. if (++sc->ps_usecount != 1)
  89. goto unlock;
  90. power_mode = sc->sc_ah->power_mode;
  91. ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_AWAKE);
  92. /*
  93. * While the hardware is asleep, the cycle counters contain no
  94. * useful data. Better clear them now so that they don't mess up
  95. * survey data results.
  96. */
  97. if (power_mode != ATH9K_PM_AWAKE) {
  98. spin_lock(&common->cc_lock);
  99. ath_hw_cycle_counters_update(common);
  100. memset(&common->cc_survey, 0, sizeof(common->cc_survey));
  101. spin_unlock(&common->cc_lock);
  102. }
  103. unlock:
  104. spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
  105. }
  106. void ath9k_ps_restore(struct ath_softc *sc)
  107. {
  108. struct ath_common *common = ath9k_hw_common(sc->sc_ah);
  109. unsigned long flags;
  110. spin_lock_irqsave(&sc->sc_pm_lock, flags);
  111. if (--sc->ps_usecount != 0)
  112. goto unlock;
  113. spin_lock(&common->cc_lock);
  114. ath_hw_cycle_counters_update(common);
  115. spin_unlock(&common->cc_lock);
  116. if (sc->ps_idle)
  117. ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_FULL_SLEEP);
  118. else if (sc->ps_enabled &&
  119. !(sc->ps_flags & (PS_WAIT_FOR_BEACON |
  120. PS_WAIT_FOR_CAB |
  121. PS_WAIT_FOR_PSPOLL_DATA |
  122. PS_WAIT_FOR_TX_ACK)))
  123. ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_NETWORK_SLEEP);
  124. unlock:
  125. spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
  126. }
  127. static void ath_start_ani(struct ath_common *common)
  128. {
  129. struct ath_hw *ah = common->ah;
  130. unsigned long timestamp = jiffies_to_msecs(jiffies);
  131. struct ath_softc *sc = (struct ath_softc *) common->priv;
  132. if (!(sc->sc_flags & SC_OP_ANI_RUN))
  133. return;
  134. if (sc->sc_flags & SC_OP_OFFCHANNEL)
  135. return;
  136. common->ani.longcal_timer = timestamp;
  137. common->ani.shortcal_timer = timestamp;
  138. common->ani.checkani_timer = timestamp;
  139. mod_timer(&common->ani.timer,
  140. jiffies +
  141. msecs_to_jiffies((u32)ah->config.ani_poll_interval));
  142. }
  143. static void ath_update_survey_nf(struct ath_softc *sc, int channel)
  144. {
  145. struct ath_hw *ah = sc->sc_ah;
  146. struct ath9k_channel *chan = &ah->channels[channel];
  147. struct survey_info *survey = &sc->survey[channel];
  148. if (chan->noisefloor) {
  149. survey->filled |= SURVEY_INFO_NOISE_DBM;
  150. survey->noise = chan->noisefloor;
  151. }
  152. }
  153. static void ath_update_survey_stats(struct ath_softc *sc)
  154. {
  155. struct ath_hw *ah = sc->sc_ah;
  156. struct ath_common *common = ath9k_hw_common(ah);
  157. int pos = ah->curchan - &ah->channels[0];
  158. struct survey_info *survey = &sc->survey[pos];
  159. struct ath_cycle_counters *cc = &common->cc_survey;
  160. unsigned int div = common->clockrate * 1000;
  161. if (!ah->curchan)
  162. return;
  163. if (ah->power_mode == ATH9K_PM_AWAKE)
  164. ath_hw_cycle_counters_update(common);
  165. if (cc->cycles > 0) {
  166. survey->filled |= SURVEY_INFO_CHANNEL_TIME |
  167. SURVEY_INFO_CHANNEL_TIME_BUSY |
  168. SURVEY_INFO_CHANNEL_TIME_RX |
  169. SURVEY_INFO_CHANNEL_TIME_TX;
  170. survey->channel_time += cc->cycles / div;
  171. survey->channel_time_busy += cc->rx_busy / div;
  172. survey->channel_time_rx += cc->rx_frame / div;
  173. survey->channel_time_tx += cc->tx_frame / div;
  174. }
  175. memset(cc, 0, sizeof(*cc));
  176. ath_update_survey_nf(sc, pos);
  177. }
  178. /*
  179. * Set/change channels. If the channel is really being changed, it's done
  180. * by reseting the chip. To accomplish this we must first cleanup any pending
  181. * DMA, then restart stuff.
  182. */
  183. int ath_set_channel(struct ath_softc *sc, struct ieee80211_hw *hw,
  184. struct ath9k_channel *hchan)
  185. {
  186. struct ath_wiphy *aphy = hw->priv;
  187. struct ath_hw *ah = sc->sc_ah;
  188. struct ath_common *common = ath9k_hw_common(ah);
  189. struct ieee80211_conf *conf = &common->hw->conf;
  190. bool fastcc = true, stopped;
  191. struct ieee80211_channel *channel = hw->conf.channel;
  192. struct ath9k_hw_cal_data *caldata = NULL;
  193. int r;
  194. if (sc->sc_flags & SC_OP_INVALID)
  195. return -EIO;
  196. del_timer_sync(&common->ani.timer);
  197. cancel_work_sync(&sc->paprd_work);
  198. cancel_work_sync(&sc->hw_check_work);
  199. cancel_delayed_work_sync(&sc->tx_complete_work);
  200. ath9k_ps_wakeup(sc);
  201. spin_lock_bh(&sc->sc_pcu_lock);
  202. /*
  203. * This is only performed if the channel settings have
  204. * actually changed.
  205. *
  206. * To switch channels clear any pending DMA operations;
  207. * wait long enough for the RX fifo to drain, reset the
  208. * hardware at the new frequency, and then re-enable
  209. * the relevant bits of the h/w.
  210. */
  211. ath9k_hw_disable_interrupts(ah);
  212. stopped = ath_drain_all_txq(sc, false);
  213. if (!ath_stoprecv(sc))
  214. stopped = false;
  215. if (!ath9k_hw_check_alive(ah))
  216. stopped = false;
  217. /* XXX: do not flush receive queue here. We don't want
  218. * to flush data frames already in queue because of
  219. * changing channel. */
  220. if (!stopped || !(sc->sc_flags & SC_OP_OFFCHANNEL))
  221. fastcc = false;
  222. if (!(sc->sc_flags & SC_OP_OFFCHANNEL))
  223. caldata = &aphy->caldata;
  224. ath_dbg(common, ATH_DBG_CONFIG,
  225. "(%u MHz) -> (%u MHz), conf_is_ht40: %d fastcc: %d\n",
  226. sc->sc_ah->curchan->channel,
  227. channel->center_freq, conf_is_ht40(conf),
  228. fastcc);
  229. r = ath9k_hw_reset(ah, hchan, caldata, fastcc);
  230. if (r) {
  231. ath_err(common,
  232. "Unable to reset channel (%u MHz), reset status %d\n",
  233. channel->center_freq, r);
  234. goto ps_restore;
  235. }
  236. if (ath_startrecv(sc) != 0) {
  237. ath_err(common, "Unable to restart recv logic\n");
  238. r = -EIO;
  239. goto ps_restore;
  240. }
  241. ath_update_txpow(sc);
  242. ath9k_hw_set_interrupts(ah, ah->imask);
  243. if (!(sc->sc_flags & (SC_OP_OFFCHANNEL))) {
  244. if (sc->sc_flags & SC_OP_BEACONS)
  245. ath_beacon_config(sc, NULL);
  246. ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 0);
  247. ath_start_ani(common);
  248. }
  249. ps_restore:
  250. spin_unlock_bh(&sc->sc_pcu_lock);
  251. ath9k_ps_restore(sc);
  252. return r;
  253. }
  254. static void ath_paprd_activate(struct ath_softc *sc)
  255. {
  256. struct ath_hw *ah = sc->sc_ah;
  257. struct ath9k_hw_cal_data *caldata = ah->caldata;
  258. struct ath_common *common = ath9k_hw_common(ah);
  259. int chain;
  260. if (!caldata || !caldata->paprd_done)
  261. return;
  262. ath9k_ps_wakeup(sc);
  263. ar9003_paprd_enable(ah, false);
  264. for (chain = 0; chain < AR9300_MAX_CHAINS; chain++) {
  265. if (!(common->tx_chainmask & BIT(chain)))
  266. continue;
  267. ar9003_paprd_populate_single_table(ah, caldata, chain);
  268. }
  269. ar9003_paprd_enable(ah, true);
  270. ath9k_ps_restore(sc);
  271. }
  272. static bool ath_paprd_send_frame(struct ath_softc *sc, struct sk_buff *skb, int chain)
  273. {
  274. struct ieee80211_hw *hw = sc->hw;
  275. struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
  276. struct ath_tx_control txctl;
  277. int time_left;
  278. memset(&txctl, 0, sizeof(txctl));
  279. txctl.txq = sc->tx.txq_map[WME_AC_BE];
  280. memset(tx_info, 0, sizeof(*tx_info));
  281. tx_info->band = hw->conf.channel->band;
  282. tx_info->flags |= IEEE80211_TX_CTL_NO_ACK;
  283. tx_info->control.rates[0].idx = 0;
  284. tx_info->control.rates[0].count = 1;
  285. tx_info->control.rates[0].flags = IEEE80211_TX_RC_MCS;
  286. tx_info->control.rates[1].idx = -1;
  287. init_completion(&sc->paprd_complete);
  288. sc->paprd_pending = true;
  289. txctl.paprd = BIT(chain);
  290. if (ath_tx_start(hw, skb, &txctl) != 0)
  291. return false;
  292. time_left = wait_for_completion_timeout(&sc->paprd_complete,
  293. msecs_to_jiffies(ATH_PAPRD_TIMEOUT));
  294. sc->paprd_pending = false;
  295. if (!time_left)
  296. ath_dbg(ath9k_hw_common(sc->sc_ah), ATH_DBG_CALIBRATE,
  297. "Timeout waiting for paprd training on TX chain %d\n",
  298. chain);
  299. return !!time_left;
  300. }
  301. void ath_paprd_calibrate(struct work_struct *work)
  302. {
  303. struct ath_softc *sc = container_of(work, struct ath_softc, paprd_work);
  304. struct ieee80211_hw *hw = sc->hw;
  305. struct ath_hw *ah = sc->sc_ah;
  306. struct ieee80211_hdr *hdr;
  307. struct sk_buff *skb = NULL;
  308. struct ath9k_hw_cal_data *caldata = ah->caldata;
  309. struct ath_common *common = ath9k_hw_common(ah);
  310. int ftype;
  311. int chain_ok = 0;
  312. int chain;
  313. int len = 1800;
  314. if (!caldata)
  315. return;
  316. if (ar9003_paprd_init_table(ah) < 0)
  317. return;
  318. skb = alloc_skb(len, GFP_KERNEL);
  319. if (!skb)
  320. return;
  321. skb_put(skb, len);
  322. memset(skb->data, 0, len);
  323. hdr = (struct ieee80211_hdr *)skb->data;
  324. ftype = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC;
  325. hdr->frame_control = cpu_to_le16(ftype);
  326. hdr->duration_id = cpu_to_le16(10);
  327. memcpy(hdr->addr1, hw->wiphy->perm_addr, ETH_ALEN);
  328. memcpy(hdr->addr2, hw->wiphy->perm_addr, ETH_ALEN);
  329. memcpy(hdr->addr3, hw->wiphy->perm_addr, ETH_ALEN);
  330. ath9k_ps_wakeup(sc);
  331. for (chain = 0; chain < AR9300_MAX_CHAINS; chain++) {
  332. if (!(common->tx_chainmask & BIT(chain)))
  333. continue;
  334. chain_ok = 0;
  335. ath_dbg(common, ATH_DBG_CALIBRATE,
  336. "Sending PAPRD frame for thermal measurement "
  337. "on chain %d\n", chain);
  338. if (!ath_paprd_send_frame(sc, skb, chain))
  339. goto fail_paprd;
  340. ar9003_paprd_setup_gain_table(ah, chain);
  341. ath_dbg(common, ATH_DBG_CALIBRATE,
  342. "Sending PAPRD training frame on chain %d\n", chain);
  343. if (!ath_paprd_send_frame(sc, skb, chain))
  344. goto fail_paprd;
  345. if (!ar9003_paprd_is_done(ah))
  346. break;
  347. if (ar9003_paprd_create_curve(ah, caldata, chain) != 0)
  348. break;
  349. chain_ok = 1;
  350. }
  351. kfree_skb(skb);
  352. if (chain_ok) {
  353. caldata->paprd_done = true;
  354. ath_paprd_activate(sc);
  355. }
  356. fail_paprd:
  357. ath9k_ps_restore(sc);
  358. }
  359. /*
  360. * This routine performs the periodic noise floor calibration function
  361. * that is used to adjust and optimize the chip performance. This
  362. * takes environmental changes (location, temperature) into account.
  363. * When the task is complete, it reschedules itself depending on the
  364. * appropriate interval that was calculated.
  365. */
  366. void ath_ani_calibrate(unsigned long data)
  367. {
  368. struct ath_softc *sc = (struct ath_softc *)data;
  369. struct ath_hw *ah = sc->sc_ah;
  370. struct ath_common *common = ath9k_hw_common(ah);
  371. bool longcal = false;
  372. bool shortcal = false;
  373. bool aniflag = false;
  374. unsigned int timestamp = jiffies_to_msecs(jiffies);
  375. u32 cal_interval, short_cal_interval, long_cal_interval;
  376. unsigned long flags;
  377. if (ah->caldata && ah->caldata->nfcal_interference)
  378. long_cal_interval = ATH_LONG_CALINTERVAL_INT;
  379. else
  380. long_cal_interval = ATH_LONG_CALINTERVAL;
  381. short_cal_interval = (ah->opmode == NL80211_IFTYPE_AP) ?
  382. ATH_AP_SHORT_CALINTERVAL : ATH_STA_SHORT_CALINTERVAL;
  383. /* Only calibrate if awake */
  384. if (sc->sc_ah->power_mode != ATH9K_PM_AWAKE)
  385. goto set_timer;
  386. ath9k_ps_wakeup(sc);
  387. /* Long calibration runs independently of short calibration. */
  388. if ((timestamp - common->ani.longcal_timer) >= long_cal_interval) {
  389. longcal = true;
  390. ath_dbg(common, ATH_DBG_ANI, "longcal @%lu\n", jiffies);
  391. common->ani.longcal_timer = timestamp;
  392. }
  393. /* Short calibration applies only while caldone is false */
  394. if (!common->ani.caldone) {
  395. if ((timestamp - common->ani.shortcal_timer) >= short_cal_interval) {
  396. shortcal = true;
  397. ath_dbg(common, ATH_DBG_ANI,
  398. "shortcal @%lu\n", jiffies);
  399. common->ani.shortcal_timer = timestamp;
  400. common->ani.resetcal_timer = timestamp;
  401. }
  402. } else {
  403. if ((timestamp - common->ani.resetcal_timer) >=
  404. ATH_RESTART_CALINTERVAL) {
  405. common->ani.caldone = ath9k_hw_reset_calvalid(ah);
  406. if (common->ani.caldone)
  407. common->ani.resetcal_timer = timestamp;
  408. }
  409. }
  410. /* Verify whether we must check ANI */
  411. if ((timestamp - common->ani.checkani_timer) >=
  412. ah->config.ani_poll_interval) {
  413. aniflag = true;
  414. common->ani.checkani_timer = timestamp;
  415. }
  416. /* Skip all processing if there's nothing to do. */
  417. if (longcal || shortcal || aniflag) {
  418. /* Call ANI routine if necessary */
  419. if (aniflag) {
  420. spin_lock_irqsave(&common->cc_lock, flags);
  421. ath9k_hw_ani_monitor(ah, ah->curchan);
  422. ath_update_survey_stats(sc);
  423. spin_unlock_irqrestore(&common->cc_lock, flags);
  424. }
  425. /* Perform calibration if necessary */
  426. if (longcal || shortcal) {
  427. common->ani.caldone =
  428. ath9k_hw_calibrate(ah,
  429. ah->curchan,
  430. common->rx_chainmask,
  431. longcal);
  432. }
  433. }
  434. ath9k_ps_restore(sc);
  435. set_timer:
  436. /*
  437. * Set timer interval based on previous results.
  438. * The interval must be the shortest necessary to satisfy ANI,
  439. * short calibration and long calibration.
  440. */
  441. cal_interval = ATH_LONG_CALINTERVAL;
  442. if (sc->sc_ah->config.enable_ani)
  443. cal_interval = min(cal_interval,
  444. (u32)ah->config.ani_poll_interval);
  445. if (!common->ani.caldone)
  446. cal_interval = min(cal_interval, (u32)short_cal_interval);
  447. mod_timer(&common->ani.timer, jiffies + msecs_to_jiffies(cal_interval));
  448. if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_PAPRD) && ah->caldata) {
  449. if (!ah->caldata->paprd_done)
  450. ieee80211_queue_work(sc->hw, &sc->paprd_work);
  451. else if (!ah->paprd_table_write_done)
  452. ath_paprd_activate(sc);
  453. }
  454. }
  455. static void ath_node_attach(struct ath_softc *sc, struct ieee80211_sta *sta)
  456. {
  457. struct ath_node *an;
  458. struct ath_hw *ah = sc->sc_ah;
  459. an = (struct ath_node *)sta->drv_priv;
  460. #ifdef CONFIG_ATH9K_DEBUGFS
  461. spin_lock(&sc->nodes_lock);
  462. list_add(&an->list, &sc->nodes);
  463. spin_unlock(&sc->nodes_lock);
  464. an->sta = sta;
  465. #endif
  466. if ((ah->caps.hw_caps) & ATH9K_HW_CAP_APM)
  467. sc->sc_flags |= SC_OP_ENABLE_APM;
  468. if (sc->sc_flags & SC_OP_TXAGGR) {
  469. ath_tx_node_init(sc, an);
  470. an->maxampdu = 1 << (IEEE80211_HT_MAX_AMPDU_FACTOR +
  471. sta->ht_cap.ampdu_factor);
  472. an->mpdudensity = parse_mpdudensity(sta->ht_cap.ampdu_density);
  473. }
  474. }
  475. static void ath_node_detach(struct ath_softc *sc, struct ieee80211_sta *sta)
  476. {
  477. struct ath_node *an = (struct ath_node *)sta->drv_priv;
  478. #ifdef CONFIG_ATH9K_DEBUGFS
  479. spin_lock(&sc->nodes_lock);
  480. list_del(&an->list);
  481. spin_unlock(&sc->nodes_lock);
  482. an->sta = NULL;
  483. #endif
  484. if (sc->sc_flags & SC_OP_TXAGGR)
  485. ath_tx_node_cleanup(sc, an);
  486. }
  487. void ath_hw_check(struct work_struct *work)
  488. {
  489. struct ath_softc *sc = container_of(work, struct ath_softc, hw_check_work);
  490. int i;
  491. ath9k_ps_wakeup(sc);
  492. for (i = 0; i < 3; i++) {
  493. if (ath9k_hw_check_alive(sc->sc_ah))
  494. goto out;
  495. msleep(1);
  496. }
  497. ath_reset(sc, true);
  498. out:
  499. ath9k_ps_restore(sc);
  500. }
  501. void ath9k_tasklet(unsigned long data)
  502. {
  503. struct ath_softc *sc = (struct ath_softc *)data;
  504. struct ath_hw *ah = sc->sc_ah;
  505. struct ath_common *common = ath9k_hw_common(ah);
  506. u32 status = sc->intrstatus;
  507. u32 rxmask;
  508. ath9k_ps_wakeup(sc);
  509. if (status & ATH9K_INT_FATAL) {
  510. ath_reset(sc, true);
  511. ath9k_ps_restore(sc);
  512. return;
  513. }
  514. spin_lock(&sc->sc_pcu_lock);
  515. /*
  516. * Only run the baseband hang check if beacons stop working in AP or
  517. * IBSS mode, because it has a high false positive rate. For station
  518. * mode it should not be necessary, since the upper layers will detect
  519. * this through a beacon miss automatically and the following channel
  520. * change will trigger a hardware reset anyway
  521. */
  522. if (ath9k_hw_numtxpending(ah, sc->beacon.beaconq) != 0 &&
  523. !ath9k_hw_check_alive(ah))
  524. ieee80211_queue_work(sc->hw, &sc->hw_check_work);
  525. if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
  526. rxmask = (ATH9K_INT_RXHP | ATH9K_INT_RXLP | ATH9K_INT_RXEOL |
  527. ATH9K_INT_RXORN);
  528. else
  529. rxmask = (ATH9K_INT_RX | ATH9K_INT_RXEOL | ATH9K_INT_RXORN);
  530. if (status & rxmask) {
  531. /* Check for high priority Rx first */
  532. if ((ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) &&
  533. (status & ATH9K_INT_RXHP))
  534. ath_rx_tasklet(sc, 0, true);
  535. ath_rx_tasklet(sc, 0, false);
  536. }
  537. if (status & ATH9K_INT_TX) {
  538. if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
  539. ath_tx_edma_tasklet(sc);
  540. else
  541. ath_tx_tasklet(sc);
  542. }
  543. if ((status & ATH9K_INT_TSFOOR) && sc->ps_enabled) {
  544. /*
  545. * TSF sync does not look correct; remain awake to sync with
  546. * the next Beacon.
  547. */
  548. ath_dbg(common, ATH_DBG_PS,
  549. "TSFOOR - Sync with next Beacon\n");
  550. sc->ps_flags |= PS_WAIT_FOR_BEACON | PS_BEACON_SYNC;
  551. }
  552. if (ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE)
  553. if (status & ATH9K_INT_GENTIMER)
  554. ath_gen_timer_isr(sc->sc_ah);
  555. /* re-enable hardware interrupt */
  556. ath9k_hw_enable_interrupts(ah);
  557. spin_unlock(&sc->sc_pcu_lock);
  558. ath9k_ps_restore(sc);
  559. }
  560. irqreturn_t ath_isr(int irq, void *dev)
  561. {
  562. #define SCHED_INTR ( \
  563. ATH9K_INT_FATAL | \
  564. ATH9K_INT_RXORN | \
  565. ATH9K_INT_RXEOL | \
  566. ATH9K_INT_RX | \
  567. ATH9K_INT_RXLP | \
  568. ATH9K_INT_RXHP | \
  569. ATH9K_INT_TX | \
  570. ATH9K_INT_BMISS | \
  571. ATH9K_INT_CST | \
  572. ATH9K_INT_TSFOOR | \
  573. ATH9K_INT_GENTIMER)
  574. struct ath_softc *sc = dev;
  575. struct ath_hw *ah = sc->sc_ah;
  576. struct ath_common *common = ath9k_hw_common(ah);
  577. enum ath9k_int status;
  578. bool sched = false;
  579. /*
  580. * The hardware is not ready/present, don't
  581. * touch anything. Note this can happen early
  582. * on if the IRQ is shared.
  583. */
  584. if (sc->sc_flags & SC_OP_INVALID)
  585. return IRQ_NONE;
  586. /* shared irq, not for us */
  587. if (!ath9k_hw_intrpend(ah))
  588. return IRQ_NONE;
  589. /*
  590. * Figure out the reason(s) for the interrupt. Note
  591. * that the hal returns a pseudo-ISR that may include
  592. * bits we haven't explicitly enabled so we mask the
  593. * value to insure we only process bits we requested.
  594. */
  595. ath9k_hw_getisr(ah, &status); /* NB: clears ISR too */
  596. status &= ah->imask; /* discard unasked-for bits */
  597. /*
  598. * If there are no status bits set, then this interrupt was not
  599. * for me (should have been caught above).
  600. */
  601. if (!status)
  602. return IRQ_NONE;
  603. /* Cache the status */
  604. sc->intrstatus = status;
  605. if (status & SCHED_INTR)
  606. sched = true;
  607. /*
  608. * If a FATAL or RXORN interrupt is received, we have to reset the
  609. * chip immediately.
  610. */
  611. if ((status & ATH9K_INT_FATAL) || ((status & ATH9K_INT_RXORN) &&
  612. !(ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)))
  613. goto chip_reset;
  614. if ((ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) &&
  615. (status & ATH9K_INT_BB_WATCHDOG)) {
  616. spin_lock(&common->cc_lock);
  617. ath_hw_cycle_counters_update(common);
  618. ar9003_hw_bb_watchdog_dbg_info(ah);
  619. spin_unlock(&common->cc_lock);
  620. goto chip_reset;
  621. }
  622. if (status & ATH9K_INT_SWBA)
  623. tasklet_schedule(&sc->bcon_tasklet);
  624. if (status & ATH9K_INT_TXURN)
  625. ath9k_hw_updatetxtriglevel(ah, true);
  626. if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
  627. if (status & ATH9K_INT_RXEOL) {
  628. ah->imask &= ~(ATH9K_INT_RXEOL | ATH9K_INT_RXORN);
  629. ath9k_hw_set_interrupts(ah, ah->imask);
  630. }
  631. }
  632. if (status & ATH9K_INT_MIB) {
  633. /*
  634. * Disable interrupts until we service the MIB
  635. * interrupt; otherwise it will continue to
  636. * fire.
  637. */
  638. ath9k_hw_disable_interrupts(ah);
  639. /*
  640. * Let the hal handle the event. We assume
  641. * it will clear whatever condition caused
  642. * the interrupt.
  643. */
  644. spin_lock(&common->cc_lock);
  645. ath9k_hw_proc_mib_event(ah);
  646. spin_unlock(&common->cc_lock);
  647. ath9k_hw_enable_interrupts(ah);
  648. }
  649. if (!(ah->caps.hw_caps & ATH9K_HW_CAP_AUTOSLEEP))
  650. if (status & ATH9K_INT_TIM_TIMER) {
  651. if (ATH_DBG_WARN_ON_ONCE(sc->ps_idle))
  652. goto chip_reset;
  653. /* Clear RxAbort bit so that we can
  654. * receive frames */
  655. ath9k_setpower(sc, ATH9K_PM_AWAKE);
  656. ath9k_hw_setrxabort(sc->sc_ah, 0);
  657. sc->ps_flags |= PS_WAIT_FOR_BEACON;
  658. }
  659. chip_reset:
  660. ath_debug_stat_interrupt(sc, status);
  661. if (sched) {
  662. /* turn off every interrupt */
  663. ath9k_hw_disable_interrupts(ah);
  664. tasklet_schedule(&sc->intr_tq);
  665. }
  666. return IRQ_HANDLED;
  667. #undef SCHED_INTR
  668. }
  669. static u32 ath_get_extchanmode(struct ath_softc *sc,
  670. struct ieee80211_channel *chan,
  671. enum nl80211_channel_type channel_type)
  672. {
  673. u32 chanmode = 0;
  674. switch (chan->band) {
  675. case IEEE80211_BAND_2GHZ:
  676. switch(channel_type) {
  677. case NL80211_CHAN_NO_HT:
  678. case NL80211_CHAN_HT20:
  679. chanmode = CHANNEL_G_HT20;
  680. break;
  681. case NL80211_CHAN_HT40PLUS:
  682. chanmode = CHANNEL_G_HT40PLUS;
  683. break;
  684. case NL80211_CHAN_HT40MINUS:
  685. chanmode = CHANNEL_G_HT40MINUS;
  686. break;
  687. }
  688. break;
  689. case IEEE80211_BAND_5GHZ:
  690. switch(channel_type) {
  691. case NL80211_CHAN_NO_HT:
  692. case NL80211_CHAN_HT20:
  693. chanmode = CHANNEL_A_HT20;
  694. break;
  695. case NL80211_CHAN_HT40PLUS:
  696. chanmode = CHANNEL_A_HT40PLUS;
  697. break;
  698. case NL80211_CHAN_HT40MINUS:
  699. chanmode = CHANNEL_A_HT40MINUS;
  700. break;
  701. }
  702. break;
  703. default:
  704. break;
  705. }
  706. return chanmode;
  707. }
  708. static void ath9k_bss_assoc_info(struct ath_softc *sc,
  709. struct ieee80211_hw *hw,
  710. struct ieee80211_vif *vif,
  711. struct ieee80211_bss_conf *bss_conf)
  712. {
  713. struct ath_wiphy *aphy = hw->priv;
  714. struct ath_hw *ah = sc->sc_ah;
  715. struct ath_common *common = ath9k_hw_common(ah);
  716. if (bss_conf->assoc) {
  717. ath_dbg(common, ATH_DBG_CONFIG,
  718. "Bss Info ASSOC %d, bssid: %pM\n",
  719. bss_conf->aid, common->curbssid);
  720. /* New association, store aid */
  721. common->curaid = bss_conf->aid;
  722. ath9k_hw_write_associd(ah);
  723. /*
  724. * Request a re-configuration of Beacon related timers
  725. * on the receipt of the first Beacon frame (i.e.,
  726. * after time sync with the AP).
  727. */
  728. sc->ps_flags |= PS_BEACON_SYNC;
  729. /* Configure the beacon */
  730. ath_beacon_config(sc, vif);
  731. /* Reset rssi stats */
  732. aphy->last_rssi = ATH_RSSI_DUMMY_MARKER;
  733. sc->sc_ah->stats.avgbrssi = ATH_RSSI_DUMMY_MARKER;
  734. sc->sc_flags |= SC_OP_ANI_RUN;
  735. ath_start_ani(common);
  736. } else {
  737. ath_dbg(common, ATH_DBG_CONFIG, "Bss Info DISASSOC\n");
  738. common->curaid = 0;
  739. /* Stop ANI */
  740. sc->sc_flags &= ~SC_OP_ANI_RUN;
  741. del_timer_sync(&common->ani.timer);
  742. }
  743. }
  744. void ath_radio_enable(struct ath_softc *sc, struct ieee80211_hw *hw)
  745. {
  746. struct ath_hw *ah = sc->sc_ah;
  747. struct ath_common *common = ath9k_hw_common(ah);
  748. struct ieee80211_channel *channel = hw->conf.channel;
  749. int r;
  750. ath9k_ps_wakeup(sc);
  751. spin_lock_bh(&sc->sc_pcu_lock);
  752. ath9k_hw_configpcipowersave(ah, 0, 0);
  753. if (!ah->curchan)
  754. ah->curchan = ath_get_curchannel(sc, sc->hw);
  755. r = ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
  756. if (r) {
  757. ath_err(common,
  758. "Unable to reset channel (%u MHz), reset status %d\n",
  759. channel->center_freq, r);
  760. }
  761. ath_update_txpow(sc);
  762. if (ath_startrecv(sc) != 0) {
  763. ath_err(common, "Unable to restart recv logic\n");
  764. goto out;
  765. }
  766. if (sc->sc_flags & SC_OP_BEACONS)
  767. ath_beacon_config(sc, NULL); /* restart beacons */
  768. /* Re-Enable interrupts */
  769. ath9k_hw_set_interrupts(ah, ah->imask);
  770. /* Enable LED */
  771. ath9k_hw_cfg_output(ah, ah->led_pin,
  772. AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
  773. ath9k_hw_set_gpio(ah, ah->led_pin, 0);
  774. ieee80211_wake_queues(hw);
  775. out:
  776. spin_unlock_bh(&sc->sc_pcu_lock);
  777. ath9k_ps_restore(sc);
  778. }
  779. void ath_radio_disable(struct ath_softc *sc, struct ieee80211_hw *hw)
  780. {
  781. struct ath_hw *ah = sc->sc_ah;
  782. struct ieee80211_channel *channel = hw->conf.channel;
  783. int r;
  784. ath9k_ps_wakeup(sc);
  785. spin_lock_bh(&sc->sc_pcu_lock);
  786. ieee80211_stop_queues(hw);
  787. /*
  788. * Keep the LED on when the radio is disabled
  789. * during idle unassociated state.
  790. */
  791. if (!sc->ps_idle) {
  792. ath9k_hw_set_gpio(ah, ah->led_pin, 1);
  793. ath9k_hw_cfg_gpio_input(ah, ah->led_pin);
  794. }
  795. /* Disable interrupts */
  796. ath9k_hw_disable_interrupts(ah);
  797. ath_drain_all_txq(sc, false); /* clear pending tx frames */
  798. ath_stoprecv(sc); /* turn off frame recv */
  799. ath_flushrecv(sc); /* flush recv queue */
  800. if (!ah->curchan)
  801. ah->curchan = ath_get_curchannel(sc, hw);
  802. r = ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
  803. if (r) {
  804. ath_err(ath9k_hw_common(sc->sc_ah),
  805. "Unable to reset channel (%u MHz), reset status %d\n",
  806. channel->center_freq, r);
  807. }
  808. ath9k_hw_phy_disable(ah);
  809. ath9k_hw_configpcipowersave(ah, 1, 1);
  810. spin_unlock_bh(&sc->sc_pcu_lock);
  811. ath9k_ps_restore(sc);
  812. ath9k_setpower(sc, ATH9K_PM_FULL_SLEEP);
  813. }
  814. int ath_reset(struct ath_softc *sc, bool retry_tx)
  815. {
  816. struct ath_hw *ah = sc->sc_ah;
  817. struct ath_common *common = ath9k_hw_common(ah);
  818. struct ieee80211_hw *hw = sc->hw;
  819. int r;
  820. /* Stop ANI */
  821. del_timer_sync(&common->ani.timer);
  822. spin_lock_bh(&sc->sc_pcu_lock);
  823. ieee80211_stop_queues(hw);
  824. ath9k_hw_disable_interrupts(ah);
  825. ath_drain_all_txq(sc, retry_tx);
  826. ath_stoprecv(sc);
  827. ath_flushrecv(sc);
  828. r = ath9k_hw_reset(ah, sc->sc_ah->curchan, ah->caldata, false);
  829. if (r)
  830. ath_err(common,
  831. "Unable to reset hardware; reset status %d\n", r);
  832. if (ath_startrecv(sc) != 0)
  833. ath_err(common, "Unable to start recv logic\n");
  834. /*
  835. * We may be doing a reset in response to a request
  836. * that changes the channel so update any state that
  837. * might change as a result.
  838. */
  839. ath_update_txpow(sc);
  840. if ((sc->sc_flags & SC_OP_BEACONS) || !(sc->sc_flags & (SC_OP_OFFCHANNEL)))
  841. ath_beacon_config(sc, NULL); /* restart beacons */
  842. ath9k_hw_set_interrupts(ah, ah->imask);
  843. if (retry_tx) {
  844. int i;
  845. for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
  846. if (ATH_TXQ_SETUP(sc, i)) {
  847. spin_lock_bh(&sc->tx.txq[i].axq_lock);
  848. ath_txq_schedule(sc, &sc->tx.txq[i]);
  849. spin_unlock_bh(&sc->tx.txq[i].axq_lock);
  850. }
  851. }
  852. }
  853. ieee80211_wake_queues(hw);
  854. spin_unlock_bh(&sc->sc_pcu_lock);
  855. /* Start ANI */
  856. ath_start_ani(common);
  857. return r;
  858. }
  859. /* XXX: Remove me once we don't depend on ath9k_channel for all
  860. * this redundant data */
  861. void ath9k_update_ichannel(struct ath_softc *sc, struct ieee80211_hw *hw,
  862. struct ath9k_channel *ichan)
  863. {
  864. struct ieee80211_channel *chan = hw->conf.channel;
  865. struct ieee80211_conf *conf = &hw->conf;
  866. ichan->channel = chan->center_freq;
  867. ichan->chan = chan;
  868. if (chan->band == IEEE80211_BAND_2GHZ) {
  869. ichan->chanmode = CHANNEL_G;
  870. ichan->channelFlags = CHANNEL_2GHZ | CHANNEL_OFDM | CHANNEL_G;
  871. } else {
  872. ichan->chanmode = CHANNEL_A;
  873. ichan->channelFlags = CHANNEL_5GHZ | CHANNEL_OFDM;
  874. }
  875. if (conf_is_ht(conf))
  876. ichan->chanmode = ath_get_extchanmode(sc, chan,
  877. conf->channel_type);
  878. }
  879. /**********************/
  880. /* mac80211 callbacks */
  881. /**********************/
  882. static int ath9k_start(struct ieee80211_hw *hw)
  883. {
  884. struct ath_wiphy *aphy = hw->priv;
  885. struct ath_softc *sc = aphy->sc;
  886. struct ath_hw *ah = sc->sc_ah;
  887. struct ath_common *common = ath9k_hw_common(ah);
  888. struct ieee80211_channel *curchan = hw->conf.channel;
  889. struct ath9k_channel *init_channel;
  890. int r;
  891. ath_dbg(common, ATH_DBG_CONFIG,
  892. "Starting driver with initial channel: %d MHz\n",
  893. curchan->center_freq);
  894. mutex_lock(&sc->mutex);
  895. if (ath9k_wiphy_started(sc)) {
  896. if (sc->chan_idx == curchan->hw_value) {
  897. /*
  898. * Already on the operational channel, the new wiphy
  899. * can be marked active.
  900. */
  901. aphy->state = ATH_WIPHY_ACTIVE;
  902. ieee80211_wake_queues(hw);
  903. } else {
  904. /*
  905. * Another wiphy is on another channel, start the new
  906. * wiphy in paused state.
  907. */
  908. aphy->state = ATH_WIPHY_PAUSED;
  909. ieee80211_stop_queues(hw);
  910. }
  911. mutex_unlock(&sc->mutex);
  912. return 0;
  913. }
  914. aphy->state = ATH_WIPHY_ACTIVE;
  915. /* setup initial channel */
  916. sc->chan_idx = curchan->hw_value;
  917. init_channel = ath_get_curchannel(sc, hw);
  918. /* Reset SERDES registers */
  919. ath9k_hw_configpcipowersave(ah, 0, 0);
  920. /*
  921. * The basic interface to setting the hardware in a good
  922. * state is ``reset''. On return the hardware is known to
  923. * be powered up and with interrupts disabled. This must
  924. * be followed by initialization of the appropriate bits
  925. * and then setup of the interrupt mask.
  926. */
  927. spin_lock_bh(&sc->sc_pcu_lock);
  928. r = ath9k_hw_reset(ah, init_channel, ah->caldata, false);
  929. if (r) {
  930. ath_err(common,
  931. "Unable to reset hardware; reset status %d (freq %u MHz)\n",
  932. r, curchan->center_freq);
  933. spin_unlock_bh(&sc->sc_pcu_lock);
  934. goto mutex_unlock;
  935. }
  936. /*
  937. * This is needed only to setup initial state
  938. * but it's best done after a reset.
  939. */
  940. ath_update_txpow(sc);
  941. /*
  942. * Setup the hardware after reset:
  943. * The receive engine is set going.
  944. * Frame transmit is handled entirely
  945. * in the frame output path; there's nothing to do
  946. * here except setup the interrupt mask.
  947. */
  948. if (ath_startrecv(sc) != 0) {
  949. ath_err(common, "Unable to start recv logic\n");
  950. r = -EIO;
  951. spin_unlock_bh(&sc->sc_pcu_lock);
  952. goto mutex_unlock;
  953. }
  954. spin_unlock_bh(&sc->sc_pcu_lock);
  955. /* Setup our intr mask. */
  956. ah->imask = ATH9K_INT_TX | ATH9K_INT_RXEOL |
  957. ATH9K_INT_RXORN | ATH9K_INT_FATAL |
  958. ATH9K_INT_GLOBAL;
  959. if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
  960. ah->imask |= ATH9K_INT_RXHP |
  961. ATH9K_INT_RXLP |
  962. ATH9K_INT_BB_WATCHDOG;
  963. else
  964. ah->imask |= ATH9K_INT_RX;
  965. ah->imask |= ATH9K_INT_GTT;
  966. if (ah->caps.hw_caps & ATH9K_HW_CAP_HT)
  967. ah->imask |= ATH9K_INT_CST;
  968. sc->sc_flags &= ~SC_OP_INVALID;
  969. sc->sc_ah->is_monitoring = false;
  970. /* Disable BMISS interrupt when we're not associated */
  971. ah->imask &= ~(ATH9K_INT_SWBA | ATH9K_INT_BMISS);
  972. ath9k_hw_set_interrupts(ah, ah->imask);
  973. ieee80211_wake_queues(hw);
  974. ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 0);
  975. if ((ah->btcoex_hw.scheme != ATH_BTCOEX_CFG_NONE) &&
  976. !ah->btcoex_hw.enabled) {
  977. ath9k_hw_btcoex_set_weight(ah, AR_BT_COEX_WGHT,
  978. AR_STOMP_LOW_WLAN_WGHT);
  979. ath9k_hw_btcoex_enable(ah);
  980. if (common->bus_ops->bt_coex_prep)
  981. common->bus_ops->bt_coex_prep(common);
  982. if (ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE)
  983. ath9k_btcoex_timer_resume(sc);
  984. }
  985. /* User has the option to provide pm-qos value as a module
  986. * parameter rather than using the default value of
  987. * 'ATH9K_PM_QOS_DEFAULT_VALUE'.
  988. */
  989. pm_qos_update_request(&sc->pm_qos_req, ath9k_pm_qos_value);
  990. if (ah->caps.pcie_lcr_extsync_en && common->bus_ops->extn_synch_en)
  991. common->bus_ops->extn_synch_en(common);
  992. mutex_unlock:
  993. mutex_unlock(&sc->mutex);
  994. return r;
  995. }
  996. static int ath9k_tx(struct ieee80211_hw *hw,
  997. struct sk_buff *skb)
  998. {
  999. struct ath_wiphy *aphy = hw->priv;
  1000. struct ath_softc *sc = aphy->sc;
  1001. struct ath_common *common = ath9k_hw_common(sc->sc_ah);
  1002. struct ath_tx_control txctl;
  1003. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
  1004. if (aphy->state != ATH_WIPHY_ACTIVE && aphy->state != ATH_WIPHY_SCAN) {
  1005. ath_dbg(common, ATH_DBG_XMIT,
  1006. "ath9k: %s: TX in unexpected wiphy state %d\n",
  1007. wiphy_name(hw->wiphy), aphy->state);
  1008. goto exit;
  1009. }
  1010. if (sc->ps_enabled) {
  1011. /*
  1012. * mac80211 does not set PM field for normal data frames, so we
  1013. * need to update that based on the current PS mode.
  1014. */
  1015. if (ieee80211_is_data(hdr->frame_control) &&
  1016. !ieee80211_is_nullfunc(hdr->frame_control) &&
  1017. !ieee80211_has_pm(hdr->frame_control)) {
  1018. ath_dbg(common, ATH_DBG_PS,
  1019. "Add PM=1 for a TX frame while in PS mode\n");
  1020. hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM);
  1021. }
  1022. }
  1023. if (unlikely(sc->sc_ah->power_mode != ATH9K_PM_AWAKE)) {
  1024. /*
  1025. * We are using PS-Poll and mac80211 can request TX while in
  1026. * power save mode. Need to wake up hardware for the TX to be
  1027. * completed and if needed, also for RX of buffered frames.
  1028. */
  1029. ath9k_ps_wakeup(sc);
  1030. if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_AUTOSLEEP))
  1031. ath9k_hw_setrxabort(sc->sc_ah, 0);
  1032. if (ieee80211_is_pspoll(hdr->frame_control)) {
  1033. ath_dbg(common, ATH_DBG_PS,
  1034. "Sending PS-Poll to pick a buffered frame\n");
  1035. sc->ps_flags |= PS_WAIT_FOR_PSPOLL_DATA;
  1036. } else {
  1037. ath_dbg(common, ATH_DBG_PS,
  1038. "Wake up to complete TX\n");
  1039. sc->ps_flags |= PS_WAIT_FOR_TX_ACK;
  1040. }
  1041. /*
  1042. * The actual restore operation will happen only after
  1043. * the sc_flags bit is cleared. We are just dropping
  1044. * the ps_usecount here.
  1045. */
  1046. ath9k_ps_restore(sc);
  1047. }
  1048. memset(&txctl, 0, sizeof(struct ath_tx_control));
  1049. txctl.txq = sc->tx.txq_map[skb_get_queue_mapping(skb)];
  1050. ath_dbg(common, ATH_DBG_XMIT, "transmitting packet, skb: %p\n", skb);
  1051. if (ath_tx_start(hw, skb, &txctl) != 0) {
  1052. ath_dbg(common, ATH_DBG_XMIT, "TX failed\n");
  1053. goto exit;
  1054. }
  1055. return 0;
  1056. exit:
  1057. dev_kfree_skb_any(skb);
  1058. return 0;
  1059. }
  1060. static void ath9k_stop(struct ieee80211_hw *hw)
  1061. {
  1062. struct ath_wiphy *aphy = hw->priv;
  1063. struct ath_softc *sc = aphy->sc;
  1064. struct ath_hw *ah = sc->sc_ah;
  1065. struct ath_common *common = ath9k_hw_common(ah);
  1066. int i;
  1067. mutex_lock(&sc->mutex);
  1068. aphy->state = ATH_WIPHY_INACTIVE;
  1069. if (led_blink)
  1070. cancel_delayed_work_sync(&sc->ath_led_blink_work);
  1071. cancel_delayed_work_sync(&sc->tx_complete_work);
  1072. cancel_work_sync(&sc->paprd_work);
  1073. cancel_work_sync(&sc->hw_check_work);
  1074. for (i = 0; i < sc->num_sec_wiphy; i++) {
  1075. if (sc->sec_wiphy[i])
  1076. break;
  1077. }
  1078. if (i == sc->num_sec_wiphy) {
  1079. cancel_delayed_work_sync(&sc->wiphy_work);
  1080. cancel_work_sync(&sc->chan_work);
  1081. }
  1082. if (sc->sc_flags & SC_OP_INVALID) {
  1083. ath_dbg(common, ATH_DBG_ANY, "Device not present\n");
  1084. mutex_unlock(&sc->mutex);
  1085. return;
  1086. }
  1087. if (ath9k_wiphy_started(sc)) {
  1088. mutex_unlock(&sc->mutex);
  1089. return; /* another wiphy still in use */
  1090. }
  1091. /* Ensure HW is awake when we try to shut it down. */
  1092. ath9k_ps_wakeup(sc);
  1093. if (ah->btcoex_hw.enabled) {
  1094. ath9k_hw_btcoex_disable(ah);
  1095. if (ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE)
  1096. ath9k_btcoex_timer_pause(sc);
  1097. }
  1098. spin_lock_bh(&sc->sc_pcu_lock);
  1099. /* make sure h/w will not generate any interrupt
  1100. * before setting the invalid flag. */
  1101. ath9k_hw_disable_interrupts(ah);
  1102. if (!(sc->sc_flags & SC_OP_INVALID)) {
  1103. ath_drain_all_txq(sc, false);
  1104. ath_stoprecv(sc);
  1105. ath9k_hw_phy_disable(ah);
  1106. } else
  1107. sc->rx.rxlink = NULL;
  1108. /* disable HAL and put h/w to sleep */
  1109. ath9k_hw_disable(ah);
  1110. ath9k_hw_configpcipowersave(ah, 1, 1);
  1111. spin_unlock_bh(&sc->sc_pcu_lock);
  1112. ath9k_ps_restore(sc);
  1113. sc->ps_idle = true;
  1114. ath9k_set_wiphy_idle(aphy, true);
  1115. ath_radio_disable(sc, hw);
  1116. sc->sc_flags |= SC_OP_INVALID;
  1117. pm_qos_update_request(&sc->pm_qos_req, PM_QOS_DEFAULT_VALUE);
  1118. mutex_unlock(&sc->mutex);
  1119. ath_dbg(common, ATH_DBG_CONFIG, "Driver halt\n");
  1120. }
  1121. bool ath9k_uses_beacons(int type)
  1122. {
  1123. switch (type) {
  1124. case NL80211_IFTYPE_AP:
  1125. case NL80211_IFTYPE_ADHOC:
  1126. case NL80211_IFTYPE_MESH_POINT:
  1127. return true;
  1128. default:
  1129. return false;
  1130. }
  1131. }
  1132. static void ath9k_reclaim_beacon(struct ath_softc *sc,
  1133. struct ieee80211_vif *vif)
  1134. {
  1135. struct ath_vif *avp = (void *)vif->drv_priv;
  1136. /* Disable SWBA interrupt */
  1137. sc->sc_ah->imask &= ~ATH9K_INT_SWBA;
  1138. ath9k_ps_wakeup(sc);
  1139. ath9k_hw_set_interrupts(sc->sc_ah, sc->sc_ah->imask);
  1140. ath9k_hw_stoptxdma(sc->sc_ah, sc->beacon.beaconq);
  1141. tasklet_kill(&sc->bcon_tasklet);
  1142. ath9k_ps_restore(sc);
  1143. ath_beacon_return(sc, avp);
  1144. sc->sc_flags &= ~SC_OP_BEACONS;
  1145. if (sc->nbcnvifs > 0) {
  1146. /* Re-enable beaconing */
  1147. sc->sc_ah->imask |= ATH9K_INT_SWBA;
  1148. ath9k_ps_wakeup(sc);
  1149. ath9k_hw_set_interrupts(sc->sc_ah, sc->sc_ah->imask);
  1150. ath9k_ps_restore(sc);
  1151. }
  1152. }
  1153. static void ath9k_vif_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
  1154. {
  1155. struct ath9k_vif_iter_data *iter_data = data;
  1156. int i;
  1157. if (iter_data->hw_macaddr)
  1158. for (i = 0; i < ETH_ALEN; i++)
  1159. iter_data->mask[i] &=
  1160. ~(iter_data->hw_macaddr[i] ^ mac[i]);
  1161. switch (vif->type) {
  1162. case NL80211_IFTYPE_AP:
  1163. iter_data->naps++;
  1164. break;
  1165. case NL80211_IFTYPE_STATION:
  1166. iter_data->nstations++;
  1167. break;
  1168. case NL80211_IFTYPE_ADHOC:
  1169. iter_data->nadhocs++;
  1170. break;
  1171. case NL80211_IFTYPE_MESH_POINT:
  1172. iter_data->nmeshes++;
  1173. break;
  1174. case NL80211_IFTYPE_WDS:
  1175. iter_data->nwds++;
  1176. break;
  1177. default:
  1178. iter_data->nothers++;
  1179. break;
  1180. }
  1181. }
  1182. /* Called with sc->mutex held. */
  1183. void ath9k_calculate_iter_data(struct ieee80211_hw *hw,
  1184. struct ieee80211_vif *vif,
  1185. struct ath9k_vif_iter_data *iter_data)
  1186. {
  1187. struct ath_wiphy *aphy = hw->priv;
  1188. struct ath_softc *sc = aphy->sc;
  1189. struct ath_hw *ah = sc->sc_ah;
  1190. struct ath_common *common = ath9k_hw_common(ah);
  1191. int i;
  1192. /*
  1193. * Use the hardware MAC address as reference, the hardware uses it
  1194. * together with the BSSID mask when matching addresses.
  1195. */
  1196. memset(iter_data, 0, sizeof(*iter_data));
  1197. iter_data->hw_macaddr = common->macaddr;
  1198. memset(&iter_data->mask, 0xff, ETH_ALEN);
  1199. if (vif)
  1200. ath9k_vif_iter(iter_data, vif->addr, vif);
  1201. /* Get list of all active MAC addresses */
  1202. spin_lock_bh(&sc->wiphy_lock);
  1203. ieee80211_iterate_active_interfaces_atomic(sc->hw, ath9k_vif_iter,
  1204. iter_data);
  1205. for (i = 0; i < sc->num_sec_wiphy; i++) {
  1206. if (sc->sec_wiphy[i] == NULL)
  1207. continue;
  1208. ieee80211_iterate_active_interfaces_atomic(
  1209. sc->sec_wiphy[i]->hw, ath9k_vif_iter, iter_data);
  1210. }
  1211. spin_unlock_bh(&sc->wiphy_lock);
  1212. }
  1213. /* Called with sc->mutex held. */
  1214. static void ath9k_calculate_summary_state(struct ieee80211_hw *hw,
  1215. struct ieee80211_vif *vif)
  1216. {
  1217. struct ath_wiphy *aphy = hw->priv;
  1218. struct ath_softc *sc = aphy->sc;
  1219. struct ath_hw *ah = sc->sc_ah;
  1220. struct ath_common *common = ath9k_hw_common(ah);
  1221. struct ath9k_vif_iter_data iter_data;
  1222. ath9k_calculate_iter_data(hw, vif, &iter_data);
  1223. /* Set BSSID mask. */
  1224. memcpy(common->bssidmask, iter_data.mask, ETH_ALEN);
  1225. ath_hw_setbssidmask(common);
  1226. /* Set op-mode & TSF */
  1227. if (iter_data.naps > 0) {
  1228. ath9k_hw_set_tsfadjust(ah, 1);
  1229. sc->sc_flags |= SC_OP_TSF_RESET;
  1230. ah->opmode = NL80211_IFTYPE_AP;
  1231. } else {
  1232. ath9k_hw_set_tsfadjust(ah, 0);
  1233. sc->sc_flags &= ~SC_OP_TSF_RESET;
  1234. if (iter_data.nwds + iter_data.nmeshes)
  1235. ah->opmode = NL80211_IFTYPE_AP;
  1236. else if (iter_data.nadhocs)
  1237. ah->opmode = NL80211_IFTYPE_ADHOC;
  1238. else
  1239. ah->opmode = NL80211_IFTYPE_STATION;
  1240. }
  1241. /*
  1242. * Enable MIB interrupts when there are hardware phy counters.
  1243. */
  1244. if ((iter_data.nstations + iter_data.nadhocs + iter_data.nmeshes) > 0) {
  1245. if (ah->config.enable_ani)
  1246. ah->imask |= ATH9K_INT_MIB;
  1247. ah->imask |= ATH9K_INT_TSFOOR;
  1248. } else {
  1249. ah->imask &= ~ATH9K_INT_MIB;
  1250. ah->imask &= ~ATH9K_INT_TSFOOR;
  1251. }
  1252. ath9k_hw_set_interrupts(ah, ah->imask);
  1253. /* Set up ANI */
  1254. if ((iter_data.naps + iter_data.nadhocs) > 0) {
  1255. sc->sc_flags |= SC_OP_ANI_RUN;
  1256. ath_start_ani(common);
  1257. } else {
  1258. sc->sc_flags &= ~SC_OP_ANI_RUN;
  1259. del_timer_sync(&common->ani.timer);
  1260. }
  1261. }
  1262. /* Called with sc->mutex held, vif counts set up properly. */
  1263. static void ath9k_do_vif_add_setup(struct ieee80211_hw *hw,
  1264. struct ieee80211_vif *vif)
  1265. {
  1266. struct ath_wiphy *aphy = hw->priv;
  1267. struct ath_softc *sc = aphy->sc;
  1268. ath9k_calculate_summary_state(hw, vif);
  1269. if (ath9k_uses_beacons(vif->type)) {
  1270. int error;
  1271. ath9k_hw_stoptxdma(sc->sc_ah, sc->beacon.beaconq);
  1272. /* This may fail because upper levels do not have beacons
  1273. * properly configured yet. That's OK, we assume it
  1274. * will be properly configured and then we will be notified
  1275. * in the info_changed method and set up beacons properly
  1276. * there.
  1277. */
  1278. error = ath_beacon_alloc(aphy, vif);
  1279. if (error)
  1280. ath9k_reclaim_beacon(sc, vif);
  1281. else
  1282. ath_beacon_config(sc, vif);
  1283. }
  1284. }
  1285. static int ath9k_add_interface(struct ieee80211_hw *hw,
  1286. struct ieee80211_vif *vif)
  1287. {
  1288. struct ath_wiphy *aphy = hw->priv;
  1289. struct ath_softc *sc = aphy->sc;
  1290. struct ath_hw *ah = sc->sc_ah;
  1291. struct ath_common *common = ath9k_hw_common(ah);
  1292. struct ath_vif *avp = (void *)vif->drv_priv;
  1293. int ret = 0;
  1294. mutex_lock(&sc->mutex);
  1295. switch (vif->type) {
  1296. case NL80211_IFTYPE_STATION:
  1297. case NL80211_IFTYPE_WDS:
  1298. case NL80211_IFTYPE_ADHOC:
  1299. case NL80211_IFTYPE_AP:
  1300. case NL80211_IFTYPE_MESH_POINT:
  1301. break;
  1302. default:
  1303. ath_err(common, "Interface type %d not yet supported\n",
  1304. vif->type);
  1305. ret = -EOPNOTSUPP;
  1306. goto out;
  1307. }
  1308. if (ath9k_uses_beacons(vif->type)) {
  1309. if (sc->nbcnvifs >= ATH_BCBUF) {
  1310. ath_err(common, "Not enough beacon buffers when adding"
  1311. " new interface of type: %i\n",
  1312. vif->type);
  1313. ret = -ENOBUFS;
  1314. goto out;
  1315. }
  1316. }
  1317. if ((vif->type == NL80211_IFTYPE_ADHOC) &&
  1318. sc->nvifs > 0) {
  1319. ath_err(common, "Cannot create ADHOC interface when other"
  1320. " interfaces already exist.\n");
  1321. ret = -EINVAL;
  1322. goto out;
  1323. }
  1324. ath_dbg(common, ATH_DBG_CONFIG,
  1325. "Attach a VIF of type: %d\n", vif->type);
  1326. /* Set the VIF opmode */
  1327. avp->av_opmode = vif->type;
  1328. avp->av_bslot = -1;
  1329. sc->nvifs++;
  1330. ath9k_do_vif_add_setup(hw, vif);
  1331. out:
  1332. mutex_unlock(&sc->mutex);
  1333. return ret;
  1334. }
  1335. static int ath9k_change_interface(struct ieee80211_hw *hw,
  1336. struct ieee80211_vif *vif,
  1337. enum nl80211_iftype new_type,
  1338. bool p2p)
  1339. {
  1340. struct ath_wiphy *aphy = hw->priv;
  1341. struct ath_softc *sc = aphy->sc;
  1342. struct ath_common *common = ath9k_hw_common(sc->sc_ah);
  1343. int ret = 0;
  1344. ath_dbg(common, ATH_DBG_CONFIG, "Change Interface\n");
  1345. mutex_lock(&sc->mutex);
  1346. /* See if new interface type is valid. */
  1347. if ((new_type == NL80211_IFTYPE_ADHOC) &&
  1348. (sc->nvifs > 1)) {
  1349. ath_err(common, "When using ADHOC, it must be the only"
  1350. " interface.\n");
  1351. ret = -EINVAL;
  1352. goto out;
  1353. }
  1354. if (ath9k_uses_beacons(new_type) &&
  1355. !ath9k_uses_beacons(vif->type)) {
  1356. if (sc->nbcnvifs >= ATH_BCBUF) {
  1357. ath_err(common, "No beacon slot available\n");
  1358. ret = -ENOBUFS;
  1359. goto out;
  1360. }
  1361. }
  1362. /* Clean up old vif stuff */
  1363. if (ath9k_uses_beacons(vif->type))
  1364. ath9k_reclaim_beacon(sc, vif);
  1365. /* Add new settings */
  1366. vif->type = new_type;
  1367. vif->p2p = p2p;
  1368. ath9k_do_vif_add_setup(hw, vif);
  1369. out:
  1370. mutex_unlock(&sc->mutex);
  1371. return ret;
  1372. }
  1373. static void ath9k_remove_interface(struct ieee80211_hw *hw,
  1374. struct ieee80211_vif *vif)
  1375. {
  1376. struct ath_wiphy *aphy = hw->priv;
  1377. struct ath_softc *sc = aphy->sc;
  1378. struct ath_common *common = ath9k_hw_common(sc->sc_ah);
  1379. ath_dbg(common, ATH_DBG_CONFIG, "Detach Interface\n");
  1380. mutex_lock(&sc->mutex);
  1381. sc->nvifs--;
  1382. /* Reclaim beacon resources */
  1383. if (ath9k_uses_beacons(vif->type))
  1384. ath9k_reclaim_beacon(sc, vif);
  1385. ath9k_calculate_summary_state(hw, NULL);
  1386. mutex_unlock(&sc->mutex);
  1387. }
  1388. static void ath9k_enable_ps(struct ath_softc *sc)
  1389. {
  1390. struct ath_hw *ah = sc->sc_ah;
  1391. sc->ps_enabled = true;
  1392. if (!(ah->caps.hw_caps & ATH9K_HW_CAP_AUTOSLEEP)) {
  1393. if ((ah->imask & ATH9K_INT_TIM_TIMER) == 0) {
  1394. ah->imask |= ATH9K_INT_TIM_TIMER;
  1395. ath9k_hw_set_interrupts(ah, ah->imask);
  1396. }
  1397. ath9k_hw_setrxabort(ah, 1);
  1398. }
  1399. }
  1400. static void ath9k_disable_ps(struct ath_softc *sc)
  1401. {
  1402. struct ath_hw *ah = sc->sc_ah;
  1403. sc->ps_enabled = false;
  1404. ath9k_hw_setpower(ah, ATH9K_PM_AWAKE);
  1405. if (!(ah->caps.hw_caps & ATH9K_HW_CAP_AUTOSLEEP)) {
  1406. ath9k_hw_setrxabort(ah, 0);
  1407. sc->ps_flags &= ~(PS_WAIT_FOR_BEACON |
  1408. PS_WAIT_FOR_CAB |
  1409. PS_WAIT_FOR_PSPOLL_DATA |
  1410. PS_WAIT_FOR_TX_ACK);
  1411. if (ah->imask & ATH9K_INT_TIM_TIMER) {
  1412. ah->imask &= ~ATH9K_INT_TIM_TIMER;
  1413. ath9k_hw_set_interrupts(ah, ah->imask);
  1414. }
  1415. }
  1416. }
  1417. static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
  1418. {
  1419. struct ath_wiphy *aphy = hw->priv;
  1420. struct ath_softc *sc = aphy->sc;
  1421. struct ath_hw *ah = sc->sc_ah;
  1422. struct ath_common *common = ath9k_hw_common(ah);
  1423. struct ieee80211_conf *conf = &hw->conf;
  1424. bool disable_radio;
  1425. mutex_lock(&sc->mutex);
  1426. /*
  1427. * Leave this as the first check because we need to turn on the
  1428. * radio if it was disabled before prior to processing the rest
  1429. * of the changes. Likewise we must only disable the radio towards
  1430. * the end.
  1431. */
  1432. if (changed & IEEE80211_CONF_CHANGE_IDLE) {
  1433. bool enable_radio;
  1434. bool all_wiphys_idle;
  1435. bool idle = !!(conf->flags & IEEE80211_CONF_IDLE);
  1436. spin_lock_bh(&sc->wiphy_lock);
  1437. all_wiphys_idle = ath9k_all_wiphys_idle(sc);
  1438. ath9k_set_wiphy_idle(aphy, idle);
  1439. enable_radio = (!idle && all_wiphys_idle);
  1440. /*
  1441. * After we unlock here its possible another wiphy
  1442. * can be re-renabled so to account for that we will
  1443. * only disable the radio toward the end of this routine
  1444. * if by then all wiphys are still idle.
  1445. */
  1446. spin_unlock_bh(&sc->wiphy_lock);
  1447. if (enable_radio) {
  1448. sc->ps_idle = false;
  1449. ath_radio_enable(sc, hw);
  1450. ath_dbg(common, ATH_DBG_CONFIG,
  1451. "not-idle: enabling radio\n");
  1452. }
  1453. }
  1454. /*
  1455. * We just prepare to enable PS. We have to wait until our AP has
  1456. * ACK'd our null data frame to disable RX otherwise we'll ignore
  1457. * those ACKs and end up retransmitting the same null data frames.
  1458. * IEEE80211_CONF_CHANGE_PS is only passed by mac80211 for STA mode.
  1459. */
  1460. if (changed & IEEE80211_CONF_CHANGE_PS) {
  1461. unsigned long flags;
  1462. spin_lock_irqsave(&sc->sc_pm_lock, flags);
  1463. if (conf->flags & IEEE80211_CONF_PS)
  1464. ath9k_enable_ps(sc);
  1465. else
  1466. ath9k_disable_ps(sc);
  1467. spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
  1468. }
  1469. if (changed & IEEE80211_CONF_CHANGE_MONITOR) {
  1470. if (conf->flags & IEEE80211_CONF_MONITOR) {
  1471. ath_dbg(common, ATH_DBG_CONFIG,
  1472. "Monitor mode is enabled\n");
  1473. sc->sc_ah->is_monitoring = true;
  1474. } else {
  1475. ath_dbg(common, ATH_DBG_CONFIG,
  1476. "Monitor mode is disabled\n");
  1477. sc->sc_ah->is_monitoring = false;
  1478. }
  1479. }
  1480. if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
  1481. struct ieee80211_channel *curchan = hw->conf.channel;
  1482. int pos = curchan->hw_value;
  1483. int old_pos = -1;
  1484. unsigned long flags;
  1485. if (ah->curchan)
  1486. old_pos = ah->curchan - &ah->channels[0];
  1487. aphy->chan_idx = pos;
  1488. aphy->chan_is_ht = conf_is_ht(conf);
  1489. if (hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)
  1490. sc->sc_flags |= SC_OP_OFFCHANNEL;
  1491. else
  1492. sc->sc_flags &= ~SC_OP_OFFCHANNEL;
  1493. if (aphy->state == ATH_WIPHY_SCAN ||
  1494. aphy->state == ATH_WIPHY_ACTIVE)
  1495. ath9k_wiphy_pause_all_forced(sc, aphy);
  1496. else {
  1497. /*
  1498. * Do not change operational channel based on a paused
  1499. * wiphy changes.
  1500. */
  1501. goto skip_chan_change;
  1502. }
  1503. ath_dbg(common, ATH_DBG_CONFIG, "Set channel: %d MHz\n",
  1504. curchan->center_freq);
  1505. /* XXX: remove me eventualy */
  1506. ath9k_update_ichannel(sc, hw, &sc->sc_ah->channels[pos]);
  1507. /* update survey stats for the old channel before switching */
  1508. spin_lock_irqsave(&common->cc_lock, flags);
  1509. ath_update_survey_stats(sc);
  1510. spin_unlock_irqrestore(&common->cc_lock, flags);
  1511. /*
  1512. * If the operating channel changes, change the survey in-use flags
  1513. * along with it.
  1514. * Reset the survey data for the new channel, unless we're switching
  1515. * back to the operating channel from an off-channel operation.
  1516. */
  1517. if (!(hw->conf.flags & IEEE80211_CONF_OFFCHANNEL) &&
  1518. sc->cur_survey != &sc->survey[pos]) {
  1519. if (sc->cur_survey)
  1520. sc->cur_survey->filled &= ~SURVEY_INFO_IN_USE;
  1521. sc->cur_survey = &sc->survey[pos];
  1522. memset(sc->cur_survey, 0, sizeof(struct survey_info));
  1523. sc->cur_survey->filled |= SURVEY_INFO_IN_USE;
  1524. } else if (!(sc->survey[pos].filled & SURVEY_INFO_IN_USE)) {
  1525. memset(&sc->survey[pos], 0, sizeof(struct survey_info));
  1526. }
  1527. if (ath_set_channel(sc, hw, &sc->sc_ah->channels[pos]) < 0) {
  1528. ath_err(common, "Unable to set channel\n");
  1529. mutex_unlock(&sc->mutex);
  1530. return -EINVAL;
  1531. }
  1532. /*
  1533. * The most recent snapshot of channel->noisefloor for the old
  1534. * channel is only available after the hardware reset. Copy it to
  1535. * the survey stats now.
  1536. */
  1537. if (old_pos >= 0)
  1538. ath_update_survey_nf(sc, old_pos);
  1539. }
  1540. skip_chan_change:
  1541. if (changed & IEEE80211_CONF_CHANGE_POWER) {
  1542. sc->config.txpowlimit = 2 * conf->power_level;
  1543. ath_update_txpow(sc);
  1544. }
  1545. spin_lock_bh(&sc->wiphy_lock);
  1546. disable_radio = ath9k_all_wiphys_idle(sc);
  1547. spin_unlock_bh(&sc->wiphy_lock);
  1548. if (disable_radio) {
  1549. ath_dbg(common, ATH_DBG_CONFIG, "idle: disabling radio\n");
  1550. sc->ps_idle = true;
  1551. ath_radio_disable(sc, hw);
  1552. }
  1553. mutex_unlock(&sc->mutex);
  1554. return 0;
  1555. }
  1556. #define SUPPORTED_FILTERS \
  1557. (FIF_PROMISC_IN_BSS | \
  1558. FIF_ALLMULTI | \
  1559. FIF_CONTROL | \
  1560. FIF_PSPOLL | \
  1561. FIF_OTHER_BSS | \
  1562. FIF_BCN_PRBRESP_PROMISC | \
  1563. FIF_PROBE_REQ | \
  1564. FIF_FCSFAIL)
  1565. /* FIXME: sc->sc_full_reset ? */
  1566. static void ath9k_configure_filter(struct ieee80211_hw *hw,
  1567. unsigned int changed_flags,
  1568. unsigned int *total_flags,
  1569. u64 multicast)
  1570. {
  1571. struct ath_wiphy *aphy = hw->priv;
  1572. struct ath_softc *sc = aphy->sc;
  1573. u32 rfilt;
  1574. changed_flags &= SUPPORTED_FILTERS;
  1575. *total_flags &= SUPPORTED_FILTERS;
  1576. sc->rx.rxfilter = *total_flags;
  1577. ath9k_ps_wakeup(sc);
  1578. rfilt = ath_calcrxfilter(sc);
  1579. ath9k_hw_setrxfilter(sc->sc_ah, rfilt);
  1580. ath9k_ps_restore(sc);
  1581. ath_dbg(ath9k_hw_common(sc->sc_ah), ATH_DBG_CONFIG,
  1582. "Set HW RX filter: 0x%x\n", rfilt);
  1583. }
  1584. static int ath9k_sta_add(struct ieee80211_hw *hw,
  1585. struct ieee80211_vif *vif,
  1586. struct ieee80211_sta *sta)
  1587. {
  1588. struct ath_wiphy *aphy = hw->priv;
  1589. struct ath_softc *sc = aphy->sc;
  1590. ath_node_attach(sc, sta);
  1591. return 0;
  1592. }
  1593. static int ath9k_sta_remove(struct ieee80211_hw *hw,
  1594. struct ieee80211_vif *vif,
  1595. struct ieee80211_sta *sta)
  1596. {
  1597. struct ath_wiphy *aphy = hw->priv;
  1598. struct ath_softc *sc = aphy->sc;
  1599. ath_node_detach(sc, sta);
  1600. return 0;
  1601. }
  1602. static int ath9k_conf_tx(struct ieee80211_hw *hw, u16 queue,
  1603. const struct ieee80211_tx_queue_params *params)
  1604. {
  1605. struct ath_wiphy *aphy = hw->priv;
  1606. struct ath_softc *sc = aphy->sc;
  1607. struct ath_common *common = ath9k_hw_common(sc->sc_ah);
  1608. struct ath_txq *txq;
  1609. struct ath9k_tx_queue_info qi;
  1610. int ret = 0;
  1611. if (queue >= WME_NUM_AC)
  1612. return 0;
  1613. txq = sc->tx.txq_map[queue];
  1614. mutex_lock(&sc->mutex);
  1615. memset(&qi, 0, sizeof(struct ath9k_tx_queue_info));
  1616. qi.tqi_aifs = params->aifs;
  1617. qi.tqi_cwmin = params->cw_min;
  1618. qi.tqi_cwmax = params->cw_max;
  1619. qi.tqi_burstTime = params->txop;
  1620. ath_dbg(common, ATH_DBG_CONFIG,
  1621. "Configure tx [queue/halq] [%d/%d], aifs: %d, cw_min: %d, cw_max: %d, txop: %d\n",
  1622. queue, txq->axq_qnum, params->aifs, params->cw_min,
  1623. params->cw_max, params->txop);
  1624. ret = ath_txq_update(sc, txq->axq_qnum, &qi);
  1625. if (ret)
  1626. ath_err(common, "TXQ Update failed\n");
  1627. if (sc->sc_ah->opmode == NL80211_IFTYPE_ADHOC)
  1628. if (queue == WME_AC_BE && !ret)
  1629. ath_beaconq_config(sc);
  1630. mutex_unlock(&sc->mutex);
  1631. return ret;
  1632. }
  1633. static int ath9k_set_key(struct ieee80211_hw *hw,
  1634. enum set_key_cmd cmd,
  1635. struct ieee80211_vif *vif,
  1636. struct ieee80211_sta *sta,
  1637. struct ieee80211_key_conf *key)
  1638. {
  1639. struct ath_wiphy *aphy = hw->priv;
  1640. struct ath_softc *sc = aphy->sc;
  1641. struct ath_common *common = ath9k_hw_common(sc->sc_ah);
  1642. int ret = 0;
  1643. if (ath9k_modparam_nohwcrypt)
  1644. return -ENOSPC;
  1645. mutex_lock(&sc->mutex);
  1646. ath9k_ps_wakeup(sc);
  1647. ath_dbg(common, ATH_DBG_CONFIG, "Set HW Key\n");
  1648. switch (cmd) {
  1649. case SET_KEY:
  1650. ret = ath_key_config(common, vif, sta, key);
  1651. if (ret >= 0) {
  1652. key->hw_key_idx = ret;
  1653. /* push IV and Michael MIC generation to stack */
  1654. key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
  1655. if (key->cipher == WLAN_CIPHER_SUITE_TKIP)
  1656. key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC;
  1657. if (sc->sc_ah->sw_mgmt_crypto &&
  1658. key->cipher == WLAN_CIPHER_SUITE_CCMP)
  1659. key->flags |= IEEE80211_KEY_FLAG_SW_MGMT;
  1660. ret = 0;
  1661. }
  1662. break;
  1663. case DISABLE_KEY:
  1664. ath_key_delete(common, key);
  1665. break;
  1666. default:
  1667. ret = -EINVAL;
  1668. }
  1669. ath9k_ps_restore(sc);
  1670. mutex_unlock(&sc->mutex);
  1671. return ret;
  1672. }
  1673. static void ath9k_bss_info_changed(struct ieee80211_hw *hw,
  1674. struct ieee80211_vif *vif,
  1675. struct ieee80211_bss_conf *bss_conf,
  1676. u32 changed)
  1677. {
  1678. struct ath_wiphy *aphy = hw->priv;
  1679. struct ath_softc *sc = aphy->sc;
  1680. struct ath_hw *ah = sc->sc_ah;
  1681. struct ath_common *common = ath9k_hw_common(ah);
  1682. struct ath_vif *avp = (void *)vif->drv_priv;
  1683. int slottime;
  1684. int error;
  1685. mutex_lock(&sc->mutex);
  1686. if (changed & BSS_CHANGED_BSSID) {
  1687. /* Set BSSID */
  1688. memcpy(common->curbssid, bss_conf->bssid, ETH_ALEN);
  1689. memcpy(avp->bssid, bss_conf->bssid, ETH_ALEN);
  1690. common->curaid = 0;
  1691. ath9k_hw_write_associd(ah);
  1692. /* Set aggregation protection mode parameters */
  1693. sc->config.ath_aggr_prot = 0;
  1694. ath_dbg(common, ATH_DBG_CONFIG, "BSSID: %pM aid: 0x%x\n",
  1695. common->curbssid, common->curaid);
  1696. /* need to reconfigure the beacon */
  1697. sc->sc_flags &= ~SC_OP_BEACONS ;
  1698. }
  1699. /* Enable transmission of beacons (AP, IBSS, MESH) */
  1700. if ((changed & BSS_CHANGED_BEACON) ||
  1701. ((changed & BSS_CHANGED_BEACON_ENABLED) && bss_conf->enable_beacon)) {
  1702. ath9k_hw_stoptxdma(sc->sc_ah, sc->beacon.beaconq);
  1703. error = ath_beacon_alloc(aphy, vif);
  1704. if (!error)
  1705. ath_beacon_config(sc, vif);
  1706. }
  1707. if (changed & BSS_CHANGED_ERP_SLOT) {
  1708. if (bss_conf->use_short_slot)
  1709. slottime = 9;
  1710. else
  1711. slottime = 20;
  1712. if (vif->type == NL80211_IFTYPE_AP) {
  1713. /*
  1714. * Defer update, so that connected stations can adjust
  1715. * their settings at the same time.
  1716. * See beacon.c for more details
  1717. */
  1718. sc->beacon.slottime = slottime;
  1719. sc->beacon.updateslot = UPDATE;
  1720. } else {
  1721. ah->slottime = slottime;
  1722. ath9k_hw_init_global_settings(ah);
  1723. }
  1724. }
  1725. /* Disable transmission of beacons */
  1726. if ((changed & BSS_CHANGED_BEACON_ENABLED) && !bss_conf->enable_beacon)
  1727. ath9k_hw_stoptxdma(sc->sc_ah, sc->beacon.beaconq);
  1728. if (changed & BSS_CHANGED_BEACON_INT) {
  1729. sc->beacon_interval = bss_conf->beacon_int;
  1730. /*
  1731. * In case of AP mode, the HW TSF has to be reset
  1732. * when the beacon interval changes.
  1733. */
  1734. if (vif->type == NL80211_IFTYPE_AP) {
  1735. sc->sc_flags |= SC_OP_TSF_RESET;
  1736. ath9k_hw_stoptxdma(sc->sc_ah, sc->beacon.beaconq);
  1737. error = ath_beacon_alloc(aphy, vif);
  1738. if (!error)
  1739. ath_beacon_config(sc, vif);
  1740. } else {
  1741. ath_beacon_config(sc, vif);
  1742. }
  1743. }
  1744. if (changed & BSS_CHANGED_ERP_PREAMBLE) {
  1745. ath_dbg(common, ATH_DBG_CONFIG, "BSS Changed PREAMBLE %d\n",
  1746. bss_conf->use_short_preamble);
  1747. if (bss_conf->use_short_preamble)
  1748. sc->sc_flags |= SC_OP_PREAMBLE_SHORT;
  1749. else
  1750. sc->sc_flags &= ~SC_OP_PREAMBLE_SHORT;
  1751. }
  1752. if (changed & BSS_CHANGED_ERP_CTS_PROT) {
  1753. ath_dbg(common, ATH_DBG_CONFIG, "BSS Changed CTS PROT %d\n",
  1754. bss_conf->use_cts_prot);
  1755. if (bss_conf->use_cts_prot &&
  1756. hw->conf.channel->band != IEEE80211_BAND_5GHZ)
  1757. sc->sc_flags |= SC_OP_PROTECT_ENABLE;
  1758. else
  1759. sc->sc_flags &= ~SC_OP_PROTECT_ENABLE;
  1760. }
  1761. if (changed & BSS_CHANGED_ASSOC) {
  1762. ath_dbg(common, ATH_DBG_CONFIG, "BSS Changed ASSOC %d\n",
  1763. bss_conf->assoc);
  1764. ath9k_bss_assoc_info(sc, hw, vif, bss_conf);
  1765. }
  1766. mutex_unlock(&sc->mutex);
  1767. }
  1768. static u64 ath9k_get_tsf(struct ieee80211_hw *hw)
  1769. {
  1770. u64 tsf;
  1771. struct ath_wiphy *aphy = hw->priv;
  1772. struct ath_softc *sc = aphy->sc;
  1773. mutex_lock(&sc->mutex);
  1774. ath9k_ps_wakeup(sc);
  1775. tsf = ath9k_hw_gettsf64(sc->sc_ah);
  1776. ath9k_ps_restore(sc);
  1777. mutex_unlock(&sc->mutex);
  1778. return tsf;
  1779. }
  1780. static void ath9k_set_tsf(struct ieee80211_hw *hw, u64 tsf)
  1781. {
  1782. struct ath_wiphy *aphy = hw->priv;
  1783. struct ath_softc *sc = aphy->sc;
  1784. mutex_lock(&sc->mutex);
  1785. ath9k_ps_wakeup(sc);
  1786. ath9k_hw_settsf64(sc->sc_ah, tsf);
  1787. ath9k_ps_restore(sc);
  1788. mutex_unlock(&sc->mutex);
  1789. }
  1790. static void ath9k_reset_tsf(struct ieee80211_hw *hw)
  1791. {
  1792. struct ath_wiphy *aphy = hw->priv;
  1793. struct ath_softc *sc = aphy->sc;
  1794. mutex_lock(&sc->mutex);
  1795. ath9k_ps_wakeup(sc);
  1796. ath9k_hw_reset_tsf(sc->sc_ah);
  1797. ath9k_ps_restore(sc);
  1798. mutex_unlock(&sc->mutex);
  1799. }
  1800. static int ath9k_ampdu_action(struct ieee80211_hw *hw,
  1801. struct ieee80211_vif *vif,
  1802. enum ieee80211_ampdu_mlme_action action,
  1803. struct ieee80211_sta *sta,
  1804. u16 tid, u16 *ssn, u8 buf_size)
  1805. {
  1806. struct ath_wiphy *aphy = hw->priv;
  1807. struct ath_softc *sc = aphy->sc;
  1808. int ret = 0;
  1809. local_bh_disable();
  1810. switch (action) {
  1811. case IEEE80211_AMPDU_RX_START:
  1812. if (!(sc->sc_flags & SC_OP_RXAGGR))
  1813. ret = -ENOTSUPP;
  1814. break;
  1815. case IEEE80211_AMPDU_RX_STOP:
  1816. break;
  1817. case IEEE80211_AMPDU_TX_START:
  1818. if (!(sc->sc_flags & SC_OP_TXAGGR))
  1819. return -EOPNOTSUPP;
  1820. ath9k_ps_wakeup(sc);
  1821. ret = ath_tx_aggr_start(sc, sta, tid, ssn);
  1822. if (!ret)
  1823. ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid);
  1824. ath9k_ps_restore(sc);
  1825. break;
  1826. case IEEE80211_AMPDU_TX_STOP:
  1827. ath9k_ps_wakeup(sc);
  1828. ath_tx_aggr_stop(sc, sta, tid);
  1829. ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
  1830. ath9k_ps_restore(sc);
  1831. break;
  1832. case IEEE80211_AMPDU_TX_OPERATIONAL:
  1833. ath9k_ps_wakeup(sc);
  1834. ath_tx_aggr_resume(sc, sta, tid);
  1835. ath9k_ps_restore(sc);
  1836. break;
  1837. default:
  1838. ath_err(ath9k_hw_common(sc->sc_ah), "Unknown AMPDU action\n");
  1839. }
  1840. local_bh_enable();
  1841. return ret;
  1842. }
  1843. static int ath9k_get_survey(struct ieee80211_hw *hw, int idx,
  1844. struct survey_info *survey)
  1845. {
  1846. struct ath_wiphy *aphy = hw->priv;
  1847. struct ath_softc *sc = aphy->sc;
  1848. struct ath_common *common = ath9k_hw_common(sc->sc_ah);
  1849. struct ieee80211_supported_band *sband;
  1850. struct ieee80211_channel *chan;
  1851. unsigned long flags;
  1852. int pos;
  1853. spin_lock_irqsave(&common->cc_lock, flags);
  1854. if (idx == 0)
  1855. ath_update_survey_stats(sc);
  1856. sband = hw->wiphy->bands[IEEE80211_BAND_2GHZ];
  1857. if (sband && idx >= sband->n_channels) {
  1858. idx -= sband->n_channels;
  1859. sband = NULL;
  1860. }
  1861. if (!sband)
  1862. sband = hw->wiphy->bands[IEEE80211_BAND_5GHZ];
  1863. if (!sband || idx >= sband->n_channels) {
  1864. spin_unlock_irqrestore(&common->cc_lock, flags);
  1865. return -ENOENT;
  1866. }
  1867. chan = &sband->channels[idx];
  1868. pos = chan->hw_value;
  1869. memcpy(survey, &sc->survey[pos], sizeof(*survey));
  1870. survey->channel = chan;
  1871. spin_unlock_irqrestore(&common->cc_lock, flags);
  1872. return 0;
  1873. }
  1874. static void ath9k_sw_scan_start(struct ieee80211_hw *hw)
  1875. {
  1876. struct ath_wiphy *aphy = hw->priv;
  1877. struct ath_softc *sc = aphy->sc;
  1878. mutex_lock(&sc->mutex);
  1879. if (ath9k_wiphy_scanning(sc)) {
  1880. /*
  1881. * There is a race here in mac80211 but fixing it requires
  1882. * we revisit how we handle the scan complete callback.
  1883. * After mac80211 fixes we will not have configured hardware
  1884. * to the home channel nor would we have configured the RX
  1885. * filter yet.
  1886. */
  1887. mutex_unlock(&sc->mutex);
  1888. return;
  1889. }
  1890. aphy->state = ATH_WIPHY_SCAN;
  1891. ath9k_wiphy_pause_all_forced(sc, aphy);
  1892. mutex_unlock(&sc->mutex);
  1893. }
  1894. /*
  1895. * XXX: this requires a revisit after the driver
  1896. * scan_complete gets moved to another place/removed in mac80211.
  1897. */
  1898. static void ath9k_sw_scan_complete(struct ieee80211_hw *hw)
  1899. {
  1900. struct ath_wiphy *aphy = hw->priv;
  1901. struct ath_softc *sc = aphy->sc;
  1902. mutex_lock(&sc->mutex);
  1903. aphy->state = ATH_WIPHY_ACTIVE;
  1904. mutex_unlock(&sc->mutex);
  1905. }
  1906. static void ath9k_set_coverage_class(struct ieee80211_hw *hw, u8 coverage_class)
  1907. {
  1908. struct ath_wiphy *aphy = hw->priv;
  1909. struct ath_softc *sc = aphy->sc;
  1910. struct ath_hw *ah = sc->sc_ah;
  1911. mutex_lock(&sc->mutex);
  1912. ah->coverage_class = coverage_class;
  1913. ath9k_hw_init_global_settings(ah);
  1914. mutex_unlock(&sc->mutex);
  1915. }
  1916. struct ieee80211_ops ath9k_ops = {
  1917. .tx = ath9k_tx,
  1918. .start = ath9k_start,
  1919. .stop = ath9k_stop,
  1920. .add_interface = ath9k_add_interface,
  1921. .change_interface = ath9k_change_interface,
  1922. .remove_interface = ath9k_remove_interface,
  1923. .config = ath9k_config,
  1924. .configure_filter = ath9k_configure_filter,
  1925. .sta_add = ath9k_sta_add,
  1926. .sta_remove = ath9k_sta_remove,
  1927. .conf_tx = ath9k_conf_tx,
  1928. .bss_info_changed = ath9k_bss_info_changed,
  1929. .set_key = ath9k_set_key,
  1930. .get_tsf = ath9k_get_tsf,
  1931. .set_tsf = ath9k_set_tsf,
  1932. .reset_tsf = ath9k_reset_tsf,
  1933. .ampdu_action = ath9k_ampdu_action,
  1934. .get_survey = ath9k_get_survey,
  1935. .sw_scan_start = ath9k_sw_scan_start,
  1936. .sw_scan_complete = ath9k_sw_scan_complete,
  1937. .rfkill_poll = ath9k_rfkill_poll_state,
  1938. .set_coverage_class = ath9k_set_coverage_class,
  1939. };