mac80211_if.c 43 KB

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