mac80211_if.c 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730
  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. wiphy_err(wl->wiphy, "%s: fail to load firmware %s\n",
  347. KBUILD_MODNAME, fw_name);
  348. return status;
  349. }
  350. sprintf(fw_name, "%s_hdr-%d.fw", brcms_firmwares[i],
  351. UCODE_LOADER_API_VER);
  352. status = request_firmware(&wl->fw.fw_hdr[i], fw_name, device);
  353. if (status) {
  354. wiphy_err(wl->wiphy, "%s: fail to load firmware %s\n",
  355. KBUILD_MODNAME, fw_name);
  356. return status;
  357. }
  358. wl->fw.hdr_num_entries[i] =
  359. wl->fw.fw_hdr[i]->size / (sizeof(struct firmware_hdr));
  360. }
  361. wl->fw.fw_cnt = i;
  362. status = brcms_ucode_data_init(wl, &wl->ucode);
  363. brcms_release_fw(wl);
  364. return status;
  365. }
  366. static void brcms_ops_tx(struct ieee80211_hw *hw,
  367. struct ieee80211_tx_control *control,
  368. struct sk_buff *skb)
  369. {
  370. struct brcms_info *wl = hw->priv;
  371. struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
  372. spin_lock_bh(&wl->lock);
  373. if (!wl->pub->up) {
  374. brcms_err(wl->wlc->hw->d11core, "ops->tx called while down\n");
  375. kfree_skb(skb);
  376. goto done;
  377. }
  378. if (brcms_c_sendpkt_mac80211(wl->wlc, skb, hw))
  379. tx_info->rate_driver_data[0] = control->sta;
  380. done:
  381. spin_unlock_bh(&wl->lock);
  382. }
  383. static int brcms_ops_start(struct ieee80211_hw *hw)
  384. {
  385. struct brcms_info *wl = hw->priv;
  386. bool blocked;
  387. int err;
  388. if (!wl->ucode.bcm43xx_bomminor) {
  389. err = brcms_request_fw(wl, wl->wlc->hw->d11core);
  390. if (err)
  391. return -ENOENT;
  392. }
  393. ieee80211_wake_queues(hw);
  394. spin_lock_bh(&wl->lock);
  395. blocked = brcms_rfkill_set_hw_state(wl);
  396. spin_unlock_bh(&wl->lock);
  397. if (!blocked)
  398. wiphy_rfkill_stop_polling(wl->pub->ieee_hw->wiphy);
  399. spin_lock_bh(&wl->lock);
  400. /* avoid acknowledging frames before a non-monitor device is added */
  401. wl->mute_tx = true;
  402. if (!wl->pub->up)
  403. if (!blocked)
  404. err = brcms_up(wl);
  405. else
  406. err = -ERFKILL;
  407. else
  408. err = -ENODEV;
  409. spin_unlock_bh(&wl->lock);
  410. if (err != 0)
  411. brcms_err(wl->wlc->hw->d11core, "%s: brcms_up() returned %d\n",
  412. __func__, err);
  413. bcma_core_pci_power_save(wl->wlc->hw->d11core->bus, true);
  414. return err;
  415. }
  416. static void brcms_ops_stop(struct ieee80211_hw *hw)
  417. {
  418. struct brcms_info *wl = hw->priv;
  419. int status;
  420. ieee80211_stop_queues(hw);
  421. if (wl->wlc == NULL)
  422. return;
  423. spin_lock_bh(&wl->lock);
  424. status = brcms_c_chipmatch(wl->wlc->hw->d11core);
  425. spin_unlock_bh(&wl->lock);
  426. if (!status) {
  427. brcms_err(wl->wlc->hw->d11core,
  428. "wl: brcms_ops_stop: chipmatch failed\n");
  429. return;
  430. }
  431. bcma_core_pci_power_save(wl->wlc->hw->d11core->bus, false);
  432. /* put driver in down state */
  433. spin_lock_bh(&wl->lock);
  434. brcms_down(wl);
  435. spin_unlock_bh(&wl->lock);
  436. }
  437. static int
  438. brcms_ops_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
  439. {
  440. struct brcms_info *wl = hw->priv;
  441. /* Just STA, AP and ADHOC for now */
  442. if (vif->type != NL80211_IFTYPE_STATION &&
  443. vif->type != NL80211_IFTYPE_AP &&
  444. vif->type != NL80211_IFTYPE_ADHOC) {
  445. brcms_err(wl->wlc->hw->d11core,
  446. "%s: Attempt to add type %d, only STA, AP and AdHoc for now\n",
  447. __func__, vif->type);
  448. return -EOPNOTSUPP;
  449. }
  450. spin_lock_bh(&wl->lock);
  451. wl->wlc->vif = vif;
  452. wl->mute_tx = false;
  453. brcms_c_mute(wl->wlc, false);
  454. if (vif->type == NL80211_IFTYPE_STATION)
  455. brcms_c_start_station(wl->wlc, vif->addr);
  456. else if (vif->type == NL80211_IFTYPE_AP)
  457. brcms_c_start_ap(wl->wlc, vif->addr, vif->bss_conf.bssid,
  458. vif->bss_conf.ssid, vif->bss_conf.ssid_len);
  459. else if (vif->type == NL80211_IFTYPE_ADHOC)
  460. brcms_c_start_adhoc(wl->wlc, vif->addr);
  461. spin_unlock_bh(&wl->lock);
  462. return 0;
  463. }
  464. static void
  465. brcms_ops_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
  466. {
  467. struct brcms_info *wl = hw->priv;
  468. spin_lock_bh(&wl->lock);
  469. wl->wlc->vif = NULL;
  470. spin_unlock_bh(&wl->lock);
  471. }
  472. static int brcms_ops_config(struct ieee80211_hw *hw, u32 changed)
  473. {
  474. struct ieee80211_conf *conf = &hw->conf;
  475. struct brcms_info *wl = hw->priv;
  476. struct bcma_device *core = wl->wlc->hw->d11core;
  477. int err = 0;
  478. int new_int;
  479. spin_lock_bh(&wl->lock);
  480. if (changed & IEEE80211_CONF_CHANGE_LISTEN_INTERVAL) {
  481. brcms_c_set_beacon_listen_interval(wl->wlc,
  482. conf->listen_interval);
  483. }
  484. if (changed & IEEE80211_CONF_CHANGE_MONITOR)
  485. brcms_dbg_info(core, "%s: change monitor mode: %s\n",
  486. __func__, conf->flags & IEEE80211_CONF_MONITOR ?
  487. "true" : "false");
  488. if (changed & IEEE80211_CONF_CHANGE_PS)
  489. brcms_err(core, "%s: change power-save mode: %s (implement)\n",
  490. __func__, conf->flags & IEEE80211_CONF_PS ?
  491. "true" : "false");
  492. if (changed & IEEE80211_CONF_CHANGE_POWER) {
  493. err = brcms_c_set_tx_power(wl->wlc, conf->power_level);
  494. if (err < 0) {
  495. brcms_err(core, "%s: Error setting power_level\n",
  496. __func__);
  497. goto config_out;
  498. }
  499. new_int = brcms_c_get_tx_power(wl->wlc);
  500. if (new_int != conf->power_level)
  501. brcms_err(core,
  502. "%s: Power level req != actual, %d %d\n",
  503. __func__, conf->power_level,
  504. new_int);
  505. }
  506. if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
  507. if (conf->chandef.width == NL80211_CHAN_WIDTH_20 ||
  508. conf->chandef.width == NL80211_CHAN_WIDTH_20_NOHT)
  509. err = brcms_c_set_channel(wl->wlc,
  510. conf->chandef.chan->hw_value);
  511. else
  512. err = -ENOTSUPP;
  513. }
  514. if (changed & IEEE80211_CONF_CHANGE_RETRY_LIMITS)
  515. err = brcms_c_set_rate_limit(wl->wlc,
  516. conf->short_frame_max_tx_count,
  517. conf->long_frame_max_tx_count);
  518. config_out:
  519. spin_unlock_bh(&wl->lock);
  520. return err;
  521. }
  522. static void
  523. brcms_ops_bss_info_changed(struct ieee80211_hw *hw,
  524. struct ieee80211_vif *vif,
  525. struct ieee80211_bss_conf *info, u32 changed)
  526. {
  527. struct brcms_info *wl = hw->priv;
  528. struct bcma_device *core = wl->wlc->hw->d11core;
  529. if (changed & BSS_CHANGED_ASSOC) {
  530. /* association status changed (associated/disassociated)
  531. * also implies a change in the AID.
  532. */
  533. brcms_err(core, "%s: %s: %sassociated\n", KBUILD_MODNAME,
  534. __func__, info->assoc ? "" : "dis");
  535. spin_lock_bh(&wl->lock);
  536. brcms_c_associate_upd(wl->wlc, info->assoc);
  537. spin_unlock_bh(&wl->lock);
  538. }
  539. if (changed & BSS_CHANGED_ERP_SLOT) {
  540. s8 val;
  541. /* slot timing changed */
  542. if (info->use_short_slot)
  543. val = 1;
  544. else
  545. val = 0;
  546. spin_lock_bh(&wl->lock);
  547. brcms_c_set_shortslot_override(wl->wlc, val);
  548. spin_unlock_bh(&wl->lock);
  549. }
  550. if (changed & BSS_CHANGED_HT) {
  551. /* 802.11n parameters changed */
  552. u16 mode = info->ht_operation_mode;
  553. spin_lock_bh(&wl->lock);
  554. brcms_c_protection_upd(wl->wlc, BRCMS_PROT_N_CFG,
  555. mode & IEEE80211_HT_OP_MODE_PROTECTION);
  556. brcms_c_protection_upd(wl->wlc, BRCMS_PROT_N_NONGF,
  557. mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT);
  558. brcms_c_protection_upd(wl->wlc, BRCMS_PROT_N_OBSS,
  559. mode & IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT);
  560. spin_unlock_bh(&wl->lock);
  561. }
  562. if (changed & BSS_CHANGED_BASIC_RATES) {
  563. struct ieee80211_supported_band *bi;
  564. u32 br_mask, i;
  565. u16 rate;
  566. struct brcm_rateset rs;
  567. int error;
  568. /* retrieve the current rates */
  569. spin_lock_bh(&wl->lock);
  570. brcms_c_get_current_rateset(wl->wlc, &rs);
  571. spin_unlock_bh(&wl->lock);
  572. br_mask = info->basic_rates;
  573. bi = hw->wiphy->bands[brcms_c_get_curband(wl->wlc)];
  574. for (i = 0; i < bi->n_bitrates; i++) {
  575. /* convert to internal rate value */
  576. rate = (bi->bitrates[i].bitrate << 1) / 10;
  577. /* set/clear basic rate flag */
  578. brcms_set_basic_rate(&rs, rate, br_mask & 1);
  579. br_mask >>= 1;
  580. }
  581. /* update the rate set */
  582. spin_lock_bh(&wl->lock);
  583. error = brcms_c_set_rateset(wl->wlc, &rs);
  584. spin_unlock_bh(&wl->lock);
  585. if (error)
  586. brcms_err(core, "changing basic rates failed: %d\n",
  587. error);
  588. }
  589. if (changed & BSS_CHANGED_BEACON_INT) {
  590. /* Beacon interval changed */
  591. spin_lock_bh(&wl->lock);
  592. brcms_c_set_beacon_period(wl->wlc, info->beacon_int);
  593. spin_unlock_bh(&wl->lock);
  594. }
  595. if (changed & BSS_CHANGED_BSSID) {
  596. /* BSSID changed, for whatever reason (IBSS and managed mode) */
  597. spin_lock_bh(&wl->lock);
  598. brcms_c_set_addrmatch(wl->wlc, RCM_BSSID_OFFSET, info->bssid);
  599. spin_unlock_bh(&wl->lock);
  600. }
  601. if (changed & BSS_CHANGED_SSID) {
  602. /* BSSID changed, for whatever reason (IBSS and managed mode) */
  603. spin_lock_bh(&wl->lock);
  604. brcms_c_set_ssid(wl->wlc, info->ssid, info->ssid_len);
  605. spin_unlock_bh(&wl->lock);
  606. }
  607. if (changed & BSS_CHANGED_BEACON) {
  608. /* Beacon data changed, retrieve new beacon (beaconing modes) */
  609. struct sk_buff *beacon;
  610. u16 tim_offset = 0;
  611. spin_lock_bh(&wl->lock);
  612. beacon = ieee80211_beacon_get_tim(hw, vif, &tim_offset, NULL);
  613. brcms_c_set_new_beacon(wl->wlc, beacon, tim_offset,
  614. info->dtim_period);
  615. spin_unlock_bh(&wl->lock);
  616. }
  617. if (changed & BSS_CHANGED_AP_PROBE_RESP) {
  618. struct sk_buff *probe_resp;
  619. spin_lock_bh(&wl->lock);
  620. probe_resp = ieee80211_proberesp_get(hw, vif);
  621. brcms_c_set_new_probe_resp(wl->wlc, probe_resp);
  622. spin_unlock_bh(&wl->lock);
  623. }
  624. if (changed & BSS_CHANGED_BEACON_ENABLED) {
  625. /* Beaconing should be enabled/disabled (beaconing modes) */
  626. brcms_err(core, "%s: Beacon enabled: %s\n", __func__,
  627. info->enable_beacon ? "true" : "false");
  628. if (info->enable_beacon &&
  629. hw->wiphy->flags & WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD) {
  630. brcms_c_enable_probe_resp(wl->wlc, true);
  631. } else {
  632. brcms_c_enable_probe_resp(wl->wlc, false);
  633. }
  634. }
  635. if (changed & BSS_CHANGED_CQM) {
  636. /* Connection quality monitor config changed */
  637. brcms_err(core, "%s: cqm change: threshold %d, hys %d "
  638. " (implement)\n", __func__, info->cqm_rssi_thold,
  639. info->cqm_rssi_hyst);
  640. }
  641. if (changed & BSS_CHANGED_IBSS) {
  642. /* IBSS join status changed */
  643. brcms_err(core, "%s: IBSS joined: %s (implement)\n",
  644. __func__, info->ibss_joined ? "true" : "false");
  645. }
  646. if (changed & BSS_CHANGED_ARP_FILTER) {
  647. /* Hardware ARP filter address list or state changed */
  648. brcms_err(core, "%s: arp filtering: %d addresses"
  649. " (implement)\n", __func__, info->arp_addr_cnt);
  650. }
  651. if (changed & BSS_CHANGED_QOS) {
  652. /*
  653. * QoS for this association was enabled/disabled.
  654. * Note that it is only ever disabled for station mode.
  655. */
  656. brcms_err(core, "%s: qos enabled: %s (implement)\n",
  657. __func__, info->qos ? "true" : "false");
  658. }
  659. return;
  660. }
  661. static void
  662. brcms_ops_configure_filter(struct ieee80211_hw *hw,
  663. unsigned int changed_flags,
  664. unsigned int *total_flags, u64 multicast)
  665. {
  666. struct brcms_info *wl = hw->priv;
  667. struct bcma_device *core = wl->wlc->hw->d11core;
  668. changed_flags &= MAC_FILTERS;
  669. *total_flags &= MAC_FILTERS;
  670. if (changed_flags & FIF_ALLMULTI)
  671. brcms_dbg_info(core, "FIF_ALLMULTI\n");
  672. if (changed_flags & FIF_FCSFAIL)
  673. brcms_dbg_info(core, "FIF_FCSFAIL\n");
  674. if (changed_flags & FIF_CONTROL)
  675. brcms_dbg_info(core, "FIF_CONTROL\n");
  676. if (changed_flags & FIF_OTHER_BSS)
  677. brcms_dbg_info(core, "FIF_OTHER_BSS\n");
  678. if (changed_flags & FIF_PSPOLL)
  679. brcms_dbg_info(core, "FIF_PSPOLL\n");
  680. if (changed_flags & FIF_BCN_PRBRESP_PROMISC)
  681. brcms_dbg_info(core, "FIF_BCN_PRBRESP_PROMISC\n");
  682. spin_lock_bh(&wl->lock);
  683. brcms_c_mac_promisc(wl->wlc, *total_flags);
  684. spin_unlock_bh(&wl->lock);
  685. return;
  686. }
  687. static void brcms_ops_sw_scan_start(struct ieee80211_hw *hw,
  688. struct ieee80211_vif *vif,
  689. const u8 *mac_addr)
  690. {
  691. struct brcms_info *wl = hw->priv;
  692. spin_lock_bh(&wl->lock);
  693. brcms_c_scan_start(wl->wlc);
  694. spin_unlock_bh(&wl->lock);
  695. return;
  696. }
  697. static void brcms_ops_sw_scan_complete(struct ieee80211_hw *hw,
  698. struct ieee80211_vif *vif)
  699. {
  700. struct brcms_info *wl = hw->priv;
  701. spin_lock_bh(&wl->lock);
  702. brcms_c_scan_stop(wl->wlc);
  703. spin_unlock_bh(&wl->lock);
  704. return;
  705. }
  706. static int
  707. brcms_ops_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u16 queue,
  708. const struct ieee80211_tx_queue_params *params)
  709. {
  710. struct brcms_info *wl = hw->priv;
  711. spin_lock_bh(&wl->lock);
  712. brcms_c_wme_setparams(wl->wlc, queue, params, true);
  713. spin_unlock_bh(&wl->lock);
  714. return 0;
  715. }
  716. static int
  717. brcms_ops_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  718. struct ieee80211_sta *sta)
  719. {
  720. struct brcms_info *wl = hw->priv;
  721. struct scb *scb = &wl->wlc->pri_scb;
  722. brcms_c_init_scb(scb);
  723. wl->pub->global_ampdu = &(scb->scb_ampdu);
  724. wl->pub->global_ampdu->scb = scb;
  725. wl->pub->global_ampdu->max_pdu = 16;
  726. /*
  727. * minstrel_ht initiates addBA on our behalf by calling
  728. * ieee80211_start_tx_ba_session()
  729. */
  730. return 0;
  731. }
  732. static int
  733. brcms_ops_ampdu_action(struct ieee80211_hw *hw,
  734. struct ieee80211_vif *vif,
  735. struct ieee80211_ampdu_params *params)
  736. {
  737. struct brcms_info *wl = hw->priv;
  738. struct scb *scb = &wl->wlc->pri_scb;
  739. int status;
  740. struct ieee80211_sta *sta = params->sta;
  741. enum ieee80211_ampdu_mlme_action action = params->action;
  742. u16 tid = params->tid;
  743. u8 buf_size = params->buf_size;
  744. if (WARN_ON(scb->magic != SCB_MAGIC))
  745. return -EIDRM;
  746. switch (action) {
  747. case IEEE80211_AMPDU_RX_START:
  748. break;
  749. case IEEE80211_AMPDU_RX_STOP:
  750. break;
  751. case IEEE80211_AMPDU_TX_START:
  752. spin_lock_bh(&wl->lock);
  753. status = brcms_c_aggregatable(wl->wlc, tid);
  754. spin_unlock_bh(&wl->lock);
  755. if (!status) {
  756. brcms_dbg_ht(wl->wlc->hw->d11core,
  757. "START: tid %d is not agg\'able\n", tid);
  758. return -EINVAL;
  759. }
  760. ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid);
  761. break;
  762. case IEEE80211_AMPDU_TX_STOP_CONT:
  763. case IEEE80211_AMPDU_TX_STOP_FLUSH:
  764. case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT:
  765. spin_lock_bh(&wl->lock);
  766. brcms_c_ampdu_flush(wl->wlc, sta, tid);
  767. spin_unlock_bh(&wl->lock);
  768. ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
  769. break;
  770. case IEEE80211_AMPDU_TX_OPERATIONAL:
  771. /*
  772. * BA window size from ADDBA response ('buf_size') defines how
  773. * many outstanding MPDUs are allowed for the BA stream by
  774. * recipient and traffic class. 'ampdu_factor' gives maximum
  775. * AMPDU size.
  776. */
  777. spin_lock_bh(&wl->lock);
  778. brcms_c_ampdu_tx_operational(wl->wlc, tid, buf_size,
  779. (1 << (IEEE80211_HT_MAX_AMPDU_FACTOR +
  780. sta->ht_cap.ampdu_factor)) - 1);
  781. spin_unlock_bh(&wl->lock);
  782. /* Power save wakeup */
  783. break;
  784. default:
  785. brcms_err(wl->wlc->hw->d11core,
  786. "%s: Invalid command, ignoring\n", __func__);
  787. }
  788. return 0;
  789. }
  790. static void brcms_ops_rfkill_poll(struct ieee80211_hw *hw)
  791. {
  792. struct brcms_info *wl = hw->priv;
  793. bool blocked;
  794. spin_lock_bh(&wl->lock);
  795. blocked = brcms_c_check_radio_disabled(wl->wlc);
  796. spin_unlock_bh(&wl->lock);
  797. wiphy_rfkill_set_hw_state(wl->pub->ieee_hw->wiphy, blocked);
  798. }
  799. static bool brcms_tx_flush_completed(struct brcms_info *wl)
  800. {
  801. bool result;
  802. spin_lock_bh(&wl->lock);
  803. result = brcms_c_tx_flush_completed(wl->wlc);
  804. spin_unlock_bh(&wl->lock);
  805. return result;
  806. }
  807. static void brcms_ops_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  808. u32 queues, bool drop)
  809. {
  810. struct brcms_info *wl = hw->priv;
  811. int ret;
  812. no_printk("%s: drop = %s\n", __func__, drop ? "true" : "false");
  813. ret = wait_event_timeout(wl->tx_flush_wq,
  814. brcms_tx_flush_completed(wl),
  815. msecs_to_jiffies(BRCMS_FLUSH_TIMEOUT));
  816. brcms_dbg_mac80211(wl->wlc->hw->d11core,
  817. "ret=%d\n", jiffies_to_msecs(ret));
  818. }
  819. static u64 brcms_ops_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
  820. {
  821. struct brcms_info *wl = hw->priv;
  822. u64 tsf;
  823. spin_lock_bh(&wl->lock);
  824. tsf = brcms_c_tsf_get(wl->wlc);
  825. spin_unlock_bh(&wl->lock);
  826. return tsf;
  827. }
  828. static void brcms_ops_set_tsf(struct ieee80211_hw *hw,
  829. struct ieee80211_vif *vif, u64 tsf)
  830. {
  831. struct brcms_info *wl = hw->priv;
  832. spin_lock_bh(&wl->lock);
  833. brcms_c_tsf_set(wl->wlc, tsf);
  834. spin_unlock_bh(&wl->lock);
  835. }
  836. static int brcms_ops_beacon_set_tim(struct ieee80211_hw *hw,
  837. struct ieee80211_sta *sta, bool set)
  838. {
  839. struct brcms_info *wl = hw->priv;
  840. struct sk_buff *beacon = NULL;
  841. u16 tim_offset = 0;
  842. spin_lock_bh(&wl->lock);
  843. if (wl->wlc->vif)
  844. beacon = ieee80211_beacon_get_tim(hw, wl->wlc->vif,
  845. &tim_offset, NULL);
  846. if (beacon)
  847. brcms_c_set_new_beacon(wl->wlc, beacon, tim_offset,
  848. wl->wlc->vif->bss_conf.dtim_period);
  849. spin_unlock_bh(&wl->lock);
  850. return 0;
  851. }
  852. static const struct ieee80211_ops brcms_ops = {
  853. .tx = brcms_ops_tx,
  854. .start = brcms_ops_start,
  855. .stop = brcms_ops_stop,
  856. .add_interface = brcms_ops_add_interface,
  857. .remove_interface = brcms_ops_remove_interface,
  858. .config = brcms_ops_config,
  859. .bss_info_changed = brcms_ops_bss_info_changed,
  860. .configure_filter = brcms_ops_configure_filter,
  861. .sw_scan_start = brcms_ops_sw_scan_start,
  862. .sw_scan_complete = brcms_ops_sw_scan_complete,
  863. .conf_tx = brcms_ops_conf_tx,
  864. .sta_add = brcms_ops_sta_add,
  865. .ampdu_action = brcms_ops_ampdu_action,
  866. .rfkill_poll = brcms_ops_rfkill_poll,
  867. .flush = brcms_ops_flush,
  868. .get_tsf = brcms_ops_get_tsf,
  869. .set_tsf = brcms_ops_set_tsf,
  870. .set_tim = brcms_ops_beacon_set_tim,
  871. };
  872. void brcms_dpc(unsigned long data)
  873. {
  874. struct brcms_info *wl;
  875. wl = (struct brcms_info *) data;
  876. spin_lock_bh(&wl->lock);
  877. /* call the common second level interrupt handler */
  878. if (wl->pub->up) {
  879. if (wl->resched) {
  880. unsigned long flags;
  881. spin_lock_irqsave(&wl->isr_lock, flags);
  882. brcms_c_intrsupd(wl->wlc);
  883. spin_unlock_irqrestore(&wl->isr_lock, flags);
  884. }
  885. wl->resched = brcms_c_dpc(wl->wlc, true);
  886. }
  887. /* brcms_c_dpc() may bring the driver down */
  888. if (!wl->pub->up)
  889. goto done;
  890. /* re-schedule dpc */
  891. if (wl->resched)
  892. tasklet_schedule(&wl->tasklet);
  893. else
  894. /* re-enable interrupts */
  895. brcms_intrson(wl);
  896. done:
  897. spin_unlock_bh(&wl->lock);
  898. wake_up(&wl->tx_flush_wq);
  899. }
  900. static irqreturn_t brcms_isr(int irq, void *dev_id)
  901. {
  902. struct brcms_info *wl;
  903. irqreturn_t ret = IRQ_NONE;
  904. wl = (struct brcms_info *) dev_id;
  905. spin_lock(&wl->isr_lock);
  906. /* call common first level interrupt handler */
  907. if (brcms_c_isr(wl->wlc)) {
  908. /* schedule second level handler */
  909. tasklet_schedule(&wl->tasklet);
  910. ret = IRQ_HANDLED;
  911. }
  912. spin_unlock(&wl->isr_lock);
  913. return ret;
  914. }
  915. /*
  916. * is called in brcms_pci_probe() context, therefore no locking required.
  917. */
  918. static int ieee_hw_rate_init(struct ieee80211_hw *hw)
  919. {
  920. struct brcms_info *wl = hw->priv;
  921. struct brcms_c_info *wlc = wl->wlc;
  922. struct ieee80211_supported_band *band;
  923. int has_5g = 0;
  924. u16 phy_type;
  925. hw->wiphy->bands[NL80211_BAND_2GHZ] = NULL;
  926. hw->wiphy->bands[NL80211_BAND_5GHZ] = NULL;
  927. phy_type = brcms_c_get_phy_type(wl->wlc, 0);
  928. if (phy_type == PHY_TYPE_N || phy_type == PHY_TYPE_LCN) {
  929. band = &wlc->bandstate[BAND_2G_INDEX]->band;
  930. *band = brcms_band_2GHz_nphy_template;
  931. if (phy_type == PHY_TYPE_LCN) {
  932. /* Single stream */
  933. band->ht_cap.mcs.rx_mask[1] = 0;
  934. band->ht_cap.mcs.rx_highest = cpu_to_le16(72);
  935. }
  936. hw->wiphy->bands[NL80211_BAND_2GHZ] = band;
  937. } else {
  938. return -EPERM;
  939. }
  940. /* Assume all bands use the same phy. True for 11n devices. */
  941. if (wl->pub->_nbands > 1) {
  942. has_5g++;
  943. if (phy_type == PHY_TYPE_N || phy_type == PHY_TYPE_LCN) {
  944. band = &wlc->bandstate[BAND_5G_INDEX]->band;
  945. *band = brcms_band_5GHz_nphy_template;
  946. hw->wiphy->bands[NL80211_BAND_5GHZ] = band;
  947. } else {
  948. return -EPERM;
  949. }
  950. }
  951. return 0;
  952. }
  953. /*
  954. * is called in brcms_pci_probe() context, therefore no locking required.
  955. */
  956. static int ieee_hw_init(struct ieee80211_hw *hw)
  957. {
  958. ieee80211_hw_set(hw, AMPDU_AGGREGATION);
  959. ieee80211_hw_set(hw, SIGNAL_DBM);
  960. ieee80211_hw_set(hw, REPORTS_TX_ACK_STATUS);
  961. hw->extra_tx_headroom = brcms_c_get_header_len();
  962. hw->queues = N_TX_QUEUES;
  963. hw->max_rates = 2; /* Primary rate and 1 fallback rate */
  964. /* channel change time is dependent on chip and band */
  965. hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
  966. BIT(NL80211_IFTYPE_AP) |
  967. BIT(NL80211_IFTYPE_ADHOC);
  968. /*
  969. * deactivate sending probe responses by ucude, because this will
  970. * cause problems when WPS is used.
  971. *
  972. * hw->wiphy->flags |= WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD;
  973. */
  974. wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_CQM_RSSI_LIST);
  975. hw->rate_control_algorithm = "minstrel_ht";
  976. hw->sta_data_size = 0;
  977. return ieee_hw_rate_init(hw);
  978. }
  979. /**
  980. * attach to the WL device.
  981. *
  982. * Attach to the WL device identified by vendor and device parameters.
  983. * regs is a host accessible memory address pointing to WL device registers.
  984. *
  985. * is called in brcms_bcma_probe() context, therefore no locking required.
  986. */
  987. static struct brcms_info *brcms_attach(struct bcma_device *pdev)
  988. {
  989. struct brcms_info *wl = NULL;
  990. int unit, err;
  991. struct ieee80211_hw *hw;
  992. u8 perm[ETH_ALEN];
  993. unit = n_adapters_found;
  994. err = 0;
  995. if (unit < 0)
  996. return NULL;
  997. /* allocate private info */
  998. hw = bcma_get_drvdata(pdev);
  999. if (hw != NULL)
  1000. wl = hw->priv;
  1001. if (WARN_ON(hw == NULL) || WARN_ON(wl == NULL))
  1002. return NULL;
  1003. wl->wiphy = hw->wiphy;
  1004. atomic_set(&wl->callbacks, 0);
  1005. init_waitqueue_head(&wl->tx_flush_wq);
  1006. /* setup the bottom half handler */
  1007. tasklet_init(&wl->tasklet, brcms_dpc, (unsigned long) wl);
  1008. spin_lock_init(&wl->lock);
  1009. spin_lock_init(&wl->isr_lock);
  1010. /* common load-time initialization */
  1011. wl->wlc = brcms_c_attach((void *)wl, pdev, unit, false, &err);
  1012. if (!wl->wlc) {
  1013. wiphy_err(wl->wiphy, "%s: attach() failed with code %d\n",
  1014. KBUILD_MODNAME, err);
  1015. goto fail;
  1016. }
  1017. wl->pub = brcms_c_pub(wl->wlc);
  1018. wl->pub->ieee_hw = hw;
  1019. /* register our interrupt handler */
  1020. if (request_irq(pdev->irq, brcms_isr,
  1021. IRQF_SHARED, KBUILD_MODNAME, wl)) {
  1022. wiphy_err(wl->wiphy, "wl%d: request_irq() failed\n", unit);
  1023. goto fail;
  1024. }
  1025. wl->irq = pdev->irq;
  1026. /* register module */
  1027. brcms_c_module_register(wl->pub, "linux", wl, NULL);
  1028. if (ieee_hw_init(hw)) {
  1029. wiphy_err(wl->wiphy, "wl%d: %s: ieee_hw_init failed!\n", unit,
  1030. __func__);
  1031. goto fail;
  1032. }
  1033. brcms_c_regd_init(wl->wlc);
  1034. memcpy(perm, &wl->pub->cur_etheraddr, ETH_ALEN);
  1035. if (WARN_ON(!is_valid_ether_addr(perm)))
  1036. goto fail;
  1037. SET_IEEE80211_PERM_ADDR(hw, perm);
  1038. err = ieee80211_register_hw(hw);
  1039. if (err)
  1040. wiphy_err(wl->wiphy, "%s: ieee80211_register_hw failed, status"
  1041. "%d\n", __func__, err);
  1042. if (wl->pub->srom_ccode[0] &&
  1043. regulatory_hint(wl->wiphy, wl->pub->srom_ccode))
  1044. wiphy_err(wl->wiphy, "%s: regulatory hint failed\n", __func__);
  1045. brcms_debugfs_attach(wl->pub);
  1046. brcms_debugfs_create_files(wl->pub);
  1047. n_adapters_found++;
  1048. return wl;
  1049. fail:
  1050. brcms_free(wl);
  1051. return NULL;
  1052. }
  1053. /**
  1054. * determines if a device is a WL device, and if so, attaches it.
  1055. *
  1056. * This function determines if a device pointed to by pdev is a WL device,
  1057. * and if so, performs a brcms_attach() on it.
  1058. *
  1059. * Perimeter lock is initialized in the course of this function.
  1060. */
  1061. static int brcms_bcma_probe(struct bcma_device *pdev)
  1062. {
  1063. struct brcms_info *wl;
  1064. struct ieee80211_hw *hw;
  1065. dev_info(&pdev->dev, "mfg %x core %x rev %d class %d irq %d\n",
  1066. pdev->id.manuf, pdev->id.id, pdev->id.rev, pdev->id.class,
  1067. pdev->irq);
  1068. if ((pdev->id.manuf != BCMA_MANUF_BCM) ||
  1069. (pdev->id.id != BCMA_CORE_80211))
  1070. return -ENODEV;
  1071. hw = ieee80211_alloc_hw(sizeof(struct brcms_info), &brcms_ops);
  1072. if (!hw) {
  1073. pr_err("%s: ieee80211_alloc_hw failed\n", __func__);
  1074. return -ENOMEM;
  1075. }
  1076. SET_IEEE80211_DEV(hw, &pdev->dev);
  1077. bcma_set_drvdata(pdev, hw);
  1078. memset(hw->priv, 0, sizeof(*wl));
  1079. wl = brcms_attach(pdev);
  1080. if (!wl) {
  1081. pr_err("%s: brcms_attach failed!\n", __func__);
  1082. return -ENODEV;
  1083. }
  1084. brcms_led_register(wl);
  1085. return 0;
  1086. }
  1087. static int brcms_suspend(struct bcma_device *pdev)
  1088. {
  1089. struct brcms_info *wl;
  1090. struct ieee80211_hw *hw;
  1091. hw = bcma_get_drvdata(pdev);
  1092. wl = hw->priv;
  1093. if (!wl) {
  1094. pr_err("%s: %s: no driver private struct!\n", KBUILD_MODNAME,
  1095. __func__);
  1096. return -ENODEV;
  1097. }
  1098. /* only need to flag hw is down for proper resume */
  1099. spin_lock_bh(&wl->lock);
  1100. wl->pub->hw_up = false;
  1101. spin_unlock_bh(&wl->lock);
  1102. brcms_dbg_info(wl->wlc->hw->d11core, "brcms_suspend ok\n");
  1103. return 0;
  1104. }
  1105. static int brcms_resume(struct bcma_device *pdev)
  1106. {
  1107. return 0;
  1108. }
  1109. static struct bcma_driver brcms_bcma_driver = {
  1110. .name = KBUILD_MODNAME,
  1111. .probe = brcms_bcma_probe,
  1112. .suspend = brcms_suspend,
  1113. .resume = brcms_resume,
  1114. .remove = brcms_remove,
  1115. .id_table = brcms_coreid_table,
  1116. };
  1117. /**
  1118. * This is the main entry point for the brcmsmac driver.
  1119. *
  1120. * This function is scheduled upon module initialization and
  1121. * does the driver registration, which result in brcms_bcma_probe()
  1122. * call resulting in the driver bringup.
  1123. */
  1124. static void brcms_driver_init(struct work_struct *work)
  1125. {
  1126. int error;
  1127. error = bcma_driver_register(&brcms_bcma_driver);
  1128. if (error)
  1129. pr_err("%s: register returned %d\n", __func__, error);
  1130. }
  1131. static DECLARE_WORK(brcms_driver_work, brcms_driver_init);
  1132. static int __init brcms_module_init(void)
  1133. {
  1134. brcms_debugfs_init();
  1135. if (!schedule_work(&brcms_driver_work))
  1136. return -EBUSY;
  1137. return 0;
  1138. }
  1139. /**
  1140. * This function unloads the brcmsmac driver from the system.
  1141. *
  1142. * This function unconditionally unloads the brcmsmac driver module from the
  1143. * system.
  1144. *
  1145. */
  1146. static void __exit brcms_module_exit(void)
  1147. {
  1148. cancel_work_sync(&brcms_driver_work);
  1149. bcma_driver_unregister(&brcms_bcma_driver);
  1150. brcms_debugfs_exit();
  1151. }
  1152. module_init(brcms_module_init);
  1153. module_exit(brcms_module_exit);
  1154. /*
  1155. * precondition: perimeter lock has been acquired
  1156. */
  1157. void brcms_txflowcontrol(struct brcms_info *wl, struct brcms_if *wlif,
  1158. bool state, int prio)
  1159. {
  1160. brcms_err(wl->wlc->hw->d11core, "Shouldn't be here %s\n", __func__);
  1161. }
  1162. /*
  1163. * precondition: perimeter lock has been acquired
  1164. */
  1165. void brcms_init(struct brcms_info *wl)
  1166. {
  1167. brcms_dbg_info(wl->wlc->hw->d11core, "Initializing wl%d\n",
  1168. wl->pub->unit);
  1169. brcms_reset(wl);
  1170. brcms_c_init(wl->wlc, wl->mute_tx);
  1171. }
  1172. /*
  1173. * precondition: perimeter lock has been acquired
  1174. */
  1175. uint brcms_reset(struct brcms_info *wl)
  1176. {
  1177. brcms_dbg_info(wl->wlc->hw->d11core, "Resetting wl%d\n", wl->pub->unit);
  1178. brcms_c_reset(wl->wlc);
  1179. /* dpc will not be rescheduled */
  1180. wl->resched = false;
  1181. /* inform publicly that interface is down */
  1182. wl->pub->up = false;
  1183. return 0;
  1184. }
  1185. void brcms_fatal_error(struct brcms_info *wl)
  1186. {
  1187. brcms_err(wl->wlc->hw->d11core, "wl%d: fatal error, reinitializing\n",
  1188. wl->wlc->pub->unit);
  1189. brcms_reset(wl);
  1190. ieee80211_restart_hw(wl->pub->ieee_hw);
  1191. }
  1192. /*
  1193. * These are interrupt on/off entry points. Disable interrupts
  1194. * during interrupt state transition.
  1195. */
  1196. void brcms_intrson(struct brcms_info *wl)
  1197. {
  1198. unsigned long flags;
  1199. spin_lock_irqsave(&wl->isr_lock, flags);
  1200. brcms_c_intrson(wl->wlc);
  1201. spin_unlock_irqrestore(&wl->isr_lock, flags);
  1202. }
  1203. u32 brcms_intrsoff(struct brcms_info *wl)
  1204. {
  1205. unsigned long flags;
  1206. u32 status;
  1207. spin_lock_irqsave(&wl->isr_lock, flags);
  1208. status = brcms_c_intrsoff(wl->wlc);
  1209. spin_unlock_irqrestore(&wl->isr_lock, flags);
  1210. return status;
  1211. }
  1212. void brcms_intrsrestore(struct brcms_info *wl, u32 macintmask)
  1213. {
  1214. unsigned long flags;
  1215. spin_lock_irqsave(&wl->isr_lock, flags);
  1216. brcms_c_intrsrestore(wl->wlc, macintmask);
  1217. spin_unlock_irqrestore(&wl->isr_lock, flags);
  1218. }
  1219. /*
  1220. * precondition: perimeter lock has been acquired
  1221. */
  1222. int brcms_up(struct brcms_info *wl)
  1223. {
  1224. int error = 0;
  1225. if (wl->pub->up)
  1226. return 0;
  1227. error = brcms_c_up(wl->wlc);
  1228. return error;
  1229. }
  1230. /*
  1231. * precondition: perimeter lock has been acquired
  1232. */
  1233. void brcms_down(struct brcms_info *wl)
  1234. {
  1235. uint callbacks, ret_val = 0;
  1236. /* call common down function */
  1237. ret_val = brcms_c_down(wl->wlc);
  1238. callbacks = atomic_read(&wl->callbacks) - ret_val;
  1239. /* wait for down callbacks to complete */
  1240. spin_unlock_bh(&wl->lock);
  1241. /* For HIGH_only driver, it's important to actually schedule other work,
  1242. * not just spin wait since everything runs at schedule level
  1243. */
  1244. SPINWAIT((atomic_read(&wl->callbacks) > callbacks), 100 * 1000);
  1245. spin_lock_bh(&wl->lock);
  1246. }
  1247. /*
  1248. * precondition: perimeter lock is not acquired
  1249. */
  1250. static void _brcms_timer(struct work_struct *work)
  1251. {
  1252. struct brcms_timer *t = container_of(work, struct brcms_timer,
  1253. dly_wrk.work);
  1254. spin_lock_bh(&t->wl->lock);
  1255. if (t->set) {
  1256. if (t->periodic) {
  1257. atomic_inc(&t->wl->callbacks);
  1258. ieee80211_queue_delayed_work(t->wl->pub->ieee_hw,
  1259. &t->dly_wrk,
  1260. msecs_to_jiffies(t->ms));
  1261. } else {
  1262. t->set = false;
  1263. }
  1264. t->fn(t->arg);
  1265. }
  1266. atomic_dec(&t->wl->callbacks);
  1267. spin_unlock_bh(&t->wl->lock);
  1268. }
  1269. /*
  1270. * Adds a timer to the list. Caller supplies a timer function.
  1271. * Is called from wlc.
  1272. *
  1273. * precondition: perimeter lock has been acquired
  1274. */
  1275. struct brcms_timer *brcms_init_timer(struct brcms_info *wl,
  1276. void (*fn) (void *arg),
  1277. void *arg, const char *name)
  1278. {
  1279. struct brcms_timer *t;
  1280. t = kzalloc(sizeof(struct brcms_timer), GFP_ATOMIC);
  1281. if (!t)
  1282. return NULL;
  1283. INIT_DELAYED_WORK(&t->dly_wrk, _brcms_timer);
  1284. t->wl = wl;
  1285. t->fn = fn;
  1286. t->arg = arg;
  1287. t->next = wl->timers;
  1288. wl->timers = t;
  1289. #ifdef DEBUG
  1290. t->name = kstrdup(name, GFP_ATOMIC);
  1291. #endif
  1292. return t;
  1293. }
  1294. /*
  1295. * adds only the kernel timer since it's going to be more accurate
  1296. * as well as it's easier to make it periodic
  1297. *
  1298. * precondition: perimeter lock has been acquired
  1299. */
  1300. void brcms_add_timer(struct brcms_timer *t, uint ms, int periodic)
  1301. {
  1302. struct ieee80211_hw *hw = t->wl->pub->ieee_hw;
  1303. #ifdef DEBUG
  1304. if (t->set)
  1305. brcms_dbg_info(t->wl->wlc->hw->d11core,
  1306. "%s: Already set. Name: %s, per %d\n",
  1307. __func__, t->name, periodic);
  1308. #endif
  1309. t->ms = ms;
  1310. t->periodic = (bool) periodic;
  1311. if (!t->set) {
  1312. t->set = true;
  1313. atomic_inc(&t->wl->callbacks);
  1314. }
  1315. ieee80211_queue_delayed_work(hw, &t->dly_wrk, msecs_to_jiffies(ms));
  1316. }
  1317. /*
  1318. * return true if timer successfully deleted, false if still pending
  1319. *
  1320. * precondition: perimeter lock has been acquired
  1321. */
  1322. bool brcms_del_timer(struct brcms_timer *t)
  1323. {
  1324. if (t->set) {
  1325. t->set = false;
  1326. if (!cancel_delayed_work(&t->dly_wrk))
  1327. return false;
  1328. atomic_dec(&t->wl->callbacks);
  1329. }
  1330. return true;
  1331. }
  1332. /*
  1333. * precondition: perimeter lock has been acquired
  1334. */
  1335. void brcms_free_timer(struct brcms_timer *t)
  1336. {
  1337. struct brcms_info *wl = t->wl;
  1338. struct brcms_timer *tmp;
  1339. /* delete the timer in case it is active */
  1340. brcms_del_timer(t);
  1341. if (wl->timers == t) {
  1342. wl->timers = wl->timers->next;
  1343. #ifdef DEBUG
  1344. kfree(t->name);
  1345. #endif
  1346. kfree(t);
  1347. return;
  1348. }
  1349. tmp = wl->timers;
  1350. while (tmp) {
  1351. if (tmp->next == t) {
  1352. tmp->next = t->next;
  1353. #ifdef DEBUG
  1354. kfree(t->name);
  1355. #endif
  1356. kfree(t);
  1357. return;
  1358. }
  1359. tmp = tmp->next;
  1360. }
  1361. }
  1362. /*
  1363. * precondition: no locking required
  1364. */
  1365. int brcms_ucode_init_buf(struct brcms_info *wl, void **pbuf, u32 idx)
  1366. {
  1367. int i, entry;
  1368. const u8 *pdata;
  1369. struct firmware_hdr *hdr;
  1370. for (i = 0; i < wl->fw.fw_cnt; i++) {
  1371. hdr = (struct firmware_hdr *)wl->fw.fw_hdr[i]->data;
  1372. for (entry = 0; entry < wl->fw.hdr_num_entries[i];
  1373. entry++, hdr++) {
  1374. u32 len = le32_to_cpu(hdr->len);
  1375. if (le32_to_cpu(hdr->idx) == idx) {
  1376. pdata = wl->fw.fw_bin[i]->data +
  1377. le32_to_cpu(hdr->offset);
  1378. *pbuf = kvmalloc(len, GFP_KERNEL);
  1379. if (*pbuf == NULL)
  1380. goto fail;
  1381. memcpy(*pbuf, pdata, len);
  1382. return 0;
  1383. }
  1384. }
  1385. }
  1386. brcms_err(wl->wlc->hw->d11core,
  1387. "ERROR: ucode buf tag:%d can not be found!\n", idx);
  1388. *pbuf = NULL;
  1389. fail:
  1390. return -ENODATA;
  1391. }
  1392. /*
  1393. * Precondition: Since this function is called in brcms_bcma_probe() context,
  1394. * no locking is required.
  1395. */
  1396. int brcms_ucode_init_uint(struct brcms_info *wl, size_t *n_bytes, u32 idx)
  1397. {
  1398. int i, entry;
  1399. const u8 *pdata;
  1400. struct firmware_hdr *hdr;
  1401. for (i = 0; i < wl->fw.fw_cnt; i++) {
  1402. hdr = (struct firmware_hdr *)wl->fw.fw_hdr[i]->data;
  1403. for (entry = 0; entry < wl->fw.hdr_num_entries[i];
  1404. entry++, hdr++) {
  1405. if (le32_to_cpu(hdr->idx) == idx) {
  1406. pdata = wl->fw.fw_bin[i]->data +
  1407. le32_to_cpu(hdr->offset);
  1408. if (le32_to_cpu(hdr->len) != 4) {
  1409. brcms_err(wl->wlc->hw->d11core,
  1410. "ERROR: fw hdr len\n");
  1411. return -ENOMSG;
  1412. }
  1413. *n_bytes = le32_to_cpu(*((__le32 *) pdata));
  1414. return 0;
  1415. }
  1416. }
  1417. }
  1418. brcms_err(wl->wlc->hw->d11core,
  1419. "ERROR: ucode tag:%d can not be found!\n", idx);
  1420. return -ENOMSG;
  1421. }
  1422. /*
  1423. * precondition: can both be called locked and unlocked
  1424. */
  1425. void brcms_ucode_free_buf(void *p)
  1426. {
  1427. kvfree(p);
  1428. }
  1429. /*
  1430. * checks validity of all firmware images loaded from user space
  1431. *
  1432. * Precondition: Since this function is called in brcms_bcma_probe() context,
  1433. * no locking is required.
  1434. */
  1435. int brcms_check_firmwares(struct brcms_info *wl)
  1436. {
  1437. int i;
  1438. int entry;
  1439. int rc = 0;
  1440. const struct firmware *fw;
  1441. const struct firmware *fw_hdr;
  1442. struct firmware_hdr *ucode_hdr;
  1443. for (i = 0; i < MAX_FW_IMAGES && rc == 0; i++) {
  1444. fw = wl->fw.fw_bin[i];
  1445. fw_hdr = wl->fw.fw_hdr[i];
  1446. if (fw == NULL && fw_hdr == NULL) {
  1447. break;
  1448. } else if (fw == NULL || fw_hdr == NULL) {
  1449. wiphy_err(wl->wiphy, "%s: invalid bin/hdr fw\n",
  1450. __func__);
  1451. rc = -EBADF;
  1452. } else if (fw_hdr->size % sizeof(struct firmware_hdr)) {
  1453. wiphy_err(wl->wiphy, "%s: non integral fw hdr file "
  1454. "size %zu/%zu\n", __func__, fw_hdr->size,
  1455. sizeof(struct firmware_hdr));
  1456. rc = -EBADF;
  1457. } else if (fw->size < MIN_FW_SIZE || fw->size > MAX_FW_SIZE) {
  1458. wiphy_err(wl->wiphy, "%s: out of bounds fw file size %zu\n",
  1459. __func__, fw->size);
  1460. rc = -EBADF;
  1461. } else {
  1462. /* check if ucode section overruns firmware image */
  1463. ucode_hdr = (struct firmware_hdr *)fw_hdr->data;
  1464. for (entry = 0; entry < wl->fw.hdr_num_entries[i] &&
  1465. !rc; entry++, ucode_hdr++) {
  1466. if (le32_to_cpu(ucode_hdr->offset) +
  1467. le32_to_cpu(ucode_hdr->len) >
  1468. fw->size) {
  1469. wiphy_err(wl->wiphy,
  1470. "%s: conflicting bin/hdr\n",
  1471. __func__);
  1472. rc = -EBADF;
  1473. }
  1474. }
  1475. }
  1476. }
  1477. if (rc == 0 && wl->fw.fw_cnt != i) {
  1478. wiphy_err(wl->wiphy, "%s: invalid fw_cnt=%d\n", __func__,
  1479. wl->fw.fw_cnt);
  1480. rc = -EBADF;
  1481. }
  1482. return rc;
  1483. }
  1484. /*
  1485. * precondition: perimeter lock has been acquired
  1486. */
  1487. bool brcms_rfkill_set_hw_state(struct brcms_info *wl)
  1488. {
  1489. bool blocked = brcms_c_check_radio_disabled(wl->wlc);
  1490. spin_unlock_bh(&wl->lock);
  1491. wiphy_rfkill_set_hw_state(wl->pub->ieee_hw->wiphy, blocked);
  1492. if (blocked)
  1493. wiphy_rfkill_start_polling(wl->pub->ieee_hw->wiphy);
  1494. spin_lock_bh(&wl->lock);
  1495. return blocked;
  1496. }