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