Commit | Line | Data |
---|---|---|
a9533e7e HP |
1 | /* |
2 | * Copyright (c) 2010 Broadcom Corporation | |
3 | * | |
4 | * Permission to use, copy, modify, and/or distribute this software for any | |
5 | * purpose with or without fee is hereby granted, provided that the above | |
6 | * copyright notice and this permission notice appear in all copies. | |
7 | * | |
8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | |
11 | * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION | |
13 | * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |
14 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
15 | */ | |
16 | ||
17 | #define __UNDEF_NO_VERSION__ | |
18 | ||
a9533e7e | 19 | #include <linux/kernel.h> |
a9533e7e | 20 | #include <linux/etherdevice.h> |
a9533e7e | 21 | #include <linux/string.h> |
a9533e7e | 22 | #include <linux/pci_ids.h> |
a1c16ed2 | 23 | #include <bcmdefs.h> |
c6ac24e9 BR |
24 | #include <linux/module.h> |
25 | #include <linux/pci.h> | |
26 | #include <linux/sched.h> | |
a1c16ed2 | 27 | #include <osl.h> |
a9533e7e HP |
28 | #define WLC_MAXBSSCFG 1 /* single BSS configs */ |
29 | ||
a9533e7e HP |
30 | #include <wlc_cfg.h> |
31 | #include <net/mac80211.h> | |
a9533e7e | 32 | #include <phy_version.h> |
a9533e7e HP |
33 | #include <bcmutils.h> |
34 | #include <pcicfg.h> | |
35 | #include <wlioctl.h> | |
36 | #include <wlc_key.h> | |
a52ba66c BR |
37 | #include <sbhndpio.h> |
38 | #include <sbhnddma.h> | |
a9533e7e HP |
39 | #include <wlc_channel.h> |
40 | #include <wlc_pub.h> | |
41 | #include <wlc_scb.h> | |
42 | #include <wl_dbg.h> | |
a9533e7e | 43 | #include <wl_export.h> |
a9533e7e HP |
44 | |
45 | #include <wl_mac80211.h> | |
46 | #include <linux/firmware.h> | |
a9533e7e HP |
47 | #include <wl_ucode.h> |
48 | #include <d11ucode_ext.h> | |
a9533e7e | 49 | |
a9533e7e | 50 | |
3deea904 | 51 | static void wl_timer(unsigned long data); |
7cc4a4c0 | 52 | static void _wl_timer(wl_timer_t *t); |
a9533e7e | 53 | |
a9533e7e HP |
54 | |
55 | static int ieee_hw_init(struct ieee80211_hw *hw); | |
56 | static int ieee_hw_rate_init(struct ieee80211_hw *hw); | |
57 | ||
58 | static int wl_linux_watchdog(void *ctx); | |
59 | ||
60 | /* Flags we support */ | |
61 | #define MAC_FILTERS (FIF_PROMISC_IN_BSS | \ | |
62 | FIF_ALLMULTI | \ | |
63 | FIF_FCSFAIL | \ | |
64 | FIF_PLCPFAIL | \ | |
65 | FIF_CONTROL | \ | |
66 | FIF_OTHER_BSS | \ | |
67 | FIF_BCN_PRBRESP_PROMISC) | |
68 | ||
7e85c729 | 69 | static int wl_found; |
a9533e7e | 70 | |
6cdeaef2 | 71 | #define WL_DEV_IF(dev) ((struct wl_if *)netdev_priv(dev)) |
2cb22a7a RV |
72 | #define WL_INFO(dev) ((struct wl_info *)(WL_DEV_IF(dev)->wl)) |
73 | static int wl_request_fw(struct wl_info *wl, struct pci_dev *pdev); | |
74 | static void wl_release_fw(struct wl_info *wl); | |
a9533e7e HP |
75 | |
76 | /* local prototypes */ | |
2cb22a7a RV |
77 | static int wl_start(struct sk_buff *skb, struct wl_info *wl); |
78 | static int wl_start_int(struct wl_info *wl, struct ieee80211_hw *hw, | |
a9533e7e | 79 | struct sk_buff *skb); |
3deea904 | 80 | static void wl_dpc(unsigned long data); |
a9533e7e HP |
81 | |
82 | MODULE_AUTHOR("Broadcom Corporation"); | |
83 | MODULE_DESCRIPTION("Broadcom 802.11n wireless LAN driver."); | |
84 | MODULE_SUPPORTED_DEVICE("Broadcom 802.11n WLAN cards"); | |
85 | MODULE_LICENSE("Dual BSD/GPL"); | |
86 | ||
a9533e7e HP |
87 | /* recognized PCI IDs */ |
88 | static struct pci_device_id wl_id_table[] = { | |
89 | {PCI_VENDOR_ID_BROADCOM, 0x4357, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* 43225 2G */ | |
90 | {PCI_VENDOR_ID_BROADCOM, 0x4353, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* 43224 DUAL */ | |
91 | {PCI_VENDOR_ID_BROADCOM, 0x4727, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* 4313 DUAL */ | |
92 | {0} | |
93 | }; | |
94 | ||
95 | MODULE_DEVICE_TABLE(pci, wl_id_table); | |
6f0c5bcd | 96 | static void wl_remove(struct pci_dev *pdev); |
a9533e7e | 97 | |
a9533e7e HP |
98 | |
99 | #ifdef BCMDBG | |
100 | static int msglevel = 0xdeadbeef; | |
101 | module_param(msglevel, int, 0); | |
a9533e7e HP |
102 | static int phymsglevel = 0xdeadbeef; |
103 | module_param(phymsglevel, int, 0); | |
a9533e7e HP |
104 | #endif /* BCMDBG */ |
105 | ||
0d706ef4 JC |
106 | #define HW_TO_WL(hw) (hw->priv) |
107 | #define WL_TO_HW(wl) (wl->pub->ieee_hw) | |
a9533e7e | 108 | static int wl_ops_tx(struct ieee80211_hw *hw, struct sk_buff *skb); |
a9533e7e HP |
109 | static int wl_ops_start(struct ieee80211_hw *hw); |
110 | static void wl_ops_stop(struct ieee80211_hw *hw); | |
111 | static int wl_ops_add_interface(struct ieee80211_hw *hw, | |
112 | struct ieee80211_vif *vif); | |
113 | static void wl_ops_remove_interface(struct ieee80211_hw *hw, | |
114 | struct ieee80211_vif *vif); | |
115 | static int wl_ops_config(struct ieee80211_hw *hw, u32 changed); | |
116 | static void wl_ops_bss_info_changed(struct ieee80211_hw *hw, | |
117 | struct ieee80211_vif *vif, | |
118 | struct ieee80211_bss_conf *info, | |
119 | u32 changed); | |
120 | static void wl_ops_configure_filter(struct ieee80211_hw *hw, | |
121 | unsigned int changed_flags, | |
122 | unsigned int *total_flags, u64 multicast); | |
123 | static int wl_ops_set_tim(struct ieee80211_hw *hw, struct ieee80211_sta *sta, | |
124 | bool set); | |
125 | static void wl_ops_sw_scan_start(struct ieee80211_hw *hw); | |
126 | static void wl_ops_sw_scan_complete(struct ieee80211_hw *hw); | |
127 | static void wl_ops_set_tsf(struct ieee80211_hw *hw, u64 tsf); | |
128 | static int wl_ops_get_stats(struct ieee80211_hw *hw, | |
129 | struct ieee80211_low_level_stats *stats); | |
130 | static int wl_ops_set_rts_threshold(struct ieee80211_hw *hw, u32 value); | |
131 | static void wl_ops_sta_notify(struct ieee80211_hw *hw, | |
132 | struct ieee80211_vif *vif, | |
133 | enum sta_notify_cmd cmd, | |
134 | struct ieee80211_sta *sta); | |
135 | static int wl_ops_conf_tx(struct ieee80211_hw *hw, u16 queue, | |
136 | const struct ieee80211_tx_queue_params *params); | |
137 | static u64 wl_ops_get_tsf(struct ieee80211_hw *hw); | |
138 | static int wl_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, | |
139 | struct ieee80211_sta *sta); | |
140 | static int wl_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, | |
141 | struct ieee80211_sta *sta); | |
142 | static int wl_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, | |
143 | enum ieee80211_ampdu_mlme_action action, | |
7cc4a4c0 | 144 | struct ieee80211_sta *sta, u16 tid, u16 *ssn); |
5abb04a6 | 145 | static void wl_ops_rfkill_poll(struct ieee80211_hw *hw); |
a9533e7e | 146 | |
a9533e7e HP |
147 | static int wl_ops_tx(struct ieee80211_hw *hw, struct sk_buff *skb) |
148 | { | |
149 | int status; | |
2cb22a7a | 150 | struct wl_info *wl = hw->priv; |
a9533e7e HP |
151 | WL_LOCK(wl); |
152 | if (!wl->pub->up) { | |
f4528696 | 153 | WL_ERROR("ops->tx called while down\n"); |
a9533e7e HP |
154 | status = -ENETDOWN; |
155 | goto done; | |
156 | } | |
157 | status = wl_start(skb, wl); | |
158 | done: | |
159 | WL_UNLOCK(wl); | |
160 | return status; | |
161 | } | |
a9533e7e HP |
162 | |
163 | static int wl_ops_start(struct ieee80211_hw *hw) | |
164 | { | |
2cb22a7a | 165 | struct wl_info *wl = hw->priv; |
5abb04a6 | 166 | bool blocked; |
f4528696 JP |
167 | /* |
168 | struct ieee80211_channel *curchan = hw->conf.channel; | |
169 | WL_NONE("%s : Initial channel: %d\n", __func__, curchan->hw_value); | |
170 | */ | |
a9533e7e HP |
171 | |
172 | WL_LOCK(wl); | |
173 | ieee80211_wake_queues(hw); | |
174 | WL_UNLOCK(wl); | |
5abb04a6 AS |
175 | blocked = wl_rfkill_set_hw_state(wl); |
176 | if (!blocked) | |
177 | wiphy_rfkill_stop_polling(wl->pub->ieee_hw->wiphy); | |
a9533e7e HP |
178 | |
179 | return 0; | |
180 | } | |
181 | ||
182 | static void wl_ops_stop(struct ieee80211_hw *hw) | |
183 | { | |
2cb22a7a | 184 | struct wl_info *wl = hw->priv; |
a9533e7e HP |
185 | ASSERT(wl); |
186 | WL_LOCK(wl); | |
a9533e7e HP |
187 | ieee80211_stop_queues(hw); |
188 | WL_UNLOCK(wl); | |
a9533e7e HP |
189 | } |
190 | ||
191 | static int | |
192 | wl_ops_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) | |
193 | { | |
2cb22a7a | 194 | struct wl_info *wl; |
a9533e7e HP |
195 | int err; |
196 | ||
197 | /* Just STA for now */ | |
198 | if (vif->type != NL80211_IFTYPE_AP && | |
199 | vif->type != NL80211_IFTYPE_MESH_POINT && | |
200 | vif->type != NL80211_IFTYPE_STATION && | |
201 | vif->type != NL80211_IFTYPE_WDS && | |
202 | vif->type != NL80211_IFTYPE_ADHOC) { | |
f4528696 JP |
203 | WL_ERROR("%s: Attempt to add type %d, only STA for now\n", |
204 | __func__, vif->type); | |
a9533e7e HP |
205 | return -EOPNOTSUPP; |
206 | } | |
207 | ||
208 | wl = HW_TO_WL(hw); | |
209 | WL_LOCK(wl); | |
210 | err = wl_up(wl); | |
211 | WL_UNLOCK(wl); | |
212 | ||
5abb04a6 | 213 | if (err != 0) { |
f4528696 | 214 | WL_ERROR("%s: wl_up() returned %d\n", __func__, err); |
5abb04a6 | 215 | } |
a9533e7e HP |
216 | return err; |
217 | } | |
218 | ||
219 | static void | |
220 | wl_ops_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) | |
221 | { | |
4032ec63 AS |
222 | struct wl_info *wl; |
223 | ||
224 | wl = HW_TO_WL(hw); | |
225 | ||
226 | /* put driver in down state */ | |
227 | WL_LOCK(wl); | |
228 | wl_down(wl); | |
229 | WL_UNLOCK(wl); | |
a9533e7e HP |
230 | } |
231 | ||
232 | static int | |
233 | ieee_set_channel(struct ieee80211_hw *hw, struct ieee80211_channel *chan, | |
234 | enum nl80211_channel_type type) | |
235 | { | |
2cb22a7a | 236 | struct wl_info *wl = HW_TO_WL(hw); |
a9533e7e HP |
237 | int err = 0; |
238 | ||
239 | switch (type) { | |
240 | case NL80211_CHAN_HT20: | |
241 | case NL80211_CHAN_NO_HT: | |
a9533e7e | 242 | err = wlc_set(wl->wlc, WLC_SET_CHANNEL, chan->hw_value); |
a9533e7e HP |
243 | break; |
244 | case NL80211_CHAN_HT40MINUS: | |
245 | case NL80211_CHAN_HT40PLUS: | |
f4528696 | 246 | WL_ERROR("%s: Need to implement 40 Mhz Channels!\n", __func__); |
a9533e7e HP |
247 | break; |
248 | } | |
249 | ||
250 | if (err) | |
251 | return -EIO; | |
252 | return err; | |
253 | } | |
254 | ||
255 | static int wl_ops_config(struct ieee80211_hw *hw, u32 changed) | |
256 | { | |
257 | struct ieee80211_conf *conf = &hw->conf; | |
2cb22a7a | 258 | struct wl_info *wl = HW_TO_WL(hw); |
a9533e7e HP |
259 | int err = 0; |
260 | int new_int; | |
261 | ||
6a3be6e6 | 262 | WL_LOCK(wl); |
a9533e7e | 263 | if (changed & IEEE80211_CONF_CHANGE_LISTEN_INTERVAL) { |
f4528696 JP |
264 | WL_NONE("%s: Setting listen interval to %d\n", |
265 | __func__, conf->listen_interval); | |
a9533e7e HP |
266 | if (wlc_iovar_setint |
267 | (wl->wlc, "bcn_li_bcn", conf->listen_interval)) { | |
f4528696 JP |
268 | WL_ERROR("%s: Error setting listen_interval\n", |
269 | __func__); | |
a9533e7e HP |
270 | err = -EIO; |
271 | goto config_out; | |
272 | } | |
273 | wlc_iovar_getint(wl->wlc, "bcn_li_bcn", &new_int); | |
274 | ASSERT(new_int == conf->listen_interval); | |
275 | } | |
276 | if (changed & IEEE80211_CONF_CHANGE_MONITOR) | |
f4528696 | 277 | WL_NONE("Need to set monitor mode\n"); |
a9533e7e | 278 | if (changed & IEEE80211_CONF_CHANGE_PS) |
f4528696 | 279 | WL_NONE("Need to set Power-save mode\n"); |
a9533e7e HP |
280 | |
281 | if (changed & IEEE80211_CONF_CHANGE_POWER) { | |
f4528696 JP |
282 | WL_NONE("%s: Setting tx power to %d dbm\n", |
283 | __func__, conf->power_level); | |
a9533e7e HP |
284 | if (wlc_iovar_setint |
285 | (wl->wlc, "qtxpower", conf->power_level * 4)) { | |
f4528696 | 286 | WL_ERROR("%s: Error setting power_level\n", __func__); |
a9533e7e HP |
287 | err = -EIO; |
288 | goto config_out; | |
289 | } | |
290 | wlc_iovar_getint(wl->wlc, "qtxpower", &new_int); | |
291 | if (new_int != (conf->power_level * 4)) | |
f4528696 JP |
292 | WL_ERROR("%s: Power level req != actual, %d %d\n", |
293 | __func__, conf->power_level * 4, new_int); | |
a9533e7e HP |
294 | } |
295 | if (changed & IEEE80211_CONF_CHANGE_CHANNEL) { | |
296 | err = ieee_set_channel(hw, conf->channel, conf->channel_type); | |
297 | } | |
298 | if (changed & IEEE80211_CONF_CHANGE_RETRY_LIMITS) { | |
f4528696 JP |
299 | WL_NONE("%s: srl %d, lrl %d\n", |
300 | __func__, | |
301 | conf->short_frame_max_tx_count, | |
302 | conf->long_frame_max_tx_count); | |
a9533e7e HP |
303 | if (wlc_set |
304 | (wl->wlc, WLC_SET_SRL, | |
305 | conf->short_frame_max_tx_count) < 0) { | |
f4528696 | 306 | WL_ERROR("%s: Error setting srl\n", __func__); |
a9533e7e HP |
307 | err = -EIO; |
308 | goto config_out; | |
309 | } | |
310 | if (wlc_set(wl->wlc, WLC_SET_LRL, conf->long_frame_max_tx_count) | |
311 | < 0) { | |
f4528696 | 312 | WL_ERROR("%s: Error setting lrl\n", __func__); |
a9533e7e HP |
313 | err = -EIO; |
314 | goto config_out; | |
315 | } | |
316 | } | |
317 | ||
318 | config_out: | |
6a3be6e6 | 319 | WL_UNLOCK(wl); |
a9533e7e HP |
320 | return err; |
321 | } | |
322 | ||
323 | static void | |
324 | wl_ops_bss_info_changed(struct ieee80211_hw *hw, | |
325 | struct ieee80211_vif *vif, | |
326 | struct ieee80211_bss_conf *info, u32 changed) | |
327 | { | |
2cb22a7a | 328 | struct wl_info *wl = HW_TO_WL(hw); |
a9533e7e HP |
329 | int val; |
330 | ||
a9533e7e HP |
331 | |
332 | if (changed & BSS_CHANGED_ASSOC) { | |
f4528696 | 333 | WL_ERROR("Associated:\t%s\n", info->assoc ? "True" : "False"); |
a9533e7e HP |
334 | /* association status changed (associated/disassociated) |
335 | * also implies a change in the AID. | |
336 | */ | |
337 | } | |
338 | if (changed & BSS_CHANGED_ERP_CTS_PROT) { | |
f4528696 JP |
339 | WL_NONE("Use_cts_prot:\t%s Implement me\n", |
340 | info->use_cts_prot ? "True" : "False"); | |
a9533e7e HP |
341 | /* CTS protection changed */ |
342 | } | |
343 | if (changed & BSS_CHANGED_ERP_PREAMBLE) { | |
f4528696 JP |
344 | WL_NONE("Short preamble:\t%s Implement me\n", |
345 | info->use_short_preamble ? "True" : "False"); | |
a9533e7e HP |
346 | /* preamble changed */ |
347 | } | |
348 | if (changed & BSS_CHANGED_ERP_SLOT) { | |
f4528696 JP |
349 | WL_NONE("Changing short slot:\t%s\n", |
350 | info->use_short_slot ? "True" : "False"); | |
a9533e7e HP |
351 | if (info->use_short_slot) |
352 | val = 1; | |
353 | else | |
354 | val = 0; | |
355 | wlc_set(wl->wlc, WLC_SET_SHORTSLOT_OVERRIDE, val); | |
356 | /* slot timing changed */ | |
357 | } | |
358 | ||
359 | if (changed & BSS_CHANGED_HT) { | |
f4528696 | 360 | WL_NONE("%s: HT mode - Implement me\n", __func__); |
a9533e7e HP |
361 | /* 802.11n parameters changed */ |
362 | } | |
363 | if (changed & BSS_CHANGED_BASIC_RATES) { | |
f4528696 JP |
364 | WL_NONE("Need to change Basic Rates:\t0x%x! Implement me\n", |
365 | (u32) info->basic_rates); | |
a9533e7e HP |
366 | /* Basic rateset changed */ |
367 | } | |
368 | if (changed & BSS_CHANGED_BEACON_INT) { | |
f4528696 JP |
369 | WL_NONE("Beacon Interval:\t%d Implement me\n", |
370 | info->beacon_int); | |
a9533e7e HP |
371 | /* Beacon interval changed */ |
372 | } | |
373 | if (changed & BSS_CHANGED_BSSID) { | |
f4528696 JP |
374 | WL_NONE("new BSSID:\taid %d bss:%pM\n", |
375 | info->aid, info->bssid); | |
a9533e7e HP |
376 | /* BSSID changed, for whatever reason (IBSS and managed mode) */ |
377 | /* FIXME: need to store bssid in bsscfg */ | |
378 | wlc_set_addrmatch(wl->wlc, RCM_BSSID_OFFSET, | |
a44d4236 | 379 | info->bssid); |
a9533e7e HP |
380 | } |
381 | if (changed & BSS_CHANGED_BEACON) { | |
f4528696 | 382 | WL_ERROR("BSS_CHANGED_BEACON\n"); |
a9533e7e HP |
383 | /* Beacon data changed, retrieve new beacon (beaconing modes) */ |
384 | } | |
385 | if (changed & BSS_CHANGED_BEACON_ENABLED) { | |
f4528696 JP |
386 | WL_ERROR("Beacon enabled:\t%s\n", |
387 | info->enable_beacon ? "True" : "False"); | |
a9533e7e HP |
388 | /* Beaconing should be enabled/disabled (beaconing modes) */ |
389 | } | |
a9533e7e HP |
390 | return; |
391 | } | |
392 | ||
393 | static void | |
394 | wl_ops_configure_filter(struct ieee80211_hw *hw, | |
395 | unsigned int changed_flags, | |
396 | unsigned int *total_flags, u64 multicast) | |
397 | { | |
2cb22a7a | 398 | struct wl_info *wl = hw->priv; |
a9533e7e HP |
399 | |
400 | changed_flags &= MAC_FILTERS; | |
401 | *total_flags &= MAC_FILTERS; | |
402 | if (changed_flags & FIF_PROMISC_IN_BSS) | |
f4528696 | 403 | WL_ERROR("FIF_PROMISC_IN_BSS\n"); |
a9533e7e | 404 | if (changed_flags & FIF_ALLMULTI) |
f4528696 | 405 | WL_ERROR("FIF_ALLMULTI\n"); |
a9533e7e | 406 | if (changed_flags & FIF_FCSFAIL) |
f4528696 | 407 | WL_ERROR("FIF_FCSFAIL\n"); |
a9533e7e | 408 | if (changed_flags & FIF_PLCPFAIL) |
f4528696 | 409 | WL_ERROR("FIF_PLCPFAIL\n"); |
a9533e7e | 410 | if (changed_flags & FIF_CONTROL) |
f4528696 | 411 | WL_ERROR("FIF_CONTROL\n"); |
a9533e7e | 412 | if (changed_flags & FIF_OTHER_BSS) |
f4528696 | 413 | WL_ERROR("FIF_OTHER_BSS\n"); |
a9533e7e | 414 | if (changed_flags & FIF_BCN_PRBRESP_PROMISC) { |
f4528696 | 415 | WL_NONE("FIF_BCN_PRBRESP_PROMISC\n"); |
a9533e7e HP |
416 | WL_LOCK(wl); |
417 | if (*total_flags & FIF_BCN_PRBRESP_PROMISC) { | |
418 | wl->pub->mac80211_state |= MAC80211_PROMISC_BCNS; | |
419 | wlc_mac_bcn_promisc_change(wl->wlc, 1); | |
420 | } else { | |
421 | wlc_mac_bcn_promisc_change(wl->wlc, 0); | |
422 | wl->pub->mac80211_state &= ~MAC80211_PROMISC_BCNS; | |
423 | } | |
424 | WL_UNLOCK(wl); | |
a9533e7e HP |
425 | } |
426 | return; | |
427 | } | |
428 | ||
429 | static int | |
430 | wl_ops_set_tim(struct ieee80211_hw *hw, struct ieee80211_sta *sta, bool set) | |
431 | { | |
f4528696 | 432 | WL_ERROR("%s: Enter\n", __func__); |
a9533e7e HP |
433 | return 0; |
434 | } | |
435 | ||
436 | static void wl_ops_sw_scan_start(struct ieee80211_hw *hw) | |
437 | { | |
6a3be6e6 | 438 | struct wl_info *wl = hw->priv; |
f4528696 | 439 | WL_NONE("Scan Start\n"); |
6a3be6e6 RV |
440 | WL_LOCK(wl); |
441 | wlc_scan_start(wl->wlc); | |
442 | WL_UNLOCK(wl); | |
a9533e7e HP |
443 | return; |
444 | } | |
445 | ||
446 | static void wl_ops_sw_scan_complete(struct ieee80211_hw *hw) | |
447 | { | |
6a3be6e6 | 448 | struct wl_info *wl = hw->priv; |
f4528696 | 449 | WL_NONE("Scan Complete\n"); |
6a3be6e6 RV |
450 | WL_LOCK(wl); |
451 | wlc_scan_stop(wl->wlc); | |
452 | WL_UNLOCK(wl); | |
a9533e7e HP |
453 | return; |
454 | } | |
455 | ||
456 | static void wl_ops_set_tsf(struct ieee80211_hw *hw, u64 tsf) | |
457 | { | |
f4528696 | 458 | WL_ERROR("%s: Enter\n", __func__); |
a9533e7e HP |
459 | return; |
460 | } | |
461 | ||
462 | static int | |
463 | wl_ops_get_stats(struct ieee80211_hw *hw, | |
464 | struct ieee80211_low_level_stats *stats) | |
465 | { | |
f4528696 | 466 | WL_ERROR("%s: Enter\n", __func__); |
a9533e7e HP |
467 | return 0; |
468 | } | |
469 | ||
470 | static int wl_ops_set_rts_threshold(struct ieee80211_hw *hw, u32 value) | |
471 | { | |
fd821d1e AS |
472 | struct wl_info *wl = hw->priv; |
473 | ||
474 | WL_LOCK(wl); | |
475 | wlc_iovar_setint(wl->wlc, "rtsthresh", value & 0xFFFF); | |
476 | WL_UNLOCK(wl); | |
a9533e7e HP |
477 | return 0; |
478 | } | |
479 | ||
480 | static void | |
481 | wl_ops_sta_notify(struct ieee80211_hw *hw, struct ieee80211_vif *vif, | |
482 | enum sta_notify_cmd cmd, struct ieee80211_sta *sta) | |
483 | { | |
f4528696 | 484 | WL_NONE("%s: Enter\n", __func__); |
a9533e7e HP |
485 | switch (cmd) { |
486 | default: | |
f4528696 | 487 | WL_ERROR("%s: Unknown cmd = %d\n", __func__, cmd); |
a9533e7e HP |
488 | break; |
489 | } | |
490 | return; | |
491 | } | |
492 | ||
493 | static int | |
494 | wl_ops_conf_tx(struct ieee80211_hw *hw, u16 queue, | |
495 | const struct ieee80211_tx_queue_params *params) | |
496 | { | |
2cb22a7a | 497 | struct wl_info *wl = hw->priv; |
a9533e7e | 498 | |
f4528696 JP |
499 | WL_NONE("%s: Enter (WME config)\n", __func__); |
500 | WL_NONE("queue %d, txop %d, cwmin %d, cwmax %d, aifs %d\n", queue, | |
501 | params->txop, params->cw_min, params->cw_max, params->aifs); | |
a9533e7e HP |
502 | |
503 | WL_LOCK(wl); | |
0f0881b0 | 504 | wlc_wme_setparams(wl->wlc, queue, (void *)params, true); |
a9533e7e HP |
505 | WL_UNLOCK(wl); |
506 | ||
507 | return 0; | |
508 | } | |
509 | ||
510 | static u64 wl_ops_get_tsf(struct ieee80211_hw *hw) | |
511 | { | |
f4528696 | 512 | WL_ERROR("%s: Enter\n", __func__); |
a9533e7e HP |
513 | return 0; |
514 | } | |
515 | ||
516 | static int | |
517 | wl_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, | |
518 | struct ieee80211_sta *sta) | |
519 | { | |
520 | struct scb *scb; | |
521 | ||
522 | int i; | |
2cb22a7a | 523 | struct wl_info *wl = hw->priv; |
a9533e7e HP |
524 | |
525 | /* Init the scb */ | |
526 | scb = (struct scb *)sta->drv_priv; | |
9249ede9 | 527 | memset(scb, 0, sizeof(struct scb)); |
a9533e7e HP |
528 | for (i = 0; i < NUMPRIO; i++) |
529 | scb->seqctl[i] = 0xFFFF; | |
530 | scb->seqctl_nonqos = 0xFFFF; | |
531 | scb->magic = SCB_MAGIC; | |
532 | ||
533 | wl->pub->global_scb = scb; | |
534 | wl->pub->global_ampdu = &(scb->scb_ampdu); | |
535 | wl->pub->global_ampdu->scb = scb; | |
a9533e7e | 536 | wl->pub->global_ampdu->max_pdu = 16; |
a9533e7e HP |
537 | pktq_init(&scb->scb_ampdu.txq, AMPDU_MAX_SCB_TID, |
538 | AMPDU_MAX_SCB_TID * PKTQ_LEN_DEFAULT); | |
539 | ||
0f0881b0 | 540 | sta->ht_cap.ht_supported = true; |
a9533e7e | 541 | sta->ht_cap.ampdu_factor = AMPDU_RX_FACTOR_64K; |
a9533e7e HP |
542 | sta->ht_cap.ampdu_density = AMPDU_DEF_MPDU_DENSITY; |
543 | sta->ht_cap.cap = IEEE80211_HT_CAP_GRN_FLD | | |
544 | IEEE80211_HT_CAP_SGI_20 | | |
545 | IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_40MHZ_INTOLERANT; | |
546 | ||
547 | /* minstrel_ht initiates addBA on our behalf by calling ieee80211_start_tx_ba_session() */ | |
548 | return 0; | |
549 | } | |
550 | ||
551 | static int | |
552 | wl_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, | |
553 | struct ieee80211_sta *sta) | |
554 | { | |
f4528696 | 555 | WL_NONE("%s: Enter\n", __func__); |
a9533e7e HP |
556 | return 0; |
557 | } | |
558 | ||
559 | static int | |
560 | wl_ampdu_action(struct ieee80211_hw *hw, | |
561 | struct ieee80211_vif *vif, | |
562 | enum ieee80211_ampdu_mlme_action action, | |
7cc4a4c0 | 563 | struct ieee80211_sta *sta, u16 tid, u16 *ssn) |
a9533e7e HP |
564 | { |
565 | #if defined(BCMDBG) | |
566 | struct scb *scb = (struct scb *)sta->drv_priv; | |
567 | #endif | |
2cb22a7a | 568 | struct wl_info *wl = hw->priv; |
a9533e7e HP |
569 | |
570 | ASSERT(scb->magic == SCB_MAGIC); | |
571 | switch (action) { | |
572 | case IEEE80211_AMPDU_RX_START: | |
f4528696 | 573 | WL_NONE("%s: action = IEEE80211_AMPDU_RX_START\n", __func__); |
a9533e7e HP |
574 | break; |
575 | case IEEE80211_AMPDU_RX_STOP: | |
f4528696 | 576 | WL_NONE("%s: action = IEEE80211_AMPDU_RX_STOP\n", __func__); |
a9533e7e HP |
577 | break; |
578 | case IEEE80211_AMPDU_TX_START: | |
579 | if (!wlc_aggregatable(wl->wlc, tid)) { | |
f4528696 | 580 | /* WL_ERROR("START: tid %d is not agg' able, return FAILURE to stack\n", tid); */ |
a9533e7e HP |
581 | return -1; |
582 | } | |
583 | /* XXX: Use the starting sequence number provided ... */ | |
584 | *ssn = 0; | |
585 | ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid); | |
586 | break; | |
587 | ||
588 | case IEEE80211_AMPDU_TX_STOP: | |
589 | ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); | |
590 | break; | |
591 | case IEEE80211_AMPDU_TX_OPERATIONAL: | |
592 | /* Not sure what to do here */ | |
593 | /* Power save wakeup */ | |
f4528696 JP |
594 | WL_NONE("%s: action = IEEE80211_AMPDU_TX_OPERATIONAL\n", |
595 | __func__); | |
a9533e7e HP |
596 | break; |
597 | default: | |
f4528696 | 598 | WL_ERROR("%s: Invalid command, ignoring\n", __func__); |
a9533e7e HP |
599 | } |
600 | ||
601 | return 0; | |
602 | } | |
603 | ||
5abb04a6 AS |
604 | static void wl_ops_rfkill_poll(struct ieee80211_hw *hw) |
605 | { | |
606 | struct wl_info *wl = HW_TO_WL(hw); | |
607 | bool blocked; | |
608 | ||
609 | WL_LOCK(wl); | |
610 | blocked = wlc_check_radio_disabled(wl->wlc); | |
611 | WL_UNLOCK(wl); | |
612 | ||
613 | WL_ERROR("wl: rfkill_poll: %d\n", blocked); | |
614 | wiphy_rfkill_set_hw_state(wl->pub->ieee_hw->wiphy, blocked); | |
615 | } | |
616 | ||
a9533e7e | 617 | static const struct ieee80211_ops wl_ops = { |
a9533e7e | 618 | .tx = wl_ops_tx, |
a9533e7e HP |
619 | .start = wl_ops_start, |
620 | .stop = wl_ops_stop, | |
621 | .add_interface = wl_ops_add_interface, | |
622 | .remove_interface = wl_ops_remove_interface, | |
623 | .config = wl_ops_config, | |
624 | .bss_info_changed = wl_ops_bss_info_changed, | |
625 | .configure_filter = wl_ops_configure_filter, | |
626 | .set_tim = wl_ops_set_tim, | |
627 | .sw_scan_start = wl_ops_sw_scan_start, | |
628 | .sw_scan_complete = wl_ops_sw_scan_complete, | |
629 | .set_tsf = wl_ops_set_tsf, | |
630 | .get_stats = wl_ops_get_stats, | |
631 | .set_rts_threshold = wl_ops_set_rts_threshold, | |
632 | .sta_notify = wl_ops_sta_notify, | |
633 | .conf_tx = wl_ops_conf_tx, | |
634 | .get_tsf = wl_ops_get_tsf, | |
635 | .sta_add = wl_sta_add, | |
636 | .sta_remove = wl_sta_remove, | |
637 | .ampdu_action = wl_ampdu_action, | |
5abb04a6 | 638 | .rfkill_poll = wl_ops_rfkill_poll, |
a9533e7e HP |
639 | }; |
640 | ||
2cb22a7a | 641 | static int wl_set_hint(struct wl_info *wl, char *abbrev) |
a9533e7e | 642 | { |
f4528696 JP |
643 | WL_ERROR("%s: Sending country code %c%c to MAC80211\n", |
644 | __func__, abbrev[0], abbrev[1]); | |
90ea2296 | 645 | return regulatory_hint(wl->pub->ieee_hw->wiphy, abbrev); |
a9533e7e HP |
646 | } |
647 | ||
648 | /** | |
649 | * attach to the WL device. | |
650 | * | |
651 | * Attach to the WL device identified by vendor and device parameters. | |
652 | * regs is a host accessible memory address pointing to WL device registers. | |
653 | * | |
654 | * wl_attach is not defined as static because in the case where no bus | |
655 | * is defined, wl_attach will never be called, and thus, gcc will issue | |
656 | * a warning that this function is defined but not used if we declare | |
657 | * it as static. | |
658 | */ | |
2cb22a7a | 659 | static struct wl_info *wl_attach(u16 vendor, u16 device, unsigned long regs, |
a9533e7e HP |
660 | uint bustype, void *btparam, uint irq) |
661 | { | |
2cb22a7a | 662 | struct wl_info *wl; |
e69284f2 | 663 | struct osl_info *osh; |
a9533e7e HP |
664 | int unit, err; |
665 | ||
3deea904 | 666 | unsigned long base_addr; |
a9533e7e | 667 | struct ieee80211_hw *hw; |
41feb5ed | 668 | u8 perm[ETH_ALEN]; |
a9533e7e | 669 | |
06fc8846 | 670 | unit = wl_found; |
a9533e7e HP |
671 | err = 0; |
672 | ||
673 | if (unit < 0) { | |
f4528696 | 674 | WL_ERROR("wl%d: unit number overflow, exiting\n", unit); |
a9533e7e HP |
675 | return NULL; |
676 | } | |
677 | ||
997dd24f | 678 | osh = osl_attach(btparam, bustype); |
a9533e7e HP |
679 | ASSERT(osh); |
680 | ||
a9533e7e HP |
681 | /* allocate private info */ |
682 | hw = pci_get_drvdata(btparam); /* btparam == pdev */ | |
683 | wl = hw->priv; | |
a9533e7e HP |
684 | ASSERT(wl); |
685 | ||
a9533e7e HP |
686 | wl->osh = osh; |
687 | atomic_set(&wl->callbacks, 0); | |
688 | ||
eb4764c3 | 689 | /* setup the bottom half handler */ |
3deea904 | 690 | tasklet_init(&wl->tasklet, wl_dpc, (unsigned long) wl); |
eb4764c3 | 691 | |
a9533e7e | 692 | |
a9533e7e HP |
693 | |
694 | base_addr = regs; | |
695 | ||
696 | if (bustype == PCI_BUS) { | |
06fc8846 | 697 | wl->piomode = false; |
a9533e7e HP |
698 | } else if (bustype == RPC_BUS) { |
699 | /* Do nothing */ | |
700 | } else { | |
701 | bustype = PCI_BUS; | |
f4528696 | 702 | WL_TRACE("force to PCI\n"); |
a9533e7e HP |
703 | } |
704 | wl->bcm_bustype = bustype; | |
705 | ||
ca8c1e59 JC |
706 | wl->regsva = ioremap_nocache(base_addr, PCI_BAR0_WINSZ); |
707 | if (wl->regsva == NULL) { | |
f4528696 | 708 | WL_ERROR("wl%d: ioremap() failed\n", unit); |
a9533e7e HP |
709 | goto fail; |
710 | } | |
a9533e7e HP |
711 | spin_lock_init(&wl->lock); |
712 | spin_lock_init(&wl->isr_lock); | |
a9533e7e | 713 | |
a9533e7e HP |
714 | /* prepare ucode */ |
715 | if (wl_request_fw(wl, (struct pci_dev *)btparam)) { | |
683b505b BR |
716 | printf("%s: Failed to find firmware usually in %s\n", |
717 | KBUILD_MODNAME, "/lib/firmware/brcm"); | |
718 | wl_release_fw(wl); | |
719 | wl_remove((struct pci_dev *)btparam); | |
720 | goto fail1; | |
a9533e7e | 721 | } |
a9533e7e HP |
722 | |
723 | /* common load-time initialization */ | |
eb4764c3 BH |
724 | wl->wlc = wlc_attach((void *)wl, vendor, device, unit, wl->piomode, osh, |
725 | wl->regsva, wl->bcm_bustype, btparam, &err); | |
eb4764c3 | 726 | wl_release_fw(wl); |
eb4764c3 | 727 | if (!wl->wlc) { |
4766ae6c BR |
728 | printf("%s: wlc_attach() failed with code %d\n", |
729 | KBUILD_MODNAME, err); | |
a9533e7e HP |
730 | goto fail; |
731 | } | |
a9533e7e HP |
732 | wl->pub = wlc_pub(wl->wlc); |
733 | ||
734 | wl->pub->ieee_hw = hw; | |
735 | ASSERT(wl->pub->ieee_hw); | |
736 | ASSERT(wl->pub->ieee_hw->priv == wl); | |
737 | ||
a9533e7e | 738 | |
06fc8846 | 739 | if (wlc_iovar_setint(wl->wlc, "mpc", 0)) { |
f4528696 | 740 | WL_ERROR("wl%d: Error setting MPC variable to 0\n", unit); |
a9533e7e | 741 | } |
a9533e7e | 742 | |
a9533e7e HP |
743 | /* register our interrupt handler */ |
744 | if (request_irq(irq, wl_isr, IRQF_SHARED, KBUILD_MODNAME, wl)) { | |
f4528696 | 745 | WL_ERROR("wl%d: request_irq() failed\n", unit); |
a9533e7e HP |
746 | goto fail; |
747 | } | |
748 | wl->irq = irq; | |
a9533e7e HP |
749 | |
750 | /* register module */ | |
751 | wlc_module_register(wl->pub, NULL, "linux", wl, NULL, wl_linux_watchdog, | |
752 | NULL); | |
753 | ||
754 | if (ieee_hw_init(hw)) { | |
f4528696 | 755 | WL_ERROR("wl%d: %s: ieee_hw_init failed!\n", unit, __func__); |
a9533e7e HP |
756 | goto fail; |
757 | } | |
758 | ||
b8d63078 | 759 | bcopy(&wl->pub->cur_etheraddr, perm, ETH_ALEN); |
a9533e7e HP |
760 | ASSERT(is_valid_ether_addr(perm)); |
761 | SET_IEEE80211_PERM_ADDR(hw, perm); | |
762 | ||
763 | err = ieee80211_register_hw(hw); | |
764 | if (err) { | |
f4528696 JP |
765 | WL_ERROR("%s: ieee80211_register_hw failed, status %d\n", |
766 | __func__, err); | |
a9533e7e HP |
767 | } |
768 | ||
769 | if (wl->pub->srom_ccode[0]) | |
770 | err = wl_set_hint(wl, wl->pub->srom_ccode); | |
771 | else | |
772 | err = wl_set_hint(wl, "US"); | |
773 | if (err) { | |
f4528696 JP |
774 | WL_ERROR("%s: regulatory_hint failed, status %d\n", |
775 | __func__, err); | |
a9533e7e | 776 | } |
a9533e7e | 777 | |
a9533e7e HP |
778 | wl_found++; |
779 | return wl; | |
780 | ||
4032ec63 | 781 | fail: |
a9533e7e | 782 | wl_free(wl); |
9e56568a | 783 | fail1: |
a9533e7e HP |
784 | return NULL; |
785 | } | |
786 | ||
a9533e7e | 787 | |
a9533e7e HP |
788 | |
789 | #define CHAN2GHZ(channel, freqency, chflags) { \ | |
790 | .band = IEEE80211_BAND_2GHZ, \ | |
791 | .center_freq = (freqency), \ | |
792 | .hw_value = (channel), \ | |
793 | .flags = chflags, \ | |
794 | .max_antenna_gain = 0, \ | |
795 | .max_power = 19, \ | |
796 | } | |
797 | ||
798 | static struct ieee80211_channel wl_2ghz_chantable[] = { | |
799 | CHAN2GHZ(1, 2412, IEEE80211_CHAN_NO_HT40MINUS), | |
800 | CHAN2GHZ(2, 2417, IEEE80211_CHAN_NO_HT40MINUS), | |
801 | CHAN2GHZ(3, 2422, IEEE80211_CHAN_NO_HT40MINUS), | |
802 | CHAN2GHZ(4, 2427, IEEE80211_CHAN_NO_HT40MINUS), | |
803 | CHAN2GHZ(5, 2432, 0), | |
804 | CHAN2GHZ(6, 2437, 0), | |
805 | CHAN2GHZ(7, 2442, 0), | |
806 | CHAN2GHZ(8, 2447, IEEE80211_CHAN_NO_HT40PLUS), | |
807 | CHAN2GHZ(9, 2452, IEEE80211_CHAN_NO_HT40PLUS), | |
808 | CHAN2GHZ(10, 2457, IEEE80211_CHAN_NO_HT40PLUS), | |
809 | CHAN2GHZ(11, 2462, IEEE80211_CHAN_NO_HT40PLUS), | |
810 | CHAN2GHZ(12, 2467, | |
811 | IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_IBSS | | |
812 | IEEE80211_CHAN_NO_HT40PLUS), | |
813 | CHAN2GHZ(13, 2472, | |
814 | IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_IBSS | | |
815 | IEEE80211_CHAN_NO_HT40PLUS), | |
816 | CHAN2GHZ(14, 2484, | |
817 | IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_IBSS | | |
818 | IEEE80211_CHAN_NO_HT40PLUS | IEEE80211_CHAN_NO_HT40MINUS) | |
819 | }; | |
820 | ||
821 | #define CHAN5GHZ(channel, chflags) { \ | |
822 | .band = IEEE80211_BAND_5GHZ, \ | |
823 | .center_freq = 5000 + 5*(channel), \ | |
824 | .hw_value = (channel), \ | |
825 | .flags = chflags, \ | |
826 | .max_antenna_gain = 0, \ | |
827 | .max_power = 21, \ | |
828 | } | |
829 | ||
830 | static struct ieee80211_channel wl_5ghz_nphy_chantable[] = { | |
831 | /* UNII-1 */ | |
832 | CHAN5GHZ(36, IEEE80211_CHAN_NO_HT40MINUS), | |
833 | CHAN5GHZ(40, IEEE80211_CHAN_NO_HT40PLUS), | |
834 | CHAN5GHZ(44, IEEE80211_CHAN_NO_HT40MINUS), | |
835 | CHAN5GHZ(48, IEEE80211_CHAN_NO_HT40PLUS), | |
836 | /* UNII-2 */ | |
837 | CHAN5GHZ(52, | |
838 | IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | | |
839 | IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS), | |
840 | CHAN5GHZ(56, | |
841 | IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | | |
842 | IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS), | |
843 | CHAN5GHZ(60, | |
844 | IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | | |
845 | IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS), | |
846 | CHAN5GHZ(64, | |
847 | IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | | |
848 | IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS), | |
849 | /* MID */ | |
850 | CHAN5GHZ(100, | |
851 | IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | | |
852 | IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS), | |
853 | CHAN5GHZ(104, | |
854 | IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | | |
855 | IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS), | |
856 | CHAN5GHZ(108, | |
857 | IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | | |
858 | IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS), | |
859 | CHAN5GHZ(112, | |
860 | IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | | |
861 | IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS), | |
862 | CHAN5GHZ(116, | |
863 | IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | | |
864 | IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS), | |
865 | CHAN5GHZ(120, | |
866 | IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | | |
867 | IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS), | |
868 | CHAN5GHZ(124, | |
869 | IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | | |
870 | IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS), | |
871 | CHAN5GHZ(128, | |
872 | IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | | |
873 | IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS), | |
874 | CHAN5GHZ(132, | |
875 | IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | | |
876 | IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS), | |
877 | CHAN5GHZ(136, | |
878 | IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | | |
879 | IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS), | |
880 | CHAN5GHZ(140, | |
881 | IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | | |
882 | IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS | | |
883 | IEEE80211_CHAN_NO_HT40MINUS), | |
884 | /* UNII-3 */ | |
885 | CHAN5GHZ(149, IEEE80211_CHAN_NO_HT40MINUS), | |
886 | CHAN5GHZ(153, IEEE80211_CHAN_NO_HT40PLUS), | |
887 | CHAN5GHZ(157, IEEE80211_CHAN_NO_HT40MINUS), | |
888 | CHAN5GHZ(161, IEEE80211_CHAN_NO_HT40PLUS), | |
889 | CHAN5GHZ(165, IEEE80211_CHAN_NO_HT40PLUS | IEEE80211_CHAN_NO_HT40MINUS) | |
890 | }; | |
891 | ||
892 | #define RATE(rate100m, _flags) { \ | |
893 | .bitrate = (rate100m), \ | |
894 | .flags = (_flags), \ | |
895 | .hw_value = (rate100m / 5), \ | |
896 | } | |
897 | ||
898 | static struct ieee80211_rate wl_legacy_ratetable[] = { | |
899 | RATE(10, 0), | |
900 | RATE(20, IEEE80211_RATE_SHORT_PREAMBLE), | |
901 | RATE(55, IEEE80211_RATE_SHORT_PREAMBLE), | |
902 | RATE(110, IEEE80211_RATE_SHORT_PREAMBLE), | |
903 | RATE(60, 0), | |
904 | RATE(90, 0), | |
905 | RATE(120, 0), | |
906 | RATE(180, 0), | |
907 | RATE(240, 0), | |
908 | RATE(360, 0), | |
909 | RATE(480, 0), | |
910 | RATE(540, 0), | |
911 | }; | |
912 | ||
913 | static struct ieee80211_supported_band wl_band_2GHz_nphy = { | |
914 | .band = IEEE80211_BAND_2GHZ, | |
915 | .channels = wl_2ghz_chantable, | |
916 | .n_channels = ARRAY_SIZE(wl_2ghz_chantable), | |
917 | .bitrates = wl_legacy_ratetable, | |
918 | .n_bitrates = ARRAY_SIZE(wl_legacy_ratetable), | |
919 | .ht_cap = { | |
920 | /* from include/linux/ieee80211.h */ | |
921 | .cap = IEEE80211_HT_CAP_GRN_FLD | | |
922 | IEEE80211_HT_CAP_SGI_20 | | |
923 | IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_40MHZ_INTOLERANT, | |
a9533e7e HP |
924 | .ht_supported = true, |
925 | .ampdu_factor = AMPDU_RX_FACTOR_64K, | |
a9533e7e HP |
926 | .ampdu_density = AMPDU_DEF_MPDU_DENSITY, |
927 | .mcs = { | |
928 | /* placeholders for now */ | |
a9533e7e HP |
929 | .rx_mask = {0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0}, |
930 | .rx_highest = 500, | |
a9533e7e HP |
931 | .tx_params = IEEE80211_HT_MCS_TX_DEFINED} |
932 | } | |
933 | }; | |
934 | ||
935 | static struct ieee80211_supported_band wl_band_5GHz_nphy = { | |
936 | .band = IEEE80211_BAND_5GHZ, | |
937 | .channels = wl_5ghz_nphy_chantable, | |
938 | .n_channels = ARRAY_SIZE(wl_5ghz_nphy_chantable), | |
939 | .bitrates = wl_legacy_ratetable + 4, | |
940 | .n_bitrates = ARRAY_SIZE(wl_legacy_ratetable) - 4, | |
941 | .ht_cap = { | |
942 | /* use IEEE80211_HT_CAP_* from include/linux/ieee80211.h */ | |
943 | .cap = IEEE80211_HT_CAP_GRN_FLD | IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_40MHZ_INTOLERANT, /* No 40 mhz yet */ | |
944 | .ht_supported = true, | |
945 | .ampdu_factor = AMPDU_RX_FACTOR_64K, | |
946 | .ampdu_density = AMPDU_DEF_MPDU_DENSITY, | |
947 | .mcs = { | |
948 | /* placeholders for now */ | |
949 | .rx_mask = {0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0}, | |
950 | .rx_highest = 500, | |
951 | .tx_params = IEEE80211_HT_MCS_TX_DEFINED} | |
952 | } | |
953 | }; | |
954 | ||
955 | static int ieee_hw_rate_init(struct ieee80211_hw *hw) | |
956 | { | |
2cb22a7a | 957 | struct wl_info *wl = HW_TO_WL(hw); |
a9533e7e HP |
958 | int has_5g; |
959 | char phy_list[4]; | |
960 | ||
961 | has_5g = 0; | |
962 | ||
963 | hw->wiphy->bands[IEEE80211_BAND_2GHZ] = NULL; | |
964 | hw->wiphy->bands[IEEE80211_BAND_5GHZ] = NULL; | |
965 | ||
966 | if (wlc_get(wl->wlc, WLC_GET_PHYLIST, (int *)&phy_list) < 0) { | |
f4528696 | 967 | WL_ERROR("Phy list failed\n"); |
a9533e7e | 968 | } |
f4528696 | 969 | WL_NONE("%s: phylist = %c\n", __func__, phy_list[0]); |
a9533e7e | 970 | |
a9533e7e HP |
971 | if (phy_list[0] == 'n' || phy_list[0] == 'c') { |
972 | if (phy_list[0] == 'c') { | |
973 | /* Single stream */ | |
974 | wl_band_2GHz_nphy.ht_cap.mcs.rx_mask[1] = 0; | |
975 | wl_band_2GHz_nphy.ht_cap.mcs.rx_highest = 72; | |
976 | } | |
a9533e7e HP |
977 | hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &wl_band_2GHz_nphy; |
978 | } else { | |
979 | BUG(); | |
90ea2296 | 980 | return -1; |
a9533e7e HP |
981 | } |
982 | ||
983 | /* Assume all bands use the same phy. True for 11n devices. */ | |
984 | if (NBANDS_PUB(wl->pub) > 1) { | |
985 | has_5g++; | |
a9533e7e | 986 | if (phy_list[0] == 'n' || phy_list[0] == 'c') { |
a9533e7e HP |
987 | hw->wiphy->bands[IEEE80211_BAND_5GHZ] = |
988 | &wl_band_5GHz_nphy; | |
989 | } else { | |
90ea2296 | 990 | return -1; |
a9533e7e HP |
991 | } |
992 | } | |
993 | ||
f4528696 | 994 | WL_NONE("%s: 2ghz = %d, 5ghz = %d\n", __func__, 1, has_5g); |
a9533e7e | 995 | |
90ea2296 | 996 | return 0; |
a9533e7e HP |
997 | } |
998 | ||
999 | static int ieee_hw_init(struct ieee80211_hw *hw) | |
1000 | { | |
1001 | hw->flags = IEEE80211_HW_SIGNAL_DBM | |
1002 | /* | IEEE80211_HW_CONNECTION_MONITOR What is this? */ | |
1003 | | IEEE80211_HW_REPORTS_TX_ACK_STATUS | |
1004 | | IEEE80211_HW_AMPDU_AGGREGATION; | |
1005 | ||
1006 | hw->extra_tx_headroom = wlc_get_header_len(); | |
1007 | /* FIXME: should get this from wlc->machwcap */ | |
1008 | hw->queues = 4; | |
1009 | /* FIXME: this doesn't seem to be used properly in minstrel_ht. | |
1010 | * mac80211/status.c:ieee80211_tx_status() checks this value, | |
1011 | * but mac80211/rc80211_minstrel_ht.c:minstrel_ht_get_rate() | |
1012 | * appears to always set 3 rates | |
1013 | */ | |
1014 | hw->max_rates = 2; /* Primary rate and 1 fallback rate */ | |
1015 | ||
1016 | hw->channel_change_time = 7 * 1000; /* channel change time is dependant on chip and band */ | |
1017 | hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION); | |
1018 | ||
1019 | hw->rate_control_algorithm = "minstrel_ht"; | |
1020 | ||
1021 | hw->sta_data_size = sizeof(struct scb); | |
90ea2296 | 1022 | return ieee_hw_rate_init(hw); |
a9533e7e HP |
1023 | } |
1024 | ||
a9533e7e HP |
1025 | /** |
1026 | * determines if a device is a WL device, and if so, attaches it. | |
1027 | * | |
1028 | * This function determines if a device pointed to by pdev is a WL device, | |
1029 | * and if so, performs a wl_attach() on it. | |
1030 | * | |
1031 | */ | |
1032 | int __devinit | |
1033 | wl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |
1034 | { | |
1035 | int rc; | |
2cb22a7a | 1036 | struct wl_info *wl; |
a9533e7e | 1037 | struct ieee80211_hw *hw; |
66cbd3ab | 1038 | u32 val; |
a9533e7e HP |
1039 | |
1040 | ASSERT(pdev); | |
1041 | ||
f4528696 JP |
1042 | WL_TRACE("%s: bus %d slot %d func %d irq %d\n", |
1043 | __func__, pdev->bus->number, PCI_SLOT(pdev->devfn), | |
1044 | PCI_FUNC(pdev->devfn), pdev->irq); | |
a9533e7e HP |
1045 | |
1046 | if ((pdev->vendor != PCI_VENDOR_ID_BROADCOM) || | |
1047 | (((pdev->device & 0xff00) != 0x4300) && | |
1048 | ((pdev->device & 0xff00) != 0x4700) && | |
1049 | ((pdev->device < 43000) || (pdev->device > 43999)))) | |
90ea2296 | 1050 | return -ENODEV; |
a9533e7e HP |
1051 | |
1052 | rc = pci_enable_device(pdev); | |
1053 | if (rc) { | |
f4528696 JP |
1054 | WL_ERROR("%s: Cannot enable device %d-%d_%d\n", |
1055 | __func__, pdev->bus->number, PCI_SLOT(pdev->devfn), | |
1056 | PCI_FUNC(pdev->devfn)); | |
90ea2296 | 1057 | return -ENODEV; |
a9533e7e HP |
1058 | } |
1059 | pci_set_master(pdev); | |
1060 | ||
1061 | pci_read_config_dword(pdev, 0x40, &val); | |
1062 | if ((val & 0x0000ff00) != 0) | |
1063 | pci_write_config_dword(pdev, 0x40, val & 0xffff00ff); | |
1064 | ||
2cb22a7a | 1065 | hw = ieee80211_alloc_hw(sizeof(struct wl_info), &wl_ops); |
a9533e7e | 1066 | if (!hw) { |
f4528696 | 1067 | WL_ERROR("%s: ieee80211_alloc_hw failed\n", __func__); |
a9533e7e HP |
1068 | rc = -ENOMEM; |
1069 | goto err_1; | |
1070 | } | |
1071 | ||
1072 | SET_IEEE80211_DEV(hw, &pdev->dev); | |
1073 | ||
1074 | pci_set_drvdata(pdev, hw); | |
1075 | ||
9249ede9 | 1076 | memset(hw->priv, 0, sizeof(*wl)); |
a9533e7e HP |
1077 | |
1078 | wl = wl_attach(pdev->vendor, pdev->device, pci_resource_start(pdev, 0), | |
1079 | PCI_BUS, pdev, pdev->irq); | |
1080 | ||
683b505b | 1081 | if (!wl) { |
f4528696 JP |
1082 | WL_ERROR("%s: %s: wl_attach failed!\n", |
1083 | KBUILD_MODNAME, __func__); | |
683b505b BR |
1084 | return -ENODEV; |
1085 | } | |
a9533e7e HP |
1086 | return 0; |
1087 | err_1: | |
f4528696 | 1088 | WL_ERROR("%s: err_1: Major hoarkage\n", __func__); |
a9533e7e HP |
1089 | return 0; |
1090 | } | |
1091 | ||
878a6673 | 1092 | static int wl_suspend(struct pci_dev *pdev, pm_message_t state) |
a9533e7e | 1093 | { |
2cb22a7a | 1094 | struct wl_info *wl; |
a9533e7e HP |
1095 | struct ieee80211_hw *hw; |
1096 | ||
f4528696 | 1097 | WL_TRACE("wl: wl_suspend\n"); |
a9533e7e HP |
1098 | |
1099 | hw = pci_get_drvdata(pdev); | |
1100 | wl = HW_TO_WL(hw); | |
1101 | if (!wl) { | |
f4528696 | 1102 | WL_ERROR("wl: wl_suspend: pci_get_drvdata failed\n"); |
a9533e7e HP |
1103 | return -ENODEV; |
1104 | } | |
1105 | ||
4032ec63 | 1106 | /* only need to flag hw is down for proper resume */ |
a9533e7e | 1107 | WL_LOCK(wl); |
0965ae88 | 1108 | wl->pub->hw_up = false; |
a9533e7e | 1109 | WL_UNLOCK(wl); |
4032ec63 AS |
1110 | |
1111 | pci_save_state(pdev); | |
a9533e7e HP |
1112 | pci_disable_device(pdev); |
1113 | return pci_set_power_state(pdev, PCI_D3hot); | |
1114 | } | |
1115 | ||
1116 | static int wl_resume(struct pci_dev *pdev) | |
1117 | { | |
2cb22a7a | 1118 | struct wl_info *wl; |
a9533e7e HP |
1119 | struct ieee80211_hw *hw; |
1120 | int err = 0; | |
66cbd3ab | 1121 | u32 val; |
a9533e7e | 1122 | |
f4528696 | 1123 | WL_TRACE("wl: wl_resume\n"); |
a9533e7e HP |
1124 | hw = pci_get_drvdata(pdev); |
1125 | wl = HW_TO_WL(hw); | |
1126 | if (!wl) { | |
f4528696 | 1127 | WL_ERROR("wl: wl_resume: pci_get_drvdata failed\n"); |
a9533e7e HP |
1128 | return -ENODEV; |
1129 | } | |
1130 | ||
1131 | err = pci_set_power_state(pdev, PCI_D0); | |
1132 | if (err) | |
1133 | return err; | |
1134 | ||
4032ec63 | 1135 | pci_restore_state(pdev); |
a9533e7e HP |
1136 | |
1137 | err = pci_enable_device(pdev); | |
1138 | if (err) | |
1139 | return err; | |
1140 | ||
1141 | pci_set_master(pdev); | |
1142 | ||
1143 | pci_read_config_dword(pdev, 0x40, &val); | |
1144 | if ((val & 0x0000ff00) != 0) | |
1145 | pci_write_config_dword(pdev, 0x40, val & 0xffff00ff); | |
1146 | ||
4032ec63 AS |
1147 | /* |
1148 | * done. driver will be put in up state | |
1149 | * in wl_ops_add_interface() call. | |
1150 | */ | |
90ea2296 | 1151 | return err; |
a9533e7e | 1152 | } |
a9533e7e | 1153 | |
6f0c5bcd | 1154 | static void wl_remove(struct pci_dev *pdev) |
a9533e7e | 1155 | { |
2cb22a7a | 1156 | struct wl_info *wl; |
a9533e7e HP |
1157 | struct ieee80211_hw *hw; |
1158 | ||
1159 | hw = pci_get_drvdata(pdev); | |
1160 | wl = HW_TO_WL(hw); | |
1161 | if (!wl) { | |
f4528696 | 1162 | WL_ERROR("wl: wl_remove: pci_get_drvdata failed\n"); |
a9533e7e HP |
1163 | return; |
1164 | } | |
5abb04a6 AS |
1165 | |
1166 | /* make sure rfkill is not using driver */ | |
1167 | wiphy_rfkill_set_hw_state(wl->pub->ieee_hw->wiphy, false); | |
1168 | wiphy_rfkill_stop_polling(wl->pub->ieee_hw->wiphy); | |
1169 | ||
a9533e7e | 1170 | if (!wlc_chipmatch(pdev->vendor, pdev->device)) { |
f4528696 | 1171 | WL_ERROR("wl: wl_remove: wlc_chipmatch failed\n"); |
a9533e7e HP |
1172 | return; |
1173 | } | |
683b505b BR |
1174 | if (wl->wlc) { |
1175 | ieee80211_unregister_hw(hw); | |
1176 | WL_LOCK(wl); | |
1177 | wl_down(wl); | |
1178 | WL_UNLOCK(wl); | |
f4528696 | 1179 | WL_NONE("%s: Down\n", __func__); |
683b505b | 1180 | } |
a9533e7e HP |
1181 | pci_disable_device(pdev); |
1182 | ||
1183 | wl_free(wl); | |
1184 | ||
1185 | pci_set_drvdata(pdev, NULL); | |
1186 | ieee80211_free_hw(hw); | |
1187 | } | |
1188 | ||
1189 | static struct pci_driver wl_pci_driver = { | |
949c3676 GKH |
1190 | .name = KBUILD_MODNAME, |
1191 | .probe = wl_pci_probe, | |
1192 | .suspend = wl_suspend, | |
1193 | .resume = wl_resume, | |
c836f77f AS |
1194 | .remove = __devexit_p(wl_remove), |
1195 | .id_table = wl_id_table, | |
a9533e7e | 1196 | }; |
a9533e7e HP |
1197 | |
1198 | /** | |
1199 | * This is the main entry point for the WL driver. | |
1200 | * | |
1201 | * This function determines if a device pointed to by pdev is a WL device, | |
1202 | * and if so, performs a wl_attach() on it. | |
1203 | * | |
1204 | */ | |
1205 | static int __init wl_module_init(void) | |
1206 | { | |
1207 | int error = -ENODEV; | |
1208 | ||
1209 | #ifdef BCMDBG | |
1210 | if (msglevel != 0xdeadbeef) | |
1211 | wl_msg_level = msglevel; | |
1212 | else { | |
1213 | char *var = getvar(NULL, "wl_msglevel"); | |
1214 | if (var) | |
48c51a8c | 1215 | wl_msg_level = simple_strtoul(var, NULL, 0); |
a9533e7e | 1216 | } |
a9533e7e | 1217 | { |
66cbd3ab | 1218 | extern u32 phyhal_msg_level; |
a9533e7e HP |
1219 | |
1220 | if (phymsglevel != 0xdeadbeef) | |
1221 | phyhal_msg_level = phymsglevel; | |
1222 | else { | |
1223 | char *var = getvar(NULL, "phy_msglevel"); | |
1224 | if (var) | |
48c51a8c | 1225 | phyhal_msg_level = simple_strtoul(var, NULL, 0); |
a9533e7e HP |
1226 | } |
1227 | } | |
a9533e7e HP |
1228 | #endif /* BCMDBG */ |
1229 | ||
8ba9cfdb | 1230 | error = pci_register_driver(&wl_pci_driver); |
ca8c1e59 | 1231 | if (!error) |
90ea2296 | 1232 | return 0; |
a9533e7e | 1233 | |
a9533e7e | 1234 | |
a9533e7e | 1235 | |
90ea2296 | 1236 | return error; |
a9533e7e HP |
1237 | } |
1238 | ||
1239 | /** | |
1240 | * This function unloads the WL driver from the system. | |
1241 | * | |
1242 | * This function unconditionally unloads the WL driver module from the | |
1243 | * system. | |
1244 | * | |
1245 | */ | |
1246 | static void __exit wl_module_exit(void) | |
1247 | { | |
a9533e7e | 1248 | pci_unregister_driver(&wl_pci_driver); |
a9533e7e | 1249 | |
a9533e7e HP |
1250 | } |
1251 | ||
1252 | module_init(wl_module_init); | |
1253 | module_exit(wl_module_exit); | |
1254 | ||
1255 | /** | |
1256 | * This function frees the WL per-device resources. | |
1257 | * | |
1258 | * This function frees resources owned by the WL device pointed to | |
1259 | * by the wl parameter. | |
1260 | * | |
1261 | */ | |
2cb22a7a | 1262 | void wl_free(struct wl_info *wl) |
a9533e7e HP |
1263 | { |
1264 | wl_timer_t *t, *next; | |
e69284f2 | 1265 | struct osl_info *osh; |
a9533e7e HP |
1266 | |
1267 | ASSERT(wl); | |
a9533e7e HP |
1268 | /* free ucode data */ |
1269 | if (wl->fw.fw_cnt) | |
1270 | wl_ucode_data_free(); | |
a9533e7e HP |
1271 | if (wl->irq) |
1272 | free_irq(wl->irq, wl); | |
a9533e7e HP |
1273 | |
1274 | /* kill dpc */ | |
1275 | tasklet_kill(&wl->tasklet); | |
1276 | ||
1277 | if (wl->pub) { | |
1278 | wlc_module_unregister(wl->pub, "linux", wl); | |
1279 | } | |
1280 | ||
1281 | /* free common resources */ | |
1282 | if (wl->wlc) { | |
1283 | wlc_detach(wl->wlc); | |
1284 | wl->wlc = NULL; | |
1285 | wl->pub = NULL; | |
1286 | } | |
1287 | ||
1288 | /* virtual interface deletion is deferred so we cannot spinwait */ | |
1289 | ||
1290 | /* wait for all pending callbacks to complete */ | |
1291 | while (atomic_read(&wl->callbacks) > 0) | |
1292 | schedule(); | |
1293 | ||
1294 | /* free timers */ | |
1295 | for (t = wl->timers; t; t = next) { | |
1296 | next = t->next; | |
1297 | #ifdef BCMDBG | |
1298 | if (t->name) | |
182acb3c | 1299 | kfree(t->name); |
a9533e7e | 1300 | #endif |
182acb3c | 1301 | kfree(t); |
a9533e7e HP |
1302 | } |
1303 | ||
a9533e7e HP |
1304 | osh = wl->osh; |
1305 | ||
1306 | /* | |
1307 | * unregister_netdev() calls get_stats() which may read chip registers | |
1308 | * so we cannot unmap the chip registers until after calling unregister_netdev() . | |
1309 | */ | |
fa7a1db2 BR |
1310 | if (wl->regsva && wl->bcm_bustype != SDIO_BUS && |
1311 | wl->bcm_bustype != JTAG_BUS) { | |
a9533e7e HP |
1312 | iounmap((void *)wl->regsva); |
1313 | } | |
1314 | wl->regsva = NULL; | |
1315 | ||
a9533e7e | 1316 | |
a9533e7e HP |
1317 | osl_detach(osh); |
1318 | } | |
1319 | ||
a9533e7e | 1320 | /* transmit a packet */ |
2cb22a7a | 1321 | static int BCMFASTPATH wl_start(struct sk_buff *skb, struct wl_info *wl) |
a9533e7e HP |
1322 | { |
1323 | if (!wl) | |
1324 | return -ENETDOWN; | |
1325 | ||
1326 | return wl_start_int(wl, WL_TO_HW(wl), skb); | |
1327 | } | |
a9533e7e HP |
1328 | |
1329 | static int BCMFASTPATH | |
2cb22a7a | 1330 | wl_start_int(struct wl_info *wl, struct ieee80211_hw *hw, struct sk_buff *skb) |
a9533e7e | 1331 | { |
a9533e7e | 1332 | wlc_sendpkt_mac80211(wl->wlc, skb, hw); |
90ea2296 | 1333 | return NETDEV_TX_OK; |
a9533e7e HP |
1334 | } |
1335 | ||
2cb22a7a RV |
1336 | void wl_txflowcontrol(struct wl_info *wl, struct wl_if *wlif, bool state, |
1337 | int prio) | |
a9533e7e | 1338 | { |
f4528696 | 1339 | WL_ERROR("Shouldn't be here %s\n", __func__); |
a9533e7e HP |
1340 | } |
1341 | ||
2cb22a7a | 1342 | void wl_init(struct wl_info *wl) |
a9533e7e | 1343 | { |
f4528696 | 1344 | WL_TRACE("wl%d: wl_init\n", wl->pub->unit); |
a9533e7e HP |
1345 | |
1346 | wl_reset(wl); | |
1347 | ||
1348 | wlc_init(wl->wlc); | |
1349 | } | |
1350 | ||
2cb22a7a | 1351 | uint wl_reset(struct wl_info *wl) |
a9533e7e | 1352 | { |
f4528696 | 1353 | WL_TRACE("wl%d: wl_reset\n", wl->pub->unit); |
a9533e7e HP |
1354 | |
1355 | wlc_reset(wl->wlc); | |
1356 | ||
1357 | /* dpc will not be rescheduled */ | |
1358 | wl->resched = 0; | |
1359 | ||
90ea2296 | 1360 | return 0; |
a9533e7e HP |
1361 | } |
1362 | ||
1363 | /* | |
1364 | * These are interrupt on/off entry points. Disable interrupts | |
1365 | * during interrupt state transition. | |
1366 | */ | |
2cb22a7a | 1367 | void BCMFASTPATH wl_intrson(struct wl_info *wl) |
a9533e7e | 1368 | { |
a9533e7e HP |
1369 | unsigned long flags; |
1370 | ||
1371 | INT_LOCK(wl, flags); | |
1372 | wlc_intrson(wl->wlc); | |
1373 | INT_UNLOCK(wl, flags); | |
a9533e7e HP |
1374 | } |
1375 | ||
2cb22a7a | 1376 | bool wl_alloc_dma_resources(struct wl_info *wl, uint addrwidth) |
a9533e7e | 1377 | { |
0f0881b0 | 1378 | return true; |
a9533e7e HP |
1379 | } |
1380 | ||
2cb22a7a | 1381 | u32 BCMFASTPATH wl_intrsoff(struct wl_info *wl) |
a9533e7e | 1382 | { |
a9533e7e | 1383 | unsigned long flags; |
66cbd3ab | 1384 | u32 status; |
a9533e7e HP |
1385 | |
1386 | INT_LOCK(wl, flags); | |
1387 | status = wlc_intrsoff(wl->wlc); | |
1388 | INT_UNLOCK(wl, flags); | |
1389 | return status; | |
a9533e7e HP |
1390 | } |
1391 | ||
2cb22a7a | 1392 | void wl_intrsrestore(struct wl_info *wl, u32 macintmask) |
a9533e7e | 1393 | { |
a9533e7e HP |
1394 | unsigned long flags; |
1395 | ||
1396 | INT_LOCK(wl, flags); | |
1397 | wlc_intrsrestore(wl->wlc, macintmask); | |
1398 | INT_UNLOCK(wl, flags); | |
a9533e7e HP |
1399 | } |
1400 | ||
2cb22a7a | 1401 | int wl_up(struct wl_info *wl) |
a9533e7e HP |
1402 | { |
1403 | int error = 0; | |
1404 | ||
1405 | if (wl->pub->up) | |
90ea2296 | 1406 | return 0; |
a9533e7e HP |
1407 | |
1408 | error = wlc_up(wl->wlc); | |
1409 | ||
90ea2296 | 1410 | return error; |
a9533e7e HP |
1411 | } |
1412 | ||
2cb22a7a | 1413 | void wl_down(struct wl_info *wl) |
a9533e7e HP |
1414 | { |
1415 | uint callbacks, ret_val = 0; | |
1416 | ||
1417 | /* call common down function */ | |
1418 | ret_val = wlc_down(wl->wlc); | |
1419 | callbacks = atomic_read(&wl->callbacks) - ret_val; | |
1420 | ||
1421 | /* wait for down callbacks to complete */ | |
1422 | WL_UNLOCK(wl); | |
1423 | ||
a9533e7e HP |
1424 | /* For HIGH_only driver, it's important to actually schedule other work, |
1425 | * not just spin wait since everything runs at schedule level | |
1426 | */ | |
1427 | SPINWAIT((atomic_read(&wl->callbacks) > callbacks), 100 * 1000); | |
a9533e7e HP |
1428 | |
1429 | WL_LOCK(wl); | |
1430 | } | |
1431 | ||
1432 | irqreturn_t BCMFASTPATH wl_isr(int irq, void *dev_id) | |
1433 | { | |
2cb22a7a | 1434 | struct wl_info *wl; |
a9533e7e HP |
1435 | bool ours, wantdpc; |
1436 | unsigned long flags; | |
1437 | ||
2cb22a7a | 1438 | wl = (struct wl_info *) dev_id; |
a9533e7e HP |
1439 | |
1440 | WL_ISRLOCK(wl, flags); | |
1441 | ||
1442 | /* call common first level interrupt handler */ | |
ca8c1e59 JC |
1443 | ours = wlc_isr(wl->wlc, &wantdpc); |
1444 | if (ours) { | |
a9533e7e HP |
1445 | /* if more to do... */ |
1446 | if (wantdpc) { | |
1447 | ||
1448 | /* ...and call the second level interrupt handler */ | |
1449 | /* schedule dpc */ | |
0965ae88 | 1450 | ASSERT(wl->resched == false); |
a9533e7e HP |
1451 | tasklet_schedule(&wl->tasklet); |
1452 | } | |
1453 | } | |
1454 | ||
1455 | WL_ISRUNLOCK(wl, flags); | |
1456 | ||
1457 | return IRQ_RETVAL(ours); | |
a9533e7e HP |
1458 | } |
1459 | ||
3deea904 | 1460 | static void BCMFASTPATH wl_dpc(unsigned long data) |
a9533e7e | 1461 | { |
2cb22a7a | 1462 | struct wl_info *wl; |
a9533e7e | 1463 | |
2cb22a7a | 1464 | wl = (struct wl_info *) data; |
a9533e7e HP |
1465 | |
1466 | WL_LOCK(wl); | |
1467 | ||
1468 | /* call the common second level interrupt handler */ | |
1469 | if (wl->pub->up) { | |
1470 | if (wl->resched) { | |
1471 | unsigned long flags; | |
1472 | ||
1473 | INT_LOCK(wl, flags); | |
1474 | wlc_intrsupd(wl->wlc); | |
1475 | INT_UNLOCK(wl, flags); | |
1476 | } | |
1477 | ||
0f0881b0 | 1478 | wl->resched = wlc_dpc(wl->wlc, true); |
a9533e7e HP |
1479 | } |
1480 | ||
1481 | /* wlc_dpc() may bring the driver down */ | |
1482 | if (!wl->pub->up) | |
1483 | goto done; | |
1484 | ||
1485 | /* re-schedule dpc */ | |
1486 | if (wl->resched) | |
1487 | tasklet_schedule(&wl->tasklet); | |
1488 | else { | |
1489 | /* re-enable interrupts */ | |
1490 | wl_intrson(wl); | |
1491 | } | |
1492 | ||
1493 | done: | |
1494 | WL_UNLOCK(wl); | |
a9533e7e HP |
1495 | } |
1496 | ||
2cb22a7a | 1497 | static void wl_link_up(struct wl_info *wl, char *ifname) |
a9533e7e | 1498 | { |
f4528696 | 1499 | WL_ERROR("wl%d: link up (%s)\n", wl->pub->unit, ifname); |
a9533e7e HP |
1500 | } |
1501 | ||
2cb22a7a | 1502 | static void wl_link_down(struct wl_info *wl, char *ifname) |
a9533e7e | 1503 | { |
f4528696 | 1504 | WL_ERROR("wl%d: link down (%s)\n", wl->pub->unit, ifname); |
a9533e7e HP |
1505 | } |
1506 | ||
2cb22a7a | 1507 | void wl_event(struct wl_info *wl, char *ifname, wlc_event_t *e) |
a9533e7e HP |
1508 | { |
1509 | ||
1510 | switch (e->event.event_type) { | |
1511 | case WLC_E_LINK: | |
1512 | case WLC_E_NDIS_LINK: | |
1513 | if (e->event.flags & WLC_EVENT_MSG_LINK) | |
1514 | wl_link_up(wl, ifname); | |
1515 | else | |
1516 | wl_link_down(wl, ifname); | |
1517 | break; | |
1518 | case WLC_E_RADIO: | |
1519 | break; | |
1520 | } | |
1521 | } | |
1522 | ||
3deea904 | 1523 | static void wl_timer(unsigned long data) |
a9533e7e | 1524 | { |
a9533e7e | 1525 | _wl_timer((wl_timer_t *) data); |
a9533e7e HP |
1526 | } |
1527 | ||
7cc4a4c0 | 1528 | static void _wl_timer(wl_timer_t *t) |
a9533e7e HP |
1529 | { |
1530 | WL_LOCK(t->wl); | |
1531 | ||
1532 | if (t->set) { | |
1533 | if (t->periodic) { | |
1534 | t->timer.expires = jiffies + t->ms * HZ / 1000; | |
1535 | atomic_inc(&t->wl->callbacks); | |
1536 | add_timer(&t->timer); | |
0f0881b0 | 1537 | t->set = true; |
a9533e7e | 1538 | } else |
0965ae88 | 1539 | t->set = false; |
a9533e7e HP |
1540 | |
1541 | t->fn(t->arg); | |
1542 | } | |
1543 | ||
1544 | atomic_dec(&t->wl->callbacks); | |
1545 | ||
1546 | WL_UNLOCK(t->wl); | |
1547 | } | |
1548 | ||
2cb22a7a | 1549 | wl_timer_t *wl_init_timer(struct wl_info *wl, void (*fn) (void *arg), void *arg, |
a9533e7e HP |
1550 | const char *name) |
1551 | { | |
1552 | wl_timer_t *t; | |
1553 | ||
5fcc1fcb | 1554 | t = kmalloc(sizeof(wl_timer_t), GFP_ATOMIC); |
ca8c1e59 | 1555 | if (!t) { |
f4528696 | 1556 | WL_ERROR("wl%d: wl_init_timer: out of memory\n", wl->pub->unit); |
a9533e7e HP |
1557 | return 0; |
1558 | } | |
1559 | ||
9249ede9 | 1560 | memset(t, 0, sizeof(wl_timer_t)); |
a9533e7e HP |
1561 | |
1562 | init_timer(&t->timer); | |
3deea904 | 1563 | t->timer.data = (unsigned long) t; |
a9533e7e HP |
1564 | t->timer.function = wl_timer; |
1565 | t->wl = wl; | |
1566 | t->fn = fn; | |
1567 | t->arg = arg; | |
1568 | t->next = wl->timers; | |
1569 | wl->timers = t; | |
1570 | ||
1571 | #ifdef BCMDBG | |
5fcc1fcb | 1572 | t->name = kmalloc(strlen(name) + 1, GFP_ATOMIC); |
ca8c1e59 | 1573 | if (t->name) |
a9533e7e HP |
1574 | strcpy(t->name, name); |
1575 | #endif | |
1576 | ||
1577 | return t; | |
1578 | } | |
1579 | ||
1580 | /* BMAC_NOTE: Add timer adds only the kernel timer since it's going to be more accurate | |
1581 | * as well as it's easier to make it periodic | |
1582 | */ | |
2cb22a7a | 1583 | void wl_add_timer(struct wl_info *wl, wl_timer_t *t, uint ms, int periodic) |
a9533e7e HP |
1584 | { |
1585 | #ifdef BCMDBG | |
1586 | if (t->set) { | |
f4528696 JP |
1587 | WL_ERROR("%s: Already set. Name: %s, per %d\n", |
1588 | __func__, t->name, periodic); | |
a9533e7e HP |
1589 | } |
1590 | #endif | |
1591 | ASSERT(!t->set); | |
1592 | ||
1593 | t->ms = ms; | |
1594 | t->periodic = (bool) periodic; | |
0f0881b0 | 1595 | t->set = true; |
a9533e7e HP |
1596 | t->timer.expires = jiffies + ms * HZ / 1000; |
1597 | ||
1598 | atomic_inc(&wl->callbacks); | |
1599 | add_timer(&t->timer); | |
1600 | } | |
1601 | ||
0965ae88 | 1602 | /* return true if timer successfully deleted, false if still pending */ |
2cb22a7a | 1603 | bool wl_del_timer(struct wl_info *wl, wl_timer_t *t) |
a9533e7e HP |
1604 | { |
1605 | if (t->set) { | |
0965ae88 | 1606 | t->set = false; |
a9533e7e | 1607 | if (!del_timer(&t->timer)) { |
0965ae88 | 1608 | return false; |
a9533e7e HP |
1609 | } |
1610 | atomic_dec(&wl->callbacks); | |
1611 | } | |
1612 | ||
0f0881b0 | 1613 | return true; |
a9533e7e HP |
1614 | } |
1615 | ||
2cb22a7a | 1616 | void wl_free_timer(struct wl_info *wl, wl_timer_t *t) |
a9533e7e HP |
1617 | { |
1618 | wl_timer_t *tmp; | |
1619 | ||
1620 | /* delete the timer in case it is active */ | |
1621 | wl_del_timer(wl, t); | |
1622 | ||
1623 | if (wl->timers == t) { | |
1624 | wl->timers = wl->timers->next; | |
1625 | #ifdef BCMDBG | |
1626 | if (t->name) | |
182acb3c | 1627 | kfree(t->name); |
a9533e7e | 1628 | #endif |
182acb3c | 1629 | kfree(t); |
a9533e7e HP |
1630 | return; |
1631 | ||
1632 | } | |
1633 | ||
1634 | tmp = wl->timers; | |
1635 | while (tmp) { | |
1636 | if (tmp->next == t) { | |
1637 | tmp->next = t->next; | |
1638 | #ifdef BCMDBG | |
1639 | if (t->name) | |
182acb3c | 1640 | kfree(t->name); |
a9533e7e | 1641 | #endif |
182acb3c | 1642 | kfree(t); |
a9533e7e HP |
1643 | return; |
1644 | } | |
1645 | tmp = tmp->next; | |
1646 | } | |
1647 | ||
1648 | } | |
1649 | ||
1650 | static int wl_linux_watchdog(void *ctx) | |
1651 | { | |
2cb22a7a | 1652 | struct wl_info *wl = (struct wl_info *) ctx; |
a9533e7e HP |
1653 | struct net_device_stats *stats = NULL; |
1654 | uint id; | |
1655 | /* refresh stats */ | |
1656 | if (wl->pub->up) { | |
1657 | ASSERT(wl->stats_id < 2); | |
1658 | ||
1659 | id = 1 - wl->stats_id; | |
1660 | ||
1661 | stats = &wl->stats_watchdog[id]; | |
1662 | stats->rx_packets = WLCNTVAL(wl->pub->_cnt->rxframe); | |
1663 | stats->tx_packets = WLCNTVAL(wl->pub->_cnt->txframe); | |
1664 | stats->rx_bytes = WLCNTVAL(wl->pub->_cnt->rxbyte); | |
1665 | stats->tx_bytes = WLCNTVAL(wl->pub->_cnt->txbyte); | |
1666 | stats->rx_errors = WLCNTVAL(wl->pub->_cnt->rxerror); | |
1667 | stats->tx_errors = WLCNTVAL(wl->pub->_cnt->txerror); | |
1668 | stats->collisions = 0; | |
1669 | ||
1670 | stats->rx_length_errors = 0; | |
1671 | stats->rx_over_errors = WLCNTVAL(wl->pub->_cnt->rxoflo); | |
1672 | stats->rx_crc_errors = WLCNTVAL(wl->pub->_cnt->rxcrc); | |
1673 | stats->rx_frame_errors = 0; | |
1674 | stats->rx_fifo_errors = WLCNTVAL(wl->pub->_cnt->rxoflo); | |
1675 | stats->rx_missed_errors = 0; | |
1676 | ||
1677 | stats->tx_fifo_errors = WLCNTVAL(wl->pub->_cnt->txuflo); | |
1678 | ||
1679 | wl->stats_id = id; | |
1680 | ||
1681 | } | |
1682 | ||
1683 | return 0; | |
1684 | } | |
1685 | ||
1686 | struct wl_fw_hdr { | |
66cbd3ab GKH |
1687 | u32 offset; |
1688 | u32 len; | |
1689 | u32 idx; | |
a9533e7e HP |
1690 | }; |
1691 | ||
a9533e7e HP |
1692 | char *wl_firmwares[WL_MAX_FW] = { |
1693 | "brcm/bcm43xx", | |
1694 | NULL | |
1695 | }; | |
1696 | ||
2cb22a7a | 1697 | int wl_ucode_init_buf(struct wl_info *wl, void **pbuf, u32 idx) |
a9533e7e HP |
1698 | { |
1699 | int i, entry; | |
41feb5ed | 1700 | const u8 *pdata; |
a9533e7e HP |
1701 | struct wl_fw_hdr *hdr; |
1702 | for (i = 0; i < wl->fw.fw_cnt; i++) { | |
1703 | hdr = (struct wl_fw_hdr *)wl->fw.fw_hdr[i]->data; | |
1704 | for (entry = 0; entry < wl->fw.hdr_num_entries[i]; | |
1705 | entry++, hdr++) { | |
1706 | if (hdr->idx == idx) { | |
1707 | pdata = wl->fw.fw_bin[i]->data + hdr->offset; | |
1708 | *pbuf = kmalloc(hdr->len, GFP_ATOMIC); | |
1709 | if (*pbuf == NULL) { | |
1710 | printf("fail to alloc %d bytes\n", | |
1711 | hdr->len); | |
1712 | } | |
1713 | bcopy(pdata, *pbuf, hdr->len); | |
1714 | return 0; | |
1715 | } | |
1716 | } | |
1717 | } | |
1718 | printf("ERROR: ucode buf tag:%d can not be found!\n", idx); | |
1719 | *pbuf = NULL; | |
1720 | return -1; | |
1721 | } | |
1722 | ||
2cb22a7a | 1723 | int wl_ucode_init_uint(struct wl_info *wl, u32 *data, u32 idx) |
a9533e7e HP |
1724 | { |
1725 | int i, entry; | |
41feb5ed | 1726 | const u8 *pdata; |
a9533e7e HP |
1727 | struct wl_fw_hdr *hdr; |
1728 | for (i = 0; i < wl->fw.fw_cnt; i++) { | |
1729 | hdr = (struct wl_fw_hdr *)wl->fw.fw_hdr[i]->data; | |
1730 | for (entry = 0; entry < wl->fw.hdr_num_entries[i]; | |
1731 | entry++, hdr++) { | |
1732 | if (hdr->idx == idx) { | |
1733 | pdata = wl->fw.fw_bin[i]->data + hdr->offset; | |
1734 | ASSERT(hdr->len == 4); | |
66cbd3ab | 1735 | *data = *((u32 *) pdata); |
a9533e7e HP |
1736 | return 0; |
1737 | } | |
1738 | } | |
1739 | } | |
1740 | printf("ERROR: ucode tag:%d can not be found!\n", idx); | |
1741 | return -1; | |
1742 | } | |
a9533e7e | 1743 | |
2cb22a7a | 1744 | static int wl_request_fw(struct wl_info *wl, struct pci_dev *pdev) |
a9533e7e HP |
1745 | { |
1746 | int status; | |
1747 | struct device *device = &pdev->dev; | |
1748 | char fw_name[100]; | |
1749 | int i; | |
1750 | ||
9249ede9 | 1751 | memset((void *)&wl->fw, 0, sizeof(struct wl_firmware)); |
a9533e7e HP |
1752 | for (i = 0; i < WL_MAX_FW; i++) { |
1753 | if (wl_firmwares[i] == NULL) | |
1754 | break; | |
1755 | sprintf(fw_name, "%s-%d.fw", wl_firmwares[i], | |
1756 | UCODE_LOADER_API_VER); | |
f4528696 | 1757 | WL_NONE("request fw %s\n", fw_name); |
a9533e7e HP |
1758 | status = request_firmware(&wl->fw.fw_bin[i], fw_name, device); |
1759 | if (status) { | |
683b505b BR |
1760 | printf("%s: fail to load firmware %s\n", |
1761 | KBUILD_MODNAME, fw_name); | |
eb4764c3 | 1762 | wl_release_fw(wl); |
a9533e7e HP |
1763 | return status; |
1764 | } | |
f4528696 | 1765 | WL_NONE("request fw %s\n", fw_name); |
a9533e7e HP |
1766 | sprintf(fw_name, "%s_hdr-%d.fw", wl_firmwares[i], |
1767 | UCODE_LOADER_API_VER); | |
1768 | status = request_firmware(&wl->fw.fw_hdr[i], fw_name, device); | |
1769 | if (status) { | |
683b505b BR |
1770 | printf("%s: fail to load firmware %s\n", |
1771 | KBUILD_MODNAME, fw_name); | |
eb4764c3 | 1772 | wl_release_fw(wl); |
a9533e7e HP |
1773 | return status; |
1774 | } | |
1775 | wl->fw.hdr_num_entries[i] = | |
1776 | wl->fw.fw_hdr[i]->size / (sizeof(struct wl_fw_hdr)); | |
f4528696 JP |
1777 | WL_NONE("request fw %s find: %d entries\n", |
1778 | fw_name, wl->fw.hdr_num_entries[i]); | |
a9533e7e HP |
1779 | } |
1780 | wl->fw.fw_cnt = i; | |
3d44661a | 1781 | return wl_ucode_data_init(wl); |
a9533e7e HP |
1782 | } |
1783 | ||
a9533e7e HP |
1784 | void wl_ucode_free_buf(void *p) |
1785 | { | |
1786 | kfree(p); | |
1787 | } | |
a9533e7e | 1788 | |
2cb22a7a | 1789 | static void wl_release_fw(struct wl_info *wl) |
a9533e7e HP |
1790 | { |
1791 | int i; | |
eb4764c3 | 1792 | for (i = 0; i < WL_MAX_FW; i++) { |
a9533e7e HP |
1793 | release_firmware(wl->fw.fw_bin[i]); |
1794 | release_firmware(wl->fw.fw_hdr[i]); | |
1795 | } | |
1796 | } | |
3d44661a RV |
1797 | |
1798 | ||
1799 | /* | |
1800 | * checks validity of all firmware images loaded from user space | |
1801 | */ | |
1802 | int wl_check_firmwares(struct wl_info *wl) | |
1803 | { | |
1804 | int i; | |
1805 | int entry; | |
1806 | int rc = 0; | |
1807 | const struct firmware *fw; | |
1808 | const struct firmware *fw_hdr; | |
1809 | struct wl_fw_hdr *ucode_hdr; | |
1810 | for (i = 0; i < WL_MAX_FW && rc == 0; i++) { | |
1811 | fw = wl->fw.fw_bin[i]; | |
1812 | fw_hdr = wl->fw.fw_hdr[i]; | |
1813 | if (fw == NULL && fw_hdr == NULL) { | |
1814 | break; | |
1815 | } else if (fw == NULL || fw_hdr == NULL) { | |
f4528696 | 1816 | WL_ERROR("%s: invalid bin/hdr fw\n", __func__); |
3d44661a RV |
1817 | rc = -EBADF; |
1818 | } else if (fw_hdr->size % sizeof(struct wl_fw_hdr)) { | |
f4528696 JP |
1819 | WL_ERROR("%s: non integral fw hdr file size %d/%zu\n", |
1820 | __func__, fw_hdr->size, | |
1821 | sizeof(struct wl_fw_hdr)); | |
3d44661a RV |
1822 | rc = -EBADF; |
1823 | } else if (fw->size < MIN_FW_SIZE || fw->size > MAX_FW_SIZE) { | |
f4528696 JP |
1824 | WL_ERROR("%s: out of bounds fw file size %d\n", |
1825 | __func__, fw->size); | |
3d44661a RV |
1826 | rc = -EBADF; |
1827 | } else { | |
1828 | /* check if ucode section overruns firmware image */ | |
1829 | ucode_hdr = (struct wl_fw_hdr *)fw_hdr->data; | |
1830 | for (entry = 0; entry < wl->fw.hdr_num_entries[i] && rc; | |
1831 | entry++, ucode_hdr++) { | |
1832 | if (ucode_hdr->offset + ucode_hdr->len > | |
1833 | fw->size) { | |
f4528696 JP |
1834 | WL_ERROR("%s: conflicting bin/hdr\n", |
1835 | __func__); | |
3d44661a RV |
1836 | rc = -EBADF; |
1837 | } | |
1838 | } | |
1839 | } | |
1840 | } | |
1841 | if (rc == 0 && wl->fw.fw_cnt != i) { | |
f4528696 | 1842 | WL_ERROR("%s: invalid fw_cnt=%d\n", __func__, wl->fw.fw_cnt); |
3d44661a RV |
1843 | rc = -EBADF; |
1844 | } | |
1845 | return rc; | |
1846 | } | |
1847 | ||
5abb04a6 AS |
1848 | bool wl_rfkill_set_hw_state(struct wl_info *wl) |
1849 | { | |
1850 | bool blocked = wlc_check_radio_disabled(wl->wlc); | |
1851 | ||
1852 | WL_ERROR("%s: update hw state: blocked=%s\n", __func__, blocked ? "true" : "false"); | |
1853 | wiphy_rfkill_set_hw_state(wl->pub->ieee_hw->wiphy, blocked); | |
1854 | if (blocked) | |
1855 | wiphy_rfkill_start_polling(wl->pub->ieee_hw->wiphy); | |
1856 | return blocked; | |
1857 | } |