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