mac80211_if.c 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725
  1. /*
  2. * Copyright (c) 2010 Broadcom Corporation
  3. * Copyright (c) 2013 Hauke Mehrtens <hauke@hauke-m.de>
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any
  6. * purpose with or without fee is hereby granted, provided that the above
  7. * copyright notice and this permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  12. * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  14. * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  15. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16. */
  17. #define __UNDEF_NO_VERSION__
  18. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  19. #include <linux/etherdevice.h>
  20. #include <linux/sched.h>
  21. #include <linux/firmware.h>
  22. #include <linux/interrupt.h>
  23. #include <linux/module.h>
  24. #include <linux/bcma/bcma.h>
  25. #include <net/mac80211.h>
  26. #include <defs.h>
  27. #include "phy/phy_int.h"
  28. #include "d11.h"
  29. #include "channel.h"
  30. #include "scb.h"
  31. #include "pub.h"
  32. #include "ucode_loader.h"
  33. #include "mac80211_if.h"
  34. #include "main.h"
  35. #include "debug.h"
  36. #include "led.h"
  37. #define N_TX_QUEUES 4 /* #tx queues on mac80211<->driver interface */
  38. #define BRCMS_FLUSH_TIMEOUT 500 /* msec */
  39. /* Flags we support */
  40. #define MAC_FILTERS (FIF_ALLMULTI | \
  41. FIF_FCSFAIL | \
  42. FIF_CONTROL | \
  43. FIF_OTHER_BSS | \
  44. FIF_BCN_PRBRESP_PROMISC | \
  45. FIF_PSPOLL)
  46. #define CHAN2GHZ(channel, freqency, chflags) { \
  47. .band = NL80211_BAND_2GHZ, \
  48. .center_freq = (freqency), \
  49. .hw_value = (channel), \
  50. .flags = chflags, \
  51. .max_antenna_gain = 0, \
  52. .max_power = 19, \
  53. }
  54. #define CHAN5GHZ(channel, chflags) { \
  55. .band = NL80211_BAND_5GHZ, \
  56. .center_freq = 5000 + 5*(channel), \
  57. .hw_value = (channel), \
  58. .flags = chflags, \
  59. .max_antenna_gain = 0, \
  60. .max_power = 21, \
  61. }
  62. #define RATE(rate100m, _flags) { \
  63. .bitrate = (rate100m), \
  64. .flags = (_flags), \
  65. .hw_value = (rate100m / 5), \
  66. }
  67. struct firmware_hdr {
  68. __le32 offset;
  69. __le32 len;
  70. __le32 idx;
  71. };
  72. static const char * const brcms_firmwares[MAX_FW_IMAGES] = {
  73. "brcm/bcm43xx",
  74. NULL
  75. };
  76. static int n_adapters_found;
  77. MODULE_AUTHOR("Broadcom Corporation");
  78. MODULE_DESCRIPTION("Broadcom 802.11n wireless LAN driver.");
  79. MODULE_SUPPORTED_DEVICE("Broadcom 802.11n WLAN cards");
  80. MODULE_LICENSE("Dual BSD/GPL");
  81. /* This needs to be adjusted when brcms_firmwares changes */
  82. MODULE_FIRMWARE("brcm/bcm43xx-0.fw");
  83. MODULE_FIRMWARE("brcm/bcm43xx_hdr-0.fw");
  84. /* recognized BCMA Core IDs */
  85. static struct bcma_device_id brcms_coreid_table[] = {
  86. BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 17, BCMA_ANY_CLASS),
  87. BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 23, BCMA_ANY_CLASS),
  88. BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 24, BCMA_ANY_CLASS),
  89. {},
  90. };
  91. MODULE_DEVICE_TABLE(bcma, brcms_coreid_table);
  92. #if defined(CONFIG_BRCMDBG)
  93. /*
  94. * Module parameter for setting the debug message level. Available
  95. * flags are specified by the BRCM_DL_* macros in
  96. * drivers/net/wireless/brcm80211/include/defs.h.
  97. */
  98. module_param_named(debug, brcm_msg_level, uint, 0644);
  99. #endif
  100. static struct ieee80211_channel brcms_2ghz_chantable[] = {
  101. CHAN2GHZ(1, 2412, IEEE80211_CHAN_NO_HT40MINUS),
  102. CHAN2GHZ(2, 2417, IEEE80211_CHAN_NO_HT40MINUS),
  103. CHAN2GHZ(3, 2422, IEEE80211_CHAN_NO_HT40MINUS),
  104. CHAN2GHZ(4, 2427, IEEE80211_CHAN_NO_HT40MINUS),
  105. CHAN2GHZ(5, 2432, 0),
  106. CHAN2GHZ(6, 2437, 0),
  107. CHAN2GHZ(7, 2442, 0),
  108. CHAN2GHZ(8, 2447, IEEE80211_CHAN_NO_HT40PLUS),
  109. CHAN2GHZ(9, 2452, IEEE80211_CHAN_NO_HT40PLUS),
  110. CHAN2GHZ(10, 2457, IEEE80211_CHAN_NO_HT40PLUS),
  111. CHAN2GHZ(11, 2462, IEEE80211_CHAN_NO_HT40PLUS),
  112. CHAN2GHZ(12, 2467,
  113. IEEE80211_CHAN_NO_IR |
  114. IEEE80211_CHAN_NO_HT40PLUS),
  115. CHAN2GHZ(13, 2472,
  116. IEEE80211_CHAN_NO_IR |
  117. IEEE80211_CHAN_NO_HT40PLUS),
  118. CHAN2GHZ(14, 2484,
  119. IEEE80211_CHAN_NO_IR |
  120. IEEE80211_CHAN_NO_HT40PLUS | IEEE80211_CHAN_NO_HT40MINUS |
  121. IEEE80211_CHAN_NO_OFDM)
  122. };
  123. static struct ieee80211_channel brcms_5ghz_nphy_chantable[] = {
  124. /* UNII-1 */
  125. CHAN5GHZ(36, IEEE80211_CHAN_NO_HT40MINUS),
  126. CHAN5GHZ(40, IEEE80211_CHAN_NO_HT40PLUS),
  127. CHAN5GHZ(44, IEEE80211_CHAN_NO_HT40MINUS),
  128. CHAN5GHZ(48, IEEE80211_CHAN_NO_HT40PLUS),
  129. /* UNII-2 */
  130. CHAN5GHZ(52,
  131. IEEE80211_CHAN_RADAR |
  132. IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40MINUS),
  133. CHAN5GHZ(56,
  134. IEEE80211_CHAN_RADAR |
  135. IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40PLUS),
  136. CHAN5GHZ(60,
  137. IEEE80211_CHAN_RADAR |
  138. IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40MINUS),
  139. CHAN5GHZ(64,
  140. IEEE80211_CHAN_RADAR |
  141. IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40PLUS),
  142. /* MID */
  143. CHAN5GHZ(100,
  144. IEEE80211_CHAN_RADAR |
  145. IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40MINUS),
  146. CHAN5GHZ(104,
  147. IEEE80211_CHAN_RADAR |
  148. IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40PLUS),
  149. CHAN5GHZ(108,
  150. IEEE80211_CHAN_RADAR |
  151. IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40MINUS),
  152. CHAN5GHZ(112,
  153. IEEE80211_CHAN_RADAR |
  154. IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40PLUS),
  155. CHAN5GHZ(116,
  156. IEEE80211_CHAN_RADAR |
  157. IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40MINUS),
  158. CHAN5GHZ(120,
  159. IEEE80211_CHAN_RADAR |
  160. IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40PLUS),
  161. CHAN5GHZ(124,
  162. IEEE80211_CHAN_RADAR |
  163. IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40MINUS),
  164. CHAN5GHZ(128,
  165. IEEE80211_CHAN_RADAR |
  166. IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40PLUS),
  167. CHAN5GHZ(132,
  168. IEEE80211_CHAN_RADAR |
  169. IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40MINUS),
  170. CHAN5GHZ(136,
  171. IEEE80211_CHAN_RADAR |
  172. IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40PLUS),
  173. CHAN5GHZ(140,
  174. IEEE80211_CHAN_RADAR |
  175. IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40PLUS |
  176. IEEE80211_CHAN_NO_HT40MINUS),
  177. /* UNII-3 */
  178. CHAN5GHZ(149, IEEE80211_CHAN_NO_HT40MINUS),
  179. CHAN5GHZ(153, IEEE80211_CHAN_NO_HT40PLUS),
  180. CHAN5GHZ(157, IEEE80211_CHAN_NO_HT40MINUS),
  181. CHAN5GHZ(161, IEEE80211_CHAN_NO_HT40PLUS),
  182. CHAN5GHZ(165, IEEE80211_CHAN_NO_HT40PLUS | IEEE80211_CHAN_NO_HT40MINUS)
  183. };
  184. /*
  185. * The rate table is used for both 2.4G and 5G rates. The
  186. * latter being a subset as it does not support CCK rates.
  187. */
  188. static struct ieee80211_rate legacy_ratetable[] = {
  189. RATE(10, 0),
  190. RATE(20, IEEE80211_RATE_SHORT_PREAMBLE),
  191. RATE(55, IEEE80211_RATE_SHORT_PREAMBLE),
  192. RATE(110, IEEE80211_RATE_SHORT_PREAMBLE),
  193. RATE(60, 0),
  194. RATE(90, 0),
  195. RATE(120, 0),
  196. RATE(180, 0),
  197. RATE(240, 0),
  198. RATE(360, 0),
  199. RATE(480, 0),
  200. RATE(540, 0),
  201. };
  202. static const struct ieee80211_supported_band brcms_band_2GHz_nphy_template = {
  203. .band = NL80211_BAND_2GHZ,
  204. .channels = brcms_2ghz_chantable,
  205. .n_channels = ARRAY_SIZE(brcms_2ghz_chantable),
  206. .bitrates = legacy_ratetable,
  207. .n_bitrates = ARRAY_SIZE(legacy_ratetable),
  208. .ht_cap = {
  209. /* from include/linux/ieee80211.h */
  210. .cap = IEEE80211_HT_CAP_GRN_FLD |
  211. IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40,
  212. .ht_supported = true,
  213. .ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
  214. .ampdu_density = AMPDU_DEF_MPDU_DENSITY,
  215. .mcs = {
  216. /* placeholders for now */
  217. .rx_mask = {0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0},
  218. .rx_highest = cpu_to_le16(500),
  219. .tx_params = IEEE80211_HT_MCS_TX_DEFINED}
  220. }
  221. };
  222. static const struct ieee80211_supported_band brcms_band_5GHz_nphy_template = {
  223. .band = NL80211_BAND_5GHZ,
  224. .channels = brcms_5ghz_nphy_chantable,
  225. .n_channels = ARRAY_SIZE(brcms_5ghz_nphy_chantable),
  226. .bitrates = legacy_ratetable + BRCMS_LEGACY_5G_RATE_OFFSET,
  227. .n_bitrates = ARRAY_SIZE(legacy_ratetable) -
  228. BRCMS_LEGACY_5G_RATE_OFFSET,
  229. .ht_cap = {
  230. .cap = IEEE80211_HT_CAP_GRN_FLD | IEEE80211_HT_CAP_SGI_20 |
  231. IEEE80211_HT_CAP_SGI_40,
  232. .ht_supported = true,
  233. .ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
  234. .ampdu_density = AMPDU_DEF_MPDU_DENSITY,
  235. .mcs = {
  236. /* placeholders for now */
  237. .rx_mask = {0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0},
  238. .rx_highest = cpu_to_le16(500),
  239. .tx_params = IEEE80211_HT_MCS_TX_DEFINED}
  240. }
  241. };
  242. /* flags the given rate in rateset as requested */
  243. static void brcms_set_basic_rate(struct brcm_rateset *rs, u16 rate, bool is_br)
  244. {
  245. u32 i;
  246. for (i = 0; i < rs->count; i++) {
  247. if (rate != (rs->rates[i] & 0x7f))
  248. continue;
  249. if (is_br)
  250. rs->rates[i] |= BRCMS_RATE_FLAG;
  251. else
  252. rs->rates[i] &= BRCMS_RATE_MASK;
  253. return;
  254. }
  255. }
  256. /**
  257. * This function frees the WL per-device resources.
  258. *
  259. * This function frees resources owned by the WL device pointed to
  260. * by the wl parameter.
  261. *
  262. * precondition: can both be called locked and unlocked
  263. *
  264. */
  265. static void brcms_free(struct brcms_info *wl)
  266. {
  267. struct brcms_timer *t, *next;
  268. /* free ucode data */
  269. if (wl->fw.fw_cnt)
  270. brcms_ucode_data_free(&wl->ucode);
  271. if (wl->irq)
  272. free_irq(wl->irq, wl);
  273. /* kill dpc */
  274. tasklet_kill(&wl->tasklet);
  275. if (wl->pub) {
  276. brcms_debugfs_detach(wl->pub);
  277. brcms_c_module_unregister(wl->pub, "linux", wl);
  278. }
  279. /* free common resources */
  280. if (wl->wlc) {
  281. brcms_c_detach(wl->wlc);
  282. wl->wlc = NULL;
  283. wl->pub = NULL;
  284. }
  285. /* virtual interface deletion is deferred so we cannot spinwait */
  286. /* wait for all pending callbacks to complete */
  287. while (atomic_read(&wl->callbacks) > 0)
  288. schedule();
  289. /* free timers */
  290. for (t = wl->timers; t; t = next) {
  291. next = t->next;
  292. #ifdef DEBUG
  293. kfree(t->name);
  294. #endif
  295. kfree(t);
  296. }
  297. }
  298. /*
  299. * called from both kernel as from this kernel module (error flow on attach)
  300. * precondition: perimeter lock is not acquired.
  301. */
  302. static void brcms_remove(struct bcma_device *pdev)
  303. {
  304. struct ieee80211_hw *hw = bcma_get_drvdata(pdev);
  305. struct brcms_info *wl = hw->priv;
  306. if (wl->wlc) {
  307. brcms_led_unregister(wl);
  308. wiphy_rfkill_set_hw_state(wl->pub->ieee_hw->wiphy, false);
  309. wiphy_rfkill_stop_polling(wl->pub->ieee_hw->wiphy);
  310. ieee80211_unregister_hw(hw);
  311. }
  312. brcms_free(wl);
  313. bcma_set_drvdata(pdev, NULL);
  314. ieee80211_free_hw(hw);
  315. }
  316. /*
  317. * Precondition: Since this function is called in brcms_pci_probe() context,
  318. * no locking is required.
  319. */
  320. static void brcms_release_fw(struct brcms_info *wl)
  321. {
  322. int i;
  323. for (i = 0; i < MAX_FW_IMAGES; i++) {
  324. release_firmware(wl->fw.fw_bin[i]);
  325. release_firmware(wl->fw.fw_hdr[i]);
  326. }
  327. }
  328. /*
  329. * Precondition: Since this function is called in brcms_pci_probe() context,
  330. * no locking is required.
  331. */
  332. static int brcms_request_fw(struct brcms_info *wl, struct bcma_device *pdev)
  333. {
  334. int status;
  335. struct device *device = &pdev->dev;
  336. char fw_name[100];
  337. int i;
  338. memset(&wl->fw, 0, sizeof(struct brcms_firmware));
  339. for (i = 0; i < MAX_FW_IMAGES; i++) {
  340. if (brcms_firmwares[i] == NULL)
  341. break;
  342. sprintf(fw_name, "%s-%d.fw", brcms_firmwares[i],
  343. UCODE_LOADER_API_VER);
  344. status = request_firmware(&wl->fw.fw_bin[i], fw_name, device);
  345. if (status)
  346. return status;
  347. sprintf(fw_name, "%s_hdr-%d.fw", brcms_firmwares[i],
  348. UCODE_LOADER_API_VER);
  349. status = request_firmware(&wl->fw.fw_hdr[i], fw_name, device);
  350. if (status)
  351. return status;
  352. wl->fw.hdr_num_entries[i] =
  353. wl->fw.fw_hdr[i]->size / (sizeof(struct firmware_hdr));
  354. }
  355. wl->fw.fw_cnt = i;
  356. status = brcms_ucode_data_init(wl, &wl->ucode);
  357. brcms_release_fw(wl);
  358. return status;
  359. }
  360. static void brcms_ops_tx(struct ieee80211_hw *hw,
  361. struct ieee80211_tx_control *control,
  362. struct sk_buff *skb)
  363. {
  364. struct brcms_info *wl = hw->priv;
  365. struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
  366. spin_lock_bh(&wl->lock);
  367. if (!wl->pub->up) {
  368. brcms_err(wl->wlc->hw->d11core, "ops->tx called while down\n");
  369. kfree_skb(skb);
  370. goto done;
  371. }
  372. if (brcms_c_sendpkt_mac80211(wl->wlc, skb, hw))
  373. tx_info->rate_driver_data[0] = control->sta;
  374. done:
  375. spin_unlock_bh(&wl->lock);
  376. }
  377. static int brcms_ops_start(struct ieee80211_hw *hw)
  378. {
  379. struct brcms_info *wl = hw->priv;
  380. bool blocked;
  381. int err;
  382. if (!wl->ucode.bcm43xx_bomminor) {
  383. err = brcms_request_fw(wl, wl->wlc->hw->d11core);
  384. if (err)
  385. return -ENOENT;
  386. }
  387. ieee80211_wake_queues(hw);
  388. spin_lock_bh(&wl->lock);
  389. blocked = brcms_rfkill_set_hw_state(wl);
  390. spin_unlock_bh(&wl->lock);
  391. if (!blocked)
  392. wiphy_rfkill_stop_polling(wl->pub->ieee_hw->wiphy);
  393. spin_lock_bh(&wl->lock);
  394. /* avoid acknowledging frames before a non-monitor device is added */
  395. wl->mute_tx = true;
  396. if (!wl->pub->up)
  397. if (!blocked)
  398. err = brcms_up(wl);
  399. else
  400. err = -ERFKILL;
  401. else
  402. err = -ENODEV;
  403. spin_unlock_bh(&wl->lock);
  404. if (err != 0)
  405. brcms_err(wl->wlc->hw->d11core, "%s: brcms_up() returned %d\n",
  406. __func__, err);
  407. bcma_core_pci_power_save(wl->wlc->hw->d11core->bus, true);
  408. return err;
  409. }
  410. static void brcms_ops_stop(struct ieee80211_hw *hw)
  411. {
  412. struct brcms_info *wl = hw->priv;
  413. int status;
  414. ieee80211_stop_queues(hw);
  415. if (wl->wlc == NULL)
  416. return;
  417. spin_lock_bh(&wl->lock);
  418. status = brcms_c_chipmatch(wl->wlc->hw->d11core);
  419. spin_unlock_bh(&wl->lock);
  420. if (!status) {
  421. brcms_err(wl->wlc->hw->d11core,
  422. "wl: brcms_ops_stop: chipmatch failed\n");
  423. return;
  424. }
  425. bcma_core_pci_power_save(wl->wlc->hw->d11core->bus, false);
  426. /* put driver in down state */
  427. spin_lock_bh(&wl->lock);
  428. brcms_down(wl);
  429. spin_unlock_bh(&wl->lock);
  430. }
  431. static int
  432. brcms_ops_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
  433. {
  434. struct brcms_info *wl = hw->priv;
  435. /* Just STA, AP and ADHOC for now */
  436. if (vif->type != NL80211_IFTYPE_STATION &&
  437. vif->type != NL80211_IFTYPE_AP &&
  438. vif->type != NL80211_IFTYPE_ADHOC) {
  439. brcms_err(wl->wlc->hw->d11core,
  440. "%s: Attempt to add type %d, only STA, AP and AdHoc for now\n",
  441. __func__, vif->type);
  442. return -EOPNOTSUPP;
  443. }
  444. spin_lock_bh(&wl->lock);
  445. wl->wlc->vif = vif;
  446. wl->mute_tx = false;
  447. brcms_c_mute(wl->wlc, false);
  448. if (vif->type == NL80211_IFTYPE_STATION)
  449. brcms_c_start_station(wl->wlc, vif->addr);
  450. else if (vif->type == NL80211_IFTYPE_AP)
  451. brcms_c_start_ap(wl->wlc, vif->addr, vif->bss_conf.bssid,
  452. vif->bss_conf.ssid, vif->bss_conf.ssid_len);
  453. else if (vif->type == NL80211_IFTYPE_ADHOC)
  454. brcms_c_start_adhoc(wl->wlc, vif->addr);
  455. spin_unlock_bh(&wl->lock);
  456. return 0;
  457. }
  458. static void
  459. brcms_ops_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
  460. {
  461. struct brcms_info *wl = hw->priv;
  462. spin_lock_bh(&wl->lock);
  463. wl->wlc->vif = NULL;
  464. spin_unlock_bh(&wl->lock);
  465. }
  466. static int brcms_ops_config(struct ieee80211_hw *hw, u32 changed)
  467. {
  468. struct ieee80211_conf *conf = &hw->conf;
  469. struct brcms_info *wl = hw->priv;
  470. struct bcma_device *core = wl->wlc->hw->d11core;
  471. int err = 0;
  472. int new_int;
  473. spin_lock_bh(&wl->lock);
  474. if (changed & IEEE80211_CONF_CHANGE_LISTEN_INTERVAL) {
  475. brcms_c_set_beacon_listen_interval(wl->wlc,
  476. conf->listen_interval);
  477. }
  478. if (changed & IEEE80211_CONF_CHANGE_MONITOR)
  479. brcms_dbg_info(core, "%s: change monitor mode: %s\n",
  480. __func__, conf->flags & IEEE80211_CONF_MONITOR ?
  481. "true" : "false");
  482. if (changed & IEEE80211_CONF_CHANGE_PS)
  483. brcms_err(core, "%s: change power-save mode: %s (implement)\n",
  484. __func__, conf->flags & IEEE80211_CONF_PS ?
  485. "true" : "false");
  486. if (changed & IEEE80211_CONF_CHANGE_POWER) {
  487. err = brcms_c_set_tx_power(wl->wlc, conf->power_level);
  488. if (err < 0) {
  489. brcms_err(core, "%s: Error setting power_level\n",
  490. __func__);
  491. goto config_out;
  492. }
  493. new_int = brcms_c_get_tx_power(wl->wlc);
  494. if (new_int != conf->power_level)
  495. brcms_err(core,
  496. "%s: Power level req != actual, %d %d\n",
  497. __func__, conf->power_level,
  498. new_int);
  499. }
  500. if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
  501. if (conf->chandef.width == NL80211_CHAN_WIDTH_20 ||
  502. conf->chandef.width == NL80211_CHAN_WIDTH_20_NOHT)
  503. err = brcms_c_set_channel(wl->wlc,
  504. conf->chandef.chan->hw_value);
  505. else
  506. err = -ENOTSUPP;
  507. }
  508. if (changed & IEEE80211_CONF_CHANGE_RETRY_LIMITS)
  509. err = brcms_c_set_rate_limit(wl->wlc,
  510. conf->short_frame_max_tx_count,
  511. conf->long_frame_max_tx_count);
  512. config_out:
  513. spin_unlock_bh(&wl->lock);
  514. return err;
  515. }
  516. static void
  517. brcms_ops_bss_info_changed(struct ieee80211_hw *hw,
  518. struct ieee80211_vif *vif,
  519. struct ieee80211_bss_conf *info, u32 changed)
  520. {
  521. struct brcms_info *wl = hw->priv;
  522. struct bcma_device *core = wl->wlc->hw->d11core;
  523. if (changed & BSS_CHANGED_ASSOC) {
  524. /* association status changed (associated/disassociated)
  525. * also implies a change in the AID.
  526. */
  527. brcms_err(core, "%s: %s: %sassociated\n", KBUILD_MODNAME,
  528. __func__, info->assoc ? "" : "dis");
  529. spin_lock_bh(&wl->lock);
  530. brcms_c_associate_upd(wl->wlc, info->assoc);
  531. spin_unlock_bh(&wl->lock);
  532. }
  533. if (changed & BSS_CHANGED_ERP_SLOT) {
  534. s8 val;
  535. /* slot timing changed */
  536. if (info->use_short_slot)
  537. val = 1;
  538. else
  539. val = 0;
  540. spin_lock_bh(&wl->lock);
  541. brcms_c_set_shortslot_override(wl->wlc, val);
  542. spin_unlock_bh(&wl->lock);
  543. }
  544. if (changed & BSS_CHANGED_HT) {
  545. /* 802.11n parameters changed */
  546. u16 mode = info->ht_operation_mode;
  547. spin_lock_bh(&wl->lock);
  548. brcms_c_protection_upd(wl->wlc, BRCMS_PROT_N_CFG,
  549. mode & IEEE80211_HT_OP_MODE_PROTECTION);
  550. brcms_c_protection_upd(wl->wlc, BRCMS_PROT_N_NONGF,
  551. mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT);
  552. brcms_c_protection_upd(wl->wlc, BRCMS_PROT_N_OBSS,
  553. mode & IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT);
  554. spin_unlock_bh(&wl->lock);
  555. }
  556. if (changed & BSS_CHANGED_BASIC_RATES) {
  557. struct ieee80211_supported_band *bi;
  558. u32 br_mask, i;
  559. u16 rate;
  560. struct brcm_rateset rs;
  561. int error;
  562. /* retrieve the current rates */
  563. spin_lock_bh(&wl->lock);
  564. brcms_c_get_current_rateset(wl->wlc, &rs);
  565. spin_unlock_bh(&wl->lock);
  566. br_mask = info->basic_rates;
  567. bi = hw->wiphy->bands[brcms_c_get_curband(wl->wlc)];
  568. for (i = 0; i < bi->n_bitrates; i++) {
  569. /* convert to internal rate value */
  570. rate = (bi->bitrates[i].bitrate << 1) / 10;
  571. /* set/clear basic rate flag */
  572. brcms_set_basic_rate(&rs, rate, br_mask & 1);
  573. br_mask >>= 1;
  574. }
  575. /* update the rate set */
  576. spin_lock_bh(&wl->lock);
  577. error = brcms_c_set_rateset(wl->wlc, &rs);
  578. spin_unlock_bh(&wl->lock);
  579. if (error)
  580. brcms_err(core, "changing basic rates failed: %d\n",
  581. error);
  582. }
  583. if (changed & BSS_CHANGED_BEACON_INT) {
  584. /* Beacon interval changed */
  585. spin_lock_bh(&wl->lock);
  586. brcms_c_set_beacon_period(wl->wlc, info->beacon_int);
  587. spin_unlock_bh(&wl->lock);
  588. }
  589. if (changed & BSS_CHANGED_BSSID) {
  590. /* BSSID changed, for whatever reason (IBSS and managed mode) */
  591. spin_lock_bh(&wl->lock);
  592. brcms_c_set_addrmatch(wl->wlc, RCM_BSSID_OFFSET, info->bssid);
  593. spin_unlock_bh(&wl->lock);
  594. }
  595. if (changed & BSS_CHANGED_SSID) {
  596. /* BSSID changed, for whatever reason (IBSS and managed mode) */
  597. spin_lock_bh(&wl->lock);
  598. brcms_c_set_ssid(wl->wlc, info->ssid, info->ssid_len);
  599. spin_unlock_bh(&wl->lock);
  600. }
  601. if (changed & BSS_CHANGED_BEACON) {
  602. /* Beacon data changed, retrieve new beacon (beaconing modes) */
  603. struct sk_buff *beacon;
  604. u16 tim_offset = 0;
  605. spin_lock_bh(&wl->lock);
  606. beacon = ieee80211_beacon_get_tim(hw, vif, &tim_offset, NULL);
  607. brcms_c_set_new_beacon(wl->wlc, beacon, tim_offset,
  608. info->dtim_period);
  609. spin_unlock_bh(&wl->lock);
  610. }
  611. if (changed & BSS_CHANGED_AP_PROBE_RESP) {
  612. struct sk_buff *probe_resp;
  613. spin_lock_bh(&wl->lock);
  614. probe_resp = ieee80211_proberesp_get(hw, vif);
  615. brcms_c_set_new_probe_resp(wl->wlc, probe_resp);
  616. spin_unlock_bh(&wl->lock);
  617. }
  618. if (changed & BSS_CHANGED_BEACON_ENABLED) {
  619. /* Beaconing should be enabled/disabled (beaconing modes) */
  620. brcms_err(core, "%s: Beacon enabled: %s\n", __func__,
  621. info->enable_beacon ? "true" : "false");
  622. if (info->enable_beacon &&
  623. hw->wiphy->flags & WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD) {
  624. brcms_c_enable_probe_resp(wl->wlc, true);
  625. } else {
  626. brcms_c_enable_probe_resp(wl->wlc, false);
  627. }
  628. }
  629. if (changed & BSS_CHANGED_CQM) {
  630. /* Connection quality monitor config changed */
  631. brcms_err(core, "%s: cqm change: threshold %d, hys %d "
  632. " (implement)\n", __func__, info->cqm_rssi_thold,
  633. info->cqm_rssi_hyst);
  634. }
  635. if (changed & BSS_CHANGED_IBSS) {
  636. /* IBSS join status changed */
  637. brcms_err(core, "%s: IBSS joined: %s (implement)\n",
  638. __func__, info->ibss_joined ? "true" : "false");
  639. }
  640. if (changed & BSS_CHANGED_ARP_FILTER) {
  641. /* Hardware ARP filter address list or state changed */
  642. brcms_err(core, "%s: arp filtering: %d addresses"
  643. " (implement)\n", __func__, info->arp_addr_cnt);
  644. }
  645. if (changed & BSS_CHANGED_QOS) {
  646. /*
  647. * QoS for this association was enabled/disabled.
  648. * Note that it is only ever disabled for station mode.
  649. */
  650. brcms_err(core, "%s: qos enabled: %s (implement)\n",
  651. __func__, info->qos ? "true" : "false");
  652. }
  653. return;
  654. }
  655. static void
  656. brcms_ops_configure_filter(struct ieee80211_hw *hw,
  657. unsigned int changed_flags,
  658. unsigned int *total_flags, u64 multicast)
  659. {
  660. struct brcms_info *wl = hw->priv;
  661. struct bcma_device *core = wl->wlc->hw->d11core;
  662. changed_flags &= MAC_FILTERS;
  663. *total_flags &= MAC_FILTERS;
  664. if (changed_flags & FIF_ALLMULTI)
  665. brcms_dbg_info(core, "FIF_ALLMULTI\n");
  666. if (changed_flags & FIF_FCSFAIL)
  667. brcms_dbg_info(core, "FIF_FCSFAIL\n");
  668. if (changed_flags & FIF_CONTROL)
  669. brcms_dbg_info(core, "FIF_CONTROL\n");
  670. if (changed_flags & FIF_OTHER_BSS)
  671. brcms_dbg_info(core, "FIF_OTHER_BSS\n");
  672. if (changed_flags & FIF_PSPOLL)
  673. brcms_dbg_info(core, "FIF_PSPOLL\n");
  674. if (changed_flags & FIF_BCN_PRBRESP_PROMISC)
  675. brcms_dbg_info(core, "FIF_BCN_PRBRESP_PROMISC\n");
  676. spin_lock_bh(&wl->lock);
  677. brcms_c_mac_promisc(wl->wlc, *total_flags);
  678. spin_unlock_bh(&wl->lock);
  679. return;
  680. }
  681. static void brcms_ops_sw_scan_start(struct ieee80211_hw *hw,
  682. struct ieee80211_vif *vif,
  683. const u8 *mac_addr)
  684. {
  685. struct brcms_info *wl = hw->priv;
  686. spin_lock_bh(&wl->lock);
  687. brcms_c_scan_start(wl->wlc);
  688. spin_unlock_bh(&wl->lock);
  689. return;
  690. }
  691. static void brcms_ops_sw_scan_complete(struct ieee80211_hw *hw,
  692. struct ieee80211_vif *vif)
  693. {
  694. struct brcms_info *wl = hw->priv;
  695. spin_lock_bh(&wl->lock);
  696. brcms_c_scan_stop(wl->wlc);
  697. spin_unlock_bh(&wl->lock);
  698. return;
  699. }
  700. static int
  701. brcms_ops_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u16 queue,
  702. const struct ieee80211_tx_queue_params *params)
  703. {
  704. struct brcms_info *wl = hw->priv;
  705. spin_lock_bh(&wl->lock);
  706. brcms_c_wme_setparams(wl->wlc, queue, params, true);
  707. spin_unlock_bh(&wl->lock);
  708. return 0;
  709. }
  710. static int
  711. brcms_ops_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  712. struct ieee80211_sta *sta)
  713. {
  714. struct brcms_info *wl = hw->priv;
  715. struct scb *scb = &wl->wlc->pri_scb;
  716. brcms_c_init_scb(scb);
  717. wl->pub->global_ampdu = &(scb->scb_ampdu);
  718. wl->pub->global_ampdu->scb = scb;
  719. wl->pub->global_ampdu->max_pdu = 16;
  720. /*
  721. * minstrel_ht initiates addBA on our behalf by calling
  722. * ieee80211_start_tx_ba_session()
  723. */
  724. return 0;
  725. }
  726. static int
  727. brcms_ops_ampdu_action(struct ieee80211_hw *hw,
  728. struct ieee80211_vif *vif,
  729. struct ieee80211_ampdu_params *params)
  730. {
  731. struct brcms_info *wl = hw->priv;
  732. struct scb *scb = &wl->wlc->pri_scb;
  733. int status;
  734. struct ieee80211_sta *sta = params->sta;
  735. enum ieee80211_ampdu_mlme_action action = params->action;
  736. u16 tid = params->tid;
  737. u8 buf_size = params->buf_size;
  738. if (WARN_ON(scb->magic != SCB_MAGIC))
  739. return -EIDRM;
  740. switch (action) {
  741. case IEEE80211_AMPDU_RX_START:
  742. break;
  743. case IEEE80211_AMPDU_RX_STOP:
  744. break;
  745. case IEEE80211_AMPDU_TX_START:
  746. spin_lock_bh(&wl->lock);
  747. status = brcms_c_aggregatable(wl->wlc, tid);
  748. spin_unlock_bh(&wl->lock);
  749. if (!status) {
  750. brcms_dbg_ht(wl->wlc->hw->d11core,
  751. "START: tid %d is not agg\'able\n", tid);
  752. return -EINVAL;
  753. }
  754. ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid);
  755. break;
  756. case IEEE80211_AMPDU_TX_STOP_CONT:
  757. case IEEE80211_AMPDU_TX_STOP_FLUSH:
  758. case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT:
  759. spin_lock_bh(&wl->lock);
  760. brcms_c_ampdu_flush(wl->wlc, sta, tid);
  761. spin_unlock_bh(&wl->lock);
  762. ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
  763. break;
  764. case IEEE80211_AMPDU_TX_OPERATIONAL:
  765. /*
  766. * BA window size from ADDBA response ('buf_size') defines how
  767. * many outstanding MPDUs are allowed for the BA stream by
  768. * recipient and traffic class. 'ampdu_factor' gives maximum
  769. * AMPDU size.
  770. */
  771. spin_lock_bh(&wl->lock);
  772. brcms_c_ampdu_tx_operational(wl->wlc, tid, buf_size,
  773. (1 << (IEEE80211_HT_MAX_AMPDU_FACTOR +
  774. sta->ht_cap.ampdu_factor)) - 1);
  775. spin_unlock_bh(&wl->lock);
  776. /* Power save wakeup */
  777. break;
  778. default:
  779. brcms_err(wl->wlc->hw->d11core,
  780. "%s: Invalid command, ignoring\n", __func__);
  781. }
  782. return 0;
  783. }
  784. static void brcms_ops_rfkill_poll(struct ieee80211_hw *hw)
  785. {
  786. struct brcms_info *wl = hw->priv;
  787. bool blocked;
  788. spin_lock_bh(&wl->lock);
  789. blocked = brcms_c_check_radio_disabled(wl->wlc);
  790. spin_unlock_bh(&wl->lock);
  791. wiphy_rfkill_set_hw_state(wl->pub->ieee_hw->wiphy, blocked);
  792. }
  793. static bool brcms_tx_flush_completed(struct brcms_info *wl)
  794. {
  795. bool result;
  796. spin_lock_bh(&wl->lock);
  797. result = brcms_c_tx_flush_completed(wl->wlc);
  798. spin_unlock_bh(&wl->lock);
  799. return result;
  800. }
  801. static void brcms_ops_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  802. u32 queues, bool drop)
  803. {
  804. struct brcms_info *wl = hw->priv;
  805. int ret;
  806. no_printk("%s: drop = %s\n", __func__, drop ? "true" : "false");
  807. ret = wait_event_timeout(wl->tx_flush_wq,
  808. brcms_tx_flush_completed(wl),
  809. msecs_to_jiffies(BRCMS_FLUSH_TIMEOUT));
  810. brcms_dbg_mac80211(wl->wlc->hw->d11core,
  811. "ret=%d\n", jiffies_to_msecs(ret));
  812. }
  813. static u64 brcms_ops_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
  814. {
  815. struct brcms_info *wl = hw->priv;
  816. u64 tsf;
  817. spin_lock_bh(&wl->lock);
  818. tsf = brcms_c_tsf_get(wl->wlc);
  819. spin_unlock_bh(&wl->lock);
  820. return tsf;
  821. }
  822. static void brcms_ops_set_tsf(struct ieee80211_hw *hw,
  823. struct ieee80211_vif *vif, u64 tsf)
  824. {
  825. struct brcms_info *wl = hw->priv;
  826. spin_lock_bh(&wl->lock);
  827. brcms_c_tsf_set(wl->wlc, tsf);
  828. spin_unlock_bh(&wl->lock);
  829. }
  830. static int brcms_ops_beacon_set_tim(struct ieee80211_hw *hw,
  831. struct ieee80211_sta *sta, bool set)
  832. {
  833. struct brcms_info *wl = hw->priv;
  834. struct sk_buff *beacon = NULL;
  835. u16 tim_offset = 0;
  836. spin_lock_bh(&wl->lock);
  837. if (wl->wlc->vif)
  838. beacon = ieee80211_beacon_get_tim(hw, wl->wlc->vif,
  839. &tim_offset, NULL);
  840. if (beacon)
  841. brcms_c_set_new_beacon(wl->wlc, beacon, tim_offset,
  842. wl->wlc->vif->bss_conf.dtim_period);
  843. spin_unlock_bh(&wl->lock);
  844. return 0;
  845. }
  846. static const struct ieee80211_ops brcms_ops = {
  847. .tx = brcms_ops_tx,
  848. .start = brcms_ops_start,
  849. .stop = brcms_ops_stop,
  850. .add_interface = brcms_ops_add_interface,
  851. .remove_interface = brcms_ops_remove_interface,
  852. .config = brcms_ops_config,
  853. .bss_info_changed = brcms_ops_bss_info_changed,
  854. .configure_filter = brcms_ops_configure_filter,
  855. .sw_scan_start = brcms_ops_sw_scan_start,
  856. .sw_scan_complete = brcms_ops_sw_scan_complete,
  857. .conf_tx = brcms_ops_conf_tx,
  858. .sta_add = brcms_ops_sta_add,
  859. .ampdu_action = brcms_ops_ampdu_action,
  860. .rfkill_poll = brcms_ops_rfkill_poll,
  861. .flush = brcms_ops_flush,
  862. .get_tsf = brcms_ops_get_tsf,
  863. .set_tsf = brcms_ops_set_tsf,
  864. .set_tim = brcms_ops_beacon_set_tim,
  865. };
  866. void brcms_dpc(unsigned long data)
  867. {
  868. struct brcms_info *wl;
  869. wl = (struct brcms_info *) data;
  870. spin_lock_bh(&wl->lock);
  871. /* call the common second level interrupt handler */
  872. if (wl->pub->up) {
  873. if (wl->resched) {
  874. unsigned long flags;
  875. spin_lock_irqsave(&wl->isr_lock, flags);
  876. brcms_c_intrsupd(wl->wlc);
  877. spin_unlock_irqrestore(&wl->isr_lock, flags);
  878. }
  879. wl->resched = brcms_c_dpc(wl->wlc, true);
  880. }
  881. /* brcms_c_dpc() may bring the driver down */
  882. if (!wl->pub->up)
  883. goto done;
  884. /* re-schedule dpc */
  885. if (wl->resched)
  886. tasklet_schedule(&wl->tasklet);
  887. else
  888. /* re-enable interrupts */
  889. brcms_intrson(wl);
  890. done:
  891. spin_unlock_bh(&wl->lock);
  892. wake_up(&wl->tx_flush_wq);
  893. }
  894. static irqreturn_t brcms_isr(int irq, void *dev_id)
  895. {
  896. struct brcms_info *wl;
  897. irqreturn_t ret = IRQ_NONE;
  898. wl = (struct brcms_info *) dev_id;
  899. spin_lock(&wl->isr_lock);
  900. /* call common first level interrupt handler */
  901. if (brcms_c_isr(wl->wlc)) {
  902. /* schedule second level handler */
  903. tasklet_schedule(&wl->tasklet);
  904. ret = IRQ_HANDLED;
  905. }
  906. spin_unlock(&wl->isr_lock);
  907. return ret;
  908. }
  909. /*
  910. * is called in brcms_pci_probe() context, therefore no locking required.
  911. */
  912. static int ieee_hw_rate_init(struct ieee80211_hw *hw)
  913. {
  914. struct brcms_info *wl = hw->priv;
  915. struct brcms_c_info *wlc = wl->wlc;
  916. struct ieee80211_supported_band *band;
  917. int has_5g = 0;
  918. u16 phy_type;
  919. hw->wiphy->bands[NL80211_BAND_2GHZ] = NULL;
  920. hw->wiphy->bands[NL80211_BAND_5GHZ] = NULL;
  921. phy_type = brcms_c_get_phy_type(wl->wlc, 0);
  922. if (phy_type == PHY_TYPE_N || phy_type == PHY_TYPE_LCN) {
  923. band = &wlc->bandstate[BAND_2G_INDEX]->band;
  924. *band = brcms_band_2GHz_nphy_template;
  925. if (phy_type == PHY_TYPE_LCN) {
  926. /* Single stream */
  927. band->ht_cap.mcs.rx_mask[1] = 0;
  928. band->ht_cap.mcs.rx_highest = cpu_to_le16(72);
  929. }
  930. hw->wiphy->bands[NL80211_BAND_2GHZ] = band;
  931. } else {
  932. return -EPERM;
  933. }
  934. /* Assume all bands use the same phy. True for 11n devices. */
  935. if (wl->pub->_nbands > 1) {
  936. has_5g++;
  937. if (phy_type == PHY_TYPE_N || phy_type == PHY_TYPE_LCN) {
  938. band = &wlc->bandstate[BAND_5G_INDEX]->band;
  939. *band = brcms_band_5GHz_nphy_template;
  940. hw->wiphy->bands[NL80211_BAND_5GHZ] = band;
  941. } else {
  942. return -EPERM;
  943. }
  944. }
  945. return 0;
  946. }
  947. /*
  948. * is called in brcms_pci_probe() context, therefore no locking required.
  949. */
  950. static int ieee_hw_init(struct ieee80211_hw *hw)
  951. {
  952. ieee80211_hw_set(hw, AMPDU_AGGREGATION);
  953. ieee80211_hw_set(hw, SIGNAL_DBM);
  954. ieee80211_hw_set(hw, REPORTS_TX_ACK_STATUS);
  955. hw->extra_tx_headroom = brcms_c_get_header_len();
  956. hw->queues = N_TX_QUEUES;
  957. hw->max_rates = 2; /* Primary rate and 1 fallback rate */
  958. /* channel change time is dependent on chip and band */
  959. hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
  960. BIT(NL80211_IFTYPE_AP) |
  961. BIT(NL80211_IFTYPE_ADHOC);
  962. /*
  963. * deactivate sending probe responses by ucude, because this will
  964. * cause problems when WPS is used.
  965. *
  966. * hw->wiphy->flags |= WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD;
  967. */
  968. wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_CQM_RSSI_LIST);
  969. hw->rate_control_algorithm = "minstrel_ht";
  970. hw->sta_data_size = 0;
  971. return ieee_hw_rate_init(hw);
  972. }
  973. /**
  974. * attach to the WL device.
  975. *
  976. * Attach to the WL device identified by vendor and device parameters.
  977. * regs is a host accessible memory address pointing to WL device registers.
  978. *
  979. * is called in brcms_bcma_probe() context, therefore no locking required.
  980. */
  981. static struct brcms_info *brcms_attach(struct bcma_device *pdev)
  982. {
  983. struct brcms_info *wl = NULL;
  984. int unit, err;
  985. struct ieee80211_hw *hw;
  986. u8 perm[ETH_ALEN];
  987. unit = n_adapters_found;
  988. err = 0;
  989. if (unit < 0)
  990. return NULL;
  991. /* allocate private info */
  992. hw = bcma_get_drvdata(pdev);
  993. if (hw != NULL)
  994. wl = hw->priv;
  995. if (WARN_ON(hw == NULL) || WARN_ON(wl == NULL))
  996. return NULL;
  997. wl->wiphy = hw->wiphy;
  998. atomic_set(&wl->callbacks, 0);
  999. init_waitqueue_head(&wl->tx_flush_wq);
  1000. /* setup the bottom half handler */
  1001. tasklet_init(&wl->tasklet, brcms_dpc, (unsigned long) wl);
  1002. spin_lock_init(&wl->lock);
  1003. spin_lock_init(&wl->isr_lock);
  1004. /* common load-time initialization */
  1005. wl->wlc = brcms_c_attach((void *)wl, pdev, unit, false, &err);
  1006. if (!wl->wlc) {
  1007. wiphy_err(wl->wiphy, "%s: attach() failed with code %d\n",
  1008. KBUILD_MODNAME, err);
  1009. goto fail;
  1010. }
  1011. wl->pub = brcms_c_pub(wl->wlc);
  1012. wl->pub->ieee_hw = hw;
  1013. /* register our interrupt handler */
  1014. if (request_irq(pdev->irq, brcms_isr,
  1015. IRQF_SHARED, KBUILD_MODNAME, wl)) {
  1016. wiphy_err(wl->wiphy, "wl%d: request_irq() failed\n", unit);
  1017. goto fail;
  1018. }
  1019. wl->irq = pdev->irq;
  1020. /* register module */
  1021. brcms_c_module_register(wl->pub, "linux", wl, NULL);
  1022. if (ieee_hw_init(hw)) {
  1023. wiphy_err(wl->wiphy, "wl%d: %s: ieee_hw_init failed!\n", unit,
  1024. __func__);
  1025. goto fail;
  1026. }
  1027. brcms_c_regd_init(wl->wlc);
  1028. memcpy(perm, &wl->pub->cur_etheraddr, ETH_ALEN);
  1029. if (WARN_ON(!is_valid_ether_addr(perm)))
  1030. goto fail;
  1031. SET_IEEE80211_PERM_ADDR(hw, perm);
  1032. err = ieee80211_register_hw(hw);
  1033. if (err)
  1034. wiphy_err(wl->wiphy, "%s: ieee80211_register_hw failed, status"
  1035. "%d\n", __func__, err);
  1036. if (wl->pub->srom_ccode[0] &&
  1037. regulatory_hint(wl->wiphy, wl->pub->srom_ccode))
  1038. wiphy_err(wl->wiphy, "%s: regulatory hint failed\n", __func__);
  1039. brcms_debugfs_attach(wl->pub);
  1040. brcms_debugfs_create_files(wl->pub);
  1041. n_adapters_found++;
  1042. return wl;
  1043. fail:
  1044. brcms_free(wl);
  1045. return NULL;
  1046. }
  1047. /**
  1048. * determines if a device is a WL device, and if so, attaches it.
  1049. *
  1050. * This function determines if a device pointed to by pdev is a WL device,
  1051. * and if so, performs a brcms_attach() on it.
  1052. *
  1053. * Perimeter lock is initialized in the course of this function.
  1054. */
  1055. static int brcms_bcma_probe(struct bcma_device *pdev)
  1056. {
  1057. struct brcms_info *wl;
  1058. struct ieee80211_hw *hw;
  1059. dev_info(&pdev->dev, "mfg %x core %x rev %d class %d irq %d\n",
  1060. pdev->id.manuf, pdev->id.id, pdev->id.rev, pdev->id.class,
  1061. pdev->irq);
  1062. if ((pdev->id.manuf != BCMA_MANUF_BCM) ||
  1063. (pdev->id.id != BCMA_CORE_80211))
  1064. return -ENODEV;
  1065. hw = ieee80211_alloc_hw(sizeof(struct brcms_info), &brcms_ops);
  1066. if (!hw) {
  1067. pr_err("%s: ieee80211_alloc_hw failed\n", __func__);
  1068. return -ENOMEM;
  1069. }
  1070. SET_IEEE80211_DEV(hw, &pdev->dev);
  1071. bcma_set_drvdata(pdev, hw);
  1072. memset(hw->priv, 0, sizeof(*wl));
  1073. wl = brcms_attach(pdev);
  1074. if (!wl) {
  1075. pr_err("%s: brcms_attach failed!\n", __func__);
  1076. return -ENODEV;
  1077. }
  1078. brcms_led_register(wl);
  1079. return 0;
  1080. }
  1081. static int brcms_suspend(struct bcma_device *pdev)
  1082. {
  1083. struct brcms_info *wl;
  1084. struct ieee80211_hw *hw;
  1085. hw = bcma_get_drvdata(pdev);
  1086. wl = hw->priv;
  1087. if (!wl) {
  1088. pr_err("%s: %s: no driver private struct!\n", KBUILD_MODNAME,
  1089. __func__);
  1090. return -ENODEV;
  1091. }
  1092. /* only need to flag hw is down for proper resume */
  1093. spin_lock_bh(&wl->lock);
  1094. wl->pub->hw_up = false;
  1095. spin_unlock_bh(&wl->lock);
  1096. brcms_dbg_info(wl->wlc->hw->d11core, "brcms_suspend ok\n");
  1097. return 0;
  1098. }
  1099. static int brcms_resume(struct bcma_device *pdev)
  1100. {
  1101. return 0;
  1102. }
  1103. static struct bcma_driver brcms_bcma_driver = {
  1104. .name = KBUILD_MODNAME,
  1105. .probe = brcms_bcma_probe,
  1106. .suspend = brcms_suspend,
  1107. .resume = brcms_resume,
  1108. .remove = brcms_remove,
  1109. .id_table = brcms_coreid_table,
  1110. };
  1111. /**
  1112. * This is the main entry point for the brcmsmac driver.
  1113. *
  1114. * This function is scheduled upon module initialization and
  1115. * does the driver registration, which result in brcms_bcma_probe()
  1116. * call resulting in the driver bringup.
  1117. */
  1118. static void brcms_driver_init(struct work_struct *work)
  1119. {
  1120. int error;
  1121. error = bcma_driver_register(&brcms_bcma_driver);
  1122. if (error)
  1123. pr_err("%s: register returned %d\n", __func__, error);
  1124. }
  1125. static DECLARE_WORK(brcms_driver_work, brcms_driver_init);
  1126. static int __init brcms_module_init(void)
  1127. {
  1128. brcms_debugfs_init();
  1129. if (!schedule_work(&brcms_driver_work))
  1130. return -EBUSY;
  1131. return 0;
  1132. }
  1133. /**
  1134. * This function unloads the brcmsmac driver from the system.
  1135. *
  1136. * This function unconditionally unloads the brcmsmac driver module from the
  1137. * system.
  1138. *
  1139. */
  1140. static void __exit brcms_module_exit(void)
  1141. {
  1142. cancel_work_sync(&brcms_driver_work);
  1143. bcma_driver_unregister(&brcms_bcma_driver);
  1144. brcms_debugfs_exit();
  1145. }
  1146. module_init(brcms_module_init);
  1147. module_exit(brcms_module_exit);
  1148. /*
  1149. * precondition: perimeter lock has been acquired
  1150. */
  1151. void brcms_txflowcontrol(struct brcms_info *wl, struct brcms_if *wlif,
  1152. bool state, int prio)
  1153. {
  1154. brcms_err(wl->wlc->hw->d11core, "Shouldn't be here %s\n", __func__);
  1155. }
  1156. /*
  1157. * precondition: perimeter lock has been acquired
  1158. */
  1159. void brcms_init(struct brcms_info *wl)
  1160. {
  1161. brcms_dbg_info(wl->wlc->hw->d11core, "Initializing wl%d\n",
  1162. wl->pub->unit);
  1163. brcms_reset(wl);
  1164. brcms_c_init(wl->wlc, wl->mute_tx);
  1165. }
  1166. /*
  1167. * precondition: perimeter lock has been acquired
  1168. */
  1169. uint brcms_reset(struct brcms_info *wl)
  1170. {
  1171. brcms_dbg_info(wl->wlc->hw->d11core, "Resetting wl%d\n", wl->pub->unit);
  1172. brcms_c_reset(wl->wlc);
  1173. /* dpc will not be rescheduled */
  1174. wl->resched = false;
  1175. /* inform publicly that interface is down */
  1176. wl->pub->up = false;
  1177. return 0;
  1178. }
  1179. void brcms_fatal_error(struct brcms_info *wl)
  1180. {
  1181. brcms_err(wl->wlc->hw->d11core, "wl%d: fatal error, reinitializing\n",
  1182. wl->wlc->pub->unit);
  1183. brcms_reset(wl);
  1184. ieee80211_restart_hw(wl->pub->ieee_hw);
  1185. }
  1186. /*
  1187. * These are interrupt on/off entry points. Disable interrupts
  1188. * during interrupt state transition.
  1189. */
  1190. void brcms_intrson(struct brcms_info *wl)
  1191. {
  1192. unsigned long flags;
  1193. spin_lock_irqsave(&wl->isr_lock, flags);
  1194. brcms_c_intrson(wl->wlc);
  1195. spin_unlock_irqrestore(&wl->isr_lock, flags);
  1196. }
  1197. u32 brcms_intrsoff(struct brcms_info *wl)
  1198. {
  1199. unsigned long flags;
  1200. u32 status;
  1201. spin_lock_irqsave(&wl->isr_lock, flags);
  1202. status = brcms_c_intrsoff(wl->wlc);
  1203. spin_unlock_irqrestore(&wl->isr_lock, flags);
  1204. return status;
  1205. }
  1206. void brcms_intrsrestore(struct brcms_info *wl, u32 macintmask)
  1207. {
  1208. unsigned long flags;
  1209. spin_lock_irqsave(&wl->isr_lock, flags);
  1210. brcms_c_intrsrestore(wl->wlc, macintmask);
  1211. spin_unlock_irqrestore(&wl->isr_lock, flags);
  1212. }
  1213. /*
  1214. * precondition: perimeter lock has been acquired
  1215. */
  1216. int brcms_up(struct brcms_info *wl)
  1217. {
  1218. int error = 0;
  1219. if (wl->pub->up)
  1220. return 0;
  1221. error = brcms_c_up(wl->wlc);
  1222. return error;
  1223. }
  1224. /*
  1225. * precondition: perimeter lock has been acquired
  1226. */
  1227. void brcms_down(struct brcms_info *wl)
  1228. {
  1229. uint callbacks, ret_val = 0;
  1230. /* call common down function */
  1231. ret_val = brcms_c_down(wl->wlc);
  1232. callbacks = atomic_read(&wl->callbacks) - ret_val;
  1233. /* wait for down callbacks to complete */
  1234. spin_unlock_bh(&wl->lock);
  1235. /* For HIGH_only driver, it's important to actually schedule other work,
  1236. * not just spin wait since everything runs at schedule level
  1237. */
  1238. SPINWAIT((atomic_read(&wl->callbacks) > callbacks), 100 * 1000);
  1239. spin_lock_bh(&wl->lock);
  1240. }
  1241. /*
  1242. * precondition: perimeter lock is not acquired
  1243. */
  1244. static void _brcms_timer(struct work_struct *work)
  1245. {
  1246. struct brcms_timer *t = container_of(work, struct brcms_timer,
  1247. dly_wrk.work);
  1248. spin_lock_bh(&t->wl->lock);
  1249. if (t->set) {
  1250. if (t->periodic) {
  1251. atomic_inc(&t->wl->callbacks);
  1252. ieee80211_queue_delayed_work(t->wl->pub->ieee_hw,
  1253. &t->dly_wrk,
  1254. msecs_to_jiffies(t->ms));
  1255. } else {
  1256. t->set = false;
  1257. }
  1258. t->fn(t->arg);
  1259. }
  1260. atomic_dec(&t->wl->callbacks);
  1261. spin_unlock_bh(&t->wl->lock);
  1262. }
  1263. /*
  1264. * Adds a timer to the list. Caller supplies a timer function.
  1265. * Is called from wlc.
  1266. *
  1267. * precondition: perimeter lock has been acquired
  1268. */
  1269. struct brcms_timer *brcms_init_timer(struct brcms_info *wl,
  1270. void (*fn) (void *arg),
  1271. void *arg, const char *name)
  1272. {
  1273. struct brcms_timer *t;
  1274. t = kzalloc(sizeof(struct brcms_timer), GFP_ATOMIC);
  1275. if (!t)
  1276. return NULL;
  1277. INIT_DELAYED_WORK(&t->dly_wrk, _brcms_timer);
  1278. t->wl = wl;
  1279. t->fn = fn;
  1280. t->arg = arg;
  1281. t->next = wl->timers;
  1282. wl->timers = t;
  1283. #ifdef DEBUG
  1284. t->name = kstrdup(name, GFP_ATOMIC);
  1285. #endif
  1286. return t;
  1287. }
  1288. /*
  1289. * adds only the kernel timer since it's going to be more accurate
  1290. * as well as it's easier to make it periodic
  1291. *
  1292. * precondition: perimeter lock has been acquired
  1293. */
  1294. void brcms_add_timer(struct brcms_timer *t, uint ms, int periodic)
  1295. {
  1296. struct ieee80211_hw *hw = t->wl->pub->ieee_hw;
  1297. #ifdef DEBUG
  1298. if (t->set)
  1299. brcms_dbg_info(t->wl->wlc->hw->d11core,
  1300. "%s: Already set. Name: %s, per %d\n",
  1301. __func__, t->name, periodic);
  1302. #endif
  1303. t->ms = ms;
  1304. t->periodic = (bool) periodic;
  1305. if (!t->set) {
  1306. t->set = true;
  1307. atomic_inc(&t->wl->callbacks);
  1308. }
  1309. ieee80211_queue_delayed_work(hw, &t->dly_wrk, msecs_to_jiffies(ms));
  1310. }
  1311. /*
  1312. * return true if timer successfully deleted, false if still pending
  1313. *
  1314. * precondition: perimeter lock has been acquired
  1315. */
  1316. bool brcms_del_timer(struct brcms_timer *t)
  1317. {
  1318. if (t->set) {
  1319. t->set = false;
  1320. if (!cancel_delayed_work(&t->dly_wrk))
  1321. return false;
  1322. atomic_dec(&t->wl->callbacks);
  1323. }
  1324. return true;
  1325. }
  1326. /*
  1327. * precondition: perimeter lock has been acquired
  1328. */
  1329. void brcms_free_timer(struct brcms_timer *t)
  1330. {
  1331. struct brcms_info *wl = t->wl;
  1332. struct brcms_timer *tmp;
  1333. /* delete the timer in case it is active */
  1334. brcms_del_timer(t);
  1335. if (wl->timers == t) {
  1336. wl->timers = wl->timers->next;
  1337. #ifdef DEBUG
  1338. kfree(t->name);
  1339. #endif
  1340. kfree(t);
  1341. return;
  1342. }
  1343. tmp = wl->timers;
  1344. while (tmp) {
  1345. if (tmp->next == t) {
  1346. tmp->next = t->next;
  1347. #ifdef DEBUG
  1348. kfree(t->name);
  1349. #endif
  1350. kfree(t);
  1351. return;
  1352. }
  1353. tmp = tmp->next;
  1354. }
  1355. }
  1356. /*
  1357. * precondition: no locking required
  1358. */
  1359. int brcms_ucode_init_buf(struct brcms_info *wl, void **pbuf, u32 idx)
  1360. {
  1361. int i, entry;
  1362. const u8 *pdata;
  1363. struct firmware_hdr *hdr;
  1364. for (i = 0; i < wl->fw.fw_cnt; i++) {
  1365. hdr = (struct firmware_hdr *)wl->fw.fw_hdr[i]->data;
  1366. for (entry = 0; entry < wl->fw.hdr_num_entries[i];
  1367. entry++, hdr++) {
  1368. u32 len = le32_to_cpu(hdr->len);
  1369. if (le32_to_cpu(hdr->idx) == idx) {
  1370. pdata = wl->fw.fw_bin[i]->data +
  1371. le32_to_cpu(hdr->offset);
  1372. *pbuf = kvmalloc(len, GFP_KERNEL);
  1373. if (*pbuf == NULL)
  1374. goto fail;
  1375. memcpy(*pbuf, pdata, len);
  1376. return 0;
  1377. }
  1378. }
  1379. }
  1380. brcms_err(wl->wlc->hw->d11core,
  1381. "ERROR: ucode buf tag:%d can not be found!\n", idx);
  1382. *pbuf = NULL;
  1383. fail:
  1384. return -ENODATA;
  1385. }
  1386. /*
  1387. * Precondition: Since this function is called in brcms_bcma_probe() context,
  1388. * no locking is required.
  1389. */
  1390. int brcms_ucode_init_uint(struct brcms_info *wl, size_t *n_bytes, u32 idx)
  1391. {
  1392. int i, entry;
  1393. const u8 *pdata;
  1394. struct firmware_hdr *hdr;
  1395. for (i = 0; i < wl->fw.fw_cnt; i++) {
  1396. hdr = (struct firmware_hdr *)wl->fw.fw_hdr[i]->data;
  1397. for (entry = 0; entry < wl->fw.hdr_num_entries[i];
  1398. entry++, hdr++) {
  1399. if (le32_to_cpu(hdr->idx) == idx) {
  1400. pdata = wl->fw.fw_bin[i]->data +
  1401. le32_to_cpu(hdr->offset);
  1402. if (le32_to_cpu(hdr->len) != 4) {
  1403. brcms_err(wl->wlc->hw->d11core,
  1404. "ERROR: fw hdr len\n");
  1405. return -ENOMSG;
  1406. }
  1407. *n_bytes = le32_to_cpu(*((__le32 *) pdata));
  1408. return 0;
  1409. }
  1410. }
  1411. }
  1412. brcms_err(wl->wlc->hw->d11core,
  1413. "ERROR: ucode tag:%d can not be found!\n", idx);
  1414. return -ENOMSG;
  1415. }
  1416. /*
  1417. * precondition: can both be called locked and unlocked
  1418. */
  1419. void brcms_ucode_free_buf(void *p)
  1420. {
  1421. kvfree(p);
  1422. }
  1423. /*
  1424. * checks validity of all firmware images loaded from user space
  1425. *
  1426. * Precondition: Since this function is called in brcms_bcma_probe() context,
  1427. * no locking is required.
  1428. */
  1429. int brcms_check_firmwares(struct brcms_info *wl)
  1430. {
  1431. int i;
  1432. int entry;
  1433. int rc = 0;
  1434. const struct firmware *fw;
  1435. const struct firmware *fw_hdr;
  1436. struct firmware_hdr *ucode_hdr;
  1437. for (i = 0; i < MAX_FW_IMAGES && rc == 0; i++) {
  1438. fw = wl->fw.fw_bin[i];
  1439. fw_hdr = wl->fw.fw_hdr[i];
  1440. if (fw == NULL && fw_hdr == NULL) {
  1441. break;
  1442. } else if (fw == NULL || fw_hdr == NULL) {
  1443. wiphy_err(wl->wiphy, "%s: invalid bin/hdr fw\n",
  1444. __func__);
  1445. rc = -EBADF;
  1446. } else if (fw_hdr->size % sizeof(struct firmware_hdr)) {
  1447. wiphy_err(wl->wiphy, "%s: non integral fw hdr file "
  1448. "size %zu/%zu\n", __func__, fw_hdr->size,
  1449. sizeof(struct firmware_hdr));
  1450. rc = -EBADF;
  1451. } else if (fw->size < MIN_FW_SIZE || fw->size > MAX_FW_SIZE) {
  1452. wiphy_err(wl->wiphy, "%s: out of bounds fw file size %zu\n",
  1453. __func__, fw->size);
  1454. rc = -EBADF;
  1455. } else {
  1456. /* check if ucode section overruns firmware image */
  1457. ucode_hdr = (struct firmware_hdr *)fw_hdr->data;
  1458. for (entry = 0; entry < wl->fw.hdr_num_entries[i] &&
  1459. !rc; entry++, ucode_hdr++) {
  1460. if (le32_to_cpu(ucode_hdr->offset) +
  1461. le32_to_cpu(ucode_hdr->len) >
  1462. fw->size) {
  1463. wiphy_err(wl->wiphy,
  1464. "%s: conflicting bin/hdr\n",
  1465. __func__);
  1466. rc = -EBADF;
  1467. }
  1468. }
  1469. }
  1470. }
  1471. if (rc == 0 && wl->fw.fw_cnt != i) {
  1472. wiphy_err(wl->wiphy, "%s: invalid fw_cnt=%d\n", __func__,
  1473. wl->fw.fw_cnt);
  1474. rc = -EBADF;
  1475. }
  1476. return rc;
  1477. }
  1478. /*
  1479. * precondition: perimeter lock has been acquired
  1480. */
  1481. bool brcms_rfkill_set_hw_state(struct brcms_info *wl)
  1482. {
  1483. bool blocked = brcms_c_check_radio_disabled(wl->wlc);
  1484. spin_unlock_bh(&wl->lock);
  1485. wiphy_rfkill_set_hw_state(wl->pub->ieee_hw->wiphy, blocked);
  1486. if (blocked)
  1487. wiphy_rfkill_start_polling(wl->pub->ieee_hw->wiphy);
  1488. spin_lock_bh(&wl->lock);
  1489. return blocked;
  1490. }